mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
improved lead looks
This commit is contained in:
+17
-2
@@ -32,7 +32,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color LEAD_COLOR = Color.decode("#65909A");
|
||||
public static Color LEAD_COLOR = Color.decode("#236B8E");
|
||||
public static Color LABEL_COLOR = Color.black;
|
||||
public static Color LABEL_COLOR_SELECTED = Color.red;
|
||||
public static Size LEAD_THICKNESS = new Size(0.8d, SizeUnit.mm);
|
||||
@@ -94,13 +94,24 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
// Draw leads.
|
||||
int leadThickness = getLeadThickness().convertToPixels();
|
||||
g2d.setStroke(new BasicStroke(leadThickness));
|
||||
g2d.setColor(getLeadColor(componentState));
|
||||
g2d.setColor(shouldShadeLeads() ? getLeadColor(componentState).darker()
|
||||
: getLeadColor(componentState));
|
||||
g2d.drawLine((int) (shapeRect.width - distance) / 2, (int) shapeRect.height / 2,
|
||||
(int) ((shapeRect.width - distance) / 2 + leadLenght) - leadThickness / 2,
|
||||
(int) shapeRect.height / 2);
|
||||
g2d.drawLine((int) (shapeRect.width + distance) / 2, (int) shapeRect.height / 2,
|
||||
(int) ((shapeRect.width + distance) / 2 - leadLenght) + leadThickness / 2,
|
||||
(int) shapeRect.height / 2);
|
||||
if (shouldShadeLeads()) {
|
||||
g2d.setStroke(new BasicStroke(leadThickness - 2));
|
||||
g2d.setColor(getLeadColor(componentState));
|
||||
g2d.drawLine((int) (shapeRect.width - distance) / 2, (int) shapeRect.height / 2,
|
||||
(int) ((shapeRect.width - distance) / 2 + leadLenght) - leadThickness / 2,
|
||||
(int) shapeRect.height / 2);
|
||||
g2d.drawLine((int) (shapeRect.width + distance) / 2, (int) shapeRect.height / 2,
|
||||
(int) ((shapeRect.width + distance) / 2 - leadLenght) + leadThickness / 2,
|
||||
(int) shapeRect.height / 2);
|
||||
}
|
||||
// Do not track the label because that area was already covered.
|
||||
drawingObserver.stopTracking();
|
||||
// Draw label.
|
||||
@@ -120,6 +131,10 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
(int) (shapeRect.height - textRect.getHeight()) / 2 + fontMetrics.getAscent());
|
||||
}
|
||||
|
||||
protected boolean shouldShadeLeads() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return default component width.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user