mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c7d3ec45c | |||
| 62ae5011ff | |||
| 8a1b3c271e | |||
| c067118d77 | |||
| 9913e7ddb1 | |||
| ace11a8d7d | |||
| f152167602 | |||
| 3838b81612 | |||
| e5b7c4ff88 | |||
| 5f3e290bd0 | |||
| 9a9c875e8b | |||
| 9f8fd634cc | |||
| 8d4f6fd46c | |||
| b469ab9aa3 | |||
| 1492831678 | |||
| b997c18558 |
@@ -35,19 +35,9 @@ public enum Orientation {
|
||||
}
|
||||
|
||||
public double toDegrees() {
|
||||
switch (this) {
|
||||
case DEFAULT:
|
||||
return 0;
|
||||
case _180:
|
||||
return 180;
|
||||
case _270:
|
||||
return 270;
|
||||
case _90:
|
||||
return 90;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
if (this == DEFAULT)
|
||||
return 0;
|
||||
return Integer.parseInt(name().replace("_", ""));
|
||||
}
|
||||
|
||||
public double toRadians() {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.common;
|
||||
|
||||
public enum Orientation45 {
|
||||
|
||||
DEFAULT, _45, _90, _135, _180, _225, _270, _315;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this == DEFAULT) {
|
||||
return "Default";
|
||||
} else {
|
||||
return name().replace("_", "") + " degrees clockwise";
|
||||
}
|
||||
}
|
||||
|
||||
public double toDegrees() {
|
||||
if (this == DEFAULT)
|
||||
return 0;
|
||||
return Integer.parseInt(name().replace("_", ""));
|
||||
}
|
||||
|
||||
public double toRadians() {
|
||||
return Math.toRadians(toDegrees());
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public class Netlist implements Comparable<Netlist> {
|
||||
@@ -58,10 +60,6 @@ public class Netlist implements Comparable<Netlist> {
|
||||
return switchSetup;
|
||||
}
|
||||
|
||||
public void done() {
|
||||
Collections.sort(switchSetup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
@@ -86,11 +84,16 @@ public class Netlist implements Comparable<Netlist> {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getSwitchSetupString() {
|
||||
return getSwitchSetup().isEmpty() ? "[ ALL ]" : "[ " +
|
||||
getSwitchSetup().stream().map(x -> x.toString()).collect(Collectors.joining(",")) + " ]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Switch setup: ").append(getSwitchSetup()).append("\n\n");
|
||||
sb.append("Switch setup: ").append(getSwitchSetupString()).append("\n\n");
|
||||
List<Group> list = getSortedGroups();
|
||||
for (Group g : list) {
|
||||
sb.append("\t").append(g).append("\n");
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -29,6 +30,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.core.ICommonNode;
|
||||
@@ -42,6 +44,7 @@ import org.diylc.presenter.ComponentProcessor;
|
||||
import org.diylc.presenter.Connection;
|
||||
import org.diylc.presenter.ContinuityArea;
|
||||
import org.diylc.utils.RTree;
|
||||
|
||||
import com.google.common.graph.GraphBuilder;
|
||||
import com.google.common.graph.ImmutableGraph;
|
||||
import com.google.common.graph.ImmutableGraph.Builder;
|
||||
@@ -188,10 +191,29 @@ public class NetlistBuilder {
|
||||
// sort everything alphabetically
|
||||
List<Netlist> netlists = new ArrayList<Netlist>(result.keySet());
|
||||
Collections.sort(netlists);
|
||||
netlists.forEach(netlist -> cleanupRedundantSwitches(netlist.getSwitchSetup()));
|
||||
|
||||
return netlists;
|
||||
}
|
||||
|
||||
|
||||
public static void cleanupRedundantSwitches(List<SwitchSetup> switchSetups) {
|
||||
Map<ISwitch, Set<Integer>> positionCountMap = new HashMap<>();
|
||||
switchSetups.forEach(s -> s.getPositions().forEach(pos -> {
|
||||
positionCountMap.computeIfAbsent(pos.getSwitch(), k -> new HashSet<Integer>()).add(pos.getPosition());
|
||||
}));
|
||||
// find switches that are here in all the positions, meaning that they don't affect the circuit
|
||||
Set<ISwitch> switchesToPrune = positionCountMap.entrySet().stream()
|
||||
.filter(e -> e.getKey().getPositionCount() == e.getValue().size())
|
||||
.map(x -> x.getKey())
|
||||
.collect(Collectors.toSet());
|
||||
switchSetups.forEach(s -> s.getPositions().removeIf(x -> switchesToPrune.contains(x.getSwitch())));
|
||||
switchSetups.removeIf(x -> x.getPositions().isEmpty());
|
||||
HashSet<SwitchSetup> uniqueSetups = new HashSet<>(switchSetups);
|
||||
switchSetups.clear();
|
||||
switchSetups.addAll(uniqueSetups);
|
||||
switchSetups.sort(Comparator.comparing(x -> x.toString()));
|
||||
}
|
||||
|
||||
public static Netlist buildNetlist(List<IDIYComponent<?>> components, Collection<Node> nodes,
|
||||
Collection<ContinuityArea> continuityAreas, Collection<Connection> connections) {
|
||||
ImmutableGraph<ProjectGraphNode> graph = buildGraph(nodes, continuityAreas, connections);
|
||||
|
||||
@@ -161,10 +161,10 @@ public class Tree {
|
||||
}
|
||||
|
||||
public String toAsciiString() {
|
||||
return String.join("<br>", toAscii());
|
||||
return String.join("<br>", toAsciiLines());
|
||||
}
|
||||
|
||||
private List<String> toAscii() {
|
||||
private List<String> toAsciiLines() {
|
||||
if (leaf != null) {
|
||||
return Arrays.asList(TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH, 1) + " " + leaf.toHTML() + " " + TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH, 1));
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class Tree {
|
||||
List<Tree> children = getOrderedChildren();
|
||||
|
||||
List<List<String>> childrenAscii =
|
||||
children.stream().map(c -> c.toAscii()).collect(Collectors.toList());
|
||||
children.stream().map(c -> c.toAsciiLines()).collect(Collectors.toList());
|
||||
|
||||
if (TreeConnectionType.Series.equals(connectionType)) {
|
||||
return TreeAsciiUtil.concatenateMultiLineSerial(TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH, 1), childrenAscii);
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.diylc.clipboard.ComponentTransferable;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.Orientation45;
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.Angle;
|
||||
@@ -436,6 +437,7 @@ public class InstantiationManager {
|
||||
for (PropertyWrapper propertyWrapper : properties) {
|
||||
if (propertyWrapper.getType().getName().equals(Orientation.class.getName())
|
||||
|| propertyWrapper.getType().getName().equals(OrientationHV.class.getName())
|
||||
|| propertyWrapper.getType().getName().equals(Orientation45.class.getName())
|
||||
|| propertyWrapper.getName().equalsIgnoreCase("angle")) {
|
||||
angleProperty = propertyWrapper;
|
||||
break;
|
||||
@@ -455,6 +457,9 @@ public class InstantiationManager {
|
||||
} else if (value instanceof OrientationHV) {
|
||||
angleProperty.setValue(OrientationHV.values()[(((OrientationHV) value).ordinal() + 1)
|
||||
% OrientationHV.values().length]);
|
||||
} else if (value instanceof Orientation45) {
|
||||
angleProperty.setValue(Orientation45.values()[(((Orientation45) value).ordinal() + 1)
|
||||
% Orientation45.values().length]);
|
||||
} else if (value instanceof Angle) {
|
||||
Angle angle = (Angle) angleProperty.getValue();
|
||||
Angle newAngle = angle.rotate(1);
|
||||
|
||||
@@ -223,7 +223,7 @@
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Switched to AppImage distribution for Linux system, abandoning Flatpak as a means of distribution. DIYLC AppImage will be available alongside with other executables on the official DIYLC GitHub page.</description>
|
||||
<description>Switched to AppImage distribution for Linux system, abandoning Flatpak as a means of distribution. DIYLC AppImage will be available alongside with other executables on the official DIYLC GitHub page</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
@@ -248,7 +248,15 @@
|
||||
</versionNumber>
|
||||
<releaseDate>2025-03-09 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>'Multimeter Probe' component added and 'Virtual Multimeter' functionality that uses it</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Cleaner text representation of switch configuration in analyzer windows - removed switches and positions that have no effect on the effective circuit</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Moving selected components with a mouse doesn't register file modification action and doesn't enable Undo action</description>
|
||||
|
||||
@@ -20,6 +20,17 @@ public class TreeAsciiUtilTest {
|
||||
assertEquals("yy-yyy", result.get(1));
|
||||
assertEquals(" aaa", result.get(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleParallel() {
|
||||
List<String> result = TreeAsciiUtil.concatenateMultiLineParallel(
|
||||
Arrays.asList(Arrays.asList("xx"), Arrays.asList("yy")));
|
||||
assertNotNull(result);
|
||||
assertEquals(3, result.size());
|
||||
assertEquals(" ┌xx┐ ", result.get(0));
|
||||
assertEquals("─┤ ├─", result.get(1));
|
||||
assertEquals(" └yy┘ ", result.get(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConcatenateMultiLineSerial_singleInput() {
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
*
|
||||
* 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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package org.diylc.components.connectivity;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation45;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.transform.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Multimeter Probe", category = "Connectivity",
|
||||
author = "Branislav Stojkovic", description = "Multimeter Probe", instanceNamePrefix = "Probe",
|
||||
zOrder = IDIYComponent.TEXT, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = SimpleComponentTransformer.class,
|
||||
enableCache = true)
|
||||
public class MultimeterProbe extends AbstractTransparentComponent<Color> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Size PROBE_DIAMETER = new Size(0.05d, SizeUnit.in);
|
||||
public static Size PROBE_LENGTH = new Size(0.4d, SizeUnit.in);
|
||||
public static Color PROBE_COLOR = METAL_COLOR;
|
||||
public static Size HANDLE_DIAMETER = new Size(0.2d, SizeUnit.in);
|
||||
public static Size HANDLE_LENGTH = new Size(0.4d, SizeUnit.in);
|
||||
public static Color HANDLE_COLOR = Color.red;
|
||||
|
||||
private Point2D.Double point = new Point2D.Double(0, 0);
|
||||
private Color handleColor = HANDLE_COLOR;
|
||||
private Orientation45 orientation = Orientation45._315;
|
||||
|
||||
private transient Shape[] body = null;
|
||||
|
||||
public MultimeterProbe() {
|
||||
this.alpha = (byte) (MAX_ALPHA / 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||
Project project, IDrawingObserver drawingObserver) {
|
||||
|
||||
Shape[] shapes = getBody();
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||
|
||||
if (!outlineMode) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(
|
||||
AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(PROBE_COLOR);
|
||||
g2d.fill(shapes[0]);
|
||||
g2d.setColor(handleColor);
|
||||
g2d.fill(shapes[1]);
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
g2d.setColor(
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
|
||||
? SELECTION_COLOR
|
||||
: handleColor.darker());
|
||||
g2d.draw(shapes[1]);
|
||||
g2d.setColor(
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
|
||||
? SELECTION_COLOR
|
||||
: PROBE_COLOR.darker());
|
||||
g2d.draw(shapes[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
double probeDiameter = 2;
|
||||
double probeLength = height / 2 + 2;
|
||||
double handleDiameter = width / 4;
|
||||
double handleLength = height / 2 + 2;
|
||||
double x = 2;
|
||||
double y = height - 2;
|
||||
Shape probe = buildProbeShape(probeDiameter, probeLength, x, y);
|
||||
Shape handle = buildHandleShape(probeDiameter, probeLength, handleDiameter, handleLength, x, y);
|
||||
|
||||
double theta = Math.PI / 4;
|
||||
AffineTransform tx = AffineTransform.getRotateInstance(theta, x, y);
|
||||
probe = tx.createTransformedShape(probe);
|
||||
handle = tx.createTransformedShape(handle);
|
||||
|
||||
g2d.setColor(PROBE_COLOR);
|
||||
g2d.fill(probe);
|
||||
g2d.setColor(HANDLE_COLOR);
|
||||
g2d.fill(handle);
|
||||
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.setColor(PROBE_COLOR.darker());
|
||||
g2d.draw(probe);
|
||||
g2d.setColor(HANDLE_COLOR.darker());
|
||||
g2d.draw(handle);
|
||||
}
|
||||
|
||||
public Shape[] getBody() {
|
||||
if (body == null) {
|
||||
double probeDiameter = PROBE_DIAMETER.convertToPixels();
|
||||
double probeLength = PROBE_LENGTH.convertToPixels();
|
||||
double handleDiameter = HANDLE_DIAMETER.convertToPixels();
|
||||
double handleLength = HANDLE_LENGTH.convertToPixels();
|
||||
double x = point.getX();
|
||||
double y = point.getY();
|
||||
body = new Shape[2];
|
||||
Path2D probe = buildProbeShape(probeDiameter, probeLength, x, y);
|
||||
body[0] = probe;
|
||||
Path2D handle =
|
||||
buildHandleShape(probeDiameter, probeLength, handleDiameter, handleLength, x, y);
|
||||
body[1] = handle;
|
||||
|
||||
double theta = orientation.toRadians();
|
||||
if (theta != 0) {
|
||||
AffineTransform tx = AffineTransform.getRotateInstance(theta, x, y);
|
||||
body[0] = tx.createTransformedShape(body[0]);
|
||||
body[1] = tx.createTransformedShape(body[1]);
|
||||
}
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
private Path2D buildHandleShape(double probeDiameter, double probeLength, double handleDiameter,
|
||||
double handleLength, double x, double y) {
|
||||
Path2D handle = new Path2D.Double();
|
||||
handle.moveTo(x + probeDiameter, y - probeLength);
|
||||
handle.lineTo(x + handleDiameter / 2, y - handleLength - probeLength);
|
||||
handle.lineTo(x - handleDiameter / 2, y - handleLength - probeLength);
|
||||
handle.lineTo(x - probeDiameter, y - probeLength);
|
||||
handle.moveTo(x + probeDiameter, y - probeLength);
|
||||
handle.closePath();
|
||||
return handle;
|
||||
}
|
||||
|
||||
private Path2D buildProbeShape(double probeDiameter, double probeLength, double x, double y) {
|
||||
Path2D probe = new Path2D.Double();
|
||||
probe.moveTo(x, y);
|
||||
probe.lineTo(x - probeDiameter / 2, y - probeDiameter);
|
||||
probe.lineTo(x - probeDiameter / 2, y - probeLength);
|
||||
probe.lineTo(x + probeDiameter / 2, y - probeLength);
|
||||
probe.lineTo(x + probeDiameter / 2, y - probeDiameter);
|
||||
probe.lineTo(x, y);
|
||||
probe.closePath();
|
||||
return probe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.NEVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point2D point, int index) {
|
||||
this.point.setLocation(point);
|
||||
this.body = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@EditableProperty(name = "Color")
|
||||
public Color getValue() {
|
||||
return handleColor;
|
||||
}
|
||||
|
||||
public void setValue(Color color) {
|
||||
this.handleColor = color;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Angle")
|
||||
public Orientation45 getOrientation() {
|
||||
return orientation;
|
||||
}
|
||||
|
||||
public void setOrientation(Orientation45 orientation) {
|
||||
this.orientation = orientation;
|
||||
this.body = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return "Tip";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
Shape[] shapes = getBody();
|
||||
Rectangle2D bounds1 = shapes[0].getBounds2D();
|
||||
Rectangle2D bounds2 = shapes[1].getBounds2D();
|
||||
double minX = Math.min(bounds1.getMinX(), bounds2.getMinX());
|
||||
double minY = Math.min(bounds1.getMinY(), bounds2.getMinY());
|
||||
double maxX = Math.max(bounds1.getMaxX(), bounds2.getMaxX());
|
||||
double maxY = Math.max(bounds1.getMaxY(), bounds2.getMaxY());
|
||||
return new Rectangle2D.Double(minX - 1, minY - 1, maxX - minX + 2, maxY - minY + 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
*
|
||||
* 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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package org.diylc.netlist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.swing.JLabel;
|
||||
import org.diylc.common.INetlistAnalyzer;
|
||||
import org.diylc.components.connectivity.MultimeterProbe;
|
||||
|
||||
public class MultimeterAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Virtual Multimeter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortName() {
|
||||
return "multimeter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconName() {
|
||||
return "Multimeter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFontName() {
|
||||
return new JLabel().getFont().getName();
|
||||
}
|
||||
|
||||
protected Summary summarize(Netlist netlist, Node preferredOutput) throws TreeException {
|
||||
Tree tree = constructTree(netlist);
|
||||
|
||||
if (tree == null) {
|
||||
return new Summary(netlist, "No components found connecting the two multimeter probes.");
|
||||
}
|
||||
|
||||
List<String> notes = new ArrayList<String>();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String asciiTree = tree.toAsciiString();
|
||||
|
||||
sb.append("<br><br>")
|
||||
.append("<font face='Courier New'>")
|
||||
.append(asciiTree)
|
||||
.append("</font>");
|
||||
if (!notes.isEmpty()) {
|
||||
Collections.sort(notes);
|
||||
sb.append("<br><br>");
|
||||
for (String v : notes) {
|
||||
sb.append(v).append("<br>");
|
||||
}
|
||||
}
|
||||
|
||||
return new Summary(netlist, sb.toString());
|
||||
}
|
||||
|
||||
public Tree constructTree(Netlist netlist) throws TreeException {
|
||||
List<Node> probeNodes = find(Set.of(MultimeterProbe.class.getCanonicalName()), null, netlist);
|
||||
|
||||
if (probeNodes.size() == 0) {
|
||||
throw new TreeException("No multimeter probes are placed on the circuit.");
|
||||
} else if (probeNodes.size() != 2) {
|
||||
throw new TreeException(
|
||||
"Place exactly two multimeter probes on the circuit in order to run the analysis.");
|
||||
} else {
|
||||
return constructTreeBetween(netlist, probeNodes.get(0), probeNodes.get(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
BIN
Binary file not shown.
+14
-436
@@ -13,27 +13,26 @@
|
||||
#34 / 0.16mm
|
||||
#36 / 0.13mm
|
||||
#8 / 3.26mm
|
||||
(Building Blocks)
|
||||
(Favorites)
|
||||
(Recently Used)
|
||||
1 throws / 2 positions
|
||||
10 throws / 10 positions
|
||||
11 throws / 11 positions
|
||||
12 throws / 12 positions
|
||||
180 degrees clockwise
|
||||
135 degrees clockwise
|
||||
1P12T
|
||||
2 throws / 2 positions
|
||||
2 throws / 3 positions / OFF even positions
|
||||
270 degrees clockwise
|
||||
225 degrees clockwise
|
||||
2P5T
|
||||
2P6T
|
||||
3 throws / 3 positions
|
||||
3 throws / 5 positions / SHORT even positions
|
||||
315 degrees clockwise
|
||||
3P4T
|
||||
3PDT
|
||||
3PDT (On/Off/On)
|
||||
4 band
|
||||
4 throws / 4 positions
|
||||
45 degrees clockwise
|
||||
4P3T
|
||||
4P5T
|
||||
4P5T (Super/Mega)
|
||||
@@ -50,115 +49,22 @@
|
||||
7 throws / 7 positions
|
||||
8 throws / 8 positions
|
||||
9 throws / 9 positions
|
||||
90 degrees clockwise
|
||||
A variant with that name already exists. Overwrite?
|
||||
A-O-I REGULATOR
|
||||
AC
|
||||
ANSI
|
||||
AWG
|
||||
About
|
||||
Above
|
||||
Access User Files
|
||||
Add Flexible Leads
|
||||
Add Validation Step
|
||||
All Connected
|
||||
Alpha
|
||||
Alternate
|
||||
Analyze
|
||||
Analyze Guitar Diagrams
|
||||
And
|
||||
Angle
|
||||
Angle Offset
|
||||
Anti-Aliasing
|
||||
Arrow Size
|
||||
Author
|
||||
Auto-Create Pads
|
||||
Auto-Edit Mode
|
||||
B-C-E BJT
|
||||
Background
|
||||
Base
|
||||
Below
|
||||
Board
|
||||
Board Color
|
||||
Board Width
|
||||
Boards
|
||||
Bobbin 1
|
||||
Bobbin 2
|
||||
Body
|
||||
Border
|
||||
Border Thickness
|
||||
Both
|
||||
Both Sides
|
||||
Bottom
|
||||
Bottom Left
|
||||
Bottom Right
|
||||
Box
|
||||
Bracket
|
||||
Bring Forward
|
||||
Bring Selection to Front
|
||||
Buffer
|
||||
C-B-E BJT
|
||||
Center
|
||||
Center Negative
|
||||
Center Positive
|
||||
Center Terminal
|
||||
Central
|
||||
Change Password
|
||||
Channel
|
||||
Chassis
|
||||
Check Trace Proximity
|
||||
Circle
|
||||
Circular
|
||||
Click on a component to highlight area directly or indirectly connected to the area below the cursor. To continue editing, this mode needs to be switched OFF
|
||||
Click on the canvas to create a new %s or press %s to cancel
|
||||
Click on the canvas to set the %s control point of a new %s or press %s to cancel
|
||||
Click the lightbulb icon in the bottom-right corner of the window for more info.
|
||||
Click to fetch the most recent public announcement
|
||||
Click to show recent changes and updates
|
||||
Click to toggle to the next option
|
||||
Coil
|
||||
Coil Border
|
||||
Coil Length
|
||||
Coil Width
|
||||
Coil(s)
|
||||
Color
|
||||
Color 1
|
||||
Color 2
|
||||
Color code
|
||||
Column Spacing
|
||||
Columns
|
||||
Component
|
||||
Component API
|
||||
Component reordering is possible only when Project Explorer is sorted by z-index.
|
||||
Components
|
||||
Config
|
||||
Configuration
|
||||
Connectivity
|
||||
Connector
|
||||
Connector (Mirrored)
|
||||
Contacts
|
||||
Continuous Creation
|
||||
Coordinate Color
|
||||
Coordinate Origin
|
||||
Coordinates
|
||||
Copy
|
||||
Core
|
||||
Core Border
|
||||
Core Thickness
|
||||
Core Width
|
||||
Could not apply changes. Check the log for details.
|
||||
Could not create a new file. Check the log for details.
|
||||
Could not create component. Check log for details.
|
||||
Could not fetch public announcements.
|
||||
Could not save the project to file. Check the log for details.
|
||||
Could not set component type slot. Check log for details.
|
||||
Cover
|
||||
Create B.O.M.
|
||||
Create New Account
|
||||
Current
|
||||
Cut
|
||||
Cut Between Holes
|
||||
Cut Orientation
|
||||
D-G-S JFET
|
||||
D-G-S MOSFET
|
||||
D-S-G JFET
|
||||
@@ -167,12 +73,8 @@ DC
|
||||
DFM A
|
||||
DFM B
|
||||
DIP
|
||||
DIP (Mirrored)
|
||||
DP3T
|
||||
DP3T (Import 5-Position Strat)
|
||||
DP3T (Standard 3-Position Strat)
|
||||
DP3T (Standard 5-Position Strat)
|
||||
DP4T (4-Position Tele)
|
||||
DP4T (6-Position Oak Grigsby)
|
||||
DP5T
|
||||
DPDT
|
||||
@@ -180,78 +82,24 @@ DPDT (On/Off/On)
|
||||
DPDT (On/On)
|
||||
DPDT (On/On/On Type 1)
|
||||
DPDT (On/On/On Type 2)
|
||||
Dashed
|
||||
Decimals
|
||||
Default
|
||||
Default Font
|
||||
Default Font Size
|
||||
Delete Selection
|
||||
Description
|
||||
Designation
|
||||
Diameter
|
||||
Deutsch
|
||||
Dimension Mode
|
||||
Directional
|
||||
Directly heated
|
||||
Display
|
||||
Display Pin #s
|
||||
Dog Ear
|
||||
Donate
|
||||
Dot Spacing
|
||||
Dots (Gradual)
|
||||
Dots (Uniform)
|
||||
Dotted
|
||||
Double Rails
|
||||
Double Rods
|
||||
Drag control point(s) of
|
||||
Drag the mouse over the canvas to place a new
|
||||
Draw Standard
|
||||
Drop
|
||||
Duodecar B12C
|
||||
Duplicate
|
||||
E+
|
||||
E-B-C BJT
|
||||
Edges
|
||||
Edit
|
||||
Edit Project Settings
|
||||
Edit Selection
|
||||
Eight
|
||||
Electro-Mechanical
|
||||
Electrode Labels
|
||||
Enable Cache Boost
|
||||
End Arrow
|
||||
Enjoying DIYLC? Click here to buy me a coffee :)
|
||||
Error
|
||||
Error occurred while editing selection. Check the log for details.
|
||||
Exit
|
||||
Expand Selection
|
||||
Explicit Dimensions
|
||||
Explicit Length
|
||||
Explicit Width
|
||||
English
|
||||
Español
|
||||
Export
|
||||
Export Building Blocks
|
||||
Export Grid
|
||||
Export Variants
|
||||
Export to Gerber
|
||||
Export to PDF
|
||||
Export to PNG
|
||||
Extra Working Area
|
||||
Eyelet color
|
||||
FAQ
|
||||
Filament Voltage
|
||||
File
|
||||
Filtertron
|
||||
Find
|
||||
Five
|
||||
Flip
|
||||
Folded
|
||||
Font
|
||||
Font Bold
|
||||
Font Italic
|
||||
Font Size
|
||||
Font Size Override
|
||||
Four
|
||||
Full
|
||||
Fuse
|
||||
Français
|
||||
G-D-S JFET
|
||||
G-D-S MOSFET
|
||||
G-I-O REGULATOR
|
||||
@@ -260,198 +108,50 @@ G-S-D JFET
|
||||
G-S-D MOSFET
|
||||
Generate DIYLC Netlist (excl. Switches)
|
||||
Generate DIYLC Netlist (incl. Switches)
|
||||
Generate Spice Netlist
|
||||
Grid
|
||||
Grid Spacing
|
||||
Group Selection
|
||||
Guitar
|
||||
Half
|
||||
Heaters
|
||||
Height
|
||||
Help
|
||||
Hi-Quality Rendering
|
||||
Highlight Connected Areas
|
||||
Hole
|
||||
Hole Size
|
||||
Hole Spacing
|
||||
Gray
|
||||
Hole Type
|
||||
Holes Per Strip
|
||||
Horizontal
|
||||
Horizontal Alignment
|
||||
Horizontal Large
|
||||
Horizontal Medium
|
||||
Horizontal Small 1
|
||||
Horizontal Small 2
|
||||
Horizontal X-Small
|
||||
Humbucking - 4 leads
|
||||
I-G-O REGULATOR
|
||||
IEC
|
||||
Image
|
||||
Immediate Only
|
||||
Import
|
||||
Import Building Blocks
|
||||
Import Netlist
|
||||
Import Variants
|
||||
In-Line D-44
|
||||
In-line
|
||||
Indent
|
||||
Information
|
||||
Inline
|
||||
Inner 1
|
||||
Inner 2
|
||||
Inner 3
|
||||
Inner 4
|
||||
Inner 5
|
||||
Inner 6
|
||||
Inside Color
|
||||
Integration
|
||||
Invert Polarity
|
||||
Label
|
||||
Label Color
|
||||
Label Orientation
|
||||
Label Position
|
||||
Labels
|
||||
Language
|
||||
Language selection will be applied after the application is restarted.
|
||||
Layer
|
||||
Layers
|
||||
Lead Color
|
||||
Lead Count
|
||||
Lead Length
|
||||
Lead Spacing
|
||||
Left
|
||||
Left click to instantiate this component, right click for more options
|
||||
Left-to-Right
|
||||
Legs
|
||||
Length
|
||||
Letters
|
||||
Italiano
|
||||
Lin
|
||||
Loadline Editor
|
||||
Lock
|
||||
Log
|
||||
Log In
|
||||
Log Out
|
||||
Lug Size
|
||||
Lugs
|
||||
MPJA
|
||||
Make a Donation
|
||||
Manage Account
|
||||
Manage My Uploads
|
||||
Mark Common Lugs
|
||||
Marker
|
||||
Marker Size
|
||||
Markers
|
||||
Maximum number of switching combinations exceeded. Allowed: %s, actual: %s
|
||||
Mini
|
||||
Miniature
|
||||
Mirror Horizontally
|
||||
Mirror Selection
|
||||
Mirror Vertically
|
||||
Mirroring operation will change the circuit. Do you want to continue?
|
||||
Misc
|
||||
Model
|
||||
Mono
|
||||
Mount
|
||||
Mounting Lugs
|
||||
Mouse Wheel Zoom
|
||||
Moveable Label
|
||||
NPN
|
||||
Name
|
||||
Nand
|
||||
Negative
|
||||
New
|
||||
New version available
|
||||
Nederlands
|
||||
Nine
|
||||
No
|
||||
No new public announcements available.
|
||||
Non-Plated Through Hole
|
||||
Non-shorting
|
||||
None
|
||||
Nor
|
||||
Not
|
||||
Noval B9A
|
||||
Nudge
|
||||
Numbers
|
||||
Numeric (0-10)
|
||||
Numeric (1-10)
|
||||
Numeric (1-11)
|
||||
Numeric (1-12)
|
||||
Numeric (Even, No Ticks)
|
||||
Numeric (Even, With Ticks)
|
||||
Nut
|
||||
O-G-I REGULATOR
|
||||
Octal
|
||||
Offset
|
||||
One
|
||||
One Side
|
||||
Open
|
||||
Opposing Points
|
||||
Or
|
||||
Orientation
|
||||
Outer Foil
|
||||
Outer Foil Mark
|
||||
Outline Mode
|
||||
Outside
|
||||
Oval horizontal
|
||||
Oval vertical
|
||||
PAF
|
||||
PCB
|
||||
PNP
|
||||
Pad Color
|
||||
Pad color
|
||||
Panel
|
||||
Passive
|
||||
Paste
|
||||
Pin Arrangement
|
||||
Pin Color
|
||||
Pin Spacing
|
||||
Pin spacing
|
||||
Pinout
|
||||
Pins
|
||||
Pitch
|
||||
Plated Through Hole
|
||||
Play Test
|
||||
Plugin API
|
||||
Point Count
|
||||
Polarity
|
||||
Polarized
|
||||
Pole Color
|
||||
Pole Pieces
|
||||
Pole Pieces 1
|
||||
Pole Pieces 2
|
||||
Poles
|
||||
Positions
|
||||
Positive
|
||||
Power Rating
|
||||
Power Strip
|
||||
Primary CT
|
||||
Print...
|
||||
Project Cloud
|
||||
Public Announcement
|
||||
Português
|
||||
RS
|
||||
Radius
|
||||
Rail
|
||||
Recent Files
|
||||
Recent Updates
|
||||
Rectangle
|
||||
Redo
|
||||
Renumber On Paste
|
||||
Renumber Selection
|
||||
Resistance
|
||||
Rev log
|
||||
Reverse (standing)
|
||||
Right
|
||||
Rim
|
||||
Rods
|
||||
Rotate Clockwise
|
||||
Rotate Counterclockwise
|
||||
Rotate Selection
|
||||
Round
|
||||
Round WOG A
|
||||
Round WOG B
|
||||
Row Spacing
|
||||
Rows
|
||||
Ruler Inch Subdivision...
|
||||
S-G-D JFET
|
||||
S-G-D MOSFET
|
||||
SMD
|
||||
@@ -459,150 +159,28 @@ SPDT
|
||||
SPDT (On/Off/On)
|
||||
SPDT (On/On)
|
||||
SPST
|
||||
Same Type Only
|
||||
Save
|
||||
Save As
|
||||
Save as Variant
|
||||
Scale
|
||||
Schematic Symbols
|
||||
Screw Position
|
||||
Screws
|
||||
Search The Cloud
|
||||
Searchable Tree
|
||||
Secondary CT
|
||||
Select All
|
||||
Selected component(s) have reached the bottom of their layer. Do you want to force the selection to the back?
|
||||
Selected component(s) have reached the top of their layer. Do you want to force the selection to the top?
|
||||
Selection
|
||||
Selection Size
|
||||
Selection contains components that cannot be mirrored. Do you want to exclude them?
|
||||
Selection contains components that cannot be rotated. Do you want to exclude them?
|
||||
Selection is empty.
|
||||
Semiconductors
|
||||
Send Backward
|
||||
Send Selection to Back
|
||||
Seven
|
||||
Shaft Down
|
||||
Shaft Up
|
||||
Shape
|
||||
Shapes
|
||||
Shorting
|
||||
Show Bracket
|
||||
Show Grid
|
||||
Show Project Explorer
|
||||
Show Rulers
|
||||
Shroud
|
||||
Shrouded
|
||||
Single - North
|
||||
Single - South
|
||||
Single Rail
|
||||
Single Rods
|
||||
Six
|
||||
Size
|
||||
Sizing Mode
|
||||
Small-button B7G
|
||||
Smooth
|
||||
Snap To
|
||||
Soap Bar
|
||||
Solid
|
||||
Sort by Name
|
||||
Sort by Type
|
||||
Sort by Z-index
|
||||
Source Style
|
||||
Source Type
|
||||
Spacing
|
||||
Square
|
||||
Square BR-3
|
||||
Standard
|
||||
Start Arrow
|
||||
Start Recording
|
||||
Stereo
|
||||
Sticky Points
|
||||
Stop Recording
|
||||
Stratocaster
|
||||
Strip Color
|
||||
Stripe
|
||||
Stripe 1
|
||||
Stripe 2
|
||||
Stripe Color
|
||||
Stripe Color 1
|
||||
Stripe Color 2
|
||||
Srpski
|
||||
Stroke
|
||||
Style
|
||||
Submit a Bug
|
||||
Suppressor grid
|
||||
Switched
|
||||
Switches
|
||||
Tab
|
||||
Tab Border
|
||||
Tabbed Toolbar
|
||||
Taper
|
||||
Telecaster
|
||||
Ten
|
||||
Terminal
|
||||
Terminal Spacing
|
||||
Terminals
|
||||
Test
|
||||
Text
|
||||
Text Color
|
||||
There are unsaved changes. Would you like to save them?
|
||||
Thickness
|
||||
Three
|
||||
Through Hole
|
||||
Tick
|
||||
Tick Width
|
||||
Ticks
|
||||
Timing
|
||||
Title
|
||||
Toolbox
|
||||
Top
|
||||
Top Lead
|
||||
Top Left
|
||||
Top Right
|
||||
Top-to-Bottom
|
||||
Trace
|
||||
Trace Color
|
||||
Trace Mask
|
||||
Transform Selection
|
||||
Triangle
|
||||
Tubes
|
||||
Tubular
|
||||
Tubular Beveled
|
||||
Two
|
||||
Type
|
||||
Ultra-miniature
|
||||
Underside Pad Color
|
||||
Underside Trace Color
|
||||
Undo
|
||||
Ungroup Selection
|
||||
Unit
|
||||
Upload A Project
|
||||
User Manual
|
||||
Value
|
||||
Version history is not available.
|
||||
Vertical
|
||||
Vertical Alignment
|
||||
Vertical Inline
|
||||
Vertical Offset 1
|
||||
Vertical Offset 2
|
||||
View
|
||||
Visible
|
||||
Voltage
|
||||
Wafer
|
||||
Warning
|
||||
Width
|
||||
Winding Spacing
|
||||
Wiring
|
||||
X-axis
|
||||
Virtual Multimeter
|
||||
Xnor
|
||||
Xor
|
||||
Y-axis
|
||||
Zoom
|
||||
base of 10
|
||||
base of 2
|
||||
cm
|
||||
ft
|
||||
hold %s and drag to unstick from
|
||||
in
|
||||
mm
|
||||
px
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -69,7 +69,7 @@ public enum IconLoader {
|
||||
SnapToComponents("snap_to_components.png"), SnapToNone("snap_to_none.png"), TraceProximity("trace_proximity.png"),
|
||||
ComponentLarge("component_large.png"), ImportNetlist("import_netlist.png"), SplashIC("splash_ic.png"),
|
||||
ComponentPreferences("component_preferences.png"), ComponentReplace("component_replace.png"), Barcode("barcode.png"),
|
||||
DocumentGerber("document_gerber.png"), DocumentX2("document_x2.png"), Export("export.png");
|
||||
Multimeter("multimeter.png"), DocumentGerber("document_gerber.png"), DocumentX2("document_x2.png"), Export("export.png");
|
||||
|
||||
protected String name;
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 864 B |
Reference in New Issue
Block a user