mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
netlist summarizer infrastructure added
This commit is contained in:
@@ -25,7 +25,24 @@ import java.util.List;
|
||||
|
||||
import org.diylc.netlist.Netlist;
|
||||
|
||||
/**
|
||||
* Interface for {@link Netlist} related operations.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public interface INetlistProcessor {
|
||||
|
||||
/**
|
||||
* Finds all {@link Netlist}s for each switch position combination.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Netlist> extractNetlists();
|
||||
|
||||
/**
|
||||
* Finds all available {@link INetlistSummarizer} implementations.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<INetlistSummarizer> getNetlistSummarizers();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.diylc.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.diylc.netlist.Netlist;
|
||||
import org.diylc.netlist.Node;
|
||||
import org.diylc.netlist.Summary;
|
||||
|
||||
public interface INetlistSummarizer {
|
||||
|
||||
/**
|
||||
* @return summarizer name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return name of the icon to use
|
||||
*/
|
||||
String getIconName();
|
||||
|
||||
/**
|
||||
* Summarizes all {@link Netlist}s provided.
|
||||
*
|
||||
* @param netlists
|
||||
* @param preferredOutput optional, needed only where there's more than one possible output node.
|
||||
* @return
|
||||
*/
|
||||
List<Summary> summarize(List<Netlist> netlists, Node preferredOutput);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
|
||||
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.List;
|
||||
|
||||
public class Summary {
|
||||
|
||||
private Netlist netlist;
|
||||
private List<String> notes;
|
||||
|
||||
public Summary(Netlist netlist, List<String> notes) {
|
||||
super();
|
||||
this.netlist = netlist;
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public Netlist getNetlist() {
|
||||
return netlist;
|
||||
}
|
||||
|
||||
public List<String> getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((netlist == null) ? 0 : netlist.hashCode());
|
||||
result = prime * result + ((notes == null) ? 0 : notes.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Summary other = (Summary) obj;
|
||||
if (netlist == null) {
|
||||
if (other.netlist != null)
|
||||
return false;
|
||||
} else if (!netlist.equals(other.netlist))
|
||||
return false;
|
||||
if (notes == null) {
|
||||
if (other.notes != null)
|
||||
return false;
|
||||
} else if (!notes.equals(other.notes))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return notes.toString();
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,7 @@ import org.diylc.common.EventType;
|
||||
import org.diylc.common.IComponentFiler;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.IKeyProcessor;
|
||||
import org.diylc.common.INetlistSummarizer;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
@@ -76,11 +77,11 @@ import org.diylc.core.Theme;
|
||||
import org.diylc.core.annotations.IAutoCreator;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.netlist.Group;
|
||||
import org.diylc.netlist.Netlist;
|
||||
import org.diylc.netlist.SwitchSetup;
|
||||
import org.diylc.netlist.Node;
|
||||
import org.diylc.netlist.Position;
|
||||
import org.diylc.netlist.Group;
|
||||
import org.diylc.netlist.SwitchSetup;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
@@ -2882,98 +2883,27 @@ public class Presenter implements IPlugInPort {
|
||||
if (s.arePointsConnected(i, j, position))
|
||||
connections.add(new Line2D.Double(c.getControlPoint(i), c.getControlPoint(j)));
|
||||
}
|
||||
}
|
||||
|
||||
// // grab continuity areas
|
||||
// List<Area> continuity = drawingManager.getContinuityAreas(currentProject);
|
||||
//
|
||||
// mergeConnections(connections, continuity);
|
||||
}
|
||||
|
||||
return connections;
|
||||
}
|
||||
}
|
||||
|
||||
// private void mergeConnections(List<Line2D> connections, List<Area> continuity) {
|
||||
// List<Line2D> merged = new ArrayList<Line2D>();
|
||||
// boolean[] visited = new boolean[connections.size()];
|
||||
// for (int i = 0; i < visited.length; i++)
|
||||
// visited[i] = false;
|
||||
//
|
||||
// double t = DrawingManager.CONTROL_POINT_SIZE;
|
||||
//
|
||||
// for (int i = 0; i < visited.length - 1; i++) {
|
||||
// if (visited[i])
|
||||
// continue;
|
||||
// for (int j = i + 1; j < visited.length; j++) {
|
||||
// if (visited[j])
|
||||
// continue;
|
||||
// Line2D c1 = connections.get(i);
|
||||
// Line2D c2 = connections.get(j);
|
||||
// Point2D p1 = null;
|
||||
// Point2D p2 = null;
|
||||
// boolean connected = false;
|
||||
// // test direct continuity between two connections
|
||||
// if (!connected && c1.getP1().distance(c2.getP1()) < t) {
|
||||
// connected = true;
|
||||
// p1 = c1.getP2();
|
||||
// p2 = c2.getP2();
|
||||
// }
|
||||
// if (!connected && c1.getP1().distance(c2.getP2()) < t) {
|
||||
// connected = true;
|
||||
// p1 = c1.getP2();
|
||||
// p2 = c2.getP1();
|
||||
// }
|
||||
// if (!connected && c1.getP2().distance(c2.getP1()) < t) {
|
||||
// connected = true;
|
||||
// p1 = c1.getP1();
|
||||
// p2 = c2.getP2();
|
||||
// }
|
||||
// if (!connected && c1.getP2().distance(c2.getP2()) < t) {
|
||||
// connected = true;
|
||||
// p1 = c1.getP1();
|
||||
// p2 = c2.getP1();
|
||||
// }
|
||||
// // if that failed, try using continuity areas
|
||||
// if (!connected) {
|
||||
// for (Area a : continuity) {
|
||||
// if (!connected && a.contains(c1.getP1()) && a.contains(c2.getP1())) {
|
||||
// connected = true;
|
||||
// p1 = c1.getP2();
|
||||
// p2 = c2.getP2();
|
||||
// break;
|
||||
// }
|
||||
// if (!connected && a.contains(c1.getP1()) && a.contains(c2.getP2())) {
|
||||
// connected = true;
|
||||
// p1 = c1.getP2();
|
||||
// p2 = c2.getP1();
|
||||
// break;
|
||||
// }
|
||||
// if (!connected && a.contains(c1.getP2()) && a.contains(c2.getP1())) {
|
||||
// connected = true;
|
||||
// p1 = c1.getP1();
|
||||
// p2 = c2.getP2();
|
||||
// break;
|
||||
// }
|
||||
// if (!connected && a.contains(c1.getP2()) && a.contains(c2.getP2())) {
|
||||
// connected = true;
|
||||
// p1 = c1.getP1();
|
||||
// p2 = c2.getP1();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (connected) {
|
||||
// visited[i] = visited[j] = true;
|
||||
// merged.add(new Line2D.Double(p1, p2));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // replace connections with merged
|
||||
// if (!merged.isEmpty()) {
|
||||
//// connections.clear();
|
||||
// connections.addAll(merged);
|
||||
// mergeConnections(connections, continuity); // attempt another round of merging if needed
|
||||
// }
|
||||
// }
|
||||
@Override
|
||||
public List<INetlistSummarizer> getNetlistSummarizers() {
|
||||
Set<Class<?>> classes;
|
||||
try {
|
||||
classes = Utils.getClasses("org.diylc.netlist");
|
||||
List<INetlistSummarizer> result = new ArrayList<INetlistSummarizer>();
|
||||
|
||||
for (Class<?> clazz : classes) {
|
||||
if (!Modifier.isAbstract(clazz.getModifiers()) && INetlistSummarizer.class.isAssignableFrom(clazz)) {
|
||||
result.add((INetlistSummarizer) clazz.newInstance());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not load INetlistSummarizer implementations", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user