Mercurial > hg > truffle
changeset 3138:47d03d774d20
IdealGraphVisualizer: in the control flow graph (block view), allow nodes with longer text to be larger than the default size and center their text horizontally
author | Peter Hofer <peter.hofer@jku.at> |
---|---|
date | Mon, 04 Jul 2011 12:03:50 +0200 |
parents | 7b805b65679f |
children | c16d0e36a577 |
files | src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java |
diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java Mon Jul 04 11:28:08 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java Mon Jul 04 12:03:50 2011 +0200 @@ -31,6 +31,7 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.Point; +import java.awt.Rectangle; import org.netbeans.api.visual.border.BorderFactory; import org.netbeans.api.visual.model.ObjectState; import org.netbeans.api.visual.widget.LabelWidget; @@ -41,13 +42,13 @@ */ public class BlockWidget extends LabelWidget implements Vertex { - public static final Dimension SIZE = new Dimension(20, 20); + public static final Dimension MIN_SIZE = new Dimension(20, 20); private InputBlock block; private Port inputSlot; private Port outputSlot; private Cluster cluster; private boolean root; - private static final Font font = new Font("Serif", Font.PLAIN, 12); + 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; public static final Color HOVER_FOREGROUND_COLOR = Color.BLUE; @@ -59,29 +60,24 @@ this.setLabel(block.getName()); this.setForeground(NORMAL_FOREGROUND_COLOR); this.setBorder(BorderFactory.createLineBorder(1, NORMAL_FOREGROUND_COLOR)); - this.setMinimumSize(SIZE); - this.setMaximumSize(SIZE); + this.setMinimumSize(MIN_SIZE); this.setFont(font); + this.setAlignment(Alignment.CENTER); final BlockWidget widget = this; inputSlot = new Port() { - public Point getRelativePosition() { - return new Point((int) (SIZE.getWidth() / 2), (int) (SIZE.getHeight() / 2)); + return new Point((int) (getSize().getWidth() / 2), (int) (getSize().getHeight() / 2)); } - public Vertex getVertex() { return widget; } }; - outputSlot = new Port() { - public Point getRelativePosition() { - return new Point((int) (SIZE.getWidth() / 2), (int) (SIZE.getHeight() / 2)); + return new Point((int) (getSize().getWidth() / 2), (int) (getSize().getHeight() / 2)); } - public Vertex getVertex() { return widget; } @@ -101,7 +97,12 @@ } public Dimension getSize() { - return SIZE; + Rectangle bounds = getBounds(); + if (bounds != null) { + return bounds.getSize(); + } else { + return MIN_SIZE; + } } public void setPosition(Point p) {