mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-12 02:02:16 +10:00
3.29.0 release
[Bug Fix] Issue with losing saved user configuration [Bug Fix] Issue with disabled "Save as Template" context menu item problem, as well as issue with strange rotation and probably few more [Bug Fix] Undo steps kept after opening a new file [New Feature] Transistors can be rotated and flipped vertically [New Feature] DIL ICs can show pin numbers [New Feature] Display both component value and name or neither of them [New Feature] Potentiometer schematic symbol added
This commit is contained in:
+8
-1
@@ -346,7 +346,14 @@ public class MiniRelay extends AbstractTransparentComponent<String> {
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||
String label = display == Display.NAME ? getName() : getValue();
|
||||
String label="";
|
||||
label = display == Display.VALUE ? getValue() : getName();
|
||||
if (display==Display.NONE) {
|
||||
label="";
|
||||
}
|
||||
if (display==Display.BOTH) {
|
||||
label=getName()+" "+(getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
|
||||
int textHeight = (int) (rect.getHeight());
|
||||
int textWidth = (int) (rect.getWidth());
|
||||
|
||||
+25
-1
@@ -13,6 +13,7 @@ import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
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;
|
||||
@@ -45,9 +46,11 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
||||
public static Color PIN_COLOR = Color.decode("#00B2EE");
|
||||
public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
|
||||
public static Size PIN_SIZE = new Size(0.03d, SizeUnit.in);
|
||||
protected static Display DISPLAY = Display.NAME;
|
||||
|
||||
protected Color bodyColor = BODY_COLOR;
|
||||
protected Color borderColor = BORDER_COLOR;
|
||||
protected static Display display = DISPLAY;
|
||||
// Array of 7 elements: 3 lug connectors, 1 pot body and 3 lugs
|
||||
transient protected Shape[] body = null;
|
||||
|
||||
@@ -333,7 +336,16 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
||||
int x = (panelWidth - textWidth) / 2;
|
||||
int y = (panelHeight - textHeight) / 2 + fontMetrics.getAscent();
|
||||
|
||||
g2d.drawString(getName(), (int) (bodyRect.getX() + x), (int) (bodyRect
|
||||
String label="";
|
||||
label = (getDisplay() == Display.NAME) ? getName() : getValue().toString();
|
||||
if (getDisplay() ==Display.NONE) {
|
||||
label="";
|
||||
}
|
||||
if (getDisplay() ==Display.BOTH) {
|
||||
label=getName()+" "+(getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
|
||||
g2d.drawString(label, (int) (bodyRect.getX() + x), (int) (bodyRect
|
||||
.getY() + y));
|
||||
}
|
||||
|
||||
@@ -386,6 +398,18 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
|
||||
public void setBodyColor(Color bodyColor) {
|
||||
this.bodyColor = bodyColor;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Display getDisplay() {
|
||||
if (display == null) {
|
||||
display = Display.VALUE;
|
||||
}
|
||||
return display;
|
||||
}
|
||||
|
||||
public void setDisplay(Display display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border")
|
||||
public Color getBorderColor() {
|
||||
|
||||
+50
-2
@@ -4,6 +4,7 @@ import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.common.Display;
|
||||
@@ -28,11 +29,13 @@ public abstract class AbstractTransistorSymbol 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 flipping = FLIPPING;
|
||||
protected Display display = Display.NAME;
|
||||
transient protected Shape[] body;
|
||||
|
||||
@@ -67,6 +70,32 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
||||
|
||||
Shape[] body = getBody();
|
||||
|
||||
int rotation=0;
|
||||
//determine rotation using control points
|
||||
if (controlPoints[1].x==controlPoints[2].x)
|
||||
{
|
||||
if (controlPoints[0].x>controlPoints[1].x)
|
||||
{
|
||||
rotation=180;
|
||||
}
|
||||
}
|
||||
if (controlPoints[1].y==controlPoints[2].y)
|
||||
{
|
||||
rotation=90;
|
||||
if (controlPoints[0].y>controlPoints[1].y)
|
||||
{
|
||||
rotation=270;
|
||||
}
|
||||
}
|
||||
AffineTransform old = g2d.getTransform();
|
||||
g2d.rotate(Math.toRadians(rotation),controlPoints[0].x,controlPoints[0].y);
|
||||
|
||||
if (this.flipping==SymbolFlipping.Y){
|
||||
g2d.translate(0,controlPoints[0].y);
|
||||
g2d.scale(1, -1);
|
||||
g2d.translate(0, -1*controlPoints[0].y);
|
||||
}
|
||||
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
||||
g2d.draw(body[0]);
|
||||
|
||||
@@ -74,6 +103,7 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
||||
g2d.draw(body[1]);
|
||||
|
||||
g2d.fill(body[2]);
|
||||
g2d.setTransform(old);
|
||||
|
||||
// Draw label
|
||||
g2d.setFont(LABEL_FONT);
|
||||
@@ -90,7 +120,16 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
||||
: LABEL_COLOR;
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
drawCenteredText(g2d, display == Display.VALUE ? getValue() : getName(),
|
||||
String label="";
|
||||
label = display == Display.NAME ? getName()
|
||||
: (getValue() == null ? "" : getValue().toString());
|
||||
if (display==Display.NONE) {
|
||||
label="";
|
||||
}
|
||||
if (display==Display.BOTH) {
|
||||
label=getName()+" "+(getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
drawCenteredText(g2d, label,
|
||||
x + pinSpacing * 2, y, HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
||||
}
|
||||
|
||||
@@ -144,6 +183,15 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
|
||||
// Invalidate body
|
||||
body = null;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public SymbolFlipping getFlipping() {
|
||||
return flipping;
|
||||
}
|
||||
|
||||
public void setFlipping(SymbolFlipping flipping) {
|
||||
this.flipping = flipping;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Color getColor() {
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
@ComponentDescriptor(name = "BJT Symbol", author = "Branislav Stojkovic", category = "Schematics", instanceNamePrefix = "Q", description = "Bipolar junction transistor schematic symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT, rotatable = false)
|
||||
@ComponentDescriptor(name = "BJT Symbol", author = "Branislav Stojkovic", category = "Schematics", instanceNamePrefix = "Q", description = "Bipolar junction transistor schematic symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT, rotatable = true)
|
||||
public class BJTSymbol extends AbstractTransistorSymbol {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+84
-1
@@ -18,6 +18,7 @@ import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.misc.Label;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -44,6 +45,7 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
public static int EDGE_RADIUS = 6;
|
||||
public static Size PIN_SIZE = new Size(0.04d, SizeUnit.in);
|
||||
public static Size INDENT_SIZE = new Size(0.07d, SizeUnit.in);
|
||||
public static DisplayNumbers DISPLAY_NUMBERS = DisplayNumbers.NO;
|
||||
|
||||
private String value = "";
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
@@ -56,6 +58,7 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
private Color borderColor = BORDER_COLOR;
|
||||
private Color labelColor = LABEL_COLOR;
|
||||
private Color indentColor = INDENT_COLOR;
|
||||
private DisplayNumbers displayNumbers = DISPLAY_NUMBERS;
|
||||
// new Point(0, pinSpacing.convertToPixels()),
|
||||
// new Point(0, 2 * pinSpacing.convertToPixels()),
|
||||
// new Point(0, 3 * pinSpacing.convertToPixels()),
|
||||
@@ -334,7 +337,14 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||
String label = display == Display.NAME ? getName() : getValue();
|
||||
String label="";
|
||||
label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||
if (getDisplay() ==Display.NONE) {
|
||||
label="";
|
||||
}
|
||||
if (getDisplay() ==Display.BOTH) {
|
||||
label=getName()+" "+(getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
|
||||
int textHeight = (int) (rect.getHeight());
|
||||
int textWidth = (int) (rect.getWidth());
|
||||
@@ -343,6 +353,60 @@ public class DIL_IC 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);
|
||||
|
||||
//draw pin numbers
|
||||
int pinNo=0;
|
||||
int j=0;
|
||||
int k=0;
|
||||
int pinSize=(int)PIN_SIZE.convertToPixels();
|
||||
for (Point point : controlPoints) {
|
||||
pinNo++;
|
||||
|
||||
//determine points relative to rotation
|
||||
int textX1=point.x-2*pinSize;
|
||||
int textY1=point.y+pinSize/2;
|
||||
int textX2=point.x+pinSize;
|
||||
int textY2=point.y+pinSize/2;
|
||||
if (orientation==Orientation._90) {
|
||||
textX2=textX2-pinSize-pinSize/2;
|
||||
textY2=textY2+pinSize;
|
||||
textX1=textX1+2*pinSize-pinSize/2;
|
||||
textY1=textY1-pinSize;
|
||||
}
|
||||
if (orientation==Orientation._180) {
|
||||
textX1=textX1+3*pinSize;
|
||||
textX2=textX2-3*pinSize;
|
||||
}
|
||||
if (orientation==Orientation._270) {
|
||||
textX1 = textX1+pinSize+pinSize/2;
|
||||
textY1 = textY1+pinSize;
|
||||
textX2 = textX2-pinSize-pinSize/2;
|
||||
textY2 = textY2-pinSize;
|
||||
}
|
||||
|
||||
g2d.setFont(LABEL_FONT.deriveFont((float)(Label.LABEL_FONT.getSize2D()*0.66)));
|
||||
if (displayNumbers==DisplayNumbers.DIP){
|
||||
if (pinNo>pinCount.getValue()/2) {
|
||||
g2d.drawString(Integer.toString(pinCount.getValue()-j), textX1, textY1);
|
||||
j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
g2d.drawString(Integer.toString(pinNo), textX2, textY2);
|
||||
}
|
||||
}
|
||||
if (displayNumbers==DisplayNumbers.CONNECTOR){
|
||||
if (pinNo>pinCount.getValue()/2) {
|
||||
k++;
|
||||
g2d.drawString(Integer.toString(pinNo-(pinCount.getValue()/2)+k), textX1, textY1);
|
||||
}
|
||||
else
|
||||
{
|
||||
g2d.drawString(Integer.toString(pinNo+j), textX2, textY2);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -407,6 +471,15 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
public void setIndentColor(Color indentColor) {
|
||||
this.indentColor = indentColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Display pin numbers")
|
||||
public DisplayNumbers getDisplayNumbers() {
|
||||
return displayNumbers;
|
||||
}
|
||||
|
||||
public void setDisplayNumbers(DisplayNumbers numbers) {
|
||||
this.displayNumbers=numbers;
|
||||
}
|
||||
|
||||
public static enum PinCount {
|
||||
|
||||
@@ -421,4 +494,14 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
return Integer.parseInt(toString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum DisplayNumbers {
|
||||
|
||||
NO, DIP, CONNECTOR;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -102,7 +102,15 @@ public class ICSymbol extends AbstractTransparentComponent<String> {
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
int x = (controlPoints[0].x + controlPoints[2].x) / 2;
|
||||
drawCenteredText(g2d, display == Display.VALUE ? getValue() : getName(), x,
|
||||
String label="";
|
||||
label = display == Display.VALUE ? getValue() : getName();
|
||||
if (display==Display.NONE) {
|
||||
label="";
|
||||
}
|
||||
if (display==Display.BOTH) {
|
||||
label=getName()+" "+(getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
drawCenteredText(g2d, label, x,
|
||||
controlPoints[0].y + pinSpacing, HorizontalAlignment.CENTER,
|
||||
VerticalAlignment.CENTER);
|
||||
// Draw +/- markers
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
@ComponentDescriptor(name = "JFET Symbol", author = "Branislav Stojkovic", category = "Schematics", instanceNamePrefix = "Q", description = "JFET transistor schematic symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT, rotatable = false)
|
||||
@ComponentDescriptor(name = "JFET Symbol", author = "Branislav Stojkovic", category = "Schematics", instanceNamePrefix = "Q", description = "JFET transistor schematic symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT, rotatable = true)
|
||||
public class JFETSymbol extends AbstractTransistorSymbol {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
@ComponentDescriptor(name = "MOSFET Symbol", author = "Branislav Stojkovic", category = "Schematics", instanceNamePrefix = "Q", description = "MOSFET transistor schematic symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT, rotatable = false)
|
||||
@ComponentDescriptor(name = "MOSFET Symbol", author = "Branislav Stojkovic", category = "Schematics", instanceNamePrefix = "Q", description = "MOSFET transistor schematic symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT, rotatable = true)
|
||||
public class MOSFETSymbol extends AbstractTransistorSymbol {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+8
-1
@@ -320,7 +320,14 @@ public class SIL_IC extends AbstractTransparentComponent<String> {
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||
String label = display == Display.NAME ? getName() : getValue();
|
||||
String label="";
|
||||
label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||
if (getDisplay() ==Display.NONE) {
|
||||
label="";
|
||||
}
|
||||
if (getDisplay() ==Display.BOTH) {
|
||||
label=getName()+" "+(getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
|
||||
int textHeight = (int) (rect.getHeight());
|
||||
int textWidth = (int) (rect.getWidth());
|
||||
|
||||
+8
-1
@@ -252,7 +252,14 @@ public class TransistorTO1 extends AbstractTransparentComponent<String> {
|
||||
: getLabelColor();
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
String label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||
String label="";
|
||||
label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||
if (getDisplay() ==Display.NONE) {
|
||||
label="";
|
||||
}
|
||||
if (getDisplay() ==Display.BOTH) {
|
||||
label=getName()+" "+(getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||
Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
|
||||
int textHeight = (int) (rect.getHeight());
|
||||
|
||||
+8
-1
@@ -398,7 +398,14 @@ public class TransistorTO220 extends AbstractTransparentComponent<String> {
|
||||
: LABEL_COLOR;
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
String label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||
String label="";
|
||||
label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||
if (getDisplay() ==Display.NONE) {
|
||||
label="";
|
||||
}
|
||||
if (getDisplay() ==Display.BOTH) {
|
||||
label=getName()+" "+(getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||
Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
|
||||
int textHeight = (int) (rect.getHeight());
|
||||
|
||||
+8
-1
@@ -291,7 +291,14 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
||||
: getLabelColor();
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
String label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||
String label="";
|
||||
label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||
if (getDisplay() ==Display.NONE) {
|
||||
label="";
|
||||
}
|
||||
if (getDisplay() ==Display.BOTH) {
|
||||
label=getName()+" "+(getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||
Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
|
||||
int textHeight = (int) (rect.getHeight());
|
||||
|
||||
+8
-1
@@ -288,7 +288,14 @@ public class TransistorTO92 extends AbstractTransparentComponent<String> {
|
||||
: getLabelColor();
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
String label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||
String label="";
|
||||
label = (getDisplay() == Display.NAME) ? getName() : getValue();
|
||||
if (display==Display.NONE) {
|
||||
label="";
|
||||
}
|
||||
if (display==Display.BOTH) {
|
||||
label=getName()+" "+getValue();
|
||||
}
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
|
||||
Rectangle2D rect = fontMetrics.getStringBounds(label, g2d);
|
||||
int textHeight = (int) (rect.getHeight());
|
||||
|
||||
+9
-1
@@ -85,8 +85,16 @@ public abstract class AbstractTubeSymbol extends AbstractComponent<String> {
|
||||
}
|
||||
g2d.setColor(finalLabelColor);
|
||||
Point p = getTextLocation();
|
||||
String label="";
|
||||
label = display == Display.VALUE ? getValue() : getName();
|
||||
if (display==Display.NONE) {
|
||||
label="";
|
||||
}
|
||||
if (display==Display.BOTH) {
|
||||
label=getName()+" "+(getValue() == null ? "" : getValue().toString());
|
||||
}
|
||||
drawCenteredText(g2d,
|
||||
display == Display.VALUE ? getValue() : getName(), p.x, p.y,
|
||||
label, p.x, p.y,
|
||||
HorizontalAlignment.LEFT, VerticalAlignment.TOP);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user