mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
prepare the release
This commit is contained in:
Binary file not shown.
@@ -34,12 +34,11 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
|
||||
|
||||
public static Size PIN_SPACING = new Size(0.1d, SizeUnit.in);
|
||||
public static Color COLOR = Color.black;
|
||||
|
||||
public static SymbolFlipping FLIPPING = SymbolFlipping.NONE;
|
||||
|
||||
protected String value = "";
|
||||
protected Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
||||
protected Color color = COLOR;
|
||||
protected SymbolFlipping flip = FLIPPING;
|
||||
protected SymbolFlipping flip = SymbolFlipping.NONE;
|
||||
protected Display display = Display.NAME;
|
||||
transient protected Shape[] body;
|
||||
protected Orientation orientation = Orientation.DEFAULT;
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
//package org.diylc.components.smd;
|
||||
//
|
||||
//import java.awt.AlphaComposite;
|
||||
//import java.awt.Color;
|
||||
//import java.awt.Composite;
|
||||
//import java.awt.FontMetrics;
|
||||
//import java.awt.Graphics2D;
|
||||
//import java.awt.Point;
|
||||
//import java.awt.Rectangle;
|
||||
//import java.awt.geom.Area;
|
||||
//import java.awt.geom.Rectangle2D;
|
||||
//import java.awt.geom.RoundRectangle2D;
|
||||
//
|
||||
//import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
//import org.diylc.common.Display;
|
||||
//import org.diylc.common.IPlugInPort;
|
||||
//import org.diylc.common.ObjectCache;
|
||||
//import org.diylc.common.Orientation;
|
||||
//import org.diylc.components.AbstractTransparentComponent;
|
||||
//import org.diylc.core.ComponentState;
|
||||
//import org.diylc.core.IDIYComponent;
|
||||
//import org.diylc.core.IDrawingObserver;
|
||||
//import org.diylc.core.Project;
|
||||
//import org.diylc.core.Theme;
|
||||
//import org.diylc.core.VisibilityPolicy;
|
||||
//import org.diylc.core.annotations.ComponentDescriptor;
|
||||
//import org.diylc.core.annotations.EditableProperty;
|
||||
//import org.diylc.core.annotations.KeywordPolicy;
|
||||
//import org.diylc.core.annotations.PositiveMeasureValidator;
|
||||
//import org.diylc.core.measures.Size;
|
||||
//import org.diylc.core.measures.SizeUnit;
|
||||
//import org.diylc.utils.Constants;
|
||||
//
|
||||
//@ComponentDescriptor(name = "SOT-23 Case", author = "Branislav Stojkovic", category = "SMD", instanceNamePrefix = "C",
|
||||
// description = "Small outline transistor for SMD", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
||||
// keywordPolicy = KeywordPolicy.SHOW_VALUE)
|
||||
//public class SOT23Package extends AbstractTransparentComponent<String> {
|
||||
//
|
||||
// private static final long serialVersionUID = 1L;
|
||||
//
|
||||
// public static Color BODY_COLOR = Color.gray;
|
||||
// public static Color BORDER_COLOR = Color.gray.darker();
|
||||
//
|
||||
// public static Color PIN_COLOR = Color.decode("#00B2EE");
|
||||
// public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
|
||||
// public static Color LABEL_COLOR = Color.white;
|
||||
// public static int EDGE_RADIUS = 4;
|
||||
// public static Size PIN_SIZE = new Size(0.8d, SizeUnit.mm);
|
||||
//
|
||||
// public static Size LENGTH = new Size(3d, SizeUnit.mm);
|
||||
// public static Size WIDTH = new Size(1.4d, SizeUnit.mm);
|
||||
//
|
||||
// public static Size PIN_LENGTH = new Size(0.6d, SizeUnit.mm);
|
||||
// public static Size PIN_WIDTH = new Size(0.4d, SizeUnit.mm);
|
||||
//
|
||||
// protected String value;
|
||||
// private Orientation orientation = Orientation.DEFAULT;
|
||||
//
|
||||
// private SOT23Variation variation = SOT23Variation._3;
|
||||
// private Point[] controlPoints = new Point[] {new Point(0, 0), new Point(0, 0)};
|
||||
// protected Display display = Display.NAME;
|
||||
// protected Color bodyColor = BODY_COLOR;
|
||||
// protected Color borderColor = BORDER_COLOR;
|
||||
// private Color labelColor = LABEL_COLOR;
|
||||
// transient private Area[] body;
|
||||
//
|
||||
// public SOT23Package() {
|
||||
// super();
|
||||
// updateControlPoints();
|
||||
// }
|
||||
//
|
||||
// @EditableProperty(validatorClass = PositiveMeasureValidator.class)
|
||||
// public String getValue() {
|
||||
// return value;
|
||||
// }
|
||||
//
|
||||
// public void setValue(String value) {
|
||||
// this.value = value;
|
||||
// }
|
||||
//
|
||||
// @EditableProperty
|
||||
// public Orientation getOrientation() {
|
||||
// return orientation;
|
||||
// }
|
||||
//
|
||||
// public void setOrientation(Orientation orientation) {
|
||||
// this.orientation = orientation;
|
||||
// updateControlPoints();
|
||||
// // Reset body shape.
|
||||
// body = null;
|
||||
// }
|
||||
//
|
||||
// @EditableProperty
|
||||
// public Display getDisplay() {
|
||||
// if (display == null) {
|
||||
// display = Display.VALUE;
|
||||
// }
|
||||
// return display;
|
||||
// }
|
||||
//
|
||||
// public void setDisplay(Display display) {
|
||||
// this.display = display;
|
||||
// }
|
||||
//
|
||||
// @EditableProperty(name = "Contacts")
|
||||
// public SOT23Variation getVariation() {
|
||||
// return variation;
|
||||
// }
|
||||
//
|
||||
// public void setVariation(SOT23Variation variation) {
|
||||
// this.variation = variation;
|
||||
// updateControlPoints();
|
||||
// // Reset body shape.
|
||||
// body = null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getControlPointCount() {
|
||||
// return controlPoints.length;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Point getControlPoint(int index) {
|
||||
// return controlPoints[index];
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isControlPointSticky(int index) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
// return VisibilityPolicy.NEVER;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setControlPoint(Point point, int index) {
|
||||
// controlPoints[index].setLocation(point);
|
||||
// body = null;
|
||||
// }
|
||||
//
|
||||
// private void updateControlPoints() {
|
||||
// Point firstPoint = controlPoints[0];
|
||||
// controlPoints[0] = firstPoint;
|
||||
// int pinSize = (int) PIN_SIZE.convertToPixels();
|
||||
// int smdLength = (int) LENGTH.convertToPixels();
|
||||
// int pinSpacing = smdLength - pinSize;
|
||||
//
|
||||
// // Update control points.
|
||||
// int dx1;
|
||||
// int dy1;
|
||||
// switch (orientation) {
|
||||
// case DEFAULT:
|
||||
// dx1 = 0;
|
||||
// dy1 = pinSpacing;
|
||||
// break;
|
||||
// case _90:
|
||||
// dx1 = -pinSpacing;
|
||||
// dy1 = 0;
|
||||
// break;
|
||||
// case _180:
|
||||
// dx1 = 0;
|
||||
// dy1 = -pinSpacing;
|
||||
// break;
|
||||
// case _270:
|
||||
// dx1 = pinSpacing;
|
||||
// dy1 = 0;
|
||||
// break;
|
||||
// default:
|
||||
// throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||
// }
|
||||
// controlPoints[1] = new Point(firstPoint.x + dx1, firstPoint.y + dy1);
|
||||
// }
|
||||
//
|
||||
// public Area[] getBody() {
|
||||
// if (body == null) {
|
||||
// body = new Area[2];
|
||||
// int x = controlPoints[0].x;
|
||||
// int y = controlPoints[0].y;
|
||||
// int smdLength = (int) LENGTH.convertToPixels();
|
||||
// int smdWidth = (int) WIDTH.convertToPixels();
|
||||
// int pinSize = (int) PIN_SIZE.convertToPixels();
|
||||
// int width;
|
||||
// int height;
|
||||
//
|
||||
// // create main body
|
||||
// switch (orientation) {
|
||||
// case DEFAULT:
|
||||
// width = smdWidth;
|
||||
// height = smdLength;
|
||||
// x = controlPoints[0].x - smdWidth / 2;
|
||||
// y = controlPoints[0].y - pinSize / 2;
|
||||
// break;
|
||||
// case _90:
|
||||
// width = smdLength;
|
||||
// height = smdWidth;
|
||||
// x = controlPoints[1].x - pinSize / 2;
|
||||
// y = controlPoints[1].y - smdWidth / 2;
|
||||
// break;
|
||||
// case _180:
|
||||
// width = smdWidth;
|
||||
// height = smdLength;
|
||||
// x = controlPoints[1].x - smdWidth / 2;
|
||||
// y = controlPoints[1].y - pinSize / 2;
|
||||
// break;
|
||||
// case _270:
|
||||
// width = smdLength;
|
||||
// height = smdWidth;
|
||||
// x = controlPoints[0].x - pinSize / 2;
|
||||
// y = controlPoints[0].y - smdWidth / 2;
|
||||
// break;
|
||||
// default:
|
||||
// throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||
// }
|
||||
// Area mainArea = new Area(new RoundRectangle2D.Double(x, y, width, height, EDGE_RADIUS, EDGE_RADIUS));
|
||||
//
|
||||
// // create contact area
|
||||
// Area contactArea = new Area();
|
||||
// if (width > height) {
|
||||
// contactArea.add(new Area(new Rectangle2D.Double(x, y, pinSize, height)));
|
||||
// contactArea.add(new Area(new Rectangle2D.Double(x + width - pinSize, y, pinSize, height)));
|
||||
// } else {
|
||||
// contactArea.add(new Area(new Rectangle2D.Double(x, y, width, pinSize)));
|
||||
// contactArea.add(new Area(new Rectangle2D.Double(x, y + height - pinSize, width, pinSize)));
|
||||
// }
|
||||
// contactArea.intersect(mainArea);
|
||||
//
|
||||
// mainArea.subtract(contactArea);
|
||||
// body[0] = mainArea;
|
||||
// body[1] = contactArea;
|
||||
//
|
||||
// }
|
||||
// return body;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
// IDrawingObserver drawingObserver) {
|
||||
// if (checkPointsClipped(g2d.getClip())) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // draw main area
|
||||
// Area mainArea = getBody()[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 : getBodyColor());
|
||||
// g2d.fill(mainArea);
|
||||
// g2d.setComposite(oldComposite);
|
||||
//
|
||||
// Color finalBorderColor;
|
||||
// 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();
|
||||
// } else {
|
||||
// finalBorderColor =
|
||||
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
// : getBorderColor();
|
||||
// }
|
||||
// g2d.setColor(finalBorderColor);
|
||||
// g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
// g2d.draw(mainArea);
|
||||
//
|
||||
//
|
||||
// // draw contact area
|
||||
// Area contactArea = getBody()[1];
|
||||
// if (!outlineMode) {
|
||||
// g2d.setColor(PIN_COLOR);
|
||||
// if (alpha < MAX_ALPHA) {
|
||||
// g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
// }
|
||||
// g2d.fill(contactArea);
|
||||
// g2d.setComposite(oldComposite);
|
||||
// }
|
||||
//
|
||||
// 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();
|
||||
// } else {
|
||||
// finalBorderColor =
|
||||
// componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
// : PIN_BORDER_COLOR;
|
||||
// }
|
||||
// g2d.setColor(finalBorderColor);
|
||||
// g2d.draw(contactArea);
|
||||
//
|
||||
// // Draw label.
|
||||
// g2d.setFont(LABEL_FONT);
|
||||
// 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);
|
||||
// FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||
// String label = "";
|
||||
// label = (getDisplay() == Display.NAME) ? getName() : getValue().toString();
|
||||
// if (getDisplay() == Display.NONE) {
|
||||
// label = "";
|
||||
// }
|
||||
// if (getDisplay() == Display.BOTH) {
|
||||
// label = getName() + " " + (getValue() == null ? "" : getValue().toString());
|
||||
// }
|
||||
//
|
||||
// Rectangle textTarget = mainArea.getBounds();
|
||||
// int length = textTarget.height > textTarget.width ? textTarget.height : textTarget.width;
|
||||
//
|
||||
// Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
|
||||
// int textHeight = (int) (rect.getHeight());
|
||||
// int textWidth = (int) (rect.getWidth());
|
||||
//
|
||||
// do {
|
||||
// g2d.setFont(g2d.getFont().deriveFont(g2d.getFont().getSize2D() - 1));
|
||||
// fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||
// rect = fontMetrics.getStringBounds(label, g2d);
|
||||
// textHeight = (int) (rect.getHeight());
|
||||
// textWidth = (int) (rect.getWidth());
|
||||
// } while (textWidth > length && g2d.getFont().getSize2D() > 2);
|
||||
//
|
||||
// double centerX = textTarget.getX() + textTarget.getWidth() / 2;
|
||||
// double centerY = textTarget.getY() + textTarget.getHeight() / 2;
|
||||
// g2d.translate(centerX, centerY);
|
||||
//
|
||||
// switch (orientation) {
|
||||
// case DEFAULT:
|
||||
// g2d.rotate(Math.PI / 2);
|
||||
// break;
|
||||
// case _90:
|
||||
// g2d.rotate(Math.PI);
|
||||
// break;
|
||||
// case _180:
|
||||
// g2d.rotate(Math.PI * 3 / 2);
|
||||
// break;
|
||||
// case _270:
|
||||
// break;
|
||||
// default:
|
||||
// throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||
// }
|
||||
//
|
||||
// // Center text horizontally and vertically
|
||||
// int x = -textWidth / 2;
|
||||
// int y = -textHeight / 2 + fontMetrics.getAscent() - 1;
|
||||
// g2d.drawString(label, x, y);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
// int radius = 4 * width / 32;
|
||||
// int contactSize = 4 * width / 32;
|
||||
// int thickness = getClosestOdd(width / 2);
|
||||
// g2d.rotate(Math.PI / 4, width / 2, height / 2);
|
||||
// RoundRectangle2D rect =
|
||||
// new RoundRectangle2D.Double((width - thickness) / 2, 4 * width / 32, thickness, height - 8 * width / 32,
|
||||
// radius, radius);
|
||||
// g2d.setColor(getBodyColor());
|
||||
// g2d.fill(rect);
|
||||
// g2d.setColor(getBorderColor());
|
||||
// g2d.draw(rect);
|
||||
// Area contactArea = new Area();
|
||||
// contactArea.add(new Area(new Rectangle2D.Double((width - thickness) / 2, 4 * width / 32, thickness, contactSize)));
|
||||
// contactArea.add(new Area(new Rectangle2D.Double((width - thickness) / 2, height - 8 * width / 32, thickness,
|
||||
// contactSize)));
|
||||
// contactArea.intersect(new Area(rect));
|
||||
// g2d.setColor(PIN_COLOR);
|
||||
// g2d.fill(contactArea);
|
||||
// }
|
||||
//
|
||||
// @EditableProperty(name = "Body")
|
||||
// public Color getBodyColor() {
|
||||
// return bodyColor;
|
||||
// }
|
||||
//
|
||||
// public void setBodyColor(Color bodyColor) {
|
||||
// this.bodyColor = bodyColor;
|
||||
// }
|
||||
//
|
||||
// @EditableProperty(name = "Border")
|
||||
// public Color getBorderColor() {
|
||||
// return borderColor;
|
||||
// }
|
||||
//
|
||||
// public void setBorderColor(Color borderColor) {
|
||||
// this.borderColor = borderColor;
|
||||
// }
|
||||
//
|
||||
// @EditableProperty(name = "Label")
|
||||
// public Color getLabelColor() {
|
||||
// if (labelColor == null) {
|
||||
// labelColor = LABEL_COLOR;
|
||||
// }
|
||||
// return labelColor;
|
||||
// }
|
||||
//
|
||||
// public void setLabelColor(Color labelColor) {
|
||||
// this.labelColor = labelColor;
|
||||
// }
|
||||
//
|
||||
// public static enum SOT23Variation {
|
||||
//
|
||||
// _3, _5, _6, _8;
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return name().replace("_", "");
|
||||
// }
|
||||
//
|
||||
// public int getValue() {
|
||||
// return Integer.parseInt(toString());
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,103 @@
|
||||
package org.diylc.components.transform;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.tube.AbstractTubeSymbol;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public class TubeSymbolTransformer implements IComponentTransformer {
|
||||
|
||||
@Override
|
||||
public boolean canRotate(IDIYComponent<?> component) {
|
||||
return AbstractTubeSymbol.class.isAssignableFrom(component.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMirror(IDIYComponent<?> component) {
|
||||
return AbstractTubeSymbol.class.isAssignableFrom(component.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mirroringChangesCircuit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotate(IDIYComponent<?> component, Point center, int direction) {
|
||||
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.x, center.y);
|
||||
for (int index = 0; index < component.getControlPointCount(); index++) {
|
||||
Point p = new Point(component.getControlPoint(index));
|
||||
rotate.transform(p, p);
|
||||
component.setControlPoint(p, index);
|
||||
}
|
||||
|
||||
AbstractTubeSymbol tube = (AbstractTubeSymbol) component;
|
||||
Orientation o = tube.getOrientation();
|
||||
int oValue = o.ordinal();
|
||||
oValue += direction;
|
||||
if (oValue < 0)
|
||||
oValue = Orientation.values().length - 1;
|
||||
if (oValue >= Orientation.values().length)
|
||||
oValue = 0;
|
||||
o = Orientation.values()[oValue];
|
||||
tube.setOrientation(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mirror(IDIYComponent<?> component, Point center, int direction) {
|
||||
AbstractTubeSymbol tube = (AbstractTubeSymbol) component;
|
||||
|
||||
if (direction == IComponentTransformer.HORIZONTAL) {
|
||||
int dx = 2 * (center.x - tube.getControlPoint(0).x);
|
||||
int dy = 0;
|
||||
|
||||
Orientation o = tube.getOrientation();
|
||||
switch (o) {
|
||||
case DEFAULT:
|
||||
o = Orientation._180;
|
||||
break;
|
||||
case _90:
|
||||
break;
|
||||
case _180:
|
||||
o = Orientation.DEFAULT;
|
||||
break;
|
||||
case _270:
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < tube.getControlPointCount(); i++) {
|
||||
Point p = tube.getControlPoint(i);
|
||||
tube.setControlPoint(new Point(p.x + dx, p.y + dy), i);
|
||||
}
|
||||
|
||||
tube.setOrientation(o);
|
||||
} else {
|
||||
int dx = 0;
|
||||
int dy = 2 * (center.y - tube.getControlPoint(0).y);
|
||||
|
||||
Orientation o = tube.getOrientation();
|
||||
switch (o) {
|
||||
case DEFAULT:
|
||||
break;
|
||||
case _90:
|
||||
o = Orientation._270;
|
||||
break;
|
||||
case _180:
|
||||
break;
|
||||
case _270:
|
||||
o = Orientation._90;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < tube.getControlPointCount(); i++) {
|
||||
Point p = tube.getControlPoint(i);
|
||||
tube.setControlPoint(new Point(p.x + dx, p.y + dy), i);
|
||||
}
|
||||
|
||||
tube.setOrientation(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.components.semiconductors.SymbolFlipping;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
@@ -38,6 +39,7 @@ public abstract class AbstractTubeSymbol extends AbstractComponent<String> {
|
||||
transient protected Shape[] body;
|
||||
protected boolean showHeaters;
|
||||
protected Orientation orientation = Orientation.DEFAULT;
|
||||
protected SymbolFlipping flip = SymbolFlipping.NONE;
|
||||
protected Point[] controlPoints;
|
||||
|
||||
@Override
|
||||
@@ -87,9 +89,9 @@ public abstract class AbstractTubeSymbol extends AbstractComponent<String> {
|
||||
: LABEL_COLOR;
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
|
||||
|
||||
Rectangle rect = body[2] != null ? body[2].getBounds() : body[1].getBounds();
|
||||
|
||||
|
||||
String label = "";
|
||||
label = display == Display.VALUE ? getValue() : getName();
|
||||
if (display == Display.NONE) {
|
||||
@@ -98,9 +100,10 @@ public abstract class AbstractTubeSymbol extends AbstractComponent<String> {
|
||||
if (display == Display.BOTH) {
|
||||
label = getName() + " " + (getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
drawCenteredText(g2d, label, rect.x + rect.width, rect.y + rect.height, HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM);
|
||||
drawCenteredText(g2d, label, rect.x + rect.width, rect.y + rect.height, HorizontalAlignment.RIGHT,
|
||||
VerticalAlignment.BOTTOM);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Point getControlPoint(int index) {
|
||||
return controlPoints[index];
|
||||
@@ -110,12 +113,13 @@ public abstract class AbstractTubeSymbol extends AbstractComponent<String> {
|
||||
public int getControlPointCount() {
|
||||
return controlPoints.length;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point point, int index) {
|
||||
controlPoints[index].setLocation(point);
|
||||
|
||||
refreshDrawing();
|
||||
|
||||
if (index == controlPoints.length - 1)
|
||||
this.body = null;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
@@ -155,28 +159,112 @@ public abstract class AbstractTubeSymbol extends AbstractComponent<String> {
|
||||
public void setShowHeaters(boolean showHeaters) {
|
||||
this.showHeaters = showHeaters;
|
||||
|
||||
refreshDrawing();
|
||||
this.body = null;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Orientation getOrientation() {
|
||||
if (orientation == null)
|
||||
orientation = Orientation.DEFAULT;
|
||||
|
||||
|
||||
return orientation;
|
||||
}
|
||||
|
||||
public void setOrientation(Orientation orientation) {
|
||||
this.orientation = orientation;
|
||||
|
||||
refreshDrawing();
|
||||
updateControlPoints();
|
||||
this.body = null;
|
||||
}
|
||||
|
||||
protected void refreshDrawing() {
|
||||
@EditableProperty
|
||||
public SymbolFlipping getFlip() {
|
||||
if (flip == null)
|
||||
flip = SymbolFlipping.NONE;
|
||||
return flip;
|
||||
}
|
||||
|
||||
public void setFlip(SymbolFlipping flip) {
|
||||
this.flip = flip;
|
||||
|
||||
updateControlPoints();
|
||||
// make sure we have a new drawing
|
||||
body = null;
|
||||
getBody();
|
||||
this.body = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns transistor shape consisting of 3 parts, in this order: electrodes, connectors, bulb.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract Shape[] initializeBody();
|
||||
|
||||
protected Shape[] getBody() {
|
||||
if (this.body == null) {
|
||||
Shape[] newBody = initializeBody();
|
||||
|
||||
// int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
int centerX = this.controlPoints[0].x;// + pinSpacing * 3;
|
||||
int centerY = this.controlPoints[0].y;
|
||||
|
||||
if (getFlip() == SymbolFlipping.X) {
|
||||
AffineTransform tx = AffineTransform.getScaleInstance(-1, 1);
|
||||
tx.concatenate(AffineTransform.getTranslateInstance(-2 * centerX, 0));
|
||||
if (newBody != null) {
|
||||
for (int i = 0; i < newBody.length; i++) {
|
||||
newBody[i] = tx.createTransformedShape(newBody[i]);
|
||||
}
|
||||
}
|
||||
} else if (getFlip() == SymbolFlipping.Y) {
|
||||
AffineTransform tx = AffineTransform.getScaleInstance(1, -1);
|
||||
tx.concatenate(AffineTransform.getTranslateInstance(0, -2 * centerY));
|
||||
if (newBody != null) {
|
||||
for (int i = 0; i < newBody.length; i++) {
|
||||
newBody[i] = tx.createTransformedShape(newBody[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getOrientation() != Orientation.DEFAULT) {
|
||||
|
||||
Point first = this.controlPoints[0];
|
||||
double angle = Double.parseDouble(getOrientation().name().replace("_", ""));
|
||||
AffineTransform rotate = AffineTransform.getRotateInstance(Math.toRadians(angle), first.x, first.y);
|
||||
if (newBody != null) {
|
||||
for (int i = 0; i < newBody.length; i++) {
|
||||
newBody[i] = rotate.createTransformedShape(newBody[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.body = newBody;
|
||||
}
|
||||
|
||||
return this.body;
|
||||
}
|
||||
|
||||
protected abstract Point[] initializeControlPoints(Point first);
|
||||
|
||||
protected void updateControlPoints() {
|
||||
Point[] newPoints = initializeControlPoints(this.controlPoints[0]);
|
||||
this.controlPoints = newPoints;
|
||||
|
||||
// int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
int centerX = this.controlPoints[0].x;// + pinSpacing * 3;
|
||||
int centerY = this.controlPoints[0].y;
|
||||
|
||||
if (getFlip() == SymbolFlipping.X) {
|
||||
AffineTransform tx = AffineTransform.getScaleInstance(-1, 1);
|
||||
tx.concatenate(AffineTransform.getTranslateInstance(-2 * centerX, 0));
|
||||
for (int i = 0; i < this.controlPoints.length; i++) {
|
||||
tx.transform(this.controlPoints[i], this.controlPoints[i]);
|
||||
}
|
||||
} else if (getFlip() == SymbolFlipping.Y) {
|
||||
AffineTransform tx = AffineTransform.getScaleInstance(1, -1);
|
||||
tx.concatenate(AffineTransform.getTranslateInstance(0, -2 * centerY));
|
||||
for (int i = 0; i < this.controlPoints.length; i++) {
|
||||
tx.transform(this.controlPoints[i], this.controlPoints[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (getOrientation() == Orientation.DEFAULT)
|
||||
return;
|
||||
@@ -187,19 +275,5 @@ public abstract class AbstractTubeSymbol extends AbstractComponent<String> {
|
||||
for (int i = 1; i < this.controlPoints.length; i++) {
|
||||
rotate.transform(this.controlPoints[i], this.controlPoints[i]);
|
||||
}
|
||||
if (this.body != null) {
|
||||
for (int i = 0; i < this.body.length; i++) {
|
||||
this.body[i] = rotate.createTransformedShape(this.body[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns transistor shape consisting of 3 parts, in this order: electrodes, connectors, bulb.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract Shape[] getBody();
|
||||
|
||||
protected abstract void updateControlPoints();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.GeneralPath;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.transform.TubeSymbolTransformer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IPropertyValidator;
|
||||
import org.diylc.core.ValidationException;
|
||||
@@ -17,7 +18,7 @@ import org.diylc.core.annotations.KeywordPolicy;
|
||||
|
||||
@ComponentDescriptor(name = "Diode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
instanceNamePrefix = "V", description = "Diode tube symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT,
|
||||
keywordPolicy = KeywordPolicy.SHOW_VALUE)
|
||||
keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TubeSymbolTransformer.class)
|
||||
public class DiodeSymbol extends AbstractTubeSymbol {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -31,8 +32,10 @@ public class DiodeSymbol extends AbstractTubeSymbol {
|
||||
updateControlPoints();
|
||||
}
|
||||
|
||||
public Shape[] getBody() {
|
||||
public Shape[] initializeBody() {
|
||||
if (body == null) {
|
||||
Point[] controlPoints = initializeControlPoints(this.controlPoints[0]);
|
||||
|
||||
body = new Shape[3];
|
||||
int x = controlPoints[0].x;
|
||||
int y = controlPoints[0].y;
|
||||
@@ -110,23 +113,27 @@ public class DiodeSymbol extends AbstractTubeSymbol {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateControlPoints() {
|
||||
protected Point[] initializeControlPoints(Point first) {
|
||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
// Update control points.
|
||||
int x = controlPoints[0].x;
|
||||
int y = controlPoints[0].y;
|
||||
int x = first.x;
|
||||
int y = first.y;
|
||||
|
||||
controlPoints[1].x = x + pinSpacing * 3;
|
||||
controlPoints[1].y = y - pinSpacing * 3;
|
||||
Point[] newPoints = new Point[] {first, new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
||||
|
||||
controlPoints[2].x = x + pinSpacing * 2;
|
||||
controlPoints[2].y = y + pinSpacing * 3;
|
||||
newPoints[1].x = x + pinSpacing * 3;
|
||||
newPoints[1].y = y - pinSpacing * 3;
|
||||
|
||||
controlPoints[3].x = x + pinSpacing * 3;
|
||||
controlPoints[3].y = y + pinSpacing * 3;
|
||||
newPoints[2].x = x + pinSpacing * 2;
|
||||
newPoints[2].y = y + pinSpacing * 3;
|
||||
|
||||
controlPoints[4].x = x + pinSpacing * 4;
|
||||
controlPoints[4].y = y + pinSpacing * 3;
|
||||
newPoints[3].x = x + pinSpacing * 3;
|
||||
newPoints[3].y = y + pinSpacing * 3;
|
||||
|
||||
newPoints[4].x = x + pinSpacing * 4;
|
||||
newPoints[4].y = y + pinSpacing * 3;
|
||||
|
||||
return newPoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,7 +166,7 @@ public class DiodeSymbol extends AbstractTubeSymbol {
|
||||
public void setDirectlyHeated(boolean directlyHeated) {
|
||||
this.directlyHeated = directlyHeated;
|
||||
|
||||
refreshDrawing();
|
||||
this.body = null;
|
||||
}
|
||||
|
||||
public class HeaterValidator implements IPropertyValidator {
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.GeneralPath;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.transform.TubeSymbolTransformer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
@@ -16,7 +17,8 @@ import org.diylc.core.annotations.KeywordPolicy;
|
||||
|
||||
@ComponentDescriptor(name = "Pentode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
instanceNamePrefix = "V", description = "Pentode tube symbol", stretchable = false,
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE,
|
||||
transformer = TubeSymbolTransformer.class)
|
||||
public class PentodeSymbol extends AbstractTubeSymbol {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -31,8 +33,10 @@ public class PentodeSymbol extends AbstractTubeSymbol {
|
||||
updateControlPoints();
|
||||
}
|
||||
|
||||
public Shape[] getBody() {
|
||||
public Shape[] initializeBody() {
|
||||
if (body == null) {
|
||||
Point[] controlPoints = initializeControlPoints(this.controlPoints[0]);
|
||||
|
||||
body = new Shape[3];
|
||||
int x = controlPoints[0].x;
|
||||
int y = controlPoints[0].y;
|
||||
@@ -156,29 +160,35 @@ public class PentodeSymbol extends AbstractTubeSymbol {
|
||||
g2d.drawLine(width / 8, height * 5 / 8, width * 7 / 8, height * 5 / 8);
|
||||
}
|
||||
|
||||
protected void updateControlPoints() {
|
||||
protected Point[] initializeControlPoints(Point first) {
|
||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
// Update control points.
|
||||
int x = controlPoints[0].x;
|
||||
int y = controlPoints[0].y;
|
||||
int x = first.x;
|
||||
int y = first.y;
|
||||
|
||||
controlPoints[1].x = x + pinSpacing * 3;
|
||||
controlPoints[1].y = y - pinSpacing * 4;
|
||||
Point[] newPoints =
|
||||
new Point[] {first, new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0),
|
||||
new Point(0, 0)};
|
||||
|
||||
controlPoints[2].x = x + pinSpacing * 2;
|
||||
controlPoints[2].y = y + pinSpacing * 2;
|
||||
newPoints[1].x = x + pinSpacing * 3;
|
||||
newPoints[1].y = y - pinSpacing * 4;
|
||||
|
||||
controlPoints[3].x = x + pinSpacing * 6;
|
||||
controlPoints[3].y = y - pinSpacing;
|
||||
newPoints[2].x = x + pinSpacing * 2;
|
||||
newPoints[2].y = y + pinSpacing * 2;
|
||||
|
||||
controlPoints[4].x = x;
|
||||
controlPoints[4].y = y - pinSpacing * 2;
|
||||
newPoints[3].x = x + pinSpacing * 6;
|
||||
newPoints[3].y = y - pinSpacing;
|
||||
|
||||
controlPoints[5].x = x + pinSpacing * 3;
|
||||
controlPoints[5].y = y + pinSpacing * 2;
|
||||
newPoints[4].x = x;
|
||||
newPoints[4].y = y - pinSpacing * 2;
|
||||
|
||||
controlPoints[6].x = x + pinSpacing * 4;
|
||||
controlPoints[6].y = y + pinSpacing * 2;
|
||||
newPoints[5].x = x + pinSpacing * 3;
|
||||
newPoints[5].y = y + pinSpacing * 2;
|
||||
|
||||
newPoints[6].x = x + pinSpacing * 4;
|
||||
newPoints[6].y = y + pinSpacing * 2;
|
||||
|
||||
return newPoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,6 +218,6 @@ public class PentodeSymbol extends AbstractTubeSymbol {
|
||||
public void setExposeSuppressorGrid(boolean exposeSuppressorGrid) {
|
||||
this.exposeSuppressorGrid = exposeSuppressorGrid;
|
||||
|
||||
refreshDrawing();
|
||||
this.body = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.GeneralPath;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.transform.TubeSymbolTransformer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
@@ -16,7 +17,8 @@ import org.diylc.core.annotations.KeywordPolicy;
|
||||
|
||||
@ComponentDescriptor(name = "Triode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
instanceNamePrefix = "V", description = "Triode tube symbol", stretchable = false,
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE,
|
||||
transformer = TubeSymbolTransformer.class)
|
||||
public class TriodeSymbol extends AbstractTubeSymbol {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -30,8 +32,10 @@ public class TriodeSymbol extends AbstractTubeSymbol {
|
||||
updateControlPoints();
|
||||
}
|
||||
|
||||
public Shape[] getBody() {
|
||||
public Shape[] initializeBody() {
|
||||
if (body == null) {
|
||||
Point[] controlPoints = initializeControlPoints(this.controlPoints[0]);
|
||||
|
||||
body = new Shape[3];
|
||||
int x = controlPoints[0].x;
|
||||
int y = controlPoints[0].y;
|
||||
@@ -126,23 +130,27 @@ public class TriodeSymbol extends AbstractTubeSymbol {
|
||||
g2d.drawLine(width / 8, height / 2, width * 7 / 8, height / 2);
|
||||
}
|
||||
|
||||
protected void updateControlPoints() {
|
||||
protected Point[] initializeControlPoints(Point first) {
|
||||
int pinSpacing = (int) PIN_SPACING.convertToPixels();
|
||||
// Update control points.
|
||||
int x = controlPoints[0].x;
|
||||
int y = controlPoints[0].y;
|
||||
int x = first.x;
|
||||
int y = first.y;
|
||||
|
||||
controlPoints[1].x = x + pinSpacing * 3;
|
||||
controlPoints[1].y = y - pinSpacing * 3;
|
||||
Point[] newPoints = new Point[] {first, new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
||||
|
||||
controlPoints[2].x = x + pinSpacing * 2;
|
||||
controlPoints[2].y = y + pinSpacing * 3;
|
||||
newPoints[1].x = x + pinSpacing * 3;
|
||||
newPoints[1].y = y - pinSpacing * 3;
|
||||
|
||||
controlPoints[3].x = x + pinSpacing * 3;
|
||||
controlPoints[3].y = y + pinSpacing * 3;
|
||||
newPoints[2].x = x + pinSpacing * 2;
|
||||
newPoints[2].y = y + pinSpacing * 3;
|
||||
|
||||
controlPoints[4].x = x + pinSpacing * 4;
|
||||
controlPoints[4].y = y + pinSpacing * 3;
|
||||
newPoints[3].x = x + pinSpacing * 3;
|
||||
newPoints[3].y = y + pinSpacing * 3;
|
||||
|
||||
newPoints[4].x = x + pinSpacing * 4;
|
||||
newPoints[4].y = y + pinSpacing * 3;
|
||||
|
||||
return newPoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -175,6 +183,6 @@ public class TriodeSymbol extends AbstractTubeSymbol {
|
||||
public void setDirectlyHeated(boolean directlyHeated) {
|
||||
this.directlyHeated = directlyHeated;
|
||||
|
||||
refreshDrawing();
|
||||
this.body = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<property name="jar.dir" value="${build.dir}/jar" />
|
||||
<property name="report.dir" value="${build.dir}/junitreport" />
|
||||
<property name="main.class" value="org.diylc.DIYLCStarter" />
|
||||
<property name="diylc.version" value="3.35.0" />
|
||||
<property name="diylc.version" value="3.36.0" />
|
||||
|
||||
<property name="classes.dir" value="${build.dir}/temp/${ant.project.name}/classes" />
|
||||
<property name="test.classes.dir" value="${build.dir}/temp/${ant.project.name}/test.classes" />
|
||||
@@ -21,7 +21,7 @@
|
||||
<ant antfile="../diylc-library/build.xml" target="jar" inheritAll="false" />
|
||||
<mkdir dir="${classes.dir}" />
|
||||
<echo>Compile with JDK ${java.runtime.version}</echo>
|
||||
<javac encoding="8859_1" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="class.path">
|
||||
<javac compiler="modern" encoding="8859_1" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="class.path">
|
||||
<compilerarg value="-proc:none" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
Binary file not shown.
@@ -1572,8 +1572,12 @@
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Ability to rotate tube sockets for arbitrary angle and to change color</description>
|
||||
<description>Ability to rotate tube sockets for arbitrary angle and change color</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Flip tube schematic symbols</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Renamed "template" to "variant" as it is describes the meaning more closely</description>
|
||||
|
||||
Reference in New Issue
Block a user