mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
move section handling to base component interface
do analysis in background thread
This commit is contained in:
@@ -291,5 +291,11 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||
@Override
|
||||
public String getInternalLinkName(int index1, int index2) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSectionName(int pointIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ package org.diylc.core;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
@@ -128,7 +128,13 @@ public interface IDIYComponent<T> extends Serializable {
|
||||
* @param index2
|
||||
* @return name of the internal linked formed by the two control points, null if they do not form an internal link
|
||||
*/
|
||||
String getInternalLinkName(int index1, int index2);
|
||||
String getInternalLinkName(int index1, int index2);
|
||||
|
||||
/**
|
||||
* @param pointIndex name of the internal section containing the specified point, or null if the component does not have internal sections.
|
||||
* @return
|
||||
*/
|
||||
String getSectionName(int pointIndex);
|
||||
|
||||
/**
|
||||
* Draws the component onto the {@link Graphics2D}.
|
||||
|
||||
@@ -48,7 +48,8 @@ public class Node implements Comparable<Node> {
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return component.getControlPointNodeName(pointIndex);
|
||||
String section = component.getSectionName(pointIndex);
|
||||
return (section == null ? "" : section + ".") + component.getControlPointNodeName(pointIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Binary file not shown.
@@ -2,5 +2,7 @@ package org.diylc.netlist;
|
||||
|
||||
public interface ISpiceMapper {
|
||||
|
||||
int mapToSpiceNode(int index);
|
||||
int mapToSpiceNode(int Index);
|
||||
|
||||
String getSectionName(int pointIndex);
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1657,28 +1657,44 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.swingUI = swingUI;
|
||||
putValue(AbstractAction.NAME, "Create DIYLC Netlist");
|
||||
putValue(AbstractAction.NAME, "Generate DIYLC Netlist");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Web.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
List<Netlist> res = plugInPort.extractNetlists();
|
||||
if (res == null) {
|
||||
swingUI.showMessage("The generated netlist is empty, nothing to show.", "DIYLC Netlist", ISwingUI.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("<html>");
|
||||
|
||||
for (Netlist netlist : res) {
|
||||
sb.append("<p style=\"font-family: " + new JLabel().getFont().getName() + "; font-size: 9px\"><b>Switch configuration: ").append(netlist.getSwitchSetup()).append("</b><br><br>Connected node groups:<br>");
|
||||
for (Group v : netlist.getSortedGroups()) {
|
||||
sb.append(" ").append(v.getSortedNodes()).append("<br>");
|
||||
swingUI.executeBackgroundTask(new ITask<List<Netlist>>() {
|
||||
|
||||
@Override
|
||||
public List<Netlist> doInBackground() throws Exception {
|
||||
return plugInPort.extractNetlists();
|
||||
}
|
||||
sb.append("</p><br><hr>");
|
||||
}
|
||||
sb.append("</html>");
|
||||
new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), "DIYLC Netlist", new Dimension(600, 480)).setVisible(true);
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Failed to generate the netlist: " + e.getMessage(), "DIYLC Netlist", ISwingUI.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(List<Netlist> res) {
|
||||
if (res == null) {
|
||||
swingUI.showMessage("The generated netlist is empty, nothing to show.", "DIYLC Netlist", ISwingUI.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("<html>");
|
||||
|
||||
for (Netlist netlist : res) {
|
||||
sb.append("<p style=\"font-family: " + new JLabel().getFont().getName() + "; font-size: 9px\"><b>Switch configuration: ").
|
||||
append(netlist.getSwitchSetup()).append("</b><br><br>Connected node groups:<br>");
|
||||
for (Group v : netlist.getSortedGroups()) {
|
||||
sb.append(" ").append(v.getSortedNodes()).append("<br>");
|
||||
}
|
||||
sb.append("</p><br><hr>");
|
||||
}
|
||||
sb.append("</html>");
|
||||
new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), "DIYLC Netlist", new Dimension(600, 480)).setVisible(true);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1701,45 +1717,53 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
List<Netlist> netlists = plugInPort.extractNetlists();
|
||||
if (netlists == null || netlists.isEmpty()) {
|
||||
swingUI.showMessage("The generated netlist is empty, nothing to show.", summarizer.getName(), ISwingUI.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
List<Summary> res = null;
|
||||
try {
|
||||
res = summarizer.summarize(netlists, null);
|
||||
} catch (Exception ex) {
|
||||
swingUI.showMessage(ex.getMessage(), summarizer.getName(), ISwingUI.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (res == null) {
|
||||
swingUI.showMessage("The generated summary is empty, nothing to show.", summarizer.getName(), ISwingUI.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("<html>");
|
||||
|
||||
for (Summary summary : res) {
|
||||
sb.append("<p style=\"font-family: ").
|
||||
append(summarizer.getFontName()).
|
||||
append("; font-size: 9px\">");
|
||||
|
||||
if (res.size() > 1)
|
||||
sb.append("<b>Switch configuration: ").
|
||||
append(summary.getNetlist().getSwitchSetup()).
|
||||
append("</b><br><br>");
|
||||
|
||||
sb.append(summary.getSummary());
|
||||
|
||||
sb.append("</p><br>");
|
||||
|
||||
if (res.size() > 1)
|
||||
sb.append("<hr>");
|
||||
}
|
||||
sb.append("</html>");
|
||||
new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), summarizer.getName(), new Dimension(600, 480)).setVisible(true);
|
||||
swingUI.executeBackgroundTask(new ITask<List<Summary>>() {
|
||||
|
||||
@Override
|
||||
public List<Summary> doInBackground() throws Exception {
|
||||
List<Netlist> netlists = plugInPort.extractNetlists();
|
||||
if (netlists == null || netlists.isEmpty()) {
|
||||
throw new Exception("The generated netlist is empty, nothing to show.");
|
||||
}
|
||||
|
||||
return summarizer.summarize(netlists, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage(e.getMessage(), summarizer.getName(), ISwingUI.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(List<Summary> res) {
|
||||
if (res == null) {
|
||||
swingUI.showMessage("The generated summary is empty, nothing to show.", summarizer.getName(), ISwingUI.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("<html>");
|
||||
|
||||
for (Summary summary : res) {
|
||||
sb.append("<p style=\"font-family: ").
|
||||
append(summarizer.getFontName()).
|
||||
append("; font-size: 9px\">");
|
||||
|
||||
if (res.size() > 1)
|
||||
sb.append("<b>Switch configuration: ").
|
||||
append(summary.getNetlist().getSwitchSetup()).
|
||||
append("</b><br><br>");
|
||||
|
||||
sb.append(summary.getSummary());
|
||||
|
||||
sb.append("</p><br>");
|
||||
|
||||
if (res.size() > 1)
|
||||
sb.append("<hr>");
|
||||
}
|
||||
sb.append("</html>");
|
||||
new TextDialog(swingUI.getOwnerFrame().getRootPane(), sb.toString(), summarizer.getName(), new Dimension(600, 480)).setVisible(true);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user