diff --git a/diylc/diylc-library/src/org/diylc/components/guitar/AbstractGuitarPickup.java b/diylc/diylc-library/src/org/diylc/components/guitar/AbstractGuitarPickup.java index 70fc4a50..105a07a6 100644 --- a/diylc/diylc-library/src/org/diylc/components/guitar/AbstractGuitarPickup.java +++ b/diylc/diylc-library/src/org/diylc/components/guitar/AbstractGuitarPickup.java @@ -18,20 +18,28 @@ package org.diylc.components.guitar; import java.awt.Color; +import java.awt.Font; import java.awt.Graphics2D; import java.awt.Point; +import java.awt.Rectangle; import java.awt.Shape; +import java.awt.geom.AffineTransform; +import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.common.HorizontalAlignment; +import org.diylc.common.IPlugInPort; import org.diylc.common.Orientation; import org.diylc.common.OrientationHV; import org.diylc.common.VerticalAlignment; import org.diylc.components.AbstractTransparentComponent; +import org.diylc.core.ComponentState; import org.diylc.core.Project; +import org.diylc.core.Theme; import org.diylc.core.VisibilityPolicy; import org.diylc.core.annotations.EditableProperty; import org.diylc.core.measures.Size; import org.diylc.core.measures.SizeUnit; +import org.diylc.utils.Constants; public abstract class AbstractGuitarPickup extends AbstractTransparentComponent { @@ -39,7 +47,7 @@ public abstract class AbstractGuitarPickup extends AbstractTransparentComponent< protected static Size POINT_SPACING = new Size(0.1d, SizeUnit.in); - protected static final int TERMINAL_FONT_SIZE = 11; + protected static final int TERMINAL_FONT_SIZE = 11; protected String value = ""; protected Orientation orientation = Orientation.DEFAULT; @@ -50,11 +58,13 @@ public abstract class AbstractGuitarPickup extends AbstractTransparentComponent< protected Polarity polarity = Polarity.North; + protected Color labelColor; + public AbstractGuitarPickup() { updateControlPoints(); } - protected void drawTerminalLabels(Graphics2D g2d, Color color, Project project) { + protected void drawlTerminalLabels(Graphics2D g2d, Color color, Project project) { Point[] points = getControlPoints(); g2d.setColor(color); @@ -78,10 +88,47 @@ public abstract class AbstractGuitarPickup extends AbstractTransparentComponent< dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? -TERMINAL_FONT_SIZE : 0; dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : -(int) (TERMINAL_FONT_SIZE * 0.8); break; - } + } drawCenteredText(g2d, "N", (points[0].x + points[1].x) / 2 + dx, (points[0].y + points[1].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER); - drawCenteredText(g2d, "S", (points[2].x + points[3].x) / 2 + dx, (points[2].y + points[3].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER); + drawCenteredText(g2d, "S", (points[2].x + points[3].x) / 2 + dx, (points[2].y + points[3].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER); + } + + protected void drawMainLabel(Graphics2D g2d, Project project, boolean outlineMode, ComponentState componentState) { + Color finalLabelColor; + if (outlineMode) { + Theme theme = + (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); + finalLabelColor = + componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED + : theme.getOutlineColor(); + } else { + finalLabelColor = + componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED + : getLabelColor(); + } + g2d.setColor(finalLabelColor); + g2d.setFont(project.getFont().deriveFont(Font.BOLD)); + Rectangle bounds = getBody()[0].getBounds(); + + AffineTransform originalTx = g2d.getTransform(); + g2d.translate(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2); + if (orientation == Orientation._90) + g2d.rotate(Math.PI / 2); + else if (orientation == Orientation._270){ + g2d.rotate(-Math.PI / 2); + } + g2d.translate(0, getMainLabelYOffset()); + + drawCenteredText(g2d, value, 0, 0, HorizontalAlignment.CENTER, VerticalAlignment.CENTER); + + g2d.setTransform(originalTx); + } + + protected abstract Shape[] getBody(); + + protected int getMainLabelYOffset() { + return 0; } @EditableProperty(name = "Model") @@ -153,6 +200,17 @@ public abstract class AbstractGuitarPickup extends AbstractTransparentComponent< body = null; } + @EditableProperty(name = "Label") + public Color getLabelColor() { + if (labelColor == null) + labelColor = LABEL_COLOR; + return labelColor; + } + + public void setLabelColor(Color labelColor) { + this.labelColor = labelColor; + } + protected abstract OrientationHV getControlPointDirection(); @SuppressWarnings("incomplete-switch") diff --git a/diylc/diylc-library/src/org/diylc/components/guitar/AbstractSingleOrHumbuckerPickup.java b/diylc/diylc-library/src/org/diylc/components/guitar/AbstractSingleOrHumbuckerPickup.java index 5afbd382..2e434aa1 100644 --- a/diylc/diylc-library/src/org/diylc/components/guitar/AbstractSingleOrHumbuckerPickup.java +++ b/diylc/diylc-library/src/org/diylc/components/guitar/AbstractSingleOrHumbuckerPickup.java @@ -33,7 +33,7 @@ public abstract class AbstractSingleOrHumbuckerPickup extends AbstractGuitarPick private static final long serialVersionUID = 1L; @Override - protected void drawTerminalLabels(Graphics2D g2d, Color color, Project project) { + protected void drawlTerminalLabels(Graphics2D g2d, Color color, Project project) { Point[] points = getControlPoints(); g2d.setColor(color); diff --git a/diylc/diylc-library/src/org/diylc/components/guitar/HumbuckerPickup.java b/diylc/diylc-library/src/org/diylc/components/guitar/HumbuckerPickup.java index 89f1ff71..cf9e0671 100644 --- a/diylc/diylc-library/src/org/diylc/components/guitar/HumbuckerPickup.java +++ b/diylc/diylc-library/src/org/diylc/components/guitar/HumbuckerPickup.java @@ -22,7 +22,6 @@ import java.awt.Color; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Point; -import java.awt.Rectangle; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.AffineTransform; @@ -33,12 +32,10 @@ import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; import org.diylc.appframework.miscutils.ConfigurationManager; -import org.diylc.common.HorizontalAlignment; import org.diylc.common.IPlugInPort; import org.diylc.common.ObjectCache; import org.diylc.common.Orientation; import org.diylc.common.OrientationHV; -import org.diylc.common.VerticalAlignment; import org.diylc.core.ComponentState; import org.diylc.core.IDIYComponent; import org.diylc.core.IDrawingObserver; @@ -173,26 +170,10 @@ public class HumbuckerPickup extends AbstractGuitarPickup { g2d.setColor(finalBorderColor); g2d.draw(body[0]); } - - Color finalLabelColor; - if (outlineMode) { - Theme theme = - (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); - finalLabelColor = - componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED - : theme.getOutlineColor(); - } else { - finalLabelColor = - componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED - : LABEL_COLOR; - } - g2d.setColor(finalLabelColor); - g2d.setFont(project.getFont()); - Rectangle bounds = body[0].getBounds(); - drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, - VerticalAlignment.CENTER); - drawTerminalLabels(g2d, finalBorderColor, project); + drawMainLabel(g2d, project, outlineMode, componentState); + + drawlTerminalLabels(g2d, finalBorderColor, project); } @Override @@ -201,7 +182,8 @@ public class HumbuckerPickup extends AbstractGuitarPickup { } @SuppressWarnings("incomplete-switch") - public Shape[] getBody() { + @Override + protected Shape[] getBody() { if (body == null) { body = new Shape[7]; @@ -384,6 +366,11 @@ public class HumbuckerPickup extends AbstractGuitarPickup { } return body; } + + @Override + protected int getMainLabelYOffset() { + return (int) (getType().getWidth().convertToPixels() / 2 - 20); + } @Override public void drawIcon(Graphics2D g2d, int width, int height) { diff --git a/diylc/diylc-library/src/org/diylc/components/guitar/JazzBassPickup.java b/diylc/diylc-library/src/org/diylc/components/guitar/JazzBassPickup.java index 8724647e..71e8fcaa 100644 --- a/diylc/diylc-library/src/org/diylc/components/guitar/JazzBassPickup.java +++ b/diylc/diylc-library/src/org/diylc/components/guitar/JazzBassPickup.java @@ -26,7 +26,6 @@ import java.awt.Color; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Point; -import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.Area; @@ -34,12 +33,10 @@ import java.awt.geom.Ellipse2D; import java.awt.geom.RoundRectangle2D; import org.diylc.appframework.miscutils.ConfigurationManager; -import org.diylc.common.HorizontalAlignment; import org.diylc.common.IPlugInPort; import org.diylc.common.ObjectCache; import org.diylc.common.Orientation; import org.diylc.common.OrientationHV; -import org.diylc.common.VerticalAlignment; import org.diylc.core.ComponentState; import org.diylc.core.IDIYComponent; import org.diylc.core.IDrawingObserver; @@ -119,29 +116,30 @@ public class JazzBassPickup extends AbstractSingleOrHumbuckerPickup { g2d.draw(body[3]); } - Color finalLabelColor; - if (outlineMode) { - Theme theme = - (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); - finalLabelColor = - componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED - : theme.getOutlineColor(); - } else { - finalLabelColor = - componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED - : LABEL_COLOR; - } - g2d.setColor(finalLabelColor); - g2d.setFont(project.getFont()); - Rectangle bounds = body[0].getBounds(); - drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, - VerticalAlignment.CENTER); - - // terminal labels - drawTerminalLabels(g2d, finalLabelColor, project); +// Color finalLabelColor; +// if (outlineMode) { +// Theme theme = +// (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); +// finalLabelColor = +// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED +// : theme.getOutlineColor(); +// } else { +// finalLabelColor = +// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED +// : LABEL_COLOR; +// } +// g2d.setColor(finalLabelColor); +// g2d.setFont(project.getFont()); +// Rectangle bounds = body[0].getBounds(); +// drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, +// VerticalAlignment.CENTER); + drawMainLabel(g2d, project, outlineMode, componentState); + + drawlTerminalLabels(g2d, finalBorderColor, project); } - @SuppressWarnings("incomplete-switch") + @SuppressWarnings("incomplete-switch") + @Override public Shape[] getBody() { if (body == null) { body = new Shape[4]; @@ -222,6 +220,11 @@ public class JazzBassPickup extends AbstractSingleOrHumbuckerPickup { return body; } + @Override + protected int getMainLabelYOffset() { + return (int) (WIDTH.convertToPixels() / 2 - 20); + } + @Override protected OrientationHV getControlPointDirection() { return OrientationHV.VERTICAL; diff --git a/diylc/diylc-library/src/org/diylc/components/guitar/P90Pickup.java b/diylc/diylc-library/src/org/diylc/components/guitar/P90Pickup.java index 493855d5..bbb1ad32 100644 --- a/diylc/diylc-library/src/org/diylc/components/guitar/P90Pickup.java +++ b/diylc/diylc-library/src/org/diylc/components/guitar/P90Pickup.java @@ -35,12 +35,10 @@ import java.awt.geom.Ellipse2D; import java.awt.geom.RoundRectangle2D; import org.diylc.appframework.miscutils.ConfigurationManager; -import org.diylc.common.HorizontalAlignment; import org.diylc.common.IPlugInPort; import org.diylc.common.ObjectCache; import org.diylc.common.Orientation; import org.diylc.common.OrientationHV; -import org.diylc.common.VerticalAlignment; import org.diylc.core.ComponentState; import org.diylc.core.IDIYComponent; import org.diylc.core.IDrawingObserver; @@ -136,60 +134,63 @@ public class P90Pickup extends AbstractSingleOrHumbuckerPickup { g2d.draw(body[3]); } - Color finalLabelColor; - if (outlineMode) { - Theme theme = - (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); - finalLabelColor = - componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED - : theme.getOutlineColor(); - } else { - finalLabelColor = - componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED - : LABEL_COLOR; - } - g2d.setColor(finalLabelColor); - g2d.setFont(project.getFont()); - Rectangle bounds = body[0].getBounds(); - drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, - VerticalAlignment.CENTER); +// Color finalLabelColor; +// if (outlineMode) { +// Theme theme = +// (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); +// finalLabelColor = +// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED +// : theme.getOutlineColor(); +// } else { +// finalLabelColor = +// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED +// : LABEL_COLOR; +// } +// g2d.setColor(finalLabelColor); +// g2d.setFont(project.getFont()); +// Rectangle bounds = body[0].getBounds(); +// drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, +// VerticalAlignment.CENTER); + drawMainLabel(g2d, project, outlineMode, componentState); + drawlTerminalLabels(g2d, finalBorderColor, project); // terminal labels - Point[] points = getControlPoints(); - g2d.setColor(finalBorderColor); - - g2d.setFont(project.getFont().deriveFont(TERMINAL_FONT_SIZE * 1f)); - int dx = 0; - int dy = 0; - switch (orientation) { - case DEFAULT: - dx = (int) (TERMINAL_FONT_SIZE * 0.8); - dy = 0; - break; - case _90: - dx = 0; - dy = (int) (TERMINAL_FONT_SIZE * 0.8); - break; - case _180: - dx = -(int) (TERMINAL_FONT_SIZE * 0.8); - dy = 0; - break; - case _270: - dx = 0; - dy = -(int) (TERMINAL_FONT_SIZE * 0.8); - break; - } - - if (getPolarity() == Polarity.North || getPolarity() == Polarity.South) { - drawCenteredText(g2d, getPolarity().name().substring(0, 1), (points[1].x + points[2].x) / 2 + dx, (points[1].y + points[2].y) / 2 + dy, HorizontalAlignment.CENTER, - VerticalAlignment.CENTER); - } else { - drawCenteredText(g2d, "N", (points[0].x + points[1].x) / 2 + dx, (points[0].y + points[1].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER); - drawCenteredText(g2d, "S", (points[2].x + points[3].x) / 2 + dx, (points[2].y + points[3].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER); - } +// Point[] points = getControlPoints(); +// g2d.setColor(finalBorderColor); +// +// g2d.setFont(project.getFont().deriveFont(TERMINAL_FONT_SIZE * 1f)); +// int dx = 0; +// int dy = 0; +// switch (orientation) { +// case DEFAULT: +// dx = (int) (TERMINAL_FONT_SIZE * 0.8); +// dy = 0; +// break; +// case _90: +// dx = 0; +// dy = (int) (TERMINAL_FONT_SIZE * 0.8); +// break; +// case _180: +// dx = -(int) (TERMINAL_FONT_SIZE * 0.8); +// dy = 0; +// break; +// case _270: +// dx = 0; +// dy = -(int) (TERMINAL_FONT_SIZE * 0.8); +// break; +// } +// +// if (getPolarity() == Polarity.North || getPolarity() == Polarity.South) { +// drawCenteredText(g2d, getPolarity().name().substring(0, 1), (points[1].x + points[2].x) / 2 + dx, (points[1].y + points[2].y) / 2 + dy, HorizontalAlignment.CENTER, +// VerticalAlignment.CENTER); +// } else { +// drawCenteredText(g2d, "N", (points[0].x + points[1].x) / 2 + dx, (points[0].y + points[1].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER); +// drawCenteredText(g2d, "S", (points[2].x + points[3].x) / 2 + dx, (points[2].y + points[3].y) / 2 + dy, HorizontalAlignment.CENTER, VerticalAlignment.CENTER); +// } } - @SuppressWarnings("incomplete-switch") + @SuppressWarnings("incomplete-switch") + @Override public Shape[] getBody() { if (body == null) { body = new Shape[4]; @@ -272,6 +273,11 @@ public class P90Pickup extends AbstractSingleOrHumbuckerPickup { } } return body; + } + + @Override + protected int getMainLabelYOffset() { + return (int) (getType().getWidth().convertToPixels() / 2 - 20); } @Override diff --git a/diylc/diylc-library/src/org/diylc/components/guitar/PBassPickup.java b/diylc/diylc-library/src/org/diylc/components/guitar/PBassPickup.java index d54da5ef..29fb3300 100644 --- a/diylc/diylc-library/src/org/diylc/components/guitar/PBassPickup.java +++ b/diylc/diylc-library/src/org/diylc/components/guitar/PBassPickup.java @@ -26,7 +26,6 @@ import java.awt.Color; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Point; -import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.Area; @@ -34,12 +33,10 @@ import java.awt.geom.Ellipse2D; import java.awt.geom.RoundRectangle2D; import org.diylc.appframework.miscutils.ConfigurationManager; -import org.diylc.common.HorizontalAlignment; import org.diylc.common.IPlugInPort; import org.diylc.common.ObjectCache; import org.diylc.common.Orientation; import org.diylc.common.OrientationHV; -import org.diylc.common.VerticalAlignment; import org.diylc.core.ComponentState; import org.diylc.core.IDIYComponent; import org.diylc.core.IDrawingObserver; @@ -117,28 +114,30 @@ public class PBassPickup extends AbstractSingleOrHumbuckerPickup { g2d.draw(body[3]); } - Color finalLabelColor; - if (outlineMode) { - Theme theme = - (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); - finalLabelColor = - componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED - : theme.getOutlineColor(); - } else { - finalLabelColor = - componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED - : LABEL_COLOR; - } - g2d.setColor(finalLabelColor); - g2d.setFont(project.getFont()); - Rectangle bounds = body[0].getBounds(); - drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, - VerticalAlignment.CENTER); +// Color finalLabelColor; +// if (outlineMode) { +// Theme theme = +// (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); +// finalLabelColor = +// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED +// : theme.getOutlineColor(); +// } else { +// finalLabelColor = +// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED +// : LABEL_COLOR; +// } +// g2d.setColor(finalLabelColor); +// g2d.setFont(project.getFont()); +// Rectangle bounds = body[0].getBounds(); +// drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, +// VerticalAlignment.CENTER); + drawMainLabel(g2d, project, outlineMode, componentState); - drawTerminalLabels(g2d, finalLabelColor, project); + drawlTerminalLabels(g2d, finalBorderColor, project); } - @SuppressWarnings("incomplete-switch") + @SuppressWarnings("incomplete-switch") + @Override public Shape[] getBody() { if (body == null) { body = new Shape[4]; @@ -209,6 +208,11 @@ public class PBassPickup extends AbstractSingleOrHumbuckerPickup { } } return body; + } + + @Override + protected int getMainLabelYOffset() { + return (int) (WIDTH.convertToPixels() / 2 - 20); } @Override diff --git a/diylc/diylc-library/src/org/diylc/components/guitar/SingleCoilPickup.java b/diylc/diylc-library/src/org/diylc/components/guitar/SingleCoilPickup.java index af28fc17..4a1ae53f 100644 --- a/diylc/diylc-library/src/org/diylc/components/guitar/SingleCoilPickup.java +++ b/diylc/diylc-library/src/org/diylc/components/guitar/SingleCoilPickup.java @@ -26,7 +26,6 @@ import java.awt.Color; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Point; -import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.Area; @@ -35,12 +34,10 @@ import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; import org.diylc.appframework.miscutils.ConfigurationManager; -import org.diylc.common.HorizontalAlignment; import org.diylc.common.IPlugInPort; import org.diylc.common.ObjectCache; import org.diylc.common.Orientation; import org.diylc.common.OrientationHV; -import org.diylc.common.VerticalAlignment; import org.diylc.components.RoundedPath; import org.diylc.core.ComponentState; import org.diylc.core.IDIYComponent; @@ -121,10 +118,10 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup { g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBaseColor()); g2d.fill(body[4]); g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getColor()); - if (body[0] == null) - g2d.fill(body[3]); + if (body[3] == null) + g2d.fill(body[0]); else - g2d.fill(body[0]); + g2d.fill(body[3]); g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getLugColor()); g2d.fill(body[1]); @@ -170,27 +167,21 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup { g2d.setColor(darkerOrLighter(getPoleColor())); g2d.draw(body[2]); } - - Color finalLabelColor; - if (outlineMode) { - finalLabelColor = - componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED - : theme.getOutlineColor(); - } else { - finalLabelColor = - componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED - : LABEL_COLOR; - } - g2d.setColor(finalLabelColor); - g2d.setFont(project.getFont()); - Rectangle bounds = body[3].getBounds(); - drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER, - VerticalAlignment.CENTER); + + drawMainLabel(g2d, project, outlineMode, componentState); - drawTerminalLabels(g2d, finalLabelColor, project); - } + drawlTerminalLabels(g2d, finalBorderColor, project); + } + + @Override + protected int getMainLabelYOffset() { + if (getPolePieceType() == PolePieceType.RailHumbucker || getPolePieceType() == PolePieceType.RodHumbucker || getPolePieceType() == PolePieceType.None) + return 0; + return (int) (WIDTH.convertToPixels() / 2 - 20); + } - @SuppressWarnings("incomplete-switch") + @SuppressWarnings("incomplete-switch") + @Override public Shape[] getBody() { if (body == null) { body = new Shape[5]; @@ -225,7 +216,7 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup { mainArea.subtract(new Area(new Ellipse2D.Double(x + length / 2 - holeMargin - holeSize / 2, y - lipWidth / 2 - width / 2 - holeSize / 2, holeSize, holeSize))); - body[0] = mainArea; + body[3] = mainArea; RoundedPath basePath = new RoundedPath(baseRadius); basePath.moveTo(x, y + lipWidth / 2); basePath.lineTo(x + lipLength / 2, y + lipWidth / 2); @@ -303,7 +294,7 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup { body[2] = poleArea; - body[3] = + body[0] = new Area(new RoundRectangle2D.Double(x - coilLength / 2, y - coilOffset - width, coilLength, width, width, width)); diff --git a/diylc/diylc-swing/library/main.jar b/diylc/diylc-swing/library/main.jar index 9ef5922d..0bb9725a 100644 Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ