mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Better selection rendering for a few components, mostly
electro-mechanical
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package org.diylc.components;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Area;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
|
||||
|
||||
public abstract class AbstractMultiPartComponent<T> extends AbstractTransparentComponent<T> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public abstract Area[] getBody();
|
||||
|
||||
public void drawSelectionOutline(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
if (componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING) {
|
||||
g2d.setColor(SELECTION_COLOR);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||
g2d.draw(getBodyOutline());
|
||||
}
|
||||
}
|
||||
|
||||
public Area getBodyOutline() {
|
||||
Area[] body = getBody();
|
||||
Area outline = new Area();
|
||||
for (Area b : body)
|
||||
if (b != null)
|
||||
outline.add(b);
|
||||
return outline;
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractMultiPartComponent;
|
||||
import org.diylc.components.transform.CliffJackTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -56,7 +56,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Cliff 1/4\" Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Cliff-style closed panel mount 1/4\" phono jack", stretchable = false,
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J", autoEdit = false, transformer = CliffJackTransformer.class)
|
||||
public class CliffJack1_4 extends AbstractTransparentComponent<String> {
|
||||
public class CliffJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
|
||||
private Point[] controlPoints = new Point[] {new Point(0, 0)};
|
||||
private JackType type = JackType.MONO;
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
transient private Shape[] body;
|
||||
transient private Area[] body;
|
||||
private String value = "";
|
||||
|
||||
public CliffJack1_4() {
|
||||
@@ -129,29 +129,27 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
|
||||
return angle;
|
||||
}
|
||||
|
||||
public Shape[] getBody() {
|
||||
public Area[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Shape[5];
|
||||
body = new Area[5];
|
||||
|
||||
// Create body.
|
||||
int bodyLength = (int) BODY_LENGTH.convertToPixels();
|
||||
int bodyWidth = (int) BODY_WIDTH.convertToPixels();
|
||||
int centerX = (controlPoints[0].x + controlPoints[3].x) / 2;
|
||||
int centerY = (controlPoints[0].y + controlPoints[3].y) / 2;
|
||||
body[0] = new Rectangle(centerX - bodyLength / 2, centerY - bodyWidth / 2, bodyLength, bodyWidth);
|
||||
body[0] = new Area(new Rectangle(centerX - bodyLength / 2, centerY - bodyWidth / 2, bodyLength, bodyWidth));
|
||||
|
||||
int tailLength = (int) TAIL_LENGTH.convertToPixels();
|
||||
body[1] =
|
||||
new RoundRectangle2D.Double(centerX - bodyLength / 2 - tailLength, centerY - bodyWidth / 4, tailLength * 2,
|
||||
bodyWidth / 2, tailLength, tailLength);
|
||||
body[1] = new Area(new RoundRectangle2D.Double(centerX - bodyLength / 2 - tailLength, centerY - bodyWidth / 4, tailLength * 2,
|
||||
bodyWidth / 2, tailLength, tailLength));
|
||||
Area tailArea = new Area(body[1]);
|
||||
tailArea.subtract(new Area(body[0]));
|
||||
body[1] = tailArea;
|
||||
|
||||
body[2] = new Rectangle(centerX + bodyLength / 2, centerY - bodyWidth / 4, tailLength, bodyWidth / 2);
|
||||
body[2] = new Area(new Rectangle(centerX + bodyLength / 2, centerY - bodyWidth / 4, tailLength, bodyWidth / 2));
|
||||
|
||||
body[3] =
|
||||
new Rectangle(centerX + bodyLength / 2 + tailLength, centerY - bodyWidth / 4, tailLength, bodyWidth / 2);
|
||||
body[3] = new Area(new Rectangle(centerX + bodyLength / 2 + tailLength, centerY - bodyWidth / 4, tailLength, bodyWidth / 2));
|
||||
tailArea = new Area(body[3]);
|
||||
int radius = bodyLength / 2 + tailLength * 2;
|
||||
tailArea.intersect(new Area(new Ellipse2D.Double(centerX - radius, centerY - radius, radius * 2, radius * 2)));
|
||||
@@ -215,13 +213,9 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
|
||||
Color finalBorderColor;
|
||||
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
if (outlineMode) {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
finalBorderColor = theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: BORDER_COLOR;
|
||||
finalBorderColor = BORDER_COLOR;
|
||||
}
|
||||
|
||||
g2d.setColor(finalBorderColor);
|
||||
@@ -253,6 +247,8 @@ public class CliffJack1_4 extends AbstractTransparentComponent<String> {
|
||||
int centerX = (controlPoints[0].x + controlPoints[3].x) / 2;
|
||||
int centerY = (controlPoints[0].y + controlPoints[3].y) / 2;
|
||||
drawCenteredText(g2d, name, centerX, centerY, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
|
||||
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractMultiPartComponent;
|
||||
import org.diylc.components.transform.ClosedJackTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -56,7 +56,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Closed 1/4\" Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Enclosed panel mount 1/4\" phono jack", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
||||
instanceNamePrefix = "J", autoEdit = false, transformer = ClosedJackTransformer.class)
|
||||
public class ClosedJack1_4 extends AbstractTransparentComponent<String> {
|
||||
public class ClosedJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ClosedJack1_4 extends AbstractTransparentComponent<String> {
|
||||
private Point[] controlPoints = new Point[] {new Point(0, 0)};
|
||||
private JackType type = JackType.MONO;
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
transient private Shape[] body;
|
||||
transient private Area[] body;
|
||||
private String value = "";
|
||||
|
||||
public ClosedJack1_4() {
|
||||
@@ -129,9 +129,9 @@ public class ClosedJack1_4 extends AbstractTransparentComponent<String> {
|
||||
return angle;
|
||||
}
|
||||
|
||||
public Shape[] getBody() {
|
||||
public Area[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Shape[5];
|
||||
body = new Area[5];
|
||||
|
||||
// Create body.
|
||||
int x = controlPoints[0].x;
|
||||
@@ -170,7 +170,7 @@ public class ClosedJack1_4 extends AbstractTransparentComponent<String> {
|
||||
}
|
||||
Area pathArea = new Area(path);
|
||||
pathArea.intersect(shaft);
|
||||
body[2] = path;
|
||||
body[2] = new Area(path);
|
||||
|
||||
// Create lugs.
|
||||
Area lugs = new Area();
|
||||
@@ -234,13 +234,9 @@ public class ClosedJack1_4 extends AbstractTransparentComponent<String> {
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
finalBorderColor = theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: BORDER_COLOR;
|
||||
finalBorderColor = BORDER_COLOR;
|
||||
}
|
||||
|
||||
g2d.setColor(finalBorderColor);
|
||||
@@ -274,6 +270,8 @@ public class ClosedJack1_4 extends AbstractTransparentComponent<String> {
|
||||
int centerX = bounds.x + bounds.width / 2;
|
||||
int centerY = bounds.y + bounds.height / 2;
|
||||
drawCenteredText(g2d, name, centerX, centerY, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
|
||||
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.diylc.common.Display;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractMultiPartComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -54,7 +54,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Fuse Holder (Panel)", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Panel mounted fuse holder", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
||||
instanceNamePrefix = "FH", autoEdit = false)
|
||||
public class FuseHolderPanel extends AbstractTransparentComponent<String> {
|
||||
public class FuseHolderPanel extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -188,13 +188,9 @@ public class FuseHolderPanel extends AbstractTransparentComponent<String> {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
Color finalBorderColor;
|
||||
if (outlineMode) {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
finalBorderColor = theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: getBorderColor();
|
||||
finalBorderColor = getBorderColor();
|
||||
}
|
||||
g2d.setColor(finalBorderColor);
|
||||
for (Area a : body)
|
||||
@@ -255,8 +251,11 @@ public class FuseHolderPanel extends AbstractTransparentComponent<String> {
|
||||
int x = bounds.x + (bounds.width - textWidth) / 2;
|
||||
int y = bounds.y + (bounds.height - textHeight) / 2 + fontMetrics.getAscent();
|
||||
g2d.drawString(label, x, y);
|
||||
|
||||
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Area[] getBody() {
|
||||
if (body == null) {
|
||||
Point firstPoint = controlPoints[0];
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractMultiPartComponent;
|
||||
import org.diylc.components.RoundedPolygon;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -52,7 +52,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "IEC Socket", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Panel mounted IEC power socket", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
||||
instanceNamePrefix = "IEC", autoEdit = false)
|
||||
public class IECSocket extends AbstractTransparentComponent<String> {
|
||||
public class IECSocket extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -209,13 +209,9 @@ public class IECSocket extends AbstractTransparentComponent<String> {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
Color finalBorderColor;
|
||||
if (outlineMode) {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
finalBorderColor = theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: getBorderColor();
|
||||
finalBorderColor = getBorderColor();
|
||||
}
|
||||
g2d.setColor(finalBorderColor);
|
||||
for (Area a : body)
|
||||
@@ -245,6 +241,8 @@ public class IECSocket extends AbstractTransparentComponent<String> {
|
||||
g2d.fillRect(p.x - lugWidth / 2, p.y - lugHeight / 2, lugWidth, lugHeight);
|
||||
}
|
||||
}
|
||||
|
||||
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractMultiPartComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -54,7 +54,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Open 1/4\" Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Switchcraft-style open panel mount 1/4\" phono jack, stereo and mono", stretchable = false,
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J")
|
||||
public class OpenJack1_4 extends AbstractTransparentComponent<String> {
|
||||
public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class OpenJack1_4 extends AbstractTransparentComponent<String> {
|
||||
|
||||
private String value = "";
|
||||
private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
||||
transient Shape[] body;
|
||||
transient Area[] body;
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
private JackType type = JackType.MONO;
|
||||
private boolean showLabels = true;
|
||||
@@ -89,14 +89,14 @@ public class OpenJack1_4 extends AbstractTransparentComponent<String> {
|
||||
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
// if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : WAFER_COLOR);
|
||||
g2d.fill(body[0]);
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : WAFER_COLOR);
|
||||
g2d.fill(body[0]);
|
||||
|
||||
g2d.setComposite(oldComposite);
|
||||
g2d.setComposite(oldComposite);
|
||||
// }
|
||||
|
||||
Color finalBorderColor;
|
||||
@@ -104,13 +104,9 @@ public class OpenJack1_4 extends AbstractTransparentComponent<String> {
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
finalBorderColor = theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: WAFER_COLOR.darker();
|
||||
finalBorderColor = WAFER_COLOR.darker();
|
||||
}
|
||||
|
||||
g2d.setColor(finalBorderColor);
|
||||
@@ -136,13 +132,9 @@ public class OpenJack1_4 extends AbstractTransparentComponent<String> {
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
finalBorderColor = theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: BASE_COLOR.darker();
|
||||
finalBorderColor = BASE_COLOR.darker();
|
||||
}
|
||||
|
||||
g2d.setColor(finalBorderColor);
|
||||
@@ -192,12 +184,14 @@ public class OpenJack1_4 extends AbstractTransparentComponent<String> {
|
||||
if (getType() == JackType.STEREO)
|
||||
drawCenteredText(g2d, "R", ringLabel.x, ringLabel.y, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
}
|
||||
|
||||
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public Shape[] getBody() {
|
||||
public Area[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Shape[4];
|
||||
body = new Area[4];
|
||||
|
||||
int x = controlPoints[0].x;
|
||||
int y = controlPoints[0].y;
|
||||
|
||||
+8
-19
@@ -26,24 +26,19 @@ import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.RadialGradientPaint;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractMultiPartComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -59,7 +54,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Pilot Lamp Holder", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Fender-style pilot bulb holder for T2 and T-3 ¼ miniature bayonet lamps", stretchable = false,
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PL")
|
||||
public class PilotLampHolder extends AbstractTransparentComponent<String> {
|
||||
public class PilotLampHolder extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -110,13 +105,9 @@ public class PilotLampHolder extends AbstractTransparentComponent<String> {
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
finalBorderColor = theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: WAFER_COLOR.darker();
|
||||
finalBorderColor = WAFER_COLOR.darker();
|
||||
}
|
||||
|
||||
g2d.setColor(finalBorderColor);
|
||||
@@ -146,13 +137,9 @@ public class PilotLampHolder extends AbstractTransparentComponent<String> {
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
finalBorderColor = theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: BASE_COLOR.darker();
|
||||
finalBorderColor = BASE_COLOR.darker();
|
||||
}
|
||||
|
||||
g2d.setColor(finalBorderColor);
|
||||
@@ -163,6 +150,8 @@ public class PilotLampHolder extends AbstractTransparentComponent<String> {
|
||||
|
||||
g2d.draw(body[1]);
|
||||
g2d.draw(body[2]);
|
||||
|
||||
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractMultiPartComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -52,7 +52,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Plastic DC Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Panel mount plastic DC jack", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
||||
instanceNamePrefix = "J", autoEdit = false)
|
||||
public class PlasticDCJack extends AbstractTransparentComponent<String> {
|
||||
public class PlasticDCJack extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -68,7 +68,7 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
|
||||
private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
||||
private String value = "";
|
||||
private DCPolarity polarity = DCPolarity.CENTER_NEGATIVE;
|
||||
transient private Shape[] body;
|
||||
transient private Area[] body;
|
||||
|
||||
public PlasticDCJack() {
|
||||
updateControlPoints();
|
||||
@@ -86,18 +86,19 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
|
||||
controlPoints[2] = new Point(x - spacing, y + spacing * 2);
|
||||
}
|
||||
|
||||
public Shape[] getBody() {
|
||||
@Override
|
||||
public Area[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Shape[4];
|
||||
body = new Area[4];
|
||||
|
||||
int x = controlPoints[0].x;
|
||||
int y = controlPoints[0].y;
|
||||
int spacing = (int) SPACING.convertToPixels();
|
||||
int diameter = getClosestOdd(DIAMETER.convertToPixels());
|
||||
body[0] = new Ellipse2D.Double(x - diameter / 2, y + spacing - diameter / 2, diameter, diameter);
|
||||
body[0] = new Area(new Ellipse2D.Double(x - diameter / 2, y + spacing - diameter / 2, diameter, diameter));
|
||||
|
||||
int rectWidth = (int) (diameter / Math.sqrt(2)) - 2;
|
||||
body[1] = new Rectangle(x - rectWidth / 2, y + spacing - rectWidth / 2, rectWidth, rectWidth);
|
||||
body[1] = new Area(new Rectangle(x - rectWidth / 2, y + spacing - rectWidth / 2, rectWidth, rectWidth));
|
||||
|
||||
int lugWidth = getClosestOdd(LUG_WIDTH.convertToPixels());
|
||||
int lugThickness = getClosestOdd(LUG_THICKNESS.convertToPixels());
|
||||
@@ -134,17 +135,17 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
|
||||
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
// if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BODY_COLOR);
|
||||
g2d.fill(body[0]);
|
||||
if (!outlineMode) {
|
||||
g2d.setColor(PHENOLIC_COLOR);
|
||||
g2d.fill(body[1]);
|
||||
}
|
||||
g2d.setComposite(oldComposite);
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BODY_COLOR);
|
||||
g2d.fill(body[0]);
|
||||
if (!outlineMode) {
|
||||
g2d.setColor(PHENOLIC_COLOR);
|
||||
g2d.fill(body[1]);
|
||||
}
|
||||
g2d.setComposite(oldComposite);
|
||||
// }
|
||||
|
||||
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
@@ -186,6 +187,8 @@ public class PlasticDCJack extends AbstractTransparentComponent<String> {
|
||||
drawCenteredText(g2d, getPolarity() == DCPolarity.CENTER_NEGATIVE ? "_" : "+", controlPoints[2].x,
|
||||
controlPoints[2].y - spacing * 3 / 4, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
}
|
||||
|
||||
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.AbstractMultiPartComponent;
|
||||
import org.diylc.components.transform.DIL_ICTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -59,7 +59,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Audio Transformer", author = "Branislav Stojkovic", category = "Passive",
|
||||
instanceNamePrefix = "TR", description = "Small signal audio transformer with EI core", stretchable = false,
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = DIL_ICTransformer.class)
|
||||
public class AudioTransformer extends AbstractTransparentComponent<String> {
|
||||
public class AudioTransformer extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -205,6 +205,7 @@ public class AudioTransformer extends AbstractTransparentComponent<String> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Area[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Area[2];
|
||||
@@ -287,13 +288,9 @@ public class AudioTransformer extends AbstractTransparentComponent<String> {
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
finalBorderColor = theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: getCoilBorderColor();
|
||||
finalBorderColor = getCoilBorderColor();
|
||||
}
|
||||
g2d.setColor(finalBorderColor);
|
||||
g2d.draw(coilArea);
|
||||
@@ -303,11 +300,9 @@ public class AudioTransformer extends AbstractTransparentComponent<String> {
|
||||
g2d.fill(coreArea);
|
||||
g2d.setComposite(oldComposite);
|
||||
|
||||
if (!outlineMode) {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: getCoreBorderColor();
|
||||
}
|
||||
if (!outlineMode)
|
||||
finalBorderColor = getCoreBorderColor();
|
||||
|
||||
g2d.setColor(finalBorderColor);
|
||||
g2d.draw(coreArea);
|
||||
|
||||
@@ -383,6 +378,8 @@ public class AudioTransformer extends AbstractTransparentComponent<String> {
|
||||
g2d.setTransform(oldTransform);
|
||||
}
|
||||
}
|
||||
|
||||
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Binary file not shown.
@@ -2317,5 +2317,21 @@
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>3</major>
|
||||
<minor>51</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2019-01-23 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Better selection rendering for a few components, mostly electro-mechanical</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
</a>
|
||||
</java.util.Arrays_-ArrayList>
|
||||
|
||||
Reference in New Issue
Block a user