|
@@ -68,8 +68,10 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
*/
|
|
|
public static LayeredGraphNode convertToLayeredGraph(ElkNode n) {
|
|
|
LayeredNode ln = new LayeredNode(n, null);
|
|
|
+
|
|
|
for (ElkNode node : n.getChildren())
|
|
|
ln.addNode(convertToLayeredGraph(node));
|
|
|
+
|
|
|
for (ElkEdge edge : n.getContainedEdges()) {
|
|
|
|
|
|
ArrayList<LayeredGraphNode> sources = new ArrayList<>();
|
|
@@ -146,6 +148,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
* @param layout the layout
|
|
|
*/
|
|
|
public void setView(NodeView view, LayoutType layout) {
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER)
|
|
|
this.layouts[0].view = view;
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER)
|
|
@@ -165,6 +168,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
* @return the view
|
|
|
*/
|
|
|
public NodeView getView(LayoutType layout) {
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER)
|
|
|
return layouts[0].view;
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER)
|
|
@@ -190,6 +194,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void setShift(double shift, LayoutType layout) {
|
|
|
+
|
|
|
if (layout == null) {
|
|
|
this.layouts[0].shift = shift;
|
|
|
this.layouts[1].shift = shift;
|
|
@@ -208,6 +213,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public double getShift(LayoutType layout) {
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER)
|
|
|
return this.layouts[0].shift;
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER)
|
|
@@ -221,6 +227,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void setSink(LayeredGraphNode sink, LayoutType layout) {
|
|
|
+
|
|
|
if (layout == null) {
|
|
|
this.layouts[0].sink = sink;
|
|
|
this.layouts[1].sink = sink;
|
|
@@ -239,6 +246,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public LayeredGraphNode getSink(LayoutType layout) {
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER)
|
|
|
return this.layouts[0].sink;
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER)
|
|
@@ -252,6 +260,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public boolean isXUndefined(LayoutType layout) {
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER)
|
|
|
return this.layouts[0].xUndef;
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER)
|
|
@@ -265,6 +274,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void setAlign(LayeredGraphNode align, LayoutType layout) {
|
|
|
+
|
|
|
if (layout == null) {
|
|
|
this.layouts[0].align = align;
|
|
|
this.layouts[1].align = align;
|
|
@@ -283,6 +293,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public LayeredGraphNode getAlign(LayoutType layout) {
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER)
|
|
|
return this.layouts[0].align;
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER)
|
|
@@ -296,6 +307,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void setRoot(LayeredGraphNode root, LayoutType layout) {
|
|
|
+
|
|
|
if (layout == null) {
|
|
|
this.layouts[0].root = root;
|
|
|
this.layouts[1].root = root;
|
|
@@ -314,6 +326,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public LayeredGraphNode getRoot(LayoutType layout) {
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER)
|
|
|
return this.layouts[0].root;
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER)
|
|
@@ -327,6 +340,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void setSelected(LayoutType layout) {
|
|
|
+
|
|
|
if (layout == null) {
|
|
|
this.layouts[0].selected = true;
|
|
|
this.layouts[1].selected = true;
|
|
@@ -348,6 +362,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void unselectGraph() {
|
|
|
+
|
|
|
for (LayeredGraphNode n : nodes) {
|
|
|
n.unselectGraph();
|
|
|
}
|
|
@@ -360,6 +375,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public boolean isSelected(LayoutType layout) {
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER) {
|
|
|
return layouts[0].selected;
|
|
|
}
|
|
@@ -381,6 +397,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
@Override
|
|
|
public void setColor( Color c, LayoutType layout )
|
|
|
{
|
|
|
+
|
|
|
if( layout == null )
|
|
|
{
|
|
|
this.layouts[ 0 ].color = c;
|
|
@@ -411,30 +428,39 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public Color getClassColor(LayoutType layout) {
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER && this.layouts[0].sink == this && calcClassSize(this, layout) == 1)
|
|
|
return Color.LIGHT_GRAY;
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER && this.layouts[0].sink == this)
|
|
|
return this.layouts[0].color;
|
|
|
else if (layout == LayoutType.LEFTMOST_UPPER)
|
|
|
return this.layouts[0].sink.getClassColor(layout);
|
|
|
+
|
|
|
+
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER && this.layouts[1].sink == this && calcClassSize(this, layout) == 1)
|
|
|
return Color.LIGHT_GRAY;
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER && this.layouts[1].sink == this)
|
|
|
return this.layouts[1].color;
|
|
|
else if (layout == LayoutType.RIGHTMOST_UPPER)
|
|
|
return this.layouts[1].sink.getClassColor(layout);
|
|
|
+
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_LOWER && this.layouts[2].sink == this && calcClassSize(this, layout) == 1)
|
|
|
return Color.LIGHT_GRAY;
|
|
|
if (layout == LayoutType.LEFTMOST_LOWER && this.layouts[2].sink == this)
|
|
|
return this.layouts[2].color;
|
|
|
else if (layout == LayoutType.LEFTMOST_LOWER)
|
|
|
return this.layouts[2].sink.getClassColor(layout);
|
|
|
+
|
|
|
+
|
|
|
if (layout == LayoutType.RIGHTMOST_LOWER && this.layouts[3].sink == this && calcClassSize(this, layout) == 1)
|
|
|
return Color.LIGHT_GRAY;
|
|
|
if( layout == LayoutType.RIGHTMOST_LOWER && this.layouts[ 3 ].sink == this )
|
|
|
return this.layouts[ 3 ].color;
|
|
|
else if( layout == LayoutType.RIGHTMOST_LOWER )
|
|
|
return this.layouts[ 3 ].sink.getClassColor( layout );
|
|
|
+
|
|
|
+
|
|
|
if( layout == LayoutType.COMBINED )
|
|
|
return Color.LIGHT_GRAY;
|
|
|
return null;
|
|
@@ -443,6 +469,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
@Override
|
|
|
public Color getColor( LayoutType layout )
|
|
|
{
|
|
|
+
|
|
|
if( layout == null )
|
|
|
return this.layouts[ 0 ].color;
|
|
|
if( layout == LayoutType.LEFTMOST_UPPER && this.layouts[ 0 ].root == this && this.layouts[ 0 ].align == this )
|
|
@@ -451,12 +478,16 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
return this.layouts[0].root.getColor(layout);
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER)
|
|
|
return this.layouts[0].color;
|
|
|
+
|
|
|
+
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER && this.layouts[1].root == this && this.layouts[1].align == this)
|
|
|
return Color.LIGHT_GRAY;
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER && this.layouts[1].root != this)
|
|
|
return this.layouts[1].root.getColor(layout);
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER)
|
|
|
return this.layouts[1].color;
|
|
|
+
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_LOWER && this.layouts[2].root == this && this.layouts[2].align == this)
|
|
|
return Color.LIGHT_GRAY;
|
|
|
if (layout == LayoutType.LEFTMOST_LOWER && this.layouts[2].root != this)
|
|
@@ -465,10 +496,14 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
return this.layouts[2].color;
|
|
|
if (layout == LayoutType.RIGHTMOST_LOWER && this.layouts[3].root == this && this.layouts[3].align == this)
|
|
|
return Color.LIGHT_GRAY;
|
|
|
+
|
|
|
+
|
|
|
if( layout == LayoutType.RIGHTMOST_LOWER && this.layouts[ 3 ].root != this )
|
|
|
return this.layouts[ 3 ].root.getColor( layout );
|
|
|
if( layout == LayoutType.RIGHTMOST_LOWER )
|
|
|
return this.layouts[ 3 ].color;
|
|
|
+
|
|
|
+
|
|
|
if( layout == LayoutType.COMBINED )
|
|
|
return Color.LIGHT_GRAY;
|
|
|
return null;
|
|
@@ -506,6 +541,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void setX(double x, boolean def, LayoutType layout) {
|
|
|
+
|
|
|
if (layout == null) {
|
|
|
layouts[0].x = x;
|
|
|
layouts[1].x = x;
|
|
@@ -535,6 +571,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void setY(double y, LayoutType layout) {
|
|
|
+
|
|
|
if (layout == null) {
|
|
|
layouts[0].y = y;
|
|
|
layouts[1].y = y;
|
|
@@ -556,6 +593,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public double getX(LayoutType layout) {
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER)
|
|
|
return this.layouts[0].x;
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER)
|
|
@@ -571,6 +609,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public double getY(LayoutType layout) {
|
|
|
+
|
|
|
if (layout == LayoutType.LEFTMOST_UPPER)
|
|
|
return this.layouts[0].y;
|
|
|
if (layout == LayoutType.RIGHTMOST_UPPER)
|
|
@@ -589,6 +628,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
if (nodes.size() > 0) {
|
|
|
double max = 0;
|
|
|
double min = Double.POSITIVE_INFINITY;
|
|
|
+
|
|
|
for( LayeredGraphNode n : nodes )
|
|
|
{
|
|
|
if( max < n.getX(layout) + n.getWidth(layout) )
|
|
@@ -624,6 +664,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
if( nodes.size() > 0 )
|
|
|
{
|
|
|
double max = 0;
|
|
|
+
|
|
|
for( LayeredGraphNode n : nodes )
|
|
|
{
|
|
|
if( max < n.getY(layout) + n.getHeight(layout) )
|
|
@@ -655,6 +696,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void setWidth(double w, LayoutType layout) {
|
|
|
+
|
|
|
if (layout == null) {
|
|
|
this.layouts[0].w = w;
|
|
|
this.layouts[1].w = w;
|
|
@@ -676,6 +718,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void setHeight(double h, LayoutType layout) {
|
|
|
+
|
|
|
if (layout == null) {
|
|
|
this.layouts[0].h = h;
|
|
|
this.layouts[1].h = h;
|
|
@@ -702,11 +745,14 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void removeNode(LayeredGraphNode n) {
|
|
|
+
|
|
|
for (LayeredGraphEdge e : n.getIncomingEdges())
|
|
|
e.remove();
|
|
|
for (LayeredGraphEdge e : n.getOutgoingEdges())
|
|
|
e.remove();
|
|
|
+
|
|
|
nodes.remove(n);
|
|
|
+
|
|
|
for (ArrayList<LayeredGraphNode> l : layers) {
|
|
|
l.remove(n);
|
|
|
}
|
|
@@ -714,18 +760,24 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public void setNodeLayer(LayeredGraphNode n, int index) {
|
|
|
+
|
|
|
while (index >= layers.size())
|
|
|
layers.add(new ArrayList<>());
|
|
|
+
|
|
|
int old = n.getLayer();
|
|
|
if (old >= 0)
|
|
|
layers.get(old).remove(n);
|
|
|
+
|
|
|
layers.get(index).add(n);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void setOrderedLayer(ArrayList<Double> indizes, int layerIndex) {
|
|
|
+
|
|
|
ArrayList<LayeredGraphNode> l2 = layers.get(layerIndex);
|
|
|
ArrayList<LayeredGraphNode> result = new ArrayList<LayeredGraphNode>();
|
|
|
+
|
|
|
+
|
|
|
while (indizes.size() > 0) {
|
|
|
int mIndex = 0;
|
|
|
double min = indizes.get(0);
|
|
@@ -799,7 +851,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
public ArrayList<LayeredGraphEdge> getOutgoingEdges(LayeredGraphNode n) {
|
|
|
ArrayList<LayeredGraphEdge> result = new ArrayList<>();
|
|
|
for( LayeredGraphEdge e : edges )
|
|
|
- {
|
|
|
+ {
|
|
|
if( e.getSources().contains( n ) && !result.contains( e ) )
|
|
|
result.add( e );
|
|
|
}
|
|
@@ -810,7 +862,7 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
public ArrayList<LayeredGraphEdge> getIncomingEdges(LayeredGraphNode n) {
|
|
|
ArrayList<LayeredGraphEdge> result = new ArrayList<>();
|
|
|
for( LayeredGraphEdge e : edges )
|
|
|
- {
|
|
|
+ {
|
|
|
if( e.getTargets().contains( n ) && !result.contains( e ) )
|
|
|
result.add( e );
|
|
|
}
|
|
@@ -819,10 +871,13 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public ArrayList<LayeredGraphEdge> getSortedOutgoingEdges(LayeredGraphNode n) {
|
|
|
+
|
|
|
ArrayList<LayeredGraphEdge> result = new ArrayList<>();
|
|
|
if( n.getLayer() + 1 >= layers.size() )
|
|
|
return result;
|
|
|
ArrayList< LayeredGraphEdge > unsorted = getOutgoingEdges( n );
|
|
|
+
|
|
|
+
|
|
|
for( LayeredGraphNode node : layers.get( n.getLayer() + 1 ) )
|
|
|
{
|
|
|
for( LayeredGraphEdge e : unsorted )
|
|
@@ -836,9 +891,12 @@ public class LayeredNode implements LayeredGraphNode {
|
|
|
|
|
|
@Override
|
|
|
public ArrayList<LayeredGraphEdge> getSortedIncomingEdges(LayeredGraphNode n) {
|
|
|
+
|
|
|
ArrayList<LayeredGraphEdge> result = new ArrayList<>();
|
|
|
if( n.getLayer() - 1 < 0 )
|
|
|
return result;
|
|
|
+
|
|
|
+
|
|
|
ArrayList< LayeredGraphEdge > unsorted = getIncomingEdges( n );
|
|
|
for( LayeredGraphNode node : layers.get( n.getLayer() - 1 ) )
|
|
|
{
|