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:
bancika
2016-04-20 11:46:00 +02:00
parent fbc3c4bfc4
commit 3e18c5e1db
29 changed files with 335 additions and 115 deletions
@@ -74,7 +74,7 @@ public class HelpMenuPlugin implements IPlugIn {
aboutDialog = DialogFactory.getInstance().createAboutDialog("DIY Layout Creator",
IconLoader.IconLarge.getIcon(),
plugInPort.getCurrentVersionNumber().toString(), "Branislav Stojkovic",
"diylc.org", "bancika@gmail.com", "");
"https://github.com/bancika/diy-layout-creator", "bancika@gmail.com", "");
}
return aboutDialog;
}
@@ -2,12 +2,12 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
<classpathentry kind="lib" path="lib/junit-4.7.jar"/>
<classpathentry kind="lib" path="library/main.jar"/>
<classpathentry kind="lib" path="lib/app-framework.jar"/>
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
<classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_40"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -2,7 +2,7 @@ package org.diylc.common;
public enum Display {
NAME, VALUE;
NAME, VALUE, NONE, BOTH;
@Override
public String toString() {
@@ -33,8 +33,7 @@ import org.diylc.utils.Constants;
*
* @author Branislav Stojkovic
*/
public abstract class AbstractLeadedComponent<T> extends
AbstractTransparentComponent<T> {
public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComponent<T> {
private static final long serialVersionUID = 1L;
@@ -45,8 +44,7 @@ public abstract class AbstractLeadedComponent<T> extends
protected Size length;
protected Size width;
protected Point[] points = new Point[] {
new Point((int) (-DEFAULT_SIZE.convertToPixels() / 2), 0),
protected Point[] points = new Point[] { new Point((int) (-DEFAULT_SIZE.convertToPixels() / 2), 0),
new Point((int) (DEFAULT_SIZE.convertToPixels() / 2), 0) };
protected Color bodyColor = Color.white;
protected Color borderColor = Color.black;
@@ -68,44 +66,35 @@ public abstract class AbstractLeadedComponent<T> extends
}
@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) {
double distance = points[0].distance(points[1]);
Shape shape = getBodyShape();
// If there's no body, just draw the line connecting the ending points.
if (shape == null) {
drawLead(g2d, componentState);
} else if (supportsStandingMode()
&& length.convertToPixels() > points[0].distance(points[1])) {
} else if (supportsStandingMode() && length.convertToPixels() > points[0].distance(points[1])) {
// When ending points are too close draw the component in standing
// mode.
int width = getClosestOdd(this.width.convertToPixels());
Shape body = new Ellipse2D.Double((getFlipStanding() ? points[1]
: points[0]).x
- width / 2, (getFlipStanding() ? points[1] : points[0]).y
- width / 2, width, width);
Shape body = new Ellipse2D.Double((getFlipStanding() ? points[1] : points[0]).x - width / 2,
(getFlipStanding() ? points[1] : points[0]).y - width / 2, width, width);
Composite oldComposite = g2d.getComposite();
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
: getStandingBodyColor());
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getStandingBodyColor());
g2d.fill(body);
g2d.setComposite(oldComposite);
Color finalBorderColor;
if (outlineMode) {
Theme theme = (Theme) ConfigurationManager.getInstance()
.readObject(IPlugInPort.THEME_KEY,
Constants.DEFAULT_THEME);
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY,
Constants.DEFAULT_THEME);
finalBorderColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: theme.getOutlineColor();
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme.getOutlineColor();
} else {
finalBorderColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: borderColor;
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor;
}
g2d.setColor(finalBorderColor);
@@ -116,8 +105,7 @@ public abstract class AbstractLeadedComponent<T> extends
} else {
// Normal mode with component body in the center and two lead parts.
Rectangle shapeRect = shape.getBounds();
Double theta = Math.atan2(points[1].y - points[0].y, points[1].x
- points[0].x);
Double theta = Math.atan2(points[1].y - points[0].y, points[1].x - points[0].x);
// Go back to the original transformation to draw leads.
if (!outlineMode) {
AffineTransform textTransform = g2d.getTransform();
@@ -127,36 +115,25 @@ public abstract class AbstractLeadedComponent<T> extends
// 0.5f));
// }
int leadThickness = getClosestOdd(getLeadThickness());
double leadLength = (distance - calculatePinSpacing(shapeRect))
/ 2 - leadThickness / 2;
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
leadThickness));
Color leadColor = shouldShadeLeads() ? getLeadColorForPainting(
componentState).darker()
double leadLength = (distance - calculatePinSpacing(shapeRect)) / 2 - leadThickness / 2;
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(leadThickness));
Color leadColor = shouldShadeLeads() ? getLeadColorForPainting(componentState).darker()
: getLeadColorForPainting(componentState);
g2d.setColor(leadColor);
int endX = (int) (points[0].x + Math.cos(theta) * leadLength);
int endY = (int) Math.round(points[0].y + Math.sin(theta)
* leadLength);
int endY = (int) Math.round(points[0].y + Math.sin(theta) * leadLength);
g2d.drawLine(points[0].x, points[0].y, endX, endY);
endX = (int) (points[1].x + Math.cos(theta - Math.PI)
* leadLength);
endY = (int) Math.round(points[1].y + Math.sin(theta - Math.PI)
* leadLength);
endX = (int) (points[1].x + Math.cos(theta - Math.PI) * leadLength);
endY = (int) Math.round(points[1].y + Math.sin(theta - Math.PI) * leadLength);
g2d.drawLine(points[1].x, points[1].y, endX, endY);
if (shouldShadeLeads()) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
leadThickness - 2));
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(leadThickness - 2));
leadColor = getLeadColorForPainting(componentState);
g2d.setColor(leadColor);
g2d.drawLine(points[0].x, points[0].y,
(int) (points[0].x + Math.cos(theta) * leadLength),
g2d.drawLine(points[0].x, points[0].y, (int) (points[0].x + Math.cos(theta) * leadLength),
(int) (points[0].y + Math.sin(theta) * leadLength));
g2d.drawLine(points[1].x, points[1].y,
(int) (points[1].x + Math.cos(theta - Math.PI)
* leadLength), (int) (points[1].y + Math
.sin(theta - Math.PI)
* leadLength));
g2d.drawLine(points[1].x, points[1].y, (int) (points[1].x + Math.cos(theta - Math.PI) * leadLength),
(int) (points[1].y + Math.sin(theta - Math.PI) * leadLength));
}
g2d.setTransform(textTransform);
}
@@ -173,19 +150,16 @@ public abstract class AbstractLeadedComponent<T> extends
length = getLength().convertToPixels();
}
oldTransform = g2d.getTransform();
g2d.translate((points[0].x + points[1].x - length) / 2,
(points[0].y + points[1].y - width) / 2);
g2d.translate((points[0].x + points[1].x - length) / 2, (points[0].y + points[1].y - width) / 2);
g2d.rotate(theta, length / 2, width / 2);
// Draw body.
Composite oldComposite = g2d.getComposite();
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));
}
if (bodyColor != null) {
if (bodyColor != null) {
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR
: bodyColor);
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
g2d.fill(shape);
}
}
@@ -194,16 +168,13 @@ public abstract class AbstractLeadedComponent<T> extends
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
Color finalBorderColor;
if (outlineMode) {
Theme theme = (Theme) ConfigurationManager.getInstance()
.readObject(IPlugInPort.THEME_KEY,
Constants.DEFAULT_THEME);
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY,
Constants.DEFAULT_THEME);
finalBorderColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: theme.getOutlineColor();
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : theme.getOutlineColor();
} else {
finalBorderColor = componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: borderColor;
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor;
}
g2d.setColor(finalBorderColor);
g2d.draw(shape);
@@ -259,49 +230,46 @@ public abstract class AbstractLeadedComponent<T> extends
}
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();
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
: labelColor;
finalLabelColor = componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? LABEL_COLOR_SELECTED : labelColor;
}
g2d.setColor(finalLabelColor);
FontMetrics fontMetrics = g2d.getFontMetrics();
String label = display == Display.NAME ? getName()
: (getValue() == null ? "" : getValue().toString());
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());
}
Rectangle2D textRect = fontMetrics.getStringBounds(label, g2d);
// Don't offset in outline mode.
int offset = outlineMode ? 0 : getLabelOffset((int) length,
(int) width);
int offset = outlineMode ? 0 : getLabelOffset((int) length, (int) width);
// Adjust label angle if needed to make sure that it's readable.
if ((theta >= Math.PI / 2 && theta <= Math.PI)
|| (theta < -Math.PI / 2 && theta > -Math.PI)) {
if ((theta >= Math.PI / 2 && theta <= Math.PI) || (theta < -Math.PI / 2 && theta > -Math.PI)) {
g2d.rotate(Math.PI, length / 2, width / 2);
offset = -offset;
}
g2d.drawString(label, (int) (length - textRect.getWidth()) / 2
+ offset, calculateLabelYCoordinate(shapeRect, textRect,
fontMetrics));
g2d.drawString(label, (int) (length - textRect.getWidth()) / 2 + offset,
calculateLabelYCoordinate(shapeRect, textRect, fontMetrics));
g2d.setTransform(oldTransform);
}
}
private void drawLead(Graphics2D g2d, ComponentState componentState) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
getLeadThickness()));
Color leadColor = shouldShadeLeads() ? getLeadColorForPainting(
componentState).darker()
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(getLeadThickness()));
Color leadColor = shouldShadeLeads() ? getLeadColorForPainting(componentState).darker()
: getLeadColorForPainting(componentState);
g2d.setColor(leadColor);
g2d.drawLine(points[0].x, points[0].y, points[1].x, points[1].y);
if (shouldShadeLeads()) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
getLeadThickness() - 2));
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(getLeadThickness() - 2));
leadColor = getLeadColorForPainting(componentState);
g2d.setColor(leadColor);
g2d.drawLine(points[0].x, points[0].y, points[1].x, points[1].y);
@@ -312,10 +280,8 @@ public abstract class AbstractLeadedComponent<T> extends
// Do nothing.
}
protected int calculateLabelYCoordinate(Rectangle2D shapeRect,
Rectangle2D textRect, FontMetrics fontMetrics) {
return (int) (shapeRect.getHeight() - textRect.getHeight()) / 2
+ fontMetrics.getAscent();
protected int calculateLabelYCoordinate(Rectangle2D shapeRect, Rectangle2D textRect, FontMetrics fontMetrics) {
return (int) (shapeRect.getHeight() - textRect.getHeight()) / 2 + fontMetrics.getAscent();
}
protected boolean shouldShadeLeads() {
@@ -352,8 +318,7 @@ public abstract class AbstractLeadedComponent<T> extends
* Controls how component shape should be placed relative to start and end
* point.
*
* @return
* <code>true<code> if shape rect should be used to center the component or <code>false</code>
* @return <code>true<code> if shape rect should be used to center the component or <code>false</code>
* to place the component relative to <code>length</code> and
* <code>width</code> values.
*/
@@ -372,8 +337,7 @@ public abstract class AbstractLeadedComponent<T> extends
* @return default lead color. Override this method to change it.
*/
protected Color getLeadColorForPainting(ComponentState componentState) {
return componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
return componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: getLeadColor();
}
@@ -591,7 +591,7 @@ public class Presenter implements IPlugInPort {
}
} else {
// Otherwise just select that one component.
if (button == BUTTON1
if (button == BUTTON1 || (button == BUTTON3 && newSelection.size() == 1)
|| !newSelection.contains(topComponent)) {
newSelection.clear();
}
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
<classpathentry kind="lib" path="lib/app-framework.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/>
<classpathentry kind="lib" path="lib/xstream-1.4.3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_40"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -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());
@@ -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));
}
@@ -387,6 +399,18 @@ public class TrimmerPotentiometer extends AbstractPotentiometer {
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() {
return borderColor;
@@ -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;
@@ -29,10 +30,12 @@ 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);
}
@@ -145,6 +184,15 @@ public abstract class AbstractTransistorSymbol extends AbstractComponent<String>
body = null;
}
@EditableProperty
public SymbolFlipping getFlipping() {
return flipping;
}
public void setFlipping(SymbolFlipping flipping) {
this.flipping = flipping;
}
@EditableProperty
public Color getColor() {
return color;
@@ -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;
@@ -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
@@ -408,6 +472,15 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
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 {
_4, _6, _8, _10, _12, _14, _16, _18, _20, _22, _24, _26, _28, _30, _32, _34, _36, _38, _40, _42, _44, _46, _48, _50;
@@ -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();
}
}
}
@@ -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
@@ -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;
@@ -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;
@@ -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());
@@ -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());
@@ -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());
@@ -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());
@@ -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());
@@ -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);
}
@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
<classpathentry kind="lib" path="lib/junit-4.7.jar"/>
<classpathentry kind="lib" path="lib/iText-2.1.7.jar"/>
@@ -16,5 +15,6 @@
<classpathentry kind="lib" path="lib/swing-framework.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/>
<classpathentry kind="lib" path="lib/xstream-1.4.3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_40"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -1 +1 @@
-Xms512m -Xmx1024m -Dorg.diylc.scriptRun=true
-Xms512m -Xmx1024m -Dorg.diylc.scriptRun=true -Dfile.encoding=UTF-8
@@ -261,7 +261,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
@Override
public EnumSet<EventType> getSubscribedEventTypes() {
return EnumSet.of(EventType.SELECTION_CHANGED,
EventType.PROJECT_MODIFIED);
EventType.PROJECT_MODIFIED, EventType.PROJECT_LOADED);
}
@Override
@@ -274,6 +274,9 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
undoHandler.stateChanged((Project) params[0], (Project) params[1],
(String) params[2]);
break;
case PROJECT_LOADED:
undoHandler.reset();
break;
}
}
@@ -72,7 +72,7 @@ public class HelpMenuPlugin implements IPlugIn {
aboutDialog = DialogFactory.getInstance().createAboutDialog("DIY Layout Creator",
IconLoader.IconLarge.getIcon(),
plugInPort.getCurrentVersionNumber().toString(), "Branislav Stojkovic",
"diylc.org", "bancika@gmail.com", "");
"https://github.com/bancika/diy-layout-creator", "bancika@gmail.com", "");
}
return aboutDialog;
}
@@ -1257,5 +1257,45 @@
</changes>
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>3</major>
<minor>29</minor>
<build>0</build>
</versionNumber>
<releaseDate>2016-04-20 20:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Issue with losing saved user configuration</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Issue with disabled "Save as Template" context menu item problem, as well as issue with strange rotation and probably few more</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Undo steps kept after opening a new file</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Transistors can be rotated and flipped vertically</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>DIL ICs can show pin numbers</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Display both component value and name or neither of them</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Potentiometer schematic symbol added</description>
</org.diylc.appframework.update.Change>
</changes>
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
</org.diylc.appframework.update.Version>
</a>
</java.util.Arrays_-ArrayList>