mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
ground work for graph analysis
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
package org.diylc.graph;
|
||||||
|
|
||||||
|
import java.util.Dictionary;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Graph {
|
||||||
|
|
||||||
|
private Dictionary<String, Position> positions;
|
||||||
|
private Set<Node> nodes;
|
||||||
|
|
||||||
|
public Graph() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<String, Position> getPositions() {
|
||||||
|
return positions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Node> getNodes() {
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean nodesMatch(Graph other) {
|
||||||
|
return this.nodes.equals(other.nodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package org.diylc.graph;
|
||||||
|
|
||||||
|
|
||||||
|
public class Node {
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
private String component;
|
||||||
|
private String terminal;
|
||||||
|
|
||||||
|
public Node() {}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComponent() {
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTerminal() {
|
||||||
|
return terminal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((component == null) ? 0 : component.hashCode());
|
||||||
|
result = prime * result + ((terminal == null) ? 0 : terminal.hashCode());
|
||||||
|
result = prime * result + ((type == null) ? 0 : type.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;
|
||||||
|
Node other = (Node) obj;
|
||||||
|
if (component == null) {
|
||||||
|
if (other.component != null)
|
||||||
|
return false;
|
||||||
|
} else if (!component.equals(other.component))
|
||||||
|
return false;
|
||||||
|
if (terminal == null) {
|
||||||
|
if (other.terminal != null)
|
||||||
|
return false;
|
||||||
|
} else if (!terminal.equals(other.terminal))
|
||||||
|
return false;
|
||||||
|
if (type == null) {
|
||||||
|
if (other.type != null)
|
||||||
|
return false;
|
||||||
|
} else if (!type.equals(other.type))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return type + "." + component + "." + terminal;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package org.diylc.graph;
|
||||||
|
|
||||||
|
public class Position {
|
||||||
|
|
||||||
|
private String ownerType;
|
||||||
|
private String owner;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Position() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwnerType() {
|
||||||
|
return ownerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
|
||||||
|
result = prime * result + ((ownerType == null) ? 0 : ownerType.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;
|
||||||
|
Position other = (Position) obj;
|
||||||
|
if (name == null) {
|
||||||
|
if (other.name != null)
|
||||||
|
return false;
|
||||||
|
} else if (!name.equals(other.name))
|
||||||
|
return false;
|
||||||
|
if (owner == null) {
|
||||||
|
if (other.owner != null)
|
||||||
|
return false;
|
||||||
|
} else if (!owner.equals(other.owner))
|
||||||
|
return false;
|
||||||
|
if (ownerType == null) {
|
||||||
|
if (other.ownerType != null)
|
||||||
|
return false;
|
||||||
|
} else if (!ownerType.equals(other.ownerType))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return ownerType + "." + owner + "." + name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package org.diylc.graph;
|
||||||
|
|
||||||
|
public class Vertex {
|
||||||
|
|
||||||
|
private Node node1;
|
||||||
|
private Node node2;
|
||||||
|
|
||||||
|
public Vertex() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node getNode1() {
|
||||||
|
return node1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node getNode2() {
|
||||||
|
return node2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((node1 == null) ? 0 : node1.hashCode());
|
||||||
|
result = prime * result + ((node2 == null) ? 0 : node2.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 (node1 == null) {
|
||||||
|
if (other.node1 != null)
|
||||||
|
return false;
|
||||||
|
} else if (!node1.equals(other.node1))
|
||||||
|
return false;
|
||||||
|
if (node2 == null) {
|
||||||
|
if (other.node2 != null)
|
||||||
|
return false;
|
||||||
|
} else if (!node2.equals(other.node2))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return node1.toString() + " -> " + node2.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user