# HG changeset patch # User Thomas Wuerthinger # Date 1328406493 -3600 # Node ID 3c38bdaa6b39125c2c2624edb3b0ca6963f2c805 # Parent d6f55cb223f40afc449a08e3efe3e4aa7db15876 Removed color action. diff -r d6f55cb223f4 -r 3c38bdaa6b39 src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java --- a/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java Sun Feb 05 02:42:16 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java Sun Feb 05 02:48:13 2012 +0100 @@ -39,7 +39,7 @@ @Override protected void performAction(Node[] activatedNodes) { SelectBytecodesCookie c = activatedNodes[0].getCookie(SelectBytecodesCookie.class); - InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); + InputGraphProvider p = null; // TODO: fixme LookupHistory.getLast(InputGraphProvider.class);//Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); if (p != null) { p.setSelectedNodes(c.getNodes()); } diff -r d6f55cb223f4 -r 3c38bdaa6b39 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ColorAction.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ColorAction.java Sun Feb 05 02:42:16 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,217 +0,0 @@ -package at.ssw.visualizer.cfg.action; - -import at.ssw.visualizer.cfg.graph.CfgEventListener; -import at.ssw.visualizer.cfg.graph.CfgScene; -import at.ssw.visualizer.cfg.model.CfgNode; -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.event.ActionEvent; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.image.BufferedImage; -import java.util.Set; -import javax.swing.*; -import javax.swing.plaf.basic.BasicArrowButton; -import org.openide.util.HelpCtx; -import org.openide.util.actions.Presenter; - -/** - * Changes the background color of a node. - * - * @author Bernhard Stiftner - * @author Rumpfhuber Stefan - */ -public class ColorAction extends AbstractCfgEditorAction implements Presenter.Menu, Presenter.Popup, Presenter.Toolbar { - - public static final int IMAGE_WIDTH = 16; - public static final int IMAGE_HEIGHT = 16; - - - /** Names of colors shown in color select lists. */ - private static final String[] COLOR_NAMES = {"White", "Light Gray", "Dark Gray", "Light Yellow", "Dark Yellow", "Light Green", "Dark Green", "Light Cyan", "Dark Cyan", "Light Blue", "Dark Blue", "Light Magenta", "Dark Magenta", "Light Red", "Dark Red"}; - - /** Values of colors shown in color select lists. */ - private static final Color[] COLORS = { - new Color(0xFFFFFF), new Color(0xD4D0C8), new Color(0xA4A098), new Color(0xF0F0B0), new Color(0xE0E040), - new Color(0xB0F0B0), new Color(0x40E040), new Color(0xB0F0F0), new Color(0x40E0E0), new Color(0xB0B0F0), - new Color(0x4040E0), new Color(0xF0B0F0), new Color(0xE040E0), new Color(0xF0B0B0), new Color(0xE04040) - }; - - public void performAction() { - // nothing to do here, the presenters are supposed to call - // performAction(Color) - } - - protected void performAction(Color color) { - CfgScene tc = getEditor(); - if (tc != null) { - tc.setSelectedNodesColor(color); - } - } - - public String getName() { - return "Change NodeColor"; - } - - @Override - protected String iconResource() { - return "at/ssw/visualizer/cfg/icons/color.gif"; - } - - public HelpCtx getHelpCtx() { - return HelpCtx.DEFAULT_HELP; - } - - @Override - public JMenuItem getMenuPresenter() { - return new MenuPresenter(); - } - - @Override - public JMenuItem getPopupPresenter() { - return new MenuPresenter(); - } - - @Override - public JComponent getToolbarPresenter() { - return new ToolbarPresenter(); - } - - class MenuPresenter extends JMenu { - - public MenuPresenter() { - super(ColorAction.this); - initGUI(); - } - - protected void initGUI() { - CfgScene tc = getEditor(); - if( tc != null && tc.getSelectedNodes().size()==0) { - //no node selected - setEnabled(false); - } else { - add(new SetColorAction(null, "Automatic")); - for (int i = 0; i < COLORS.length; i++) { - add(new SetColorAction(COLORS[i], COLOR_NAMES[i])); - } - } - } - } - - class ToolbarPresenter extends JButton implements CfgEventListener, MouseListener { - - final int arrowSize = 5; - final int arrowMargin = 3; - JPopupMenu popup; - - public ToolbarPresenter() { - setIcon(createIcon()); - setToolTipText(ColorAction.this.getName()); - - popup = new JPopupMenu(); - popup.add(new SetColorAction(null, "Automatic")); - for (int i = 0; i < COLORS.length; i++) { - popup.add(new SetColorAction(COLORS[i], COLOR_NAMES[i])); - } - addMouseListener(this); - } - - public Icon createIcon() { - BasicArrowButton arrow = new BasicArrowButton(SwingConstants.SOUTH); - BufferedImage img = new BufferedImage(IMAGE_WIDTH + arrowSize + 2 * arrowMargin, IMAGE_HEIGHT, BufferedImage.TYPE_INT_ARGB); - Graphics g = img.getGraphics(); - ColorAction.this.getIcon().paintIcon(this, g, 0, 0); - arrow.paintTriangle(g, IMAGE_WIDTH + arrowMargin + arrowSize / 2, IMAGE_HEIGHT / 2 - arrowSize / 2, arrowSize, SwingConstants.SOUTH, true); - return new ImageIcon(img); - } - - - public void selectionChanged(CfgScene scene) { - Set nodes = scene.getSelectedNodes(); - setEnabled(nodes.size() > 0); - } - - public void mouseClicked(MouseEvent e) { - if (e.getX() < getInsets().left + IMAGE_WIDTH + arrowMargin) { - performAction(null); - } else { - popup.show(this, 0, getSize().height); - } - } - - public void mouseEntered(MouseEvent e) { - } - - public void mouseExited(MouseEvent e) { - } - - public void mousePressed(MouseEvent e) { - } - - public void mouseReleased(MouseEvent e) { - } - } - - protected Icon createIcon(Color color) { - if (color == null) { - return ColorAction.this.getIcon(); - } else { - return new ColorIcon(color); - } - } - - class ColorIcon implements Icon { - - Color color; - - public ColorIcon(Color color) { - this.color = color; - } - - public int getIconWidth() { - return IMAGE_WIDTH; - } - - public int getIconHeight() { - return IMAGE_HEIGHT; - } - - public void paintIcon(Component c, Graphics g, int x, int y) { - Color oldColor = g.getColor(); - g.setColor(color); - g.fillRect(x, y, IMAGE_WIDTH, IMAGE_HEIGHT); - g.setColor(oldColor); - } - } - - class SetColorAction extends AbstractAction { - - Color color; - String name; - Icon icon; - - public SetColorAction(Color color, String name) { - super(name, createIcon(color)); - this.color = color; - this.name = name; - icon = (Icon) getValue(AbstractAction.SMALL_ICON); - } - - public Color getColor() { - return color; - } - - public String getName() { - return name; - } - - public Icon getIcon() { - return icon; - } - - public void actionPerformed(ActionEvent e) { - performAction(color); - } - } -} diff -r d6f55cb223f4 -r 3c38bdaa6b39 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/CfgScene.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/CfgScene.java Sun Feb 05 02:42:16 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/CfgScene.java Sun Feb 05 02:48:13 2012 +0100 @@ -774,8 +774,6 @@ menu.add(SystemAction.get(ShowEdgesAction.class)); menu.add(SystemAction.get(HideEdgesAction.class)); - menu.addSeparator(); - menu.add(SystemAction.get(ColorAction.class).getPopupPresenter()); return menu; } }); diff -r d6f55cb223f4 -r 3c38bdaa6b39 src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/CustomizablePanAction.java --- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/CustomizablePanAction.java Sun Feb 05 02:42:16 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ -package com.sun.hotspot.igv.view.actions; - -import java.awt.Container; -import java.awt.Point; -import java.awt.Rectangle; -import javax.swing.JComponent; -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; -import org.netbeans.api.visual.action.WidgetAction; -import org.netbeans.api.visual.action.WidgetAction.State; -import org.netbeans.api.visual.action.WidgetAction.WidgetMouseEvent; -import org.netbeans.api.visual.widget.Scene; -import org.netbeans.api.visual.widget.Widget; - -/** - * @author David Kaspar - * @author Peter Hofer - */ -public class CustomizablePanAction extends WidgetAction.LockedAdapter { - private boolean enabled = true; - - private Scene scene; - private JScrollPane scrollPane; - private Point lastLocation; - - private final int modifiersExMask; - private final int modifiersEx; - - public CustomizablePanAction(int modifiersExMask, int modifiersEx) { - this.modifiersExMask = modifiersExMask; - this.modifiersEx = modifiersEx; - } - - @Override - protected boolean isLocked() { - return scrollPane != null; - } - - public void setEnabled(boolean enabled) { - if (this.enabled != enabled) { - if (isLocked()) - throw new IllegalStateException(); - - this.enabled = enabled; - } - } - - @Override - public State mousePressed (Widget widget, WidgetMouseEvent event) { - if (isLocked ()) - return State.createLocked (widget, this); - if (enabled && (event.getModifiersEx() & modifiersExMask) == modifiersEx) { - scene = widget.getScene (); - scrollPane = findScrollPane (scene.getView ()); - if (scrollPane != null) { - lastLocation = scene.convertSceneToView (widget.convertLocalToScene (event.getPoint ())); - SwingUtilities.convertPointToScreen (lastLocation, scene.getView ()); - return State.createLocked (widget, this); - } - } - return State.REJECTED; - } - - private JScrollPane findScrollPane (JComponent component) { - for (;;) { - if (component == null) - return null; - if (component instanceof JScrollPane) - return ((JScrollPane) component); - Container parent = component.getParent (); - if (! (parent instanceof JComponent)) - return null; - component = (JComponent) parent; - } - } - - @Override - public State mouseReleased (Widget widget, WidgetMouseEvent event) { - boolean state = pan (widget, event.getPoint ()); - if (state) - scrollPane = null; - return state ? State.createLocked (widget, this) : State.REJECTED; - } - - @Override - public State mouseDragged (Widget widget, WidgetMouseEvent event) { - return pan (widget, event.getPoint ()) ? State.createLocked (widget, this) : State.REJECTED; - } - - private boolean pan (Widget widget, Point newLocation) { - if (scrollPane == null || scene != widget.getScene ()) - return false; - newLocation = scene.convertSceneToView (widget.convertLocalToScene (newLocation)); - SwingUtilities.convertPointToScreen (newLocation, scene.getView ()); - JComponent view = scene.getView (); - Rectangle rectangle = view.getVisibleRect (); - rectangle.x += lastLocation.x - newLocation.x; - rectangle.y += lastLocation.y - newLocation.y; - view.scrollRectToVisible (rectangle); - lastLocation = newLocation; - return true; - } -} diff -r d6f55cb223f4 -r 3c38bdaa6b39 src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/scene/CustomizablePanWidgetAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/scene/CustomizablePanWidgetAction.java Sun Feb 05 02:48:13 2012 +0100 @@ -0,0 +1,146 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package com.sun.hotspot.igv.view.scene; + +import java.awt.Container; +import java.awt.Point; +import java.awt.Rectangle; +import javax.swing.JComponent; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; +import org.netbeans.api.visual.action.WidgetAction; +import org.netbeans.api.visual.action.WidgetAction.State; +import org.netbeans.api.visual.action.WidgetAction.WidgetMouseEvent; +import org.netbeans.api.visual.widget.Scene; +import org.netbeans.api.visual.widget.Widget; + +/** + * @author David Kaspar + * @author Peter Hofer + */ +public class CustomizablePanWidgetAction extends WidgetAction.LockedAdapter { + private boolean enabled = true; + + private Scene scene; + private JScrollPane scrollPane; + private Point lastLocation; + + private final int modifiersExMask; + private final int modifiersEx; + + public CustomizablePanWidgetAction(int modifiersExMask, int modifiersEx) { + this.modifiersExMask = modifiersExMask; + this.modifiersEx = modifiersEx; + } + + @Override + protected boolean isLocked() { + return scrollPane != null; + } + + public void setEnabled(boolean enabled) { + if (this.enabled != enabled) { + if (isLocked()) + throw new IllegalStateException(); + + this.enabled = enabled; + } + } + + @Override + public State mousePressed (Widget widget, WidgetMouseEvent event) { + if (isLocked ()) + return State.createLocked (widget, this); + if (enabled && (event.getModifiersEx() & modifiersExMask) == modifiersEx) { + scene = widget.getScene (); + scrollPane = findScrollPane (scene.getView ()); + if (scrollPane != null) { + lastLocation = scene.convertSceneToView (widget.convertLocalToScene (event.getPoint ())); + SwingUtilities.convertPointToScreen (lastLocation, scene.getView ()); + return State.createLocked (widget, this); + } + } + return State.REJECTED; + } + + private JScrollPane findScrollPane (JComponent component) { + for (;;) { + if (component == null) + return null; + if (component instanceof JScrollPane) + return ((JScrollPane) component); + Container parent = component.getParent (); + if (! (parent instanceof JComponent)) + return null; + component = (JComponent) parent; + } + } + + @Override + public State mouseReleased (Widget widget, WidgetMouseEvent event) { + boolean state = pan (widget, event.getPoint ()); + if (state) + scrollPane = null; + return state ? State.createLocked (widget, this) : State.REJECTED; + } + + @Override + public State mouseDragged (Widget widget, WidgetMouseEvent event) { + return pan (widget, event.getPoint ()) ? State.createLocked (widget, this) : State.REJECTED; + } + + private boolean pan (Widget widget, Point newLocation) { + if (scrollPane == null || scene != widget.getScene ()) + return false; + newLocation = scene.convertSceneToView (widget.convertLocalToScene (newLocation)); + SwingUtilities.convertPointToScreen (newLocation, scene.getView ()); + JComponent view = scene.getView (); + Rectangle rectangle = view.getVisibleRect (); + rectangle.x += lastLocation.x - newLocation.x; + rectangle.y += lastLocation.y - newLocation.y; + view.scrollRectToVisible (rectangle); + lastLocation = newLocation; + return true; + } +} diff -r d6f55cb223f4 -r 3c38bdaa6b39 src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/scene/DiagramScene.java --- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/scene/DiagramScene.java Sun Feb 05 02:42:16 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/scene/DiagramScene.java Sun Feb 05 02:48:13 2012 +0100 @@ -34,7 +34,6 @@ import com.sun.hotspot.igv.util.ColorIcon; import com.sun.hotspot.igv.util.DoubleClickAction; import com.sun.hotspot.igv.util.PropertiesSheet; -import com.sun.hotspot.igv.view.actions.CustomizablePanAction; import com.sun.hotspot.igv.view.widgets.*; import java.awt.*; import java.awt.event.*; @@ -61,7 +60,7 @@ */ public class DiagramScene extends ObjectScene { - private CustomizablePanAction panAction; + private CustomizablePanWidgetAction panAction; private WidgetAction hoverAction; private WidgetAction selectAction; private Lookup lookup; @@ -353,7 +352,7 @@ // This panAction handles the event only when the left mouse button is // pressed without any modifier keys, otherwise it will not consume it // and the selection action (below) will handle the event - panAction = new CustomizablePanAction(~0, MouseEvent.BUTTON1_DOWN_MASK); + panAction = new CustomizablePanWidgetAction(~0, MouseEvent.BUTTON1_DOWN_MASK); this.getActions().addAction(panAction); selectAction = createSelectAction();