Cannot edit "Hookup Wire" properties when opening existing files

This commit is contained in:
bancika
2020-04-02 21:18:36 +02:00
parent 6db50fd7c6
commit da7ddf845b
6 changed files with 42 additions and 24 deletions
@@ -26,6 +26,7 @@ import java.awt.geom.CubicCurve2D;
import java.awt.geom.Path2D; import java.awt.geom.Path2D;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import org.apache.log4j.Logger;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.LineStyle; import org.diylc.common.LineStyle;
@@ -43,6 +44,8 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Logger LOG = Logger.getLogger(AbstractCurvedComponent.class);
public static Color GUIDELINE_COLOR = Color.blue; public static Color GUIDELINE_COLOR = Color.blue;
public static Size DEFAULT_SIZE = new Size(1d, SizeUnit.in); public static Size DEFAULT_SIZE = new Size(1d, SizeUnit.in);
@@ -328,6 +331,7 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
@EditableProperty @EditableProperty
public Size getLength() { public Size getLength() {
double d = 0; double d = 0;
try {
Point[] p = getControlPoints(); Point[] p = getControlPoints();
if (getPointCount() == PointCount.TWO) { if (getPointCount() == PointCount.TWO) {
d = p[0].distance(p[1]); d = p[0].distance(p[1]);
@@ -349,6 +353,10 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
d = d * SizeUnit.px.getFactor() / unit.getFactor(); d = d * SizeUnit.px.getFactor() / unit.getFactor();
return new Size(d, unit); return new Size(d, unit);
} catch (Exception e) {
LOG.error("Error calculating length of " + getName(), e);
return null;
}
} }
public enum PointCount { public enum PointCount {
@@ -391,12 +399,17 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
/ (8 * Math.pow(uu, 1.5))); / (8 * Math.pow(uu, 1.5)));
} }
private double curveThreshold = 10; // do not use this property
@Deprecated
private double curveThreshold;
// tweak this value if needed
private static final double curveDivisionThreshold = 5d;
// approximately calculate length of Bezier curves by subdivision // approximately calculate length of Bezier curves by subdivision
private double calculateLength(Point2D a, Point2D b, Point2D c, Point2D d) { private double calculateLength(Point2D a, Point2D b, Point2D c, Point2D d) {
double distance = a.distance(d); double distance = a.distance(d);
if (distance < curveThreshold) if (distance < curveDivisionThreshold)
return distance; return distance;
CubicCurve2D curve = new CubicCurve2D.Double(a.getX(), a.getY(), b.getX(), b.getY(), c.getX(), c.getY(), d.getX(), d.getY()); CubicCurve2D curve = new CubicCurve2D.Double(a.getX(), a.getY(), b.getX(), b.getY(), c.getX(), c.getY(), d.getX(), d.getY());
CubicCurve2D left = new CubicCurve2D.Double(); CubicCurve2D left = new CubicCurve2D.Double();
@@ -233,6 +233,7 @@ public class ProjectFileManager {
project = (Project) xStreamOld.fromXML(fis); project = (Project) xStreamOld.fromXML(fis);
} }
if (!missingFields.isEmpty()) { if (!missingFields.isEmpty()) {
LOG.warn("The opened file is missing the following properties: " + String.join(", ", missingFields));
warnings.add("The project references unknown component properties, most likely because it was created with a newer version of DIYLC."); warnings.add("The project references unknown component properties, most likely because it was created with a newer version of DIYLC.");
} }
fis.close(); fis.close();
@@ -2800,11 +2800,11 @@
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Refactor dependencies to internal Java classes that are market as proprietary (could potentially affect "Hi-Quality Rendering" mode and loading older DIY files that contain images)</description> <description>Refactor dependencies to internal Java classes that are market as proprietary in Java 8 (could potentially affect "Hi-Quality Rendering" mode and loading older DIY files that contain images)</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>Fix "Ohm" symbol rendering issue with some fonts.</description> <description>Fix "Ohm" symbol rendering issue with some fonts by switching to the regular Omega character instead of the dedicated Ohm symbol that is absent in most fonts</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
@@ -2830,6 +2830,10 @@
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>Minor fix in tracking conductive areas</description> <description>Minor fix in tracking conductive areas</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Cannot edit "Hookup Wire" properties when opening existing files</description>
</org.diylc.appframework.update.Change>
</changes> </changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url> <url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version> </org.diylc.appframework.update.Version>
Binary file not shown.
Binary file not shown.
Binary file not shown.