mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
undo relay - was already there (doh!)
This commit is contained in:
+452
-452
@@ -1,452 +1,452 @@
|
|||||||
package org.diylc.components.electromechanical;
|
//package org.diylc.components.electromechanical;
|
||||||
|
//
|
||||||
import java.awt.AlphaComposite;
|
//import java.awt.AlphaComposite;
|
||||||
import java.awt.Color;
|
//import java.awt.Color;
|
||||||
import java.awt.Composite;
|
//import java.awt.Composite;
|
||||||
import java.awt.FontMetrics;
|
//import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics2D;
|
//import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
//import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
//import java.awt.Rectangle;
|
||||||
import java.awt.geom.Area;
|
//import java.awt.geom.Area;
|
||||||
import java.awt.geom.Rectangle2D;
|
//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.Display;
|
//import org.diylc.common.Display;
|
||||||
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.components.AbstractTransparentComponent;
|
//import org.diylc.components.AbstractTransparentComponent;
|
||||||
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;
|
||||||
import org.diylc.core.Project;
|
//import org.diylc.core.Project;
|
||||||
import org.diylc.core.Theme;
|
//import org.diylc.core.Theme;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
//import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
//import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
//import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.annotations.KeywordPolicy;
|
//import org.diylc.core.annotations.KeywordPolicy;
|
||||||
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;
|
//import org.diylc.utils.Constants;
|
||||||
|
//
|
||||||
@ComponentDescriptor(name = "Subminiature DIL Relay", author = "Branislav Stojkovic", category = "Electromechanical",
|
//@ComponentDescriptor(name = "Subminiature DIL Relay", author = "Branislav Stojkovic", category = "Electromechanical",
|
||||||
instanceNamePrefix = "RY", description = "Subminiature DIL relay with one or two poles", stretchable = false,
|
// instanceNamePrefix = "RY", description = "Subminiature DIL relay with one or two poles", stretchable = false,
|
||||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
|
// zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
|
||||||
public class SubminiatureDILRelay extends AbstractTransparentComponent<String> {
|
//public class SubminiatureDILRelay extends AbstractTransparentComponent<String> {
|
||||||
|
//
|
||||||
private static final long serialVersionUID = 1L;
|
// private static final long serialVersionUID = 1L;
|
||||||
|
//
|
||||||
public static Color BODY_COLOR = Color.decode("#EDEDD5");
|
// public static Color BODY_COLOR = Color.decode("#EDEDD5");
|
||||||
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
// public static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||||
public static Color PIN_COLOR = Color.decode("#00B2EE");
|
// public static Color PIN_COLOR = Color.decode("#00B2EE");
|
||||||
public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
|
// public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
|
||||||
public static Color INDENT_COLOR = Color.gray.darker();
|
// public static Color INDENT_COLOR = Color.gray.darker();
|
||||||
public static Color LABEL_COLOR = Color.darkGray;
|
// public static Color LABEL_COLOR = Color.darkGray;
|
||||||
public static int EDGE_RADIUS = 6;
|
// public static int EDGE_RADIUS = 6;
|
||||||
public static Size PIN_SIZE = new Size(0.04d, SizeUnit.in);
|
// public static Size PIN_SIZE = new Size(0.04d, SizeUnit.in);
|
||||||
public static Size INDENT_SIZE = new Size(0.05d, SizeUnit.in);
|
// public static Size INDENT_SIZE = new Size(0.05d, SizeUnit.in);
|
||||||
|
//
|
||||||
public static Size PIN_SPACING = new Size(0.2d, SizeUnit.in);
|
// public static Size PIN_SPACING = new Size(0.2d, SizeUnit.in);
|
||||||
public static Size ROW_SPACING = new Size(0.3d, SizeUnit.in);
|
// public static Size ROW_SPACING = new Size(0.3d, SizeUnit.in);
|
||||||
public static Size SECTION_SPACING = new Size(0.3d, SizeUnit.in);
|
// public static Size SECTION_SPACING = new Size(0.3d, SizeUnit.in);
|
||||||
|
//
|
||||||
private String value = "";
|
// private String value = "";
|
||||||
private Orientation orientation = Orientation.DEFAULT;
|
// private Orientation orientation = Orientation.DEFAULT;
|
||||||
private PinCount pinCount = PinCount._4;
|
// private PinCount pinCount = PinCount._4;
|
||||||
private Size pinSpacing = PIN_SPACING;
|
// private Size pinSpacing = PIN_SPACING;
|
||||||
private Size rowSpacing = ROW_SPACING;
|
// private Size rowSpacing = ROW_SPACING;
|
||||||
private Size sectionSpacing = SECTION_SPACING;
|
// private Size sectionSpacing = SECTION_SPACING;
|
||||||
private Point[] controlPoints = new Point[] {new Point(0, 0)};
|
// private Point[] controlPoints = new Point[] {new Point(0, 0)};
|
||||||
protected Display display = Display.NAME;
|
// protected Display display = Display.NAME;
|
||||||
private Color bodyColor = BODY_COLOR;
|
// private Color bodyColor = BODY_COLOR;
|
||||||
private Color borderColor = BORDER_COLOR;
|
// private Color borderColor = BORDER_COLOR;
|
||||||
private Color labelColor = LABEL_COLOR;
|
// private Color labelColor = LABEL_COLOR;
|
||||||
private Color indentColor = INDENT_COLOR;
|
// private Color indentColor = INDENT_COLOR;
|
||||||
transient private Area[] body;
|
// transient private Area[] body;
|
||||||
|
//
|
||||||
public SubminiatureDILRelay() {
|
// public SubminiatureDILRelay() {
|
||||||
super();
|
// super();
|
||||||
updateControlPoints();
|
// updateControlPoints();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EditableProperty
|
// @EditableProperty
|
||||||
public String getValue() {
|
// public String getValue() {
|
||||||
return value;
|
// return value;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setValue(String value) {
|
// public void setValue(String value) {
|
||||||
this.value = value;
|
// this.value = value;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EditableProperty
|
// @EditableProperty
|
||||||
public Orientation getOrientation() {
|
// public Orientation getOrientation() {
|
||||||
return orientation;
|
// return orientation;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setOrientation(Orientation orientation) {
|
// public void setOrientation(Orientation orientation) {
|
||||||
this.orientation = orientation;
|
// this.orientation = orientation;
|
||||||
updateControlPoints();
|
// updateControlPoints();
|
||||||
// Reset body shape.
|
// // Reset body shape.
|
||||||
body = null;
|
// body = null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EditableProperty(name = "Contacts")
|
// @EditableProperty(name = "Contacts")
|
||||||
public PinCount getPinCount() {
|
// public PinCount getPinCount() {
|
||||||
return pinCount;
|
// return pinCount;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setPinCount(PinCount pinCount) {
|
// public void setPinCount(PinCount pinCount) {
|
||||||
this.pinCount = pinCount;
|
// this.pinCount = pinCount;
|
||||||
updateControlPoints();
|
// updateControlPoints();
|
||||||
// Reset body shape;
|
// // Reset body shape;
|
||||||
body = null;
|
// body = null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EditableProperty(name = "Pin spacing")
|
// @EditableProperty(name = "Pin spacing")
|
||||||
public Size getPinSpacing() {
|
// public Size getPinSpacing() {
|
||||||
return pinSpacing;
|
// return pinSpacing;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setPinSpacing(Size pinSpacing) {
|
// public void setPinSpacing(Size pinSpacing) {
|
||||||
this.pinSpacing = pinSpacing;
|
// this.pinSpacing = pinSpacing;
|
||||||
updateControlPoints();
|
// updateControlPoints();
|
||||||
// Reset body shape;
|
// // Reset body shape;
|
||||||
body = null;
|
// body = null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EditableProperty(name = "Row spacing")
|
// @EditableProperty(name = "Row spacing")
|
||||||
public Size getRowSpacing() {
|
// public Size getRowSpacing() {
|
||||||
return rowSpacing;
|
// return rowSpacing;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setRowSpacing(Size rowSpacing) {
|
// public void setRowSpacing(Size rowSpacing) {
|
||||||
this.rowSpacing = rowSpacing;
|
// this.rowSpacing = rowSpacing;
|
||||||
updateControlPoints();
|
// updateControlPoints();
|
||||||
// Reset body shape;
|
// // Reset body shape;
|
||||||
body = null;
|
// body = null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EditableProperty(name = "Section spacing")
|
// @EditableProperty(name = "Section spacing")
|
||||||
public Size getSectionSpacing() {
|
// public Size getSectionSpacing() {
|
||||||
return sectionSpacing;
|
// return sectionSpacing;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setSectionSpacing(Size sectionSpacing) {
|
// public void setSectionSpacing(Size sectionSpacing) {
|
||||||
this.sectionSpacing = sectionSpacing;
|
// this.sectionSpacing = sectionSpacing;
|
||||||
updateControlPoints();
|
// updateControlPoints();
|
||||||
// Reset body shape;
|
// // Reset body shape;
|
||||||
body = null;
|
// body = null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EditableProperty
|
// @EditableProperty
|
||||||
public Display getDisplay() {
|
// public Display getDisplay() {
|
||||||
if (display == null) {
|
// if (display == null) {
|
||||||
display = Display.VALUE;
|
// display = Display.VALUE;
|
||||||
}
|
// }
|
||||||
return display;
|
// return display;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setDisplay(Display display) {
|
// public void setDisplay(Display display) {
|
||||||
this.display = display;
|
// this.display = display;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public int getControlPointCount() {
|
// public int getControlPointCount() {
|
||||||
return controlPoints.length;
|
// return controlPoints.length;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Point getControlPoint(int index) {
|
// public Point getControlPoint(int index) {
|
||||||
return controlPoints[index];
|
// return controlPoints[index];
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean isControlPointSticky(int index) {
|
// public boolean isControlPointSticky(int index) {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
// public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
return VisibilityPolicy.NEVER;
|
// return VisibilityPolicy.NEVER;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void setControlPoint(Point point, int index) {
|
// public void setControlPoint(Point point, int index) {
|
||||||
controlPoints[index].setLocation(point);
|
// controlPoints[index].setLocation(point);
|
||||||
body = null;
|
// body = null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void updateControlPoints() {
|
// private void updateControlPoints() {
|
||||||
Point firstPoint = controlPoints[0];
|
// Point firstPoint = controlPoints[0];
|
||||||
controlPoints = new Point[pinCount.getValue() * 2];
|
// controlPoints = new Point[pinCount.getValue() * 2];
|
||||||
controlPoints[0] = firstPoint;
|
// controlPoints[0] = firstPoint;
|
||||||
int pinSpacing = (int) this.pinSpacing.convertToPixels();
|
// int pinSpacing = (int) this.pinSpacing.convertToPixels();
|
||||||
int sectionSpacing = (int) this.sectionSpacing.convertToPixels();
|
// int sectionSpacing = (int) this.sectionSpacing.convertToPixels();
|
||||||
int rowSpacing = (int) this.rowSpacing.convertToPixels();
|
// int rowSpacing = (int) this.rowSpacing.convertToPixels();
|
||||||
// Update control points.
|
// // Update control points.
|
||||||
int dx1;
|
// int dx1;
|
||||||
int dy1;
|
// int dy1;
|
||||||
int dx2;
|
// int dx2;
|
||||||
int dy2;
|
// int dy2;
|
||||||
for (int i = 0; i < pinCount.getValue(); i++) {
|
// for (int i = 0; i < pinCount.getValue(); i++) {
|
||||||
int spacing = i == pinCount.getValue() - 1 ? sectionSpacing + (i - 1) * pinSpacing : i * pinSpacing;
|
// int spacing = i == pinCount.getValue() - 1 ? sectionSpacing + (i - 1) * pinSpacing : i * pinSpacing;
|
||||||
switch (orientation) {
|
// switch (orientation) {
|
||||||
case DEFAULT:
|
// case DEFAULT:
|
||||||
dx1 = 0;
|
// dx1 = 0;
|
||||||
dy1 = spacing;
|
// dy1 = spacing;
|
||||||
dx2 = rowSpacing;
|
// dx2 = rowSpacing;
|
||||||
dy2 = spacing;
|
// dy2 = spacing;
|
||||||
break;
|
// break;
|
||||||
case _90:
|
// case _90:
|
||||||
dx1 = -spacing;
|
// dx1 = -spacing;
|
||||||
dy1 = 0;
|
// dy1 = 0;
|
||||||
dx2 = -spacing;
|
// dx2 = -spacing;
|
||||||
dy2 = rowSpacing;
|
// dy2 = rowSpacing;
|
||||||
break;
|
// break;
|
||||||
case _180:
|
// case _180:
|
||||||
dx1 = 0;
|
// dx1 = 0;
|
||||||
dy1 = -spacing;
|
// dy1 = -spacing;
|
||||||
dx2 = -rowSpacing;
|
// dx2 = -rowSpacing;
|
||||||
dy2 = -spacing;
|
// dy2 = -spacing;
|
||||||
break;
|
// break;
|
||||||
case _270:
|
// case _270:
|
||||||
dx1 = spacing;
|
// dx1 = spacing;
|
||||||
dy1 = 0;
|
// dy1 = 0;
|
||||||
dx2 = spacing;
|
// dx2 = spacing;
|
||||||
dy2 = -rowSpacing;
|
// dy2 = -rowSpacing;
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
// throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||||
}
|
// }
|
||||||
controlPoints[i] = new Point(firstPoint.x + dx1, firstPoint.y + dy1);
|
// controlPoints[i] = new Point(firstPoint.x + dx1, firstPoint.y + dy1);
|
||||||
controlPoints[i + pinCount.getValue()] = new Point(firstPoint.x + dx2, firstPoint.y + dy2);
|
// controlPoints[i + pinCount.getValue()] = new Point(firstPoint.x + dx2, firstPoint.y + dy2);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public Area[] getBody() {
|
// public Area[] getBody() {
|
||||||
if (body == null) {
|
// if (body == null) {
|
||||||
body = new Area[2];
|
// body = new Area[2];
|
||||||
|
//
|
||||||
int pinSize = (int) PIN_SIZE.convertToPixels();
|
// int pinSize = (int) PIN_SIZE.convertToPixels();
|
||||||
|
//
|
||||||
int minX = Integer.MAX_VALUE;
|
// int minX = Integer.MAX_VALUE;
|
||||||
int maxX = Integer.MIN_VALUE;
|
// int maxX = Integer.MIN_VALUE;
|
||||||
int minY = Integer.MAX_VALUE;
|
// int minY = Integer.MAX_VALUE;
|
||||||
int maxY = Integer.MIN_VALUE;
|
// int maxY = Integer.MIN_VALUE;
|
||||||
for (int i = 0; i < this.controlPoints.length; i++) {
|
// for (int i = 0; i < this.controlPoints.length; i++) {
|
||||||
if (this.controlPoints[i].x > maxX)
|
// if (this.controlPoints[i].x > maxX)
|
||||||
maxX = this.controlPoints[i].x;
|
// maxX = this.controlPoints[i].x;
|
||||||
if (this.controlPoints[i].x < minX)
|
// if (this.controlPoints[i].x < minX)
|
||||||
minX = this.controlPoints[i].x;
|
// minX = this.controlPoints[i].x;
|
||||||
if (this.controlPoints[i].y > maxY)
|
// if (this.controlPoints[i].y > maxY)
|
||||||
maxY = this.controlPoints[i].y;
|
// maxY = this.controlPoints[i].y;
|
||||||
if (this.controlPoints[i].y < minY)
|
// if (this.controlPoints[i].y < minY)
|
||||||
minY = this.controlPoints[i].y;
|
// minY = this.controlPoints[i].y;
|
||||||
}
|
// }
|
||||||
int width = maxX - minX;
|
// int width = maxX - minX;
|
||||||
int height = maxY - minY;
|
// int height = maxY - minY;
|
||||||
|
//
|
||||||
Area indentation = null;
|
// Area indentation = null;
|
||||||
int indentationSize = getClosestOdd(INDENT_SIZE.convertToPixels());
|
// int indentationSize = getClosestOdd(INDENT_SIZE.convertToPixels());
|
||||||
switch (orientation) {
|
// switch (orientation) {
|
||||||
case DEFAULT:
|
// case DEFAULT:
|
||||||
indentation =
|
// indentation =
|
||||||
new Area(new Rectangle2D.Double(minX + width / 2 - indentationSize / 2, minY - indentationSize / 2
|
// new Area(new Rectangle2D.Double(minX + width / 2 - indentationSize / 2, minY - indentationSize / 2
|
||||||
- pinSize, indentationSize, indentationSize));
|
// - pinSize, indentationSize, indentationSize));
|
||||||
break;
|
// break;
|
||||||
case _90:
|
// case _90:
|
||||||
indentation =
|
// indentation =
|
||||||
new Area(new Rectangle2D.Double(minX + width - indentationSize / 2 + pinSize, minY + height / 2
|
// new Area(new Rectangle2D.Double(minX + width - indentationSize / 2 + pinSize, minY + height / 2
|
||||||
- indentationSize / 2, indentationSize, indentationSize));
|
// - indentationSize / 2, indentationSize, indentationSize));
|
||||||
break;
|
// break;
|
||||||
case _180:
|
// case _180:
|
||||||
indentation =
|
// indentation =
|
||||||
new Area(new Rectangle2D.Double(minX + width / 2 - indentationSize / 2, minY + height - indentationSize
|
// new Area(new Rectangle2D.Double(minX + width / 2 - indentationSize / 2, minY + height - indentationSize
|
||||||
/ 2 + pinSize, indentationSize, indentationSize));
|
// / 2 + pinSize, indentationSize, indentationSize));
|
||||||
break;
|
// break;
|
||||||
case _270:
|
// case _270:
|
||||||
indentation =
|
// indentation =
|
||||||
new Area(new Rectangle2D.Double(minX - indentationSize / 2 - pinSize, minY + height / 2 - indentationSize
|
// new Area(new Rectangle2D.Double(minX - indentationSize / 2 - pinSize, minY + height / 2 - indentationSize
|
||||||
/ 2, indentationSize, indentationSize));
|
// / 2, indentationSize, indentationSize));
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
// throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
body[0] =
|
// body[0] =
|
||||||
new Area(new RoundRectangle2D.Double(minX - pinSize, minY - pinSize, width + 2 * pinSize, height + 2
|
// new Area(new RoundRectangle2D.Double(minX - pinSize, minY - pinSize, width + 2 * pinSize, height + 2
|
||||||
* pinSize, EDGE_RADIUS, EDGE_RADIUS));
|
// * pinSize, EDGE_RADIUS, EDGE_RADIUS));
|
||||||
body[1] = indentation;
|
// body[1] = indentation;
|
||||||
if (indentation != null) {
|
// if (indentation != null) {
|
||||||
indentation.intersect(body[0]);
|
// indentation.intersect(body[0]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return body;
|
// return body;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
// public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
// IDrawingObserver drawingObserver) {
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
// if (checkPointsClipped(g2d.getClip())) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
Area mainArea = getBody()[0];
|
// Area mainArea = getBody()[0];
|
||||||
|
//
|
||||||
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 / MAX_ALPHA));
|
// g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
}
|
// }
|
||||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBodyColor());
|
// g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBodyColor());
|
||||||
g2d.fill(mainArea);
|
// g2d.fill(mainArea);
|
||||||
g2d.setComposite(oldComposite);
|
// g2d.setComposite(oldComposite);
|
||||||
|
//
|
||||||
Color finalBorderColor;
|
// Color finalBorderColor;
|
||||||
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);
|
||||||
finalBorderColor =
|
// finalBorderColor =
|
||||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
: theme.getOutlineColor();
|
// : theme.getOutlineColor();
|
||||||
} else {
|
// } else {
|
||||||
finalBorderColor =
|
// finalBorderColor =
|
||||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
: getBorderColor();
|
// : getBorderColor();
|
||||||
}
|
// }
|
||||||
g2d.setColor(finalBorderColor);
|
// g2d.setColor(finalBorderColor);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
// g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
if (outlineMode) {
|
// if (outlineMode) {
|
||||||
Area area = new Area(mainArea);
|
// Area area = new Area(mainArea);
|
||||||
area.subtract(getBody()[1]);
|
// area.subtract(getBody()[1]);
|
||||||
g2d.draw(area);
|
// g2d.draw(area);
|
||||||
} else {
|
// } else {
|
||||||
g2d.draw(mainArea);
|
// g2d.draw(mainArea);
|
||||||
if (getBody()[1] != null) {
|
// if (getBody()[1] != null) {
|
||||||
g2d.setColor(getIndentColor());
|
// g2d.setColor(getIndentColor());
|
||||||
g2d.fill(getBody()[1]);
|
// g2d.fill(getBody()[1]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (!outlineMode) {
|
// if (!outlineMode) {
|
||||||
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
|
// int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
|
||||||
for (Point point : controlPoints) {
|
// for (Point point : controlPoints) {
|
||||||
g2d.setColor(PIN_COLOR);
|
// g2d.setColor(PIN_COLOR);
|
||||||
g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
// g2d.fillOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||||
g2d.setColor(PIN_BORDER_COLOR);
|
// g2d.setColor(PIN_BORDER_COLOR);
|
||||||
g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
// g2d.drawOval(point.x - pinSize / 2, point.y - pinSize / 2, pinSize, pinSize);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Draw label.
|
// // Draw label.
|
||||||
g2d.setFont(LABEL_FONT);
|
// g2d.setFont(LABEL_FONT);
|
||||||
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
|
||||||
: getLabelColor();
|
// : getLabelColor();
|
||||||
}
|
// }
|
||||||
g2d.setColor(finalLabelColor);
|
// g2d.setColor(finalLabelColor);
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
// FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||||
String label = "";
|
// String label = "";
|
||||||
label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
// label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||||
if (getDisplay() == Display.NONE) {
|
// if (getDisplay() == Display.NONE) {
|
||||||
label = "";
|
// label = "";
|
||||||
}
|
// }
|
||||||
if (getDisplay() == Display.BOTH) {
|
// if (getDisplay() == Display.BOTH) {
|
||||||
label = getName() + " " + (getValue() == null ? "" : getValue().toString());
|
// label = getName() + " " + (getValue() == null ? "" : getValue().toString());
|
||||||
}
|
// }
|
||||||
Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
|
// Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
|
||||||
int textHeight = (int) (rect.getHeight());
|
// int textHeight = (int) (rect.getHeight());
|
||||||
int textWidth = (int) (rect.getWidth());
|
// int textWidth = (int) (rect.getWidth());
|
||||||
// Center text horizontally and vertically
|
// // Center text horizontally and vertically
|
||||||
Rectangle bounds = mainArea.getBounds();
|
// Rectangle bounds = mainArea.getBounds();
|
||||||
int x = bounds.x + (bounds.width - textWidth) / 2;
|
// int x = bounds.x + (bounds.width - textWidth) / 2;
|
||||||
int y = bounds.y + (bounds.height - textHeight) / 2 + fontMetrics.getAscent();
|
// int y = bounds.y + (bounds.height - textHeight) / 2 + fontMetrics.getAscent();
|
||||||
g2d.drawString(label, x, y);
|
// g2d.drawString(label, x, y);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
// public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
int radius = 6 * width / 32;
|
// int radius = 6 * width / 32;
|
||||||
g2d.setColor(BODY_COLOR);
|
// g2d.setColor(BODY_COLOR);
|
||||||
g2d.fillRoundRect(width / 6, 1, 4 * width / 6, height - 4, radius, radius);
|
// g2d.fillRoundRect(width / 6, 1, 4 * width / 6, height - 4, radius, radius);
|
||||||
g2d.setColor(BORDER_COLOR);
|
// g2d.setColor(BORDER_COLOR);
|
||||||
g2d.drawRoundRect(width / 6, 1, 4 * width / 6, height - 4, radius, radius);
|
// g2d.drawRoundRect(width / 6, 1, 4 * width / 6, height - 4, radius, radius);
|
||||||
int pinSize = 2 * width / 32;
|
// int pinSize = 2 * width / 32;
|
||||||
g2d.setColor(PIN_COLOR);
|
// g2d.setColor(PIN_COLOR);
|
||||||
for (int i = 0; i < 4; i++) {
|
// for (int i = 0; i < 4; i++) {
|
||||||
if (i == 1)
|
// if (i == 1)
|
||||||
continue;
|
// continue;
|
||||||
g2d.fillOval(width / 3 - pinSize, (height / 5) * (i + 1) - 1, pinSize, pinSize);
|
// g2d.fillOval(width / 3 - pinSize, (height / 5) * (i + 1) - 1, pinSize, pinSize);
|
||||||
g2d.fillOval(2 * width / 3 + 1, (height / 5) * (i + 1) - 1, pinSize, pinSize);
|
// g2d.fillOval(2 * width / 3 + 1, (height / 5) * (i + 1) - 1, pinSize, pinSize);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EditableProperty(name = "Body")
|
// @EditableProperty(name = "Body")
|
||||||
public Color getBodyColor() {
|
// public Color getBodyColor() {
|
||||||
if (bodyColor == null) {
|
// if (bodyColor == null) {
|
||||||
bodyColor = BODY_COLOR;
|
// bodyColor = BODY_COLOR;
|
||||||
}
|
// }
|
||||||
return bodyColor;
|
// return bodyColor;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setBodyColor(Color bodyColor) {
|
// public void setBodyColor(Color bodyColor) {
|
||||||
this.bodyColor = bodyColor;
|
// this.bodyColor = bodyColor;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EditableProperty(name = "Border")
|
// @EditableProperty(name = "Border")
|
||||||
public Color getBorderColor() {
|
// public Color getBorderColor() {
|
||||||
if (borderColor == null) {
|
// if (borderColor == null) {
|
||||||
borderColor = BORDER_COLOR;
|
// borderColor = BORDER_COLOR;
|
||||||
}
|
// }
|
||||||
return borderColor;
|
// return borderColor;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setBorderColor(Color borderColor) {
|
// public void setBorderColor(Color borderColor) {
|
||||||
this.borderColor = borderColor;
|
// this.borderColor = borderColor;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EditableProperty(name = "Label")
|
// @EditableProperty(name = "Label")
|
||||||
public Color getLabelColor() {
|
// public Color getLabelColor() {
|
||||||
if (labelColor == null) {
|
// if (labelColor == null) {
|
||||||
labelColor = LABEL_COLOR;
|
// labelColor = LABEL_COLOR;
|
||||||
}
|
// }
|
||||||
return labelColor;
|
// return labelColor;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setLabelColor(Color labelColor) {
|
// public void setLabelColor(Color labelColor) {
|
||||||
this.labelColor = labelColor;
|
// this.labelColor = labelColor;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@EditableProperty(name = "Indent")
|
// @EditableProperty(name = "Indent")
|
||||||
public Color getIndentColor() {
|
// public Color getIndentColor() {
|
||||||
if (indentColor == null) {
|
// if (indentColor == null) {
|
||||||
indentColor = INDENT_COLOR;
|
// indentColor = INDENT_COLOR;
|
||||||
}
|
// }
|
||||||
return indentColor;
|
// return indentColor;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setIndentColor(Color indentColor) {
|
// public void setIndentColor(Color indentColor) {
|
||||||
this.indentColor = indentColor;
|
// this.indentColor = indentColor;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static enum PinCount {
|
// public static enum PinCount {
|
||||||
|
//
|
||||||
_3, _4, _5;
|
// _3, _4, _5;
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String toString() {
|
// public String toString() {
|
||||||
return name().replace("_", "").concat(" per side");
|
// return name().replace("_", "").concat(" per side");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public int getValue() {
|
// public int getValue() {
|
||||||
return Integer.parseInt(name().replace("_", ""));
|
// return Integer.parseInt(name().replace("_", ""));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
Binary file not shown.
@@ -1409,11 +1409,7 @@
|
|||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Terminal strip component added</description>
|
<description>Terminal strip component added</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
|
||||||
<changeType>NEW_FEATURE</changeType>
|
|
||||||
<description>Subminiature DIL relay added</description>
|
|
||||||
</org.diylc.appframework.update.Change>
|
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Battery schematic symbol added</description>
|
<description>Battery schematic symbol added</description>
|
||||||
|
|||||||
Reference in New Issue
Block a user