improved lead looks

This commit is contained in:
bancika
2011-01-19 18:58:38 +00:00
parent e38fb84621
commit 69ef633af3
5 changed files with 32 additions and 12 deletions
@@ -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.
*/