mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-12 02:02:16 +10:00
object optimization
This commit is contained in:
+2
-2
@@ -86,7 +86,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
g2d.setColor(bodyColor);
|
||||
g2d.fill(shape);
|
||||
g2d.setComposite(oldComposite);
|
||||
g2d.setStroke(new BasicStroke(1));
|
||||
g2d.setStroke(Constants.BASIC_STROKE);
|
||||
g2d.setColor(componentState == ComponentState.SELECTED
|
||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
|
||||
g2d.draw(shape);
|
||||
@@ -107,7 +107,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
g2d
|
||||
.setColor(componentState == ComponentState.SELECTED ? LABEL_COLOR_SELECTED
|
||||
: LABEL_COLOR);
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||
String label = display == Display.NAME ? getName() : getValue().toString();
|
||||
Rectangle2D textRect = fontMetrics.getStringBounds(label, g2d);
|
||||
g2d.drawString(label, (int) (shapeRect.width - textRect.getWidth()) / 2,
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ public class Constants {
|
||||
|
||||
public static Font LABEL_FONT = new Font("Tahoma", Font.PLAIN, 11);
|
||||
|
||||
public static final Stroke BASIC_STROKE = new BasicStroke();
|
||||
public static final Stroke DASHED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
|
||||
BasicStroke.JOIN_MITER, 2.0f, new float[] { 2.0f }, 0.0f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user