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; 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 = Color.black;
public static Color LABEL_COLOR_SELECTED = Color.red; public static Color LABEL_COLOR_SELECTED = Color.red;
public static Size LEAD_THICKNESS = new Size(0.8d, SizeUnit.mm); public static Size LEAD_THICKNESS = new Size(0.8d, SizeUnit.mm);
@@ -94,13 +94,24 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
// Draw leads. // Draw leads.
int leadThickness = getLeadThickness().convertToPixels(); int leadThickness = getLeadThickness().convertToPixels();
g2d.setStroke(new BasicStroke(leadThickness)); 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, g2d.drawLine((int) (shapeRect.width - distance) / 2, (int) shapeRect.height / 2,
(int) ((shapeRect.width - distance) / 2 + leadLenght) - leadThickness / 2, (int) ((shapeRect.width - distance) / 2 + leadLenght) - leadThickness / 2,
(int) shapeRect.height / 2); (int) shapeRect.height / 2);
g2d.drawLine((int) (shapeRect.width + distance) / 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.width + distance) / 2 - leadLenght) + leadThickness / 2,
(int) shapeRect.height / 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. // Do not track the label because that area was already covered.
drawingObserver.stopTracking(); drawingObserver.stopTracking();
// Draw label. // Draw label.
@@ -120,6 +131,10 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
(int) (shapeRect.height - textRect.getHeight()) / 2 + fontMetrics.getAscent()); (int) (shapeRect.height - textRect.getHeight()) / 2 + fontMetrics.getAscent());
} }
protected boolean shouldShadeLeads() {
return true;
}
/** /**
* @return default component width. * @return default component width.
*/ */
@@ -20,7 +20,7 @@ public class PerfBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static Color PAD_COLOR = Color.decode("#F3926C"); public static Color COPPER_COLOR = Color.decode("#DA8A67");
public static Size SPACING = new Size(0.1d, SizeUnit.in); public static Size SPACING = new Size(0.1d, SizeUnit.in);
public static Size PAD_SIZE = new Size(0.08d, SizeUnit.in); public static Size PAD_SIZE = new Size(0.08d, SizeUnit.in);
@@ -28,7 +28,7 @@ public class PerfBoard extends AbstractBoard {
// private Area copperArea; // private Area copperArea;
protected Size spacing = SPACING; protected Size spacing = SPACING;
protected Color padColor = PAD_COLOR; protected Color padColor = COPPER_COLOR;
@Override @Override
public void draw(Graphics2D g2d, ComponentState componentState, Project project, public void draw(Graphics2D g2d, ComponentState componentState, Project project,
@@ -88,13 +88,13 @@ public class PerfBoard extends AbstractBoard {
g2d.fillRect(2, 2, width - 4, height - 4); g2d.fillRect(2, 2, width - 4, height - 4);
g2d.setColor(BORDER_COLOR); g2d.setColor(BORDER_COLOR);
g2d.drawRect(2, 2, width - 4, height - 4); g2d.drawRect(2, 2, width - 4, height - 4);
g2d.setColor(PAD_COLOR); g2d.setColor(COPPER_COLOR);
g2d.fillOval(width / 4, width / 4, width / 2, width / 2); g2d.fillOval(width / 4, width / 4, width / 2, width / 2);
g2d.setColor(PAD_COLOR.darker()); g2d.setColor(COPPER_COLOR.darker());
g2d.drawOval(width / 4, width / 4, width / 2, width / 2); g2d.drawOval(width / 4, width / 4, width / 2, width / 2);
g2d.setColor(Constants.CANVAS_COLOR); g2d.setColor(Constants.CANVAS_COLOR);
g2d.fillOval(width / 2 - 2, width / 2 - 2, 5, 5); g2d.fillOval(width / 2 - 2, width / 2 - 2, 5, 5);
g2d.setColor(PAD_COLOR.darker()); g2d.setColor(COPPER_COLOR.darker());
g2d.drawOval(width / 2 - 2, width / 2 - 2, 5, 5); g2d.drawOval(width / 2 - 2, width / 2 - 2, 5, 5);
} }
} }
@@ -21,7 +21,7 @@ public class VeroBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static Color PAD_COLOR = Color.decode("#F3926C"); public static Color COPPER_COLOR = Color.decode("#DA8A67");
public static Color BORDER_COLOR = BOARD_COLOR.darker(); public static Color BORDER_COLOR = BOARD_COLOR.darker();
public static Size SPACING = new Size(0.1d, SizeUnit.in); public static Size SPACING = new Size(0.1d, SizeUnit.in);
@@ -29,7 +29,7 @@ public class VeroBoard extends AbstractBoard {
public static Size HOLE_SIZE = new Size(0.7d, SizeUnit.mm); public static Size HOLE_SIZE = new Size(0.7d, SizeUnit.mm);
protected Size spacing = SPACING; protected Size spacing = SPACING;
protected Color padColor = PAD_COLOR; protected Color padColor = COPPER_COLOR;
@Override @Override
public void draw(Graphics2D g2d, ComponentState componentState, Project project, public void draw(Graphics2D g2d, ComponentState componentState, Project project,
@@ -92,14 +92,14 @@ public class VeroBoard extends AbstractBoard {
g2d.fillRect(2, 2, width - 4, height - 4); g2d.fillRect(2, 2, width - 4, height - 4);
g2d.setColor(BORDER_COLOR); g2d.setColor(BORDER_COLOR);
g2d.drawRect(2, 2, width - 4, height - 4); g2d.drawRect(2, 2, width - 4, height - 4);
g2d.setColor(PAD_COLOR); g2d.setColor(COPPER_COLOR);
g2d.fillRect(4, width / 4, width - 8, width / 2); g2d.fillRect(4, width / 4, width - 8, width / 2);
g2d.setColor(PAD_COLOR.darker()); g2d.setColor(COPPER_COLOR.darker());
g2d.drawRect(4, width / 4, width - 8, width / 2); g2d.drawRect(4, width / 4, width - 8, width / 2);
g2d.setColor(Constants.CANVAS_COLOR); g2d.setColor(Constants.CANVAS_COLOR);
g2d.fillOval(width / 3 - 2, width / 2 - 2, 5, 5); g2d.fillOval(width / 3 - 2, width / 2 - 2, 5, 5);
g2d.fillOval(2 * width / 3 - 2, width / 2 - 2, 5, 5); g2d.fillOval(2 * width / 3 - 2, width / 2 - 2, 5, 5);
g2d.setColor(PAD_COLOR.darker()); g2d.setColor(COPPER_COLOR.darker());
g2d.drawOval(width / 3 - 2, width / 2 - 2, 5, 5); g2d.drawOval(width / 3 - 2, width / 2 - 2, 5, 5);
g2d.drawOval(2 * width / 3 - 2, width / 2 - 2, 5, 5); g2d.drawOval(2 * width / 3 - 2, width / 2 - 2, 5, 5);
} }
@@ -57,6 +57,11 @@ public class CopperTrace extends AbstractLeadedComponent<Void> {
this.leadThickness = leadThickness; this.leadThickness = leadThickness;
} }
@Override
protected boolean shouldShadeLeads() {
return false;
}
@Deprecated @Deprecated
public Color getBodyColor() { public Color getBodyColor() {
return super.getBodyColor(); return super.getBodyColor();