You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ge...@apache.org on 2021/03/29 20:14:36 UTC
[netbeans] branch master updated: [NETBEANS-3561] Corrected
compiler warnings in Visual Library API project
This is an automated email from the ASF dual-hosted git repository.
geertjan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 7b4c8f9 [NETBEANS-3561] Corrected compiler warnings in Visual Library API project
new ea79d97 Merge pull request #1758 from mklaehn/NETBEANS-3561
7b4c8f9 is described below
commit 7b4c8f998917cf5af1e1c69d0ea398d62fc08a6f
Author: Martin Klähn <mk...@apache.org>
AuthorDate: Sat Dec 7 22:35:44 2019 +0100
[NETBEANS-3561] Corrected compiler warnings in Visual Library API project
---
platform/api.visual/nbproject/project.properties | 2 +-
.../netbeans/api/visual/border/BorderFactory.java | 1 +
.../api/visual/graph/layout/GraphLayout.java | 2 +-
.../visual/graph/layout/GraphLayoutFactory.java | 10 +-
.../api/visual/graph/layout/TreeGraphLayout.java | 6 +-
.../netbeans/api/visual/layout/LayoutFactory.java | 5 +
.../org/netbeans/api/visual/model/ObjectScene.java | 3 +-
.../netbeans/api/visual/print/ScenePrinter.java | 4 +-
.../netbeans/api/visual/widget/ResourceTable.java | 10 +-
.../api/visual/widget/general/ListItemWidget.java | 1 +
.../api/visual/widget/general/ListWidget.java | 1 +
.../action/CycleObjectSceneFocusProvider.java | 8 +-
.../modules/visual/export/Scene2Image.java | 8 +-
.../visual/graph/layout/HierarchicalLayout.java | 19 +-
.../visual/graph/layout/OrthogonalLayout.java | 30 +--
.../visual/graph/layout/TreeGraphLayout.java | 4 +-
.../BarycenterCrossingMinimizer.java | 26 +-
.../BarycenterXCoordinateAssigner.java | 29 ++-
.../layout/hierarchicalsupport/DirectedGraph.java | 201 ++++++++--------
.../EdgeReversingCycleRemover.java | 2 +-
.../layout/hierarchicalsupport/LayeredGraph.java | 64 ++---
.../layout/hierarchicalsupport/MixedGraph.java | 60 ++---
.../VertexInsertionLayerAssigner.java | 24 +-
.../layout/orthogonalsupport/DirectionalGraph.java | 197 ++++++++-------
.../graph/layout/orthogonalsupport/DualGraph.java | 62 ++---
.../orthogonalsupport/EmbeddedPlanarGraph.java | 14 +-
.../graph/layout/orthogonalsupport/Face.java | 169 +++++++------
.../layout/orthogonalsupport/FlowNetwork.java | 192 +++++++--------
.../layout/orthogonalsupport/GTPlanarizer.java | 268 ++++++++++-----------
.../graph/layout/orthogonalsupport/MGraph.java | 175 +++++++-------
.../MinimumBendOrthogonalizer.java | 93 +++----
.../OrthogonalRepresentation.java | 33 ++-
.../orthogonalsupport/RectangularCompactor.java | 121 +++++-----
33 files changed, 912 insertions(+), 932 deletions(-)
diff --git a/platform/api.visual/nbproject/project.properties b/platform/api.visual/nbproject/project.properties
index 26d72a5..0e80cc7 100644
--- a/platform/api.visual/nbproject/project.properties
+++ b/platform/api.visual/nbproject/project.properties
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-javac.compilerargs=-Xlint:unchecked
+javac.compilerargs=-Xlint:all -Xlint:-serial
javac.source=1.8
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml
diff --git a/platform/api.visual/src/org/netbeans/api/visual/border/BorderFactory.java b/platform/api.visual/src/org/netbeans/api/visual/border/BorderFactory.java
index dc1c3bb..27f8b7e 100644
--- a/platform/api.visual/src/org/netbeans/api/visual/border/BorderFactory.java
+++ b/platform/api.visual/src/org/netbeans/api/visual/border/BorderFactory.java
@@ -631,6 +631,7 @@ public final class BorderFactory {
* @return the fancy dashed border
* @deprecated use createDashedBorder (color, width, height, true) method instead
*/
+ @Deprecated
public static Border createFancyDashedBorder (Color color, int width, int height) {
GeomUtil.LOG.warning ("BorderFactory.createFancyDashedBorder() method is deprecated. Use BorderFactory.createDashedBorder(color,width,height,true) method instead."); // NOI18N
return new FancyDashedBorder (color != null ? color : (new DefaultLookFeel()).getForeground()/*Color.BLACK*/, width, height);
diff --git a/platform/api.visual/src/org/netbeans/api/visual/graph/layout/GraphLayout.java b/platform/api.visual/src/org/netbeans/api/visual/graph/layout/GraphLayout.java
index b75a747..c1be6ad 100644
--- a/platform/api.visual/src/org/netbeans/api/visual/graph/layout/GraphLayout.java
+++ b/platform/api.visual/src/org/netbeans/api/visual/graph/layout/GraphLayout.java
@@ -99,7 +99,7 @@ public abstract class GraphLayout<N,E> {
listener.graphLayoutFinished (graph);
}
- @SuppressWarnings ("unchecked")
+ @SuppressWarnings({"unchecked", "rawtypes"})
private <N,E> GraphLayoutListener<N,E>[] createListenersCopy () {
GraphLayoutListener<N,E>[] listeners;
synchronized (this.listeners) {
diff --git a/platform/api.visual/src/org/netbeans/api/visual/graph/layout/GraphLayoutFactory.java b/platform/api.visual/src/org/netbeans/api/visual/graph/layout/GraphLayoutFactory.java
index d289fb6..9ff24f0 100644
--- a/platform/api.visual/src/org/netbeans/api/visual/graph/layout/GraphLayoutFactory.java
+++ b/platform/api.visual/src/org/netbeans/api/visual/graph/layout/GraphLayoutFactory.java
@@ -82,7 +82,7 @@ public class GraphLayoutFactory {
* @since 2.25
*/
public static <N, E> GraphLayout<N, E> createTreeGraphLayout(int originX, int originY, int verticalGap, int horizontalGap, boolean vertical, boolean minimizeGap, TreeGraphLayoutAlignment alignment) {
- return new TreeGraphLayout<N, E>(originX, originY, verticalGap, horizontalGap, vertical, minimizeGap, alignment);
+ return new TreeGraphLayout<>(originX, originY, verticalGap, horizontalGap, vertical, minimizeGap, alignment);
}
/**
@@ -95,7 +95,7 @@ public class GraphLayoutFactory {
* @return a GraphLayout to be invoked from the calling class.
*/
public static <N, E> GraphLayout<N, E> createOrthogonalGraphLayout(GraphScene<N, E> graphScene, boolean animate) {
- return new OrthogonalLayout(graphScene, animate);
+ return new OrthogonalLayout<>(graphScene, animate);
}
/**
@@ -108,7 +108,7 @@ public class GraphLayoutFactory {
* @return a GraphLayout to be invoked from the calling class.
*/
public static <N, E> GraphLayout<N, E> createHierarchicalGraphLayout(GraphScene<N, E> graphScene, boolean animate) {
- return new HierarchicalLayout(graphScene, animate);
+ return new HierarchicalLayout<>(graphScene, animate);
}
/**
@@ -123,7 +123,7 @@ public class GraphLayoutFactory {
* @return a GraphLayout to be invoked from the calling class.
*/
public static <N, E> GraphLayout<N, E> createHierarchicalGraphLayout(GraphScene<N, E> graphScene, boolean animate, boolean inverted) {
- return new HierarchicalLayout(graphScene, animate, inverted);
+ return new HierarchicalLayout<>(graphScene, animate, inverted);
}
/**
@@ -141,7 +141,7 @@ public class GraphLayoutFactory {
*/
public static <N, E> GraphLayout<N, E> createHierarchicalGraphLayout(GraphScene<N, E> graphScene, boolean animate, boolean inverted,
int xOffset, int layerOffset) {
- return new HierarchicalLayout(graphScene, animate, inverted, xOffset, layerOffset);
+ return new HierarchicalLayout<>(graphScene, animate, inverted, xOffset, layerOffset);
}
diff --git a/platform/api.visual/src/org/netbeans/api/visual/graph/layout/TreeGraphLayout.java b/platform/api.visual/src/org/netbeans/api/visual/graph/layout/TreeGraphLayout.java
index 7015b51..8461c89 100644
--- a/platform/api.visual/src/org/netbeans/api/visual/graph/layout/TreeGraphLayout.java
+++ b/platform/api.visual/src/org/netbeans/api/visual/graph/layout/TreeGraphLayout.java
@@ -29,7 +29,7 @@ import java.util.*;
*
* @author David Kaspar
*/
-public class TreeGraphLayout<N, E> extends GraphLayout {
+public class TreeGraphLayout<N, E> extends GraphLayout<N, E> {
private GraphScene<N, E> scene;
private int originX;
@@ -180,7 +180,7 @@ public class TreeGraphLayout<N, E> extends GraphLayout {
}
@Override
- protected void performGraphLayout(UniversalGraph graph) {
+ protected void performGraphLayout(UniversalGraph<N, E> graph) {
Collection<N> allNodes = scene.getNodes ();
ArrayList<N> rootNodes = new ArrayList<N>() ;
for (N node: allNodes) {
@@ -196,7 +196,7 @@ public class TreeGraphLayout<N, E> extends GraphLayout {
}
@Override
- protected void performNodesLayout(UniversalGraph graph, Collection nodes) {
+ protected void performNodesLayout(UniversalGraph<N,E> graph, Collection<N> nodes) {
throw new UnsupportedOperationException("Not supported yet.");
}
diff --git a/platform/api.visual/src/org/netbeans/api/visual/layout/LayoutFactory.java b/platform/api.visual/src/org/netbeans/api/visual/layout/LayoutFactory.java
index 47711ef..b808813 100644
--- a/platform/api.visual/src/org/netbeans/api/visual/layout/LayoutFactory.java
+++ b/platform/api.visual/src/org/netbeans/api/visual/layout/LayoutFactory.java
@@ -86,6 +86,7 @@ public final class LayoutFactory {
* @return the vertical flow layout
* @deprecated use createVerticalFlowLayout method instead
*/
+ @Deprecated
public static Layout createVerticalLayout () {
GeomUtil.LOG.warning ("LayoutFactory.createVerticalLayout() method is deprecated. Use LayoutFactory.createVerticalFlowLayout() method instead."); // NOI18N
return createVerticalFlowLayout (null, 0);
@@ -101,6 +102,7 @@ public final class LayoutFactory {
* @return the vertical flow layout
* @deprecated use createVerticalFlowLayout (alignment, gap) method instead
*/
+ @Deprecated
public static Layout createVerticalLayout (SerialAlignment alignment, int gap) {
GeomUtil.LOG.warning ("LayoutFactory.createVerticalLayout(alignment,gap) method is deprecated. Use LayoutFactory.createVerticalFlowLayout(alignment,gap) method instead."); // NOI18N
return new FlowLayout (true, alignment != null ? alignment : SerialAlignment.JUSTIFY, gap);
@@ -138,6 +140,7 @@ public final class LayoutFactory {
* @return the horizontal flow layout
* @deprecated use createHorizontalFlowLayout method instead
*/
+ @Deprecated
public static Layout createHorizontalLayout () {
GeomUtil.LOG.warning ("LayoutFactory.createHorizontalLayout() method is deprecated. Use LayoutFactory.createHorizontalFlowLayout() method instead."); // NOI18N
return createHorizontalFlowLayout (null, 0);
@@ -153,6 +156,7 @@ public final class LayoutFactory {
* @return the horizontal flow layout
* @deprecated use createHorizontalFlowLayout (alignment, gap) method instead
*/
+ @Deprecated
public static Layout createHorizontalLayout (SerialAlignment alignment, int gap) {
GeomUtil.LOG.warning ("LayoutFactory.createHorizontalLayout(alignment,gap) method is deprecated. Use LayoutFactory.createHorizontalFlowLayout(alignment,gap) method instead."); // NOI18N
return new FlowLayout (false, alignment != null ? alignment : SerialAlignment.JUSTIFY, gap);
@@ -222,6 +226,7 @@ public final class LayoutFactory {
* @return the fill layout
* @deprecated use createOverlayLayout method instead
*/
+ @Deprecated
public static Layout createFillLayout () {
GeomUtil.LOG.warning ("LayoutFactory.createFillLayout() method is deprecated. Use LayoutFactory.createOverlayLayout() method instead."); // NOI18N
return createOverlayLayout ();
diff --git a/platform/api.visual/src/org/netbeans/api/visual/model/ObjectScene.java b/platform/api.visual/src/org/netbeans/api/visual/model/ObjectScene.java
index 5ce5116..25afe0b 100644
--- a/platform/api.visual/src/org/netbeans/api/visual/model/ObjectScene.java
+++ b/platform/api.visual/src/org/netbeans/api/visual/model/ObjectScene.java
@@ -509,7 +509,8 @@ public class ObjectScene extends Scene {
* @param object the object
* @return the identity code of the object; null, if the object is null
*/
- public Comparable getIdentityCode (Object object) {
+ @SuppressWarnings("rawtypes")
+ public Comparable getIdentityCode(Object object) {
return object != null ? System.identityHashCode (object) : null;
}
diff --git a/platform/api.visual/src/org/netbeans/api/visual/print/ScenePrinter.java b/platform/api.visual/src/org/netbeans/api/visual/print/ScenePrinter.java
index 9876483..b0225f0 100644
--- a/platform/api.visual/src/org/netbeans/api/visual/print/ScenePrinter.java
+++ b/platform/api.visual/src/org/netbeans/api/visual/print/ScenePrinter.java
@@ -167,9 +167,9 @@ public final class ScenePrinter {
if (scene instanceof ObjectScene) {
ObjectScene gScene = (ObjectScene) scene;
// hide unselected widget
- HashSet<Object> invisible = new HashSet<Object>();
+ HashSet<Object> invisible = new HashSet<>();
invisible.addAll(gScene.getObjects());
- Set selectedObjects = gScene.getSelectedObjects();
+ Set<?> selectedObjects = gScene.getSelectedObjects();
invisible.removeAll(selectedObjects);
for (Object o : invisible) {
diff --git a/platform/api.visual/src/org/netbeans/api/visual/widget/ResourceTable.java b/platform/api.visual/src/org/netbeans/api/visual/widget/ResourceTable.java
index 1adac65..64c020b 100644
--- a/platform/api.visual/src/org/netbeans/api/visual/widget/ResourceTable.java
+++ b/platform/api.visual/src/org/netbeans/api/visual/widget/ResourceTable.java
@@ -329,9 +329,8 @@ public class ResourceTable
// return (Set<String>)Collections.unmodifiableSet(fontProperties.keySet());
// }
- public Set<String> getLocalPropertyNames()
- {
- return (Set<String>)Collections.unmodifiableSet(properties.keySet());
+ public Set<String> getLocalPropertyNames() {
+ return Collections.unmodifiableSet(properties.keySet());
}
////////////////////////////////////////////////////////////////////////////
@@ -352,12 +351,11 @@ public class ResourceTable
{
PropertyChangeListenerProxy proxy = (PropertyChangeListenerProxy) listener;
addPropertyChangeListener(proxy.getPropertyName(),
- (PropertyChangeListener)proxy.getListener());
-
+ proxy.getListener());
}
else
{
- listeners.add(new WeakReference<PropertyChangeListener>(listener));
+ listeners.add(new WeakReference<>(listener));
}
}
diff --git a/platform/api.visual/src/org/netbeans/api/visual/widget/general/ListItemWidget.java b/platform/api.visual/src/org/netbeans/api/visual/widget/general/ListItemWidget.java
index 96ba916..b61e694 100644
--- a/platform/api.visual/src/org/netbeans/api/visual/widget/general/ListItemWidget.java
+++ b/platform/api.visual/src/org/netbeans/api/visual/widget/general/ListItemWidget.java
@@ -31,6 +31,7 @@ import org.netbeans.modules.visual.util.GeomUtil;
* @deprecated
* @author David Kaspar
*/
+@Deprecated
public class ListItemWidget extends LabelWidget {
/**
diff --git a/platform/api.visual/src/org/netbeans/api/visual/widget/general/ListWidget.java b/platform/api.visual/src/org/netbeans/api/visual/widget/general/ListWidget.java
index 7271f10..8201434 100644
--- a/platform/api.visual/src/org/netbeans/api/visual/widget/general/ListWidget.java
+++ b/platform/api.visual/src/org/netbeans/api/visual/widget/general/ListWidget.java
@@ -34,6 +34,7 @@ import java.awt.*;
* @deprecated
* @author David Kaspar
*/
+@Deprecated
public class ListWidget extends Widget {
private Widget header;
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/action/CycleObjectSceneFocusProvider.java b/platform/api.visual/src/org/netbeans/modules/visual/action/CycleObjectSceneFocusProvider.java
index 2b1933e..3fd6818 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/action/CycleObjectSceneFocusProvider.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/action/CycleObjectSceneFocusProvider.java
@@ -38,19 +38,19 @@ public class CycleObjectSceneFocusProvider implements CycleFocusProvider {
return scene instanceof ObjectScene && switchFocus ((ObjectScene) scene, true);
}
- @SuppressWarnings ("unchecked")
+ @SuppressWarnings ({"rawtypes", "unchecked"})
private boolean switchFocus (ObjectScene scene, boolean forwardDirection) {
Object object = scene.getFocusedObject ();
- Comparable identityCode = scene.getIdentityCode (object);
+ Comparable identityCode = scene.getIdentityCode(object);
Object bestObject = null;
Comparable bestIdentityCode = null;
if (identityCode != null) {
for (Object o : scene.getObjects ()) {
- Comparable ic = scene.getIdentityCode (o);
+ Comparable ic = scene.getIdentityCode(o);
if (forwardDirection) {
- if (identityCode.compareTo (ic) < 0) {
+ if (identityCode.compareTo(ic) < 0) {
if (bestIdentityCode == null || bestIdentityCode.compareTo (ic) > 0) {
bestObject = o;
bestIdentityCode = ic;
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/export/Scene2Image.java b/platform/api.visual/src/org/netbeans/modules/visual/export/Scene2Image.java
index ed64c3b..428641c 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/export/Scene2Image.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/export/Scene2Image.java
@@ -53,7 +53,7 @@ public class Scene2Image {
private final File file;
private final Scene scene;
- private Set selectedObjects;
+ private Set<?> selectedObjects;
private int imageHeight;
private int imageWidth;
private double scale;
@@ -276,7 +276,7 @@ public class Scene2Image {
int _imageWidth = sceneRec.width;
int _imageHeight = sceneRec.height;
- Set _selectedObjects = null;
+ Set<?> _selectedObjects = null;
if (selectedOnly) {
//in order to use getSelectedObject the scene must be an ObjectScene
@@ -353,8 +353,8 @@ public class Scene2Image {
FileImageOutputStream fo = new FileImageOutputStream(file);
if (imageType == ImageType.JPG) {
- Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
- ImageWriter writer = (ImageWriter) iter.next();
+ Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName("jpg");
+ ImageWriter writer = iter.next();
ImageWriteParam iwp = writer.getDefaultWriteParam();
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/HierarchicalLayout.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/HierarchicalLayout.java
index 370d721..0339329 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/HierarchicalLayout.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/HierarchicalLayout.java
@@ -633,8 +633,9 @@ public class HierarchicalLayout<N, E> extends GraphLayout<N, E> {
}
protected void run() {
-
- layers = new List[layerCount];
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ List<LayoutNode>[] layersTmp = new List[layerCount];
+ layers = layersTmp;
for (int i = 0; i < layerCount; i++) {
layers[i] = new ArrayList<LayoutNode>();
@@ -852,11 +853,17 @@ public class HierarchicalLayout<N, E> extends GraphLayout<N, E> {
}
}
+ @Override
protected void run() {
-
- space = new ArrayList[layers.length];
- downProcessingOrder = new ArrayList[layers.length];
- upProcessingOrder = new ArrayList[layers.length];
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ ArrayList<Integer>[] spaceTmp = new ArrayList[layers.length];
+ space = spaceTmp;
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ ArrayList<LayoutNode>[] downProcessingOrderTmp = new ArrayList[layers.length];
+ downProcessingOrder = downProcessingOrderTmp;
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ ArrayList<LayoutNode>[] upProcessingOrderTmp = new ArrayList[layers.length];
+ upProcessingOrder = upProcessingOrderTmp;
for (int i = 0; i < layers.length; i++) {
space[i] = new ArrayList<Integer>();
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/OrthogonalLayout.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/OrthogonalLayout.java
index 9e93ce5..3edc823 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/OrthogonalLayout.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/OrthogonalLayout.java
@@ -24,6 +24,7 @@ import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
import org.netbeans.api.visual.graph.GraphScene;
import org.netbeans.api.visual.router.RouterFactory;
import org.netbeans.api.visual.widget.ConnectionWidget;
@@ -41,9 +42,9 @@ import org.netbeans.modules.visual.graph.layout.orthogonalsupport.RectangularCom
* Note that the OrthogonalRouter is used to route the edges instead of adding
* extra control points during the orthogonalizing.
*/
-public class OrthogonalLayout<N, E> extends GraphLayout {
+public class OrthogonalLayout<N, E> extends GraphLayout<N, E> {
- private MGraph mGraph = null;
+ private MGraph<N, E> mGraph = null;
private GraphScene<N, E> scene = null;
private final boolean animate;
@@ -67,17 +68,17 @@ public class OrthogonalLayout<N, E> extends GraphLayout {
* @param graph the UniversalGraph created in UniversalGraph.layoutGraph
*/
@Override
- protected void performGraphLayout(UniversalGraph graph) {
+ protected void performGraphLayout(UniversalGraph<N, E> graph) {
mGraph = MGraph.createGraph(graph, scene);
- GTPlanarizer planarizer = new GTPlanarizer();
- Collection<EmbeddedPlanarGraph> epgs = planarizer.planarize(mGraph);
+ GTPlanarizer<N, E> planarizer = new GTPlanarizer<>();
+ Collection<EmbeddedPlanarGraph<N, E>> epgs = planarizer.planarize(mGraph);
MinimumBendOrthogonalizer orthogonalizer = new MinimumBendOrthogonalizer();
- Collection<OrthogonalRepresentation> ors = orthogonalizer.orthogonalize(epgs);
+ Collection<OrthogonalRepresentation<N, E>> ors = orthogonalizer.orthogonalize(epgs);
- RectangularCompactor compactor = new RectangularCompactor();
+ RectangularCompactor<N, E> compactor = new RectangularCompactor<>();
compactor.compact(ors);
layoutNodes();
@@ -96,15 +97,15 @@ public class OrthogonalLayout<N, E> extends GraphLayout {
conn.setRouter(RouterFactory.createOrthogonalSearchRouter());
}
- ArrayList <Widget> singletons = new ArrayList<Widget>() ;
+ List<Widget> singletons = new ArrayList<>() ;
- Collection<Vertex> vertices = mGraph.getVertices();
+ Collection<Vertex<N>> vertices = mGraph.getVertices();
int maxX = -1 ;
int maxY = -1 ;
- for (Vertex v : vertices) {
+ for (Vertex<N> v : vertices) {
- N node = (N) v.getNodeDesignElement();
+ N node = v.getNodeDesignElement();
if (node == null) {//if the vertex is a dummy, there is no
continue; //node associated with it.
}
@@ -172,13 +173,8 @@ public class OrthogonalLayout<N, E> extends GraphLayout {
}
- /**
- *
- * @param graph
- * @param nodes
- */
@Override
- protected void performNodesLayout(UniversalGraph graph, Collection nodes) {
+ protected void performNodesLayout(UniversalGraph<N, E> graph, Collection<N> nodes) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/TreeGraphLayout.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/TreeGraphLayout.java
index 10dcaa7..f0e5be6 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/TreeGraphLayout.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/TreeGraphLayout.java
@@ -344,9 +344,9 @@ public final class TreeGraphLayout<N,E> extends GraphLayout<N,E> {
for (int i = 0; i < children.size(); i++) {
if (i == 0) {
- leftright = children.get(i).layout(x, (int) (y + map.get(lvl - 1) + verticalGap), map, lvl);
+ leftright = children.get(i).layout(x, (y + map.get(lvl - 1) + verticalGap), map, lvl);
} else {
- List<LeftRight> secound = children.get(i).layout(x, (int) (y + map.get(lvl - 1) + verticalGap), map, lvl);
+ List<LeftRight> secound = children.get(i).layout(x, (y + map.get(lvl - 1) + verticalGap), map, lvl);
int leftlength = leftright.size();
int rightlength = secound.size();
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/BarycenterCrossingMinimizer.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/BarycenterCrossingMinimizer.java
index 28ad1ab..285f0d5 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/BarycenterCrossingMinimizer.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/BarycenterCrossingMinimizer.java
@@ -36,8 +36,8 @@ public class BarycenterCrossingMinimizer {
*
*
*/
- public LayeredGraph minimizeCrossings(LayeredGraph graph) {
- List<List<Vertex>> layers = graph.getLayers();
+ public <N, E> LayeredGraph<N, E> minimizeCrossings(LayeredGraph<N, E> graph) {
+ List<List<Vertex<N>>> layers = graph.getLayers();
if (layers.size() > 1) {
int maxIteration = 2;
@@ -56,21 +56,21 @@ public class BarycenterCrossingMinimizer {
*
*
*/
- private void minimizeCrossingsPhaseI(LayeredGraph graph) {
- List<List<Vertex>> layers = graph.getLayers();
+ private <N, E> void minimizeCrossingsPhaseI(LayeredGraph<N, E> graph) {
+ List<List<Vertex<N>>> layers = graph.getLayers();
int size = layers.size();
// downward phase
for (int i = 0; i < size-1; i++) {
float lowerBarycenters[] = graph.computeLowerBarycenters(i);
- List<Vertex> lowerLayer = layers.get(i+1);
+ List<Vertex<N>> lowerLayer = layers.get(i+1);
sortVertices(lowerLayer, lowerBarycenters, false);
}
// upward phase
for (int i = size-2; i >= 0; i--) {
float upperBarycenters[] = graph.computeUpperBarycenters(i);
- List<Vertex> upperLayer = layers.get(i);
+ List<Vertex<N>> upperLayer = layers.get(i);
sortVertices(upperLayer, upperBarycenters, false);
}
}
@@ -80,14 +80,14 @@ public class BarycenterCrossingMinimizer {
*
*
*/
- private void minimizeCrossingsPhaseII(LayeredGraph graph) {
- List<List<Vertex>> layers = graph.getLayers();
+ private <N, E> void minimizeCrossingsPhaseII(LayeredGraph<N, E> graph) {
+ List<List<Vertex<N>>> layers = graph.getLayers();
int size = layers.size();
// upward phase
for (int i = size-2; i >= 0; i--) {
float upperBarycenters[] = graph.computeUpperBarycenters(i);
- List<Vertex> upperLayer = layers.get(i);
+ List<Vertex<N>> upperLayer = layers.get(i);
sortVertices(upperLayer, upperBarycenters, true);
minimizeCrossingsPhaseI(graph);
}
@@ -95,7 +95,7 @@ public class BarycenterCrossingMinimizer {
// downward phase
for (int i = 0; i < size-1; i++) {
float lowerBarycenters[] = graph.computeLowerBarycenters(i);
- List<Vertex> lowerLayer = layers.get(i+1);
+ List<Vertex<N>> lowerLayer = layers.get(i+1);
sortVertices(lowerLayer, lowerBarycenters, true);
minimizeCrossingsPhaseI(graph);
}
@@ -106,15 +106,15 @@ public class BarycenterCrossingMinimizer {
*
*
*/
- private boolean sortVertices(List<Vertex> vertices,
+ private <N> boolean sortVertices(List<Vertex<N>> vertices,
float barycenters[], boolean reverseEqualBarycenters) {
int size = vertices.size();
boolean changed = false;
for (int i = 0; i < size-1; i++) {
for (int j = i+1; j < size; j++) {
- Vertex jv = vertices.get(j);
- Vertex iv = vertices.get(i);
+ Vertex<N> jv = vertices.get(j);
+ Vertex<N> iv = vertices.get(i);
float jbc = barycenters[j];
float ibc = barycenters[i];
boolean swap = false;
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/BarycenterXCoordinateAssigner.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/BarycenterXCoordinateAssigner.java
index e5d5114..02eecf4 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/BarycenterXCoordinateAssigner.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/BarycenterXCoordinateAssigner.java
@@ -37,8 +37,8 @@ public class BarycenterXCoordinateAssigner {
*
*
*/
- public LayeredGraph assignCoordinates(LayeredGraph graph) {
- List<List<Vertex>> layers = graph.getLayers();
+ public <N, E> LayeredGraph<N, E> assignCoordinates(LayeredGraph<N, E> graph) {
+ List<List<Vertex<N>>> layers = graph.getLayers();
int size = layers.size();
int maxIteration = 1;
@@ -47,7 +47,7 @@ public class BarycenterXCoordinateAssigner {
//System.out.println("downward phase");
for (int i = 0; i < size-1; i++) {
float lowerBarycenters[] = graph.computeLowerBarycenters(i);
- List<Vertex> lowerLayer = graph.getLayer(i+1);
+ List<Vertex<N>> lowerLayer = graph.getLayer(i+1);
int upPriorities[] = computeUpPriorities(lowerLayer);
moveVertices(lowerLayer, lowerBarycenters, upPriorities);
}
@@ -56,7 +56,7 @@ public class BarycenterXCoordinateAssigner {
// upward phase
for (int i = size-2; i >= 0; i--) {
float upperBarycenters[] = graph.computeUpperBarycenters(i);
- List<Vertex> upperLayer = graph.getLayer(i);
+ List<Vertex<N>> upperLayer = graph.getLayer(i);
int downPriorities[] = computeDownPriorities(upperLayer);
moveVertices(upperLayer, upperBarycenters, downPriorities);
}
@@ -69,13 +69,13 @@ public class BarycenterXCoordinateAssigner {
*
*
*/
- private void moveVertices(List<Vertex> layer, float[] barycenters,
+ private <N> void moveVertices(List<Vertex<N>> layer, float[] barycenters,
int[] priorities) {
int size = layer.size();
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
- Vertex jv = layer.get(j);
+ Vertex<N> jv = layer.get(j);
int jp = priorities[j];
float jbc = barycenters[j];
float jhd = jv.getX();
@@ -91,7 +91,6 @@ public class BarycenterXCoordinateAssigner {
// higher priority vertex to the right
int hpIndex = -1;
for (int k = j+1; k < size; k++) {
- Vertex kv = layer.get(k);
if (priorities[k] >= jp) {
hpIndex = k;
break;
@@ -106,7 +105,7 @@ public class BarycenterXCoordinateAssigner {
if (hpIndex != -1) {
lastIndex = hpIndex;
// If there is a higher priority vertex to the right,
- Vertex hv = layer.get(hpIndex);
+ Vertex<N> hv = layer.get(hpIndex);
float hhd = hv.getX();
float spacing = (hhd-jhd)/(hpIndex-j);
//System.out.println("spacing = " + spacing);
@@ -130,7 +129,7 @@ public class BarycenterXCoordinateAssigner {
float chd = nhd; //current horizontal distance
for (int k = j+1; k < lastIndex; k++) {
- Vertex kv = layer.get(k);
+ Vertex<N> kv = layer.get(k);
float khd = kv.getX();
if (khd <= (chd + 1.0f)) {
@@ -151,13 +150,13 @@ public class BarycenterXCoordinateAssigner {
*
*
*/
- private int[] computeUpPriorities(List<Vertex> layer) {
+ private <N> int[] computeUpPriorities(List<Vertex<N>> layer) {
int size = layer.size();
int upPriorities[] = new int[size];
int maxUpPriority = -1;
for (int i = 0; i < size; i++) {
- Vertex v = layer.get(i);
+ Vertex<N> v = layer.get(i);
if (!(v instanceof DummyVertex)) {
int upPriority = v.getUpperNeighbors().size();
@@ -173,7 +172,7 @@ public class BarycenterXCoordinateAssigner {
// assign each dummy vertex with max priority + 1
for (int i = 0; i < size; i++) {
- Vertex v = layer.get(i);
+ Vertex<N> v = layer.get(i);
if (v instanceof DummyVertex) {
upPriorities[i] = maxUpPriority;
@@ -188,13 +187,13 @@ public class BarycenterXCoordinateAssigner {
*
*
*/
- private int[] computeDownPriorities(List<Vertex> layer) {
+ private <N> int[] computeDownPriorities(List<Vertex<N>> layer) {
int size = layer.size();
int downPriorities[] = new int[size];
int maxDownPriority = -1;
for (int i = 0; i < size; i++) {
- Vertex v = layer.get(i);
+ Vertex<N> v = layer.get(i);
if (!(v instanceof DummyVertex)) {
int downPriority = v.getLowerNeighbors().size();
@@ -210,7 +209,7 @@ public class BarycenterXCoordinateAssigner {
// assign each dummy vertex with max priority + 1
for (int i = 0; i < size; i++) {
- Vertex v = layer.get(i);
+ Vertex<N> v = layer.get(i);
if (v instanceof DummyVertex) {
downPriorities[i] = maxDownPriority;
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/DirectedGraph.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/DirectedGraph.java
index fd3473b..46d6b98 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/DirectedGraph.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/DirectedGraph.java
@@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import org.netbeans.api.visual.graph.GraphScene;
import org.netbeans.api.visual.graph.layout.UniversalGraph;
@@ -37,31 +38,31 @@ import org.netbeans.api.visual.widget.Widget;
public class DirectedGraph<N, E> {
private Collection<N> nodes;
- private Collection<Vertex> rootVertices;
- private Collection<Vertex> vertices;
+ private Collection<Vertex<N>> rootVertices;
+ private Collection<Vertex<N>> vertices;
private Collection<E> edges;
- private Map<N, Vertex> vertexMap;
- private Map<E, Edge> edgeMap;
- private GraphScene scene;
+ private Map<N, Vertex<N>> vertexMap;
+ private Map<E, Edge<E>> edgeMap;
+ private GraphScene<N, E> scene;
private UniversalGraph<N, E> uGraph;
/**
* Creates a new instance of DirectedGraph
*/
- protected DirectedGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
+ protected DirectedGraph(UniversalGraph<N, E> uGraph, GraphScene<N, E> scene) {
this.uGraph = uGraph;
this.scene = scene;
this.nodes = uGraph.getNodes();
this.edges = uGraph.getEdges();
- vertexMap = new HashMap<N, Vertex>();
- edgeMap = new LinkedHashMap<E, Edge>();
- rootVertices = new ArrayList<Vertex>();
- vertices = new ArrayList<Vertex>();
+ vertexMap = new HashMap<>();
+ edgeMap = new LinkedHashMap<>();
+ rootVertices = new ArrayList<>();
+ vertices = new ArrayList<>();
}
- public static <N, E> DirectedGraph createGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
- DirectedGraph<N, E> graph = new DirectedGraph<N, E>(uGraph, scene);
+ public static <N, E> DirectedGraph<N, E> createGraph(UniversalGraph<N, E> uGraph, GraphScene<N, E> scene) {
+ DirectedGraph<N, E> graph = new DirectedGraph<>(uGraph, scene);
graph.createGraph();
//graph.printGraph();
return graph;
@@ -73,10 +74,10 @@ public class DirectedGraph<N, E> {
N source = uGraph.getEdgeSource(e);
N target = uGraph.getEdgeTarget(e);
- Vertex sourceVertex = getVertex(source);
- Vertex targetVertex = getVertex(target);
+ Vertex<N> sourceVertex = getVertex(source);
+ Vertex<N> targetVertex = getVertex(target);
- Edge edge = createEdge(sourceVertex, targetVertex, e);
+ Edge<E> edge = createEdge(sourceVertex, targetVertex, e);
sourceVertex.addOutgoingEdge(edge);
targetVertex.addIncomingEdge(edge);
@@ -87,7 +88,7 @@ public class DirectedGraph<N, E> {
}
for (N node : nodes) {
- Vertex vertex = getVertex(node);
+ Vertex<N> vertex = getVertex(node);
Widget widget = scene.findWidget(node);
if (widget == null) continue ; //why is it null
@@ -103,8 +104,8 @@ public class DirectedGraph<N, E> {
//printGraph();
}
- private Vertex getVertex(N node) {
- Vertex vertex = vertexMap.get(node);
+ private Vertex<N> getVertex(N node) {
+ Vertex<N> vertex = vertexMap.get(node);
if (vertex == null) {
vertex = createVertex(node);
@@ -115,16 +116,16 @@ public class DirectedGraph<N, E> {
return vertex;
}
- protected Vertex createVertex(N node) {
- return new Vertex(node);
+ protected Vertex<N> createVertex(N node) {
+ return new Vertex<>(node);
}
- protected Edge createEdge(Vertex source, Vertex target, E edgeDE) {
- return new Edge(source, target, edgeDE);
+ protected Edge<E> createEdge(Vertex<N> source, Vertex<N> target, E edgeDE) {
+ return new Edge<>(source, target, edgeDE);
}
- private Edge getEdge(Vertex source, Vertex target, E edgeDE) {
- Edge edge = edgeMap.get(edgeDE);
+ private Edge<E> getEdge(Vertex<N> source, Vertex<N> target, E edgeDE) {
+ Edge<E> edge = edgeMap.get(edgeDE);
if (edge == null) {
edge = createEdge(source, target, edgeDE);
@@ -134,41 +135,45 @@ public class DirectedGraph<N, E> {
return edge;
}
- public Collection<Vertex> getVertices() {
+ public Collection<Vertex<N>> getVertices() {
return vertexMap.values();
}
- public Collection<Vertex> getRootVertices() {
+ public Collection<Vertex<N>> getRootVertices() {
return rootVertices;
}
private void findRootVertices() {
- for (Vertex vertex : vertexMap.values()) {
- Collection<Vertex> uppers = vertex.getUpperNeighbors();
+ for (Vertex<N> vertex : vertexMap.values()) {
+ Collection<Vertex<N>> uppers = vertex.getUpperNeighbors();
if (uppers.size() == 0) {
rootVertices.add(vertex);
}
}
}
- public DummyVertex insertDummyVertex(Edge edge, DummyVertex.Type type) {
- Edge originalEdge = edge;
+ public DummyVertex<N> insertDummyVertex(Edge<E> edge, DummyVertex.Type type) {
+ Edge<E> originalEdge;
if (edge instanceof DummyEdge) {
- originalEdge = ((DummyEdge) edge).getOriginalEdge();
+ originalEdge = ((DummyEdge<E>) edge).getOriginalEdge();
+ } else {
+ originalEdge = edge;
}
- DummyVertex dv = createDummyVertex(originalEdge, type);
+ DummyVertex<N> dv = createDummyVertex(originalEdge, type);
vertices.add(dv);
- Vertex source = edge.getSource();
- Vertex target = edge.getTarget();
+ @SuppressWarnings("unchecked")
+ Vertex<N> source = (Vertex<N>) edge.getSource();
+ @SuppressWarnings("unchecked")
+ Vertex<N> target = (Vertex<N>) edge.getTarget();
source.removeOutgoingEdge(edge);
source.removeLowerNeighbor(target);
source.addLowerNeighbor(dv);
dv.addUpperNeighbor(target);
- DummyEdge de = createDummyEdge(source, dv, originalEdge);
+ DummyEdge<E> de = createDummyEdge(source, dv, originalEdge);
source.addOutgoingEdge(de);
dv.addIncomingEdge(de);
@@ -183,12 +188,12 @@ public class DirectedGraph<N, E> {
return dv;
}
- protected DummyVertex createDummyVertex(Edge originalEdge, DummyVertex.Type type) {
- return new DummyVertex(originalEdge, type);
+ protected DummyVertex<N> createDummyVertex(Edge<?> originalEdge, DummyVertex.Type type) {
+ return new DummyVertex<N>(originalEdge, type);
}
- public DummyEdge addDummyEdge(Vertex source, Vertex target) {
- DummyEdge de = createDummyEdge(source, target, null);
+ public DummyEdge<E> addDummyEdge(Vertex<N> source, Vertex<N> target) {
+ DummyEdge<E> de = createDummyEdge(source, target, null);
source.addOutgoingEdge(de);
target.addIncomingEdge(de);
source.addLowerNeighbor(target);
@@ -197,26 +202,26 @@ public class DirectedGraph<N, E> {
return de;
}
- protected DummyEdge createDummyEdge(Vertex source, Vertex target,
- Edge originalEdge) {
- return new DummyEdge(source, target, originalEdge);
+ protected DummyEdge<E> createDummyEdge(Vertex<?> source, Vertex<?> target,
+ Edge<E> originalEdge) {
+ return new DummyEdge<>(source, target, originalEdge);
}
private void printGraph() {
- for (Vertex rootVertex : getRootVertices()) {
+ for (Vertex<?> rootVertex : getRootVertices()) {
System.out.println("root vertex = " + rootVertex);
}
- for (Vertex v : getVertices()) {
+ for (Vertex<N> v : getVertices()) {
System.out.println("vertex = " + v);
- Collection<Vertex> neighbors = v.getUpperNeighbors();
- for (Vertex nv : neighbors) {
+ Collection<Vertex<N>> neighbors = v.getUpperNeighbors();
+ for (Vertex<N> nv : neighbors) {
System.out.println("\tupper neighbor = " + nv);
}
neighbors = v.getLowerNeighbors();
- for (Vertex nv : neighbors) {
+ for (Vertex<?> nv : neighbors) {
System.out.println("\tlower neighbor = " + nv);
}
}
@@ -289,10 +294,10 @@ public class DirectedGraph<N, E> {
public static class Vertex<N> {
private N nodeDE;
- private ArrayList<Vertex> upperNeighbors;
- private ArrayList<Vertex> lowerNeighbors;
- private Collection<Edge> incomingEdges;
- private Collection<Edge> outgoingEdges;
+ private List<Vertex<N>> upperNeighbors;
+ private List<Vertex<N>> lowerNeighbors;
+ private Collection<Edge<?>> incomingEdges;
+ private Collection<Edge<?>> outgoingEdges;
private int number = -1;
private int x;
private int y;
@@ -302,10 +307,10 @@ public class DirectedGraph<N, E> {
/** Creates a new instance of Vertex */
public Vertex(N nodeDE) {
this.nodeDE = nodeDE;
- upperNeighbors = new ArrayList<Vertex>();
- lowerNeighbors = new ArrayList<Vertex>();
- incomingEdges = new ArrayList<Edge>();
- outgoingEdges = new ArrayList<Edge>();
+ upperNeighbors = new ArrayList<>();
+ lowerNeighbors = new ArrayList<>();
+ incomingEdges = new ArrayList<>();
+ outgoingEdges = new ArrayList<>();
}
public Dimension getSize() {
@@ -376,7 +381,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public void addLowerNeighbor(Vertex vertex) {
+ public void addLowerNeighbor(Vertex<N> vertex) {
if (!lowerNeighbors.contains(vertex)) {
lowerNeighbors.add(vertex);
}
@@ -386,7 +391,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public void removeLowerNeighbor(Vertex vertex) {
+ public void removeLowerNeighbor(Vertex<?> vertex) {
lowerNeighbors.remove(vertex);
}
@@ -394,7 +399,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public void replaceLowerNeighbor(Vertex oldVertex, Vertex newVertex) {
+ public void replaceLowerNeighbor(Vertex<N> oldVertex, Vertex<N> newVertex) {
lowerNeighbors.set(lowerNeighbors.indexOf(oldVertex), newVertex);
}
@@ -402,7 +407,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public Collection<Vertex> getLowerNeighbors() {
+ public Collection<Vertex<N>> getLowerNeighbors() {
return Collections.unmodifiableCollection(lowerNeighbors);
}
@@ -410,7 +415,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public void addUpperNeighbor(Vertex vertex) {
+ public void addUpperNeighbor(Vertex<N> vertex) {
if (!upperNeighbors.contains(vertex)) {
upperNeighbors.add(vertex);
}
@@ -420,7 +425,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public void removeUpperNeighbor(Vertex vertex) {
+ public void removeUpperNeighbor(Vertex<N> vertex) {
upperNeighbors.remove(vertex);
}
@@ -428,7 +433,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public void replaceUpperNeighbor(Vertex oldVertex, Vertex newVertex) {
+ public void replaceUpperNeighbor(Vertex<N> oldVertex, Vertex<N> newVertex) {
upperNeighbors.set(upperNeighbors.indexOf(oldVertex), newVertex);
}
@@ -436,7 +441,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public Collection<Vertex> getUpperNeighbors() {
+ public Collection<Vertex<N>> getUpperNeighbors() {
return Collections.unmodifiableCollection(upperNeighbors);
}
@@ -444,7 +449,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public Collection<Edge> getOutgoingEdges() {
+ public Collection<Edge<?>> getOutgoingEdges() {
return outgoingEdges;
}
@@ -452,7 +457,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public void addOutgoingEdge(Edge edge) {
+ public void addOutgoingEdge(Edge<?> edge) {
if (!outgoingEdges.contains(edge)) {
outgoingEdges.add(edge);
}
@@ -462,7 +467,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public Collection<Edge> getIncomingEdges() {
+ public Collection<Edge<?>> getIncomingEdges() {
return incomingEdges;
}
@@ -470,7 +475,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public void removeOutgoingEdge(Edge edge) {
+ public void removeOutgoingEdge(Edge<?> edge) {
outgoingEdges.remove(edge);
}
@@ -478,7 +483,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public void addIncomingEdge(Edge edge) {
+ public void addIncomingEdge(Edge<?> edge) {
if (!incomingEdges.contains(edge)) {
incomingEdges.add(edge);
}
@@ -488,7 +493,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public void removeIncomingEdge(Edge edge) {
+ public void removeIncomingEdge(Edge<?> edge) {
incomingEdges.remove(edge);
}
@@ -496,10 +501,10 @@ public class DirectedGraph<N, E> {
*
*
*/
- public Edge getEdgeToLowerNeighbor(Vertex nv) {
- Collection<Edge> edges = nv.getOutgoingEdges();
+ public Edge<?> getEdgeToLowerNeighbor(Vertex<N> nv) {
+ Collection<Edge<?>> edges = nv.getOutgoingEdges();
- for (Edge edge : edges) {
+ for (Edge<?> edge : edges) {
if (edge.getTarget() == nv) {
return edge;
}
@@ -512,10 +517,10 @@ public class DirectedGraph<N, E> {
*
*
*/
- public Edge getEdgeToUpperNeighbor(Vertex nv) {
- Collection<Edge> edges = nv.getIncomingEdges();
+ public Edge<?> getEdgeToUpperNeighbor(Vertex<N> nv) {
+ Collection<Edge<?>> edges = nv.getIncomingEdges();
- for (Edge edge : edges) {
+ for (Edge<?> edge : edges) {
if (edge.getSource() == nv) {
return edge;
}
@@ -555,15 +560,15 @@ public class DirectedGraph<N, E> {
*/
public static class Edge<E> {
- private Vertex source;
- private Vertex target;
+ private Vertex<?> source;
+ private Vertex<?> target;
private E edgeDE;
/**
*
*
*/
- public Edge(Vertex source, Vertex target, E edgeDE) {
+ public Edge(Vertex<?> source, Vertex<?> target, E edgeDE) {
this.source = source;
this.target = target;
this.edgeDE = edgeDE;
@@ -573,7 +578,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public Vertex getSource() {
+ public Vertex<?> getSource() {
return source;
}
@@ -581,7 +586,7 @@ public class DirectedGraph<N, E> {
*
*
*/
- public Vertex getTarget() {
+ public Vertex<?> getTarget() {
return target;
}
@@ -598,27 +603,19 @@ public class DirectedGraph<N, E> {
*
*
*/
- public static class DummyVertex extends Vertex {
+ public static class DummyVertex<N> extends Vertex<N> {
private static int counter = 0;
public enum Type {
CROSSING, HYPEREDGE, BEND, TEMPORARY
- }
-
-
-
- ;
- private Edge originalEdge;
- private Type
-
-
+ };
+ private Edge<?> originalEdge;
+ private Type type;
+ private int index;
- type ;
- private int index;
-
- public DummyVertex(Edge originalEdge, Type type) {
+ public DummyVertex(Edge<?> originalEdge, Type type) {
super(null);
this.originalEdge = originalEdge;
this.type = type;
@@ -629,11 +626,11 @@ public class DirectedGraph<N, E> {
this(null, type);
}
- public void setOriginalEdge(Edge originalEdge) {
+ public void setOriginalEdge(Edge<?> originalEdge) {
this.originalEdge = originalEdge;
}
- public Edge getOriginalEdge() {
+ public Edge<?> getOriginalEdge() {
return originalEdge;
}
@@ -650,24 +647,24 @@ public class DirectedGraph<N, E> {
*
*
*/
- public static class DummyEdge extends Edge {
+ public static class DummyEdge<E> extends Edge<E> {
- private Edge originalEdge;
+ private Edge<E> originalEdge;
- public DummyEdge(Vertex source, Vertex target, Edge originalEdge) {
+ public DummyEdge(Vertex<?> source, Vertex<?> target, Edge<E> originalEdge) {
super(source, target, null);
this.originalEdge = originalEdge;
}
- public DummyEdge(Vertex source, Vertex target) {
+ public DummyEdge(Vertex<?> source, Vertex<?> target) {
this(source, target, null);
}
- public void setOriginalEdge(Edge originalEdge) {
+ public void setOriginalEdge(Edge<E> originalEdge) {
this.originalEdge = originalEdge;
}
- public Edge getOriginalEdge() {
+ public Edge<E> getOriginalEdge() {
return originalEdge;
}
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/EdgeReversingCycleRemover.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/EdgeReversingCycleRemover.java
index aa9a74e..d4ab573 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/EdgeReversingCycleRemover.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/EdgeReversingCycleRemover.java
@@ -32,7 +32,7 @@ public class EdgeReversingCycleRemover {
* @param graph
* @return
*/
- public DirectedGraph removeCycles(DirectedGraph graph) {
+ public <N, E> DirectedGraph<N, E> removeCycles(DirectedGraph<N, E> graph) {
return graph;
}
}
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/LayeredGraph.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/LayeredGraph.java
index b218ae0..4b16c97 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/LayeredGraph.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/LayeredGraph.java
@@ -26,22 +26,22 @@ import org.netbeans.modules.visual.graph.layout.hierarchicalsupport.DirectedGrap
*
* @author ptliu
*/
-public class LayeredGraph {
- private DirectedGraph originalGraph;
- private List<List<Vertex>> layers;
+public class LayeredGraph<N, E> {
+ private DirectedGraph<N, E> originalGraph;
+ private List<List<Vertex<N>>> layers;
/** Creates a new instance of LayeredGraph */
- protected LayeredGraph(DirectedGraph originalGraph) {
+ protected LayeredGraph(DirectedGraph<N, E> originalGraph) {
this.originalGraph = originalGraph;
- layers = new ArrayList<List<Vertex>>();
+ layers = new ArrayList<>();
}
/**
*
*
*/
- public static LayeredGraph createGraph(DirectedGraph originalGraph) {
- LayeredGraph graph = new LayeredGraph(originalGraph);
+ public static <N, E> LayeredGraph<N, E> createGraph(DirectedGraph<N, E> originalGraph) {
+ LayeredGraph<N, E> graph = new LayeredGraph<>(originalGraph);
graph.createGraph();
return graph;
@@ -52,8 +52,8 @@ public class LayeredGraph {
*
*/
protected void createGraph() {
- Collection<Vertex> rootVertices = originalGraph.getRootVertices() ;
- for (Vertex rootVertex : rootVertices) {
+ Collection<Vertex<N>> rootVertices = originalGraph.getRootVertices() ;
+ for (Vertex<N> rootVertex : rootVertices) {
assignLayers(rootVertex, 0);
}
}
@@ -62,7 +62,7 @@ public class LayeredGraph {
*
*
*/
- public DirectedGraph getOriginalGraph() {
+ public DirectedGraph<N, E> getOriginalGraph() {
return originalGraph;
}
@@ -71,11 +71,11 @@ public class LayeredGraph {
*
*
*/
- private void assignLayers(Vertex vertex, int index) {
+ private void assignLayers(Vertex<N> vertex, int index) {
assignLayer(vertex, index);
- Collection<Vertex> vertices = vertex.getLowerNeighbors();
- for (Vertex nv : vertices) {
+ Collection<Vertex<N>> vertices = vertex.getLowerNeighbors();
+ for (Vertex<N> nv : vertices) {
int nvIndex = nv.getNumber();
if (nvIndex <= index) {
@@ -89,15 +89,15 @@ public class LayeredGraph {
*
*
*/
- public void assignLayer(Vertex vertex, int index) {
+ public void assignLayer(Vertex<N> vertex, int index) {
int prevIndex = vertex.getNumber();
if (prevIndex != -1) {
- List<Vertex> layer = getLayer(prevIndex);
+ List<Vertex<N>> layer = getLayer(prevIndex);
layer.remove(vertex);
}
- List<Vertex> layer = getLayer(index);
+ List<Vertex<N>> layer = getLayer(index);
layer.add(vertex);
vertex.setNumber(index);
vertex.setY(index);
@@ -108,7 +108,7 @@ public class LayeredGraph {
*
*
*/
- public List<List<Vertex>> getLayers() {
+ public List<List<Vertex<N>>> getLayers() {
return layers;
}
@@ -116,12 +116,12 @@ public class LayeredGraph {
*
*
*/
- public List<Vertex> getLayer(int index) {
+ public List<Vertex<N>> getLayer(int index) {
int size = layers.size();
if (index >= size) {
for (int i = size; i <= index; i++)
- layers.add(new ArrayList<Vertex>());
+ layers.add(new ArrayList<>());
}
return layers.get(index);
@@ -132,18 +132,18 @@ public class LayeredGraph {
*
*/
public boolean[][] computeAdjacencyMatrix(int upperLayerIndex) {
- List<Vertex> upperLayer = layers.get(upperLayerIndex);
- List<Vertex> lowerLayer = layers.get(upperLayerIndex+1);
+ List<Vertex<N>> upperLayer = layers.get(upperLayerIndex);
+ List<Vertex<N>> lowerLayer = layers.get(upperLayerIndex+1);
int upperLayerSize = upperLayer.size();
int lowerLayerSize = lowerLayer.size();
boolean[][] matrix = new boolean[upperLayerSize][lowerLayerSize];
for (int j = 0; j < upperLayerSize; j++) {
- Vertex v = upperLayer.get(j);
+ Vertex<N> v = upperLayer.get(j);
if (v != null) {
- Collection<Vertex> vertices = v.getLowerNeighbors();
- for (Vertex nv : vertices) {
+ Collection<Vertex<N>> vertices = v.getLowerNeighbors();
+ for (Vertex<N> nv : vertices) {
int k = lowerLayer.indexOf(nv);
if (k > -1) {
@@ -163,8 +163,8 @@ public class LayeredGraph {
*/
public float[] computeLowerBarycenters(int upperLayerIndex) {
boolean[][] matrix = computeAdjacencyMatrix(upperLayerIndex);
- List<Vertex> upperLayer = layers.get(upperLayerIndex);
- List<Vertex> lowerLayer = layers.get(upperLayerIndex+1);
+ List<Vertex<N>> upperLayer = layers.get(upperLayerIndex);
+ List<Vertex<N>> lowerLayer = layers.get(upperLayerIndex+1);
int upperLayerSize = upperLayer.size();
int lowerLayerSize = lowerLayer.size();
float lowerBarycenters[] = new float[lowerLayerSize];
@@ -175,12 +175,12 @@ public class LayeredGraph {
float count = 0;
for (int j = 0; j < upperLayerSize; j++) {
if (matrix[j][k]) {
- Vertex jv = upperLayer.get(j);
+ Vertex<N> jv = upperLayer.get(j);
sum += jv.getX();
count++;
}
}
- Vertex kv = lowerLayer.get(k);
+ Vertex<N> kv = lowerLayer.get(k);
lowerBarycenters[k] = sum/count;
//System.out.println("kv = " + kv + " barycenter = " + lowerBarycenters[k]);
}
@@ -195,8 +195,8 @@ public class LayeredGraph {
*/
public float[] computeUpperBarycenters(int upperLayerIndex) {
boolean[][] matrix = computeAdjacencyMatrix(upperLayerIndex);
- List<Vertex> upperLayer = layers.get(upperLayerIndex);
- List<Vertex> lowerLayer = layers.get(upperLayerIndex+1);
+ List<Vertex<N>> upperLayer = layers.get(upperLayerIndex);
+ List<Vertex<N>> lowerLayer = layers.get(upperLayerIndex+1);
int upperLayerSize = upperLayer.size();
int lowerLayerSize = lowerLayer.size();
float upperBarycenters[] = new float[upperLayerSize];
@@ -206,13 +206,13 @@ public class LayeredGraph {
float count = 0;
for (int k = 0; k < lowerLayerSize; k++) {
if (matrix[j][k]) {
- Vertex kv = lowerLayer.get(k);
+ Vertex<N> kv = lowerLayer.get(k);
sum += kv.getX();
count++;
}
}
- Vertex jv = upperLayer.get(j);
+ Vertex<N> jv = upperLayer.get(j);
upperBarycenters[j] = sum/count;
//System.out.println("jv = " + jv + " barycenter = " + upperBarycenters[j]);
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/MixedGraph.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/MixedGraph.java
index 8b70fe7..f35608c 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/MixedGraph.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/MixedGraph.java
@@ -33,23 +33,23 @@ import org.netbeans.api.visual.graph.layout.UniversalGraph;
public class MixedGraph<N, E> {
private Collection<N> nodes;
- private Map<N, Vertex> vertexMap;
- private GraphScene scene;
+ private Map<N, Vertex<N>> vertexMap;
+ private GraphScene<N, E> scene;
private UniversalGraph<N, E> uGraph;
private Collection<E> edges;
/** Creates a new instance of UndirectedGraph */
- private MixedGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
+ private MixedGraph(UniversalGraph<N, E> uGraph, GraphScene<N, E> scene) {
this.uGraph = uGraph;
this.scene = scene;
this.nodes = uGraph.getNodes();
this.edges = uGraph.getEdges() ;
- vertexMap = new HashMap<N, Vertex>();
+ vertexMap = new HashMap<>();
}
- public static <N, E> MixedGraph createGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
- MixedGraph<N, E> graph = new MixedGraph<N, E>(uGraph, scene);
+ public static <N, E> MixedGraph<N, E> createGraph(UniversalGraph<N, E> uGraph, GraphScene<N, E> scene) {
+ MixedGraph<N, E> graph = new MixedGraph<>(uGraph, scene);
graph.createGraph();
//graph.printGraph();
return graph;
@@ -89,8 +89,8 @@ public class MixedGraph<N, E> {
N source = uGraph.getEdgeSource(e) ;
N target = uGraph.getEdgeTarget(e) ;
- Vertex sourceVertex = getVertex(source);
- Vertex targetVertex = getVertex(target);
+ Vertex<N> sourceVertex = getVertex(source);
+ Vertex<N> targetVertex = getVertex(target);
sourceVertex.addUpperNeighbor(targetVertex);
targetVertex.addLowerNeighbor(sourceVertex);
@@ -99,7 +99,7 @@ public class MixedGraph<N, E> {
}
for (N node : nodes) {
- Vertex vertex = getVertex(node);
+ Vertex<N> vertex = getVertex(node);
}
@@ -110,7 +110,7 @@ public class MixedGraph<N, E> {
*
*
*/
- public Collection<Vertex> getVertices() {
+ public Collection<Vertex<N>> getVertices() {
return vertexMap.values();
}
@@ -118,11 +118,11 @@ public class MixedGraph<N, E> {
*
*
*/
- private Vertex getVertex(N node) {
- Vertex vertex = vertexMap.get(node);
+ private Vertex<N> getVertex(N node) {
+ Vertex<N> vertex = vertexMap.get(node);
if (vertex == null) {
- vertex = new Vertex(node);
+ vertex = new Vertex<>(node);
vertexMap.put(node, vertex);
}
@@ -134,10 +134,10 @@ public class MixedGraph<N, E> {
*
*/
private void printGraph() {
- for (Vertex v : getVertices()) {
+ for (Vertex<?> v : getVertices()) {
System.out.println("vertex = " + v);
- Collection<Vertex> vertices = v.getNeighbors() ;
- for (Vertex nv : vertices) {
+ Collection<Vertex<?>> vertices = v.getNeighbors() ;
+ for (Vertex<?> nv : vertices) {
System.out.println("\tneighbor = " + nv);
}
}
@@ -147,56 +147,56 @@ public class MixedGraph<N, E> {
*
*
*/
- public static class Vertex <N> {
+ public static class Vertex<N> {
private N node;
- private ArrayList<Vertex> upperNeighbors;
- private ArrayList<Vertex> lowerNeighbors;
- private ArrayList<Vertex> neighbors;
+ private ArrayList<Vertex<?>> upperNeighbors;
+ private ArrayList<Vertex<?>> lowerNeighbors;
+ private ArrayList<Vertex<?>> neighbors;
private Object vertexData;
public Vertex(N node) {
this.node = node;
- neighbors = new ArrayList<Vertex>();
+ neighbors = new ArrayList<>();
}
- public void addNeighbor(Vertex vertex) {
+ public void addNeighbor(Vertex<?> vertex) {
neighbors.add(vertex);
}
- public void removeNeighbor(Vertex vertex) {
+ public void removeNeighbor(Vertex<?> vertex) {
neighbors.remove(vertex);
}
- public void addLowerNeighbor(Vertex vertex) {
+ public void addLowerNeighbor(Vertex<?> vertex) {
if (!lowerNeighbors.contains(vertex)) {
lowerNeighbors.add(vertex);
}
}
- public void removeLowerNeighbor(Vertex vertex) {
+ public void removeLowerNeighbor(Vertex<?> vertex) {
lowerNeighbors.remove(vertex);
}
- public Collection<Vertex> getLowerNeighbors() {
+ public Collection<Vertex<?>> getLowerNeighbors() {
return Collections.unmodifiableCollection(lowerNeighbors);
}
- public void addUpperNeighbor(Vertex vertex) {
+ public void addUpperNeighbor(Vertex<?> vertex) {
if (!upperNeighbors.contains(vertex)) {
upperNeighbors.add(vertex);
}
}
- public void removeUpperNeighbor(Vertex vertex) {
+ public void removeUpperNeighbor(Vertex<?> vertex) {
upperNeighbors.remove(vertex);
}
- public Collection<Vertex> getUpperNeighbors() {
+ public Collection<Vertex<?>> getUpperNeighbors() {
return Collections.unmodifiableCollection(upperNeighbors);
}
- public Collection<Vertex> getNeighbors() {
+ public Collection<Vertex<?>> getNeighbors() {
return neighbors;
}
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/VertexInsertionLayerAssigner.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/VertexInsertionLayerAssigner.java
index ff1255b..530166d 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/VertexInsertionLayerAssigner.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/hierarchicalsupport/VertexInsertionLayerAssigner.java
@@ -41,8 +41,8 @@ public class VertexInsertionLayerAssigner {
*
*
*/
- public LayeredGraph assignLayers(DirectedGraph graph) {
- LayeredGraph layeredGraph = LayeredGraph.createGraph(graph);
+ public <N, E> LayeredGraph<N, E> assignLayers(DirectedGraph<N, E> graph) {
+ LayeredGraph<N, E> layeredGraph = LayeredGraph.createGraph(graph);
insertDummyVertices(layeredGraph);
@@ -54,24 +54,26 @@ public class VertexInsertionLayerAssigner {
*
*
*/
- private void insertDummyVertices(LayeredGraph graph) {
- DirectedGraph originalGraph = graph.getOriginalGraph();
- List<List<Vertex>> layers = graph.getLayers();
+ private <N, E> void insertDummyVertices(LayeredGraph<N, E> graph) {
+ DirectedGraph<N, E> originalGraph = graph.getOriginalGraph();
+ List<List<Vertex<N>>> layers = graph.getLayers();
for (int i = 0; i < layers.size(); i++) {
- List<Vertex> layer = layers.get(i);
+ List<Vertex<N>> layer = layers.get(i);
- for (Vertex v : layer) {
+ for (Vertex<N> v : layer) {
int layerIndex = v.getNumber();
// work around concurrent modification exception
- Collection<Edge> edges = new ArrayList<Edge>(v.getOutgoingEdges());
- for (Edge e : edges) {
- Vertex nv = e.getTarget();
+ Collection<Edge<?>> edges = new ArrayList<>(v.getOutgoingEdges());
+ for (Edge<?> e : edges) {
+ Vertex<?> nv = e.getTarget();
int nvLayerIndex = nv.getNumber();
if (nvLayerIndex > layerIndex+1) {
- Vertex dummyVertex = originalGraph.insertDummyVertex(e, DummyVertex.Type.BEND);
+ @SuppressWarnings("unchecked")
+ Edge<E> tmp = (Edge<E>) e;
+ Vertex<N> dummyVertex = originalGraph.insertDummyVertex(tmp, DummyVertex.Type.BEND);
graph.assignLayer(dummyVertex, layerIndex+1);
}
}
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/DirectionalGraph.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/DirectionalGraph.java
index b16aed2..8ad8e94 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/DirectionalGraph.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/DirectionalGraph.java
@@ -31,16 +31,16 @@ import org.netbeans.modules.visual.graph.layout.orthogonalsupport.MGraph.Edge;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.MGraph.Edge.Direction;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.MGraph.Vertex;
-public class DirectionalGraph {
+public class DirectionalGraph<N, E> {
- private OrthogonalRepresentation or;
+ private OrthogonalRepresentation<N, E> or;
private Direction direction;
private Direction barDirection;
- private ArrayList<Bar> bars;
- private Map<Vertex, Bar> barMap;
- private Set<Edge> visitedEdges;
- private Map<Vertex, Edge> forwardEdges;
- private Map<Vertex, Edge> reverseEdges;
+ private List<Bar> bars;
+ private Map<Vertex<?>, Bar> barMap;
+ private Set<Edge<?>> visitedEdges;
+ private Map<Vertex<?>, Edge<?>> forwardEdges;
+ private Map<Vertex<?>, Edge<?>> reverseEdges;
/**
*
@@ -48,9 +48,9 @@ public class DirectionalGraph {
* @param direction
* @return
*/
- public static DirectionalGraph createGraph(OrthogonalRepresentation or,
+ public static <N, E> DirectionalGraph<N, E> createGraph(OrthogonalRepresentation<N, E> or,
Direction direction) {
- DirectionalGraph graph = new DirectionalGraph(or, direction);
+ DirectionalGraph<N, E> graph = new DirectionalGraph<>(or, direction);
graph.createGraph();
return graph;
@@ -61,13 +61,13 @@ public class DirectionalGraph {
* @param or
* @param direction
*/
- private DirectionalGraph(OrthogonalRepresentation or, Direction direction) {
+ private DirectionalGraph(OrthogonalRepresentation<N, E> or, Direction direction) {
this.or = or;
- barMap = new HashMap<Vertex, Bar>();
- bars = new ArrayList<Bar>();
- visitedEdges = new HashSet<Edge>();
- forwardEdges = new HashMap<Vertex, Edge>();
- reverseEdges = new HashMap<Vertex, Edge>();
+ barMap = new HashMap<>();
+ bars = new ArrayList<>();
+ visitedEdges = new HashSet<>();
+ forwardEdges = new HashMap<>();
+ reverseEdges = new HashMap<>();
this.direction = direction;
@@ -83,9 +83,9 @@ public class DirectionalGraph {
*
*/
private void createGraph() {
- Vertex cornerVertex = getCornerVertex();
- Collection<Vertex> rootVertices = getRootVertices(cornerVertex);
- assignEdgeDirections(rootVertices, new HashSet<Vertex>());
+ Vertex<?> cornerVertex = getCornerVertex();
+ Collection<Vertex<?>> rootVertices = getRootVertices(cornerVertex);
+ assignEdgeDirections(rootVertices, new HashSet<Vertex<?>>());
visitedEdges.clear();
createBar(cornerVertex, null);
@@ -99,17 +99,17 @@ public class DirectionalGraph {
* @param vertices
* @param skippedVertices
*/
- private void assignEdgeDirections(Collection<Vertex> vertices,
- Set<Vertex> skippedVertices) {
- Collection<Vertex> oppositeVertices = new ArrayList<Vertex>();
+ private void assignEdgeDirections(Collection<Vertex<?>> vertices,
+ Set<Vertex<?>> skippedVertices) {
+ Collection<Vertex<?>> oppositeVertices = new ArrayList<>();
- for (Vertex v : vertices) {
- Collection<Edge> edges = v.getEdges();
- for (Edge e : edges) {
+ for (Vertex<?> v : vertices) {
+ Collection<Edge<?>> edges = v.getEdges();
+ for (Edge<?> e : edges) {
if (e.getDirection() == direction &&
reverseEdges.get(v) != e) {
forwardEdges.put(v, e);
- Vertex w = e.getOppositeVertex(v);
+ Vertex<?> w = e.getOppositeVertex(v);
reverseEdges.put(w, e);
oppositeVertices.add(w);
}
@@ -117,31 +117,31 @@ public class DirectionalGraph {
}
if (!oppositeVertices.isEmpty()) {
- HashSet<Vertex> additionalVertices = new LinkedHashSet<Vertex>();
+ Set<Vertex<?>> additionalVertices = new LinkedHashSet<>();
- for (Vertex v : oppositeVertices) {
- Collection<Vertex> prevVertices = new ArrayList<Vertex>();
- Set<Vertex> parentVertices = computeParentVertices(v);
+ for (Vertex<?> v : oppositeVertices) {
+ Collection<Vertex<?>> prevVertices = new ArrayList<>();
+ Set<Vertex<?>> parentVertices = computeParentVertices(v);
- Collection<Edge> edges = v.getEdges();
- for (Edge e : edges) {
+ Collection<Edge<?>> edges = v.getEdges();
+ for (Edge<?> e : edges) {
if (e.getDirection() == barDirection) {
- Vertex currentVertex = e.getOppositeVertex(v);
- Edge prevEdge = e;
+ Vertex<?> currentVertex = e.getOppositeVertex(v);
+ Edge<?> prevEdge = e;
boolean terminate = false;
while (!oppositeVertices.contains(currentVertex) &&
!additionalVertices.contains(currentVertex) &&
!skippedVertices.contains(currentVertex)) {
- if (!containsReverseEdge(currentVertex, new HashSet<Edge>()) &&
+ if (!containsReverseEdge(currentVertex, new HashSet<Edge<?>>()) &&
!reachableToParentVertex(currentVertex, parentVertices,
- new HashSet<Edge>())) {
+ new HashSet<Edge<?>>())) {
additionalVertices.add(currentVertex);
prevVertices.add(currentVertex);
boolean found = false;
- Collection<Edge> nextEdges = currentVertex.getEdges();
- for (Edge nextEdge : nextEdges) {
+ Collection<Edge<?>> nextEdges = currentVertex.getEdges();
+ for (Edge<?> nextEdge : nextEdges) {
if (nextEdge != prevEdge &&
nextEdge.getDirection() == barDirection) {
currentVertex = nextEdge.getOppositeVertex(currentVertex);
@@ -179,14 +179,14 @@ public class DirectionalGraph {
* @param v
* @return
*/
- private Set<Vertex> computeParentVertices(Vertex v) {
- HashSet<Vertex> parentVertices = new HashSet<Vertex>();
+ private Set<Vertex<?>> computeParentVertices(Vertex<?> v) {
+ Set<Vertex<?>> parentVertices = new HashSet<>();
- Edge reverseEdge = reverseEdges.get(v);
- Vertex currentVertex = v;
+ Edge<?> reverseEdge = reverseEdges.get(v);
+ Vertex<?> currentVertex = v;
while (reverseEdge != null) {
- Vertex parentVertex = reverseEdge.getOppositeVertex(currentVertex);
+ Vertex<?> parentVertex = reverseEdge.getOppositeVertex(currentVertex);
parentVertices.add(parentVertex);
currentVertex = parentVertex;
reverseEdge = reverseEdges.get(currentVertex);
@@ -201,10 +201,10 @@ public class DirectionalGraph {
* @param visitedEdges
* @return
*/
- private boolean containsReverseEdge(Vertex v, Set<Edge> visitedEdges) {
+ private boolean containsReverseEdge(Vertex<?> v, Set<Edge<?>> visitedEdges) {
- Collection<Edge> edges = v.getEdges();
- for (Edge e : edges) {
+ Collection<Edge<?>> edges = v.getEdges();
+ for (Edge<?> e : edges) {
if (e.getDirection() == direction &&
!visitedEdges.contains(e)) {
//Logger.log (1, "e = " + e);
@@ -227,14 +227,14 @@ public class DirectionalGraph {
* @param visitedEdges
* @return
*/
- private boolean reachableToParentVertex(Vertex v, Set<Vertex> parentVertices,
- Set<Edge> visitedEdges) {
+ private boolean reachableToParentVertex(Vertex<?> v, Set<Vertex<?>> parentVertices,
+ Set<Edge<?>> visitedEdges) {
- Collection<Edge> edges = v.getEdges();
- for (Edge e : edges) {
+ Collection<Edge<?>> edges = v.getEdges();
+ for (Edge<?> e : edges) {
if (e.getDirection() == direction && !visitedEdges.contains(e)) {
visitedEdges.add(e);
- Vertex w = e.getOppositeVertex(v);
+ Vertex<?> w = e.getOppositeVertex(v);
if (checkSideway(w, parentVertices, visitedEdges) ||
reachableToParentVertex(w, parentVertices, visitedEdges)) {
@@ -253,24 +253,24 @@ public class DirectionalGraph {
* @param visitedEdges
* @return
*/
- private boolean checkSideway(Vertex v, Set<Vertex> parentVertices,
- Set<Edge> visitedEdges) {
+ private boolean checkSideway(Vertex<?> v, Set<Vertex<?>> parentVertices,
+ Set<Edge<?>> visitedEdges) {
- Collection<Edge> edges = v.getEdges();
- for (Edge e : edges) {
+ Collection<Edge<?>> edges = v.getEdges();
+ for (Edge<?> e : edges) {
if (e.getDirection() == barDirection &&
!visitedEdges.contains(e)) {
visitedEdges.add(e);
- Vertex currentVertex = e.getOppositeVertex(v);
+ Vertex<?> currentVertex = e.getOppositeVertex(v);
while (true) {
if (parentVertices.contains(currentVertex)) {
return true;
}
- Edge nextEdge = null;
- Collection<Edge> edges2 = currentVertex.getEdges();
- for (Edge ce : edges2) {
+ Edge<?> nextEdge = null;
+ Collection<Edge<?>> edges2 = currentVertex.getEdges();
+ for (Edge<?> ce : edges2) {
if (ce.getDirection() == barDirection &&
!visitedEdges.contains(ce)) {
visitedEdges.add(ce);
@@ -297,7 +297,7 @@ public class DirectionalGraph {
* @param parentBar
* @return
*/
- private Bar createBar(Vertex vertex, Bar parentBar) {
+ private Bar createBar(Vertex<?> vertex, Bar parentBar) {
Bar bar = barMap.get(vertex);
if (bar == null) {
@@ -306,19 +306,19 @@ public class DirectionalGraph {
bar.addVertex(vertex);
barMap.put(vertex, bar);
- Collection<Edge> edges = vertex.getEdges();
- for (Edge edge : edges) {
+ Collection<Edge<?>> edges = vertex.getEdges();
+ for (Edge<?> edge : edges) {
if (edge.getDirection() == barDirection) {
- Vertex currentVertex = edge.getOppositeVertex(vertex);
- Edge prevEdge = edge;
+ Vertex<?> currentVertex = edge.getOppositeVertex(vertex);
+ Edge<?> prevEdge = edge;
while (true) {
bar.addVertex(currentVertex);
barMap.put(currentVertex, bar);
- Edge foundEdge = null;
+ Edge<?> foundEdge = null;
- Collection<Edge> edges2 = currentVertex.getEdges();
- for (Edge e : edges2) {
+ Collection<Edge<?>> edges2 = currentVertex.getEdges();
+ for (Edge<?> e : edges2) {
if (e != prevEdge &&
e.getDirection() == barDirection) {
foundEdge = e;
@@ -336,9 +336,9 @@ public class DirectionalGraph {
}
}
- for (Vertex v : bar.getVertices()) {
- Collection<Edge> edges2 = v.getEdges();
- for (Edge e : edges2) {
+ for (Vertex<?> v : bar.getVertices()) {
+ Collection<Edge<?>> edges2 = v.getEdges();
+ for (Edge<?> e : edges2) {
if (e.getDirection() == direction &&
forwardEdges.get(v) == e &&
!visitedEdges.contains(e)) {
@@ -368,18 +368,18 @@ public class DirectionalGraph {
* @param cornerVertex
* @return
*/
- private Collection<Vertex> getRootVertices(Vertex cornerVertex) {
- ArrayList<Vertex> rootVertices = new ArrayList<Vertex>();
+ private Collection<Vertex<?>> getRootVertices(Vertex<?> cornerVertex) {
+ ArrayList<Vertex<?>> rootVertices = new ArrayList<>();
- Vertex currentVertex = cornerVertex;
- Edge prevEdge = null;
+ Vertex<?> currentVertex = cornerVertex;
+ Edge<?> prevEdge = null;
rootVertices.add(cornerVertex);
while (true) {
- Edge foundEdge = null;
+ Edge<?> foundEdge = null;
- Collection<Edge> edges = currentVertex.getEdges();
- for (Edge e : edges) {
+ Collection<Edge<?>> edges = currentVertex.getEdges();
+ for (Edge<?> e : edges) {
if (e != prevEdge &&
e.getDirection() == barDirection) {
foundEdge = e;
@@ -402,27 +402,27 @@ public class DirectionalGraph {
*
* @return
*/
- private Vertex getCornerVertex() {
- Vertex cornerVertex = or.getCornerVertex();
+ private Vertex<?> getCornerVertex() {
+ Vertex<N> cornerVertex = or.getCornerVertex();
if (cornerVertex != null) {
return cornerVertex;
}
- EmbeddedPlanarGraph epg = or.getOriginalGraph();
+ EmbeddedPlanarGraph<N, E> epg = or.getOriginalGraph();
Face outerFace = epg.getOuterFace();
- List<Vertex> vertices = outerFace.getVertices();
+ List<Vertex<?>> vertices = outerFace.getVertices();
- Vertex candidate1 = null;
- Vertex candidate2 = null;
- Vertex candidate3 = null;
+ Vertex<?> candidate1 = null;
+ Vertex<?> candidate2 = null;
+ Vertex<?> candidate3 = null;
- for (Vertex v : vertices) {
+ for (Vertex<?> v : vertices) {
int hEdgeCount = 0;
int vEdgeCount = 0;
- Collection<Edge> edges = v.getEdges();
- for (Edge e : edges) {
+ Collection<Edge<?>> edges = v.getEdges();
+ for (Edge<?> e : edges) {
Direction direction = e.getDirection();
if (direction == Direction.HORIZONTAL) {
@@ -534,9 +534,9 @@ public class DirectionalGraph {
/**
*
*/
- public static class Bar implements Comparable {
+ public static class Bar implements Comparable<Object> {
- private Collection<Vertex> vertices;
+ private Collection<Vertex<?>> vertices;
private Collection<Bar> neighbors;
private Direction direction;
private int number;
@@ -547,15 +547,15 @@ public class DirectionalGraph {
*/
public Bar(Direction direction) {
this.direction = direction;
- vertices = new ArrayList<Vertex>();
- neighbors = new HashSet<Bar>();
+ vertices = new ArrayList<>();
+ neighbors = new HashSet<>();
}
/**
*
* @param vertex
*/
- public void addVertex(Vertex vertex) {
+ public void addVertex(Vertex<?> vertex) {
vertices.add(vertex);
Dimension d = vertex.getSize();
@@ -582,7 +582,7 @@ public class DirectionalGraph {
*
* @return
*/
- public Collection<Vertex> getVertices() {
+ public Collection<Vertex<?>> getVertices() {
return vertices;
}
@@ -618,15 +618,12 @@ public class DirectionalGraph {
return number;
}
- /**
- *
- * @return
- */
+ @Override
public String toString() {
String s = "\t" + direction + " Bar:\n";
s = s + "\t\tNumber = " + number + "\n";
s = s + "\t\tVertices:\n";
- for (Vertex v : vertices) {
+ for (Vertex<?> v : vertices) {
s = s + "\t\t\t" + v + "\n";
}
s = s + "\t\tNeighbors =" + neighbors.size() + "\n";
@@ -638,11 +635,7 @@ public class DirectionalGraph {
return s;
}
- /**
- *
- * @param o
- * @return
- */
+ @Override
public int compareTo(Object o) {
if (!(o instanceof Bar)) {
return 0;
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/DualGraph.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/DualGraph.java
index 51900d3..1d01ffc 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/DualGraph.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/DualGraph.java
@@ -30,14 +30,14 @@ import org.netbeans.modules.visual.graph.layout.orthogonalsupport.MGraph.Vertex;
*
* @author ptliu
*/
-public class DualGraph {
+public class DualGraph<N, E> {
- private EmbeddedPlanarGraph originalGraph;
+ private EmbeddedPlanarGraph<N, E> originalGraph;
private Map<Face, FaceVertex> vertexMap;
private Collection<FaceVertex> vertices;
- private Map<Edge, FaceEdge> edgeMap;
+ private Map<Edge<?>, FaceEdge> edgeMap;
private Collection<FaceEdge> edges;
- private Collection<Edge> edgesToIgnore;
+ private Collection<Edge<?>> edgesToIgnore;
private Collection<Face> facesToIgnore;
/**
@@ -47,10 +47,10 @@ public class DualGraph {
* @param edgesToIgnore
* @return
*/
- public static DualGraph createGraph(EmbeddedPlanarGraph graph,
+ public static <N, E> DualGraph<N, E> createGraph(EmbeddedPlanarGraph<N, E> graph,
Collection<Face> facesToIgnore,
- Collection<Edge> edgesToIgnore) {
- DualGraph dualGraph = new DualGraph(graph, facesToIgnore, edgesToIgnore);
+ Collection<Edge<?>> edgesToIgnore) {
+ DualGraph<N, E> dualGraph = new DualGraph<>(graph, facesToIgnore, edgesToIgnore);
dualGraph.createGraph();
return dualGraph;
@@ -62,16 +62,16 @@ public class DualGraph {
* @param facesToIgnore
* @param edgesToIgnore
*/
- private DualGraph(EmbeddedPlanarGraph graph, Collection<Face> facesToIgnore,
- Collection<Edge> edgesToIgnore) {
+ private DualGraph(EmbeddedPlanarGraph<N, E> graph, Collection<Face> facesToIgnore,
+ Collection<Edge<?>> edgesToIgnore) {
this.originalGraph = graph;
this.facesToIgnore = facesToIgnore;
this.edgesToIgnore = edgesToIgnore;
- vertexMap = new HashMap<Face, FaceVertex>();
- vertices = new ArrayList<FaceVertex>();
- edgeMap = new HashMap<Edge, FaceEdge>();
- edges = new ArrayList<FaceEdge>();
+ vertexMap = new HashMap<>();
+ vertices = new ArrayList<>();
+ edgeMap = new HashMap<>();
+ edges = new ArrayList<>();
}
/**
@@ -103,7 +103,7 @@ public class DualGraph {
if (fv == gv) {
continue;
}
- for (Edge e : fv.getFace().getEdges()) {
+ for (Edge<?> e : fv.getFace().getEdges()) {
if (edgesToIgnore.contains(e)) {
continue;
}
@@ -150,7 +150,7 @@ public class DualGraph {
*
* @return
*/
- public EmbeddedPlanarGraph getOriginalGraph() {
+ public EmbeddedPlanarGraph<N, E> getOriginalGraph() {
return originalGraph;
}
@@ -194,7 +194,7 @@ public class DualGraph {
* @param e
* @return
*/
- private FaceEdge getEdge(FaceVertex f, FaceVertex g, Edge e) {
+ private FaceEdge getEdge(FaceVertex f, FaceVertex g, Edge<?> e) {
FaceEdge edge = edgeMap.get(e);
if (edge == null) {
@@ -211,8 +211,8 @@ public class DualGraph {
* @param e
* @return
*/
- public Collection<FaceVertex> getVerticesBorderingEdge(Edge e) {
- Collection<FaceVertex> result = new ArrayList<FaceVertex>();
+ public Collection<FaceVertex> getVerticesBorderingEdge(Edge<?> e) {
+ Collection<FaceVertex> result = new ArrayList<>();
for (FaceVertex v : getVertices()) {
if (v.getFace().containsEdge(e)) {
@@ -223,10 +223,7 @@ public class DualGraph {
return result;
}
- /**
- *
- * @return
- */
+ @Override
public String toString() {
String s = "DualGraph:\n";
@@ -246,7 +243,7 @@ public class DualGraph {
/**
*
*/
- public class FaceVertex {
+ public static class FaceVertex {
private Face face;
private Collection<FaceEdge> edges;
@@ -286,10 +283,7 @@ public class DualGraph {
}
}
- /**
- *
- * @return
- */
+ @Override
public String toString() {
return "FaceVertex: " + face.toString();
}
@@ -298,11 +292,11 @@ public class DualGraph {
/**
*
*/
- public class FaceEdge {
+ public static class FaceEdge {
private FaceVertex f;
private FaceVertex g;
- private Edge edge;
+ private Edge<?> edge;
/**
*
@@ -310,7 +304,7 @@ public class DualGraph {
* @param g
* @param e
*/
- public FaceEdge(FaceVertex f, FaceVertex g, Edge e) {
+ public FaceEdge(FaceVertex f, FaceVertex g, Edge<?> e) {
this.f = f;
this.g = g;
this.edge = e;
@@ -336,7 +330,7 @@ public class DualGraph {
*
* @return
*/
- public Edge getEdge() {
+ public Edge<?> getEdge() {
return edge;
}
@@ -369,7 +363,7 @@ public class DualGraph {
* @param v
* @return
*/
- public FaceVertex getVertex(Vertex v) {
+ public FaceVertex getVertex(Vertex<?> v) {
if (f.face.containsVertex(v)) {
return f;
}
@@ -379,10 +373,6 @@ public class DualGraph {
return null;
}
- /**
- *
- * @return
- */
@Override
public String toString() {
String s = "FaceEdge:\n";
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/EmbeddedPlanarGraph.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/EmbeddedPlanarGraph.java
index 454b3a0..956b4ac 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/EmbeddedPlanarGraph.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/EmbeddedPlanarGraph.java
@@ -26,9 +26,9 @@ import org.netbeans.modules.visual.graph.layout.orthogonalsupport.Face.Dart;
*
* @author ptliu
*/
-public class EmbeddedPlanarGraph {
+public class EmbeddedPlanarGraph<N, E> {
- private MGraph originalGraph;
+ private MGraph<N, E> originalGraph;
private ArrayList<Face> faces;
/**
@@ -36,24 +36,24 @@ public class EmbeddedPlanarGraph {
* @param graph
* @return
*/
- public static EmbeddedPlanarGraph createGraph(MGraph graph) {
- return new EmbeddedPlanarGraph(graph);
+ public static <N, E> EmbeddedPlanarGraph<N, E> createGraph(MGraph<N, E> graph) {
+ return new EmbeddedPlanarGraph<>(graph);
}
/**
*
* @param graph
*/
- private EmbeddedPlanarGraph(MGraph graph) {
+ private EmbeddedPlanarGraph(MGraph<N, E> graph) {
this.originalGraph = graph;
- faces = new ArrayList<Face>();
+ faces = new ArrayList<>();
}
/**
*
* @return
*/
- public MGraph getOriginalGraph() {
+ public MGraph<N, E> getOriginalGraph() {
return originalGraph;
}
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/Face.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/Face.java
index 303b5e9..953ab176 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/Face.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/Face.java
@@ -36,8 +36,8 @@ import org.netbeans.modules.visual.graph.layout.orthogonalsupport.MGraph.Vertex;
*/
public class Face {
- private List<Edge> edges;
- private Set<Edge> edgeMap;
+ private List<Edge<?>> edges;
+ private Set<Edge<?>> edgeMap;
private List<Dart> darts;
private Set<Dart> dartMap;
private Map<Dart, Integer> dartIndices;
@@ -47,11 +47,11 @@ public class Face {
*
*/
public Face() {
- edges = new ArrayList<Edge>();
- edgeMap = new HashSet<Edge>();
- darts = new ArrayList<Dart>();
- dartMap = new HashSet<Dart>();
- dartIndices = new HashMap<Dart, Integer>();
+ edges = new ArrayList<>();
+ edgeMap = new HashSet<>();
+ darts = new ArrayList<>();
+ dartMap = new HashSet<>();
+ dartIndices = new HashMap<>();
}
/**
@@ -82,8 +82,8 @@ public class Face {
*
* @return
*/
- public List<Vertex> getVertices() {
- List<Vertex> vertices = new ArrayList<Vertex>();
+ public List<Vertex<?>> getVertices() {
+ List<Vertex<?>> vertices = new ArrayList<>();
List<Dart> _darts = getDarts();
for (Dart dart : _darts) {
@@ -97,7 +97,7 @@ public class Face {
*
* @param edge
*/
- public void addEdge(Edge edge) {
+ public void addEdge(Edge<?> edge) {
edgeMap.add(edge);
edges.add(edge);
}
@@ -106,7 +106,7 @@ public class Face {
*
* @param newEdges
*/
- public void addEdges(Collection<Edge> newEdges) {
+ public void addEdges(Collection<Edge<?>> newEdges) {
this.edges.addAll(newEdges);
this.edgeMap.addAll(newEdges);
}
@@ -116,7 +116,7 @@ public class Face {
* @param index
* @param newEdge
*/
- private void addEdge(int index, Edge newEdge) {
+ private void addEdge(int index, Edge<?> newEdge) {
edges.add(index, newEdge);
edgeMap.add(newEdge);
}
@@ -125,7 +125,7 @@ public class Face {
*
* @param edgeToRemove
*/
- private void removeEdge(Edge edgeToRemove) {
+ private void removeEdge(Edge<?> edgeToRemove) {
edges.remove(edgeToRemove);
// It's possible to have two entries of the same edge.
@@ -139,7 +139,7 @@ public class Face {
* @param index
*/
private void removeEdge(int index) {
- Edge removedEdge = edges.remove(index);
+ Edge<?> removedEdge = edges.remove(index);
// It's possible to have two entries of the same edge.
if (!edges.contains(removedEdge)) {
@@ -151,7 +151,7 @@ public class Face {
*
* @return
*/
- public List<Edge> getEdges() {
+ public List<Edge<?>> getEdges() {
return Collections.unmodifiableList(edges);
}
@@ -160,8 +160,8 @@ public class Face {
* @param face
* @return
*/
- public Edge getBorderingEdge(Face face) {
- for (Edge e : face.getEdges()) {
+ public Edge<?> getBorderingEdge(Face face) {
+ for (Edge<?> e : face.getEdges()) {
if (edgeMap.contains(e)) {
return e;
}
@@ -176,20 +176,20 @@ public class Face {
* @param newEdges
* @return
*/
- public List<Dart> replaceEdge(Edge edgeToReplace, Collection<Edge> newEdges) {
- HashSet<Edge> newEdgeSet = new HashSet<Edge>(newEdges);
- ArrayList<Dart> newDarts = new ArrayList<Dart>();
+ public List<Dart> replaceEdge(Edge<?> edgeToReplace, Collection<Edge<?>> newEdges) {
+ HashSet<Edge<?>> newEdgeSet = new HashSet<>(newEdges);
+ ArrayList<Dart> newDarts = new ArrayList<>();
Dart dartToReplace = getDart(edgeToReplace);
- Vertex v = dartToReplace.getV();
- Vertex w = dartToReplace.getW();
+ Vertex<?> v = dartToReplace.getV();
+ Vertex<?> w = dartToReplace.getW();
int index = getDartIndex(dartToReplace);
removeEdge(index);
removeDart(index);
while (v != w) {
- Edge newEdge = searchAndRemoveEdge(v, newEdgeSet);
- Vertex ov = newEdge.getOppositeVertex(v);
+ Edge<?> newEdge = searchAndRemoveEdge(v, newEdgeSet);
+ Vertex<?> ov = newEdge.getOppositeVertex(v);
Dart newDart = new Dart(v, ov, newEdge);
addEdge(index, newEdge);
@@ -208,19 +208,19 @@ public class Face {
* @param newEdges
* @return
*/
- public List<Dart> replaceDart(Dart dartToReplace, Collection<Edge> newEdges) {
- HashSet<Edge> newEdgeSet = new HashSet<Edge>(newEdges);
- ArrayList<Dart> newDarts = new ArrayList<Dart>();
- Vertex v = dartToReplace.getV();
- Vertex w = dartToReplace.getW();
+ public List<Dart> replaceDart(Dart dartToReplace, Collection<Edge<?>> newEdges) {
+ HashSet<Edge<?>> newEdgeSet = new HashSet<>(newEdges);
+ ArrayList<Dart> newDarts = new ArrayList<>();
+ Vertex<?> v = dartToReplace.getV();
+ Vertex<?> w = dartToReplace.getW();
int index = getDartIndex(dartToReplace);
removeEdge(index);
removeDart(index);
while (v != w) {
- Edge newEdge = searchAndRemoveEdge(v, newEdgeSet);
- Vertex ov = newEdge.getOppositeVertex(v);
+ Edge<?> newEdge = searchAndRemoveEdge(v, newEdgeSet);
+ Vertex<?> ov = newEdge.getOppositeVertex(v);
Dart newDart = new Dart(v, ov, newEdge);
addEdge(index, newEdge);
addDart(index, newDart);
@@ -237,7 +237,7 @@ public class Face {
* @param edgeToAdd
* @return
*/
- public List<Dart> replaceDarts(Edge edgeToAdd) {
+ public List<Dart> replaceDarts(Edge<?> edgeToAdd) {
return replaceDarts(edgeToAdd, null);
}
@@ -247,10 +247,10 @@ public class Face {
* @param startingVertex
* @return
*/
- public List<Dart> replaceDarts(Edge edgeToAdd, Vertex startingVertex) {
- ArrayList<Dart> removedDarts = new ArrayList<Dart>();
- Vertex v = null;
- Vertex w = null;
+ public List<Dart> replaceDarts(Edge<?> edgeToAdd, Vertex<?> startingVertex) {
+ ArrayList<Dart> removedDarts = new ArrayList<>();
+ Vertex<?> v = null;
+ Vertex<?> w = null;
if (startingVertex == null) {
v = edgeToAdd.getV();
@@ -296,10 +296,10 @@ public class Face {
* @param edges
* @return
*/
- private Edge searchAndRemoveEdge(Vertex v, Collection<Edge> edges) {
- Edge edge = null;
+ private Edge<?> searchAndRemoveEdge(Vertex<?> v, Collection<Edge<?>> edges) {
+ Edge<?> edge = null;
- for (Edge e : edges) {
+ for (Edge<?> e : edges) {
if (e.contains(v)) {
edge = e;
break;
@@ -327,16 +327,16 @@ public class Face {
*
* @param startingVertex
*/
- public void createDarts(Vertex startingVertex) {
- Vertex prevVertex = null;
+ public void createDarts(Vertex<?> startingVertex) {
+ Vertex<?> prevVertex = null;
darts.clear();
dartMap.clear();
- for (Edge e : edges) {
+ for (Edge<?> e : edges) {
if (prevVertex == null) {
- Vertex v = e.getV();
- Vertex w = e.getW();
+ Vertex<?> v = e.getV();
+ Vertex<?> w = e.getW();
if (startingVertex == null) {
if (isOuterFace) {
@@ -357,7 +357,7 @@ public class Face {
}
}
- Vertex nextVertex = e.getOppositeVertex(prevVertex);
+ Vertex<?> nextVertex = e.getOppositeVertex(prevVertex);
Dart dart = new Dart(prevVertex, nextVertex, e);
addDart(dart);
@@ -439,8 +439,8 @@ public class Face {
* @param v
* @return
*/
- public List<Dart> getDartsFrom(Vertex v) {
- ArrayList<Dart> darts = new ArrayList<Dart>();
+ public List<Dart> getDartsFrom(Vertex<?> v) {
+ ArrayList<Dart> darts = new ArrayList<>();
for (Dart d : getDarts()) {
if (v == d.getV()) {
@@ -456,7 +456,7 @@ public class Face {
* @param v
* @return
*/
- public Dart getDartFrom(Vertex v) {
+ public Dart getDartFrom(Vertex<?> v) {
for (Dart d : getDarts()) {
if (v == d.getV()) {
return d;
@@ -471,8 +471,8 @@ public class Face {
* @param v
* @return
*/
- public List<Dart> getDartsTo(Vertex v) {
- ArrayList<Dart> darts = new ArrayList<Dart>();
+ public List<Dart> getDartsTo(Vertex<?> v) {
+ ArrayList<Dart> darts = new ArrayList<>();
for (Dart d : getDarts()) {
if (v == d.getW()) {
@@ -488,7 +488,7 @@ public class Face {
* @param v
* @return
*/
- public Dart getDartTo(Vertex v) {
+ public Dart getDartTo(Vertex<?> v) {
for (Dart d : getDarts()) {
if (v == d.getW()) {
return d;
@@ -503,7 +503,7 @@ public class Face {
* @param edge
* @return
*/
- public Dart getDart(Edge edge) {
+ public Dart getDart(Edge<?> edge) {
for (Dart d : getDarts()) {
if (d.getEdge() == edge) {
return d;
@@ -518,8 +518,8 @@ public class Face {
* @param edge
* @return
*/
- public List<Dart> getDarts(Edge edge) {
- ArrayList<Dart> _darts = new ArrayList<Dart>();
+ public List<Dart> getDarts(Edge<?> edge) {
+ ArrayList<Dart> _darts = new ArrayList<>();
for (Dart d : getDarts()) {
if (d.getEdge() == edge) {
@@ -536,7 +536,7 @@ public class Face {
* @param sourceVertex
* @return
*/
- public Dart getDart(Edge edge, Vertex sourceVertex) {
+ public Dart getDart(Edge<?> edge, Vertex<?> sourceVertex) {
for (Dart d : getDarts()) {
if (d.getEdge() == edge && d.getV() == sourceVertex) {
return d;
@@ -552,7 +552,7 @@ public class Face {
* @return
*/
public Dart getBorderingDart(Face face) {
- Edge edge = getBorderingEdge(face);
+ Edge<?> edge = getBorderingEdge(face);
for (Dart d : getDarts()) {
if (d.getEdge() == edge) {
@@ -568,7 +568,7 @@ public class Face {
* @param e
* @return
*/
- public boolean containsEdge(Edge e) {
+ public boolean containsEdge(Edge<?> e) {
return edgeMap.contains(e);
}
@@ -586,8 +586,8 @@ public class Face {
* @param v
* @return
*/
- public boolean containsVertex(Vertex v) {
- for (Edge e : edges) {
+ public boolean containsVertex(Vertex<?> v) {
+ for (Edge<?> e : edges) {
if (e.contains(v)) {
return true;
}
@@ -602,8 +602,8 @@ public class Face {
* @return
*/
public boolean connects(Face face) {
- for (Edge e : getEdges()) {
- for (Edge ne : face.getEdges()) {
+ for (Edge<?> e : getEdges()) {
+ for (Edge<?> ne : face.getEdges()) {
if (e.shareVertex(ne)) {
return true;
}
@@ -619,7 +619,7 @@ public class Face {
* @return
*/
public boolean borders(Face face) {
- for (Edge e : face.edges) {
+ for (Edge<?> e : face.edges) {
if (edgeMap.contains(e)) {
return true;
}
@@ -633,12 +633,12 @@ public class Face {
* @param edge
* @return
*/
- public Vertex getCornerVertex(Edge edge) {
- Edge nextEdge = getNextEdge(edge);
- Vertex v = edge.getV();
- Vertex w = edge.getW();
- Vertex nv = nextEdge.getV();
- Vertex nw = nextEdge.getW();
+ public Vertex<?> getCornerVertex(Edge<?> edge) {
+ Edge<?> nextEdge = getNextEdge(edge);
+ Vertex<?> v = edge.getV();
+ Vertex<?> w = edge.getW();
+ Vertex<?> nv = nextEdge.getV();
+ Vertex<?> nw = nextEdge.getW();
if (v == nv || v == nw) {
return v;
@@ -658,7 +658,7 @@ public class Face {
* @param e
* @return
*/
- public Edge getNextEdge(Edge e) {
+ public Edge<?> getNextEdge(Edge<?> e) {
int index = getEdgeIndex(e);
return edges.get((index + 1) % edges.size());
@@ -670,7 +670,7 @@ public class Face {
* @param e
* @return
*/
- private int getEdgeIndex(Edge e) {
+ private int getEdgeIndex(Edge<?> e) {
return edges.indexOf(e);
}
@@ -679,12 +679,12 @@ public class Face {
* @param dart
* @return
*/
- public Vertex getCornerVertex(Dart dart) {
+ public Vertex<?> getCornerVertex(Dart dart) {
Dart nextDart = getNextDart(dart);
- Vertex v = dart.getV();
- Vertex w = dart.getW();
- Vertex nv = nextDart.getV();
- Vertex nw = nextDart.getW();
+ Vertex<?> v = dart.getV();
+ Vertex<?> w = dart.getW();
+ Vertex<?> nv = nextDart.getV();
+ Vertex<?> nw = nextDart.getW();
if (v == nv || v == nw) {
return v;
@@ -725,7 +725,7 @@ public class Face {
*
*/
public void reverseDirection() {
- ArrayList<Edge> l = new ArrayList<Edge>(edges);
+ ArrayList<Edge<?>> l = new ArrayList<>(edges);
edges.clear();
edgeMap.clear();
@@ -737,10 +737,7 @@ public class Face {
dartMap.clear();
}
- /**
- *
- * @return
- */
+ @Override
public String toString() {
String s = "Face:\n";
@@ -749,7 +746,7 @@ public class Face {
}
s = s + "Edges:\n";
- for (Edge e : edges) {
+ for (Edge<?> e : edges) {
s = s + "\t" + e + "\n";
}
@@ -761,13 +758,13 @@ public class Face {
}
/**
- * The difference between a Dart and and Edge is that Dart
+ * The difference between a Dart and an Edge is that Dart
* has direction. Each edge can have two Darts going in
* the opposite direction.
*/
- public static class Dart extends Edge {
+ public static class Dart extends Edge<Object> {
- private Edge e;
+ private Edge<?> e;
/**
*
@@ -775,7 +772,7 @@ public class Face {
* @param w
* @param e
*/
- public Dart(Vertex v, Vertex w, Edge e) {
+ public Dart(Vertex<?> v, Vertex<?> w, Edge<?> e) {
super(v, w, null);
this.e = e;
@@ -785,7 +782,7 @@ public class Face {
*
* @return
*/
- public Edge getEdge() {
+ public Edge<?> getEdge() {
return e;
}
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/FlowNetwork.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/FlowNetwork.java
index 4b4ac74..55da103 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/FlowNetwork.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/FlowNetwork.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.visual.graph.layout.orthogonalsupport;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.Face.Dart;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.MGraph.Edge;
@@ -31,23 +31,23 @@ import org.netbeans.modules.visual.graph.layout.orthogonalsupport.MGraph.Vertex;
*
* @author ptliu
*/
-public class FlowNetwork {
+public class FlowNetwork<N, E> {
- private EmbeddedPlanarGraph originalGraph;
- private Map<Vertex, Node> vertexNodeMap;
- private Map<Face, Node> faceNodeMap;
- public Collection<Node> nodes;
- public Collection<Arc> arcs;
- public Node source;
- public Node sink;
+ private EmbeddedPlanarGraph<N, E> originalGraph;
+ private Map<Vertex<N>, Node<N>> vertexNodeMap;
+ private Map<Face, Node<N>> faceNodeMap;
+ public Collection<Node<N>> nodes;
+ public Collection<Arc<N>> arcs;
+ public Node<N> source;
+ public Node<N> sink;
/**
*
* @param graph
* @return
*/
- public static FlowNetwork createGraph(EmbeddedPlanarGraph graph) {
- FlowNetwork network = new FlowNetwork(graph);
+ public static <N, E> FlowNetwork<N, E> createGraph(EmbeddedPlanarGraph<N, E> graph) {
+ FlowNetwork<N, E> network = new FlowNetwork<>(graph);
network.createGraph();
return network;
@@ -57,29 +57,29 @@ public class FlowNetwork {
*
* @param graph
*/
- private FlowNetwork(EmbeddedPlanarGraph graph) {
+ private FlowNetwork(EmbeddedPlanarGraph<N, E> graph) {
this.originalGraph = graph;
- vertexNodeMap = new HashMap<Vertex, Node>();
- faceNodeMap = new HashMap<Face, Node>();
- nodes = new ArrayList<Node>();
- arcs = new ArrayList<Arc>();
+ vertexNodeMap = new HashMap<>();
+ faceNodeMap = new HashMap<>();
+ nodes = new ArrayList<>();
+ arcs = new ArrayList<>();
}
/**
*
*/
private void createGraph() {
- Collection<Vertex> vertices = originalGraph.getOriginalGraph().getVertices();
+ Collection<Vertex<N>> vertices = originalGraph.getOriginalGraph().getVertices();
Collection<Face> faces = originalGraph.getFaces();
- for (Vertex v : vertices) {
+ for (Vertex<N> v : vertices) {
- Node vn = getNode(v);
+ Node<N> vn = getNode(v);
for (Face f : faces) {
if (f.containsVertex(v)) {
- Node fn = getNode(f);
+ Node<N> fn = getNode(f);
Collection<Dart> darts = f.getDartsFrom(v);
for (Dart d : darts) {
addArc(vn, fn, d);
@@ -90,31 +90,31 @@ public class FlowNetwork {
for (Face f : faces) {
- Node fn = getNode(f);
+ Node<N> fn = getNode(f);
for (Dart d : f.getDarts()) {
Face nf = originalGraph.getOppositeFace(f, d);
- Node nfn = getNode(nf);
+ Node<N> nfn = getNode(nf);
addArc(fn, nfn, d);
}
}
// Now create source and sink
- source = new Node();
+ source = new Node<>();
source.isSource = true;
- sink = new Node();
+ sink = new Node<>();
sink.isSink = true;
int sourceProduction = 0;
int sinkProduction = 0;
- for (Node n : getNodes()) {
+ for (Node<N> n : getNodes()) {
if (n.production > 0) {
- Arc arc = addArc(source, n);
+ Arc<N> arc = addArc(source, n);
arc.capacity = n.production;
arc.cost = 0;
sourceProduction += n.production;
} else if (n.production < 0) {
- Arc arc = addArc(n, sink);
+ Arc<N> arc = addArc(n, sink);
arc.capacity = -n.production;
arc.cost = 0;
sinkProduction += n.production;
@@ -129,7 +129,7 @@ public class FlowNetwork {
*
* @return
*/
- public EmbeddedPlanarGraph getOriginalGraph() {
+ public EmbeddedPlanarGraph<N, E> getOriginalGraph() {
return originalGraph;
}
@@ -138,11 +138,11 @@ public class FlowNetwork {
* @param vertex
* @return
*/
- public Node getNode(Vertex vertex) {
- Node node = vertexNodeMap.get(vertex);
+ public Node<N> getNode(Vertex<N> vertex) {
+ Node<N> node = vertexNodeMap.get(vertex);
if (node == null) {
- node = new Node(vertex);
+ node = new Node<>(vertex);
vertexNodeMap.put(vertex, node);
nodes.add(node);
}
@@ -155,11 +155,11 @@ public class FlowNetwork {
* @param face
* @return
*/
- public Node getNode(Face face) {
- Node node = faceNodeMap.get(face);
+ public Node<N> getNode(Face face) {
+ Node<N> node = faceNodeMap.get(face);
if (node == null) {
- node = new Node(face);
+ node = new Node<>(face);
faceNodeMap.put(face, node);
nodes.add(node);
}
@@ -171,7 +171,7 @@ public class FlowNetwork {
*
* @return
*/
- public Node getSource() {
+ public Node<N> getSource() {
return source;
}
@@ -179,7 +179,7 @@ public class FlowNetwork {
*
* @return
*/
- public Node getSink() {
+ public Node<N> getSink() {
return sink;
}
@@ -190,8 +190,8 @@ public class FlowNetwork {
* @param dart
* @return
*/
- public Arc addArc(Node sourceNode, Node destNode, Dart dart) {
- Arc arc = new Arc(sourceNode, destNode, dart);
+ public Arc<N> addArc(Node<N> sourceNode, Node<N> destNode, Dart dart) {
+ Arc<N> arc = new Arc<>(sourceNode, destNode, dart);
arcs.add(arc);
return arc;
}
@@ -202,7 +202,7 @@ public class FlowNetwork {
* @param destNode
* @return
*/
- public Arc addArc(Node sourceNode, Node destNode) {
+ public Arc<N> addArc(Node<N> sourceNode, Node<N> destNode) {
return addArc(sourceNode, destNode, null);
}
@@ -210,10 +210,10 @@ public class FlowNetwork {
*
* @param arc
*/
- public void removeArc(Arc arc) {
+ public void removeArc(Arc<N> arc) {
arcs.remove(arc);
- Node node = arc.getSourceNode();
+ Node<N> node = arc.getSourceNode();
if (node != null) {
node.removeOutputArc(arc);
}
@@ -228,7 +228,7 @@ public class FlowNetwork {
*
* @return
*/
- public Collection<Node> getNodes() {
+ public Collection<Node<N>> getNodes() {
return nodes;
}
@@ -236,7 +236,7 @@ public class FlowNetwork {
*
* @return
*/
- public Collection<Arc> getArcs() {
+ public Collection<Arc<N>> getArcs() {
return arcs;
}
@@ -247,13 +247,13 @@ public class FlowNetwork {
nodes.remove(source);
nodes.remove(sink);
- ArrayList<Arc> _arcs = new ArrayList<Arc>(source.getOutputArcs());
- for (Arc a : _arcs) {
+ List<Arc<N>> _arcs = new ArrayList<>(source.getOutputArcs());
+ for (Arc<N> a : _arcs) {
removeArc(a);
}
- _arcs = new ArrayList<Arc>(sink.getInputArcs());
- for (Arc a : _arcs) {
+ _arcs = new ArrayList<>(sink.getInputArcs());
+ for (Arc<N> a : _arcs) {
removeArc(a);
}
}
@@ -267,7 +267,7 @@ public class FlowNetwork {
s = s + "Source:\n" + source + "\n";
s = s + "Sink:\n" + sink + "\n";
s = s + "Nodes:\n";
- for (Node n : nodes) {
+ for (Node<N> n : nodes) {
s = s + n + "\n";
}
@@ -277,12 +277,12 @@ public class FlowNetwork {
/**
*
*/
- public static class Node {
+ public static class Node<N> {
private Face face;
- private Vertex vertex;
- private Collection<Arc> inputArcs;
- private Collection<Arc> outputArcs;
+ private Vertex<N> vertex;
+ private Collection<Arc<N>> inputArcs;
+ private Collection<Arc<N>> outputArcs;
private int production;
private boolean isSource;
private boolean isSink;
@@ -291,8 +291,8 @@ public class FlowNetwork {
*
*/
public Node() {
- inputArcs = new ArrayList<Arc>();
- outputArcs = new ArrayList<Arc>();
+ inputArcs = new ArrayList<>();
+ outputArcs = new ArrayList<>();
}
/**
@@ -319,7 +319,7 @@ public class FlowNetwork {
*
* @param vertex
*/
- public Node(Vertex vertex) {
+ public Node(Vertex<N> vertex) {
this();
this.vertex = vertex;
@@ -332,7 +332,7 @@ public class FlowNetwork {
*
* @return
*/
- public Vertex getVertex() {
+ public Vertex<N> getVertex() {
return vertex;
}
@@ -364,7 +364,7 @@ public class FlowNetwork {
*
* @param arc
*/
- public void addInputArc(Arc arc) {
+ public void addInputArc(Arc<N> arc) {
inputArcs.add(arc);
}
@@ -372,7 +372,7 @@ public class FlowNetwork {
*
* @param arc
*/
- public void removeInputArc(Arc arc) {
+ public void removeInputArc(Arc<N> arc) {
inputArcs.remove(arc);
}
@@ -380,7 +380,7 @@ public class FlowNetwork {
*
* @param arc
*/
- public void addOutputArc(Arc arc) {
+ public void addOutputArc(Arc<N> arc) {
outputArcs.add(arc);
}
@@ -388,7 +388,7 @@ public class FlowNetwork {
*
* @param arc
*/
- public void removeOutputArc(Arc arc) {
+ public void removeOutputArc(Arc<N> arc) {
outputArcs.remove(arc);
}
@@ -396,7 +396,7 @@ public class FlowNetwork {
*
* @return
*/
- public Collection<Arc> getInputArcs() {
+ public Collection<Arc<N>> getInputArcs() {
return inputArcs;
}
@@ -404,7 +404,7 @@ public class FlowNetwork {
*
* @return
*/
- public Collection<Arc> getOutputArcs() {
+ public Collection<Arc<N>> getOutputArcs() {
return outputArcs;
}
@@ -414,9 +414,9 @@ public class FlowNetwork {
* @param dart
* @return
*/
- public Arc getArcToVia(Node node, Dart dart) {
- Edge edge = dart.getEdge();
- for (Arc arc : outputArcs) {
+ public Arc<N> getArcToVia(Node<N> node, Dart dart) {
+ Edge<?> edge = dart.getEdge();
+ for (Arc<N> arc : outputArcs) {
if (arc.getDestinationNode() == node &&
arc.getDart().getEdge() == edge) {
return arc;
@@ -474,10 +474,10 @@ public class FlowNetwork {
}
}
- public static class Arc {
+ public static class Arc<N> {
- private Node sourceNode;
- private Node destinationNode;
+ private Node<N> sourceNode;
+ private Node<N> destinationNode;
private int capacity;
private int cost;
private int flow;
@@ -490,7 +490,7 @@ public class FlowNetwork {
* @param destination
* @param dart
*/
- public Arc(Node source, Node destination, Dart dart) {
+ public Arc(Node<N> source, Node<N> destination, Dart dart) {
this.sourceNode = source;
this.destinationNode = destination;
this.dart = dart;
@@ -515,7 +515,7 @@ public class FlowNetwork {
*
* @return
*/
- public Node getSourceNode() {
+ public Node<N> getSourceNode() {
return sourceNode;
}
@@ -523,7 +523,7 @@ public class FlowNetwork {
*
* @return
*/
- public Node getDestinationNode() {
+ public Node<N> getDestinationNode() {
return destinationNode;
}
@@ -645,30 +645,30 @@ public class FlowNetwork {
}
}
- public static class ResidualFlowNetwork extends FlowNetwork {
+ public static class ResidualFlowNetwork<N, E> extends FlowNetwork<N, E> {
- private Map<Arc, ResidualArc> arcToResidualArcMap;
- private Map<Arc, ResidualArc> arcToReverseResidualArcMap;
- private FlowNetwork network;
- private Map<Node, Node> nodeMap;
+ private Map<Arc<N>, ResidualArc<N>> arcToResidualArcMap;
+ private Map<Arc<N>, ResidualArc<N>> arcToReverseResidualArcMap;
+ private FlowNetwork<N, E> network;
+ private Map<Node<N>, Node<N>> nodeMap;
/**
*
* @param network
*/
- public ResidualFlowNetwork(FlowNetwork network) {
+ public ResidualFlowNetwork(FlowNetwork<N, E> network) {
super(null);
this.network = network;
- nodeMap = new HashMap<Node, Node>();
- arcToResidualArcMap = new HashMap<Arc, ResidualArc>();
- arcToReverseResidualArcMap = new HashMap<Arc, ResidualArc>();
+ nodeMap = new HashMap<>();
+ arcToResidualArcMap = new HashMap<>();
+ arcToReverseResidualArcMap = new HashMap<>();
source = getNode(network.getSource());
source.isSource = true;
sink = getNode(network.getSink());
sink.isSink = true;
- for (Arc arc : network.getArcs()) {
+ for (Arc<N> arc : network.getArcs()) {
addResidualArc(arc);
}
}
@@ -677,17 +677,17 @@ public class FlowNetwork {
*
* @param arc
*/
- private void addResidualArc(Arc arc) {
+ private void addResidualArc(Arc<N> arc) {
// Assume all flow equals zero at the start
- Node sourceNode = getNode(arc.getSourceNode());
- Node destNode = getNode(arc.getDestinationNode());
+ Node<N> sourceNode = getNode(arc.getSourceNode());
+ Node<N> destNode = getNode(arc.getDestinationNode());
// Forward arc
- ResidualArc residualArc = new ResidualArc(sourceNode, destNode, arc, false);
+ ResidualArc<N> residualArc = new ResidualArc<>(sourceNode, destNode, arc, false);
arcToResidualArcMap.put(arc, residualArc);
// Reverse arc
- ResidualArc reverseResidualArc = new ResidualArc(destNode, sourceNode, arc, true);
+ ResidualArc<N> reverseResidualArc = new ResidualArc<>(destNode, sourceNode, arc, true);
arcToReverseResidualArcMap.put(arc, reverseResidualArc);
}
@@ -696,7 +696,7 @@ public class FlowNetwork {
* @param arc
* @return
*/
- public ResidualArc getResidualArcFromArc(Arc arc) {
+ public ResidualArc<N> getResidualArcFromArc(Arc<N> arc) {
return arcToResidualArcMap.get(arc);
}
@@ -705,7 +705,7 @@ public class FlowNetwork {
* @param arc
* @return
*/
- public ResidualArc getReverseResidualArcFromArc(Arc arc) {
+ public ResidualArc<N> getReverseResidualArcFromArc(Arc<N> arc) {
return arcToReverseResidualArcMap.get(arc);
}
@@ -714,8 +714,8 @@ public class FlowNetwork {
* @param node
* @return
*/
- private Node getNode(Node node) {
- Node residualNode = nodeMap.get(node);
+ private Node<N> getNode(Node<N> node) {
+ Node<N> residualNode = nodeMap.get(node);
if (residualNode == null) {
if (node.isVertexNode()) {
@@ -723,7 +723,7 @@ public class FlowNetwork {
} else if (node.isFaceNode()) {
residualNode = getNode(node.getFace());
} else {
- residualNode = new Node();
+ residualNode = new Node<>();
residualNode.setProduction(node.getProduction());
nodes.add(residualNode);
}
@@ -738,10 +738,10 @@ public class FlowNetwork {
/**
*
*/
- public static class ResidualArc extends Arc {
+ public static class ResidualArc<N> extends Arc<N> {
private boolean isReverse;
- private Arc arc;
+ private Arc<N> arc;
/**
*
@@ -750,8 +750,8 @@ public class FlowNetwork {
* @param arc
* @param isReverse
*/
- public ResidualArc(Node sourceNode, Node destNode,
- Arc arc, boolean isReverse) {
+ public ResidualArc(Node<N> sourceNode, Node<N> destNode,
+ Arc<N> arc, boolean isReverse) {
super(sourceNode, destNode, null);
this.isReverse = isReverse;
this.arc = arc;
@@ -777,7 +777,7 @@ public class FlowNetwork {
*
* @return
*/
- public Arc getArc() {
+ public Arc<N> getArc() {
return arc;
}
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/GTPlanarizer.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/GTPlanarizer.java
index 4035fbb..f50d1c6 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/GTPlanarizer.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/GTPlanarizer.java
@@ -22,7 +22,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Random;
+import java.util.Set;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.DualGraph.FaceEdge;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.DualGraph.FaceVertex;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.Face.Dart;
@@ -34,7 +36,7 @@ import org.netbeans.modules.visual.graph.layout.orthogonalsupport.MGraph.Vertex;
/**
*
*/
-public class GTPlanarizer {
+public class GTPlanarizer<N, E> {
private final int DEFAULT_ITERATIONS = 1;
private int maxIterations;
@@ -53,8 +55,8 @@ public class GTPlanarizer {
* @param graph
* @return
*/
- public Collection<EmbeddedPlanarGraph> planarize(MGraph graph) {
- Collection<EmbeddedPlanarGraph> epgs = createPlanarSubgraphs(graph);
+ public Collection<EmbeddedPlanarGraph<N, E>> planarize(MGraph<N, E> graph) {
+ Collection<EmbeddedPlanarGraph<N, E>> epgs = createPlanarSubgraphs(graph);
return epgs;
}
@@ -64,19 +66,19 @@ public class GTPlanarizer {
* @param graph
* @return
*/
- private Collection<EmbeddedPlanarGraph> createPlanarSubgraphs(MGraph graph) {
- Collection<Edge> LMax = null;
- Collection<Edge> RMax = null;
- Collection<Edge> BMax = null;
- ArrayList<Vertex> orderingMax = null;
+ private Collection<EmbeddedPlanarGraph<N, E>> createPlanarSubgraphs(MGraph<N, E> graph) {
+ Collection<Edge<?>> LMax = null;
+ Collection<Edge<?>> RMax = null;
+ Collection<Edge<?>> BMax = null;
+ List<Vertex<N>> orderingMax = null;
for (int i = 0; i < maxIterations; i++) {
- ArrayList<Edge> L = new ArrayList<Edge>();
- ArrayList<Edge> R = new ArrayList<Edge>();
- ArrayList<Edge> B = new ArrayList<Edge>();
+ List<Edge<?>> L = new ArrayList<>();
+ List<Edge<?>> R = new ArrayList<>();
+ List<Edge<?>> B = new ArrayList<>();
- ArrayList<Vertex> ordering = computeOrdering(graph.getVertices());
+ List<Vertex<N>> ordering = computeOrdering(graph.getVertices());
computeLRB(L, R, B, ordering);
@@ -93,20 +95,20 @@ public class GTPlanarizer {
// Restore ordering specified by orderingMax
int order = 0;
- for (Vertex v : orderingMax) {
+ for (Vertex<?> v : orderingMax) {
v.setNumber(order++);
}
- Collection<Face> leftFaces = new LinkedHashSet<Face>();
- Collection<Face> rightFaces = new LinkedHashSet<Face>();
+ Collection<Face> leftFaces = new LinkedHashSet<>();
+ Collection<Face> rightFaces = new LinkedHashSet<>();
- Collection<ArrayList<Face>> faceLists = createAllFaces(LMax, RMax,
+ Collection<List<Face>> faceLists = createAllFaces(LMax, RMax,
orderingMax, leftFaces, rightFaces);
- Collection<EmbeddedPlanarGraph> epgs = new ArrayList<EmbeddedPlanarGraph>();
+ Collection<EmbeddedPlanarGraph<N, E>> epgs = new ArrayList<>();
- for (ArrayList<Face> faceList : faceLists) {
- EmbeddedPlanarGraph epg = EmbeddedPlanarGraph.createGraph(graph);
+ for (List<Face> faceList : faceLists) {
+ EmbeddedPlanarGraph<N, E> epg = EmbeddedPlanarGraph.createGraph(graph);
epgs.add(epg);
epg.addFaces(faceList);
}
@@ -114,7 +116,7 @@ public class GTPlanarizer {
// We use the right faces for inserting the remaining edges
// because there should be less of them.
insertRemainingEdges(epgs, BMax, rightFaces, false,
- leftFaces, new HashSet<Edge>(LMax));
+ leftFaces, new HashSet<Edge<?>>(LMax));
return epgs;
}
@@ -124,29 +126,31 @@ public class GTPlanarizer {
* @param vertices
* @return
*/
- private ArrayList<Vertex> computeOrdering(Collection<Vertex> vertices) {
- ArrayList<Vertex> ordering = new ArrayList<Vertex>();
- ArrayList<Vertex> vertexArray = new ArrayList<Vertex>(vertices);
+ private List<Vertex<N>> computeOrdering(Collection<Vertex<N>> vertices) {
+ List<Vertex<N>> ordering = new ArrayList<>();
+ List<Vertex<N>> vertexArray = new ArrayList<>(vertices);
int order = 0;
//determine the lowest degree of any vertex. Creates a collection of
//vertices with this degree. Lastly, picks a random vertex with the
//lowest degree.
- Vertex v = getMinimumDegreeVertex(vertexArray);
+ Vertex<N> v = getMinimumDegreeVertex(vertexArray);
//appending v to the oredering list and setting v's "order" to order
assignOrdering(ordering, v, order++);
//now that it is added to the ordered array, remove it from the default list
vertexArray.remove(v);
- ArrayList<Vertex> candidates = new ArrayList<Vertex>();
+ List<Vertex<N>> candidates = new ArrayList<>();
while (!vertexArray.isEmpty()) {
- Collection<Vertex> neighbors = v.getNeighbors();
+ Collection<Vertex<?>> neighbors = v.getNeighbors();
- for (Vertex nv : neighbors) {
- if (vertexArray.contains(nv)) {
- candidates.add(nv);
+ for (Vertex<?> nv : neighbors) {
+ @SuppressWarnings("unchecked")
+ Vertex<N> tmp = (Vertex<N>) nv;
+ if (vertexArray.contains(tmp)) {
+ candidates.add(tmp);
}
}
@@ -169,15 +173,15 @@ public class GTPlanarizer {
* @param vertices
* @return
*/
- private Vertex getMinimumDegreeVertex(Collection<Vertex> vertices) {
+ private Vertex<N> getMinimumDegreeVertex(Collection<Vertex<N>> vertices) {
if (vertices.size() == 0) {
return null;
}
- ArrayList<Vertex> candidates = new ArrayList<Vertex>();
+ List<Vertex<N>> candidates = new ArrayList<>();
int minDegree = getMinimumDegree(vertices);
- for (Vertex v : vertices) {
+ for (Vertex<N> v : vertices) {
if (v.getDegree() == minDegree) {
candidates.add(v);
}
@@ -191,10 +195,10 @@ public class GTPlanarizer {
* @param vertices
* @return
*/
- private int getMinimumDegree(Collection<Vertex> vertices) {
+ private int getMinimumDegree(Collection<Vertex<N>> vertices) {
int minDegree = Integer.MAX_VALUE;
- for (Vertex v : vertices) {
+ for (Vertex<N> v : vertices) {
int degree = v.getDegree();
if (degree < minDegree) {
minDegree = degree;
@@ -209,7 +213,7 @@ public class GTPlanarizer {
* @param candidates
* @return
*/
- private Vertex pickVertex(ArrayList<Vertex> candidates) {
+ private Vertex<N> pickVertex(List<Vertex<N>> candidates) {
int index = 0;
if (isRandom()) {
@@ -226,13 +230,13 @@ public class GTPlanarizer {
* @param B
* @param ordering
*/
- private void computeLRB(ArrayList<Edge> L, ArrayList<Edge> R, ArrayList<Edge> B,
- ArrayList<Vertex> ordering) {
- ArrayList<Edge> edges = assignEdgeWeights(ordering);
+ private void computeLRB(List<Edge<?>> L, List<Edge<?>> R, List<Edge<?>> B,
+ List<Vertex<N>> ordering) {
+ List<Edge<?>> edges = assignEdgeWeights(ordering);
int size = edges.size();
for (int i = 0; i < size; i++) {
- Edge ie = edges.get(i);
+ Edge<?> ie = edges.get(i);
if (R.contains(ie)) {
continue;
@@ -249,7 +253,7 @@ public class GTPlanarizer {
L.add(ie);
for (int j = i + 1; j < size; j++) {
- Edge je = edges.get(j);
+ Edge<?> je = edges.get(j);
if (R.contains(je)) {
continue;
@@ -272,7 +276,7 @@ public class GTPlanarizer {
size = R.size();
for (int i = 0; i < size; i++) {
- Edge ie = R.get(i);
+ Edge<?> ie = R.get(i);
if (B.contains(ie)) {
continue;
@@ -287,7 +291,7 @@ public class GTPlanarizer {
}
for (int j = i + 1; j < size; j++) {
- Edge je = R.get(j);
+ Edge<?> je = R.get(j);
if (B.contains(je)) {
continue;
@@ -315,35 +319,34 @@ public class GTPlanarizer {
* @param vertices
* @return
*/
- private ArrayList<Edge> assignEdgeWeights(Collection<Vertex> vertices) {
- LinkedHashSet<Edge> edges = new LinkedHashSet<Edge>();
+ private List<Edge<?>> assignEdgeWeights(Collection<Vertex<N>> vertices) {
+ Set<Edge<?>> edges = new LinkedHashSet<>();
// First create all the edges
- for (Vertex v : vertices) {
- Collection<Edge> localEdges = v.getEdges();
- for (Edge e : localEdges) {
+ for (Vertex<?> v : vertices) {
+ Collection<Edge<?>> localEdges = v.getEdges();
+ for (Edge<?> e : localEdges) {
edges.add(e);
}
}
if (!isRandom) {
- return new ArrayList<Edge>(edges);
+ return new ArrayList<>(edges);
} else {
// Randomly assign a weight to each edge
int size = edges.size();
- for (Edge e : edges) {
+ for (Edge<?> e : edges) {
e.setWeight(0); //random.nextInt(size));
-
}
// Sort the edges by weight
- ArrayList<Edge> sortedEdges = new ArrayList<Edge>(edges);
+ List<Edge<?>> sortedEdges = new ArrayList<>(edges);
for (int i = 0; i < size - 2; i++) {
- Edge ie = sortedEdges.get(i);
+ Edge<?> ie = sortedEdges.get(i);
for (int j = i + 1; j < size - 1; j++) {
- Edge je = sortedEdges.get(j);
+ Edge<?> je = sortedEdges.get(j);
if (je.getWeight() < ie.getWeight()) {
sortedEdges.set(i, je);
sortedEdges.set(j, ie);
@@ -362,7 +365,7 @@ public class GTPlanarizer {
* @param v
* @param order
*/
- private void assignOrdering(ArrayList<Vertex> ordering, Vertex v, int order) {
+ private void assignOrdering(List<Vertex<N>> ordering, Vertex<N> v, int order) {
// assume vertices are added in order
ordering.add(v);
v.setNumber(order);
@@ -377,10 +380,10 @@ public class GTPlanarizer {
* @param rightFaces
* @return
*/
- private Collection<ArrayList<Face>> createAllFaces(Collection<Edge> L,
- Collection<Edge> R, ArrayList<Vertex> ordering,
+ private Collection<List<Face>> createAllFaces(Collection<Edge<?>> L,
+ Collection<Edge<?>> R, List<Vertex<N>> ordering,
Collection<Face> leftFaces, Collection<Face> rightFaces) {
- ArrayList<Face> faces = new ArrayList<Face>();
+ List<Face> faces = new ArrayList<>();
leftFaces.addAll(createFaces(L, null, ordering, false));
rightFaces.addAll(createFaces(R, L, ordering, true));
@@ -388,8 +391,8 @@ public class GTPlanarizer {
faces.addAll(rightFaces);
removeFaces(faces);
- Collection<ArrayList<Face>> faceLists = computeFaceLists(faces);
- for (ArrayList<Face> faceList : faceLists) {
+ Collection<List<Face>> faceLists = computeFaceLists(faces);
+ for (List<Face> faceList : faceLists) {
Face outerFace = createOuterFace(faceList, L, R);
faceList.add(0, outerFace);
@@ -406,18 +409,18 @@ public class GTPlanarizer {
* @param faces
* @return
*/
- private Collection<ArrayList<Face>> computeFaceLists(ArrayList<Face> faces) {
- Collection<ArrayList<Face>> faceLists = new ArrayList<ArrayList<Face>>();
- faces = new ArrayList<Face>(faces);
+ private Collection<List<Face>> computeFaceLists(List<Face> faces) {
+ Collection<List<Face>> faceLists = new ArrayList<>();
+ faces = new ArrayList<>(faces);
while (!faces.isEmpty()) {
- ArrayList<Face> faceList = new ArrayList<Face>();
+ List<Face> faceList = new ArrayList<>();
faceLists.add(faceList);
Face firstFace = faces.remove(0);
faceList.add(firstFace);
for (int i = 0; i < faceList.size(); i++) {
- Collection<Face> connectedFaces = new ArrayList<Face>();
+ Collection<Face> connectedFaces = new ArrayList<>();
Face iface = faceList.get(i);
for (int j = 0; j < faces.size(); j++) {
@@ -443,14 +446,13 @@ public class GTPlanarizer {
* @param R
* @return
*/
- private Face createOuterFace(ArrayList<Face> faces, Collection<Edge> L,
- Collection<Edge> R) {
- HashSet<Edge> sharedEdges = new HashSet<Edge>();
- HashSet<Dart> outerDarts = new LinkedHashSet<Dart>();
- HashSet<Edge> outerEdges = new HashSet<Edge>();
- ArrayList<Dart> reverseDarts = new ArrayList<Dart>();
- HashSet<Edge> reverseEdges = new HashSet<Edge>();
- HashSet<Edge> leftEdges = new HashSet<Edge>(L);
+ private Face createOuterFace(List<Face> faces, Collection<Edge<?>> L,
+ Collection<Edge<?>> R) {
+ Set<Edge<?>> sharedEdges = new HashSet<>();
+ Set<Dart> outerDarts = new LinkedHashSet<>();
+ Set<Edge<?>> outerEdges = new HashSet<>();
+ List<Dart> reverseDarts = new ArrayList<>();
+ Set<Edge<?>> reverseEdges = new HashSet<>();
int size = faces.size();
Dart firstDart = null;
@@ -461,7 +463,7 @@ public class GTPlanarizer {
for (Dart d : f.getDarts()) {
- Edge e = d.getEdge();
+ Edge<?> e = d.getEdge();
boolean isSharedEdge = false;
if (sharedEdges.contains(e)) {
@@ -499,7 +501,7 @@ public class GTPlanarizer {
Face outerFace = new Face();
outerFace.setOuterFace(true);
- Vertex v = firstDart.getV();
+ Vertex<?> v = firstDart.getV();
outerDarts.remove(firstDart);
outerFace.addEdge(firstDart.getEdge());
@@ -539,14 +541,14 @@ public class GTPlanarizer {
if (nextDart == null) {
nextDart = cd;
} else {
- Vertex cw = null;
+ Vertex<?> cw = null;
if (cd.getW().getNumber() > cd.getV().getNumber()) {
cw = cd.getW();
} else {
cw = cd.getV();
}
- Vertex nw = null;
+ Vertex<?> nw = null;
if (nextDart.getW().getNumber() > nextDart.getV().getNumber()) {
nw = nextDart.getW();
} else {
@@ -589,20 +591,20 @@ public class GTPlanarizer {
* @param reverseDirection
* @return
*/
- private Collection<Face> createFaces(Collection<Edge> subgraph,
- Collection<Edge> alternateSubgraph,
- ArrayList<Vertex> ordering, boolean reverseDirection) {
+ private Collection<Face> createFaces(Collection<Edge<?>> subgraph,
+ Collection<Edge<?>> alternateSubgraph,
+ List<Vertex<N>> ordering, boolean reverseDirection) {
Collection<Face> faces = new ArrayList<Face>(); //new HashSet<Face>();
- for (Vertex v : ordering) {
- Collection<Edge> connEdges = getIncidentEdges(v, subgraph);
+ for (Vertex<N> v : ordering) {
+ Collection<Edge<?>> connEdges = getIncidentEdges(v, subgraph);
while (!connEdges.isEmpty()) {
int maxOrder = v.getNumber();
- Edge maxEdge = null;
+ Edge<?> maxEdge = null;
- for (Edge e : connEdges) {
- Vertex w = e.getOppositeVertex(v);
+ for (Edge<?> e : connEdges) {
+ Vertex<?> w = e.getOppositeVertex(v);
int order = w.getNumber();
if (order > maxOrder) {
maxOrder = order;
@@ -616,7 +618,7 @@ public class GTPlanarizer {
connEdges.remove(maxEdge);
- Collection<Edge> shortestPath = computeShortedReturnPath(v,
+ Collection<Edge<?>> shortestPath = computeShortedReturnPath(v,
maxEdge.getOppositeVertex(v), maxEdge, subgraph,
alternateSubgraph);
@@ -657,22 +659,22 @@ public class GTPlanarizer {
* @param alternateEdges
* @return
*/
- private Collection<Edge> computeShortedReturnPath(Vertex sourceVertex,
- Vertex currentVertex, Edge currentEdge,
- Collection<Edge> edges, Collection<Edge> alternateEdges) {
+ private Collection<Edge<?>> computeShortedReturnPath(Vertex<?> sourceVertex,
+ Vertex<?> currentVertex, Edge<?> currentEdge,
+ Collection<Edge<?>> edges, Collection<Edge<?>> alternateEdges) {
- Collection<Edge> result = new ArrayList<Edge>();
- Collection<Edge> connEdges = getIncidentEdges(currentVertex, edges);
+ Collection<Edge<?>> result = new ArrayList<>();
+ Collection<Edge<?>> connEdges = getIncidentEdges(currentVertex, edges);
connEdges.remove(currentEdge);
int sourceOrder = sourceVertex.getNumber();
int currentOrder = currentVertex.getNumber();
- Edge edge = null;
+ Edge<?> edge = null;
int minOrder = currentOrder;
boolean lowerOrderFound = false;
- for (Edge e : connEdges) {
- Vertex w = e.getOppositeVertex(currentVertex);
+ for (Edge<?> e : connEdges) {
+ Vertex<?> w = e.getOppositeVertex(currentVertex);
int order = w.getNumber();
if ((order < minOrder) && (order >= sourceOrder)) {
@@ -689,8 +691,8 @@ public class GTPlanarizer {
connEdges = getIncidentEdges(currentVertex, alternateEdges);
int maxOrder = sourceOrder;
- for (Edge e : connEdges) {
- Vertex w = e.getOppositeVertex(currentVertex);
+ for (Edge<?> e : connEdges) {
+ Vertex<?> w = e.getOppositeVertex(currentVertex);
int order = w.getNumber();
if ((order >= maxOrder) && (order < currentOrder)) {
@@ -712,8 +714,8 @@ public class GTPlanarizer {
if (edge.contains(sourceVertex)) {
result.add(edge);
} else {
- Collection<Edge> shortestPath = null;
- Vertex oppositeVertex = edge.getOppositeVertex(currentVertex);
+ Collection<Edge<?>> shortestPath = null;
+ Vertex<?> oppositeVertex = edge.getOppositeVertex(currentVertex);
if (!oppositeVertex.equals(currentVertex) || !edge.equals(currentEdge)) {
shortestPath = computeShortedReturnPath(sourceVertex, oppositeVertex,
edge, edges, alternateEdges);
@@ -763,8 +765,8 @@ public class GTPlanarizer {
* @param edges
* @return
*/
- private Collection<Edge> getIncidentEdges(Vertex v, Collection<Edge> edges) {
- Collection<Edge> result = new ArrayList<Edge>(v.getEdges());
+ private Collection<Edge<?>> getIncidentEdges(Vertex<?> v, Collection<Edge<?>> edges) {
+ Collection<Edge<?>> result = new ArrayList<>(v.getEdges());
result.retainAll(edges);
return result;
@@ -779,20 +781,20 @@ public class GTPlanarizer {
* @param facesToIgnore
* @param edgesToIgnore
*/
- private void insertRemainingEdges(Collection<EmbeddedPlanarGraph> epgs,
- Collection<Edge> edgesToInsert, Collection<Face> faces,
+ private void insertRemainingEdges(Collection<EmbeddedPlanarGraph<N, E>> epgs,
+ Collection<Edge<?>> edgesToInsert, Collection<Face> faces,
boolean isLeftFaces, Collection<Face> facesToIgnore,
- Collection<Edge> edgesToIgnore) {
+ Collection<Edge<?>> edgesToIgnore) {
if (edgesToInsert.isEmpty()) {
return;
}
- for (EmbeddedPlanarGraph epg : epgs) {
- DualGraph dualGraph = DualGraph.createGraph(epg, facesToIgnore,
+ for (EmbeddedPlanarGraph<N, E> epg : epgs) {
+ DualGraph<N, E> dualGraph = DualGraph.createGraph(epg, facesToIgnore,
edgesToIgnore);
- for (Edge edge : edgesToInsert) {
+ for (Edge<?> edge : edgesToInsert) {
insertEdge(dualGraph, edge, faces, isLeftFaces);
}
@@ -806,32 +808,31 @@ public class GTPlanarizer {
* @param faces
* @param isLeftFaces
*/
- private void insertEdge(DualGraph graph, Edge edgeToInsert,
+ private void insertEdge(DualGraph<?, ?> graph, Edge<?> edgeToInsert,
Collection<Face> faces, boolean isLeftFaces) {
- EmbeddedPlanarGraph epg = graph.getOriginalGraph();
- MGraph originalGraph = epg.getOriginalGraph();
+ EmbeddedPlanarGraph<?, ?> epg = graph.getOriginalGraph();
+ MGraph<?, ?> originalGraph = epg.getOriginalGraph();
- Vertex v = edgeToInsert.getV();
- Vertex w = edgeToInsert.getW();
+ Vertex<?> v = edgeToInsert.getV();
+ Vertex<?> w = edgeToInsert.getW();
boolean reverse = false;
if (v.getNumber() < w.getNumber()) {
reverse = true;
}
- ArrayList<FaceEdge> shortestPath = computeShortestPathInDualGraph(graph, v, w,
- faces);
+ List<FaceEdge> shortestPath = computeShortestPathInDualGraph(graph, v, w, faces);
// Insert dummy vertices and edges and update the dualGraph
FaceEdge fe = null;
FaceVertex fv = null;
- Vertex currentVertex = null;
- Vertex prevVertex = v;
- Edge newEdge = null;
- Edge prevEdge = null;
- ArrayList<Edge> newFaceEdges = null;
+ Vertex<?> currentVertex = null;
+ Vertex<?> prevVertex = v;
+ Edge<?> newEdge = null;
+ Edge<?> prevEdge = null;
+ ArrayList<Edge<?>> newFaceEdges = null;
int length = shortestPath.size();
for (int i = 0; i <= length; i++) {
@@ -852,14 +853,14 @@ public class GTPlanarizer {
fe.getEdge(), DummyVertex.Type.CROSSING);
((DummyVertex) currentVertex).setNumber(Integer.MAX_VALUE);
- newFaceEdges = new ArrayList<Edge>(currentVertex.getEdges());
+ newFaceEdges = new ArrayList<>(currentVertex.getEdges());
}
newEdge = originalGraph.addDummyEdge(prevVertex, currentVertex);
- ((DummyEdge) newEdge).setOriginalEdge(edgeToInsert);
+ ((DummyEdge<?>) newEdge).setOriginalEdge(edgeToInsert);
- Vertex startingVertex = null;
+ Vertex<?> startingVertex = null;
if (isLeftFaces) {
if (reverse) {
@@ -897,14 +898,13 @@ public class GTPlanarizer {
* @param rightFaces
* @return
*/
- private Collection<FaceVertex> getIncidentFaceVertices(Vertex v,
- DualGraph graph, Collection<Face> rightFaces) {
-
- HashSet<FaceVertex> result = new LinkedHashSet<FaceVertex>();
+ private Collection<FaceVertex> getIncidentFaceVertices(Vertex<?> v,
+ DualGraph<?, ?> graph, Collection<Face> rightFaces) {
+ Set<FaceVertex> result = new LinkedHashSet<>();
FaceVertex outerFace = null;
- Collection<Edge> edges = v.getEdges();
- for (Edge e : edges) {
+ Collection<Edge<?>> edges = v.getEdges();
+ for (Edge<?> e : edges) {
Collection<FaceVertex> faceVertices = graph.getVerticesBorderingEdge(e);
for (FaceVertex fv : faceVertices) {
@@ -938,13 +938,13 @@ public class GTPlanarizer {
* @param rightFaces
* @return
*/
- private ArrayList<FaceEdge> computeShortestPathInDualGraph(DualGraph graph,
- Vertex v, Vertex w, Collection<Face> rightFaces) {
- EmbeddedPlanarGraph epg = graph.getOriginalGraph();
+ private List<FaceEdge> computeShortestPathInDualGraph(DualGraph<?, ?> graph,
+ Vertex<?> v, Vertex<?> w, Collection<Face> rightFaces) {
+ EmbeddedPlanarGraph<?, ?> epg = graph.getOriginalGraph();
Collection<FaceVertex> vFaceVertices = getIncidentFaceVertices(v, graph, rightFaces);
Collection<FaceVertex> wFaceVertices = getIncidentFaceVertices(w, graph, rightFaces);
- ArrayList<FaceEdge> shortestPath = null;
+ List<FaceEdge> shortestPath = null;
int shortestPathLength = Integer.MAX_VALUE;
for (FaceVertex vfv : vFaceVertices) {
@@ -1045,9 +1045,9 @@ public class GTPlanarizer {
* @param startingVertex
* @param faces
*/
- public void subdivide(DualGraph graph, FaceVertex fv, FaceEdge fe,
- Collection<Edge> newFaceEdges, Edge dividingEdge,
- Vertex startingVertex, Collection<Face> faces) {
+ public void subdivide(DualGraph<?, ?> graph, FaceVertex fv, FaceEdge fe,
+ Collection<Edge<?>> newFaceEdges, Edge<?> dividingEdge,
+ Vertex<?> startingVertex, Collection<Face> faces) {
Face face = fv.getFace();
face.replaceEdge(fe.getEdge(), newFaceEdges);
@@ -1066,7 +1066,7 @@ public class GTPlanarizer {
newFace.addEdge(dividingEdge);
newFace.createDarts(firstDart.getV());
- EmbeddedPlanarGraph epg = graph.getOriginalGraph();
+ EmbeddedPlanarGraph<?, ?> epg = graph.getOriginalGraph();
epg.addFace(newFace);
faces.add(newFace);
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/MGraph.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/MGraph.java
index 554c716..ff98399 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/MGraph.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/MGraph.java
@@ -34,26 +34,25 @@ import org.netbeans.api.visual.widget.Widget;
public class MGraph<N, E> {
private Collection<N> nodes;
- private Map<N, Vertex> vertexMap;
- private Map<E, Edge> edgeMap;
- private Collection<Vertex> vertices;
- private Collection<Edge> edges;
+ private Map<N, Vertex<N>> vertexMap;
+ private Map<E, Edge<E>> edgeMap;
+ private Collection<Vertex<N>> vertices;
private UniversalGraph<N, E> uGraph = null;
- private GraphScene scene = null;
+ private GraphScene<N, E> scene = null;
/**
*
* @param uGraph
* @param scene
*/
- protected MGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
+ protected MGraph(UniversalGraph<N, E> uGraph, GraphScene<N, E> scene) {
this.uGraph = uGraph;
this.scene = scene;
this.nodes = uGraph.getNodes();
- vertexMap = new HashMap<N, Vertex>();
- edgeMap = new LinkedHashMap<E, Edge>();
- vertices = new ArrayList<Vertex>();
+ vertexMap = new HashMap<>();
+ edgeMap = new LinkedHashMap<>();
+ vertices = new ArrayList<>();
DummyVertex.resetCounter();
}
@@ -64,7 +63,7 @@ public class MGraph<N, E> {
* @param scene
* @return
*/
- public static <N, E> MGraph createGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
+ public static <N, E> MGraph<N, E> createGraph(UniversalGraph<N, E> uGraph, GraphScene<N, E> scene) {
MGraph<N, E> graph = new MGraph<N, E>(uGraph, scene);
graph.createGraph();
return graph;
@@ -76,7 +75,7 @@ public class MGraph<N, E> {
protected void createGraph() {
for (N node : nodes) {
//will create a vertex if one does not exist.
- Vertex v = getVertex(node);
+ Vertex<N> v = getVertex(node);
Widget widget = scene.findWidget(node);
Rectangle bounds = widget.getBounds();
@@ -90,10 +89,10 @@ public class MGraph<N, E> {
for (E edge : nodeEdges) {
N destNode = uGraph.getEdgeTarget(edge);
- Vertex nv = getVertex(destNode);
+ Vertex<N> nv = getVertex(destNode);
// Implicitly preserve the direction of the edge
- Edge e = getEdge(edge, v, nv);
+ Edge<E> e = getEdge(edge, v, nv);
v.addNeighbor(nv);
v.addEdge(e);
nv.addEdge(e);
@@ -103,10 +102,10 @@ public class MGraph<N, E> {
nodeEdges = uGraph.findNodeEdges(node, false, true);
for (E edge : nodeEdges) {
N destNode = uGraph.getEdgeSource(edge);
- Vertex nv = getVertex(destNode);
+ Vertex<N> nv = getVertex(destNode);
// Implicitly preserve the direction of the edge.
- Edge e = getEdge(edge, nv, v);
+ Edge<E> e = getEdge(edge, nv, v);
v.addNeighbor(nv);
v.addEdge(e);
nv.addEdge(e);
@@ -118,7 +117,7 @@ public class MGraph<N, E> {
*
* @return
*/
- public Collection<Vertex> getVertices() {
+ public Collection<Vertex<N>> getVertices() {
return Collections.unmodifiableCollection(vertices);
}
@@ -126,7 +125,7 @@ public class MGraph<N, E> {
*
* @return
*/
- public Collection<Edge> getEdges() {
+ public Collection<Edge<E>> getEdges() {
return Collections.unmodifiableCollection(edgeMap.values());
}
@@ -135,8 +134,8 @@ public class MGraph<N, E> {
* @param node
* @return
*/
- protected Vertex getVertex(N node) {
- Vertex vertex = vertexMap.get(node);
+ protected Vertex<N> getVertex(N node) {
+ Vertex<N> vertex = vertexMap.get(node);
if (vertex == null) {
vertex = createVertex(node);
@@ -152,8 +151,8 @@ public class MGraph<N, E> {
* @param node
* @return
*/
- protected Vertex createVertex(N node) {
- return new Vertex(node);
+ protected Vertex<N> createVertex(N node) {
+ return new Vertex<>(node);
}
/**
@@ -163,8 +162,8 @@ public class MGraph<N, E> {
* @param w
* @return
*/
- protected Edge getEdge(E edgeDE, Vertex v, Vertex w) {
- Edge edge = edgeMap.get(edgeDE);
+ protected Edge<E> getEdge(E edgeDE, Vertex<N> v, Vertex<N> w) {
+ Edge<E> edge = edgeMap.get(edgeDE);
if (edge == null) {
edge = createEdge(v, w, edgeDE);
@@ -181,8 +180,8 @@ public class MGraph<N, E> {
* @param edgeDE
* @return
*/
- protected Edge createEdge(Vertex v, Vertex w, E edgeDE) {
- return new Edge(v, w, edgeDE);
+ protected Edge<E> createEdge(Vertex<N> v, Vertex<N> w, E edgeDE) {
+ return new Edge<>(v, w, edgeDE);
}
/**
@@ -191,24 +190,30 @@ public class MGraph<N, E> {
* @param type
* @return
*/
- public DummyVertex insertDummyVertex(Edge edge, DummyVertex.Type type) {
- Edge originalEdge = edge;
+ public DummyVertex<N> insertDummyVertex(Edge<?> edge, DummyVertex.Type type) {
+ Edge<E> originalEdge;
if (edge instanceof DummyEdge) {
- originalEdge = ((DummyEdge) edge).getOriginalEdge();
+ @SuppressWarnings("unchecked")
+ Edge<E> tmp = (Edge<E>) ((DummyEdge<?>) edge).getOriginalEdge();
+ originalEdge = tmp;
+ } else {
+ @SuppressWarnings("unchecked")
+ Edge<E> tmp = (Edge<E>) edge;
+ originalEdge = tmp;
}
- DummyVertex dv = createDummyVertex(originalEdge, type);
+ DummyVertex<N> dv = createDummyVertex(originalEdge, type);
vertices.add(dv);
- Vertex v = edge.getV();
- Vertex w = edge.getW();
+ Vertex<?> v = edge.getV();
+ Vertex<?> w = edge.getW();
v.removeEdge(edge);
v.removeNeighbor(w);
v.addNeighbor(dv);
dv.addNeighbor(v);
- DummyEdge de = createDummyEdge(v, dv, originalEdge);
+ DummyEdge<E> de = createDummyEdge(v, dv, originalEdge);
v.addEdge(de);
dv.addEdge(de);
@@ -229,8 +234,8 @@ public class MGraph<N, E> {
* @param type
* @return
*/
- protected DummyVertex createDummyVertex(Edge originalEdge, DummyVertex.Type type) {
- return new DummyVertex(originalEdge, type);
+ protected DummyVertex<N> createDummyVertex(Edge<?> originalEdge, DummyVertex.Type type) {
+ return new DummyVertex<>(originalEdge, type);
}
/**
@@ -239,8 +244,8 @@ public class MGraph<N, E> {
* @param w
* @return
*/
- public DummyEdge addDummyEdge(Vertex v, Vertex w) {
- DummyEdge de = createDummyEdge(v, w, null);
+ public DummyEdge<E> addDummyEdge(Vertex<?> v, Vertex<?> w) {
+ DummyEdge<E> de = createDummyEdge(v, w, null);
v.addEdge(de);
w.addEdge(de);
v.addNeighbor(w);
@@ -256,9 +261,9 @@ public class MGraph<N, E> {
* @param originalEdge
* @return
*/
- protected DummyEdge createDummyEdge(Vertex v, Vertex w,
- Edge originalEdge) {
- return new DummyEdge(v, w, originalEdge);
+ protected DummyEdge<E> createDummyEdge(Vertex<?> v, Vertex<?> w,
+ Edge<E> originalEdge) {
+ return new DummyEdge<>(v, w, originalEdge);
}
/**
@@ -266,8 +271,8 @@ public class MGraph<N, E> {
* @param type
* @return
*/
- public DummyVertex addDummyVertex(DummyVertex.Type type) {
- DummyVertex dv = createDummyVertex(null, type);
+ public DummyVertex<N> addDummyVertex(DummyVertex.Type type) {
+ DummyVertex<N> dv = createDummyVertex(null, type);
vertices.add(dv);
return dv;
@@ -302,8 +307,8 @@ public class MGraph<N, E> {
}
Logger.log(1, "\tneighbors:");
- Collection<Vertex> neighbors = v.getNeighbors();
- for (Vertex nv : neighbors) {
+ Collection<Vertex<?>> neighbors = v.getNeighbors();
+ for (Vertex<?> nv : neighbors) {
Logger.log(1, "\t\t" + nv);
}
@@ -311,7 +316,7 @@ public class MGraph<N, E> {
Logger.log(1, "------------------\n------------------");
count = 0;
- for (Edge e : getEdges()) {
+ for (Edge<E> e : getEdges()) {
Logger.log(1, count + ") edge = " + e);
count++;
}
@@ -324,8 +329,8 @@ public class MGraph<N, E> {
public static class Vertex<N> {
private N node;
- private Collection<Vertex> neighbors;
- private Collection<Edge> edges;
+ private Collection<Vertex<?>> neighbors;
+ private Collection<Edge<?>> edges;
private int number = -1;
private Object vertexData;
private float x;
@@ -338,8 +343,8 @@ public class MGraph<N, E> {
*/
public Vertex(N node) {
this.node = node;
- neighbors = new LinkedHashSet<Vertex>();
- edges = new LinkedHashSet<Edge>();
+ neighbors = new LinkedHashSet<>();
+ edges = new LinkedHashSet<>();
}
/**
@@ -394,7 +399,7 @@ public class MGraph<N, E> {
*
* @param vertex
*/
- public void addNeighbor(Vertex vertex) {
+ public void addNeighbor(Vertex<?> vertex) {
neighbors.add(vertex);
}
@@ -402,7 +407,7 @@ public class MGraph<N, E> {
*
* @param vertex
*/
- public void removeNeighbor(Vertex vertex) {
+ public void removeNeighbor(Vertex<?> vertex) {
neighbors.remove(vertex);
}
@@ -410,7 +415,7 @@ public class MGraph<N, E> {
*
* @return
*/
- public Collection<Vertex> getNeighbors() {
+ public Collection<Vertex<?>> getNeighbors() {
return neighbors;
}
@@ -421,8 +426,8 @@ public class MGraph<N, E> {
* @param neighbor
* @return
*/
- public Edge getEdge(Vertex neighbor) {
- for (Edge e : edges) {
+ public Edge<?> getEdge(Vertex<?> neighbor) {
+ for (Edge<?> e : edges) {
if (e.contains(neighbor)) {
return e;
}
@@ -435,7 +440,7 @@ public class MGraph<N, E> {
*
* @param edge
*/
- public void addEdge(Edge edge) {
+ public void addEdge(Edge<?> edge) {
edges.add(edge);
}
@@ -443,7 +448,7 @@ public class MGraph<N, E> {
*
* @param edge
*/
- public void removeEdge(Edge edge) {
+ public void removeEdge(Edge<?> edge) {
edges.remove(edge);
}
@@ -451,7 +456,7 @@ public class MGraph<N, E> {
*
* @return
*/
- public Collection<Edge> getEdges() {
+ public Collection<Edge<?>> getEdges() {
return edges;
}
@@ -503,10 +508,7 @@ public class MGraph<N, E> {
return vertexData;
}
- /**
- *
- * @return
- */
+ @Override
public String toString() {
return "vertex : " + node;// + " number = " + number;
@@ -522,8 +524,8 @@ public class MGraph<N, E> {
HORIZONTAL, VERTICAL, UP, DOWN, LEFT, RIGHT
}
- private Vertex v;
- private Vertex w;
+ private Vertex<?> v;
+ private Vertex<?> w;
private E edge;
private Direction direction;
private int weight;
@@ -535,7 +537,7 @@ public class MGraph<N, E> {
* @param w
* @param edge
*/
- public Edge(Vertex v, Vertex w, E edge) {
+ public Edge(Vertex<?> v, Vertex<?> w, E edge) {
this.v = v;
this.w = w;
this.edge = edge;
@@ -545,7 +547,7 @@ public class MGraph<N, E> {
*
* @return
*/
- public Vertex getV() {
+ public Vertex<?> getV() {
return v;
}
@@ -553,7 +555,7 @@ public class MGraph<N, E> {
*
* @return
*/
- public Vertex getW() {
+ public Vertex<?> getW() {
return w;
}
@@ -602,7 +604,7 @@ public class MGraph<N, E> {
* @param vertex
* @return
*/
- public boolean contains(Vertex vertex) {
+ public boolean contains(Vertex<?> vertex) {
return (this.v == vertex || this.w == vertex);
}
@@ -611,7 +613,7 @@ public class MGraph<N, E> {
* @param edge
* @return
*/
- public boolean shareVertex(Edge edge) {
+ public boolean shareVertex(Edge<?> edge) {
return contains(edge.v) || contains(edge.w);
}
@@ -620,7 +622,7 @@ public class MGraph<N, E> {
* @param vertex
* @return
*/
- public Vertex getOppositeVertex(Vertex vertex) {
+ public Vertex<?> getOppositeVertex(Vertex<?> vertex) {
if (v == vertex) {
return w;
} else if (w == vertex) {
@@ -646,10 +648,7 @@ public class MGraph<N, E> {
return direction;
}
- /**
- *
- * @return
- */
+ @Override
public String toString() {
return "edge : " + edge + "\n v = " + v + "\n w = " + w;
}
@@ -658,7 +657,7 @@ public class MGraph<N, E> {
/**
*
*/
- public static class DummyVertex extends Vertex {
+ public static class DummyVertex<N> extends Vertex<N> {
public enum Type {
@@ -666,7 +665,7 @@ public class MGraph<N, E> {
};
private static int counter = 0;
- private Edge originalEdge;
+ private Edge<?> originalEdge;
private Type type;
private int index;
@@ -675,7 +674,7 @@ public class MGraph<N, E> {
* @param originalEdge
* @param type
*/
- public DummyVertex(Edge originalEdge, Type type) {
+ public DummyVertex(Edge<?> originalEdge, Type type) {
super(null);
this.originalEdge = originalEdge;
this.type = type;
@@ -701,7 +700,7 @@ public class MGraph<N, E> {
*
* @param originalEdge
*/
- public void setOriginalEdge(Edge originalEdge) {
+ public void setOriginalEdge(Edge<?> originalEdge) {
this.originalEdge = originalEdge;
}
@@ -709,7 +708,7 @@ public class MGraph<N, E> {
*
* @return
*/
- public Edge getOriginalEdge() {
+ public Edge<?> getOriginalEdge() {
return originalEdge;
}
@@ -721,10 +720,7 @@ public class MGraph<N, E> {
return type;
}
- /**
- *
- * @return
- */
+ @Override
public String toString() {
return "dummy vertex " + index;
}
@@ -733,9 +729,9 @@ public class MGraph<N, E> {
/**
*
*/
- public static class DummyEdge extends Edge {
+ public static class DummyEdge<E> extends Edge<E> {
- private Edge originalEdge;
+ private Edge<?> originalEdge;
/**
*
@@ -743,7 +739,7 @@ public class MGraph<N, E> {
* @param w
* @param originalEdge
*/
- public DummyEdge(Vertex v, Vertex w, Edge originalEdge) {
+ public DummyEdge(Vertex<?> v, Vertex<?> w, Edge<E> originalEdge) {
super(v, w, null);
this.originalEdge = originalEdge;
}
@@ -753,7 +749,7 @@ public class MGraph<N, E> {
* @param v
* @param w
*/
- public DummyEdge(Vertex v, Vertex w) {
+ public DummyEdge(Vertex<?> v, Vertex<?> w) {
this(v, w, null);
}
@@ -761,7 +757,7 @@ public class MGraph<N, E> {
*
* @param originalEdge
*/
- public void setOriginalEdge(Edge originalEdge) {
+ public void setOriginalEdge(Edge<?> originalEdge) {
this.originalEdge = originalEdge;
}
@@ -769,14 +765,11 @@ public class MGraph<N, E> {
*
* @return
*/
- public Edge getOriginalEdge() {
+ public Edge<?> getOriginalEdge() {
return originalEdge;
}
- /**
- *
- * @return
- */
+ @Override
public String toString() {
return "dummy " + super.toString();
}
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/MinimumBendOrthogonalizer.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/MinimumBendOrthogonalizer.java
index 79cad1c..63bd444 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/MinimumBendOrthogonalizer.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/MinimumBendOrthogonalizer.java
@@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
+import java.util.Set;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.Face.Dart;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.FlowNetwork.Arc;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.FlowNetwork.Node;
@@ -50,17 +51,17 @@ public class MinimumBendOrthogonalizer {
* @param epgs
* @return
*/
- public Collection<OrthogonalRepresentation> orthogonalize(
- Collection<EmbeddedPlanarGraph> epgs) {
- Collection<OrthogonalRepresentation> ors = new ArrayList<OrthogonalRepresentation>();
+ public <N, E> Collection<OrthogonalRepresentation<N, E>> orthogonalize(
+ Collection<EmbeddedPlanarGraph<N, E>> epgs) {
+ Collection<OrthogonalRepresentation<N, E>> ors = new ArrayList<>();
- for (EmbeddedPlanarGraph epg : epgs) {
- FlowNetwork network = FlowNetwork.createGraph(epg);
+ for (EmbeddedPlanarGraph<N, E> epg : epgs) {
+ FlowNetwork<N, E> network = FlowNetwork.createGraph(epg);
computeMinimumCostFlowNetwork(network);
network.removeSourceAndSink();
- OrthogonalRepresentation or = computeOrthogonalRepresentation(network);
+ OrthogonalRepresentation<N, E> or = computeOrthogonalRepresentation(network);
ors.add(or);
}
@@ -72,15 +73,15 @@ public class MinimumBendOrthogonalizer {
*
* @param network
*/
- private void computeMinimumCostFlowNetwork(FlowNetwork network) {
- ResidualFlowNetwork residualNetwork = new ResidualFlowNetwork(network);
+ private <N, E> void computeMinimumCostFlowNetwork(FlowNetwork<N, E> network) {
+ ResidualFlowNetwork<N, E> residualNetwork = new ResidualFlowNetwork<>(network);
int totalFlow = 0;
int production = network.getSource().getProduction();
while (totalFlow < production) {
- Collection<ResidualArc> path = computeDijkstraShortestPath(residualNetwork);
+ Collection<ResidualArc<N>> path = computeDijkstraShortestPath(residualNetwork);
// Flow is blocked, we simply return;
if (path == null) {
@@ -88,7 +89,7 @@ public class MinimumBendOrthogonalizer {
}
int minFlow = Integer.MAX_VALUE;
- for (Arc arc : path) {
+ for (Arc<N> arc : path) {
int capacity = arc.getCapacity();
if (capacity < minFlow) {
minFlow = capacity;
@@ -97,10 +98,10 @@ public class MinimumBendOrthogonalizer {
totalFlow += minFlow;
- for (ResidualArc ra : path) {
- Arc arc = ra.getArc();
- ResidualArc residualArc = null;
- ResidualArc reverseResidualArc = null;
+ for (ResidualArc<N> ra : path) {
+ Arc<N> arc = ra.getArc();
+ ResidualArc<N> residualArc = null;
+ ResidualArc<N> reverseResidualArc = null;
int flow = minFlow;
if (!ra.isReverse()) {
@@ -126,26 +127,26 @@ public class MinimumBendOrthogonalizer {
* @param network
* @return
*/
- private Collection<ResidualArc> computeDijkstraShortestPath(ResidualFlowNetwork network) {
- Collection<Node> nodes = network.getNodes();
- Map<Node, ResidualArc> paths = new HashMap<Node, ResidualArc>();
- final Map<Node, Integer> distances = new HashMap<Node, Integer>();
- Node sourceNode = network.getSource();
+ private <N, E> Collection<ResidualArc<N>> computeDijkstraShortestPath(ResidualFlowNetwork<N, E> network) {
+ Collection<Node<N>> nodes = network.getNodes();
+ Map<Node<N>, ResidualArc<N>> paths = new HashMap<>();
+ final Map<Node<N>, Integer> distances = new HashMap<>();
+ Node<N> sourceNode = network.getSource();
- for (Node node : nodes) {
+ for (Node<N> node : nodes) {
distances.put(node, Integer.MAX_VALUE);
}
distances.put(sourceNode, 0);
- PriorityQueue<Node> priorityQueue = createPriorityQueue(distances);
- for (Node node : nodes) {
+ PriorityQueue<Node<N>> priorityQueue = createPriorityQueue(distances);
+ for (Node<N> node : nodes) {
priorityQueue.offer(node);
}
- HashSet<Node> visitedNodes = new HashSet<Node>();
+ Set<Node<N>> visitedNodes = new HashSet<Node<N>>();
while (priorityQueue.size() > 0) {
- Node node = priorityQueue.poll();
+ Node<N> node = priorityQueue.poll();
if (distances.get(node) == Integer.MAX_VALUE) {
continue;
@@ -153,7 +154,7 @@ public class MinimumBendOrthogonalizer {
if (visitedNodes.contains(node)) {
continue;
}
- for (Arc arc : node.getOutputArcs()) {
+ for (Arc<N> arc : node.getOutputArcs()) {
if (arc.getCapacity() > 0) {
computeRelaxation(arc, paths, distances, priorityQueue);
}
@@ -162,16 +163,16 @@ public class MinimumBendOrthogonalizer {
visitedNodes.add(node);
}
- Collection<ResidualArc> shortestPath = new ArrayList<ResidualArc>();
- Node currentNode = network.getSink();
+ Collection<ResidualArc<N>> shortestPath = new ArrayList<>();
+ Node<N> currentNode = network.getSink();
while (currentNode != sourceNode) {
- Arc arc = paths.get(currentNode);
+ Arc<N> arc = paths.get(currentNode);
if (arc == null) {
return null;
}
- shortestPath.add((ResidualArc) arc);
+ shortestPath.add((ResidualArc<N>) arc);
currentNode = arc.getSourceNode();
}
@@ -185,17 +186,17 @@ public class MinimumBendOrthogonalizer {
* @param distances
* @param queue
*/
- private void computeRelaxation(Arc arc, Map<Node, ResidualArc> paths,
- Map<Node, Integer> distances, PriorityQueue<Node> queue) {
- Node srcNode = arc.getSourceNode();
- Node destNode = arc.getDestinationNode();
+ private <N> void computeRelaxation(Arc<N> arc, Map<Node<N>, ResidualArc<N>> paths,
+ Map<Node<N>, Integer> distances, PriorityQueue<Node<N>> queue) {
+ Node<N> srcNode = arc.getSourceNode();
+ Node<N> destNode = arc.getDestinationNode();
int sd = distances.get(srcNode);
int dd = distances.get(destNode);
int cost = arc.getCost();
if (dd > sd + cost) {
distances.put(destNode, sd + cost);
- paths.put(destNode, (ResidualArc) arc);
+ paths.put(destNode, (ResidualArc<N>) arc);
// There can be multiple instance of the same node in the queue.
// This is the only way to update the queue.
@@ -208,12 +209,12 @@ public class MinimumBendOrthogonalizer {
* @param distances
* @return
*/
- private PriorityQueue<Node> createPriorityQueue(final Map<Node, Integer> distances) {
- return new PriorityQueue<Node>(
+ private <N> PriorityQueue<Node<N>> createPriorityQueue(final Map<Node<N>, Integer> distances) {
+ return new PriorityQueue<>(
distances.size(),
- new Comparator<Node>() {
+ new Comparator<Node<?>>() {
- public int compare(Node o1, Node o2) {
+ public int compare(Node<?> o1, Node<?> o2) {
int d1 = distances.get(o1);
int d2 = distances.get(o2);
@@ -238,23 +239,23 @@ public class MinimumBendOrthogonalizer {
* @param network
* @return
*/
- private OrthogonalRepresentation computeOrthogonalRepresentation(FlowNetwork network) {
- OrthogonalRepresentation or = OrthogonalRepresentation.createGraph(network.getOriginalGraph());
+ private <N, E> OrthogonalRepresentation<N, E> computeOrthogonalRepresentation(FlowNetwork<N, E> network) {
+ OrthogonalRepresentation<N, E> or = OrthogonalRepresentation.createGraph(network.getOriginalGraph());
- for (Arc arc : network.getArcs()) {
+ for (Arc<N> arc : network.getArcs()) {
if (arc.isVertexArc()) {
- Vertex v = arc.getSourceNode().getVertex();
+ Vertex<N> v = arc.getSourceNode().getVertex();
Face f = arc.getDestinationNode().getFace();
OrthogonalShape shape = or.getShape(f);
- Dart d = (Dart) arc.getDart();
+ Dart d = arc.getDart();
Tuple t = shape.getTuple(d);
t.setAngles(arc.getFlow() + 1);
} else if (arc.isFaceArc()) {
- Node srcNode = arc.getSourceNode();
- Node destNode = arc.getDestinationNode();
+ Node<N> srcNode = arc.getSourceNode();
+ Node<N> destNode = arc.getDestinationNode();
Face f = srcNode.getFace();
- Arc reverseArc = destNode.getArcToVia(srcNode, arc.getDart());
+ Arc<N> reverseArc = destNode.getArcToVia(srcNode, arc.getDart());
OrthogonalShape shape = or.getShape(f);
Dart d = arc.getDart();
Tuple t = shape.getTuple(d);
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/OrthogonalRepresentation.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/OrthogonalRepresentation.java
index eace361..3503d50 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/OrthogonalRepresentation.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/OrthogonalRepresentation.java
@@ -31,22 +31,22 @@ import org.netbeans.modules.visual.graph.layout.orthogonalsupport.MGraph.Vertex;
*
* @author ptliu
*/
-public class OrthogonalRepresentation {
+public class OrthogonalRepresentation<N, E> {
private Map<Face, OrthogonalShape> shapes;
- private EmbeddedPlanarGraph originalGraph;
- private Vertex cornerVertex;
+ private EmbeddedPlanarGraph<N, E> originalGraph;
+ private Vertex<N> cornerVertex;
- public static OrthogonalRepresentation createGraph(EmbeddedPlanarGraph graph) {
- return new OrthogonalRepresentation(graph);
+ public static <N, E> OrthogonalRepresentation<N, E> createGraph(EmbeddedPlanarGraph<N, E> graph) {
+ return new OrthogonalRepresentation<>(graph);
}
- private OrthogonalRepresentation(EmbeddedPlanarGraph graph) {
- shapes = new LinkedHashMap<Face, OrthogonalShape>();
+ private OrthogonalRepresentation(EmbeddedPlanarGraph<N, E> graph) {
+ shapes = new LinkedHashMap<>();
this.originalGraph = graph;
}
- public EmbeddedPlanarGraph getOriginalGraph() {
+ public EmbeddedPlanarGraph<N, E> getOriginalGraph() {
return originalGraph;
}
@@ -64,11 +64,11 @@ public class OrthogonalRepresentation {
return shapes.values();
}
- public void setCornerVertex(Vertex cornerVertex) {
+ public void setCornerVertex(Vertex<N> cornerVertex) {
this.cornerVertex = cornerVertex;
}
- public Vertex getCornerVertex() {
+ public Vertex<N> getCornerVertex() {
return cornerVertex;
}
@@ -83,14 +83,14 @@ public class OrthogonalRepresentation {
return s;
}
- public class OrthogonalShape {
+ public static class OrthogonalShape {
private Map<Dart, Tuple> tupleMap;
private Face face;
OrthogonalShape(Face face) {
this.face = face;
- tupleMap = new LinkedHashMap<Dart, Tuple>();
+ tupleMap = new LinkedHashMap<>();
for (Dart d : face.getDarts()) {
Tuple t = new Tuple(d);
tupleMap.put(d, t);
@@ -105,10 +105,9 @@ public class OrthogonalRepresentation {
return tupleMap.get(dart);
}
- public void updateTuple(Tuple tuple, Collection<Edge> newEdges) {
-
+ public void updateTuple(Tuple tuple, Collection<Edge<?>> newEdges) {
Dart originalDart = tuple.getDart();
- Edge originalEdge = originalDart.getEdge();
+ Edge<?> originalEdge = originalDart.getEdge();
List<Dart> newDarts = face.replaceDart(originalDart, newEdges);
tupleMap.remove(originalDart);
BitSet bends = tuple.getBends();
@@ -143,7 +142,7 @@ public class OrthogonalRepresentation {
}
}
- public void insertEdge(Edge edge) {
+ public void insertEdge(Edge<?> edge) {
List<Dart> removedDarts = face.replaceDarts(edge);
if (removedDarts.isEmpty()) {
@@ -174,7 +173,7 @@ public class OrthogonalRepresentation {
}
}
- public class Tuple {
+ public static class Tuple {
private Dart dart;
private BitSet bends;
diff --git a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/RectangularCompactor.java b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/RectangularCompactor.java
index 6f874db..55b45d9 100644
--- a/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/RectangularCompactor.java
+++ b/platform/api.visual/src/org/netbeans/modules/visual/graph/layout/orthogonalsupport/RectangularCompactor.java
@@ -21,7 +21,6 @@ package org.netbeans.modules.visual.graph.layout.orthogonalsupport;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.BitSet;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -38,7 +37,7 @@ import org.netbeans.modules.visual.graph.layout.orthogonalsupport.MGraph.Vertex;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.OrthogonalRepresentation.OrthogonalShape;
import org.netbeans.modules.visual.graph.layout.orthogonalsupport.OrthogonalRepresentation.Tuple;
-public class RectangularCompactor {
+public class RectangularCompactor<N, E> {
private static int startOfNextBar;
@@ -52,9 +51,9 @@ public class RectangularCompactor {
*
* @param ors
*/
- public void compact(Collection<OrthogonalRepresentation> ors) {
+ public void compact(Collection<OrthogonalRepresentation<N, E>> ors) {
startOfNextBar = 0;
- for (OrthogonalRepresentation or : ors) {
+ for (OrthogonalRepresentation<N, E> or : ors) {
compact(or);
}
}
@@ -63,13 +62,13 @@ public class RectangularCompactor {
*
* @param or
*/
- private void compact(OrthogonalRepresentation or) {
+ private void compact(OrthogonalRepresentation<N, E> or) {
insertBendVertices(or);
assignEdgeDirections(or);
refineShapes(or);
- DirectionalGraph hGraph = DirectionalGraph.createGraph(or, Direction.HORIZONTAL);
+ DirectionalGraph<N, E> hGraph = DirectionalGraph.createGraph(or, Direction.HORIZONTAL);
Collection<Bar> bars = hGraph.getBars();
Bar[] barArray = new Bar[bars.size()];
@@ -87,7 +86,7 @@ public class RectangularCompactor {
x += (maxWidth + OrthogonalLayout.gutter);
maxWidth = -1;
- for (Vertex v : bar.getVertices()) {
+ for (Vertex<?> v : bar.getVertices()) {
if (v instanceof DummyVertex) {
continue;
@@ -108,7 +107,7 @@ public class RectangularCompactor {
startOfNextBar = x + maxWidth ;
- DirectionalGraph vGraph = DirectionalGraph.createGraph(or, Direction.VERTICAL);
+ DirectionalGraph<?, ?> vGraph = DirectionalGraph.createGraph(or, Direction.VERTICAL);
bars = vGraph.getBars();
barArray = new Bar[bars.size()];
@@ -124,7 +123,7 @@ public class RectangularCompactor {
y += (maxHeight + OrthogonalLayout.gutter);
maxHeight = -1;
- for (Vertex v : bar.getVertices()) {
+ for (Vertex<?> v : bar.getVertices()) {
if (v instanceof DummyVertex) {
continue;
@@ -149,15 +148,15 @@ public class RectangularCompactor {
*
* @param or
*/
- private void insertBendVertices(OrthogonalRepresentation or) {
- MGraph originalGraph = or.getOriginalGraph().getOriginalGraph();
- Map<Edge, Collection<Edge>> edgeMap = new HashMap<Edge, Collection<Edge>>();
+ private void insertBendVertices(OrthogonalRepresentation<?, ?> or) {
+ MGraph<?, ?> originalGraph = or.getOriginalGraph().getOriginalGraph();
+ Map<Edge<?>, Collection<Edge<?>>> edgeMap = new HashMap<>();
for (OrthogonalShape shape : or.getShapes()) {
Face face = shape.getFace();
// Work around current modification exception.
- ArrayList<Dart> darts = new ArrayList<Dart>(face.getDarts());
+ List<Dart> darts = new ArrayList<>(face.getDarts());
for (Dart dart : darts) {
Tuple tuple = shape.getTuple(dart);
@@ -165,23 +164,22 @@ public class RectangularCompactor {
continue;
}
- BitSet bends = tuple.getBends();
int numOfBends = tuple.getNumberOfBends();
if (numOfBends == 0) {
continue;
}
- Edge edge = dart.getEdge();
- Collection<Edge> newEdges = edgeMap.get(edge);
+ Edge<?> edge = dart.getEdge();
+ Collection<Edge<?>> newEdges = edgeMap.get(edge);
if (newEdges == null) {
- newEdges = new ArrayList<Edge>();
+ newEdges = new ArrayList<>();
edgeMap.put(edge, newEdges);
- Vertex v = dart.getV();
- Vertex w = dart.getW();
+ Vertex<?> v = dart.getV();
+ Vertex<?> w = dart.getW();
for (int i = 0; i < numOfBends; i++) {
- Vertex dv = originalGraph.insertDummyVertex(edge, DummyVertex.Type.BEND);
+ Vertex<?> dv = originalGraph.insertDummyVertex(edge, DummyVertex.Type.BEND);
newEdges.add(v.getEdge(dv));
edge = dv.getEdge(w);
v = dv;
@@ -198,11 +196,11 @@ public class RectangularCompactor {
*
* @param or
*/
- private void assignEdgeDirections(OrthogonalRepresentation or) {
+ private void assignEdgeDirections(OrthogonalRepresentation<?, ?> or) {
Face outerFace = or.getOriginalGraph().getFaces().get(0);
- HashSet<Face> visitedFace = new HashSet<Face>();
+ Set<Face> visitedFace = new HashSet<>();
OrthogonalShape startingShape = or.getShape(outerFace);
- Edge startingEdge = startingShape.getFace().getDarts().get(0).getEdge();
+ Edge<?> startingEdge = startingShape.getFace().getDarts().get(0).getEdge();
startingEdge.setDirection(Direction.HORIZONTAL);
assignEdgeDirections(startingShape, startingEdge, or, visitedFace);
@@ -216,11 +214,11 @@ public class RectangularCompactor {
* @param or
* @param visitedFaces
*/
- private void assignEdgeDirections(OrthogonalShape shape, Edge startingEdge,
- OrthogonalRepresentation or, Set<Face> visitedFaces) {
+ private void assignEdgeDirections(OrthogonalShape shape, Edge<?> startingEdge,
+ OrthogonalRepresentation<?, ?> or, Set<Face> visitedFaces) {
Face face = shape.getFace();
visitedFaces.add(face);
- EmbeddedPlanarGraph epg = or.getOriginalGraph();
+ EmbeddedPlanarGraph<?, ?> epg = or.getOriginalGraph();
List<Dart> darts = face.getDarts();
int startingIndex = 0;
int size = darts.size();
@@ -236,7 +234,7 @@ public class RectangularCompactor {
Direction prevDirection = null;
while (true) {
Dart dart = darts.get(index);
- Edge edge = dart.getEdge();
+ Edge<?> edge = dart.getEdge();
Direction direction = edge.getDirection();
if (direction == null) {
@@ -286,8 +284,8 @@ public class RectangularCompactor {
*
* @param or
*/
- private void refineShapes(OrthogonalRepresentation or) {
- Map<Edge, Collection<Edge>> edgeMap = new HashMap<Edge, Collection<Edge>>();
+ private void refineShapes(OrthogonalRepresentation<N, E> or) {
+ Map<Edge<?>, Collection<Edge<?>>> edgeMap = new HashMap<>();
OrthogonalShape outerShape = null;
for (OrthogonalShape shape : or.getShapes()) {
@@ -311,7 +309,7 @@ public class RectangularCompactor {
* @param shape
* @param edgeMap
*/
- private void updateShape(OrthogonalShape shape, Map<Edge, Collection<Edge>> edgeMap) {
+ private void updateShape(OrthogonalShape shape, Map<Edge<?>, Collection<Edge<?>>> edgeMap) {
if (edgeMap.isEmpty()) {
return;
}
@@ -320,8 +318,8 @@ public class RectangularCompactor {
Dart currentDart = face.getDarts().get(0);
while (true) {
- Edge edge = currentDart.getEdge();
- Collection<Edge> newEdges = edgeMap.get(edge);
+ Edge<?> edge = currentDart.getEdge();
+ Collection<Edge<?>> newEdges = edgeMap.get(edge);
if (newEdges != null) {
Tuple tuple = shape.getTuple(currentDart);
@@ -345,13 +343,13 @@ public class RectangularCompactor {
* @param edgeMap
*/
private void refineShape(OrthogonalShape shape,
- OrthogonalRepresentation or,
- Map<Edge, Collection<Edge>> edgeMap) {
+ OrthogonalRepresentation<?, ?> or,
+ Map<Edge<?>, Collection<Edge<?>>> edgeMap) {
updateShape(shape, edgeMap);
// Do outer face last.
// May need multiple passes.
- MGraph originalGraph = or.getOriginalGraph().getOriginalGraph();
+ MGraph<?, ?> originalGraph = or.getOriginalGraph().getOriginalGraph();
while (refineShapeSub(shape, originalGraph, edgeMap)) {
//do nothing
@@ -365,11 +363,11 @@ public class RectangularCompactor {
* @param edgeMap
* @return
*/
- private boolean refineShapeSub(OrthogonalShape shape, MGraph originalGraph,
- Map<Edge, Collection<Edge>> edgeMap) {
+ private boolean refineShapeSub(OrthogonalShape shape, MGraph<?, ?> originalGraph,
+ Map<Edge<?>, Collection<Edge<?>>> edgeMap) {
Face face = shape.getFace();
Logger.log(0, "refining face " + face);
- ArrayList<Dart> darts = new ArrayList<Dart>(face.getDarts());
+ List<Dart> darts = new ArrayList<>(face.getDarts());
Dart firstDart = darts.get(0);
Dart currentDart = firstDart;
@@ -424,16 +422,16 @@ public class RectangularCompactor {
}
if (frontDart != null) {
- Edge currentEdge = currentDart.getEdge();
+ Edge<?> currentEdge = currentDart.getEdge();
Direction direction = currentEdge.getDirection();
Tuple currentTuple = shape.getTuple(currentDart);
if (currentTuple.getAngles() != -1) {
- ArrayList<Edge> newEdges = new ArrayList<Edge>();
+ List<Edge<?>> newEdges = new ArrayList<>();
edgeMap.put(currentEdge, newEdges);
- Vertex dv = originalGraph.insertDummyVertex(currentEdge, DummyVertex.Type.TEMPORARY);
- Edge de = originalGraph.addDummyEdge(dv, frontDart.getV());
+ Vertex<?> dv = originalGraph.insertDummyVertex(currentEdge, DummyVertex.Type.TEMPORARY);
+ Edge<?> de = originalGraph.addDummyEdge(dv, frontDart.getV());
if (direction == Direction.VERTICAL) {
de.setDirection(Direction.HORIZONTAL);
@@ -441,20 +439,20 @@ public class RectangularCompactor {
de.setDirection(Direction.VERTICAL);
}
- Vertex currentV = currentDart.getV();
- Edge de1 = currentV.getEdge(dv);
+ Vertex<?> currentV = currentDart.getV();
+ Edge<?> de1 = currentV.getEdge(dv);
de1.setDirection(direction);
newEdges.add(de1);
- Vertex currentW = currentDart.getW();
- Edge de2 = dv.getEdge(currentW);
+ Vertex<?> currentW = currentDart.getW();
+ Edge<?> de2 = dv.getEdge(currentW);
de2.setDirection(direction);
newEdges.add(de2);
shape.updateTuple(shape.getTuple(currentDart), newEdges);
shape.insertEdge(de);
} else {
- Edge de = originalGraph.addDummyEdge(currentDart.getV(), frontDart.getV());
+ Edge<?> de = originalGraph.addDummyEdge(currentDart.getV(), frontDart.getV());
if (direction == Direction.VERTICAL) {
de.setDirection(Direction.HORIZONTAL);
@@ -483,16 +481,16 @@ public class RectangularCompactor {
* @param or
*/
private void addDummyOuterFace(OrthogonalShape shape,
- OrthogonalRepresentation or) {
- MGraph graph = or.getOriginalGraph().getOriginalGraph();
- ArrayList<Edge> dummyEdges1 = new ArrayList<Edge>();
- ArrayList<Edge> dummyEdges2 = new ArrayList<Edge>();
+ OrthogonalRepresentation<N, E> or) {
+ MGraph<N, E> graph = or.getOriginalGraph().getOriginalGraph();
+ List<Edge<?>> dummyEdges1 = new ArrayList<>();
+ List<Edge<?>> dummyEdges2 = new ArrayList<>();
- Vertex dv = graph.addDummyVertex(DummyVertex.Type.TEMPORARY);
- Vertex cornerVertex = dv;
+ Vertex<N> dv = graph.addDummyVertex(DummyVertex.Type.TEMPORARY);
+ Vertex<N> cornerVertex = dv;
for (int i = 0; i < 4; i++) {
- Vertex dw = null;
+ Vertex<N> dw = null;
if (i < 3) {
dw = graph.addDummyVertex(DummyVertex.Type.TEMPORARY);
@@ -500,7 +498,7 @@ public class RectangularCompactor {
dw = cornerVertex;
}
- Edge de = graph.addDummyEdge(dv, dw);
+ Edge<?> de = graph.addDummyEdge(dv, dw);
dummyEdges1.add(de);
if (i == 0 || i == 2) {
@@ -555,10 +553,11 @@ public class RectangularCompactor {
if (firstIndex == -1) {
firstIndex = index;
}
- Edge de = dummyEdges1.get(index);
+ Edge<?> de = dummyEdges1.get(index);
Direction direction = de.getDirection();
- Vertex v = de.getV();
- Vertex w = de.getW();
+ Vertex<?> v = de.getV();
+ Vertex<?> w = de.getW();
+ graph.insertDummyVertex(de, DummyVertex.Type.TEMPORARY);
dv = graph.insertDummyVertex(de, DummyVertex.Type.TEMPORARY);
de = graph.addDummyEdge(currentDart.getW(), dv);
@@ -568,11 +567,11 @@ public class RectangularCompactor {
de.setDirection(Direction.HORIZONTAL);
}
- Edge e1 = dv.getEdge(w);
+ Edge<?> e1 = dv.getEdge(w);
e1.setDirection(direction);
dummyEdges1.set(index, e1);
- Edge e2 = v.getEdge(dv);
+ Edge<?> e2 = v.getEdge(dv);
e2.setDirection(direction);
if (dummyEdges2.get(index) == null) {
@@ -625,7 +624,7 @@ public class RectangularCompactor {
if (index == firstIndex) {
swapped = true;
- Edge de = dummyEdges2.get(firstIndex);
+ Edge<?> de = dummyEdges2.get(firstIndex);
if (de != null) {
dummyEdges1.set(firstIndex, de);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists