mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
improve pickup label rendering
This commit is contained in:
@@ -18,20 +18,28 @@
|
|||||||
package org.diylc.components.guitar;
|
package org.diylc.components.guitar;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
|
||||||
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.common.HorizontalAlignment;
|
import org.diylc.common.HorizontalAlignment;
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.common.OrientationHV;
|
import org.diylc.common.OrientationHV;
|
||||||
import org.diylc.common.VerticalAlignment;
|
import org.diylc.common.VerticalAlignment;
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.Theme;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
public abstract class AbstractGuitarPickup extends AbstractTransparentComponent<String> {
|
public abstract class AbstractGuitarPickup extends AbstractTransparentComponent<String> {
|
||||||
|
|
||||||
@@ -39,7 +47,7 @@ public abstract class AbstractGuitarPickup extends AbstractTransparentComponent<
|
|||||||
|
|
||||||
protected static Size POINT_SPACING = new Size(0.1d, SizeUnit.in);
|
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 String value = "";
|
||||||
protected Orientation orientation = Orientation.DEFAULT;
|
protected Orientation orientation = Orientation.DEFAULT;
|
||||||
@@ -50,11 +58,13 @@ public abstract class AbstractGuitarPickup extends AbstractTransparentComponent<
|
|||||||
|
|
||||||
protected Polarity polarity = Polarity.North;
|
protected Polarity polarity = Polarity.North;
|
||||||
|
|
||||||
|
protected Color labelColor;
|
||||||
|
|
||||||
public AbstractGuitarPickup() {
|
public AbstractGuitarPickup() {
|
||||||
updateControlPoints();
|
updateControlPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawTerminalLabels(Graphics2D g2d, Color color, Project project) {
|
protected void drawlTerminalLabels(Graphics2D g2d, Color color, Project project) {
|
||||||
Point[] points = getControlPoints();
|
Point[] points = getControlPoints();
|
||||||
g2d.setColor(color);
|
g2d.setColor(color);
|
||||||
|
|
||||||
@@ -78,10 +88,47 @@ public abstract class AbstractGuitarPickup extends AbstractTransparentComponent<
|
|||||||
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? -TERMINAL_FONT_SIZE : 0;
|
dx = getControlPointDirection() == OrientationHV.HORIZONTAL ? -TERMINAL_FONT_SIZE : 0;
|
||||||
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : -(int) (TERMINAL_FONT_SIZE * 0.8);
|
dy = getControlPointDirection() == OrientationHV.HORIZONTAL ? 0 : -(int) (TERMINAL_FONT_SIZE * 0.8);
|
||||||
break;
|
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, "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")
|
@EditableProperty(name = "Model")
|
||||||
@@ -153,6 +200,17 @@ public abstract class AbstractGuitarPickup extends AbstractTransparentComponent<
|
|||||||
body = null;
|
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();
|
protected abstract OrientationHV getControlPointDirection();
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
@SuppressWarnings("incomplete-switch")
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ public abstract class AbstractSingleOrHumbuckerPickup extends AbstractGuitarPick
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawTerminalLabels(Graphics2D g2d, Color color, Project project) {
|
protected void drawlTerminalLabels(Graphics2D g2d, Color color, Project project) {
|
||||||
Point[] points = getControlPoints();
|
Point[] points = getControlPoints();
|
||||||
g2d.setColor(color);
|
g2d.setColor(color);
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import java.awt.Color;
|
|||||||
import java.awt.Composite;
|
import java.awt.Composite;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.Stroke;
|
import java.awt.Stroke;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
@@ -33,12 +32,10 @@ import java.awt.geom.Rectangle2D;
|
|||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.common.HorizontalAlignment;
|
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.common.OrientationHV;
|
import org.diylc.common.OrientationHV;
|
||||||
import org.diylc.common.VerticalAlignment;
|
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
@@ -173,26 +170,10 @@ public class HumbuckerPickup extends AbstractGuitarPickup {
|
|||||||
g2d.setColor(finalBorderColor);
|
g2d.setColor(finalBorderColor);
|
||||||
g2d.draw(body[0]);
|
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
|
@Override
|
||||||
@@ -201,7 +182,8 @@ public class HumbuckerPickup extends AbstractGuitarPickup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
@SuppressWarnings("incomplete-switch")
|
||||||
public Shape[] getBody() {
|
@Override
|
||||||
|
protected Shape[] getBody() {
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
body = new Shape[7];
|
body = new Shape[7];
|
||||||
|
|
||||||
@@ -384,6 +366,11 @@ public class HumbuckerPickup extends AbstractGuitarPickup {
|
|||||||
}
|
}
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getMainLabelYOffset() {
|
||||||
|
return (int) (getType().getWidth().convertToPixels() / 2 - 20);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import java.awt.Color;
|
|||||||
import java.awt.Composite;
|
import java.awt.Composite;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
@@ -34,12 +33,10 @@ import java.awt.geom.Ellipse2D;
|
|||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.common.HorizontalAlignment;
|
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.common.OrientationHV;
|
import org.diylc.common.OrientationHV;
|
||||||
import org.diylc.common.VerticalAlignment;
|
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
@@ -119,29 +116,30 @@ public class JazzBassPickup extends AbstractSingleOrHumbuckerPickup {
|
|||||||
g2d.draw(body[3]);
|
g2d.draw(body[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color finalLabelColor;
|
// Color finalLabelColor;
|
||||||
if (outlineMode) {
|
// if (outlineMode) {
|
||||||
Theme theme =
|
// Theme theme =
|
||||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
// (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
finalLabelColor =
|
// finalLabelColor =
|
||||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
: theme.getOutlineColor();
|
// : theme.getOutlineColor();
|
||||||
} else {
|
// } else {
|
||||||
finalLabelColor =
|
// finalLabelColor =
|
||||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
: LABEL_COLOR;
|
// : LABEL_COLOR;
|
||||||
}
|
// }
|
||||||
g2d.setColor(finalLabelColor);
|
// g2d.setColor(finalLabelColor);
|
||||||
g2d.setFont(project.getFont());
|
// g2d.setFont(project.getFont());
|
||||||
Rectangle bounds = body[0].getBounds();
|
// Rectangle bounds = body[0].getBounds();
|
||||||
drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
|
// drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
|
||||||
VerticalAlignment.CENTER);
|
// VerticalAlignment.CENTER);
|
||||||
|
drawMainLabel(g2d, project, outlineMode, componentState);
|
||||||
// terminal labels
|
|
||||||
drawTerminalLabels(g2d, finalLabelColor, project);
|
drawlTerminalLabels(g2d, finalBorderColor, project);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
@SuppressWarnings("incomplete-switch")
|
||||||
|
@Override
|
||||||
public Shape[] getBody() {
|
public Shape[] getBody() {
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
body = new Shape[4];
|
body = new Shape[4];
|
||||||
@@ -222,6 +220,11 @@ public class JazzBassPickup extends AbstractSingleOrHumbuckerPickup {
|
|||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getMainLabelYOffset() {
|
||||||
|
return (int) (WIDTH.convertToPixels() / 2 - 20);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OrientationHV getControlPointDirection() {
|
protected OrientationHV getControlPointDirection() {
|
||||||
return OrientationHV.VERTICAL;
|
return OrientationHV.VERTICAL;
|
||||||
|
|||||||
@@ -35,12 +35,10 @@ import java.awt.geom.Ellipse2D;
|
|||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.common.HorizontalAlignment;
|
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.common.OrientationHV;
|
import org.diylc.common.OrientationHV;
|
||||||
import org.diylc.common.VerticalAlignment;
|
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
@@ -136,60 +134,63 @@ public class P90Pickup extends AbstractSingleOrHumbuckerPickup {
|
|||||||
g2d.draw(body[3]);
|
g2d.draw(body[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color finalLabelColor;
|
// Color finalLabelColor;
|
||||||
if (outlineMode) {
|
// if (outlineMode) {
|
||||||
Theme theme =
|
// Theme theme =
|
||||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
// (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
finalLabelColor =
|
// finalLabelColor =
|
||||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
: theme.getOutlineColor();
|
// : theme.getOutlineColor();
|
||||||
} else {
|
// } else {
|
||||||
finalLabelColor =
|
// finalLabelColor =
|
||||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
: LABEL_COLOR;
|
// : LABEL_COLOR;
|
||||||
}
|
// }
|
||||||
g2d.setColor(finalLabelColor);
|
// g2d.setColor(finalLabelColor);
|
||||||
g2d.setFont(project.getFont());
|
// g2d.setFont(project.getFont());
|
||||||
Rectangle bounds = body[0].getBounds();
|
// Rectangle bounds = body[0].getBounds();
|
||||||
drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
|
// drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
|
||||||
VerticalAlignment.CENTER);
|
// VerticalAlignment.CENTER);
|
||||||
|
drawMainLabel(g2d, project, outlineMode, componentState);
|
||||||
|
|
||||||
|
drawlTerminalLabels(g2d, finalBorderColor, project);
|
||||||
// terminal labels
|
// terminal labels
|
||||||
Point[] points = getControlPoints();
|
// Point[] points = getControlPoints();
|
||||||
g2d.setColor(finalBorderColor);
|
// g2d.setColor(finalBorderColor);
|
||||||
|
//
|
||||||
g2d.setFont(project.getFont().deriveFont(TERMINAL_FONT_SIZE * 1f));
|
// g2d.setFont(project.getFont().deriveFont(TERMINAL_FONT_SIZE * 1f));
|
||||||
int dx = 0;
|
// int dx = 0;
|
||||||
int dy = 0;
|
// int dy = 0;
|
||||||
switch (orientation) {
|
// switch (orientation) {
|
||||||
case DEFAULT:
|
// case DEFAULT:
|
||||||
dx = (int) (TERMINAL_FONT_SIZE * 0.8);
|
// dx = (int) (TERMINAL_FONT_SIZE * 0.8);
|
||||||
dy = 0;
|
// dy = 0;
|
||||||
break;
|
// break;
|
||||||
case _90:
|
// case _90:
|
||||||
dx = 0;
|
// dx = 0;
|
||||||
dy = (int) (TERMINAL_FONT_SIZE * 0.8);
|
// dy = (int) (TERMINAL_FONT_SIZE * 0.8);
|
||||||
break;
|
// break;
|
||||||
case _180:
|
// case _180:
|
||||||
dx = -(int) (TERMINAL_FONT_SIZE * 0.8);
|
// dx = -(int) (TERMINAL_FONT_SIZE * 0.8);
|
||||||
dy = 0;
|
// dy = 0;
|
||||||
break;
|
// break;
|
||||||
case _270:
|
// case _270:
|
||||||
dx = 0;
|
// dx = 0;
|
||||||
dy = -(int) (TERMINAL_FONT_SIZE * 0.8);
|
// dy = -(int) (TERMINAL_FONT_SIZE * 0.8);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (getPolarity() == Polarity.North || getPolarity() == Polarity.South) {
|
// 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,
|
// 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);
|
// VerticalAlignment.CENTER);
|
||||||
} else {
|
// } 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, "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);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
@SuppressWarnings("incomplete-switch")
|
||||||
|
@Override
|
||||||
public Shape[] getBody() {
|
public Shape[] getBody() {
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
body = new Shape[4];
|
body = new Shape[4];
|
||||||
@@ -272,6 +273,11 @@ public class P90Pickup extends AbstractSingleOrHumbuckerPickup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return body;
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getMainLabelYOffset() {
|
||||||
|
return (int) (getType().getWidth().convertToPixels() / 2 - 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import java.awt.Color;
|
|||||||
import java.awt.Composite;
|
import java.awt.Composite;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
@@ -34,12 +33,10 @@ import java.awt.geom.Ellipse2D;
|
|||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.common.HorizontalAlignment;
|
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.common.OrientationHV;
|
import org.diylc.common.OrientationHV;
|
||||||
import org.diylc.common.VerticalAlignment;
|
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
@@ -117,28 +114,30 @@ public class PBassPickup extends AbstractSingleOrHumbuckerPickup {
|
|||||||
g2d.draw(body[3]);
|
g2d.draw(body[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color finalLabelColor;
|
// Color finalLabelColor;
|
||||||
if (outlineMode) {
|
// if (outlineMode) {
|
||||||
Theme theme =
|
// Theme theme =
|
||||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
// (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||||
finalLabelColor =
|
// finalLabelColor =
|
||||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
: theme.getOutlineColor();
|
// : theme.getOutlineColor();
|
||||||
} else {
|
// } else {
|
||||||
finalLabelColor =
|
// finalLabelColor =
|
||||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
|
||||||
: LABEL_COLOR;
|
// : LABEL_COLOR;
|
||||||
}
|
// }
|
||||||
g2d.setColor(finalLabelColor);
|
// g2d.setColor(finalLabelColor);
|
||||||
g2d.setFont(project.getFont());
|
// g2d.setFont(project.getFont());
|
||||||
Rectangle bounds = body[0].getBounds();
|
// Rectangle bounds = body[0].getBounds();
|
||||||
drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
|
// drawCenteredText(g2d, value, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, HorizontalAlignment.CENTER,
|
||||||
VerticalAlignment.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() {
|
public Shape[] getBody() {
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
body = new Shape[4];
|
body = new Shape[4];
|
||||||
@@ -209,6 +208,11 @@ public class PBassPickup extends AbstractSingleOrHumbuckerPickup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return body;
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getMainLabelYOffset() {
|
||||||
|
return (int) (WIDTH.convertToPixels() / 2 - 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import java.awt.Color;
|
|||||||
import java.awt.Composite;
|
import java.awt.Composite;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
@@ -35,12 +34,10 @@ import java.awt.geom.Rectangle2D;
|
|||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.common.HorizontalAlignment;
|
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.common.OrientationHV;
|
import org.diylc.common.OrientationHV;
|
||||||
import org.diylc.common.VerticalAlignment;
|
|
||||||
import org.diylc.components.RoundedPath;
|
import org.diylc.components.RoundedPath;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
@@ -121,10 +118,10 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup {
|
|||||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBaseColor());
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBaseColor());
|
||||||
g2d.fill(body[4]);
|
g2d.fill(body[4]);
|
||||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getColor());
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getColor());
|
||||||
if (body[0] == null)
|
if (body[3] == null)
|
||||||
g2d.fill(body[3]);
|
g2d.fill(body[0]);
|
||||||
else
|
else
|
||||||
g2d.fill(body[0]);
|
g2d.fill(body[3]);
|
||||||
|
|
||||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getLugColor());
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getLugColor());
|
||||||
g2d.fill(body[1]);
|
g2d.fill(body[1]);
|
||||||
@@ -170,27 +167,21 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup {
|
|||||||
g2d.setColor(darkerOrLighter(getPoleColor()));
|
g2d.setColor(darkerOrLighter(getPoleColor()));
|
||||||
g2d.draw(body[2]);
|
g2d.draw(body[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color finalLabelColor;
|
drawMainLabel(g2d, project, outlineMode, componentState);
|
||||||
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);
|
|
||||||
|
|
||||||
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() {
|
public Shape[] getBody() {
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
body = new Shape[5];
|
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
|
mainArea.subtract(new Area(new Ellipse2D.Double(x + length / 2 - holeMargin - holeSize / 2, y - lipWidth / 2
|
||||||
- width / 2 - holeSize / 2, holeSize, holeSize)));
|
- width / 2 - holeSize / 2, holeSize, holeSize)));
|
||||||
|
|
||||||
body[0] = mainArea;
|
body[3] = mainArea;
|
||||||
RoundedPath basePath = new RoundedPath(baseRadius);
|
RoundedPath basePath = new RoundedPath(baseRadius);
|
||||||
basePath.moveTo(x, y + lipWidth / 2);
|
basePath.moveTo(x, y + lipWidth / 2);
|
||||||
basePath.lineTo(x + lipLength / 2, y + lipWidth / 2);
|
basePath.lineTo(x + lipLength / 2, y + lipWidth / 2);
|
||||||
@@ -303,7 +294,7 @@ public class SingleCoilPickup extends AbstractSingleOrHumbuckerPickup {
|
|||||||
|
|
||||||
body[2] = poleArea;
|
body[2] = poleArea;
|
||||||
|
|
||||||
body[3] =
|
body[0] =
|
||||||
new Area(new RoundRectangle2D.Double(x - coilLength / 2, y - coilOffset - width, coilLength, width, width,
|
new Area(new RoundRectangle2D.Double(x - coilLength / 2, y - coilOffset - width, coilLength, width, width,
|
||||||
width));
|
width));
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user