diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar index 984d913c..8b797d50 100644 Binary files a/diylc/diylc-library/lib/diylc-core.jar and b/diylc/diylc-library/lib/diylc-core.jar differ diff --git a/diylc/diylc-library/src/org/diylc/components/AbstractLeadedComponent.java b/diylc/diylc-library/src/org/diylc/components/AbstractLeadedComponent.java index d19430c0..f81108ea 100644 --- a/diylc/diylc-library/src/org/diylc/components/AbstractLeadedComponent.java +++ b/diylc/diylc-library/src/org/diylc/components/AbstractLeadedComponent.java @@ -221,7 +221,7 @@ public abstract class AbstractLeadedComponent extends AbstractTransparentComp newComposite = g2d.getComposite(); g2d.setComposite(oldComposite); - g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1)); + g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(getOutlineStrokeSize())); Color finalBorderColor; if (outlineMode) { Theme theme = @@ -376,6 +376,10 @@ public abstract class AbstractLeadedComponent extends AbstractTransparentComp protected int getLabelOffset(int bodyLength, int bodyWidth, int labelLength) { return 0; } + + protected float getOutlineStrokeSize() { + return 1f; + } /** * @return default component length. diff --git a/diylc/diylc-library/src/org/diylc/components/AbstractSchematicLeadedSymbol.java b/diylc/diylc-library/src/org/diylc/components/AbstractSchematicLeadedSymbol.java index 3e593cf5..73a22ffa 100644 --- a/diylc/diylc-library/src/org/diylc/components/AbstractSchematicLeadedSymbol.java +++ b/diylc/diylc-library/src/org/diylc/components/AbstractSchematicLeadedSymbol.java @@ -24,7 +24,7 @@ package org.diylc.components; import java.awt.Color; import java.awt.FontMetrics; import java.awt.geom.Rectangle2D; - + import org.diylc.common.LabelPosition; import org.diylc.core.ComponentState; import org.diylc.core.annotations.EditableProperty; @@ -59,8 +59,8 @@ public abstract class AbstractSchematicLeadedSymbol extends AbstractLeadedCom @Override protected float getLeadThickness() { return 1; - } - + } + @Override protected int calculateLabelYCoordinate(Rectangle2D shapeRect, Rectangle2D textRect, FontMetrics fontMetrics) { if (labelPosition == LabelPosition.ABOVE) { diff --git a/diylc/diylc-library/src/org/diylc/components/passive/FuseSymbol.java b/diylc/diylc-library/src/org/diylc/components/passive/FuseSymbol.java new file mode 100644 index 00000000..d2bccd3f --- /dev/null +++ b/diylc/diylc-library/src/org/diylc/components/passive/FuseSymbol.java @@ -0,0 +1,112 @@ +/* + + DIY Layout Creator (DIYLC). + Copyright (c) 2009-2018 held jointly by the individual authors. + + This file is part of DIYLC. + + DIYLC is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DIYLC is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DIYLC. If not, see . + +*/ +package org.diylc.components.passive; + +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Path2D; + +import org.diylc.common.SimpleComponentTransformer; +import org.diylc.components.AbstractSchematicLeadedSymbol; +import org.diylc.core.CreationMethod; +import org.diylc.core.IDIYComponent; +import org.diylc.core.annotations.ComponentDescriptor; +import org.diylc.core.annotations.EditableProperty; +import org.diylc.core.annotations.KeywordPolicy; +import org.diylc.core.measures.Current; +import org.diylc.core.measures.Size; +import org.diylc.core.measures.SizeUnit; + +@ComponentDescriptor(name = "Fuse", author = "Branislav Stojkovic", category = "Schematic Symbols", + creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "F", + description = "Fuse schematic symbol", zOrder = IDIYComponent.COMPONENT, + keywordPolicy = KeywordPolicy.SHOW_VALUE, keywordTag = "Schematic", transformer = SimpleComponentTransformer.class) +public class FuseSymbol extends AbstractSchematicLeadedSymbol { + + private static final long serialVersionUID = 1L; + + public static Size DEFAULT_LENGTH = new Size(0.3, SizeUnit.in); + public static Size DEFAULT_WIDTH = new Size(0.12, SizeUnit.in); + + private Current value = null; + + @EditableProperty + public Current getValue() { + return value; + } + + public void setValue(Current value) { + this.value = value; + } + + @Override + public String getValueForDisplay() { + return getValue().toString();// + (getPowerNew() == null ? "" : " " + getPowerNew().toString()); + } + + public void drawIcon(Graphics2D g2d, int width, int height) { + g2d.rotate(-Math.PI / 4, width / 2, height / 2); + g2d.setColor(LEAD_COLOR); + g2d.drawLine(0, height / 2, 4, height / 2); + g2d.drawLine(width - 4, height / 2, width, height / 2); + int d = 3; + g2d.setColor(COLOR); + g2d.drawOval(4, height / 2 - 1, d, d); + g2d.drawOval(width - 4 - d, height / 2 - 1, d, d); + Path2D path = new Path2D.Double(); + path.moveTo(4 + d, height / 2); + double w = 5; + path.curveTo(4 + 2 * d, height / 2 + w, width / 2 - d, height / 2 + w, width / 2, height / 2); + path.curveTo(width / 2 + d, height / 2 - w, width - 4 - 2 * d, height / 2 - w, width - 4 - d, height / 2); + g2d.draw(path); + } + + @Override + protected Size getDefaultWidth() { + return DEFAULT_WIDTH; + } + + @Override + protected Size getDefaultLength() { + return DEFAULT_LENGTH; + } + + @Override + protected Shape getBodyShape() { + Path2D polyline = new Path2D.Double(); + double length = getLength().convertToPixels(); + double width = getWidth().convertToPixels(); + double radius = width / 6; + polyline.moveTo(2 * radius, width / 2); + polyline.curveTo(3 * radius, width, length / 2 - radius, width, length / 2, width / 2); + polyline.curveTo(length / 2 + radius, 0, length - 3 * radius, 0, length - 2 * radius, width / 2); + polyline.append(new Ellipse2D.Double(0, width / 2 - radius, radius * 2, radius * 2), false); + polyline.append(new Ellipse2D.Double(length - radius * 2, width / 2 - radius, radius * 2, radius * 2), false); + return polyline; + } + + @Override + protected boolean useShapeRectAsPosition() { + return false; + } +} diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar index 984d913c..8b797d50 100644 Binary files a/diylc/diylc-swing/lib/diylc-core.jar and b/diylc/diylc-swing/lib/diylc-core.jar differ diff --git a/diylc/diylc-swing/library/main.jar b/diylc/diylc-swing/library/main.jar index d6a3e14f..92c0c53d 100644 Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml index 29c26665..f0d55ecc 100644 --- a/diylc/diylc-swing/update.xml +++ b/diylc/diylc-swing/update.xml @@ -2358,9 +2358,13 @@ 2019-01-28 00:00:00.000 CET + + NEW_FEATURE + "Fuse Symbol" added + IMPROVEMENT - Better precision when exporting to PDF and PNG files + Better rendering precision when exporting to PDF and PNG files BUG_FIX