< prev index next >

src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java

Print this page


   1 /*
   2  * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 package com.sun.hotspot.igv.view.widgets;
  25 
  26 import com.sun.hotspot.igv.graph.Connection;
  27 import com.sun.hotspot.igv.graph.Figure;
  28 import com.sun.hotspot.igv.graph.InputSlot;
  29 import com.sun.hotspot.igv.graph.OutputSlot;

  30 import com.sun.hotspot.igv.view.DiagramScene;
  31 import java.awt.*;
  32 import java.awt.geom.Line2D;
  33 import java.util.ArrayList;
  34 import java.util.HashSet;
  35 import java.util.List;
  36 import java.util.Set;
  37 import javax.swing.JPopupMenu;
  38 import javax.swing.event.PopupMenuEvent;
  39 import javax.swing.event.PopupMenuListener;
  40 import org.netbeans.api.visual.action.ActionFactory;
  41 import org.netbeans.api.visual.action.PopupMenuProvider;
  42 import org.netbeans.api.visual.action.SelectProvider;
  43 import org.netbeans.api.visual.animator.SceneAnimator;
  44 import org.netbeans.api.visual.model.ObjectState;
  45 import org.netbeans.api.visual.widget.Widget;
  46 
  47 /**
  48  *
  49  * @author Thomas Wuerthinger


 131             @Override
 132             public boolean isSelectionAllowed(Widget arg0, Point arg1, boolean arg2) {
 133                 return true;
 134             }
 135 
 136             @Override
 137             public void select(Widget arg0, Point arg1, boolean arg2) {
 138                 Set<Figure> set = new HashSet<>();
 139                 for (Connection c : LineWidget.this.connections) {
 140                     set.add(c.getInputSlot().getFigure());
 141                     set.add(c.getOutputSlot().getFigure());
 142                 }
 143                 LineWidget.this.scene.setSelectedObjects(set);
 144             }
 145         }));
 146     }
 147 
 148     private String generateToolTipText(List<Connection> conn) {
 149         StringBuilder sb = new StringBuilder();
 150         for (Connection c : conn) {
 151             sb.append(c.getToolTipText());
 152             sb.append("<br>");
 153         }
 154         return sb.toString();
 155     }
 156 
 157     public Point getFrom() {
 158         return from;
 159     }
 160 
 161     public Point getTo() {
 162         return to;
 163     }
 164 
 165     private void addSuccessor(LineWidget widget) {
 166         this.successors.add(widget);
 167     }
 168 
 169     @Override
 170     protected Rectangle calculateClientArea() {
 171         return clientArea;


   1 /*
   2  * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 package com.sun.hotspot.igv.view.widgets;
  25 
  26 import com.sun.hotspot.igv.graph.Connection;
  27 import com.sun.hotspot.igv.graph.Figure;
  28 import com.sun.hotspot.igv.graph.InputSlot;
  29 import com.sun.hotspot.igv.graph.OutputSlot;
  30 import com.sun.hotspot.igv.util.StringUtils;
  31 import com.sun.hotspot.igv.view.DiagramScene;
  32 import java.awt.*;
  33 import java.awt.geom.Line2D;
  34 import java.util.ArrayList;
  35 import java.util.HashSet;
  36 import java.util.List;
  37 import java.util.Set;
  38 import javax.swing.JPopupMenu;
  39 import javax.swing.event.PopupMenuEvent;
  40 import javax.swing.event.PopupMenuListener;
  41 import org.netbeans.api.visual.action.ActionFactory;
  42 import org.netbeans.api.visual.action.PopupMenuProvider;
  43 import org.netbeans.api.visual.action.SelectProvider;
  44 import org.netbeans.api.visual.animator.SceneAnimator;
  45 import org.netbeans.api.visual.model.ObjectState;
  46 import org.netbeans.api.visual.widget.Widget;
  47 
  48 /**
  49  *
  50  * @author Thomas Wuerthinger


 132             @Override
 133             public boolean isSelectionAllowed(Widget arg0, Point arg1, boolean arg2) {
 134                 return true;
 135             }
 136 
 137             @Override
 138             public void select(Widget arg0, Point arg1, boolean arg2) {
 139                 Set<Figure> set = new HashSet<>();
 140                 for (Connection c : LineWidget.this.connections) {
 141                     set.add(c.getInputSlot().getFigure());
 142                     set.add(c.getOutputSlot().getFigure());
 143                 }
 144                 LineWidget.this.scene.setSelectedObjects(set);
 145             }
 146         }));
 147     }
 148 
 149     private String generateToolTipText(List<Connection> conn) {
 150         StringBuilder sb = new StringBuilder();
 151         for (Connection c : conn) {
 152             sb.append(StringUtils.escapeHTML(c.getToolTipText()));
 153             sb.append("<br>");
 154         }
 155         return sb.toString();
 156     }
 157 
 158     public Point getFrom() {
 159         return from;
 160     }
 161 
 162     public Point getTo() {
 163         return to;
 164     }
 165 
 166     private void addSuccessor(LineWidget widget) {
 167         this.successors.add(widget);
 168     }
 169 
 170     @Override
 171     protected Rectangle calculateClientArea() {
 172         return clientArea;


< prev index next >