mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
added ability to include or exclude switches from netlist analyzer
This commit is contained in:
@@ -35,9 +35,10 @@ public interface INetlistProcessor {
|
||||
/**
|
||||
* Finds all {@link Netlist}s for each switch position combination.
|
||||
*
|
||||
* @param includeSwitches
|
||||
* @return
|
||||
*/
|
||||
List<Netlist> extractNetlists();
|
||||
List<Netlist> extractNetlists(boolean includeSwitches);
|
||||
|
||||
/**
|
||||
* Finds all available {@link INetlistAnalyzer} implementations.
|
||||
|
||||
@@ -1906,7 +1906,7 @@ public class Presenter implements IPlugInPort {
|
||||
public void expandSelection(ExpansionMode expansionMode) {
|
||||
LOG.info(String.format("expandSelection(%s)", expansionMode));
|
||||
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>(this.selectedComponents);
|
||||
List<Netlist> netlists = extractNetlists();
|
||||
List<Netlist> netlists = extractNetlists(false);
|
||||
List<Set<IDIYComponent<?>>> allGroups = NetlistAnalyzer.extractComponentGroups(netlists);
|
||||
// Find control points of all selected components and all types
|
||||
Set<String> selectedNamePrefixes = new HashSet<String>();
|
||||
@@ -2699,11 +2699,12 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<Netlist> extractNetlists() {
|
||||
public List<Netlist> extractNetlists(boolean includeSwitches) {
|
||||
Map<Netlist, Netlist> result = new HashMap<Netlist, Netlist>();
|
||||
List<Node> nodes = new ArrayList<Node>();
|
||||
|
||||
List<ISwitch> switches = new ArrayList<ISwitch>();
|
||||
|
||||
for (IDIYComponent<?> c : currentProject.getComponents()) {
|
||||
ComponentType type =
|
||||
ComponentProcessor.getInstance().extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) c.getClass());
|
||||
@@ -2712,15 +2713,15 @@ public class Presenter implements IPlugInPort {
|
||||
if (!(c instanceof IContinuity)) {
|
||||
for (int i = 0; i < c.getControlPointCount(); i++) {
|
||||
String nodeName = c.getControlPointNodeName(i);
|
||||
if (nodeName != null) {
|
||||
if (nodeName != null && (!includeSwitches || !ISwitch.class.isAssignableFrom(type.getInstanceClass()))) {
|
||||
nodes.add(new Node(c, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// extract switches
|
||||
if (ISwitch.class.isAssignableFrom(type.getInstanceClass()))
|
||||
switches.add((ISwitch)c);
|
||||
if (includeSwitches && ISwitch.class.isAssignableFrom(type.getInstanceClass()))
|
||||
switches.add((ISwitch) c);
|
||||
}
|
||||
|
||||
// save us the trouble
|
||||
|
||||
Binary file not shown.
@@ -338,7 +338,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
drawCenteredText(g2d, label, offset, 0, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
g2d.setTransform(oldTransform);
|
||||
} else {
|
||||
if (getLabelOriantation() == LabelOriantation.Horizontal) {
|
||||
if (isStanding() || getLabelOriantation() == LabelOriantation.Horizontal) {
|
||||
g2d.setTransform(oldTransform);
|
||||
double x = (getNewPoints()[0].x + getNewPoints()[1].x - length) / 2.0;
|
||||
double y = (getNewPoints()[0].y + getNewPoints()[1].y - width) / 2.0;
|
||||
|
||||
+6
-6
@@ -393,12 +393,12 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
}
|
||||
|
||||
// switch stuff
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
// we don't want the switch to produce any nodes, it just makes connections
|
||||
return null;
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public String getControlPointNodeName(int index) {
|
||||
// // we don't want the switch to produce any nodes, it just makes connections
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
|
||||
@@ -328,12 +328,12 @@ public class LPSwitch extends AbstractTransparentComponent<String> implements IS
|
||||
body = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
// we don't want the switch to produce any nodes, it just makes connections
|
||||
return null;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String getControlPointNodeName(int index) {
|
||||
// // we don't want the switch to produce any nodes, it just makes connections
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// switch stuff
|
||||
|
||||
@Override
|
||||
|
||||
@@ -428,11 +428,11 @@ public class LeverSwitch extends AbstractTransparentComponent<String> implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
// we don't want the switch to produce any nodes, it just makes connections
|
||||
return null;
|
||||
}
|
||||
// @Override
|
||||
// public String getControlPointNodeName(int index) {
|
||||
// // we don't want the switch to produce any nodes, it just makes connections
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// switch stuff
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1667,7 +1667,7 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public List<Netlist> doInBackground() throws Exception {
|
||||
return plugInPort.extractNetlists();
|
||||
return plugInPort.extractNetlists(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1722,7 +1722,7 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public List<Summary> doInBackground() throws Exception {
|
||||
List<Netlist> netlists = plugInPort.extractNetlists();
|
||||
List<Netlist> netlists = plugInPort.extractNetlists(true);
|
||||
if (netlists == null || netlists.isEmpty()) {
|
||||
throw new Exception("The generated netlist is empty, nothing to show.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user