8290011: IGV: Remove dead code and cleanup

Reviewed-by: chagedorn
This commit is contained in:
Tobias Holenstein 2022-10-19 15:49:22 +00:00
parent d37ce4cdd1
commit e27bea0c4d
133 changed files with 1164 additions and 4199 deletions

View File

@ -59,9 +59,7 @@ public class BytecodeNode extends AbstractNode {
List<InputNode> nodeList = selector.selectMultiple(matcher);
if (nodeList.size() > 0) {
nodes = new LinkedHashSet<>();
for (InputNode n : nodeList) {
nodes.add(n);
}
nodes.addAll(nodeList);
displayName += " (" + nodes.size() + " nodes)";
}
@ -88,12 +86,12 @@ public class BytecodeNode extends AbstractNode {
@Override
public Action[] getActions(boolean b) {
return new Action[]{(Action) SelectBytecodesAction.findObject(SelectBytecodesAction.class, true)};
return new Action[]{SelectBytecodesAction.findObject(SelectBytecodesAction.class, true)};
}
@Override
public Action getPreferredAction() {
return (Action) SelectBytecodesAction.findObject(SelectBytecodesAction.class, true);
return SelectBytecodesAction.findObject(SelectBytecodesAction.class, true);
}
@Override

View File

@ -29,12 +29,11 @@ import com.sun.hotspot.igv.data.InputGraph;
import com.sun.hotspot.igv.data.services.InputGraphProvider;
import com.sun.hotspot.igv.util.LookupHistory;
import java.awt.BorderLayout;
import java.io.Serializable;
import org.openide.ErrorManager;
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils;
import org.openide.explorer.view.BeanTreeView;
import org.openide.util.*;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
@ -62,7 +61,7 @@ final class BytecodeViewTopComponent extends TopComponent implements ExplorerMan
treeView = new BeanTreeView();
treeView.setRootVisible(false);
this.add(BorderLayout.CENTER, treeView);
add(BorderLayout.CENTER, treeView);
associateLookup(ExplorerUtils.createLookup(manager, getActionMap()));
}
@ -109,11 +108,6 @@ final class BytecodeViewTopComponent extends TopComponent implements ExplorerMan
LookupHistory.removeListener(InputGraphProvider.class, this);
}
@Override
public Object writeReplace() {
return new ResolvableHelper();
}
@Override
protected String preferredID() {
return PREFERRED_ID;
@ -156,15 +150,6 @@ final class BytecodeViewTopComponent extends TopComponent implements ExplorerMan
manager.setRootContext(rootNode);
}
static final class ResolvableHelper implements Serializable {
private static final long serialVersionUID = 1L;
public Object readResolve() {
return BytecodeViewTopComponent.getDefault();
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is

View File

@ -42,7 +42,7 @@ public class MethodNode extends AbstractNode {
private InputMethod method;
private InputGraph graph;
private String bciString;
private final String bciString;
public MethodNodeChildren(InputMethod method, InputGraph graph, String bciString) {
this.method = method;

View File

@ -34,7 +34,7 @@ import org.openide.nodes.Node;
*/
public class SelectBytecodesCookie implements Node.Cookie {
private Set<InputNode> nodes;
private final Set<InputNode> nodes;
/** Creates a new instance of SelectBytecodesCookie */
public SelectBytecodesCookie(Set<InputNode> nodes) {

View File

@ -13,6 +13,7 @@
<folder name="Window">
<file name="BytecodeViewAction.shadow">
<attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-bytecodes-BytecodeViewAction.instance"/>
<attr name="position" intvalue="1"/>
</file>
</folder>
</folder>

View File

@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
@ -24,9 +24,9 @@
package com.sun.hotspot.igv.controlflow;
import com.sun.hotspot.igv.data.InputBlockEdge;
import com.sun.hotspot.igv.layout.Cluster;
import com.sun.hotspot.igv.layout.Link;
import com.sun.hotspot.igv.layout.Port;
import com.sun.hotspot.igv.layout.Cluster;
import java.awt.BasicStroke;
import java.awt.Point;
import java.awt.Stroke;
@ -45,28 +45,22 @@ public class BlockConnectionWidget extends ConnectionWidget implements Link {
private static final Stroke DASHED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[]{5, 5}, 0);
private static final Stroke BOLD_DASHED_STROKE = new BasicStroke(2.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[]{5, 5}, 0);
private BlockWidget from;
private BlockWidget to;
private Port inputSlot;
private Port outputSlot;
private final BlockWidget from;
private final BlockWidget to;
private final Port inputSlot;
private final Port outputSlot;
private List<Point> points;
private InputBlockEdge edge;
private boolean isDashed = false;
private boolean isBold = false;
public BlockConnectionWidget(ControlFlowScene scene, InputBlockEdge edge) {
super(scene);
this.edge = edge;
this.from = (BlockWidget) scene.findWidget(edge.getFrom());
this.to = (BlockWidget) scene.findWidget(edge.getTo());
inputSlot = to.getInputSlot();
outputSlot = from.getOutputSlot();
points = new ArrayList<Point>();
}
public InputBlockEdge getEdge() {
return edge;
points = new ArrayList<>();
}
public Port getTo() {

View File

@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
@ -27,11 +27,7 @@ import com.sun.hotspot.igv.data.InputBlock;
import com.sun.hotspot.igv.layout.Cluster;
import com.sun.hotspot.igv.layout.Port;
import com.sun.hotspot.igv.layout.Vertex;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.*;
import org.netbeans.api.visual.border.BorderFactory;
import org.netbeans.api.visual.model.ObjectState;
import org.netbeans.api.visual.widget.LabelWidget;
@ -43,11 +39,10 @@ import org.netbeans.api.visual.widget.LabelWidget;
public class BlockWidget extends LabelWidget implements Vertex {
public static final Dimension MIN_SIZE = new Dimension(20, 20);
private InputBlock block;
private Port inputSlot;
private Port outputSlot;
private final InputBlock block;
private final Port inputSlot;
private final Port outputSlot;
private Cluster cluster;
private boolean root;
private static final Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
private static final Font boldFont = font.deriveFont(Font.BOLD);
public static final Color NORMAL_FOREGROUND_COLOR = Color.BLACK;
@ -123,15 +118,7 @@ public class BlockWidget extends LabelWidget implements Vertex {
}
public boolean isRoot() {
return root;
}
public void setCluster(Cluster c) {
cluster = c;
}
public void setRoot(boolean b) {
root = b;
return false;
}
public int compareTo(Vertex o) {

View File

@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*

View File

@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
@ -23,11 +23,11 @@
*/
package com.sun.hotspot.igv.controlflow;
import com.sun.hotspot.igv.data.InputBlockEdge;
import com.sun.hotspot.igv.data.InputBlock;
import com.sun.hotspot.igv.data.InputBlockEdge;
import com.sun.hotspot.igv.data.InputGraph;
import com.sun.hotspot.igv.data.services.InputGraphProvider;
import com.sun.hotspot.igv.data.InputNode;
import com.sun.hotspot.igv.data.services.InputGraphProvider;
import com.sun.hotspot.igv.util.LookupHistory;
import java.awt.Color;
import java.awt.Point;
@ -36,22 +36,17 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import javax.swing.BorderFactory;
import org.netbeans.api.visual.action.ActionFactory;
import org.netbeans.api.visual.action.MoveProvider;
import org.netbeans.api.visual.action.RectangularSelectDecorator;
import org.netbeans.api.visual.action.RectangularSelectProvider;
import org.netbeans.api.visual.action.SelectProvider;
import org.netbeans.api.visual.action.WidgetAction;
import org.netbeans.api.visual.action.*;
import org.netbeans.api.visual.anchor.AnchorFactory;
import org.netbeans.api.visual.anchor.AnchorShape;
import org.netbeans.api.visual.router.RouterFactory;
import org.netbeans.api.visual.widget.LayerWidget;
import org.netbeans.api.visual.widget.Widget;
import org.netbeans.api.visual.graph.GraphScene;
import org.netbeans.api.visual.graph.layout.GraphLayout;
import org.netbeans.api.visual.layout.LayoutFactory;
import org.netbeans.api.visual.layout.SceneLayout;
import org.netbeans.api.visual.router.RouterFactory;
import org.netbeans.api.visual.widget.ConnectionWidget;
import org.netbeans.api.visual.widget.LayerWidget;
import org.netbeans.api.visual.widget.Widget;
/**
*
@ -59,34 +54,33 @@ import org.netbeans.api.visual.widget.ConnectionWidget;
*/
public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> implements SelectProvider, MoveProvider, RectangularSelectDecorator, RectangularSelectProvider {
private HashSet<BlockWidget> selection;
private final HashSet<BlockWidget> selection;
private InputGraph oldGraph;
private LayerWidget edgeLayer;
private LayerWidget mainLayer;
private LayerWidget selectLayer;
private WidgetAction hoverAction = this.createWidgetHoverAction();
private WidgetAction selectAction = new DoubleClickSelectAction(this);
private WidgetAction moveAction = ActionFactory.createMoveAction(null, this);
private final LayerWidget edgeLayer;
private final LayerWidget mainLayer;
private final WidgetAction hoverAction = createWidgetHoverAction();
private final WidgetAction selectAction = new DoubleClickSelectAction(this);
private final WidgetAction moveAction = ActionFactory.createMoveAction(null, this);
public ControlFlowScene() {
selection = new HashSet<BlockWidget>();
selection = new HashSet<>();
this.getInputBindings().setZoomActionModifiers(0);
this.setLayout(LayoutFactory.createAbsoluteLayout());
getInputBindings().setZoomActionModifiers(0);
setLayout(LayoutFactory.createAbsoluteLayout());
mainLayer = new LayerWidget(this);
this.addChild(mainLayer);
addChild(mainLayer);
edgeLayer = new LayerWidget(this);
this.addChild(edgeLayer);
addChild(edgeLayer);
selectLayer = new LayerWidget(this);
this.addChild(selectLayer);
LayerWidget selectLayer = new LayerWidget(this);
addChild(selectLayer);
this.getActions().addAction(hoverAction);
this.getActions().addAction(selectAction);
this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this));
this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
getActions().addAction(hoverAction);
getActions().addAction(selectAction);
getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this));
getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
}
public void setGraph(InputGraph g) {
@ -95,12 +89,12 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
}
oldGraph = g;
ArrayList<InputBlock> blocks = new ArrayList<InputBlock>(this.getNodes());
ArrayList<InputBlock> blocks = new ArrayList<>(getNodes());
for (InputBlock b : blocks) {
removeNode(b);
}
ArrayList<InputBlockEdge> edges = new ArrayList<InputBlockEdge>(this.getEdges());
ArrayList<InputBlockEdge> edges = new ArrayList<>(getEdges());
for (InputBlockEdge e : edges) {
removeEdge(e);
}
@ -113,15 +107,15 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
addEdge(e);
assert g.getBlocks().contains(e.getFrom());
assert g.getBlocks().contains(e.getTo());
this.setEdgeSource(e, e.getFrom());
this.setEdgeTarget(e, e.getTo());
setEdgeSource(e, e.getFrom());
setEdgeTarget(e, e.getTo());
}
GraphLayout<InputBlock, InputBlockEdge> layout = new HierarchicalGraphLayout<InputBlock, InputBlockEdge>();//GridGraphLayout();
GraphLayout<InputBlock, InputBlockEdge> layout = new HierarchicalGraphLayout<>();
SceneLayout sceneLayout = LayoutFactory.createSceneGraphLayout(this, layout);
sceneLayout.invokeLayout();
this.validate();
validate();
}
public void clearSelection() {
@ -135,7 +129,7 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
public void selectionChanged() {
InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);
if (p != null) {
Set<InputNode> inputNodes = new HashSet<InputNode>();
Set<InputNode> inputNodes = new HashSet<>();
for (BlockWidget w : selection) {
inputNodes.addAll(w.getBlock().getNodes());
}
@ -155,14 +149,17 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
selectionChanged();
}
@Override
public boolean isAimingAllowed(Widget widget, Point point, boolean b) {
return false;
}
@Override
public boolean isSelectionAllowed(Widget widget, Point point, boolean b) {
return true;
}
@Override
public void select(Widget widget, Point point, boolean change) {
if (widget == this) {
clearSelection();
@ -185,18 +182,22 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
}
}
public void movementStarted(Widget widget) {
}
@Override
public void movementStarted(Widget widget) {}
public void movementFinished(Widget widget) {
}
@Override
public void movementFinished(Widget widget) {}
@Override
public Point getOriginalLocation(Widget widget) {
return widget.getPreferredLocation();
}
@Override
public void setNewLocation(Widget widget, Point location) {
if (selection.contains(widget)) {
assert widget instanceof BlockWidget;
if (selection.contains((BlockWidget) widget)) {
// move entire selection
Point originalLocation = getOriginalLocation(widget);
int xOffset = location.x - originalLocation.x;
@ -211,6 +212,7 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
}
}
@Override
public Widget createSelectionWidget() {
Widget widget = new Widget(this);
widget.setOpaque(false);
@ -219,6 +221,7 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
return widget;
}
@Override
public void performSelection(Rectangle rectangle) {
if (rectangle.width < 0) {
@ -232,7 +235,7 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
}
boolean changed = false;
for (InputBlock b : this.getNodes()) {
for (InputBlock b : getNodes()) {
BlockWidget w = (BlockWidget) findWidget(b);
Rectangle r = new Rectangle(w.getBounds());
r.setLocation(w.getLocation());
@ -257,6 +260,7 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
}
@Override
protected Widget attachNodeWidget(InputBlock node) {
BlockWidget w = new BlockWidget(this, node);
mainLayer.addChild(w);
@ -266,6 +270,7 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
return w;
}
@Override
protected Widget attachEdgeWidget(InputBlockEdge edge) {
BlockConnectionWidget w = new BlockConnectionWidget(this, edge);
switch (edge.getState()) {
@ -282,16 +287,18 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
return w;
}
@Override
protected void attachEdgeSourceAnchor(InputBlockEdge edge, InputBlock oldSourceNode, InputBlock sourceNode) {
Widget w = this.findWidget(edge);
Widget w = findWidget(edge);
assert w instanceof ConnectionWidget;
ConnectionWidget cw = (ConnectionWidget) w;
cw.setSourceAnchor(AnchorFactory.createRectangularAnchor(findWidget(sourceNode)));
}
@Override
protected void attachEdgeTargetAnchor(InputBlockEdge edge, InputBlock oldTargetNode, InputBlock targetNode) {
Widget w = this.findWidget(edge);
Widget w = findWidget(edge);
assert w instanceof ConnectionWidget;
ConnectionWidget cw = (ConnectionWidget) w;
cw.setTargetAnchor(AnchorFactory.createRectangularAnchor(findWidget(targetNode)));

View File

@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
@ -28,7 +28,6 @@ import com.sun.hotspot.igv.data.InputGraph;
import com.sun.hotspot.igv.data.services.InputGraphProvider;
import com.sun.hotspot.igv.util.LookupHistory;
import java.awt.BorderLayout;
import java.io.Serializable;
import javax.swing.JScrollPane;
import org.openide.ErrorManager;
import org.openide.util.NbBundle;
@ -51,12 +50,11 @@ final class ControlFlowTopComponent extends TopComponent implements ChangedListe
setToolTipText(NbBundle.getMessage(ControlFlowTopComponent.class, "HINT_ControlFlowTopComponent"));
scene = new ControlFlowScene();
this.setLayout(new BorderLayout());
this.associateLookup(scene.getLookup());
setLayout(new BorderLayout());
associateLookup(scene.getLookup());
JScrollPane panel = new JScrollPane(scene.createView());
this.add(panel, BorderLayout.CENTER);
add(panel, BorderLayout.CENTER);
}
/**
@ -114,11 +112,6 @@ final class ControlFlowTopComponent extends TopComponent implements ChangedListe
scene.setGraph(new InputGraph(""));
}
@Override
public Object writeReplace() {
return new ResolvableHelper();
}
@Override
protected String preferredID() {
return PREFERRED_ID;
@ -130,15 +123,6 @@ final class ControlFlowTopComponent extends TopComponent implements ChangedListe
scene.getView().requestFocus();
}
static final class ResolvableHelper implements Serializable {
private static final long serialVersionUID = 1L;
public Object readResolve() {
return ControlFlowTopComponent.getDefault();
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is

View File

@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*

View File

@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
@ -24,20 +24,10 @@
package com.sun.hotspot.igv.controlflow;
import com.sun.hotspot.igv.hierarchicallayout.HierarchicalLayoutManager;
import com.sun.hotspot.igv.layout.Cluster;
import com.sun.hotspot.igv.layout.LayoutGraph;
import com.sun.hotspot.igv.layout.Link;
import com.sun.hotspot.igv.layout.Port;
import com.sun.hotspot.igv.layout.Vertex;
import com.sun.hotspot.igv.layout.*;
import java.awt.Dimension;
import java.awt.Point;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import org.netbeans.api.visual.graph.layout.GraphLayout;
import org.netbeans.api.visual.graph.layout.UniversalGraph;
import org.netbeans.api.visual.widget.Widget;
@ -48,13 +38,12 @@ import org.netbeans.api.visual.widget.Widget;
*/
public class HierarchicalGraphLayout<N, E> extends GraphLayout<N, E> {
public HierarchicalGraphLayout() {
}
public HierarchicalGraphLayout() {}
private class LinkWrapper implements Link {
private VertexWrapper from;
private VertexWrapper to;
private final VertexWrapper from;
private final VertexWrapper to;
public LinkWrapper(VertexWrapper from, VertexWrapper to) {
this.from = from;
@ -78,7 +67,7 @@ public class HierarchicalGraphLayout<N, E> extends GraphLayout<N, E> {
}
public List<Point> getControlPoints() {
return new ArrayList<Point>();
return new ArrayList<>();
}
public void setControlPoints(List<Point> list) {
@ -92,9 +81,9 @@ public class HierarchicalGraphLayout<N, E> extends GraphLayout<N, E> {
private class VertexWrapper implements Vertex {
private N node;
private UniversalGraph<N, E> graph;
private Port slot;
private final N node;
private final UniversalGraph<N, E> graph;
private final Port slot;
private Point position;
public VertexWrapper(N node, UniversalGraph<N, E> graph) {
@ -122,6 +111,7 @@ public class HierarchicalGraphLayout<N, E> extends GraphLayout<N, E> {
public Dimension getSize() {
Widget w = graph.getScene().findWidget(node);
assert w.getBounds() != null;
return w.getBounds().getSize();
}
@ -151,9 +141,9 @@ public class HierarchicalGraphLayout<N, E> extends GraphLayout<N, E> {
protected void performGraphLayout(UniversalGraph<N, E> graph) {
Set<LinkWrapper> links = new LinkedHashSet<LinkWrapper>();
Set<VertexWrapper> vertices = new LinkedHashSet<VertexWrapper>();
Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>();
Set<LinkWrapper> links = new LinkedHashSet<>();
Set<VertexWrapper> vertices = new LinkedHashSet<>();
Map<N, VertexWrapper> vertexMap = new HashMap<>();
for (N node : graph.getNodes()) {
VertexWrapper v = new VertexWrapper(node, graph);

View File

@ -10,6 +10,7 @@
<folder name="Window">
<file name="ControlFlowAction.shadow">
<attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-controlflow-ControlFlowAction.instance"/>
<attr name="position" intvalue="2"/>
</file>
</folder>
</folder>

View File

@ -28,8 +28,8 @@ import com.sun.hotspot.igv.data.*;
import com.sun.hotspot.igv.util.PropertiesSheet;
import com.sun.hotspot.igv.util.StringUtils;
import java.awt.Image;
import java.util.List;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
@ -45,11 +45,11 @@ import org.openide.util.lookup.InstanceContent;
*/
public class FolderNode extends AbstractNode {
private InstanceContent content;
private FolderChildren children;
private final InstanceContent content;
private final FolderChildren children;
// NetBeans node corresponding to each opened graph. Used to highlight the
// focused graph in the Outline window.
private static Map<InputGraph, GraphNode> graphNode = new HashMap<>();
private static final Map<InputGraph, GraphNode> graphNode = new HashMap<>();
private boolean selected = false;
private static class FolderChildren extends Children.Keys<FolderElement> implements ChangedListener {
@ -128,12 +128,9 @@ public class FolderNode extends AbstractNode {
if (folder instanceof FolderElement) {
final FolderElement folderElement = (FolderElement) folder;
this.setDisplayName(folderElement.getName());
content.add(new RemoveCookie() {
@Override
public void remove() {
children.destroyNodes(children.getNodes());
folderElement.getParent().removeElement(folderElement);
}
content.add((RemoveCookie) () -> {
children.destroyNodes(children.getNodes());
folderElement.getParent().removeElement(folderElement);
});
}
}
@ -163,7 +160,7 @@ public class FolderNode extends AbstractNode {
public boolean isRootNode() {
Folder folder = getFolder();
return (folder != null && folder instanceof GraphDocument);
return (folder instanceof GraphDocument);
}
@Override

View File

@ -23,12 +23,7 @@
*/
package com.sun.hotspot.igv.coordinator;
import com.sun.hotspot.igv.coordinator.actions.CloneGraphAction;
import com.sun.hotspot.igv.coordinator.actions.DiffGraphAction;
import com.sun.hotspot.igv.coordinator.actions.DiffGraphCookie;
import com.sun.hotspot.igv.coordinator.actions.GraphCloneCookie;
import com.sun.hotspot.igv.coordinator.actions.GraphOpenCookie;
import com.sun.hotspot.igv.coordinator.actions.GraphRemoveCookie;
import com.sun.hotspot.igv.coordinator.actions.*;
import com.sun.hotspot.igv.data.InputGraph;
import com.sun.hotspot.igv.data.Properties;
import com.sun.hotspot.igv.data.services.GraphViewer;
@ -37,12 +32,7 @@ import com.sun.hotspot.igv.util.StringUtils;
import java.awt.Image;
import javax.swing.Action;
import org.openide.actions.OpenAction;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.NodeAdapter;
import org.openide.nodes.NodeEvent;
import org.openide.nodes.NodeMemberEvent;
import org.openide.nodes.Sheet;
import org.openide.nodes.*;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
import org.openide.util.lookup.AbstractLookup;
@ -132,12 +122,12 @@ public class GraphNode extends AbstractNode {
@Override
public Action[] getActions(boolean b) {
return new Action[]{(Action) DiffGraphAction.findObject(DiffGraphAction.class, true), (Action) CloneGraphAction.findObject(CloneGraphAction.class, true), (Action) OpenAction.findObject(OpenAction.class, true)};
return new Action[]{DiffGraphAction.findObject(DiffGraphAction.class, true), CloneGraphAction.findObject(CloneGraphAction.class, true), OpenAction.findObject(OpenAction.class, true)};
}
@Override
public Action getPreferredAction() {
return (Action) OpenAction.findObject(OpenAction.class, true);
return OpenAction.findObject(OpenAction.class, true);
}
@Override

View File

@ -37,7 +37,6 @@ import java.awt.Dimension;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.swing.UIManager;
@ -66,8 +65,6 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM
private ExplorerManager manager;
private final GraphDocument document;
private FolderNode root;
private Server server;
private Server binaryServer;
private SaveAllAction saveAllAction;
private RemoveAllAction removeAllAction;
private GraphNode[] selectedGraphs = new GraphNode[0];
@ -138,8 +135,7 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM
}
};
server = new Server(getDocument(), callback, false);
binaryServer = new Server(getDocument(), callback, true);
new Server(callback);
}
public void clear() {
@ -286,15 +282,6 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM
super.writeExternal(objectOutput);
}
static final class ResolvableHelper implements Serializable {
private static final long serialVersionUID = 1L;
public Object readResolve() {
return OutlineTopComponent.getDefault();
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,31 +26,24 @@ package com.sun.hotspot.igv.coordinator.actions;
import com.sun.hotspot.igv.coordinator.OutlineTopComponent;
import com.sun.hotspot.igv.data.GraphDocument;
import com.sun.hotspot.igv.data.serialization.BinaryParser;
import com.sun.hotspot.igv.data.serialization.GraphParser;
import com.sun.hotspot.igv.data.serialization.ParseMonitor;
import com.sun.hotspot.igv.data.serialization.Parser;
import com.sun.hotspot.igv.settings.Settings;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.file.StandardOpenOption;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Action;
import javax.swing.JFileChooser;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileFilter;
import javax.swing.Action;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.*;
import org.openide.util.actions.CallableSystemAction;
import org.openide.util.Utilities;
/**
*
@ -65,12 +58,12 @@ public final class ImportAction extends CallableSystemAction {
@Override
public boolean accept(File f) {
return f.getName().toLowerCase().endsWith(".xml") || f.getName().toLowerCase().endsWith(".bgv") || f.isDirectory();
return f.getName().toLowerCase().endsWith(".xml") || f.isDirectory();
}
@Override
public String getDescription() {
return "Graph files (*.xml, *.bgv)";
return "Graph files (*.xml)";
}
};
}
@ -102,8 +95,7 @@ public final class ImportAction extends CallableSystemAction {
try {
int prog = (int) (WORKUNITS * (double) channel.position() / (double) start);
handle.progress(prog);
} catch (IOException ex) {
}
} catch (IOException ignored) {}
}
@Override
public void setState(String state) {
@ -115,8 +107,6 @@ public final class ImportAction extends CallableSystemAction {
final OutlineTopComponent component = OutlineTopComponent.findInstance();
if (file.getName().endsWith(".xml")) {
parser = new Parser(channel, monitor, null);
} else if (file.getName().endsWith(".bgv")) {
parser = new BinaryParser(channel, monitor, component.getDocument(), null);
} else {
parser = null;
}
@ -126,13 +116,10 @@ public final class ImportAction extends CallableSystemAction {
try {
final GraphDocument document = parser.parse();
if (document != null) {
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
component.requestActive();
component.getDocument().addGraphDocument(document);
}
});
SwingUtilities.invokeLater(() -> {
component.requestActive();
component.getDocument().addGraphDocument(document);
});
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
@ -142,8 +129,6 @@ public final class ImportAction extends CallableSystemAction {
Logger.getLogger(getClass().getName()).log(Level.INFO, "Loaded in " + file + " in " + ((stop - startTime) / 1000.0) + " seconds");
}
});
} catch (FileNotFoundException ex) {
Exceptions.printStackTrace(ex);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}

View File

@ -25,10 +25,7 @@
package com.sun.hotspot.igv.coordinator.actions;
import com.sun.hotspot.igv.coordinator.OutlineTopComponent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.Action;
import javax.swing.KeyStroke;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CallableSystemAction;

View File

@ -25,15 +25,11 @@
package com.sun.hotspot.igv.coordinator.actions;
import com.sun.hotspot.igv.coordinator.OutlineTopComponent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.Action;
import javax.swing.KeyStroke;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.CallableSystemAction;
import org.openide.util.Utilities;
import org.openide.util.actions.CallableSystemAction;
/**
*

View File

@ -25,19 +25,21 @@
package com.sun.hotspot.igv.coordinator.actions;
import com.sun.hotspot.igv.coordinator.FolderNode;
import com.sun.hotspot.igv.coordinator.OutlineTopComponent;
import com.sun.hotspot.igv.data.Folder;
import com.sun.hotspot.igv.data.GraphDocument;
import com.sun.hotspot.igv.data.Group;
import com.sun.hotspot.igv.data.serialization.Printer;
import com.sun.hotspot.igv.settings.Settings;
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.file.Files;
import javax.swing.Action;
import javax.swing.JFileChooser;
import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CookieAction;
import org.openide.util.actions.NodeAction;
/**
@ -52,7 +54,6 @@ public final class SaveAsAction extends NodeAction {
@Override
protected void performAction(Node[] activatedNodes) {
final OutlineTopComponent component = OutlineTopComponent.findInstance();
GraphDocument doc = new GraphDocument();
for (Node node : activatedNodes) {
if (node instanceof FolderNode) {
@ -84,23 +85,16 @@ public final class SaveAsAction extends NodeAction {
}
Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath());
try {
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file))) {
try (Writer writer = new OutputStreamWriter(Files.newOutputStream(file.toPath()))) {
Printer p = new Printer();
p.export(writer, doc);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
protected int mode() {
return CookieAction.MODE_SOME;
}
@Override
public String getName() {
return NbBundle.getMessage(SaveAsAction.class, "CTL_SaveAsAction");

View File

@ -43,9 +43,10 @@
<file name="com-sun-hotspot-igv-coordinator-actions-OutlineAction.instance"/>
</folder>
</folder>
<folder name="Menu">
<folder name="File">
<attr name="position" intvalue="50"/>
<file name="Export_hidden"/>
<file name="Import_hidden"/>
<file name="Separator2.instance_hidden"/>
@ -96,8 +97,9 @@
<file name="org-openide-actions-SaveAllAction.shadow_hidden"/>
<file name="org-openide-actions-SaveAsAction.shadow_hidden"/>
</folder>
<folder name="Edit">
<attr name="position" intvalue="100"/>
<file name="org-openide-actions-UndoAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-UndoAction.instance"/>
<attr name="position" intvalue="100"/>
@ -130,8 +132,9 @@
<file name="org-openide-actions-ReplaceAction.shadow_hidden"/>
<file name="sep-before-reposearch.instance_hidden"/>
</folder>
<folder name="View">
<attr name="position" intvalue="150"/>
<!-- Hidden menu entries from other modules -->
<file name="Separator1.instance_hidden"/>
<file name="Separator2.instance_hidden"/>
@ -148,7 +151,7 @@
<file name="toggle-non-printable-characters.shadow_hidden"/>
<file name="toggle-toolbar.shadow_hidden"/>
</folder>
<!-- Hidden menus -->
<folder name="Tools_hidden"/>
<folder name="GoTo_hidden"/>
@ -159,14 +162,18 @@
<folder name="Versioning_hidden"/>
<folder name="Options">
<attr name="position" intvalue="200"/>
<file name="org-netbeans-modules-options-OptionsWindowAction.shadow">
<attr name="originalFile" stringvalue="Actions/Window/org-netbeans-modules-options-OptionsWindowAction.instance"/>
<attr name="position" intvalue="1"/>
</file>
</folder>
<folder name="Window">
<attr name="position" intvalue="250"/>
<file name="OutlineAction.shadow">
<attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-coordinator-actions-OutlineAction.instance"/>
<attr name="position" intvalue="4"/>
</file>
<!-- Hidden menu entries from other modules -->
<file name="Web_hidden"/>
@ -188,6 +195,7 @@
</folder>
<folder name="Help">
<attr name="position" intvalue="300"/>
<!-- Hidden menu entries from other modules -->
<file name="Separator1.instance_hidden"/>
<file name="netbeans-kb.url_hidden"/>
@ -214,12 +222,12 @@
<file name="Versioning.instance_hidden"/>
</folder>
</folder>
<folder name="Windows2">
<folder name="Components">
<file name="OutlineTopComponent.settings" url="OutlineTopComponentSettings.xml"/>
</folder>
<folder name="Modes">
<folder name="Modes">
<file name="customLeft.wsmode" url="customLeftWsmode.xml"/>
<folder name="customLeft">
<file name="OutlineTopComponent.wstcref" url="OutlineTopComponentWstcref.xml"/>

View File

@ -30,7 +30,7 @@ package com.sun.hotspot.igv.data;
*/
public class ChangedEvent<T> extends Event<ChangedListener<T>> {
private T object;
private final T object;
/**
* Creates a new event with the specific object as the one for which the event gets fired.

View File

@ -32,7 +32,7 @@ import java.util.List;
*/
public abstract class Event<L> {
private List<L> listener;
private final List<L> listener;
private boolean fireEvents;
private boolean eventWasFired;
@ -45,10 +45,6 @@ public abstract class Event<L> {
listener.add(l);
}
/**
* Remove listener
* @param l
*/
public void removeListener(final L l) {
listener.remove(l);
}

View File

@ -32,8 +32,8 @@ import java.util.List;
*/
public class GraphDocument extends Properties.Entity implements ChangedEventProvider<GraphDocument>, Folder {
private List<FolderElement> elements;
private ChangedEvent<GraphDocument> changedEvent;
private final List<FolderElement> elements;
private final ChangedEvent<GraphDocument> changedEvent;
public GraphDocument() {
elements = new ArrayList<>();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,26 +31,18 @@ import java.util.*;
*/
public class Group extends Properties.Entity implements ChangedEventProvider<Group>, Folder, FolderElement {
private final List<FolderElement> elements;
private final List<InputGraph> graphs;
private InputMethod method;
private transient ChangedEvent<Group> changedEvent;
private final transient ChangedEvent<Group> changedEvent;
private Folder parent;
public Group(Folder parent) {
elements = new ArrayList<>();
graphs = new ArrayList<>();
changedEvent = new ChangedEvent<>(this);
this.parent = parent;
// Ensure that name and type are never null
// Ensure that name is never null
getProperties().setProperty("name", "");
getProperties().setProperty("type", "");
}
public void fireChangedEvent() {
changedEvent.fire();
}
public void setMethod(InputMethod method) {
@ -67,33 +59,34 @@ public class Group extends Properties.Entity implements ChangedEventProvider<Gro
}
@Override
public List<FolderElement> getElements() {
return Collections.unmodifiableList(elements);
}
public int getGraphsCount() {
return elements.size();
public void addElement(FolderElement element) {
assert element instanceof InputGraph;
graphs.add((InputGraph) element);
element.setParent(this);
getChangedEvent().fire();
}
@Override
public void addElement(FolderElement element) {
elements.add(element);
if (element instanceof InputGraph) {
graphs.add((InputGraph) element);
} else {
public void removeElement(FolderElement element) {
assert element instanceof InputGraph;
if (graphs.remove((InputGraph) element)) {
getChangedEvent().fire();
}
element.setParent(this);
changedEvent.fire();
}
@Override
public List<FolderElement> getElements() {
return Collections.unmodifiableList(graphs);
}
public List<InputGraph> getGraphs() {
return Collections.unmodifiableList(graphs);
}
public Set<Integer> getAllNodes() {
Set<Integer> result = new HashSet<>();
for (FolderElement e : elements) {
if (e instanceof InputGraph) {
InputGraph g = (InputGraph) e;
result.addAll(g.getNodesAsSet());
}
for (InputGraph g : graphs) {
result.addAll(g.getNodesAsSet());
}
return result;
}
@ -102,7 +95,7 @@ public class Group extends Properties.Entity implements ChangedEventProvider<Gro
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Group ").append(getProperties()).append("\n");
for (FolderElement g : elements) {
for (FolderElement g : getElements()) {
sb.append(g.toString());
sb.append('\n');
}
@ -121,7 +114,7 @@ public class Group extends Properties.Entity implements ChangedEventProvider<Gro
InputGraph getPrev(InputGraph graph) {
InputGraph lastGraph = null;
for (FolderElement e : elements) {
for (FolderElement e : getElements()) {
if (e == graph) {
return lastGraph;
}
@ -134,7 +127,7 @@ public class Group extends Properties.Entity implements ChangedEventProvider<Gro
InputGraph getNext(InputGraph graph) {
boolean found = false;
for (FolderElement e : elements) {
for (FolderElement e : getElements()) {
if (e == graph) {
found = true;
} else if (found && e instanceof InputGraph) {
@ -144,35 +137,10 @@ public class Group extends Properties.Entity implements ChangedEventProvider<Gro
return null;
}
public InputGraph getLastGraph() {
InputGraph lastGraph = null;
for (FolderElement e : elements) {
if (e instanceof InputGraph) {
lastGraph = (InputGraph) e;
}
}
return lastGraph;
}
@Override
public Folder getParent() {
return parent;
}
@Override
public void removeElement(FolderElement element) {
if (elements.remove(element)) {
if (element instanceof InputGraph) {
graphs.remove((InputGraph) element);
}
changedEvent.fire();
}
}
public List<InputGraph> getGraphs() {
return graphs;
}
@Override
public void setParent(Folder parent) {
this.parent = parent;

View File

@ -32,9 +32,9 @@ import java.util.*;
public class InputBlock {
private List<InputNode> nodes;
private String name;
private InputGraph graph;
private Set<InputBlock> successors;
private final String name;
private final InputGraph graph;
private final Set<InputBlock> successors;
private boolean artificial;
@Override
@ -49,7 +49,7 @@ public class InputBlock {
return true;
}
if (o == null || (!(o instanceof InputBlock))) {
if ((!(o instanceof InputBlock))) {
return false;
}
@ -113,13 +113,11 @@ public class InputBlock {
}
void addSuccessor(InputBlock b) {
if (!successors.contains(b)) {
successors.add(b);
}
successors.add(b);
}
void setArtificial(boolean artificial) {
this.artificial = artificial;
void setArtificial() {
this.artificial = true;
}
public boolean isArtificial() {

View File

@ -35,10 +35,10 @@ public class InputBlockEdge {
DELETED
}
private InputBlock from;
private InputBlock to;
private final InputBlock from;
private final InputBlock to;
private State state = State.SAME;
private String label;
private final String label;
public InputBlockEdge(InputBlock from, InputBlock to, String label) {
assert from != null;
@ -70,7 +70,7 @@ public class InputBlockEdge {
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof InputBlockEdge) {
if (obj instanceof InputBlockEdge) {
InputBlockEdge e = (InputBlockEdge) obj;
return e.from.equals(from) && e.to.equals(to);
}

View File

@ -29,10 +29,10 @@ package com.sun.hotspot.igv.data;
*/
public class InputBytecode {
private int bci;
private String name;
private String operands;
private String comment;
private final int bci;
private final String name;
private final String operands;
private final String comment;
private InputMethod inlined;
public InputBytecode(int bci, String name, String operands, String comment) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,8 +24,7 @@
package com.sun.hotspot.igv.data;
import java.util.Comparator;
import java.util.WeakHashMap;
import java.lang.ref.WeakReference;
import java.util.Objects;
/**
*
@ -40,27 +39,19 @@ public class InputEdge {
DELETED
}
public static final Comparator<InputEdge> OUTGOING_COMPARATOR = new Comparator<InputEdge>(){
@Override
public int compare(InputEdge o1, InputEdge o2) {
if(o1.getFromIndex() == o2.getFromIndex()) {
return o1.getTo() - o2.getTo();
}
return o1.getFromIndex() - o2.getFromIndex();
public static final Comparator<InputEdge> OUTGOING_COMPARATOR = (o1, o2) -> {
if (o1.getFromIndex() == o2.getFromIndex()) {
return o1.getTo() - o2.getTo();
}
};
return o1.getFromIndex() - o2.getFromIndex();
};
public static final Comparator<InputEdge> INGOING_COMPARATOR = new Comparator<InputEdge>(){
@Override
public int compare(InputEdge o1, InputEdge o2) {
if(o1.getToIndex() == o2.getToIndex()) {
return o1.getFrom() - o2.getFrom();
}
return o1.getToIndex() - o2.getToIndex();
public static final Comparator<InputEdge> INGOING_COMPARATOR = (o1, o2) -> {
if (o1.getToIndex() == o2.getToIndex()) {
return o1.getFrom() - o2.getFrom();
}
};
return o1.getToIndex() - o2.getToIndex();
};
private final char toIndex;
private final char fromIndex;
@ -70,14 +61,6 @@ public class InputEdge {
private final String type;
private State state;
public InputEdge(char toIndex, int from, int to) {
this((char) 0, toIndex, from, to, null, null);
}
public InputEdge(char fromIndex, char toIndex, int from, int to) {
this(fromIndex, toIndex, from, to, null, null);
}
public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type) {
this.toIndex = toIndex;
this.fromIndex = fromIndex;
@ -88,31 +71,6 @@ public class InputEdge {
this.type = type.intern();
}
static WeakHashMap<InputEdge, WeakReference<InputEdge>> immutableCache = new WeakHashMap<>();
public static synchronized InputEdge createImmutable(char fromIndex, char toIndex, int from, int to, String label, String type) {
InputEdge edge = new InputEdge(fromIndex, toIndex, from, to, label, type, State.IMMUTABLE);
WeakReference<InputEdge> result = immutableCache.get(edge);
if (result != null) {
InputEdge edge2 = result.get();
if (edge2 != null) {
return edge2;
}
}
immutableCache.put(edge, new WeakReference<>(edge));
return edge;
}
public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type, State state) {
this.toIndex = toIndex;
this.fromIndex = fromIndex;
this.from = from;
this.to = to;
this.state = state;
this.label = label;
this.type = type;
}
public State getState() {
return state;
}
@ -154,14 +112,14 @@ public class InputEdge {
@Override
public boolean equals(Object o) {
if (o == null || !(o instanceof InputEdge)) {
if (!(o instanceof InputEdge)) {
return false;
}
InputEdge conn2 = (InputEdge) o;
boolean result = conn2.fromIndex == fromIndex && conn2.toIndex == toIndex && conn2.from == from && conn2.to == to;
if (result && (state == State.IMMUTABLE || conn2.state == State.IMMUTABLE)) {
// Immutable instances must be exactly the same
return conn2.label == label && conn2.state == state;
return Objects.equals(conn2.label, label) && conn2.state == state;
}
return result;
}

View File

@ -31,13 +31,13 @@ import java.util.*;
*/
public class InputGraph extends Properties.Entity implements FolderElement {
private Map<Integer, InputNode> nodes;
private List<InputEdge> edges;
private final Map<Integer, InputNode> nodes;
private final List<InputEdge> edges;
private Folder parent;
private Group parentGroup;
private Map<String, InputBlock> blocks;
private List<InputBlockEdge> blockEdges;
private Map<Integer, InputBlock> nodeToBlock;
private final Map<String, InputBlock> blocks;
private final List<InputBlockEdge> blockEdges;
private final Map<Integer, InputBlock> nodeToBlock;
private boolean isDiffGraph;
private InputGraph firstGraph;
private InputGraph secondGraph;
@ -64,7 +64,7 @@ public class InputGraph extends Properties.Entity implements FolderElement {
}
public boolean isDiffGraph() {
return this.isDiffGraph;
return isDiffGraph;
}
public InputGraph getFirstGraph() {
@ -114,7 +114,7 @@ public class InputGraph extends Properties.Entity implements FolderElement {
public Map<InputNode, List<InputEdge>> findAllOutgoingEdges() {
Map<InputNode, List<InputEdge>> result = new HashMap<>(getNodes().size());
for(InputNode n : this.getNodes()) {
result.put(n, new ArrayList<InputEdge>());
result.put(n, new ArrayList<>());
}
for(InputEdge e : this.edges) {
@ -175,16 +175,6 @@ public class InputGraph extends Properties.Entity implements FolderElement {
nodeToBlock.clear();
}
public void setEdge(int fromIndex, int toIndex, int from, int to) {
assert fromIndex == ((char)fromIndex) : "Downcast must be safe";
assert toIndex == ((char)toIndex) : "Downcast must be safe";
InputEdge edge = new InputEdge((char)fromIndex, (char)toIndex, from, to);
if(!this.getEdges().contains(edge)) {
this.addEdge(edge);
}
}
public void ensureNodesInBlocks() {
InputBlock noBlock = null;
Set<InputNode> scheduledNodes = new HashSet<>();
@ -304,7 +294,7 @@ public class InputGraph extends Properties.Entity implements FolderElement {
public InputBlock addArtificialBlock() {
InputBlock b = addBlock("(no block)");
b.setArtificial(true);
b.setArtificial();
return b;
}

View File

@ -35,13 +35,13 @@ import java.util.regex.Pattern;
*/
public class InputMethod extends Properties.Entity {
private String name;
private int bci;
private String shortName;
private List<InputMethod> inlined;
private final String name;
private final int bci;
private final String shortName;
private final List<InputMethod> inlined;
private InputMethod parentMethod;
private Group group;
private List<InputBytecode> bytecodes;
private final Group group;
private final List<InputBytecode> bytecodes;
@Override
public int hashCode() {
@ -55,11 +55,10 @@ public class InputMethod extends Properties.Entity {
@Override
public boolean equals(Object o) {
if (o == null || (!(o instanceof InputMethod))) {
if ((!(o instanceof InputMethod))) {
return false;
}
final InputMethod im = (InputMethod)o;
final InputMethod im = (InputMethod) o;
return name.equals(im.name) && bci == im.bci && shortName.equals(im.shortName) &&
inlined.equals(im.inlined) && bytecodes.equals(im.bytecodes);
}

View File

@ -23,10 +23,6 @@
*/
package com.sun.hotspot.igv.data;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
/**
*
* @author Thomas Wuerthinger
@ -34,37 +30,6 @@ import java.util.List;
public class InputNode extends Properties.Entity {
private int id;
private List<InputGraph> subgraphs;
public static final Comparator<InputNode> COMPARATOR = new Comparator<InputNode>() {
@Override
public int compare(InputNode o1, InputNode o2) {
return o1.getId() - o2.getId();
}
};
public static Comparator<InputNode> getPropertyComparator(final String propertyName) {
return new Comparator<InputNode>() {
@Override
public int compare(InputNode o1, InputNode o2) {
int i1 = 0;
try {
i1 = Integer.parseInt(o1.getProperties().get(propertyName));
} catch(NumberFormatException e) {
}
int i2 = 0;
try {
i2 = Integer.parseInt(o2.getProperties().get(propertyName));
} catch(NumberFormatException e) {
}
return i1 - i2;
}
};
}
public InputNode(InputNode n) {
super(n);
@ -83,17 +48,6 @@ public class InputNode extends Properties.Entity {
return id;
}
public void addSubgraph(InputGraph graph) {
if (subgraphs == null) {
subgraphs = new ArrayList<>();
}
subgraphs.add(graph);
}
public List<InputGraph> getSubgraphs() {
return subgraphs;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof InputNode)) {

View File

@ -58,10 +58,10 @@ public class Pair<L, R> {
@Override
public boolean equals(Object o) {
if (o == null || !(o instanceof Pair)) {
if (!(o instanceof Pair<?, ?>)) {
return false;
}
Pair<?,?> obj = (Pair<?,?>) o;
Pair<?, ?> obj = (Pair<?, ?>) o;
boolean b1 = (l == obj.l);
if (l != null) {
b1 = l.equals(obj.l);

View File

@ -26,7 +26,6 @@ package com.sun.hotspot.igv.data;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.*;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@ -188,7 +187,7 @@ public class Properties implements Serializable, Iterable<Property> {
public static class InvertPropertyMatcher implements PropertyMatcher {
private PropertyMatcher matcher;
private final PropertyMatcher matcher;
public InvertPropertyMatcher(PropertyMatcher matcher) {
this.matcher = matcher;
@ -210,8 +209,8 @@ public class Properties implements Serializable, Iterable<Property> {
public static class StringPropertyMatcher implements PropertyMatcher {
private String name;
private String value;
private final String name;
private final String value;
public StringPropertyMatcher(String name, String value) {
if (name == null) {
@ -240,8 +239,8 @@ public class Properties implements Serializable, Iterable<Property> {
public static class RegexpPropertyMatcher implements PropertyMatcher {
private String name;
private Pattern valuePattern;
private final String name;
private final Pattern valuePattern;
public RegexpPropertyMatcher(String name, String value) {
this(name, value, 0);
@ -312,13 +311,10 @@ public class Properties implements Serializable, Iterable<Property> {
}
}
pairs.sort(new Comparator<String[]>() {
@Override
public int compare(String[] o1, String[] o2) {
assert o1.length == 2;
assert o2.length == 2;
return o1[0].compareTo(o2[0]);
}
pairs.sort((o1, o2) -> {
assert o1.length == 2;
assert o2.length == 2;
return o1[0].compareTo(o2[0]);
});
StringBuilder sb = new StringBuilder();
@ -337,7 +333,7 @@ public class Properties implements Serializable, Iterable<Property> {
public static class PropertySelector<T extends Properties.Provider> {
private Collection<T> objects;
private final Collection<T> objects;
public PropertySelector(Collection<T> objects) {
this.objects = objects;

View File

@ -32,8 +32,8 @@ import java.io.Serializable;
public class Property implements Serializable {
public static final long serialVersionUID = 1L;
private String name;
private String value;
private final String name;
private final String value;
Property(String name, String value) {
this.name = name;

View File

@ -31,8 +31,8 @@ import java.util.*;
*/
public class Source {
private List<InputNode> sourceNodes;
private Set<Integer> set;
private final List<InputNode> sourceNodes;
private final Set<Integer> set;
public Source() {
sourceNodes = new ArrayList<>(1);
@ -56,12 +56,7 @@ public class Source {
public interface Provider {
public Source getSource();
Source getSource();
}
public void addSourceNodes(Source s) {
for (InputNode n : s.getSourceNodes()) {
addSourceNode(n);
}
}
}

View File

@ -1,937 +0,0 @@
/*
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.hotspot.igv.data.serialization;
import com.sun.hotspot.igv.data.*;
import com.sun.hotspot.igv.data.Properties;
import com.sun.hotspot.igv.data.services.GroupCallback;
import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.SwingUtilities;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import static java.nio.charset.StandardCharsets.UTF_8;
public class BinaryParser implements GraphParser {
private static final int BEGIN_GROUP = 0x00;
private static final int BEGIN_GRAPH = 0x01;
private static final int CLOSE_GROUP = 0x02;
private static final int POOL_NEW = 0x00;
private static final int POOL_STRING = 0x01;
private static final int POOL_ENUM = 0x02;
private static final int POOL_CLASS = 0x03;
private static final int POOL_METHOD = 0x04;
private static final int POOL_NULL = 0x05;
private static final int POOL_NODE_CLASS = 0x06;
private static final int POOL_FIELD = 0x07;
private static final int POOL_SIGNATURE = 0x08;
private static final int KLASS = 0x00;
private static final int ENUM_KLASS = 0x01;
private static final int PROPERTY_POOL = 0x00;
private static final int PROPERTY_INT = 0x01;
private static final int PROPERTY_LONG = 0x02;
private static final int PROPERTY_DOUBLE = 0x03;
private static final int PROPERTY_FLOAT = 0x04;
private static final int PROPERTY_TRUE = 0x05;
private static final int PROPERTY_FALSE = 0x06;
private static final int PROPERTY_ARRAY = 0x07;
private static final int PROPERTY_SUBGRAPH = 0x08;
private static final String NO_BLOCK = "noBlock";
private final GroupCallback callback;
private final List<Object> constantPool;
private final ByteBuffer buffer;
private final ReadableByteChannel channel;
private final GraphDocument rootDocument;
private final Deque<Folder> folderStack;
private final Deque<byte[]> hashStack;
private final ParseMonitor monitor;
private MessageDigest digest;
private enum Length {
S,
M,
L
}
private interface LengthToString {
String toString(Length l);
}
private abstract static class Member implements LengthToString {
public final Klass holder;
public final int accessFlags;
public final String name;
public Member(Klass holder, String name, int accessFlags) {
this.holder = holder;
this.accessFlags = accessFlags;
this.name = name;
}
}
private static class Method extends Member {
public final Signature signature;
public final byte[] code;
public Method(String name, Signature signature, byte[] code, Klass holder, int accessFlags) {
super(holder, name, accessFlags);
this.signature = signature;
this.code = code;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(holder).append('.').append(name).append('(');
for (int i = 0; i < signature.argTypes.length; i++) {
if (i > 0) {
sb.append(", ");
}
sb.append(signature.argTypes[i]);
}
sb.append(')');
return sb.toString();
}
@Override
public String toString(Length l) {
switch(l) {
case M:
return holder.toString(Length.L) + "." + name;
case S:
return holder.toString(Length.S) + "." + name;
default:
case L:
return toString();
}
}
}
private static class Signature {
public final String returnType;
public final String[] argTypes;
public Signature(String returnType, String[] argTypes) {
this.returnType = returnType;
this.argTypes = argTypes;
}
}
private static class Field extends Member {
public final String type;
public Field(String type, Klass holder, String name, int accessFlags) {
super(holder, name, accessFlags);
this.type = type;
}
@Override
public String toString() {
return holder + "." + name;
}
@Override
public String toString(Length l) {
switch(l) {
case M:
return holder.toString(Length.L) + "." + name;
case S:
return holder.toString(Length.S) + "." + name;
default:
case L:
return toString();
}
}
}
private static class Klass implements LengthToString {
public final String name;
public final String simpleName;
public Klass(String name) {
this.name = name;
String simple;
try {
simple = name.substring(name.lastIndexOf('.') + 1);
} catch (IndexOutOfBoundsException ioobe) {
simple = name;
}
this.simpleName = simple;
}
@Override
public String toString() {
return name;
}
@Override
public String toString(Length l) {
switch(l) {
case S:
return simpleName;
default:
case L:
case M:
return toString();
}
}
}
private static class EnumKlass extends Klass {
public final String[] values;
public EnumKlass(String name, String[] values) {
super(name);
this.values = values;
}
}
private static class Port {
public final boolean isList;
public final String name;
private Port(boolean isList, String name) {
this.isList = isList;
this.name = name;
}
}
private static class TypedPort extends Port {
public final EnumValue type;
private TypedPort(boolean isList, String name, EnumValue type) {
super(isList, name);
this.type = type;
}
}
private static class NodeClass {
public final String className;
public final String nameTemplate;
public final List<TypedPort> inputs;
public final List<Port> sux;
private NodeClass(String className, String nameTemplate, List<TypedPort> inputs, List<Port> sux) {
this.className = className;
this.nameTemplate = nameTemplate;
this.inputs = inputs;
this.sux = sux;
}
@Override
public String toString() {
return className;
}
}
private static class EnumValue implements LengthToString {
public EnumKlass enumKlass;
public int ordinal;
public EnumValue(EnumKlass enumKlass, int ordinal) {
this.enumKlass = enumKlass;
this.ordinal = ordinal;
}
@Override
public String toString() {
return enumKlass.simpleName + "." + enumKlass.values[ordinal];
}
@Override
public String toString(Length l) {
switch(l) {
case S:
return enumKlass.values[ordinal];
default:
case M:
case L:
return toString();
}
}
}
public BinaryParser(ReadableByteChannel channel, ParseMonitor monitor, GraphDocument rootDocument, GroupCallback callback) {
this.callback = callback;
constantPool = new ArrayList<>();
buffer = ByteBuffer.allocateDirect(256 * 1024);
buffer.flip();
this.channel = channel;
this.rootDocument = rootDocument;
folderStack = new LinkedList<>();
hashStack = new LinkedList<>();
this.monitor = monitor;
try {
this.digest = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
}
}
private void fill() throws IOException {
// All the data between lastPosition and position has been
// used so add it to the digest.
int position = buffer.position();
buffer.position(lastPosition);
byte[] remaining = new byte[position - buffer.position()];
buffer.get(remaining);
digest.update(remaining);
assert position == buffer.position();
buffer.compact();
if (channel.read(buffer) < 0) {
throw new EOFException();
}
buffer.flip();
lastPosition = buffer.position();
}
private void ensureAvailable(int i) throws IOException {
if (i > buffer.capacity()) {
throw new IllegalArgumentException(String.format("Can not request %d bytes: buffer capacity is %d", i, buffer.capacity()));
}
while (buffer.remaining() < i) {
fill();
}
}
private int readByte() throws IOException {
ensureAvailable(1);
return ((int)buffer.get()) & 0xff;
}
private int readInt() throws IOException {
ensureAvailable(4);
return buffer.getInt();
}
private char readShort() throws IOException {
ensureAvailable(2);
return buffer.getChar();
}
private long readLong() throws IOException {
ensureAvailable(8);
return buffer.getLong();
}
private double readDouble() throws IOException {
ensureAvailable(8);
return buffer.getDouble();
}
private float readFloat() throws IOException {
ensureAvailable(4);
return buffer.getFloat();
}
private String readString() throws IOException {
return new String(readBytes(), UTF_8).intern();
}
private byte[] readBytes() throws IOException {
int len = readInt();
if (len < 0) {
return null;
}
byte[] b = new byte[len];
int bytesRead = 0;
while (bytesRead < b.length) {
int toRead = Math.min(b.length - bytesRead, buffer.capacity());
ensureAvailable(toRead);
buffer.get(b, bytesRead, toRead);
bytesRead += toRead;
}
return b;
}
private String readIntsToString() throws IOException {
int len = readInt();
if (len < 0) {
return "null";
}
ensureAvailable(len * 4);
StringBuilder sb = new StringBuilder().append('[');
for (int i = 0; i < len; i++) {
sb.append(buffer.getInt());
if (i < len - 1) {
sb.append(", ");
}
}
sb.append(']');
return sb.toString().intern();
}
private String readDoublesToString() throws IOException {
int len = readInt();
if (len < 0) {
return "null";
}
ensureAvailable(len * 8);
StringBuilder sb = new StringBuilder().append('[');
for (int i = 0; i < len; i++) {
sb.append(buffer.getDouble());
if (i < len - 1) {
sb.append(", ");
}
}
sb.append(']');
return sb.toString().intern();
}
private String readPoolObjectsToString() throws IOException {
int len = readInt();
if (len < 0) {
return "null";
}
StringBuilder sb = new StringBuilder().append('[');
for (int i = 0; i < len; i++) {
sb.append(readPoolObject(Object.class));
if (i < len - 1) {
sb.append(", ");
}
}
sb.append(']');
return sb.toString().intern();
}
private <T> T readPoolObject(Class<T> klass) throws IOException {
int type = readByte();
if (type == POOL_NULL) {
return null;
}
if (type == POOL_NEW) {
return (T) addPoolEntry(klass);
}
assert assertObjectType(klass, type);
char index = readShort();
if (index < 0 || index >= constantPool.size()) {
throw new IOException("Invalid constant pool index : " + index);
}
Object obj = constantPool.get(index);
return (T) obj;
}
private boolean assertObjectType(Class<?> klass, int type) {
switch(type) {
case POOL_CLASS:
return klass.isAssignableFrom(EnumKlass.class);
case POOL_ENUM:
return klass.isAssignableFrom(EnumValue.class);
case POOL_METHOD:
return klass.isAssignableFrom(Method.class);
case POOL_STRING:
return klass.isAssignableFrom(String.class);
case POOL_NODE_CLASS:
return klass.isAssignableFrom(NodeClass.class);
case POOL_FIELD:
return klass.isAssignableFrom(Field.class);
case POOL_SIGNATURE:
return klass.isAssignableFrom(Signature.class);
case POOL_NULL:
return true;
default:
return false;
}
}
private Object addPoolEntry(Class<?> klass) throws IOException {
char index = readShort();
int type = readByte();
assert assertObjectType(klass, type) : "Wrong object type : " + klass + " != " + type;
Object obj;
switch(type) {
case POOL_CLASS: {
String name = readString();
int klasstype = readByte();
if (klasstype == ENUM_KLASS) {
int len = readInt();
String[] values = new String[len];
for (int i = 0; i < len; i++) {
values[i] = readPoolObject(String.class);
}
obj = new EnumKlass(name, values);
} else if (klasstype == KLASS) {
obj = new Klass(name);
} else {
throw new IOException("unknown klass type : " + klasstype);
}
break;
}
case POOL_ENUM: {
EnumKlass enumClass = readPoolObject(EnumKlass.class);
int ordinal = readInt();
obj = new EnumValue(enumClass, ordinal);
break;
}
case POOL_NODE_CLASS: {
String className = readString();
String nameTemplate = readString();
int inputCount = readShort();
List<TypedPort> inputs = new ArrayList<>(inputCount);
for (int i = 0; i < inputCount; i++) {
boolean isList = readByte() != 0;
String name = readPoolObject(String.class);
EnumValue inputType = readPoolObject(EnumValue.class);
inputs.add(new TypedPort(isList, name, inputType));
}
int suxCount = readShort();
List<Port> sux = new ArrayList<>(suxCount);
for (int i = 0; i < suxCount; i++) {
boolean isList = readByte() != 0;
String name = readPoolObject(String.class);
sux.add(new Port(isList, name));
}
obj = new NodeClass(className, nameTemplate, inputs, sux);
break;
}
case POOL_METHOD: {
Klass holder = readPoolObject(Klass.class);
String name = readPoolObject(String.class);
Signature sign = readPoolObject(Signature.class);
int flags = readInt();
byte[] code = readBytes();
obj = new Method(name, sign, code, holder, flags);
break;
}
case POOL_FIELD: {
Klass holder = readPoolObject(Klass.class);
String name = readPoolObject(String.class);
String fType = readPoolObject(String.class);
int flags = readInt();
obj = new Field(fType, holder, name, flags);
break;
}
case POOL_SIGNATURE: {
int argc = readShort();
String[] args = new String[argc];
for (int i = 0; i < argc; i++) {
args[i] = readPoolObject(String.class);
}
String returnType = readPoolObject(String.class);
obj = new Signature(returnType, args);
break;
}
case POOL_STRING: {
obj = readString();
break;
}
default:
throw new IOException("unknown pool type");
}
while (constantPool.size() <= index) {
constantPool.add(null);
}
constantPool.set(index, obj);
return obj;
}
private Object readPropertyObject() throws IOException {
int type = readByte();
switch (type) {
case PROPERTY_INT:
return readInt();
case PROPERTY_LONG:
return readLong();
case PROPERTY_FLOAT:
return readFloat();
case PROPERTY_DOUBLE:
return readDouble();
case PROPERTY_TRUE:
return Boolean.TRUE;
case PROPERTY_FALSE:
return Boolean.FALSE;
case PROPERTY_POOL:
return readPoolObject(Object.class);
case PROPERTY_ARRAY:
int subType = readByte();
switch(subType) {
case PROPERTY_INT:
return readIntsToString();
case PROPERTY_DOUBLE:
return readDoublesToString();
case PROPERTY_POOL:
return readPoolObjectsToString();
default:
throw new IOException("Unknown type");
}
case PROPERTY_SUBGRAPH:
InputGraph graph = parseGraph("");
new Group(null).addElement(graph);
return graph;
default:
throw new IOException("Unknown type");
}
}
@Override
public GraphDocument parse() throws IOException {
folderStack.push(rootDocument);
hashStack.push(null);
if (monitor != null) {
monitor.setState("Starting parsing");
}
try {
while(true) {
parseRoot();
}
} catch (EOFException e) {
}
if (monitor != null) {
monitor.setState("Finished parsing");
}
return rootDocument;
}
private void parseRoot() throws IOException {
int type = readByte();
switch(type) {
case BEGIN_GRAPH: {
final Folder parent = folderStack.peek();
final InputGraph graph = parseGraph();
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
parent.addElement(graph);
}
});
break;
}
case BEGIN_GROUP: {
final Folder parent = folderStack.peek();
final Group group = parseGroup(parent);
if (callback == null || parent instanceof Group) {
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
parent.addElement(group);
}
});
}
folderStack.push(group);
hashStack.push(null);
if (callback != null && parent instanceof GraphDocument) {
callback.started(group);
}
break;
}
case CLOSE_GROUP: {
if (folderStack.isEmpty()) {
throw new IOException("Unbalanced groups");
}
folderStack.pop();
hashStack.pop();
break;
}
default:
throw new IOException("unknown root : " + type);
}
}
private Group parseGroup(Folder parent) throws IOException {
String name = readPoolObject(String.class);
String shortName = readPoolObject(String.class);
if (monitor != null) {
monitor.setState(shortName);
}
Method method = readPoolObject(Method.class);
int bci = readInt();
Group group = new Group(parent);
group.getProperties().setProperty("name", name);
parseProperties(group.getProperties());
if (method != null) {
InputMethod inMethod = new InputMethod(group, method.name, shortName, bci);
inMethod.setBytecodes("TODO");
group.setMethod(inMethod);
}
return group;
}
int lastPosition = 0;
private InputGraph parseGraph() throws IOException {
if (monitor != null) {
monitor.updateProgress();
}
String title = readPoolObject(String.class);
digest.reset();
lastPosition = buffer.position();
InputGraph graph = parseGraph(title);
int position = buffer.position();
buffer.position(lastPosition);
byte[] remaining = new byte[position - buffer.position()];
buffer.get(remaining);
digest.update(remaining);
assert position == buffer.position();
lastPosition = buffer.position();
byte[] d = digest.digest();
byte[] hash = hashStack.peek();
if (hash != null && Arrays.equals(hash, d)) {
graph.getProperties().setProperty("_isDuplicate", "true");
} else {
hashStack.pop();
hashStack.push(d);
}
return graph;
}
private void parseProperties(Properties properties) throws IOException {
int propCount = readShort();
for (int j = 0; j < propCount; j++) {
String key = readPoolObject(String.class);
Object value = readPropertyObject();
properties.setProperty(key, value != null ? value.toString() : "null");
}
}
private InputGraph parseGraph(String title) throws IOException {
InputGraph graph = new InputGraph(title);
parseProperties(graph.getProperties());
parseNodes(graph);
parseBlocks(graph);
graph.ensureNodesInBlocks();
for (InputNode node : graph.getNodes()) {
node.internProperties();
}
return graph;
}
private void parseBlocks(InputGraph graph) throws IOException {
int blockCount = readInt();
List<Edge> edges = new LinkedList<>();
for (int i = 0; i < blockCount; i++) {
int id = readInt();
String name = id >= 0 ? Integer.toString(id) : NO_BLOCK;
InputBlock block = graph.addBlock(name);
int nodeCount = readInt();
for (int j = 0; j < nodeCount; j++) {
int nodeId = readInt();
if (nodeId < 0) {
continue;
}
final Properties properties = graph.getNode(nodeId).getProperties();
final String oldBlock = properties.get("block");
if(oldBlock != null) {
properties.setProperty("block", oldBlock + ", " + name);
} else {
block.addNode(nodeId);
properties.setProperty("block", name);
}
}
int edgeCount = readInt();
for (int j = 0; j < edgeCount; j++) {
int to = readInt();
edges.add(new Edge(id, to));
}
}
for (Edge e : edges) {
String fromName = e.from >= 0 ? Integer.toString(e.from) : NO_BLOCK;
String toName = e.to >= 0 ? Integer.toString(e.to) : NO_BLOCK;
graph.addBlockEdge(graph.getBlock(fromName), graph.getBlock(toName));
}
}
private void parseNodes(InputGraph graph) throws IOException {
int count = readInt();
Map<String, Object> props = new HashMap<>();
List<Edge> inputEdges = new ArrayList<>(count);
List<Edge> succEdges = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
int id = readInt();
InputNode node = new InputNode(id);
final Properties properties = node.getProperties();
NodeClass nodeClass = readPoolObject(NodeClass.class);
int preds = readByte();
if (preds > 0) {
properties.setProperty("hasPredecessor", "true");
}
properties.setProperty("idx", Integer.toString(id));
int propCount = readShort();
for (int j = 0; j < propCount; j++) {
String key = readPoolObject(String.class);
if (key.equals("hasPredecessor") || key.equals("name") || key.equals("class") || key.equals("id") || key.equals("idx")) {
key = "!data." + key;
}
Object value = readPropertyObject();
if (value instanceof InputGraph) {
InputGraph subgraph = (InputGraph) value;
subgraph.getProperties().setProperty("name", node.getId() + ":" + key);
node.addSubgraph((InputGraph) value);
} else {
properties.setProperty(key, value != null ? value.toString() : "null");
props.put(key, value);
}
}
ArrayList<Edge> currentEdges = new ArrayList<>();
int portNum = 0;
for (TypedPort p : nodeClass.inputs) {
if (p.isList) {
int size = readShort();
for (int j = 0; j < size; j++) {
int in = readInt();
if (in >= 0) {
Edge e = new Edge(in, id, (char) (preds + portNum), p.name + "[" + j + "]", p.type.toString(Length.S), true);
currentEdges.add(e);
inputEdges.add(e);
portNum++;
}
}
} else {
int in = readInt();
if (in >= 0) {
Edge e = new Edge(in, id, (char) (preds + portNum), p.name, p.type.toString(Length.S), true);
currentEdges.add(e);
inputEdges.add(e);
portNum++;
}
}
}
portNum = 0;
for (Port p : nodeClass.sux) {
if (p.isList) {
int size = readShort();
for (int j = 0; j < size; j++) {
int sux = readInt();
if (sux >= 0) {
Edge e = new Edge(id, sux, (char) portNum, p.name + "[" + j + "]", "Successor", false);
currentEdges.add(e);
succEdges.add(e);
portNum++;
}
}
} else {
int sux = readInt();
if (sux >= 0) {
Edge e = new Edge(id, sux, (char) portNum, p.name, "Successor", false);
currentEdges.add(e);
succEdges.add(e);
portNum++;
}
}
}
properties.setProperty("name", createName(currentEdges, props, nodeClass.nameTemplate));
properties.setProperty("class", nodeClass.className);
switch (nodeClass.className) {
case "BeginNode":
properties.setProperty("shortName", "B");
break;
case "EndNode":
properties.setProperty("shortName", "E");
break;
}
graph.addNode(node);
props.clear();
}
Set<InputNode> nodesWithSuccessor = new HashSet<>();
for (Edge e : succEdges) {
assert !e.input;
char fromIndex = e.num;
nodesWithSuccessor.add(graph.getNode(e.from));
char toIndex = 0;
graph.addEdge(InputEdge.createImmutable(fromIndex, toIndex, e.from, e.to, e.label, e.type));
}
for (Edge e : inputEdges) {
assert e.input;
char fromIndex = (char) (nodesWithSuccessor.contains(graph.getNode(e.from)) ? 1 : 0);
char toIndex = e.num;
graph.addEdge(InputEdge.createImmutable(fromIndex, toIndex, e.from, e.to, e.label, e.type));
}
}
static final Pattern templatePattern = Pattern.compile("\\{(p|i)#([a-zA-Z0-9$_]+)(/(l|m|s))?\\}");
private String createName(List<Edge> edges, Map<String, Object> properties, String template) {
Matcher m = templatePattern.matcher(template);
StringBuffer sb = new StringBuffer();
while (m.find()) {
String name = m.group(2);
String type = m.group(1);
String result;
switch (type) {
case "i":
StringBuilder inputString = new StringBuilder();
for(Edge edge : edges) {
if (edge.label.startsWith(name) && (name.length() == edge.label.length() || edge.label.charAt(name.length()) == '[')) {
if (inputString.length() > 0) {
inputString.append(", ");
}
inputString.append(edge.from);
}
}
result = inputString.toString();
break;
case "p":
Object prop = properties.get(name);
String length = m.group(4);
if (prop == null) {
result = "?";
} else if (length != null && prop instanceof LengthToString) {
LengthToString lengthProp = (LengthToString) prop;
switch(length) {
default:
case "l":
result = lengthProp.toString(Length.L);
break;
case "m":
result = lengthProp.toString(Length.M);
break;
case "s":
result = lengthProp.toString(Length.S);
break;
}
} else {
result = prop.toString();
}
break;
default:
result = "#?#";
break;
}
result = result.replace("\\", "\\\\");
result = result.replace("$", "\\$");
m.appendReplacement(sb, result);
}
m.appendTail(sb);
return sb.toString().intern();
}
private static class Edge {
final int from;
final int to;
final char num;
final String label;
final String type;
final boolean input;
public Edge(int from, int to) {
this(from, to, (char) 0, null, null, false);
}
public Edge(int from, int to, char num, String label, String type, boolean input) {
this.from = from;
this.to = to;
this.label = label != null ? label.intern() : label;
this.type = type != null ? type.intern() : type;
this.num = num;
this.input = input;
}
}
}

View File

@ -28,5 +28,5 @@ import com.sun.hotspot.igv.data.GraphDocument;
import java.io.IOException;
public interface GraphParser {
public GraphDocument parse() throws IOException;
GraphDocument parse() throws IOException;
}

View File

@ -26,8 +26,8 @@ package com.sun.hotspot.igv.data.serialization;
public interface ParseMonitor {
public void updateProgress();
void updateProgress();
public void setState(String state);
void setState(String state);
}

View File

@ -29,7 +29,6 @@ import com.sun.hotspot.igv.data.serialization.XMLParser.HandoverElementHandler;
import com.sun.hotspot.igv.data.serialization.XMLParser.TopElementHandler;
import com.sun.hotspot.igv.data.services.GroupCallback;
import java.io.IOException;
import java.io.InputStream;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
@ -39,9 +38,6 @@ import java.util.Map;
import javax.swing.SwingUtilities;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.SchemaFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@ -95,12 +91,12 @@ public class Parser implements GraphParser {
public static final String SUCCESSOR_ELEMENT = "successor";
public static final String ASSEMBLY_ELEMENT = "assembly";
public static final String DIFFERENCE_PROPERTY = "difference";
private TopElementHandler<GraphDocument> xmlDocument = new TopElementHandler<>();
private Map<Group, Boolean> differenceEncoding = new HashMap<>();
private Map<Group, InputGraph> lastParsedGraph = new HashMap<>();
private GroupCallback groupCallback;
private HashMap<String, Integer> idCache = new HashMap<>();
private ArrayList<Pair<String, String>> blockConnections = new ArrayList<>();
private final TopElementHandler<GraphDocument> xmlDocument = new TopElementHandler<>();
private final Map<Group, Boolean> differenceEncoding = new HashMap<>();
private final Map<Group, InputGraph> lastParsedGraph = new HashMap<>();
private final GroupCallback groupCallback;
private final HashMap<String, Integer> idCache = new HashMap<>();
private final ArrayList<Pair<String, String>> blockConnections = new ArrayList<>();
private int maxId = 0;
private GraphDocument graphDocument;
private final ParseMonitor monitor;
@ -118,7 +114,7 @@ public class Parser implements GraphParser {
id = maxId++;
idCache.put(i, id);
}
return id.intValue();
return id;
}
// <graphDocument>

View File

@ -36,7 +36,7 @@ import java.util.Set;
*/
public class Printer {
private InputStream in;
private final InputStream in;
public Printer() {
this(null);
@ -52,8 +52,7 @@ public class Printer {
try {
export(xmlWriter, document);
} catch (IOException ex) {
}
} catch (IOException ignored) {}
}
private void export(XMLWriter xmlWriter, GraphDocument document) throws IOException {

View File

@ -23,7 +23,6 @@
*/
package com.sun.hotspot.igv.data.serialization;
import com.sun.hotspot.igv.data.Properties;
import java.util.HashMap;
import java.util.Stack;
import org.xml.sax.Attributes;
@ -39,16 +38,10 @@ public class XMLParser implements ContentHandler {
public static class MissingAttributeException extends SAXException {
private String name;
public MissingAttributeException(String name) {
super("Missing attribute \"" + name + "\"");
this.name = name;
}
public String getAttributeName() {
return this.getMessage();
}
}
public static class HandoverElementHandler<P> extends ElementHandler<P, P> {
@ -76,24 +69,20 @@ public class XMLParser implements ContentHandler {
public static class ElementHandler<T, P> {
private String name;
private Stack<T> object = new Stack<>();
private final String name;
private final Stack<T> object = new Stack<>();
private Attributes attr;
private StringBuilder currentText;
private ParseMonitor monitor;
private HashMap<String, ElementHandler<?, ? super T>> hashtable;
private boolean needsText;
private Stack<ElementHandler<P, ?>> parentElement = new Stack<>();
private Stack<P> parentObject = new Stack<>();
private final HashMap<String, ElementHandler<?, ? super T>> hashtable;
private final boolean needsText;
private final Stack<ElementHandler<P, ?>> parentElement = new Stack<>();
private final Stack<P> parentObject = new Stack<>();
public ElementHandler(String name) {
this(name, false);
}
public ElementHandler<P, ?> getParentElement() {
return parentElement.peek();
}
public P getParentObject() {
return parentObject.peek();
}
@ -141,15 +130,6 @@ public class XMLParser implements ContentHandler {
return s;
}
public void processAttributesAsProperties(Properties p) {
int length = attr.getLength();
for (int i = 0; i < length; i++) {
String val = attr.getValue(i);
String localName = attr.getLocalName(i);
p.setProperty(val, localName);
}
}
public void startElement(ElementHandler<P, ?> parentElement, Attributes attr, ParseMonitor monitor) throws SAXException {
this.currentText = new StringBuilder();
this.attr = attr;
@ -179,8 +159,8 @@ public class XMLParser implements ContentHandler {
currentText.append(c, start, length);
}
}
private Stack<ElementHandler> stack;
private ParseMonitor monitor;
private final Stack<ElementHandler> stack;
private final ParseMonitor monitor;
public XMLParser(TopElementHandler rootHandler, ParseMonitor monitor) {
this.stack = new Stack<>();

View File

@ -36,8 +36,8 @@ import java.util.Stack;
*/
public class XMLWriter extends Writer {
private Writer inner;
private Stack<String> elementStack;
private final Writer inner;
private final Stack<String> elementStack;
public XMLWriter(Writer inner) {
this.inner = inner;
@ -114,7 +114,7 @@ public class XMLWriter extends Writer {
}
public void writeProperties(Properties props) throws IOException {
if (props.iterator().hasNext() == false) {
if (!props.iterator().hasNext()) {
return;
}

View File

@ -24,8 +24,8 @@
package com.sun.hotspot.igv.data;
import static org.junit.Assert.assertEquals;
import org.junit.*;
import static org.junit.Assert.assertEquals;
/**
*

View File

@ -24,8 +24,8 @@
package com.sun.hotspot.igv.data;
import static org.junit.Assert.*;
import org.junit.*;
import static org.junit.Assert.*;
/**
*

View File

@ -26,8 +26,8 @@ package com.sun.hotspot.igv.data;
import java.util.Arrays;
import java.util.HashSet;
import static org.junit.Assert.assertEquals;
import org.junit.*;
import static org.junit.Assert.assertEquals;
/**
*

View File

@ -26,8 +26,8 @@ package com.sun.hotspot.igv.data;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import org.junit.*;
import static org.junit.Assert.assertThat;
/**
*

View File

@ -25,8 +25,8 @@
package com.sun.hotspot.igv.data;
import static org.junit.Assert.*;
import org.junit.*;
import static org.junit.Assert.*;
/**
*

View File

@ -25,11 +25,7 @@
package com.sun.hotspot.igv.data;
import com.sun.hotspot.igv.data.Properties.InvertPropertyMatcher;
import com.sun.hotspot.igv.data.Properties.PropertyMatcher;
import com.sun.hotspot.igv.data.Properties.PropertySelector;
import com.sun.hotspot.igv.data.Properties.RegexpPropertyMatcher;
import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher;
import com.sun.hotspot.igv.data.Properties.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

View File

@ -25,8 +25,8 @@
package com.sun.hotspot.igv.data;
import static org.junit.Assert.*;
import org.junit.*;
import static org.junit.Assert.*;
/**
*

View File

@ -26,8 +26,8 @@ package com.sun.hotspot.igv.data;
import java.util.Arrays;
import java.util.LinkedHashSet;
import static org.junit.Assert.assertEquals;
import org.junit.*;
import static org.junit.Assert.assertEquals;
/**
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,16 +33,6 @@ import static org.junit.Assert.*;
*/
public class Util {
public static void assertGraphDocumentNotEquals(GraphDocument a, GraphDocument b) {
try {
assertGraphDocumentEquals(a, b);
} catch(AssertionError e) {
return;
}
fail("Graphs documents are equal!");
}
public static void assertGraphDocumentEquals(GraphDocument a, GraphDocument b) {
if (a.getElements().size() != b.getElements().size()) {
@ -61,19 +51,9 @@ public class Util {
}
}
public static void assertGroupNotEquals(Group a, Group b) {
try {
assertGroupEquals(a, b);
} catch(AssertionError e) {
return;
}
fail("Groups are equal!");
}
public static void assertGroupEquals(Group a, Group b) {
if (a.getGraphsCount() != b.getGraphsCount()) {
if (a.getElements().size() != b.getElements().size()) {
fail();
}

View File

@ -26,15 +26,15 @@
package com.sun.hotspot.igv.data.serialization;
import com.sun.hotspot.igv.data.*;
import java.io.*;
import java.io.ByteArrayInputStream;
import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.InputStream;
import java.nio.channels.Channels;
import static java.nio.charset.StandardCharsets.UTF_8;
import org.junit.*;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.*;
import org.openide.util.Exceptions;
import org.xml.sax.InputSource;
/**
*

View File

@ -287,9 +287,6 @@ public class Difference {
}
private static InputGraph createDiff(InputGraph a, InputGraph b) {
Set<InputNode> matched = new HashSet<>();
Set<NodePair> pairs = new HashSet<>();
for (InputNode n : a.getNodes()) {
String s = n.getProperties().get(MAIN_PROPERTY);

View File

@ -38,7 +38,7 @@ public abstract class AbstractFilter implements Filter {
private Properties properties;
public AbstractFilter() {
changedEvent = new ChangedEvent<Filter>(this);
changedEvent = new ChangedEvent<>(this);
properties = new Properties();
}

View File

@ -24,8 +24,8 @@
package com.sun.hotspot.igv.filter;
import com.sun.hotspot.igv.data.Properties;
import com.sun.hotspot.igv.graph.Connection.ConnectionStyle;
import com.sun.hotspot.igv.graph.*;
import com.sun.hotspot.igv.graph.Connection.ConnectionStyle;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

View File

@ -74,7 +74,7 @@ public class CombineFilter extends AbstractFilter {
}
}
slot.getSource().addSourceNodes(f.getSource());
slot.getSource().addSourceNode(f.getInputNode());
if (r.getShortProperty() != null) {
String s = f.getProperties().get(r.getShortProperty());
if (s != null && s.length() > 0) {
@ -130,7 +130,7 @@ public class CombineFilter extends AbstractFilter {
pos = Integer.parseInt(succ.getProperties().get("con"));
}
OutputSlot slot = f.createOutputSlot(pos);
slot.getSource().addSourceNodes(succ.getSource());
slot.getSource().addSourceNode(succ.getInputNode());
if (r.getShortProperty() != null) {
String s = succ.getProperties().get(r.getShortProperty());
if (s != null && s.length() > 0) {

View File

@ -25,7 +25,10 @@
package com.sun.hotspot.igv.filter;
import com.sun.hotspot.igv.graph.Diagram;
import javax.script.*;
import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
import org.openide.cookies.OpenCookie;
import org.openide.util.Exceptions;

View File

@ -23,9 +23,9 @@
*/
package com.sun.hotspot.igv.filter;
import com.sun.hotspot.igv.graph.Diagram;
import com.sun.hotspot.igv.graph.Block;
import com.sun.hotspot.igv.graph.BlockSelector;
import com.sun.hotspot.igv.graph.Diagram;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

View File

@ -56,9 +56,9 @@ public class SplitFilter extends AbstractFilter {
for (InputSlot is : f.getInputSlots()) {
for (FigureConnection c : is.getConnections()) {
OutputSlot os = c.getOutputSlot();
if (f.getSource().getSourceNodes().size() > 0) {
os.getSource().addSourceNodes(f.getSource());
os.setAssociatedNode(f.getSource().getSourceNodes().get(0));
if (f.getInputNode() != null) {
os.getSource().addSourceNode(f.getInputNode());
os.setAssociatedNode(f.getInputNode());
os.setColor(f.getColor());
}
@ -73,9 +73,9 @@ public class SplitFilter extends AbstractFilter {
for (OutputSlot os : f.getOutputSlots()) {
for (FigureConnection c : os.getConnections()) {
InputSlot is = c.getInputSlot();
if (f.getSource().getSourceNodes().size() > 0) {
is.getSource().addSourceNodes(f.getSource());
is.setAssociatedNode(f.getSource().getSourceNodes().get(0));
if (f.getInputNode() != null) {
is.getSource().addSourceNode(f.getInputNode());
is.setAssociatedNode(f.getInputNode());
is.setColor(f.getColor());
}

View File

@ -24,7 +24,9 @@
package com.sun.hotspot.igv.filter;
import com.sun.hotspot.igv.data.Properties;
import com.sun.hotspot.igv.graph.*;
import com.sun.hotspot.igv.graph.Diagram;
import com.sun.hotspot.igv.graph.Figure;
import com.sun.hotspot.igv.graph.Selector;
import java.util.ArrayList;
import java.util.List;

View File

@ -60,13 +60,7 @@ public class FilterNode extends CheckNode implements LookupListener, ChangedList
content.add(filter.getEditor());
this.filter = filter;
filter.getChangedEvent().addListener(new ChangedListener<Filter>() {
@Override
public void changed(Filter source) {
update();
}
});
filter.getChangedEvent().addListener(source -> update());
update();

View File

@ -184,13 +184,7 @@ public final class FilterTopComponent extends TopComponent implements LookupList
filterSettings.add(setting);
// Sort alphabetically
filterSettings.sort(new Comparator<FilterSetting>() {
@Override
public int compare(FilterSetting o1, FilterSetting o2) {
return o1.getName().compareTo(o2.getName());
}
});
filterSettings.sort(Comparator.comparing(FilterSetting::getName));
updateComboBox();
}
@ -268,13 +262,7 @@ public final class FilterTopComponent extends TopComponent implements LookupList
}
public FilterChildren() {
sequence.getChangedEvent().addListener(new ChangedListener<FilterChain>() {
@Override
public void changed(FilterChain source) {
addNotify();
}
});
sequence.getChangedEvent().addListener(source -> addNotify());
setBefore(false);
}
@ -706,13 +694,4 @@ public final class FilterTopComponent extends TopComponent implements LookupList
}
updateComboBox();
}
static final class ResolvableHelper implements Serializable {
private static final long serialVersionUID = 1L;
public Object readResolve() {
return FilterTopComponent.getDefault();
}
}
}

View File

@ -8,7 +8,7 @@
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*

View File

@ -18,7 +18,7 @@
<attr name="position" intvalue="900"/>
</file>
</folder>
<folder name="Actions">
<folder name="Window">
<file name="com-sun-hotspot-igv-filterwindow-actions-FilterAction.instance"/>
@ -28,6 +28,7 @@
<folder name="Window">
<file name="FilterAction.shadow">
<attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-filterwindow-actions-FilterAction.instance"/>
<attr name="position" intvalue="3"/>
</file>
</folder>
</folder>

View File

@ -23,8 +23,8 @@
*/
package com.sun.hotspot.igv.graph;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
// Selects blocks where any node is selected.
public class AnySelector implements BlockSelector {
@ -39,7 +39,7 @@ public class AnySelector implements BlockSelector {
public List<Block> selected(Diagram d) {
List<Block> l = new ArrayList<>();
for (Figure f : selector.selected(d)) {
l.add(d.getBlock(f.getBlock()));
l.add(f.getBlock());
}
return l;
}

View File

@ -23,9 +23,9 @@
*/
package com.sun.hotspot.igv.graph;
import java.awt.Dimension;
import com.sun.hotspot.igv.data.InputBlock;
import com.sun.hotspot.igv.layout.Cluster;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.util.HashSet;
import java.util.Set;
@ -45,10 +45,6 @@ public class Block implements Cluster {
this.diagram = diagram;
}
public Cluster getOuter() {
return null;
}
public InputBlock getInputBlock() {
return inputBlock;
}

View File

@ -23,15 +23,9 @@
*/
package com.sun.hotspot.igv.graph;
import com.sun.hotspot.igv.data.InputBlock;
import com.sun.hotspot.igv.data.InputBlockEdge;
import com.sun.hotspot.igv.data.InputEdge;
import com.sun.hotspot.igv.data.InputGraph;
import com.sun.hotspot.igv.data.InputNode;
import com.sun.hotspot.igv.data.*;
import com.sun.hotspot.igv.data.Properties;
import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher;
import java.awt.Font;
import java.awt.Color;
import java.util.*;
/**
@ -41,32 +35,19 @@ import java.util.*;
public class Diagram {
private List<Figure> figures;
private Map<InputBlock, Block> blocks;
private InputGraph graph;
private int curId;
private String nodeText;
private String shortNodeText;
private String tinyNodeText;
private final Font font;
private final Font slotFont;
private final Font boldFont;
private final Map<InputBlock, Block> blocks;
private final String nodeText;
private final String shortNodeText;
private final String tinyNodeText;
public static final Font FONT = new Font("Arial", Font.PLAIN, 12);
public static final Font SLOT_FONT = new Font("Arial", Font.PLAIN, 10);
public static final Font BOLD_FONT = FONT.deriveFont(Font.BOLD);
// Whether widgets derived from this diagram should be adapted for the
// control-flow graph view.
private boolean cfg;
private final Set<BlockConnection> blockConnections;
public Font getFont() {
return font;
}
public Font getSlotFont() {
return slotFont;
}
public Font getBoldFont() {
return boldFont;
}
public boolean isCFG() {
return cfg;
}
@ -75,21 +56,68 @@ public class Diagram {
this.cfg = cfg;
}
private Diagram(InputGraph graph, String nodeText, String shortNodeText,
String tinyNodeText) {
figures = new ArrayList<>();
blocks = new LinkedHashMap<>(8);
this.nodeText = "";
this.shortNodeText = "";
this.font = new Font("Arial", Font.PLAIN, 12);
this.slotFont = new Font("Arial", Font.PLAIN, 10);
this.boldFont = this.font.deriveFont(Font.BOLD);
this.cfg = false;
this.blockConnections = new HashSet<>();
this.graph = graph;
public Diagram(InputGraph graph, String nodeText, String shortNodeText,
String tinyNodeText) {
assert graph != null;
this.nodeText = nodeText;
this.shortNodeText = shortNodeText;
this.tinyNodeText = tinyNodeText;
this.figures = new ArrayList<>();
this.blocks = new LinkedHashMap<>(8);
this.blockConnections = new HashSet<>();
this.cfg = false;
int curId = 0;
for (InputBlock b : graph.getBlocks()) {
blocks.put(b, new Block(b, this));
}
Collection<InputNode> nodes = graph.getNodes();
Hashtable<Integer, Figure> figureHash = new Hashtable<>();
for (InputNode n : nodes) {
Figure f = new Figure(this, curId, n);
curId++;
f.getProperties().add(n.getProperties());
f.setBlock(blocks.get(graph.getBlock(n)));
figureHash.put(n.getId(), f);
this.figures.add(f);
}
for (InputEdge e : graph.getEdges()) {
int from = e.getFrom();
int to = e.getTo();
Figure fromFigure = figureHash.get(from);
Figure toFigure = figureHash.get(to);
if(fromFigure == null || toFigure == null) continue;
int fromIndex = e.getFromIndex();
while (fromFigure.getOutputSlots().size() <= fromIndex) {
fromFigure.createOutputSlot();
}
OutputSlot outputSlot = fromFigure.getOutputSlots().get(fromIndex);
int toIndex = e.getToIndex();
while (toFigure.getInputSlots().size() <= toIndex) {
toFigure.createInputSlot();
}
InputSlot inputSlot = toFigure.getInputSlots().get(toIndex);
FigureConnection c = createConnection(inputSlot, outputSlot, e.getLabel());
if (e.getState() == InputEdge.State.NEW) {
c.setStyle(Connection.ConnectionStyle.BOLD);
} else if (e.getState() == InputEdge.State.DELETED) {
c.setStyle(Connection.ConnectionStyle.DASHED);
}
}
for (InputBlockEdge e : graph.getBlockEdges()) {
Block p = getBlock(e.getFrom());
Block s = getBlock(e.getTo());
blockConnections.add(new BlockConnection(p, s, e.getLabel()));
}
}
public Block getBlock(InputBlock b) {
@ -113,27 +141,16 @@ public class Diagram {
return tinyNodeText;
}
public void updateBlocks() {
blocks.clear();
for (InputBlock b : graph.getBlocks()) {
Block curBlock = new Block(b, this);
blocks.put(b, curBlock);
}
}
public Collection<Block> getBlocks() {
return Collections.unmodifiableCollection(blocks.values());
}
public List<Figure> getFigures() {
return Collections.unmodifiableList(figures);
public Collection<InputBlock> getInputBlocks() {
return Collections.unmodifiableCollection(blocks.keySet());
}
public Figure createFigure() {
Figure f = new Figure(this, curId);
curId++;
this.figures.add(f);
return f;
public List<Figure> getFigures() {
return Collections.unmodifiableList(figures);
}
public FigureConnection createConnection(InputSlot inputSlot, OutputSlot outputSlot, String label) {
@ -142,88 +159,11 @@ public class Diagram {
return new FigureConnection(inputSlot, outputSlot, label);
}
public Map<InputNode, Set<Figure>> calcSourceToFigureRelation() {
Map<InputNode, Set<Figure>> map = new HashMap<>();
for(InputNode node : this.getGraph().getNodes()) {
map.put(node, new HashSet<Figure>());
}
for(Figure f : this.getFigures()) {
for(InputNode node : f.getSource().getSourceNodes()) {
map.get(node).add(f);
}
}
return map;
}
public static Diagram createDiagram(InputGraph graph, String nodeText,
String shortNodeText,
String tinyNodeText) {
if (graph == null) {
return null;
}
Diagram d = new Diagram(graph, nodeText, shortNodeText, tinyNodeText);
d.updateBlocks();
Collection<InputNode> nodes = graph.getNodes();
Hashtable<Integer, Figure> figureHash = new Hashtable<>();
for (InputNode n : nodes) {
Figure f = d.createFigure();
f.getSource().addSourceNode(n);
f.getProperties().add(n.getProperties());
f.setSubgraphs(n.getSubgraphs());
f.setBlock(graph.getBlock(n));
figureHash.put(n.getId(), f);
}
for (InputEdge e : graph.getEdges()) {
int from = e.getFrom();
int to = e.getTo();
Figure fromFigure = figureHash.get(from);
Figure toFigure = figureHash.get(to);
if(fromFigure == null || toFigure == null) continue;
assert fromFigure != null && toFigure != null;
int fromIndex = e.getFromIndex();
while (fromFigure.getOutputSlots().size() <= fromIndex) {
fromFigure.createOutputSlot();
}
OutputSlot outputSlot = fromFigure.getOutputSlots().get(fromIndex);
int toIndex = e.getToIndex();
while (toFigure.getInputSlots().size() <= toIndex) {
toFigure.createInputSlot();
}
InputSlot inputSlot = toFigure.getInputSlots().get(toIndex);
FigureConnection c = d.createConnection(inputSlot, outputSlot, e.getLabel());
if (e.getState() == InputEdge.State.NEW) {
c.setStyle(Connection.ConnectionStyle.BOLD);
} else if (e.getState() == InputEdge.State.DELETED) {
c.setStyle(Connection.ConnectionStyle.DASHED);
}
}
for (InputBlockEdge e : graph.getBlockEdges()) {
Block p = d.getBlock(e.getFrom());
Block s = d.getBlock(e.getTo());
d.blockConnections.add(new BlockConnection(p, s, e.getLabel()));
}
return d;
}
public void removeAllBlocks(Set<Block> blocksToRemove) {
Set<Figure> figuresToRemove = new HashSet<>();
for (Block b : blocksToRemove) {
for (Figure f : getFigures()) {
if (f.getBlock() == b.getInputBlock()) {
if (f.getBlock() == b) {
figuresToRemove.add(f);
}
}
@ -273,14 +213,6 @@ public class Diagram {
this.figures.remove(succ);
}
public String getName() {
return graph.getName();
}
public InputGraph getGraph() {
return graph;
}
public Set<FigureConnection> getConnections() {
Set<FigureConnection> connections = new HashSet<>();
for (Figure f : figures) {
@ -302,24 +234,6 @@ public class Diagram {
return connections;
}
public Figure getRootFigure() {
Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<>(figures);
Figure root = selector.selectSingle(new StringPropertyMatcher("name", "Root"));
if (root == null) {
root = selector.selectSingle(new StringPropertyMatcher("name", "Start"));
}
if (root == null) {
List<Figure> rootFigures = getRootFigures();
if (rootFigures.size() > 0) {
root = rootFigures.get(0);
} else if (figures.size() > 0) {
root = figures.get(0);
}
}
return root;
}
public void printStatistics() {
System.out.println("=============================================================");
System.out.println("Diagram statistics");
@ -354,14 +268,4 @@ public class Diagram {
System.out.println("=============================================================");
}
public List<Figure> getRootFigures() {
ArrayList<Figure> rootFigures = new ArrayList<>();
for (Figure f : figures) {
if (f.getPredecessors().size() == 0) {
rootFigures.add(f);
}
}
return rootFigures;
}
}

View File

@ -23,18 +23,15 @@
*/
package com.sun.hotspot.igv.graph;
import com.sun.hotspot.igv.data.InputBlock;
import com.sun.hotspot.igv.data.InputGraph;
import com.sun.hotspot.igv.data.InputNode;
import com.sun.hotspot.igv.data.Properties;
import com.sun.hotspot.igv.data.Source;
import com.sun.hotspot.igv.layout.Cluster;
import com.sun.hotspot.igv.layout.Vertex;
import java.awt.*;
import java.util.List;
import java.util.*;
public class Figure extends Properties.Entity implements Source.Provider, Vertex {
public class Figure extends Properties.Entity implements Vertex {
public static final int INSET = 8;
public static final int SLOT_WIDTH = 10;
@ -46,20 +43,19 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
public static final int WARNING_WIDTH = 16;
protected List<InputSlot> inputSlots;
protected List<OutputSlot> outputSlots;
private Source source;
private Diagram diagram;
private final InputNode inputNode;
private final Diagram diagram;
private Point position;
private List<Figure> predecessors;
private List<Figure> successors;
private List<InputGraph> subgraphs;
private final List<Figure> predecessors;
private final List<Figure> successors;
private Color color;
private String warning;
private int id;
private String idString;
private final int id;
private final String idString;
private String[] lines;
private int heightCash = -1;
private int widthCash = -1;
private InputBlock block;
private Block block;
private final FontMetrics metrics;
public int getHeight() {
@ -132,20 +128,19 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
widthCash = Math.max(widthCash, Figure.getSlotsWidth(outputSlots));
}
protected Figure(Diagram diagram, int id) {
protected Figure(Diagram diagram, int id, InputNode node) {
this.diagram = diagram;
this.source = new Source();
inputSlots = new ArrayList<>(5);
outputSlots = new ArrayList<>(1);
predecessors = new ArrayList<>(6);
successors = new ArrayList<>(6);
this.inputNode = node;
this.inputSlots = new ArrayList<>(5);
this.outputSlots = new ArrayList<>(1);
this.predecessors = new ArrayList<>(6);
this.successors = new ArrayList<>(6);
this.id = id;
idString = Integer.toString(id);
this.idString = Integer.toString(id);
this.position = new Point(0, 0);
this.color = Color.WHITE;
Canvas canvas = new Canvas();
metrics = canvas.getFontMetrics(diagram.getFont().deriveFont(Font.BOLD));
this.metrics = canvas.getFontMetrics(Diagram.FONT.deriveFont(Font.BOLD));
}
public int getId() {
@ -172,11 +167,11 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
return diagram.isCFG() && !getPredecessors().isEmpty();
}
public void setBlock(InputBlock block) {
public void setBlock(Block block) {
this.block = block;
}
public InputBlock getBlock() {
public Block getBlock() {
return block;
}
@ -185,19 +180,11 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
}
public Set<Figure> getPredecessorSet() {
Set<Figure> result = new HashSet<>();
for (Figure f : getPredecessors()) {
result.add(f);
}
return Collections.unmodifiableSet(result);
return Collections.unmodifiableSet(new HashSet<>(getPredecessors()));
}
public Set<Figure> getSuccessorSet() {
Set<Figure> result = new HashSet<>();
for (Figure f : getSuccessors()) {
result.add(f);
}
return Collections.unmodifiableSet(result);
return Collections.unmodifiableSet(new HashSet<>(getSuccessors()));
}
public List<Figure> getSuccessors() {
@ -222,14 +209,6 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
successors.remove(f);
}
public List<InputGraph> getSubgraphs() {
return subgraphs;
}
public void setSubgraphs(List<InputGraph> subgraphs) {
this.subgraphs = subgraphs;
}
@Override
public void setPosition(Point p) {
this.position = p;
@ -244,9 +223,8 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
return diagram;
}
@Override
public Source getSource() {
return source;
public InputNode getInputNode() {
return inputNode;
}
public InputSlot createInputSlot() {
@ -255,13 +233,6 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
return slot;
}
public InputSlot createInputSlot(int index) {
InputSlot slot = new InputSlot(this, index);
inputSlots.add(slot);
inputSlots.sort(Slot.slotIndexComparator);
return slot;
}
public void removeSlot(Slot s) {
assert inputSlots.contains(s) || outputSlots.contains(s);
@ -273,15 +244,12 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
if (inputSlots.contains(s)) {
inputSlots.remove(s);
} else if (outputSlots.contains(s)) {
outputSlots.remove(s);
}
} else outputSlots.remove(s);
}
public OutputSlot createOutputSlot() {
public void createOutputSlot() {
OutputSlot slot = new OutputSlot(this, -1);
outputSlots.add(slot);
return slot;
}
public OutputSlot createOutputSlot(int index) {
@ -345,13 +313,13 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
String[] strings = diagram.getNodeText().split("\n");
List<String> result = new ArrayList<>(strings.length + 1);
for (int i = 0; i < strings.length; i++) {
result.add(getProperties().resolveString(strings[i]));
for (String string : strings) {
result.add(getProperties().resolveString(string));
}
if (hasInputList()) {
String inputList = "";
List<String> inputs = new ArrayList<String>(getPredecessors().size());
List<String> inputs = new ArrayList<>(getPredecessors().size());
for (Figure p : getPredecessors()) {
inputs.add(p.getProperties().resolveString(diagram.getTinyNodeText()));
}
@ -366,13 +334,12 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
}
lines = result.toArray(new String[0]);
// Set the "label" property of each input node, so that by default
// Set the "label" property of the input node, so that by default
// search is done on the node label (without line breaks). See also
// class NodeQuickSearch in the View module.
for (InputNode n : getSource().getSourceNodes()) {
String label = n.getProperties().resolveString(diagram.getNodeText());
n.getProperties().setProperty("label", label.replaceAll("\\R", " "));
}
String label = inputNode.getProperties().resolveString(diagram.getNodeText());
inputNode.getProperties().setProperty("label", label.replaceAll("\\R", " "));
// Update figure dimensions, as these are affected by the node text.
updateWidth();
updateHeight();
@ -390,33 +357,18 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
return idString;
}
public InputNode getFirstSourceNode() {
return getSource().getSourceNodes().get(0);
}
public static int getVerticalOffset() {
return Figure.SLOT_WIDTH - Figure.OVERLAPPING;
}
public Cluster getCluster() {
if (getSource().getSourceNodes().size() == 0) {
assert false : "Should never reach here, every figure must have at least one source node!";
return null;
} else {
final InputBlock inputBlock = diagram.getGraph().getBlock(getFirstSourceNode());
assert inputBlock != null;
Cluster result = diagram.getBlock(inputBlock);
assert result != null;
return result;
}
return block;
}
@Override
public boolean isRoot() {
List<InputNode> sourceNodes = source.getSourceNodes();
if (sourceNodes.size() > 0 && getFirstSourceNode().getProperties().get("name") != null) {
return getFirstSourceNode().getProperties().get("name").equals("Root");
if (inputNode != null && inputNode.getProperties().get("name") != null) {
return inputNode.getProperties().get("name").equals("Root");
} else {
return false;
}
@ -426,8 +378,4 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex
public int compareTo(Vertex f) {
return toString().compareTo(f.toString());
}
public Rectangle getBounds() {
return new Rectangle(this.getPosition(), new Dimension(this.getWidth(), this.getHeight()));
}
}

View File

@ -23,8 +23,8 @@
*/
package com.sun.hotspot.igv.graph;
import com.sun.hotspot.igv.layout.Port;
import com.sun.hotspot.igv.layout.Cluster;
import com.sun.hotspot.igv.layout.Port;
import java.awt.Color;
import java.awt.Point;
import java.util.ArrayList;

View File

@ -78,24 +78,7 @@ public abstract class Slot implements Port, Source.Provider, Properties.Provider
}
return p;
}
public static final Comparator<Slot> slotIndexComparator = new Comparator<Slot>() {
@Override
public int compare(Slot o1, Slot o2) {
return o1.wantedIndex - o2.wantedIndex;
}
};
public static final Comparator<Slot> slotFigureComparator = new Comparator<Slot>() {
@Override
public int compare(Slot o1, Slot o2) {
return o1.figure.getId() - o2.figure.getId();
}
};
public InputNode getAssociatedNode() {
return associatedNode;
}
public static final Comparator<Slot> slotIndexComparator = Comparator.comparingInt(o -> o.wantedIndex);
public void setAssociatedNode(InputNode node) {
associatedNode = node;
@ -107,7 +90,7 @@ public abstract class Slot implements Port, Source.Provider, Properties.Provider
} else {
BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setFont(figure.getDiagram().getSlotFont().deriveFont(Font.BOLD));
g.setFont(Diagram.SLOT_FONT.deriveFont(Font.BOLD));
FontMetrics metrics = g.getFontMetrics();
return Math.max(Figure.SLOT_WIDTH, metrics.stringWidth(shortName) + 6);
}

View File

@ -23,9 +23,9 @@
*/
package com.sun.hotspot.igv.hierarchicallayout;
import com.sun.hotspot.igv.layout.Cluster;
import com.sun.hotspot.igv.layout.Link;
import com.sun.hotspot.igv.layout.Port;
import com.sun.hotspot.igv.layout.Cluster;
import java.awt.Point;
import java.util.List;
@ -35,8 +35,8 @@ import java.util.List;
*/
public class ClusterEdge implements Link {
private ClusterNode from;
private ClusterNode to;
private final ClusterNode from;
private final ClusterNode to;
private List<Point> points;
public ClusterEdge(ClusterNode from, ClusterNode to) {

View File

@ -23,9 +23,9 @@
*/
package com.sun.hotspot.igv.hierarchicallayout;
import com.sun.hotspot.igv.layout.Cluster;
import com.sun.hotspot.igv.layout.Link;
import com.sun.hotspot.igv.layout.Port;
import com.sun.hotspot.igv.layout.Cluster;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
@ -37,28 +37,16 @@ import java.util.List;
public class ClusterIngoingConnection implements Link {
private List<Point> controlPoints;
private ClusterInputSlotNode inputSlotNode;
private Link connection;
private Port inputSlot;
private Port outputSlot;
private final Port inputSlot;
private final Port outputSlot;
public ClusterIngoingConnection(ClusterInputSlotNode inputSlotNode, Link c) {
this.inputSlotNode = inputSlotNode;
this.connection = c;
this.controlPoints = new ArrayList<Point>();
this.controlPoints = new ArrayList<>();
inputSlot = c.getTo();
outputSlot = inputSlotNode.getOutputSlot();
}
public Link getConnection() {
return connection;
}
public ClusterInputSlotNode getInputSlotNode() {
return inputSlotNode;
}
public Port getTo() {
return inputSlot;
}

View File

@ -35,23 +35,12 @@ import java.awt.Point;
*/
public class ClusterInputSlotNode implements Vertex {
private final int SIZE = 0;
private Point position;
private Port inputSlot;
private Port outputSlot;
private ClusterNode blockNode;
private InterClusterConnection interBlockConnection;
private Cluster cluster;
private ClusterIngoingConnection conn;
private final Port inputSlot;
private final Port outputSlot;
private final ClusterNode blockNode;
public void setIngoingConnection(ClusterIngoingConnection c) {
conn = c;
}
public ClusterIngoingConnection getIngoingConnection() {
return conn;
}
private String id;
private final String id;
@Override
public String toString() {
@ -79,7 +68,7 @@ public class ClusterInputSlotNode implements Vertex {
@Override
public String toString() {
return "OutPort of " + thisNode.toString();
return "OutPort of " + thisNode;
}
};
@ -98,7 +87,7 @@ public class ClusterInputSlotNode implements Vertex {
@Override
public String toString() {
return "InPort of " + thisNode.toString();
return "InPort of " + thisNode;
}
};
}
@ -107,16 +96,12 @@ public class ClusterInputSlotNode implements Vertex {
return inputSlot;
}
public InterClusterConnection getInterBlockConnection() {
return interBlockConnection;
}
public Port getOutputSlot() {
return outputSlot;
}
public Dimension getSize() {
return new Dimension(SIZE, SIZE);
return new Dimension(0, 0);
}
public void setPosition(Point p) {
@ -127,12 +112,8 @@ public class ClusterInputSlotNode implements Vertex {
return position;
}
public void setInterBlockConnection(InterClusterConnection interBlockConnection) {
this.interBlockConnection = interBlockConnection;
}
public Cluster getCluster() {
return cluster;
return null;
}
public boolean isRoot() {

View File

@ -29,11 +29,7 @@ import com.sun.hotspot.igv.layout.Port;
import com.sun.hotspot.igv.layout.Vertex;
import java.awt.Dimension;
import java.awt.Point;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
/**
*
@ -43,14 +39,12 @@ public class ClusterNode implements Vertex {
private Cluster cluster;
private Port inputSlot;
private Port outputSlot;
private Set<Vertex> subNodes;
private final Set<Vertex> subNodes;
private Dimension size;
private Point position;
private Set<Link> subEdges;
private boolean dirty;
private final Set<Link> subEdges;
private boolean root;
private String name;
private final String name;
private final int border;
private final Dimension nodeOffset;
private final int headerVerticalSpace;
@ -59,10 +53,10 @@ public class ClusterNode implements Vertex {
public ClusterNode(Cluster cluster, String name, int border,
Dimension nodeOffset, int headerVerticalSpace,
Dimension emptySize) {
this.subNodes = new HashSet<Vertex>();
this.subEdges = new HashSet<Link>();
this.subNodes = new HashSet<>();
this.subEdges = new HashSet<>();
this.cluster = cluster;
position = new Point(0, 0);
this.position = new Point(0, 0);
this.name = name;
this.border = border;
this.nodeOffset = nodeOffset;
@ -94,8 +88,6 @@ public class ClusterNode implements Vertex {
}
public void updateSize() {
calculateSize();
final ClusterNode widget = this;
@ -114,22 +106,6 @@ public class ClusterNode implements Vertex {
return "ClusterInput(" + name + ")";
}
};
outputSlot = new Port() {
public Point getRelativePosition() {
return new Point(size.width / 2, 0);//size.height);
}
public Vertex getVertex() {
return widget;
}
@Override
public String toString() {
return "ClusterOutput(" + name + ")";
}
};
}
private void calculateSize() {
@ -174,7 +150,7 @@ public class ClusterNode implements Vertex {
}
for (Link l : subEdges) {
List<Point> points = new ArrayList<Point>(l.getControlPoints());
List<Point> points = new ArrayList<>(l.getControlPoints());
for (Point p : points) {
p.x -= minX;
p.y -= minY;
@ -192,10 +168,6 @@ public class ClusterNode implements Vertex {
}
public Port getOutputSlot() {
return outputSlot;
}
public Dimension getSize() {
return size;
}
@ -215,7 +187,7 @@ public class ClusterNode implements Vertex {
for (Link e : subEdges) {
List<Point> arr = e.getControlPoints();
ArrayList<Point> newArr = new ArrayList<Point>(arr.size());
ArrayList<Point> newArr = new ArrayList<>(arr.size());
for (Point p : arr) {
if (p != null) {
Point p2 = new Point(p);
@ -238,10 +210,6 @@ public class ClusterNode implements Vertex {
cluster = c;
}
public void setDirty(boolean b) {
dirty = b;
}
public void setRoot(boolean b) {
root = b;
}

View File

@ -23,9 +23,9 @@
*/
package com.sun.hotspot.igv.hierarchicallayout;
import com.sun.hotspot.igv.layout.Cluster;
import com.sun.hotspot.igv.layout.Link;
import com.sun.hotspot.igv.layout.Port;
import com.sun.hotspot.igv.layout.Cluster;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
@ -37,18 +37,13 @@ import java.util.List;
public class ClusterOutgoingConnection implements Link {
private List<Point> intermediatePoints;
private ClusterOutputSlotNode outputSlotNode;
private Link connection;
private Port inputSlot;
private Port outputSlot;
private final Port inputSlot;
private final Port outputSlot;
public ClusterOutgoingConnection(ClusterOutputSlotNode outputSlotNode, Link c) {
this.outputSlotNode = outputSlotNode;
this.connection = c;
this.intermediatePoints = new ArrayList<Point>();
outputSlot = c.getFrom();
inputSlot = outputSlotNode.getInputSlot();
this.intermediatePoints = new ArrayList<>();
this.outputSlot = c.getFrom();
this.inputSlot = outputSlotNode.getInputSlot();
}
public Port getTo() {

View File

@ -35,15 +35,13 @@ import java.awt.Point;
*/
public class ClusterOutputSlotNode implements Vertex {
private final int SIZE = 0;
private Point position;
private Port inputSlot;
private Port outputSlot;
private ClusterNode blockNode;
private boolean root;
private final Port inputSlot;
private final Port outputSlot;
private final ClusterNode blockNode;
private Cluster cluster;
private ClusterOutgoingConnection conn;
private String id;
private final String id;
public void setOutgoingConnection(ClusterOutgoingConnection c) {
this.conn = c;
@ -79,7 +77,7 @@ public class ClusterOutputSlotNode implements Vertex {
@Override
public String toString() {
return "InPort of " + thisNode.toString();
return "InPort of " + thisNode;
}
};
@ -88,7 +86,7 @@ public class ClusterOutputSlotNode implements Vertex {
public Point getRelativePosition() {
Point p = new Point(thisNode.getPosition());
p.x += blockNode.getBorder();
p.y = 0;//thisBlockNode.getSize().height;
p.y = 0;
return p;
}
@ -98,13 +96,13 @@ public class ClusterOutputSlotNode implements Vertex {
@Override
public String toString() {
return "OutPort of " + thisNode.toString();
return "OutPort of " + thisNode;
}
};
}
public Dimension getSize() {
return new Dimension(SIZE, SIZE);
return new Dimension(0, 0);
}
public void setPosition(Point p) {
@ -127,16 +125,12 @@ public class ClusterOutputSlotNode implements Vertex {
cluster = c;
}
public void setRoot(boolean b) {
root = b;
}
public Cluster getCluster() {
return cluster;
}
public boolean isRoot() {
return root;
return false;
}
public int compareTo(Vertex o) {

View File

@ -1,90 +0,0 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package com.sun.hotspot.igv.hierarchicallayout;
/**
*
* @author Thomas Wuerthinger
*/
public class Edge<N, E> {
private E data;
private Node<N, E> source;
private Node<N, E> dest;
protected Edge(Graph<N, E> graph, Node<N, E> source, Node<N, E> dest, E data) {
setData(data);
this.source = source;
this.dest = dest;
assert source != null;
assert dest != null;
assert source.getGraph() == dest.getGraph();
assert source.getGraph() != null;
assert dest.getGraph() != null;
}
public Node<N, E> getSource() {
return source;
}
public Node<N, E> getDest() {
return dest;
}
public E getData() {
return data;
}
public void setData(E e) {
data = e;
}
public void remove() {
source.getGraph().removeEdge(this, null);
}
public boolean isSelfLoop() {
return source == dest;
}
public void reverse() {
// Remove from current source / dest
source.removeOutEdge(this);
dest.removeInEdge(this);
Node<N, E> tmp = source;
source = dest;
dest = tmp;
// Add to new source / dest
source.addOutEdge(this);
dest.addInEdge(this);
}
@Override
public String toString() {
return "Edge (" + source + " -- " + dest + "): " + data;
}
}

View File

@ -1,292 +0,0 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package com.sun.hotspot.igv.hierarchicallayout;
import java.util.*;
/**
*
* @author Thomas Wuerthinger
*/
public class Graph<N, E> {
private HashMap<Object, Node<N, E>> nodes;
private HashMap<Object, Edge<N, E>> edges;
private List<Node<N, E>> nodeList;
public Graph() {
nodes = new HashMap<>();
edges = new HashMap<>();
nodeList = new ArrayList<>();
}
public Node<N, E> createNode(N data, Object key) {
Node<N, E> n = new Node<>(this, data);
assert key == null || !nodes.containsKey(key);
if (key != null) {
nodes.put(key, n);
}
nodeList.add(n);
return n;
}
public Edge<N, E> createEdge(Node<N, E> source, Node<N, E> dest, E data, Object key) {
Edge<N, E> e = new Edge<>(this, source, dest, data);
source.addOutEdge(e);
dest.addInEdge(e);
if (key != null) {
edges.put(key, e);
}
return e;
}
public Node<N, E> getNode(Object key) {
return nodes.get(key);
}
public Edge<N, E> getEdge(Object key) {
return edges.get(key);
}
public Collection<Edge<N, E>> getEdges() {
return Collections.unmodifiableCollection(edges.values());
}
public Collection<Node<N, E>> getNodes() {
return Collections.unmodifiableList(nodeList);
}
public void removeEdge(Edge<N, E> e, Object key) {
assert key == null || edges.containsKey(key);
if (key != null) {
edges.remove(key);
}
e.getSource().removeOutEdge(e);
e.getDest().removeInEdge(e);
}
public class DFSTraversalVisitor {
public void visitNode(Node<N, E> n) {
}
public boolean visitEdge(Edge<N, E> e, boolean backEdge) {
return true;
}
}
public class BFSTraversalVisitor {
public void visitNode(Node<N, E> n, int depth) {
}
}
public List<Node<N, E>> getNodesWithInDegree(int x) {
return getNodesWithInDegree(x, true);
}
public List<Node<N, E>> getNodesWithInDegree(int x, boolean countSelfLoops) {
List<Node<N, E>> result = new ArrayList<>();
for (Node<N, E> n : getNodes()) {
if (n.getInDegree(countSelfLoops) == x) {
result.add(n);
}
}
return result;
}
private void markReachable(Node<N, E> startingNode) {
ArrayList<Node<N, E>> arr = new ArrayList<>();
arr.add(startingNode);
for (Node<N, E> n : getNodes()) {
n.setReachable(false);
}
traverseDFS(arr, new DFSTraversalVisitor() {
@Override
public void visitNode(Node<N, E> n) {
n.setReachable(true);
}
});
}
public void traverseBFS(Node<N, E> startingNode, BFSTraversalVisitor tv, boolean longestPath) {
if (longestPath) {
markReachable(startingNode);
}
for (Node<N, E> n : getNodes()) {
n.setVisited(false);
n.setActive(false);
}
Queue<Node<N, E>> queue = new LinkedList<>();
queue.add(startingNode);
startingNode.setVisited(true);
int layer = 0;
Node<N, E> lastOfLayer = startingNode;
Node<N, E> lastAdded = null;
while (!queue.isEmpty()) {
Node<N, E> current = queue.poll();
tv.visitNode(current, layer);
current.setActive(false);
for (Edge<N, E> e : current.getOutEdges()) {
if (!e.getDest().isVisited()) {
boolean allow = true;
if (longestPath) {
for (Node<N, E> pred : e.getDest().getPredecessors()) {
if ((!pred.isVisited() || pred.isActive()) && pred.isReachable()) {
allow = false;
break;
}
}
}
if (allow) {
queue.offer(e.getDest());
lastAdded = e.getDest();
e.getDest().setVisited(true);
e.getDest().setActive(true);
}
}
}
if (current == lastOfLayer && !queue.isEmpty()) {
lastOfLayer = lastAdded;
layer++;
}
}
}
public void traverseDFS(DFSTraversalVisitor tv) {
traverseDFS(getNodes(), tv);
}
public void traverseDFS(Collection<Node<N, E>> startingNodes, DFSTraversalVisitor tv) {
for (Node<N, E> n : getNodes()) {
n.setVisited(false);
n.setActive(false);
}
boolean result = false;
for (Node<N, E> n : startingNodes) {
traverse(tv, n);
}
}
private void traverse(DFSTraversalVisitor tv, Node<N, E> n) {
if (!n.isVisited()) {
n.setVisited(true);
n.setActive(true);
tv.visitNode(n);
for (Edge<N, E> e : n.getOutEdges()) {
Node<N, E> next = e.getDest();
if (next.isActive()) {
tv.visitEdge(e, true);
} else {
if (tv.visitEdge(e, false)) {
traverse(tv, next);
}
}
}
n.setActive(false);
}
}
public boolean hasCycles() {
for (Node<N, E> n : getNodes()) {
n.setVisited(false);
n.setActive(false);
}
boolean result = false;
for (Node<N, E> n : getNodes()) {
result |= checkCycles(n);
if (result) {
break;
}
}
return result;
}
private boolean checkCycles(Node<N, E> n) {
if (n.isActive()) {
return true;
}
if (!n.isVisited()) {
n.setVisited(true);
n.setActive(true);
for (Node<N, E> succ : n.getSuccessors()) {
if (checkCycles(succ)) {
return true;
}
}
n.setActive(false);
}
return false;
}
@Override
public String toString() {
StringBuilder s = new StringBuilder();
s.append("Nodes: ");
for (Node<N, E> n : getNodes()) {
s.append(n.toString());
s.append("\n");
}
s.append("Edges: ");
for (Edge<N, E> e : getEdges()) {
s.append(e.toString());
s.append("\n");
}
return s.toString();
}
}

View File

@ -23,22 +23,15 @@
*/
package com.sun.hotspot.igv.hierarchicallayout;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Canvas;
import java.awt.Font;
import java.awt.FontMetrics;
import java.util.*;
import com.sun.hotspot.igv.layout.Cluster;
import com.sun.hotspot.igv.layout.LayoutGraph;
import com.sun.hotspot.igv.layout.LayoutManager;
import com.sun.hotspot.igv.layout.Link;
import com.sun.hotspot.igv.layout.Vertex;
import com.sun.hotspot.igv.layout.*;
import java.awt.*;
import java.util.*;
public class HierarchicalCFGLayoutManager implements LayoutManager {
private static final int BLOCK_BORDER = 5;
private FontMetrics fontMetrics;
private final FontMetrics fontMetrics;
// Lays out nodes within a single cluster (basic block).
private LayoutManager subManager;
// Lays out clusters in the CFG.
@ -78,13 +71,12 @@ public class HierarchicalCFGLayoutManager implements LayoutManager {
// Compute layout for each cluster.
for (Cluster c : clusters) {
ClusterNode n = clusterNode.get(c);
subManager.doLayout(new LayoutGraph(n.getSubEdges(), n.getSubNodes()), new HashSet<Link>());
subManager.doLayout(new LayoutGraph(n.getSubEdges(), n.getSubNodes()), new HashSet<>());
n.updateSize();
}
// Compute inter-cluster layout.
manager.doLayout(new LayoutGraph(clusterEdges, new HashSet<>(clusterNode.values())),
new HashSet<Link>());
manager.doLayout(new LayoutGraph(clusterEdges, new HashSet<>(clusterNode.values())), new HashSet<>());
// Write back results.
writeBackClusterBounds(clusterNode);
@ -144,11 +136,11 @@ public class HierarchicalCFGLayoutManager implements LayoutManager {
// Map from "primitive" cluster edges to their input links.
Map<AbstractMap.SimpleEntry<Cluster, Cluster>, Link> inputLink = new HashMap<>();
for (Link l : graph.getLinks()) {
inputLink.put(new AbstractMap.SimpleEntry<Cluster, Cluster>(l.getFromCluster(), l.getToCluster()), l);
inputLink.put(new AbstractMap.SimpleEntry<>(l.getFromCluster(), l.getToCluster()), l);
}
for (ClusterEdge ce : clusterEdges) {
assert (ce.getControlPoints() != null);
Link l = inputLink.get(new AbstractMap.SimpleEntry<Cluster, Cluster>(ce.getFromCluster(), ce.getToCluster()));
Link l = inputLink.get(new AbstractMap.SimpleEntry<>(ce.getFromCluster(), ce.getToCluster()));
l.setControlPoints(ce.getControlPoints());
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,20 +23,10 @@
*/
package com.sun.hotspot.igv.hierarchicallayout;
import com.sun.hotspot.igv.layout.*;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.TreeSet;
import com.sun.hotspot.igv.layout.Cluster;
import com.sun.hotspot.igv.layout.LayoutGraph;
import com.sun.hotspot.igv.layout.LayoutManager;
import com.sun.hotspot.igv.layout.Link;
import com.sun.hotspot.igv.layout.Port;
import com.sun.hotspot.igv.layout.Vertex;
import java.util.*;
/**
*
@ -53,10 +43,6 @@ public class HierarchicalClusterLayoutManager implements LayoutManager {
this.combine = combine;
}
public void doLayout(LayoutGraph graph) {
doLayout(graph, new HashSet<Vertex>(), new HashSet<Vertex>(), new HashSet<Link>());
}
public void doLayout(LayoutGraph graph, Set<? extends Link> importantLinks) {
doLayout(graph);
}
@ -69,34 +55,32 @@ public class HierarchicalClusterLayoutManager implements LayoutManager {
this.manager = manager;
}
public void doLayout(LayoutGraph graph, Set<? extends Vertex> firstLayerHint, Set<? extends Vertex> lastLayerHint, Set<? extends Link> importantLinks) {
public void doLayout(LayoutGraph graph) {
assert graph.verify();
HashMap<Cluster, List<Vertex>> lists = new HashMap<Cluster, List<Vertex>>();
HashMap<Cluster, List<Link>> listsConnection = new HashMap<Cluster, List<Link>>();
HashMap<Cluster, HashMap<Port, ClusterInputSlotNode>> clusterInputSlotHash = new HashMap<Cluster, HashMap<Port, ClusterInputSlotNode>>();
HashMap<Cluster, HashMap<Port, ClusterOutputSlotNode>> clusterOutputSlotHash = new HashMap<Cluster, HashMap<Port, ClusterOutputSlotNode>>();
HashMap<Cluster, List<Link>> listsConnection = new HashMap<>();
HashMap<Cluster, HashMap<Port, ClusterInputSlotNode>> clusterInputSlotHash = new HashMap<>();
HashMap<Cluster, HashMap<Port, ClusterOutputSlotNode>> clusterOutputSlotHash = new HashMap<>();
HashMap<Cluster, ClusterNode> clusterNodes = new HashMap<Cluster, ClusterNode>();
HashMap<Cluster, Set<ClusterInputSlotNode>> clusterInputSlotSet = new HashMap<Cluster, Set<ClusterInputSlotNode>>();
HashMap<Cluster, Set<ClusterOutputSlotNode>> clusterOutputSlotSet = new HashMap<Cluster, Set<ClusterOutputSlotNode>>();
Set<Link> clusterEdges = new HashSet<Link>();
Set<Link> interClusterEdges = new HashSet<Link>();
HashMap<Link, ClusterOutgoingConnection> linkClusterOutgoingConnection = new HashMap<Link, ClusterOutgoingConnection>();
HashMap<Link, InterClusterConnection> linkInterClusterConnection = new HashMap<Link, InterClusterConnection>();
HashMap<Link, ClusterIngoingConnection> linkClusterIngoingConnection = new HashMap<Link, ClusterIngoingConnection>();
Set<ClusterNode> clusterNodeSet = new HashSet<ClusterNode>();
HashMap<Cluster, ClusterNode> clusterNodes = new HashMap<>();
HashMap<Cluster, Set<ClusterInputSlotNode>> clusterInputSlotSet = new HashMap<>();
HashMap<Cluster, Set<ClusterOutputSlotNode>> clusterOutputSlotSet = new HashMap<>();
Set<Link> clusterEdges = new HashSet<>();
Set<Link> interClusterEdges = new HashSet<>();
HashMap<Link, ClusterOutgoingConnection> linkClusterOutgoingConnection = new HashMap<>();
HashMap<Link, InterClusterConnection> linkInterClusterConnection = new HashMap<>();
HashMap<Link, ClusterIngoingConnection> linkClusterIngoingConnection = new HashMap<>();
Set<ClusterNode> clusterNodeSet = new HashSet<>();
Set<Cluster> cluster = graph.getClusters();
int z = 0;
for (Cluster c : cluster) {
lists.put(c, new ArrayList<Vertex>());
listsConnection.put(c, new ArrayList<Link>());
clusterInputSlotHash.put(c, new HashMap<Port, ClusterInputSlotNode>());
clusterOutputSlotHash.put(c, new HashMap<Port, ClusterOutputSlotNode>());
clusterOutputSlotSet.put(c, new TreeSet<ClusterOutputSlotNode>());
clusterInputSlotSet.put(c, new TreeSet<ClusterInputSlotNode>());
listsConnection.put(c, new ArrayList<>());
clusterInputSlotHash.put(c, new HashMap<>());
clusterOutputSlotHash.put(c, new HashMap<>());
clusterOutputSlotSet.put(c, new TreeSet<>());
clusterInputSlotSet.put(c, new TreeSet<>());
ClusterNode cn = new ClusterNode(c, "" + z);
clusterNodes.put(c, cn);
clusterNodeSet.add(cn);
@ -156,7 +140,7 @@ public class HierarchicalClusterLayoutManager implements LayoutManager {
}
if (outputSlotNode == null) {
outputSlotNode = new ClusterOutputSlotNode(clusterNodes.get(fromCluster), "Out " + fromCluster.toString() + " " + samePort.toString());
outputSlotNode = new ClusterOutputSlotNode(clusterNodes.get(fromCluster), "Out " + fromCluster.toString() + " " + samePort);
clusterOutputSlotSet.get(fromCluster).add(outputSlotNode);
ClusterOutgoingConnection conn = new ClusterOutgoingConnection(outputSlotNode, l);
outputSlotNode.setOutgoingConnection(conn);
@ -171,16 +155,13 @@ public class HierarchicalClusterLayoutManager implements LayoutManager {
}
if (inputSlotNode == null) {
inputSlotNode = new ClusterInputSlotNode(clusterNodes.get(toCluster), "In " + toCluster.toString() + " " + samePort.toString());
inputSlotNode = new ClusterInputSlotNode(clusterNodes.get(toCluster), "In " + toCluster.toString() + " " + samePort);
clusterInputSlotSet.get(toCluster).add(inputSlotNode);
}
ClusterIngoingConnection conn = new ClusterIngoingConnection(inputSlotNode, l);
inputSlotNode.setIngoingConnection(conn);
clusterNodes.get(toCluster).addSubEdge(conn);
if (samePort != null) {
clusterInputSlotHash.get(toCluster).put(samePort, inputSlotNode);
}
clusterInputSlotHash.get(toCluster).put(samePort, inputSlotNode);
linkClusterIngoingConnection.put(l, conn);
@ -194,13 +175,13 @@ public class HierarchicalClusterLayoutManager implements LayoutManager {
Timing t = null;
if (TRACE) {
new Timing("Child timing");
t = new Timing("Child timing");
t.start();
}
for (Cluster c : cluster) {
ClusterNode n = clusterNodes.get(c);
subManager.doLayout(new LayoutGraph(n.getSubEdges(), n.getSubNodes()), new HashSet<Link>());
subManager.doLayout(new LayoutGraph(n.getSubEdges(), n.getSubNodes()), new HashSet<>());
n.updateSize();
}
@ -235,7 +216,7 @@ public class HierarchicalClusterLayoutManager implements LayoutManager {
assert conn2 != null;
assert conn3 != null;
List<Point> points = new ArrayList<Point>();
List<Point> points = new ArrayList<>();
points.addAll(conn1.getControlPoints());
points.addAll(conn2.getControlPoints());

View File

@ -56,9 +56,9 @@ public class HierarchicalLayoutManager implements LayoutManager {
SAME_OUTPUTS
}
// Options
private Combine combine;
private int dummyWidth;
private int dummyHeight;
private final Combine combine;
private final int dummyWidth;
private final int dummyHeight;
private int xOffset;
private int layerOffset;
private int maxLayerLength;
@ -71,14 +71,13 @@ public class HierarchicalLayoutManager implements LayoutManager {
private HashMap<Vertex, LayoutNode> vertexToLayoutNode;
private HashMap<Link, List<Point>> reversedLinkStartPoints;
private HashMap<Link, List<Point>> reversedLinkEndPoints;
private HashMap<LayoutEdge, LayoutEdge> bottomEdgeHash;
private HashMap<Link, List<Point>> splitStartPoints;
private HashMap<Link, List<Point>> splitEndPoints;
private LayoutGraph graph;
private List<LayoutNode>[] layers;
private int layerCount;
private Set<? extends Link> importantLinks;
private Set<Link> linksToFollow;
private final Set<Link> linksToFollow;
private class LayoutNode {
@ -123,7 +122,7 @@ public class HierarchicalLayoutManager implements LayoutManager {
}
}
private abstract class AlgorithmPart {
private abstract static class AlgorithmPart {
public void start() {
if (CHECK) {
@ -159,10 +158,6 @@ public class HierarchicalLayoutManager implements LayoutManager {
}
}
public HierarchicalLayoutManager() {
this(Combine.NONE);
}
public HierarchicalLayoutManager(Combine b) {
this.combine = b;
this.dummyWidth = DUMMY_WIDTH;
@ -183,10 +178,6 @@ public class HierarchicalLayoutManager implements LayoutManager {
this.layerOffset = layerOffset;
}
public int getMaxLayerLength() {
return maxLayerLength;
}
public void setMaxLayerLength(int v) {
maxLayerLength = v;
}
@ -216,7 +207,7 @@ public class HierarchicalLayoutManager implements LayoutManager {
@Override
public void doLayout(LayoutGraph graph) {
doLayout(graph, new HashSet<Link>());
doLayout(graph, new HashSet<>());
}
@ -231,7 +222,6 @@ public class HierarchicalLayoutManager implements LayoutManager {
selfEdges = new HashSet<>();
reversedLinkStartPoints = new HashMap<>();
reversedLinkEndPoints = new HashMap<>();
bottomEdgeHash = new HashMap<>();
nodes = new ArrayList<>();
splitStartPoints = new HashMap<>();
splitEndPoints = new HashMap<>();
@ -452,7 +442,6 @@ public class HierarchicalLayoutManager implements LayoutManager {
points.add(null);
points.addAll(splitEndPoints.get(e.link));
//checkPoints(points);
if (reversedLinks.contains(e.link)) {
Collections.reverse(points);
}
@ -476,7 +465,6 @@ public class HierarchicalLayoutManager implements LayoutManager {
if (reversedLinks.contains(e.link)) {
Collections.reverse(points);
}
//checkPoints(points);
assert !linkPositions.containsKey(e.link);
linkPositions.put(e.link, points);
}
@ -538,105 +526,60 @@ public class HierarchicalLayoutManager implements LayoutManager {
}
}
private static class Segment {
public float d;
public int orderNumber = -1;
public ArrayList<LayoutNode> nodes = new ArrayList<>();
public HashSet<Segment> succs = new HashSet<>();
public HashSet<Segment> preds = new HashSet<>();
public Region region;
}
private static final Comparator<Segment> segmentComparator = new Comparator<Segment>() {
@Override
public int compare(Segment s1, Segment s2) {
return s1.orderNumber - s2.orderNumber;
private static final Comparator<LayoutNode> nodePositionComparator = Comparator.comparingInt(n -> n.pos);
private static final Comparator<LayoutNode> nodeProcessingDownComparator = (n1, n2) -> {
int n1VIP = 0;
for (LayoutEdge e : n1.preds) {
if (e.vip) {
n1VIP++;
}
}
};
private static class Region {
public float d;
public int minOrderNumber;
public SortedSet<Segment> segments = new TreeSet<>(segmentComparator);
public HashSet<Region> succs = new HashSet<>(4);
public HashSet<Region> preds = new HashSet<>(4);
}
private static final Comparator<Region> regionComparator = new Comparator<Region>() {
@Override
public int compare(Region r1, Region r2) {
return r1.minOrderNumber - r2.minOrderNumber;
int n2VIP = 0;
for (LayoutEdge e : n2.preds) {
if (e.vip) {
n2VIP++;
}
}
};
private static final Comparator<LayoutNode> nodePositionComparator = new Comparator<LayoutNode>() {
@Override
public int compare(LayoutNode n1, LayoutNode n2) {
return n1.pos - n2.pos;
if (n1VIP != n2VIP) {
return n2VIP - n1VIP;
}
};
private static final Comparator<LayoutNode> nodeProcessingDownComparator = new Comparator<LayoutNode>() {
@Override
public int compare(LayoutNode n1, LayoutNode n2) {
int n1VIP = 0;
for (LayoutEdge e : n1.preds) {
if (e.vip) {
n1VIP++;
}
}
int n2VIP = 0;
for (LayoutEdge e : n2.preds) {
if (e.vip) {
n2VIP++;
}
}
if (n1VIP != n2VIP) {
return n2VIP - n1VIP;
}
if (n1.vertex == null) {
if (n2.vertex == null) {
return 0;
}
return -1;
}
if (n1.vertex == null) {
if (n2.vertex == null) {
return 1;
return 0;
}
return n1.preds.size() - n2.preds.size();
return -1;
}
if (n2.vertex == null) {
return 1;
}
return n1.preds.size() - n2.preds.size();
};
private static final Comparator<LayoutNode> nodeProcessingUpComparator = new Comparator<LayoutNode>() {
@Override
public int compare(LayoutNode n1, LayoutNode n2) {
int n1VIP = 0;
for (LayoutEdge e : n1.succs) {
if (e.vip) {
n1VIP++;
}
private static final Comparator<LayoutNode> nodeProcessingUpComparator = (n1, n2) -> {
int n1VIP = 0;
for (LayoutEdge e : n1.succs) {
if (e.vip) {
n1VIP++;
}
int n2VIP = 0;
for (LayoutEdge e : n2.succs) {
if (e.vip) {
n2VIP++;
}
}
if (n1VIP != n2VIP) {
return n2VIP - n1VIP;
}
if (n1.vertex == null) {
if (n2.vertex == null) {
return 0;
}
return -1;
}
if (n2.vertex == null) {
return 1;
}
return n1.succs.size() - n2.succs.size();
}
int n2VIP = 0;
for (LayoutEdge e : n2.succs) {
if (e.vip) {
n2VIP++;
}
}
if (n1VIP != n2VIP) {
return n2VIP - n1VIP;
}
if (n1.vertex == null) {
if (n2.vertex == null) {
return 0;
}
return -1;
}
if (n2.vertex == null) {
return 1;
}
return n1.succs.size() - n2.succs.size();
};
private class AssignXCoordinates extends AlgorithmPart {
@ -683,22 +626,19 @@ public class HierarchicalLayoutManager implements LayoutManager {
for (int i = 0; i < SWEEP_ITERATIONS; i++) {
sweepDown();
adjustSpace();
sweepUp(false);
sweepUp();
adjustSpace();
}
sweepDown();
adjustSpace();
sweepUp(true);
sweepUp();
}
private void adjustSpace() {
for (int i = 0; i < layers.length; i++) {
// space[i] = new ArrayList<>();
int curX = 0;
for (LayoutNode n : layers[i]) {
space[i].add(n.x);
// curX += n.width + xOffset;
}
}
}
@ -781,7 +721,7 @@ public class HierarchicalLayoutManager implements LayoutManager {
}
}
private void sweepUp(boolean onlyDummies) {
private void sweepUp() {
for (int i = layers.length - 1; i >= 0; i--) {
NodeRow r = new NodeRow(space[i]);
for (LayoutNode n : upProcessingOrder[i]) {
@ -791,16 +731,6 @@ public class HierarchicalLayoutManager implements LayoutManager {
}
}
private void doubleSweep() {
for (int i = layers.length - 2; i >= 0; i--) {
NodeRow r = new NodeRow(space[i]);
for (LayoutNode n : upProcessingOrder[i]) {
int optimal = calculateOptimalBoth(n);
r.insert(n, optimal);
}
}
}
private void sweepDown() {
for (int i = 1; i < layers.length; i++) {
NodeRow r = new NodeRow(space[i]);
@ -814,8 +744,8 @@ public class HierarchicalLayoutManager implements LayoutManager {
private static class NodeRow {
private TreeSet<LayoutNode> treeSet;
private ArrayList<Integer> space;
private final TreeSet<LayoutNode> treeSet;
private final ArrayList<Integer> space;
public NodeRow(ArrayList<Integer> space) {
treeSet = new TreeSet<>(nodePositionComparator);
@ -832,7 +762,7 @@ public class HierarchicalLayoutManager implements LayoutManager {
SortedSet<LayoutNode> headSet = treeSet.headSet(n);
LayoutNode leftNeighbor = null;
LayoutNode leftNeighbor;
int minX = Integer.MIN_VALUE;
if (!headSet.isEmpty()) {
leftNeighbor = headSet.last();
@ -843,7 +773,7 @@ public class HierarchicalLayoutManager implements LayoutManager {
n.x = minX;
} else {
LayoutNode rightNeighbor = null;
LayoutNode rightNeighbor;
SortedSet<LayoutNode> tailSet = treeSet.tailSet(n);
int maxX = Integer.MAX_VALUE;
if (!tailSet.isEmpty()) {
@ -851,11 +781,7 @@ public class HierarchicalLayoutManager implements LayoutManager {
maxX = rightNeighbor.x - offset(n, rightNeighbor) - n.width;
}
if (pos > maxX) {
n.x = maxX;
} else {
n.x = pos;
}
n.x = Math.min(pos, maxX);
assert minX <= maxX : minX + " vs " + maxX;
}
@ -863,13 +789,7 @@ public class HierarchicalLayoutManager implements LayoutManager {
treeSet.add(n);
}
}
private static Comparator<LayoutNode> crossingNodeComparator = new Comparator<LayoutNode>() {
@Override
public int compare(LayoutNode n1, LayoutNode n2) {
return n1.crossingNumber - n2.crossingNumber;
}
};
private static final Comparator<LayoutNode> crossingNodeComparator = Comparator.comparingInt(n -> n.crossingNumber);
private class CrossingReduction extends AlgorithmPart {
@ -945,10 +865,9 @@ public class HierarchicalLayoutManager implements LayoutManager {
}
private void updatePositions() {
for (int i = 0; i < layers.length; i++) {
for (List<LayoutNode> layer : layers) {
int z = 0;
for (LayoutNode n : layers[i]) {
for (LayoutNode n : layer) {
n.pos = z;
z++;
}
@ -1088,18 +1007,18 @@ public class HierarchicalLayoutManager implements LayoutManager {
protected void run() {
int curY = 0;
for (int i = 0; i < layers.length; i++) {
for (List<LayoutNode> layer : layers) {
int maxHeight = 0;
int baseLine = 0;
int bottomBaseLine = 0;
for (LayoutNode n : layers[i]) {
for (LayoutNode n : layer) {
maxHeight = Math.max(maxHeight, n.height - n.yOffset - n.bottomYOffset);
baseLine = Math.max(baseLine, n.yOffset);
bottomBaseLine = Math.max(bottomBaseLine, n.bottomYOffset);
}
int maxXOffset = 0;
for (LayoutNode n : layers[i]) {
for (LayoutNode n : layer) {
if (n.vertex == null) {
// Dummy node
n.y = curY;
@ -1147,13 +1066,7 @@ public class HierarchicalLayoutManager implements LayoutManager {
if (combine == Combine.SAME_OUTPUTS) {
Comparator<LayoutEdge> comparator = new Comparator<LayoutEdge>() {
@Override
public int compare(LayoutEdge e1, LayoutEdge e2) {
return e1.to.layer - e2.to.layer;
}
};
Comparator<LayoutEdge> comparator = Comparator.comparingInt(e -> e.to.layer);
HashMap<Integer, List<LayoutEdge>> portHash = new HashMap<>();
ArrayList<LayoutNode> currentNodes = new ArrayList<>(nodes);
for (LayoutNode n : currentNodes) {
@ -1165,12 +1078,12 @@ public class HierarchicalLayoutManager implements LayoutManager {
for (LayoutEdge e : succs) {
assert e.from.layer < e.to.layer;
if (e.from.layer != e.to.layer - 1) {
if (maxLayerLength != -1 && e.to.layer - e.from.layer > maxLayerLength/* && e.to.preds.size() > 1 && e.from.succs.size() > 1*/) {
if (maxLayerLength != -1 && e.to.layer - e.from.layer > maxLayerLength) {
assert maxLayerLength > 2;
e.to.preds.remove(e);
e.from.succs.remove(e);
LayoutEdge topEdge = null;
LayoutEdge topEdge;
if (combine == Combine.SAME_OUTPUTS && topNodeHash.containsKey(e.relativeFrom)) {
LayoutNode topNode = topNodeHash.get(e.relativeFrom);
@ -1193,19 +1106,19 @@ public class HierarchicalLayoutManager implements LayoutManager {
topEdge = new LayoutEdge();
topEdge.relativeFrom = e.relativeFrom;
topEdge.from = e.from;
topEdge.relativeTo = topNode.width / 2;
topEdge.relativeTo = 0;
topEdge.to = topNode;
topEdge.link = e.link;
topEdge.vip = e.vip;
e.from.succs.add(topEdge);
topNode.preds.add(topEdge);
topNodeHash.put(e.relativeFrom, topNode);
bottomNodeHash.put(e.relativeFrom, new HashMap<Integer, LayoutNode>());
bottomNodeHash.put(e.relativeFrom, new HashMap<>());
}
HashMap<Integer, LayoutNode> hash = bottomNodeHash.get(e.relativeFrom);
LayoutNode bottomNode = null;
LayoutNode bottomNode;
if (hash.containsKey(e.to.layer)) {
bottomNode = hash.get(e.to.layer);
} else {
@ -1226,13 +1139,12 @@ public class HierarchicalLayoutManager implements LayoutManager {
bottomEdge.link = e.link;
bottomEdge.vip = e.vip;
e.to.preds.add(bottomEdge);
bottomEdgeHash.put(topEdge, bottomEdge);
bottomNode.succs.add(bottomEdge);
} else {
Integer i = e.relativeFrom;
if (!portHash.containsKey(i)) {
portHash.put(i, new ArrayList<LayoutEdge>());
portHash.put(i, new ArrayList<>());
}
portHash.get(i).add(e);
}
@ -1565,7 +1477,7 @@ public class HierarchicalLayoutManager implements LayoutManager {
final int offset = xOffset + DUMMY_WIDTH;
int curX = 0;
int curY = 0;
int curWidth = node.width + reversedDown.size() * offset;
for (int pos : reversedDown) {
ArrayList<LayoutEdge> reversedSuccs = new ArrayList<>();
@ -1577,15 +1489,15 @@ public class HierarchicalLayoutManager implements LayoutManager {
}
ArrayList<Point> startPoints = new ArrayList<>();
startPoints.add(new Point(curWidth, curX));
startPoints.add(new Point(pos, curX));
startPoints.add(new Point(curWidth, curY));
startPoints.add(new Point(pos, curY));
startPoints.add(new Point(pos, reversedDown.size() * offset));
for (LayoutEdge e : reversedSuccs) {
reversedLinkStartPoints.put(e.link, startPoints);
}
node.inOffsets.put(pos, -curX);
curX += offset;
node.inOffsets.put(pos, -curY);
curY += offset;
node.height += offset;
node.yOffset += offset;
curWidth -= offset;
@ -1597,13 +1509,7 @@ public class HierarchicalLayoutManager implements LayoutManager {
}
node.width += widthFactor * offset;
if (hasReversedDown) {
curX = -offset;
} else {
curX = offset;
}
curX = 0;
int curX = 0;
int minX = 0;
if (hasReversedDown) {
minX = -offset * reversedUp.size();
@ -1761,33 +1667,29 @@ public class HierarchicalLayoutManager implements LayoutManager {
}
}
}
private Comparator<Link> linkComparator = new Comparator<Link>() {
private final Comparator<Link> linkComparator = (l1, l2) -> {
if (l1.isVIP() && !l2.isVIP()) {
return -1;
}
@Override
public int compare(Link l1, Link l2) {
if (l1.isVIP() && !l2.isVIP()) {
return -1;
}
if (!l1.isVIP() && l2.isVIP()) {
return 1;
}
if (!l1.isVIP() && l2.isVIP()) {
return 1;
}
int result = l1.getFrom().getVertex().compareTo(l2.getFrom().getVertex());
if (result != 0) {
return result;
}
result = l1.getTo().getVertex().compareTo(l2.getTo().getVertex());
if (result != 0) {
return result;
}
result = l1.getFrom().getRelativePosition().x - l2.getFrom().getRelativePosition().x;
if (result != 0) {
return result;
}
result = l1.getTo().getRelativePosition().x - l2.getTo().getRelativePosition().x;
int result = l1.getFrom().getVertex().compareTo(l2.getFrom().getVertex());
if (result != 0) {
return result;
}
result = l1.getTo().getVertex().compareTo(l2.getTo().getVertex());
if (result != 0) {
return result;
}
result = l1.getFrom().getRelativePosition().x - l2.getFrom().getRelativePosition().x;
if (result != 0) {
return result;
}
result = l1.getTo().getRelativePosition().x - l2.getTo().getRelativePosition().x;
return result;
};
private class BuildDatastructure extends AlgorithmPart {
@ -1797,11 +1699,8 @@ public class HierarchicalLayoutManager implements LayoutManager {
// Set up nodes
List<Vertex> vertices = new ArrayList<>(graph.getVertices());
// Order roots first to create more natural layer assignments.
Collections.sort(vertices,
(Vertex a, Vertex b) ->
a.isRoot() == b.isRoot() ?
a.compareTo(b) :
Boolean.compare(b.isRoot(), a.isRoot()));
vertices.sort((Vertex a, Vertex b) ->
a.isRoot() == b.isRoot() ? a.compareTo(b) : Boolean.compare(b.isRoot(), a.isRoot()));
for (Vertex v : vertices) {
LayoutNode node = new LayoutNode();

View File

@ -23,9 +23,9 @@
*/
package com.sun.hotspot.igv.hierarchicallayout;
import com.sun.hotspot.igv.layout.Cluster;
import com.sun.hotspot.igv.layout.Link;
import com.sun.hotspot.igv.layout.Port;
import com.sun.hotspot.igv.layout.Cluster;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
@ -36,22 +36,14 @@ import java.util.List;
*/
public class InterClusterConnection implements Link {
private Port inputSlot;
private Port outputSlot;
private final Port inputSlot;
private final Port outputSlot;
private List<Point> intermediatePoints;
private ClusterInputSlotNode inputSlotNode;
private ClusterOutputSlotNode outputSlotNode;
public InterClusterConnection(ClusterOutputSlotNode outputSlotNode, ClusterInputSlotNode inputSlotNode) {
this.outputSlotNode = outputSlotNode;
this.inputSlotNode = inputSlotNode;
this.inputSlot = inputSlotNode.getInputSlot();
this.outputSlot = outputSlotNode.getOutputSlot();
intermediatePoints = new ArrayList<Point>();
}
public ClusterOutputSlotNode getOutputSlotNode() {
return outputSlotNode;
this.intermediatePoints = new ArrayList<>();
}
public Port getTo() {

View File

@ -41,7 +41,7 @@ public class LinearLayoutManager implements LayoutManager {
@Override
public void doLayout(LayoutGraph graph) {
doLayout(graph, new HashSet<Link>());
doLayout(graph, new HashSet<>());
}
@Override

View File

@ -1,161 +0,0 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package com.sun.hotspot.igv.hierarchicallayout;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
*
* @author Thomas Wuerthinger
*/
public class Node<N, E> {
private N data;
private List<Edge<N, E>> inEdges;
private List<Edge<N, E>> outEdges;
private boolean visited;
private boolean active;
private boolean reachable;
private Graph<N, E> graph;
protected boolean isVisited() {
return visited;
}
protected void setVisited(boolean b) {
visited = b;
}
protected boolean isReachable() {
return reachable;
}
protected void setReachable(boolean b) {
reachable = b;
}
protected boolean isActive() {
return active;
}
protected void setActive(boolean b) {
active = b;
}
public int getInDegree() {
return getInDegree(true);
}
public int getInDegree(boolean countSelfLoops) {
if (countSelfLoops) {
return inEdges.size();
} else {
int cnt = 0;
for (Edge<N, E> e : inEdges) {
if (e.getSource() != this) {
cnt++;
}
}
return cnt;
}
}
public int getOutDegree() {
return outEdges.size();
}
protected Node(Graph<N, E> graph, N data) {
setData(data);
this.graph = graph;
inEdges = new ArrayList<>();
outEdges = new ArrayList<>();
}
protected void addInEdge(Edge<N, E> e) {
inEdges.add(e);
}
public Graph<N, E> getGraph() {
return graph;
}
protected void addOutEdge(Edge<N, E> e) {
outEdges.add(e);
}
protected void removeInEdge(Edge<N, E> e) {
//assert inEdges.contains(e);
inEdges.remove(e);
}
protected void removeOutEdge(Edge<N, E> e) {
//assert outEdges.contains(e);
outEdges.remove(e);
}
public List<Edge<N, E>> getInEdges() {
return Collections.unmodifiableList(inEdges);
}
public List<Edge<N, E>> getOutEdges() {
return Collections.unmodifiableList(outEdges);
}
public List<Node<N, E>> getSuccessors() {
ArrayList<Node<N, E>> succ = new ArrayList<>();
for (Edge<N, E> e : getOutEdges()) {
Node<N, E> n = e.getDest();
if (!succ.contains(n)) {
succ.add(n);
}
}
return succ;
}
public List<Node<N, E>> getPredecessors() {
ArrayList<Node<N, E>> pred = new ArrayList<>();
for (Edge<N, E> e : getInEdges()) {
Node<N, E> n = e.getSource();
if (!pred.contains(n)) {
pred.add(n);
}
}
return pred;
}
public N getData() {
return data;
}
public void setData(N d) {
data = d;
}
@Override
public String toString() {
return "Node: " + data;
}
}

View File

@ -31,7 +31,7 @@ public class Timing {
private long lastValue;
private long sum;
private String name;
private final String name;
public Timing(String name) {
this.name = name;
@ -49,7 +49,7 @@ public class Timing {
}
public void print() {
System.out.println(toString());
System.out.println();
}
public void start() {

View File

@ -33,11 +33,9 @@ import java.util.Set;
*/
public interface Cluster extends Comparable<Cluster> {
public Cluster getOuter();
void setBounds(Rectangle r);
public void setBounds(Rectangle r);
Set<? extends Cluster> getSuccessors();
public Set<? extends Cluster> getSuccessors();
public Dimension getNodeOffset();
Dimension getNodeOffset();
}

View File

@ -31,14 +31,14 @@ import java.util.*;
*/
public class LayoutGraph {
private Set<? extends Link> links;
private SortedSet<Vertex> vertices;
private HashMap<Vertex, Set<Port>> inputPorts;
private HashMap<Vertex, Set<Port>> outputPorts;
private HashMap<Port, Set<Link>> portLinks;
private final Set<? extends Link> links;
private final SortedSet<Vertex> vertices;
private final HashMap<Vertex, Set<Port>> inputPorts;
private final HashMap<Vertex, Set<Port>> outputPorts;
private final HashMap<Port, Set<Link>> portLinks;
public LayoutGraph(Set<? extends Link> links) {
this(links, new HashSet<Vertex>());
this(links, new HashSet<>());
}
public LayoutGraph(Set<? extends Link> links, Set<? extends Vertex> additionalVertices) {
@ -61,8 +61,8 @@ public class LayoutGraph {
if (!vertices.contains(v1)) {
outputPorts.put(v1, new HashSet<Port>(1));
inputPorts.put(v1, new HashSet<Port>(3));
outputPorts.put(v1, new HashSet<>(1));
inputPorts.put(v1, new HashSet<>(3));
vertices.add(v1);
assert vertices.contains(v1);
}
@ -70,8 +70,8 @@ public class LayoutGraph {
if (!vertices.contains(v2)) {
vertices.add(v2);
assert vertices.contains(v2);
outputPorts.put(v2, new HashSet<Port>(1));
inputPorts.put(v2, new HashSet<Port>(3));
outputPorts.put(v2, new HashSet<>(1));
inputPorts.put(v2, new HashSet<>(3));
}
if (!portLinks.containsKey(p)) {
@ -80,7 +80,7 @@ public class LayoutGraph {
}
if (!portLinks.containsKey(p2)) {
portLinks.put(p2, new HashSet<Link>(3));
portLinks.put(p2, new HashSet<>(3));
}
outputPorts.get(v1).add(p);
@ -92,10 +92,9 @@ public class LayoutGraph {
for (Vertex v : additionalVertices) {
if (!vertices.contains(v)) {
outputPorts.put(v, new HashSet<Port>(1));
inputPorts.put(v, new HashSet<Port>(3));
outputPorts.put(v, new HashSet<>(1));
inputPorts.put(v, new HashSet<>(3));
vertices.add(v);
vertices.contains(v);
}
}
}
@ -184,12 +183,12 @@ public class LayoutGraph {
}
public Set<Vertex> findRootVertices() {
return findRootVertices(new HashSet<Vertex>());
return findRootVertices(new HashSet<>());
}
public SortedSet<Cluster> getClusters() {
SortedSet<Cluster> clusters = new TreeSet<Cluster>();
SortedSet<Cluster> clusters = new TreeSet<>();
for (Vertex v : getVertices()) {
if (v.getCluster() != null) {
clusters.add(v.getCluster());

View File

@ -31,7 +31,7 @@ import java.util.Set;
*/
public interface LayoutManager {
public void doLayout(LayoutGraph graph);
void doLayout(LayoutGraph graph);
public void doLayout(LayoutGraph graph, Set<? extends Link> importantLinks);
void doLayout(LayoutGraph graph, Set<? extends Link> importantLinks);
}

View File

@ -32,17 +32,17 @@ import java.util.List;
*/
public interface Link {
public Port getFrom();
Port getFrom();
public Cluster getFromCluster();
Cluster getFromCluster();
public Port getTo();
Port getTo();
public Cluster getToCluster();
Cluster getToCluster();
public boolean isVIP();
boolean isVIP();
public List<Point> getControlPoints();
List<Point> getControlPoints();
public void setControlPoints(List<Point> list);
void setControlPoints(List<Point> list);
}

View File

@ -31,7 +31,7 @@ import java.awt.Point;
*/
public interface Port {
public Vertex getVertex();
Vertex getVertex();
public Point getRelativePosition();
Point getRelativePosition();
}

View File

@ -32,13 +32,13 @@ import java.awt.Point;
*/
public interface Vertex extends Comparable<Vertex> {
public Dimension getSize();
Dimension getSize();
public Point getPosition();
Point getPosition();
public void setPosition(Point p);
void setPosition(Point p);
public boolean isRoot();
boolean isRoot();
public Cluster getCluster();
Cluster getCluster();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,8 +24,6 @@
*/
package com.sun.hotspot.igv.connection;
import com.sun.hotspot.igv.data.GraphDocument;
import com.sun.hotspot.igv.data.serialization.BinaryParser;
import com.sun.hotspot.igv.data.serialization.Parser;
import com.sun.hotspot.igv.data.services.GroupCallback;
import java.io.IOException;
@ -33,16 +31,12 @@ import java.nio.channels.SocketChannel;
import org.openide.util.Exceptions;
public class Client implements Runnable {
private final boolean binary;
private final SocketChannel socket;
private final GraphDocument rootDocument;
private final GroupCallback callback;
public Client(SocketChannel socket, GraphDocument rootDocument, GroupCallback callback, boolean binary) {
public Client(SocketChannel socket, GroupCallback callback) {
this.callback = callback;
this.socket = socket;
this.binary = binary;
this.rootDocument = rootDocument;
}
@Override
@ -51,13 +45,8 @@ public class Client implements Runnable {
try {
final SocketChannel channel = socket;
channel.configureBlocking(true);
if (binary) {
new BinaryParser(channel, null, rootDocument, callback).parse();
} else {
// signal readiness to client VM (old protocol)
channel.socket().getOutputStream().write('y');
new Parser(channel, null, callback).parse();
}
channel.socket().getOutputStream().write('y');
new Parser(channel, null, callback).parse();
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
} finally {

View File

@ -24,7 +24,6 @@
*/
package com.sun.hotspot.igv.connection;
import com.sun.hotspot.igv.data.GraphDocument;
import com.sun.hotspot.igv.data.services.GroupCallback;
import com.sun.hotspot.igv.settings.Settings;
import java.io.IOException;
@ -42,16 +41,12 @@ import org.openide.util.RequestProcessor;
* @author Thomas Wuerthinger
*/
public class Server implements PreferenceChangeListener {
private final boolean binary;
private ServerSocketChannel serverSocket;
private final GraphDocument rootDocument;
private final GroupCallback callback;
private int port;
private Runnable serverRunnable;
public Server(GraphDocument rootDocument, GroupCallback callback, boolean binary) {
this.binary = binary;
this.rootDocument = rootDocument;
public Server(GroupCallback callback) {
this.callback = callback;
initializeNetwork();
Settings.get().addPreferenceChangeListener(this);
@ -59,22 +54,20 @@ public class Server implements PreferenceChangeListener {
@Override
public void preferenceChange(PreferenceChangeEvent e) {
int curPort = Integer.parseInt(Settings.get().get(binary ? Settings.PORT_BINARY : Settings.PORT, binary ? Settings.PORT_BINARY_DEFAULT : Settings.PORT_DEFAULT));
int curPort = Integer.parseInt(Settings.get().get(Settings.PORT, Settings.PORT_DEFAULT));
if (curPort != port) {
initializeNetwork();
}
}
private void initializeNetwork() {
int curPort = Integer.parseInt(Settings.get().get(binary ? Settings.PORT_BINARY : Settings.PORT, binary ? Settings.PORT_BINARY_DEFAULT : Settings.PORT_DEFAULT));
int curPort = Integer.parseInt(Settings.get().get(Settings.PORT, Settings.PORT_DEFAULT));
this.port = curPort;
try {
serverSocket = ServerSocketChannel.open();
serverSocket.bind(new InetSocketAddress(curPort));
} catch (Throwable ex) {
NotifyDescriptor message = new NotifyDescriptor.Message("Could not create server. Listening for incoming binary data is disabled.", NotifyDescriptor.ERROR_MESSAGE);
NotifyDescriptor message = new NotifyDescriptor.Message("Could not create server. Listening for incoming data is disabled.", NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notifyLater(message);
return;
}
@ -90,10 +83,10 @@ public class Server implements PreferenceChangeListener {
clientSocket.close();
return;
}
RequestProcessor.getDefault().post(new Client(clientSocket, rootDocument, callback, binary), 0, Thread.MAX_PRIORITY);
RequestProcessor.getDefault().post(new Client(clientSocket, callback), 0, Thread.MAX_PRIORITY);
} catch (IOException ex) {
serverSocket = null;
NotifyDescriptor message = new NotifyDescriptor.Message("Error during listening for incoming connections. Listening for incoming binary data is disabled.", NotifyDescriptor.ERROR_MESSAGE);
NotifyDescriptor message = new NotifyDescriptor.Message("Error during listening for incoming connections. Listening for incoming data is disabled.", NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notifyLater(message);
return;
}

View File

@ -35,11 +35,11 @@ import java.util.Set;
*/
public class SelectionCoordinator {
private static SelectionCoordinator singleInstance = new SelectionCoordinator();
private Set<Object> selectedObjects;
private Set<Object> highlightedObjects;
private ChangedEvent<SelectionCoordinator> selectedChangedEvent;
private ChangedEvent<SelectionCoordinator> highlightedChangedEvent;
private static final SelectionCoordinator singleInstance = new SelectionCoordinator();
private final Set<Integer> selectedObjects;
private final Set<Integer> highlightedObjects;
private final ChangedEvent<SelectionCoordinator> selectedChangedEvent;
private final ChangedEvent<SelectionCoordinator> highlightedChangedEvent;
public static SelectionCoordinator getInstance() {
return singleInstance;
@ -52,11 +52,11 @@ public class SelectionCoordinator {
highlightedObjects = new HashSet<>();
}
public Set<Object> getSelectedObjects() {
public Set<Integer> getSelectedObjects() {
return Collections.unmodifiableSet(selectedObjects);
}
public Set<Object> getHighlightedObjects() {
public Set<Integer> getHighlightedObjects() {
return Collections.unmodifiableSet(highlightedObjects);
}
@ -68,72 +68,18 @@ public class SelectionCoordinator {
return selectedChangedEvent;
}
public void addHighlighted(Object o) {
if (!highlightedObjects.contains(o)) {
highlightedObjects.add(o);
highlightedObjectsChanged();
}
}
public void removeHighlighted(Object o) {
if (highlightedObjects.contains(o)) {
highlightedObjects.remove(o);
highlightedObjectsChanged();
}
}
public void addAllHighlighted(Set<? extends Object> s) {
int oldSize = highlightedObjects.size();
highlightedObjects.addAll(s);
if (oldSize != highlightedObjects.size()) {
highlightedObjectsChanged();
}
}
public void removeAllHighlighted(Set<? extends Object> s) {
int oldSize = highlightedObjects.size();
highlightedObjects.removeAll(s);
if (oldSize != highlightedObjects.size()) {
highlightedObjectsChanged();
}
}
private void highlightedObjectsChanged() {
highlightedChangedEvent.fire();
}
public void addAllSelected(Set<? extends Object> s) {
int oldSize = selectedObjects.size();
selectedObjects.addAll(s);
if (oldSize != selectedObjects.size()) {
selectedObjectsChanged();
}
}
public void removeAllSelected(Set<? extends Object> s) {
int oldSize = selectedObjects.size();
selectedObjects.removeAll(s);
if (oldSize != selectedObjects.size()) {
selectedObjectsChanged();
}
}
public void setSelectedObjects(Set<? extends Object> s) {
public void setSelectedObjects(Set<Integer> s) {
assert s != null;
selectedObjects.clear();
selectedObjects.addAll(s);
selectedObjectsChanged();
getSelectedChangedEvent().fire();
}
private void selectedObjectsChanged() {
selectedChangedEvent.fire();
}
public void setHighlightedObjects(Set<? extends Object> s) {
public void setHighlightedObjects(Set<Integer> s) {
assert s != null;
this.highlightedObjects.clear();
this.highlightedObjects.addAll(s);
highlightedObjectsChanged();
highlightedObjects.clear();
highlightedObjects.addAll(s);
getHighlightedChangedEvent().fire();
}
}

View File

@ -4,13 +4,13 @@
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
@ -24,6 +24,9 @@
*/
package com.sun.hotspot.igv.servercompiler;
import com.ibm.wala.util.graph.Graph;
import com.ibm.wala.util.graph.dominators.Dominators;
import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
import com.sun.hotspot.igv.data.InputBlock;
import com.sun.hotspot.igv.data.InputEdge;
import com.sun.hotspot.igv.data.InputGraph;
@ -33,9 +36,6 @@ import java.util.*;
import java.util.function.Predicate;
import org.openide.ErrorManager;
import org.openide.util.lookup.ServiceProvider;
import com.ibm.wala.util.graph.Graph;
import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
import com.ibm.wala.util.graph.dominators.Dominators;
/**
*
@ -122,13 +122,7 @@ public class ServerCompilerScheduler implements Scheduler {
Map<Node, List<Node>> controlSuccs = new HashMap<>();
// Nodes reachable in backward traversal from root.
private Map<InputBlock, InputBlock> dominatorMap;
private static final Comparator<InputEdge> edgeComparator = new Comparator<InputEdge>() {
@Override
public int compare(InputEdge o1, InputEdge o2) {
return o1.getToIndex() - o2.getToIndex();
}
};
private static final Comparator<InputEdge> edgeComparator = Comparator.comparingInt(InputEdge::getToIndex);
public void buildBlocks() {
@ -173,7 +167,7 @@ public class ServerCompilerScheduler implements Scheduler {
rootBlock = block;
}
blockCount++;
Set<Node> blockTerminators = new HashSet<Node>();
Set<Node> blockTerminators = new HashSet<>();
// Move forwards until a terminator node is found, assigning all
// visited nodes to the current block.
while (true) {
@ -283,12 +277,12 @@ public class ServerCompilerScheduler implements Scheduler {
Node n = new Node();
n.preds.add(p);
n.succs.add(s);
controlSuccs.put(n, Arrays.asList(s));
controlSuccs.put(n, Collections.singletonList(s));
n.isCFG = true;
// Update predecessor node p.
p.succs.remove(s);
p.succs.add(n);
controlSuccs.put(p, Arrays.asList(n));
controlSuccs.put(p, Collections.singletonList(n));
// Update successor node s.
Collections.replaceAll(s.preds, p, n);
return n;
@ -373,30 +367,27 @@ public class ServerCompilerScheduler implements Scheduler {
}
}
private static final Comparator<Node> schedulePriority = new Comparator<Node>(){
@Override
public int compare(Node n1, Node n2) {
// Order by rank, then idx.
int r1 = n1.rank, r2 = n2.rank;
int o1, o2;
if (r1 != r2) { // Different rank.
o1 = r1;
o2 = r2;
} else { // Same rank, order by idx.
o1 = Integer.parseInt(n1.inputNode.getProperties().get("idx"));
o2 = Integer.parseInt(n2.inputNode.getProperties().get("idx"));
}
return Integer.compare(o1, o2);
};
};
private static final Comparator<Node> schedulePriority = (n1, n2) -> {
// Order by rank, then idx.
int r1 = n1.rank, r2 = n2.rank;
int o1, o2;
if (r1 != r2) { // Different rank.
o1 = r1;
o2 = r2;
} else { // Same rank, order by idx.
o1 = Integer.parseInt(n1.inputNode.getProperties().get("idx"));
o2 = Integer.parseInt(n2.inputNode.getProperties().get("idx"));
}
return Integer.compare(o1, o2);
};
private List<InputNode> scheduleBlock(Collection<Node> nodes) {
List<InputNode> schedule = new ArrayList<InputNode>();
List<InputNode> schedule = new ArrayList<>();
// Initialize ready priority queue with nodes without predecessors.
Queue<Node> ready = new PriorityQueue<Node>(schedulePriority);
Queue<Node> ready = new PriorityQueue<>(schedulePriority);
// Set of nodes that have been enqueued.
Set<Node> visited = new HashSet<Node>(nodes.size());
Set<Node> visited = new HashSet<>(nodes.size());
for (Node n : nodes) {
if (n.preds.isEmpty()) {
ready.add(n);
@ -712,9 +703,7 @@ public class ServerCompilerScheduler implements Scheduler {
// Find all nodes reachable in backward traversal from root.
private Set<Node> reachableNodes() {
Node root = findRoot();
if (root == null) {
assert false : "No root found!";
}
assert root != null : "No root found!";
Set<Node> reachable = new HashSet<>();
reachable.add(root);
Stack<Node> stack = new Stack<>();
@ -753,7 +742,7 @@ public class ServerCompilerScheduler implements Scheduler {
int to = e.getTo();
if (!edgeMap.containsKey(to)) {
edgeMap.put(to, new ArrayList<InputEdge>());
edgeMap.put(to, new ArrayList<>());
}
@ -862,7 +851,7 @@ public class ServerCompilerScheduler implements Scheduler {
}
for (String warning : n.warnings) {
if (!nodesPerWarning.containsKey(warning)) {
nodesPerWarning.put(warning, new HashSet<Node>());
nodesPerWarning.put(warning, new HashSet<>());
}
nodesPerWarning.get(warning).add(n);
}

View File

@ -47,9 +47,7 @@ public class Settings {
public static final String DEFAULT_VIEW = "defaultView";
public static final int DEFAULT_VIEW_DEFAULT = DefaultView.SEA_OF_NODES;
public static final String PORT = "port";
public static final String PORT_BINARY = "portBinary";
public static final String PORT_DEFAULT = "4444";
public static final String PORT_BINARY_DEFAULT = "4445";
public static final String DIRECTORY = "directory";
public static final String DIRECTORY_DEFAULT = System.getProperty("user.dir");

View File

@ -32,7 +32,7 @@ import org.netbeans.api.visual.widget.Widget;
*/
public class DoubleClickAction extends WidgetAction.Adapter {
private DoubleClickHandler handler;
private final DoubleClickHandler handler;
public DoubleClickAction(DoubleClickHandler handler) {
this.handler = handler;

View File

@ -32,5 +32,5 @@ import org.netbeans.api.visual.widget.Widget;
*/
public interface DoubleClickHandler {
public void handleDoubleClick(Widget w, WidgetMouseEvent e);
void handleDoubleClick(Widget w, WidgetMouseEvent e);
}

View File

@ -1,208 +0,0 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package com.sun.hotspot.igv.util;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JComponent;
import org.netbeans.api.visual.widget.Scene;
/**
* @author David Kaspar
* @author Thomas Wuerthinger
*/
public class ExtendedSatelliteComponent extends JComponent implements MouseListener, MouseMotionListener, Scene.SceneListener, ComponentListener {
private Scene scene;
private Image image;
private int imageWidth;
private int imageHeight;
public ExtendedSatelliteComponent(Scene scene) {
this.scene = scene;
setDoubleBuffered(true);
setPreferredSize(new Dimension(128, 128));
addMouseListener(this);
addMouseMotionListener(this);
}
@Override
public void addNotify() {
super.addNotify();
scene.addSceneListener(this);
JComponent viewComponent = scene.getView();
if (viewComponent == null) {
viewComponent = scene.createView();
}
viewComponent.addComponentListener(this);
repaint();
}
@Override
public void removeNotify() {
scene.getView().removeComponentListener(this);
scene.removeSceneListener(this);
super.removeNotify();
}
public void update() {
this.image = null;
repaint();
}
@Override
public void paint(Graphics g) {
Graphics2D gr = (Graphics2D) g;
super.paint(g);
Rectangle bounds = scene.getBounds();
Dimension size = getSize();
double sx = bounds.width > 0 ? (double) size.width / bounds.width : 0.0;
double sy = bounds.width > 0 ? (double) size.height / bounds.height : 0.0;
double scale = Math.min(sx, sy);
int vw = (int) (scale * bounds.width);
int vh = (int) (scale * bounds.height);
int vx = (size.width - vw) / 2;
int vy = (size.height - vh) / 2;
if (image == null || vw != imageWidth || vh != imageHeight) {
imageWidth = vw;
imageHeight = vh;
image = this.createImage(imageWidth, imageHeight);
Graphics2D ig = (Graphics2D) image.getGraphics();
ig.scale(scale, scale);
scene.paint(ig);
}
gr.drawImage(image, vx, vy, this);
JComponent component = scene.getView();
double zoomFactor = scene.getZoomFactor();
Rectangle viewRectangle = component != null ? component.getVisibleRect() : null;
if (viewRectangle != null) {
Rectangle window = new Rectangle(
(int) ((double) viewRectangle.x * scale / zoomFactor),
(int) ((double) viewRectangle.y * scale / zoomFactor),
(int) ((double) viewRectangle.width * scale / zoomFactor),
(int) ((double) viewRectangle.height * scale / zoomFactor));
window.translate(vx, vy);
gr.setColor(new Color(200, 200, 200, 128));
gr.fill(window);
gr.setColor(Color.BLACK);
gr.drawRect(window.x, window.y, window.width - 1, window.height - 1);
}
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
moveVisibleRect(e.getPoint());
}
@Override
public void mouseReleased(MouseEvent e) {
moveVisibleRect(e.getPoint());
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mouseDragged(MouseEvent e) {
moveVisibleRect(e.getPoint());
}
@Override
public void mouseMoved(MouseEvent e) {
}
private void moveVisibleRect(Point center) {
JComponent component = scene.getView();
if (component == null) {
return;
}
double zoomFactor = scene.getZoomFactor();
Rectangle bounds = scene.getBounds();
Dimension size = getSize();
double sx = bounds.width > 0 ? (double) size.width / bounds.width : 0.0;
double sy = bounds.width > 0 ? (double) size.height / bounds.height : 0.0;
double scale = Math.min(sx, sy);
int vw = (int) (scale * bounds.width);
int vh = (int) (scale * bounds.height);
int vx = (size.width - vw) / 2;
int vy = (size.height - vh) / 2;
int cx = (int) ((double) (center.x - vx) / scale * zoomFactor);
int cy = (int) ((double) (center.y - vy) / scale * zoomFactor);
Rectangle visibleRect = component.getVisibleRect();
visibleRect.x = cx - visibleRect.width / 2;
visibleRect.y = cy - visibleRect.height / 2;
component.scrollRectToVisible(visibleRect);
}
@Override
public void sceneRepaint() {
}
@Override
public void sceneValidating() {
}
@Override
public void sceneValidated() {
}
@Override
public void componentResized(ComponentEvent e) {
repaint();
}
@Override
public void componentMoved(ComponentEvent e) {
repaint();
}
@Override
public void componentShown(ComponentEvent e) {
}
@Override
public void componentHidden(ComponentEvent e) {
}
}

Some files were not shown because too many files have changed in this diff Show More