Cleaner XML format for .DIY files with less cross-references

pinout update
This commit is contained in:
Branislav Stojkovic
2019-03-09 20:15:36 +01:00
parent 7af919b303
commit f63b422a8c
12 changed files with 74 additions and 10 deletions
@@ -294,7 +294,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
} }
@Override @Override
public String getSectionName(int pointIndex) { public String[] getSectionNames(int pointIndex) {
return null; return null;
} }
@@ -132,9 +132,10 @@ public interface IDIYComponent<T> extends Serializable {
/** /**
* @param pointIndex name of the internal section containing the specified point, or null if the component does not have internal sections. * @param pointIndex name of the internal section containing the specified point, or null if the component does not have internal sections.
* One point can be shared between multiple sections, in which case, the result may contain more than one element.
* @return * @return
*/ */
String getSectionName(int pointIndex); String[] getSectionNames(int pointIndex);
/** /**
* Draws the component onto the {@link Graphics2D}. * Draws the component onto the {@link Graphics2D}.
@@ -48,8 +48,8 @@ public class Node implements Comparable<Node> {
} }
public String getDisplayName() { public String getDisplayName() {
String section = component.getSectionName(pointIndex); String[] section = component.getSectionNames(pointIndex);
return (section == null ? "" : section + ".") + component.getControlPointNodeName(pointIndex); return (section == null || section.length > 1 ? "" : section[0] + ".") + component.getControlPointNodeName(pointIndex);
} }
@Override @Override
@@ -21,6 +21,7 @@
*/ */
package org.diylc.presenter; package org.diylc.presenter;
import java.awt.Color;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@@ -93,6 +94,15 @@ public class ProjectFileManager {
}; };
xStream.autodetectAnnotations(true); xStream.autodetectAnnotations(true);
xStream.registerConverter(new PointConverter()); xStream.registerConverter(new PointConverter());
xStream.addImmutableType(Color.class);
xStream.addImmutableType(java.awt.Point.class);
xStream.addImmutableType(org.diylc.core.measures.Voltage.class);
xStream.addImmutableType(org.diylc.core.measures.Resistance.class);
xStream.addImmutableType(org.diylc.core.measures.Capacitance.class);
xStream.addImmutableType(org.diylc.core.measures.Current.class);
xStream.addImmutableType(org.diylc.core.measures.Power.class);
xStream.addImmutableType(org.diylc.core.measures.Inductance.class);
xStream.addImmutableType(org.diylc.core.measures.Size.class);
this.xStreamOld = new XStream(new DomDriver()); this.xStreamOld = new XStream(new DomDriver());
xStreamOld.autodetectAnnotations(true); xStreamOld.autodetectAnnotations(true);
this.messageDispatcher = messageDispatcher; this.messageDispatcher = messageDispatcher;
Binary file not shown.
@@ -87,6 +87,11 @@ public abstract class AbstractTransistorPackage extends AbstractTransparentCompo
return index; return index;
} }
@Override
public String getComment() {
return getPinout() == null ? null : (getPinout().toString() + " pinout");
}
@EditableProperty @EditableProperty
public String getValue() { public String getValue() {
return value; return value;
@@ -6,6 +6,14 @@ public enum TransistorPinout {
@Override @Override
public String toString() { public String toString() {
return name().replace("_", " "); String[] parts = name().split("_");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < parts[1].length(); i++) {
if (i > 0)
sb.append("-");
sb.append(parts[1].charAt(i));
}
sb.append(" ").append(parts[0]);
return sb.toString();
}; };
} }
@@ -1,8 +1,34 @@
/*
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; package org.diylc.netlist;
/**
* Maps DIYLC component control points to spice-compatible node indices.
*
* @author Branislav Stojkovic
*/
public interface ISpiceMapper { public interface ISpiceMapper {
int mapToSpiceNode(int Index); int mapToSpiceNode(int pontIndex);
String getSectionName(int pointIndex); String getComment();
} }
@@ -110,6 +110,12 @@ public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer {
} }
sb.append(c.getValue()); sb.append(c.getValue());
if (c instanceof ISpiceMapper) {
String comment = ((ISpiceMapper)c).getComment();
if (comment != null)
sb.append(" ; ").append(comment);
}
sb.append("<br>"); sb.append("<br>");
} }
Binary file not shown.
Binary file not shown.
+8
View File
@@ -2586,10 +2586,18 @@
<changeType>NEW_FEATURE</changeType> <changeType>NEW_FEATURE</changeType>
<description>Generate SPICE-compatible netlist (still in beta stage)</description> <description>Generate SPICE-compatible netlist (still in beta stage)</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added pinout property to all transistor components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>When in "Highlight Connected Area" mode, the status bar shows useful information making it harder to forget what the mode does</description> <description>When in "Highlight Connected Area" mode, the status bar shows useful information making it harder to forget what the mode does</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Cleaner XML format for .DIY files with less cross-references</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>"Highlight Connected Areas" doesn't follow multiple chained wires and jumpers</description> <description>"Highlight Connected Areas" doesn't follow multiple chained wires and jumpers</description>