jack outline

This commit is contained in:
bancika
2012-09-21 13:42:07 +00:00
parent 8ea4ba6aab
commit d7198e4705
3 changed files with 132 additions and 103 deletions
@@ -78,7 +78,8 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
// Apply rotation if necessary // Apply rotation if necessary
double angle = getAngle(); double angle = getAngle();
if (angle != 0) { if (angle != 0) {
AffineTransform rotation = AffineTransform.getRotateInstance(angle, x, y); AffineTransform rotation = AffineTransform.getRotateInstance(angle,
x, y);
for (int i = 1; i < controlPoints.length; i++) { for (int i = 1; i < controlPoints.length; i++) {
rotation.transform(controlPoints[i], controlPoints[i]); rotation.transform(controlPoints[i], controlPoints[i]);
} }
@@ -114,32 +115,33 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
int bodyWidth = (int) BODY_WIDTH.convertToPixels(); int bodyWidth = (int) BODY_WIDTH.convertToPixels();
int centerX = (controlPoints[0].x + controlPoints[3].x) / 2; int centerX = (controlPoints[0].x + controlPoints[3].x) / 2;
int centerY = (controlPoints[0].y + controlPoints[3].y) / 2; int centerY = (controlPoints[0].y + controlPoints[3].y) / 2;
body[0] = new Rectangle(centerX - bodyLength / 2, centerY - bodyWidth / 2, bodyLength, body[0] = new Rectangle(centerX - bodyLength / 2, centerY
bodyWidth); - bodyWidth / 2, bodyLength, bodyWidth);
int tailLength = (int) TAIL_LENGTH.convertToPixels(); int tailLength = (int) TAIL_LENGTH.convertToPixels();
body[1] = new RoundRectangle2D.Double(centerX - bodyLength / 2 - tailLength, centerY body[1] = new RoundRectangle2D.Double(centerX - bodyLength / 2
- bodyWidth / 4, tailLength * 2, bodyWidth / 2, tailLength, tailLength); - tailLength, centerY - bodyWidth / 4, tailLength * 2,
bodyWidth / 2, tailLength, tailLength);
Area tailArea = new Area(body[1]); Area tailArea = new Area(body[1]);
tailArea.subtract(new Area(body[0])); tailArea.subtract(new Area(body[0]));
body[1] = tailArea; body[1] = tailArea;
body[2] = new Rectangle(centerX + bodyLength / 2, centerY - bodyWidth / 4, tailLength, body[2] = new Rectangle(centerX + bodyLength / 2, centerY
bodyWidth / 2); - bodyWidth / 4, tailLength, bodyWidth / 2);
body[3] = new Rectangle(centerX + bodyLength / 2 + tailLength, centerY - bodyWidth / 4, body[3] = new Rectangle(centerX + bodyLength / 2 + tailLength,
tailLength, bodyWidth / 2); centerY - bodyWidth / 4, tailLength, bodyWidth / 2);
tailArea = new Area(body[3]); tailArea = new Area(body[3]);
int radius = bodyLength / 2 + tailLength * 2; int radius = bodyLength / 2 + tailLength * 2;
tailArea.intersect(new Area(new Ellipse2D.Double(centerX - radius, centerY - radius, tailArea.intersect(new Area(new Ellipse2D.Double(centerX - radius,
radius * 2, radius * 2))); centerY - radius, radius * 2, radius * 2)));
body[3] = tailArea; body[3] = tailArea;
// Apply rotation if necessary // Apply rotation if necessary
double angle = getAngle(); double angle = getAngle();
if (angle != 0) { if (angle != 0) {
AffineTransform rotation = AffineTransform.getRotateInstance(angle, centerX, AffineTransform rotation = AffineTransform.getRotateInstance(
centerY); angle, centerX, centerY);
for (int i = 0; i < body.length; i++) { for (int i = 0; i < body.length; i++) {
if (body[i] != null) { if (body[i] != null) {
Area area = new Area(body[i]); Area area = new Area(body[i]);
@@ -157,12 +159,13 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
for (int i = 0; i < getControlPointCount(); i++) { for (int i = 0; i < getControlPointCount(); i++) {
Point point = getControlPoint(i); Point point = getControlPoint(i);
Rectangle pin; Rectangle pin;
if (orientation == Orientation.DEFAULT || orientation == Orientation._180) { if (orientation == Orientation.DEFAULT
pin = new Rectangle(point.x - pinWidth / 2, point.y - pinThickness / 2, || orientation == Orientation._180) {
pinWidth, pinThickness); pin = new Rectangle(point.x - pinWidth / 2, point.y
- pinThickness / 2, pinWidth, pinThickness);
} else { } else {
pin = new Rectangle(point.x - pinThickness / 2, point.y - pinWidth / 2, pin = new Rectangle(point.x - pinThickness / 2, point.y
pinThickness, pinWidth); - pinWidth / 2, pinThickness, pinWidth);
} }
pins.add(new Area(pin)); pins.add(new Area(pin));
} }
@@ -173,34 +176,38 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
} }
@Override @Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, public void draw(Graphics2D g2d, ComponentState componentState,
Project project, IDrawingObserver drawingObserver) { boolean outlineMode, Project project,
IDrawingObserver drawingObserver) {
Shape[] body = getBody(); Shape[] body = getBody();
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1)); g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
if (componentState != ComponentState.DRAGGING) { if (componentState != ComponentState.DRAGGING) {
Composite oldComposite = g2d.getComposite(); Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) { if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha g2d.setComposite(AlphaComposite.getInstance(
/ MAX_ALPHA)); AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
} }
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BODY_COLOR); g2d
.setColor(outlineMode ? Constants.TRANSPARENT_COLOR
: BODY_COLOR);
for (int i = 0; i < body.length - 1; i++) { for (int i = 0; i < body.length - 1; i++) {
// Nut is brighter colored. // Nut is brighter colored.
if (i == body.length - 2) if (i == body.length - 2)
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : NUT_COLOR); g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR
: NUT_COLOR);
g2d.fill(body[i]); g2d.fill(body[i]);
} }
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
} }
Color finalBorderColor; Color finalBorderColor;
if (outlineMode) {
Theme theme = (Theme) ConfigurationManager.getInstance().readObject( Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
if (outlineMode) {
finalBorderColor = componentState == ComponentState.SELECTED finalBorderColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
.getOutlineColor(); : theme.getOutlineColor();
} else { } else {
finalBorderColor = componentState == ComponentState.SELECTED finalBorderColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
@@ -214,18 +221,19 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
// Pins are the last piece. // Pins are the last piece.
Shape pins = body[body.length - 1]; Shape pins = body[body.length - 1];
if (!outlineMode) {
g2d.setColor(METAL_COLOR); g2d.setColor(METAL_COLOR);
g2d.fill(pins); g2d.fill(pins);
g2d.setColor(METAL_COLOR.darker()); }
g2d.setColor(outlineMode ? theme.getOutlineColor() : METAL_COLOR
.darker());
g2d.draw(pins); g2d.draw(pins);
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
finalLabelColor = componentState == ComponentState.SELECTED finalLabelColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED : theme || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
.getOutlineColor(); : theme.getOutlineColor();
} else { } else {
finalLabelColor = componentState == ComponentState.SELECTED finalLabelColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
@@ -235,8 +243,8 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
g2d.setFont(LABEL_FONT); g2d.setFont(LABEL_FONT);
int centerX = (controlPoints[0].x + controlPoints[3].x) / 2; int centerX = (controlPoints[0].x + controlPoints[3].x) / 2;
int centerY = (controlPoints[0].y + controlPoints[3].y) / 2; int centerY = (controlPoints[0].y + controlPoints[3].y) / 2;
drawCenteredText(g2d, name, centerX, centerY, HorizontalAlignment.CENTER, drawCenteredText(g2d, name, centerX, centerY,
VerticalAlignment.CENTER); HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
} }
@Override @Override
@@ -245,23 +253,25 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
int tailWidth = getClosestOdd(width * 3 / 9); int tailWidth = getClosestOdd(width * 3 / 9);
g2d.setColor(BODY_COLOR); g2d.setColor(BODY_COLOR);
g2d.fillRoundRect((width - tailWidth) / 2, height / 2, tailWidth, height / 2 - 2 * 32 g2d.fillRoundRect((width - tailWidth) / 2, height / 2, tailWidth,
/ height, 4 * 32 / width, 4 * 32 / width); height / 2 - 2 * 32 / height, 4 * 32 / width, 4 * 32 / width);
g2d.setColor(BORDER_COLOR); g2d.setColor(BORDER_COLOR);
g2d.drawRoundRect((width - tailWidth) / 2, height / 2, tailWidth, height / 2 - 2 * 32 g2d.drawRoundRect((width - tailWidth) / 2, height / 2, tailWidth,
/ height, 4 * 32 / width, 4 * 32 / width); height / 2 - 2 * 32 / height, 4 * 32 / width, 4 * 32 / width);
g2d.setColor(NUT_COLOR); g2d.setColor(NUT_COLOR);
g2d.fillRoundRect((width - tailWidth) / 2, 2 * 32 / height, tailWidth, height / 2, g2d.fillRoundRect((width - tailWidth) / 2, 2 * 32 / height, tailWidth,
4 * 32 / width, 4 * 32 / width); height / 2, 4 * 32 / width, 4 * 32 / width);
g2d.setColor(BORDER_COLOR); g2d.setColor(BORDER_COLOR);
g2d.drawRoundRect((width - tailWidth) / 2, 2 * 32 / height, tailWidth, height / 2, g2d.drawRoundRect((width - tailWidth) / 2, 2 * 32 / height, tailWidth,
4 * 32 / width, 4 * 32 / width); height / 2, 4 * 32 / width, 4 * 32 / width);
g2d.setColor(BODY_COLOR); g2d.setColor(BODY_COLOR);
g2d.fillRect((width - bodyWidth) / 2, height / 7 + 1, bodyWidth, height * 5 / 7); g2d.fillRect((width - bodyWidth) / 2, height / 7 + 1, bodyWidth,
height * 5 / 7);
g2d.setColor(BORDER_COLOR); g2d.setColor(BORDER_COLOR);
g2d.drawRect((width - bodyWidth) / 2, height / 7 + 1, bodyWidth, height * 5 / 7); g2d.drawRect((width - bodyWidth) / 2, height / 7 + 1, bodyWidth,
height * 5 / 7);
g2d.setColor(METAL_COLOR); g2d.setColor(METAL_COLOR);
int pinX1 = getClosestOdd((width - bodyWidth * 3 / 4) / 2); int pinX1 = getClosestOdd((width - bodyWidth * 3 / 4) / 2);
@@ -294,22 +294,23 @@ public class MiniRelay extends AbstractTransparentComponent<String> {
g2d.fill(mainArea); g2d.fill(mainArea);
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
if (!outlineMode) { Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2; int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
for (Point point : controlPoints) { for (Point point : controlPoints) {
if (!outlineMode) {
g2d.setColor(PIN_COLOR); g2d.setColor(PIN_COLOR);
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2,
pinSize, pinSize); pinSize, pinSize);
g2d.setColor(PIN_BORDER_COLOR);
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2,
pinSize, pinSize);
} }
g2d.setColor(outlineMode ? theme.getOutlineColor()
: PIN_BORDER_COLOR);
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize,
pinSize);
} }
Color finalBorderColor; Color finalBorderColor;
if (outlineMode) { if (outlineMode) {
Theme theme = (Theme) ConfigurationManager.getInstance()
.readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
finalBorderColor = componentState == ComponentState.SELECTED finalBorderColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: theme.getOutlineColor(); : theme.getOutlineColor();
@@ -335,8 +336,6 @@ public class MiniRelay extends AbstractTransparentComponent<String> {
g2d.setFont(LABEL_FONT); g2d.setFont(LABEL_FONT);
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
Theme theme = (Theme) ConfigurationManager.getInstance()
.readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
finalLabelColor = componentState == ComponentState.SELECTED finalLabelColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
: theme.getOutlineColor(); : theme.getOutlineColor();
@@ -42,7 +42,8 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
private static Color BORDER_COLOR = Color.black; private static Color BORDER_COLOR = Color.black;
private static Color MARKING_COLOR = Color.lightGray; private static Color MARKING_COLOR = Color.lightGray;
private Point[] controlPoints = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0) }; private Point[] controlPoints = new Point[] { new Point(0, 0),
new Point(0, 0), new Point(0, 0) };
private String value = ""; private String value = "";
private DCPolarity polarity = DCPolarity.CENTER_NEGATIVE; private DCPolarity polarity = DCPolarity.CENTER_NEGATIVE;
transient private Shape[] body; transient private Shape[] body;
@@ -71,23 +72,24 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
int y = controlPoints[0].y; int y = controlPoints[0].y;
int spacing = (int) SPACING.convertToPixels(); int spacing = (int) SPACING.convertToPixels();
int diameter = getClosestOdd(DIAMETER.convertToPixels()); int diameter = getClosestOdd(DIAMETER.convertToPixels());
body[0] = new Ellipse2D.Double(x - diameter / 2, y + spacing - diameter / 2, diameter, body[0] = new Ellipse2D.Double(x - diameter / 2, y + spacing
diameter); - diameter / 2, diameter, diameter);
int rectWidth = (int) (diameter / Math.sqrt(2)) - 2; int rectWidth = (int) (diameter / Math.sqrt(2)) - 2;
body[1] = new Rectangle(x - rectWidth / 2, y + spacing - rectWidth / 2, rectWidth, body[1] = new Rectangle(x - rectWidth / 2, y + spacing - rectWidth
rectWidth); / 2, rectWidth, rectWidth);
int lugWidth = getClosestOdd(LUG_WIDTH.convertToPixels()); int lugWidth = getClosestOdd(LUG_WIDTH.convertToPixels());
int lugThickness = getClosestOdd(LUG_THICKNESS.convertToPixels()); int lugThickness = getClosestOdd(LUG_THICKNESS.convertToPixels());
Point groundPoint = controlPoints[controlPoints.length - 1]; Point groundPoint = controlPoints[controlPoints.length - 1];
Area groundLug = new Area(new Ellipse2D.Double(groundPoint.x + spacing - lugWidth / 2, Area groundLug = new Area(new Ellipse2D.Double(groundPoint.x
groundPoint.y - lugWidth / 2, lugWidth, lugWidth)); + spacing - lugWidth / 2, groundPoint.y - lugWidth / 2,
groundLug.add(new Area(new Rectangle(groundPoint.x, groundPoint.y - lugWidth / 2, lugWidth, lugWidth));
spacing, lugWidth))); groundLug.add(new Area(new Rectangle(groundPoint.x, groundPoint.y
groundLug.subtract(new Area(new Ellipse2D.Double( - lugWidth / 2, spacing, lugWidth)));
groundPoint.x + spacing - lugWidth / 6, groundPoint.y - lugWidth / 6, groundLug.subtract(new Area(new Ellipse2D.Double(groundPoint.x
+ spacing - lugWidth / 6, groundPoint.y - lugWidth / 6,
lugWidth / 3, lugWidth / 3))); lugWidth / 3, lugWidth / 3)));
body[2] = groundLug; body[2] = groundLug;
@@ -95,11 +97,14 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
for (int i = 0; i < controlPoints.length; i++) { for (int i = 0; i < controlPoints.length; i++) {
Point point = controlPoints[i]; Point point = controlPoints[i];
if (i == getControlPointCount() - 1) { if (i == getControlPointCount() - 1) {
lugArea.add(new Area(new Rectangle(point.x - lugThickness / 2, point.y lugArea.add(new Area(
new Rectangle(point.x - lugThickness / 2, point.y
- lugWidth / 2, lugThickness, lugWidth))); - lugWidth / 2, lugThickness, lugWidth)));
} else { } else {
lugArea.add(new Area(new Rectangle(point.x - lugWidth / 2, point.y lugArea
- lugThickness / 2, lugWidth, lugThickness))); .add(new Area(new Rectangle(point.x - lugWidth / 2,
point.y - lugThickness / 2, lugWidth,
lugThickness)));
} }
} }
body[3] = lugArea; body[3] = lugArea;
@@ -108,18 +113,21 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
} }
@Override @Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, public void draw(Graphics2D g2d, ComponentState componentState,
Project project, IDrawingObserver drawingObserver) { boolean outlineMode, Project project,
IDrawingObserver drawingObserver) {
Shape[] body = getBody(); Shape[] body = getBody();
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1)); g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
if (componentState != ComponentState.DRAGGING) { if (componentState != ComponentState.DRAGGING) {
Composite oldComposite = g2d.getComposite(); Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) { if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha g2d.setComposite(AlphaComposite.getInstance(
/ MAX_ALPHA)); AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
} }
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BODY_COLOR); g2d
.setColor(outlineMode ? Constants.TRANSPARENT_COLOR
: BODY_COLOR);
g2d.fill(body[0]); g2d.fill(body[0]);
if (!outlineMode) { if (!outlineMode) {
g2d.setColor(PHENOLIC_COLOR); g2d.setColor(PHENOLIC_COLOR);
@@ -128,16 +136,17 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
} }
Color finalBorderColor;
if (outlineMode) {
Theme theme = (Theme) ConfigurationManager.getInstance().readObject( Theme theme = (Theme) ConfigurationManager.getInstance().readObject(
IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
Color finalBorderColor;
if (outlineMode) {
finalBorderColor = componentState == ComponentState.SELECTED finalBorderColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
.getOutlineColor(); : theme.getOutlineColor();
} else { } else {
finalBorderColor = componentState == ComponentState.SELECTED finalBorderColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : BORDER_COLOR; || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: BORDER_COLOR;
} }
g2d.setColor(finalBorderColor); g2d.setColor(finalBorderColor);
@@ -150,21 +159,25 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
g2d.fill(body[2]); g2d.fill(body[2]);
g2d.setColor(METAL_COLOR.darker()); g2d.setColor(METAL_COLOR.darker());
g2d.draw(body[2]); g2d.draw(body[2]);
}
g2d.setColor(METAL_COLOR); g2d.setColor(METAL_COLOR);
g2d.fill(body[3]); g2d.fill(body[3]);
g2d.setColor(METAL_COLOR.darker()); }
g2d.setColor(outlineMode ? theme.getOutlineColor() : METAL_COLOR
.darker());
g2d.draw(body[3]); g2d.draw(body[3]);
if (!outlineMode && getPolarity() != DCPolarity.NONE) { if (!outlineMode && getPolarity() != DCPolarity.NONE) {
int spacing = (int) SPACING.convertToPixels(); int spacing = (int) SPACING.convertToPixels();
g2d.setColor(MARKING_COLOR); g2d.setColor(MARKING_COLOR);
g2d.setFont(LABEL_FONT.deriveFont(12f)); g2d.setFont(LABEL_FONT.deriveFont(12f));
drawCenteredText(g2d, getPolarity() == DCPolarity.CENTER_NEGATIVE ? "+" : "-", drawCenteredText(g2d,
getPolarity() == DCPolarity.CENTER_NEGATIVE ? "+" : "-",
controlPoints[0].x, controlPoints[0].y - spacing * 7 / 16, controlPoints[0].x, controlPoints[0].y - spacing * 7 / 16,
HorizontalAlignment.CENTER, VerticalAlignment.CENTER); HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
drawCenteredText(g2d, getPolarity() == DCPolarity.CENTER_NEGATIVE ? "_" : "+", drawCenteredText(g2d,
getPolarity() == DCPolarity.CENTER_NEGATIVE ? "_" : "+",
controlPoints[2].x, controlPoints[2].y - spacing * 3 / 4, controlPoints[2].x, controlPoints[2].y - spacing * 3 / 4,
HorizontalAlignment.CENTER, VerticalAlignment.CENTER); HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
} }
@@ -175,25 +188,32 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
int margin = 2 * 32 / width; int margin = 2 * 32 / width;
int diameter = getClosestOdd(width - margin); int diameter = getClosestOdd(width - margin);
g2d.setColor(BODY_COLOR); g2d.setColor(BODY_COLOR);
g2d.fillOval((width - diameter) / 2, (height - diameter) / 2, diameter, diameter); g2d.fillOval((width - diameter) / 2, (height - diameter) / 2, diameter,
diameter);
g2d.setColor(BORDER_COLOR); g2d.setColor(BORDER_COLOR);
g2d.drawOval((width - diameter) / 2, (height - diameter) / 2, diameter, diameter); g2d.drawOval((width - diameter) / 2, (height - diameter) / 2, diameter,
int rectWidth = getClosestOdd(((width - 2 * margin) / Math.sqrt(2)) - margin / 2); diameter);
int rectWidth = getClosestOdd(((width - 2 * margin) / Math.sqrt(2))
- margin / 2);
g2d.setColor(PHENOLIC_COLOR); g2d.setColor(PHENOLIC_COLOR);
g2d.fillRect((width - rectWidth) / 2, (height - rectWidth) / 2, rectWidth, rectWidth); g2d.fillRect((width - rectWidth) / 2, (height - rectWidth) / 2,
rectWidth, rectWidth);
g2d.setColor(PHENOLIC_COLOR.darker()); g2d.setColor(PHENOLIC_COLOR.darker());
g2d.drawRect((width - rectWidth) / 2, (height - rectWidth) / 2, rectWidth, rectWidth); g2d.drawRect((width - rectWidth) / 2, (height - rectWidth) / 2,
rectWidth, rectWidth);
int lugWidth = 4 * 32 / width; int lugWidth = 4 * 32 / width;
g2d.setColor(METAL_COLOR); g2d.setColor(METAL_COLOR);
g2d.drawLine((width - lugWidth) / 2, height / 3, (width + lugWidth) / 2, height / 3); g2d.drawLine((width - lugWidth) / 2, height / 3,
g2d (width + lugWidth) / 2, height / 3);
.drawLine(width * 2 / 3, (height - lugWidth) / 2, width * 2 / 3, g2d.drawLine(width * 2 / 3, (height - lugWidth) / 2, width * 2 / 3,
(height + lugWidth) / 2); (height + lugWidth) / 2);
g2d.fillOval((width - lugWidth) / 2, height * 2 / 3 - lugWidth / 2, lugWidth, lugWidth); g2d.fillOval((width - lugWidth) / 2, height * 2 / 3 - lugWidth / 2,
g2d.fillRect(width / 2 - lugWidth * 3 / 2, height * 2 / 3 - lugWidth / 2, lugWidth * 3 / 2, lugWidth, lugWidth);
lugWidth); g2d.fillRect(width / 2 - lugWidth * 3 / 2, height * 2 / 3 - lugWidth
/ 2, lugWidth * 3 / 2, lugWidth);
g2d.setColor(PHENOLIC_COLOR); g2d.setColor(PHENOLIC_COLOR);
g2d.fillOval((width - margin) / 2, height * 2 / 3 - margin / 2, margin, margin); g2d.fillOval((width - margin) / 2, height * 2 / 3 - margin / 2, margin,
margin);
} }
@Override @Override