mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
Cannot edit "Hookup Wire" properties when opening existing files
This commit is contained in:
@@ -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,27 +331,32 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
|
|||||||
@EditableProperty
|
@EditableProperty
|
||||||
public Size getLength() {
|
public Size getLength() {
|
||||||
double d = 0;
|
double d = 0;
|
||||||
Point[] p = getControlPoints();
|
try {
|
||||||
if (getPointCount() == PointCount.TWO) {
|
Point[] p = getControlPoints();
|
||||||
d = p[0].distance(p[1]);
|
if (getPointCount() == PointCount.TWO) {
|
||||||
} else if (getPointCount() == PointCount.THREE) {
|
d = p[0].distance(p[1]);
|
||||||
d = calculateLength(p[0], p[1], p[1], p[2]);
|
} else if (getPointCount() == PointCount.THREE) {
|
||||||
} else if (getPointCount() == PointCount.FOUR) {
|
d = calculateLength(p[0], p[1], p[1], p[2]);
|
||||||
d = calculateLength(p[0], p[1], p[2], p[3]);
|
} else if (getPointCount() == PointCount.FOUR) {
|
||||||
} else if (getPointCount() == PointCount.FIVE) {
|
d = calculateLength(p[0], p[1], p[2], p[3]);
|
||||||
d = calculateLength(p[0], p[1], p[2]) + calculateLength(p[2], p[3], p[4]);
|
} else if (getPointCount() == PointCount.FIVE) {
|
||||||
} else if (getPointCount() == PointCount.SEVEN) {
|
d = calculateLength(p[0], p[1], p[2]) + calculateLength(p[2], p[3], p[4]);
|
||||||
d = calculateLength(p[0], p[1], p[2], p[3]) + calculateLength(p[3], p[4], p[5], p[6]);
|
} else if (getPointCount() == PointCount.SEVEN) {
|
||||||
|
d = calculateLength(p[0], p[1], p[2], p[3]) + calculateLength(p[3], p[4], p[5], p[6]);
|
||||||
|
}
|
||||||
|
|
||||||
|
SizeUnit unit;
|
||||||
|
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.METRIC_KEY, true))
|
||||||
|
unit = SizeUnit.mm;
|
||||||
|
else
|
||||||
|
unit = SizeUnit.in;
|
||||||
|
|
||||||
|
d = d * SizeUnit.px.getFactor() / unit.getFactor();
|
||||||
|
return new Size(d, unit);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Error calculating length of " + getName(), e);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
SizeUnit unit;
|
|
||||||
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.METRIC_KEY, true))
|
|
||||||
unit = SizeUnit.mm;
|
|
||||||
else
|
|
||||||
unit = SizeUnit.in;
|
|
||||||
|
|
||||||
d = d * SizeUnit.px.getFactor() / unit.getFactor();
|
|
||||||
return new Size(d, unit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
Reference in New Issue
Block a user