This commit is contained in:
serso
2011-12-14 02:47:04 +04:00
parent 780d278fda
commit 848012615e
33 changed files with 298 additions and 211 deletions

View File

@@ -120,7 +120,18 @@ public class DirectionDragButton extends DragButton {
@NotNull
@Override
public Point2d getTextPosition(@NotNull Paint paint, @NotNull Paint basePaint, @NotNull CharSequence text, CharSequence baseText, int w, int h) {
throw new UnsupportedOperationException("Not implemented yet!");
final Point2d result = new Point2d();
float width = paint.measureText(" ");
result.setX(width);
float selfHeight = paint.ascent() + paint.descent();
basePaint.measureText(StringUtils.getNotEmpty(baseText, "|"));
result.setY(h / 2 - selfHeight / 2);
return result;
}
}/*,
right(DragDirection.right) {
@@ -163,9 +174,9 @@ public class DirectionDragButton extends DragButton {
}
@Nullable
public static GuiDragDirection valueOf ( @NotNull DragDirection dragDirection ) {
public static GuiDragDirection valueOf(@NotNull DragDirection dragDirection) {
for (GuiDragDirection guiDragDirection : values()) {
if ( guiDragDirection.dragDirection == dragDirection ) {
if (guiDragDirection.dragDirection == dragDirection) {
return guiDragDirection;
}
}
@@ -204,7 +215,7 @@ public class DirectionDragButton extends DragButton {
default:
// try drag direction text
for (GuiDragDirection guiDragDirection : GuiDragDirection.values()) {
if ( guiDragDirection.getAttributeId() == attr ) {
if (guiDragDirection.getAttributeId() == attr) {
this.directionTextDataMap.put(guiDragDirection, new DirectionTextData(guiDragDirection, attrValue));
break;
}

View File

@@ -62,6 +62,7 @@ public class SimpleOnDragListener implements OnDragListener, DragPreferencesChan
DragDirection direction = null;
for (Map.Entry<DragDirection, DragPreference> directionEntry : distancePreferences.getDirectionPreferences().entrySet()) {
Log.d(String.valueOf(dragButton.getId()), "Drag direction: " + directionEntry.getKey());
Log.d(String.valueOf(dragButton.getId()), "Trying direction interval: " + directionEntry.getValue().getInterval());
if (isInInterval(directionEntry.getValue().getInterval(), distance)) {
@@ -180,7 +181,7 @@ public class SimpleOnDragListener implements OnDragListener, DragPreferencesChan
transformInterval(preferenceType, dragDirection, intervalPref);
Log.d(SimpleOnDragListener.class.getName(), "Preference loaded. Id: " + preferenceId + ", value: " + intervalPref.toString());
Log.d(SimpleOnDragListener.class.getName(), "Preference loaded for " + dragDirection +". Id: " + preferenceId + ", value: " + intervalPref.toString());
final DragPreference directionPreference = new DragPreference(dragDirection, intervalPref);
@@ -207,9 +208,12 @@ public class SimpleOnDragListener implements OnDragListener, DragPreferencesChan
if (dragDirection == DragDirection.up) {
interval.setLeftBorder(180f - rightBorder);
interval.setRightBorder(180f - leftBorder);
} else if (dragDirection == DragDirection.left || dragDirection == DragDirection.right) {
} else if (dragDirection == DragDirection.left ) {
interval.setLeftBorder(90f - rightBorder / 2);
interval.setRightBorder(90f + leftBorder / 2);
interval.setRightBorder(90f + rightBorder / 2);
} else if ( dragDirection == DragDirection.right ) {
interval.setLeftBorder(180f + 90f - rightBorder / 2);
interval.setRightBorder(180f + 90f + rightBorder / 2);
}
}