mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
rename graph-related stuff into netlists
This commit is contained in:
+4
-4
@@ -24,10 +24,10 @@ package org.diylc.common;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.diylc.graph.Graph;
|
import org.diylc.netlist.Netlist;
|
||||||
import org.diylc.graph.GraphKey;
|
import org.diylc.netlist.SwitchSetup;
|
||||||
|
|
||||||
public interface IGraphProcessor {
|
public interface INetlistProcessor {
|
||||||
|
|
||||||
Map<Graph, List<GraphKey>> extractGraphs();
|
Map<Netlist, List<SwitchSetup>> extractNetlists();
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ import org.diylc.core.Theme;
|
|||||||
* @see EventType
|
* @see EventType
|
||||||
*/
|
*/
|
||||||
public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyProcessor, IVariantProcessor,
|
public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyProcessor, IVariantProcessor,
|
||||||
IBlockProcessor, IGraphProcessor {
|
IBlockProcessor, INetlistProcessor {
|
||||||
|
|
||||||
public static final String ANTI_ALIASING_KEY = "antiAliasing";
|
public static final String ANTI_ALIASING_KEY = "antiAliasing";
|
||||||
public static final String HI_QUALITY_RENDER_KEY = "hiQualityRender";
|
public static final String HI_QUALITY_RENDER_KEY = "hiQualityRender";
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
package org.diylc.graph;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class Graph {
|
|
||||||
|
|
||||||
private Set<Vertex> vertices = new HashSet<Vertex>();
|
|
||||||
|
|
||||||
public Graph() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Vertex> getVertices() {
|
|
||||||
return vertices;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean verticesMatch(Graph other) {
|
|
||||||
return this.vertices.equals(other.vertices);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((vertices == null) ? 0 : vertices.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;
|
|
||||||
Graph other = (Graph) obj;
|
|
||||||
if (vertices == null) {
|
|
||||||
if (other.vertices != null)
|
|
||||||
return false;
|
|
||||||
} else if (!vertices.equals(other.vertices))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (Vertex v : vertices) {
|
|
||||||
sb.append("\t").append(v).append("\n");
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package org.diylc.graph;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GraphKey {
|
|
||||||
|
|
||||||
private List<Position> positions;
|
|
||||||
|
|
||||||
public GraphKey(List<Position> positions) {
|
|
||||||
super();
|
|
||||||
this.positions = positions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Position> getPositions() {
|
|
||||||
return positions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((positions == null) ? 0 : positions.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;
|
|
||||||
GraphKey other = (GraphKey) obj;
|
|
||||||
if (positions == null) {
|
|
||||||
if (other.positions != null)
|
|
||||||
return false;
|
|
||||||
} else if (!positions.equals(other.positions))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (Position s : positions)
|
|
||||||
{
|
|
||||||
if (sb.length() > 0)
|
|
||||||
sb.append(":");
|
|
||||||
sb.append(s.toString());
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package org.diylc.graph;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class Vertex {
|
|
||||||
|
|
||||||
private Set<Node> nodes = new HashSet<Node>();
|
|
||||||
|
|
||||||
public Vertex(Node node1, Node node2) {
|
|
||||||
nodes.add(node1);
|
|
||||||
nodes.add(node2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Node getNode1() {
|
|
||||||
Iterator<Node> i = nodes.iterator();
|
|
||||||
return i.next();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Node getNode2() {
|
|
||||||
Iterator<Node> i = nodes.iterator();
|
|
||||||
i.next();
|
|
||||||
return i.next();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((nodes == null) ? 0 : nodes.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;
|
|
||||||
Vertex other = (Vertex) obj;
|
|
||||||
if (nodes == null) {
|
|
||||||
if (other.nodes != null)
|
|
||||||
return false;
|
|
||||||
} else if (!nodes.equals(other.nodes))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getNode1().toString() + " <-> " + getNode2().toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a group of {@link Node}s that are connected together.
|
||||||
|
*
|
||||||
|
* @author Branislav Stojkovic
|
||||||
|
*/
|
||||||
|
public class Group {
|
||||||
|
|
||||||
|
private Set<Node> nodes = new HashSet<Node>();
|
||||||
|
|
||||||
|
public Group(Node node1, Node node2) {
|
||||||
|
nodes.add(node1);
|
||||||
|
nodes.add(node2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Node> getNodes() {
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((nodes == null) ? 0 : nodes.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;
|
||||||
|
Group other = (Group) obj;
|
||||||
|
if (nodes == null) {
|
||||||
|
if (other.nodes != null)
|
||||||
|
return false;
|
||||||
|
} else if (!nodes.equals(other.nodes))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Node n : nodes) {
|
||||||
|
if (sb.length() > 0)
|
||||||
|
sb.append(" <-> ");
|
||||||
|
sb.append(n);
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
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.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Netlist {
|
||||||
|
|
||||||
|
private Set<Group> vertices = new HashSet<Group>();
|
||||||
|
|
||||||
|
public Netlist() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Group> getVertices() {
|
||||||
|
return vertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean verticesMatch(Netlist other) {
|
||||||
|
return this.vertices.equals(other.vertices);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((vertices == null) ? 0 : vertices.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;
|
||||||
|
Netlist other = (Netlist) obj;
|
||||||
|
if (vertices == null) {
|
||||||
|
if (other.vertices != null)
|
||||||
|
return false;
|
||||||
|
} else if (!vertices.equals(other.vertices))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Group v : vertices) {
|
||||||
|
sb.append("\t").append(v).append("\n");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
-2
@@ -1,8 +1,33 @@
|
|||||||
package org.diylc.graph;
|
/*
|
||||||
|
|
||||||
|
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 org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a single node in a {@link Netlist}, uniquely defined by a component and a control point.
|
||||||
|
*
|
||||||
|
* @author Branislav Stojkovic
|
||||||
|
*/
|
||||||
public class Node {
|
public class Node {
|
||||||
|
|
||||||
private IDIYComponent<?> component;
|
private IDIYComponent<?> component;
|
||||||
+27
-1
@@ -1,8 +1,34 @@
|
|||||||
package org.diylc.graph;
|
/*
|
||||||
|
|
||||||
|
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 org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.ISwitch;
|
import org.diylc.core.ISwitch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a single position of a switch, uniquely defined by the switch and the position.
|
||||||
|
*
|
||||||
|
* @author Branislav Stojkovic
|
||||||
|
*/
|
||||||
public class Position {
|
public class Position {
|
||||||
|
|
||||||
private ISwitch theSwitch;
|
private ISwitch theSwitch;
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a full switch configuration of the whole {@link Netlist}, containing one position of each switch in the {@link Netlist}.
|
||||||
|
*
|
||||||
|
* @author Branislav Stojkovic
|
||||||
|
*/
|
||||||
|
public class SwitchSetup {
|
||||||
|
|
||||||
|
private List<Position> positions;
|
||||||
|
|
||||||
|
public SwitchSetup(List<Position> positions) {
|
||||||
|
super();
|
||||||
|
this.positions = positions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Position> getPositions() {
|
||||||
|
return positions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((positions == null) ? 0 : positions.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;
|
||||||
|
SwitchSetup other = (SwitchSetup) obj;
|
||||||
|
if (positions == null) {
|
||||||
|
if (other.positions != null)
|
||||||
|
return false;
|
||||||
|
} else if (!positions.equals(other.positions))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Position s : positions)
|
||||||
|
{
|
||||||
|
if (sb.length() > 0)
|
||||||
|
sb.append(":");
|
||||||
|
sb.append(s.toString());
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -76,11 +76,11 @@ import org.diylc.core.Theme;
|
|||||||
import org.diylc.core.annotations.IAutoCreator;
|
import org.diylc.core.annotations.IAutoCreator;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
import org.diylc.graph.Graph;
|
import org.diylc.netlist.Netlist;
|
||||||
import org.diylc.graph.GraphKey;
|
import org.diylc.netlist.SwitchSetup;
|
||||||
import org.diylc.graph.Node;
|
import org.diylc.netlist.Node;
|
||||||
import org.diylc.graph.Position;
|
import org.diylc.netlist.Position;
|
||||||
import org.diylc.graph.Vertex;
|
import org.diylc.netlist.Group;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
import com.thoughtworks.xstream.XStream;
|
import com.thoughtworks.xstream.XStream;
|
||||||
@@ -2687,8 +2687,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public Map<Graph, List<GraphKey>> extractGraphs() {
|
public Map<Netlist, List<SwitchSetup>> extractNetlists() {
|
||||||
Map<Graph, List<GraphKey>> result = new HashMap<Graph, List<GraphKey>>();
|
Map<Netlist, List<SwitchSetup>> result = new HashMap<Netlist, List<SwitchSetup>>();
|
||||||
List<Node> nodes = new ArrayList<Node>();
|
List<Node> nodes = new ArrayList<Node>();
|
||||||
|
|
||||||
List<ISwitch> switches = new ArrayList<ISwitch>();
|
List<ISwitch> switches = new ArrayList<ISwitch>();
|
||||||
@@ -2752,14 +2752,14 @@ public class Presenter implements IPlugInPort {
|
|||||||
posList.add(new Position(switches.get(j), positions[j]));
|
posList.add(new Position(switches.get(j), positions[j]));
|
||||||
}
|
}
|
||||||
List<Line2D> connections = getConnections(switchPositions);
|
List<Line2D> connections = getConnections(switchPositions);
|
||||||
Graph graph = constructGraph(nodes, connections, continuity);
|
Netlist graph = constructGraph(nodes, connections, continuity);
|
||||||
|
|
||||||
// merge graphs that are effectivelly the same
|
// merge graphs that are effectivelly the same
|
||||||
if (result.containsKey(graph)) {
|
if (result.containsKey(graph)) {
|
||||||
result.get(graph).add(new GraphKey(posList));
|
result.get(graph).add(new SwitchSetup(posList));
|
||||||
} else {
|
} else {
|
||||||
List<GraphKey> list = new ArrayList<GraphKey>();
|
List<SwitchSetup> list = new ArrayList<SwitchSetup>();
|
||||||
list.add(new GraphKey(posList));
|
list.add(new SwitchSetup(posList));
|
||||||
result.put(graph, list);
|
result.put(graph, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2781,8 +2781,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Graph constructGraph(List<Node> nodes, List<Line2D> connections, List<Area> continuityAreas) {
|
private Netlist constructGraph(List<Node> nodes, List<Line2D> connections, List<Area> continuityAreas) {
|
||||||
Graph graph = new Graph();
|
Netlist graph = new Netlist();
|
||||||
|
|
||||||
// StringBuilder sb = new StringBuilder();
|
// StringBuilder sb = new StringBuilder();
|
||||||
// sb.append("Nodes:").append("\n");
|
// sb.append("Nodes:").append("\n");
|
||||||
@@ -2807,7 +2807,18 @@ public class Presenter implements IPlugInPort {
|
|||||||
if (point1.distance(point2) < t ||
|
if (point1.distance(point2) < t ||
|
||||||
checkGraphConnection(point1, point2, connections, continuityAreas, new boolean[connections.size()]) ||
|
checkGraphConnection(point1, point2, connections, continuityAreas, new boolean[connections.size()]) ||
|
||||||
checkGraphConnection(point2, point1, connections, continuityAreas, new boolean[connections.size()])) {
|
checkGraphConnection(point2, point1, connections, continuityAreas, new boolean[connections.size()])) {
|
||||||
graph.getVertices().add(new Vertex(node1, node2));
|
boolean added = false;
|
||||||
|
// add to an existing vertex if possible
|
||||||
|
for (Group v :graph.getVertices())
|
||||||
|
if (v.getNodes().contains(node1)) {
|
||||||
|
v.getNodes().add(node2);
|
||||||
|
added = true;
|
||||||
|
} else if (v.getNodes().contains(node2)) {
|
||||||
|
v.getNodes().add(node1);
|
||||||
|
added = true;
|
||||||
|
}
|
||||||
|
if (!added)
|
||||||
|
graph.getVertices().add(new Group(node1, node2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user