trimmer display improvement

This commit is contained in:
bancika
2017-01-12 17:39:10 +01:00
parent 58bf48d8ac
commit e4cf9d5fda
4 changed files with 14 additions and 13 deletions
Binary file not shown.
@@ -338,18 +338,6 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
: LABEL_COLOR; : LABEL_COLOR;
} }
g2d.setColor(finalLabelColor);
FontMetrics fontMetrics = g2d.getFontMetrics();
Rectangle2D bodyRect = getBody()[0].getBounds2D();
Rectangle2D rect = fontMetrics.getStringBounds(getName(), g2d);
int textHeight = (int) rect.getHeight();
int textWidth = (int) rect.getWidth();
int panelHeight = (int) bodyRect.getHeight();
int panelWidth = (int) bodyRect.getWidth();
int x = (panelWidth - textWidth) / 2;
int y = (panelHeight - textHeight) / 2 + fontMetrics.getAscent();
String label = ""; String label = "";
label = (getDisplay() == Display.NAME) ? getName() : (getValue() == null ? "" : getValue().toString()); label = (getDisplay() == Display.NAME) ? getName() : (getValue() == null ? "" : getValue().toString());
@@ -360,6 +348,19 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
label = getName() + " " + (getValue() == null ? "" : getValue().toString()); label = getName() + " " + (getValue() == null ? "" : getValue().toString());
} }
g2d.setColor(finalLabelColor);
FontMetrics fontMetrics = g2d.getFontMetrics();
Rectangle2D bodyRect = getBody()[0].getBounds2D();
Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
int textHeight = (int) rect.getHeight();
int textWidth = (int) rect.getWidth();
int panelHeight = (int) bodyRect.getHeight();
int panelWidth = (int) bodyRect.getWidth();
int x = (panelWidth - textWidth) / 2;
int y = (panelHeight - textHeight) / 2 + fontMetrics.getAscent();
g2d.drawString(label, (int) (bodyRect.getX() + x), (int) (bodyRect.getY() + y)); g2d.drawString(label, (int) (bodyRect.getX() + x), (int) (bodyRect.getY() + y));
} }
Binary file not shown.
Binary file not shown.