mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
netlist analyzer enhancements
This commit is contained in:
@@ -30,6 +30,7 @@ import java.util.stream.Collectors;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import org.diylc.common.INetlistAnalyzer;
|
||||
import org.diylc.common.NetlistSwitchPreference;
|
||||
import org.diylc.components.electromechanical.ClosedJack1_4;
|
||||
import org.diylc.components.electromechanical.OpenJack1_4;
|
||||
import org.diylc.components.guitar.AbstractGuitarPickup;
|
||||
@@ -89,6 +90,10 @@ public class GuitarDiagramAnalyzer extends AbstractNetlistAnalyzer implements IN
|
||||
RC_TYPES.addAll(RESISTOR_TYPES);
|
||||
}
|
||||
|
||||
private int positiveCount;
|
||||
private int negativeCount;
|
||||
private int noiseCount;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Analyze Guitar Diagrams";
|
||||
@@ -109,10 +114,10 @@ public class GuitarDiagramAnalyzer extends AbstractNetlistAnalyzer implements IN
|
||||
return new JLabel().getFont().getName();
|
||||
}
|
||||
|
||||
|
||||
private int positiveCount;
|
||||
private int negativeCount;
|
||||
private int noiseCount;
|
||||
@Override
|
||||
public Set<NetlistSwitchPreference> getSwitchPreference() {
|
||||
return Set.of(NetlistSwitchPreference.WITH);
|
||||
}
|
||||
|
||||
protected Summary summarize(Netlist netlist, Node preferredOutput) throws TreeException {
|
||||
List<String> notes = new ArrayList<String>();
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.diylc.netlist;
|
||||
import java.util.*;
|
||||
import javax.swing.JLabel;
|
||||
import org.diylc.common.INetlistAnalyzer;
|
||||
import org.diylc.common.NetlistSwitchPreference;
|
||||
import org.diylc.components.connectivity.MultimeterProbe;
|
||||
|
||||
public class MultimeterAnalyzer extends AbstractNetlistAnalyzer implements INetlistAnalyzer {
|
||||
@@ -45,6 +46,11 @@ public class MultimeterAnalyzer extends AbstractNetlistAnalyzer implements INetl
|
||||
return new JLabel().getFont().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<NetlistSwitchPreference> getSwitchPreference() {
|
||||
return EnumSet.allOf(NetlistSwitchPreference.class);
|
||||
}
|
||||
|
||||
protected Summary summarize(Netlist netlist, Node preferredOutput) throws TreeException {
|
||||
Tree tree = constructTree(netlist);
|
||||
|
||||
|
||||
@@ -21,11 +21,15 @@
|
||||
*/
|
||||
package org.diylc.netlist;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.diylc.common.INetlistAnalyzer;
|
||||
import org.diylc.common.NetlistSwitchPreference;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.netlist.Group;
|
||||
import org.diylc.netlist.Netlist;
|
||||
@@ -33,6 +37,7 @@ import org.diylc.netlist.NetlistAnalyzer;
|
||||
import org.diylc.netlist.Node;
|
||||
import org.diylc.netlist.Summary;
|
||||
import org.diylc.netlist.TreeException;
|
||||
import org.diylc.presenter.ComponentProcessor;
|
||||
|
||||
public class SpiceAnalyzer extends AbstractNetlistAnalyzer implements INetlistAnalyzer {
|
||||
|
||||
@@ -58,6 +63,11 @@ public class SpiceAnalyzer extends AbstractNetlistAnalyzer implements INetlistAn
|
||||
public String getFontName() {
|
||||
return "Courier New";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<NetlistSwitchPreference> getSwitchPreference() {
|
||||
return EnumSet.allOf(NetlistSwitchPreference.class);
|
||||
}
|
||||
|
||||
protected Summary summarize(Netlist netlist, Node preferredOutput) throws TreeException {
|
||||
// grab all components that are in the netlist
|
||||
@@ -121,7 +131,7 @@ public class SpiceAnalyzer extends AbstractNetlistAnalyzer implements INetlistAn
|
||||
sb.append(" ");
|
||||
}
|
||||
|
||||
sb.append(c.getValue());
|
||||
sb.append(formatValue(c));
|
||||
|
||||
if (c instanceof ISpiceMapper) {
|
||||
String comment = ((ISpiceMapper)c).getComment();
|
||||
@@ -137,7 +147,27 @@ public class SpiceAnalyzer extends AbstractNetlistAnalyzer implements INetlistAn
|
||||
.sorted()
|
||||
.collect(Collectors.joining("\n")));
|
||||
}
|
||||
|
||||
|
||||
private static Object formatValue(IDIYComponent<?> c) {
|
||||
if (c.getValue() == null || c.getValue().toString().trim().isEmpty()) {
|
||||
String typeName = ComponentProcessor.getInstance()
|
||||
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) c.getClass()).getName();
|
||||
// if (
|
||||
// Void.class.equals(((ParameterizedType) c.getClass()
|
||||
// .getGenericSuperclass()).getActualTypeArguments()[0])) {
|
||||
// return typeName;
|
||||
// }
|
||||
if (typeName.contains(" ")) {
|
||||
return "\"" + typeName + "\"";
|
||||
}
|
||||
return typeName;
|
||||
}
|
||||
if (c.getValue().toString().contains(" ")) {
|
||||
return "\"" + c.getValue() + "\"";
|
||||
}
|
||||
return c.getValue();
|
||||
}
|
||||
|
||||
private static String formatSpiceNode(int i) {
|
||||
return String.format("N%03d" , i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user