mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
trimmer display improvement
This commit is contained in:
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.
Reference in New Issue
Block a user