コード例 #1
0
ファイル: Rings.java プロジェクト: schnee/tweetgeister
  public void paint(Graphics g) {
    g.setColor(Color.gray);

    Graphics2D g2d = (Graphics2D) g;

    Ellipse2D ellipse = new Ellipse2D.Double();
    for (Node<?> v : layout.getGraph().getVertices()) {
      Double radius = layout.getRadii().get(v);
      if (radius == null) continue;
      Point2D p = layout.transform(v);
      ellipse.setFrame(-radius, -radius, 2 * radius, 2 * radius);
      AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
      Shape shape = at.createTransformedShape(ellipse);

      MutableTransformer viewTransformer =
          vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);

      if (viewTransformer instanceof MutableTransformerDecorator) {
        shape = vv.getRenderContext().getMultiLayerTransformer().transform(shape);
      } else {
        shape = vv.getRenderContext().getMultiLayerTransformer().transform(Layer.LAYOUT, shape);
      }

      g2d.draw(shape);
    }
  }
  public void displayLicenseGraph() {

    Transformer<String, Paint> vertexColor =
        new Transformer<String, Paint>() {
          public Paint transform(String licenseTerm) {
            if (licenseTerm.contains("May")) return Color.GREEN;
            if (licenseTerm.contains("Must")) return Color.ORANGE;
            if (licenseTerm.equals("LimitedLiability")
                || licenseTerm.equals("ProvideWithoutWarranty")) return Color.CYAN;
            return Color.YELLOW;
          }
        };

    Layout<String, Edge> layout = new CircleLayout<String, Edge>(this.licenseGraph);
    layout.setSize(new Dimension(1024, 768));
    VisualizationViewer<String, Edge> vv = new VisualizationViewer<String, Edge>(layout);
    vv.setPreferredSize(new Dimension(1024, 768));

    vv.getRenderContext().setVertexFillPaintTransformer(vertexColor);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>());

    AbstractModalGraphMouse gm = new DefaultModalGraphMouse<String, Edge>();
    vv.setGraphMouse(gm);

    LicenseTermPopupMenu<String, Edge> popupMenu = new LicenseTermPopupMenu<>(licenseModel);
    gm.add(popupMenu);

    JFrame frame = new JFrame("Interactive Graph View 1");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(vv);

    frame.pack();
    frame.setVisible(true);
  }
コード例 #3
0
  /**
   * Method paint. Paints the rings on the graph.
   *
   * @param g Graphics - the graphics to be painted.
   */
  @Override
  public void paint(Graphics g) {
    Collection<Double> depths = getDepths();
    g.setColor(Color.gray);
    Graphics2D g2d = (Graphics2D) g;
    Point2D center = radialLayout.getCenter();

    Ellipse2D ellipse = new Ellipse2D.Double();
    for (double d : depths) {
      ellipse.setFrameFromDiagonal(
          center.getX() - d, center.getY() - d, center.getX() + d, center.getY() + d);
      AffineTransform at = AffineTransform.getTranslateInstance(0, 0);
      Shape shape = at.createTransformedShape(ellipse);
      // Shape shape =
      //	vv.getRenderContext().getMultiLayerTransformer().transform(ellipse);
      //
      //	vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).transform(ellipse);

      MutableTransformer viewTransformer =
          vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);

      if (viewTransformer instanceof MutableTransformerDecorator) {
        shape = vv.getRenderContext().getMultiLayerTransformer().transform(shape);
      } else {
        shape = vv.getRenderContext().getMultiLayerTransformer().transform(Layer.LAYOUT, shape);
      }
      g2d.draw(shape);
    }
  }
コード例 #4
0
  /**
   * Add support for mouse over popups.
   *
   * @param e
   */
  @Override
  public void mouseMoved(MouseEvent e) {
    super.mouseMoved(e);
    VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource();
    GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
    Layout<V, E> layout = vv.getGraphLayout();
    Point2D loc = e.getPoint();
    V vertex = pickSupport.getVertex(layout, loc.getX(), loc.getY());
    final ITermNode node = (ITermNode) vertex;
    if (vertex == null) {
      if (!GUI2.getInstance().getGraphPanel().getShowNewTerms()) {
        GUI2.getInstance()
            .getGraphPanel()
            .setStatusbarText("New assertions are not shown in the graph.");
      } else {
        GUI2.getInstance().getGraphPanel().setStatusbarText("");
      }
      return;
    }
    String sbtext = "   ";

    if (node.getTerm().isMolecular()) sbtext += node.getTerm().toString();
    else sbtext += node.toString();

    if (!node.getInEdges().isEmpty()) {
      sbtext +=
          " is in relation"
              + (node.getInEdges().size() == 1 ? "" : "s")
              + ": "
              + new HashSet(node.getRelationsPartOf()); // Use a HashSet to eliminate duplicates.
    }
    GUI2.getInstance().getGraphPanel().setStatusbarText(sbtext);
  }
コード例 #5
0
ファイル: DendrogramView.java プロジェクト: hardisty/geoviz
 @Override
 public void stateChanged(ChangeEvent e) {
   int level = levelControl.getValue();
   if (level != current_level) {
     createTree(level);
     current_level = level;
     if (!radial.isSelected()) {
       TreeLayout<String, Number> tl2 = treeLayout;
       radialLayout = new BalloonLayout<String, Number>(graph);
       radialLayout.setSize(new Dimension(1200, 1200));
       rings = new Rings(radialLayout);
       treeLayout = new TreeLayout<String, Number>(graph);
       LayoutTransition<String, Number> lt =
           new LayoutTransition<String, Number>(vv, tl2, treeLayout);
       Animator animator = new Animator(lt);
       animator.start();
     } else {
       BalloonLayout<String, Number> r2 = radialLayout;
       radialLayout = new BalloonLayout<String, Number>(graph);
       radialLayout.setSize(new Dimension(1200, 1200));
       treeLayout = new TreeLayout<String, Number>(graph);
       vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
       vv.removePreRenderPaintable(rings);
       rings = new Rings(radialLayout);
       LayoutTransition<String, Number> lt =
           new LayoutTransition<String, Number>(vv, r2, radialLayout);
       Animator animator = new Animator(lt);
       animator.start();
       vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
       vv.addPreRenderPaintable(rings);
     }
     // vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
   }
 }
  public VisualizationViewer<String, Edge> generateGraphView() {

    Transformer<String, Paint> vertexColor =
        new Transformer<String, Paint>() {
          public Paint transform(String licenseTerm) {
            if (licenseTerm.contains("May")) return Color.GREEN;
            if (licenseTerm.contains("Must")) return Color.ORANGE;
            if (licenseTerm.equals("LimitedLiability")
                || licenseTerm.equals("ProvideWithoutWarranty")) return Color.CYAN;
            return Color.YELLOW;
          }
        };

    Layout<String, Edge> layout = new CircleLayout<String, Edge>(this.licenseGraph);
    layout.setSize(new Dimension(1024, 768));
    VisualizationViewer<String, Edge> vv = new VisualizationViewer<String, Edge>(layout);
    vv.setPreferredSize(new Dimension(1024, 768));

    vv.getRenderContext().setVertexFillPaintTransformer(vertexColor);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>());

    AbstractModalGraphMouse gm = new DefaultModalGraphMouse<String, Edge>();
    vv.setGraphMouse(gm);

    popupMenu = new LicenseTermPopupMenu<>(licenseModel);
    gm.add(popupMenu);

    return vv;
  }
コード例 #7
0
ファイル: FrmGraph.java プロジェクト: adamsmj/yawl
 public void redrawGraph() {
   // get the new graph
   vv.validate();
   vv.repaint();
   splitPanelLeft.repaint();
   getContentPane().repaint();
   validate();
   repaint();
 }
コード例 #8
0
ファイル: FrmGraph.java プロジェクト: adamsmj/yawl
 private void setVisualizationViewer(VisualizationViewer vviewer) {
   //			vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
   vv = vviewer;
   // vv.setPickSupport(new edu.uci.ics.jung.visualization.picking.ShapePickSupport(vv));
   vv.setPreferredSize(new Dimension(350, 350));
   //			vv.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer);
   vv.setGraphMouse(gm);
   vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
   splitPanelLeft.setRightComponent(new GraphZoomScrollPane(vv));
 }
  /**
   * check the modifiers. If accepted, use the mouse drag motion to rotate the graph in the master
   * view
   */
  public void mouseDragged(MouseEvent e) {
    if (down == null) return;
    VisualizationViewer vv = (VisualizationViewer) e.getSource();
    boolean accepted = checkModifiers(e);
    if (accepted) {
      if (vv instanceof SatelliteVisualizationViewer) {
        VisualizationViewer vvMaster = ((SatelliteVisualizationViewer) vv).getMaster();

        MutableTransformer modelTransformerMaster = vvMaster.getLayoutTransformer();

        // rotate
        vv.setCursor(cursor);
        // I want to compute rotation based on the view coordinates of the
        // lens center in the satellite view.
        // translate the master view center to layout coords, then translate
        // that point to the satellite view's view coordinate system....
        Point2D center = vv.transform(vvMaster.inverseTransform(vvMaster.getCenter()));
        Point2D q = down;
        Point2D p = e.getPoint();
        Point2D v1 = new Point2D.Double(center.getX() - p.getX(), center.getY() - p.getY());
        Point2D v2 = new Point2D.Double(center.getX() - q.getX(), center.getY() - q.getY());
        double theta = angleBetween(v1, v2);
        modelTransformerMaster.rotate(-theta, vvMaster.inverseViewTransform(vvMaster.getCenter()));
        down.x = e.getX();
        down.y = e.getY();
      }
      e.consume();
    }
  }
コード例 #10
0
ファイル: EditorMouseMenu.java プロジェクト: jscontreras/fact
  /** @param args the command line arguments */
  public static void main(String[] args) {
    JFrame frame = new JFrame("Editing and Mouse Menu Demo");
    SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge> g =
        new SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge>();
    // Layout<V, E>, VisualizationViewer<V,E>
    //        Map<GraphElements.MyVertex,Point2D> vertexLocations = new
    // HashMap<GraphElements.MyVertex, Point2D>();
    Layout<GraphElements.MyVertex, GraphElements.MyEdge> layout = new StaticLayout(g);
    layout.setSize(new Dimension(300, 300));
    VisualizationViewer<GraphElements.MyVertex, GraphElements.MyEdge> vv =
        new VisualizationViewer<GraphElements.MyVertex, GraphElements.MyEdge>(layout);
    vv.setPreferredSize(new Dimension(350, 350));
    // Show vertex and edge labels
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
    // Create a graph mouse and add it to the visualization viewer
    EditingModalGraphMouse gm =
        new EditingModalGraphMouse(
            vv.getRenderContext(),
            GraphElements.MyVertexFactory.getInstance(),
            GraphElements.MyEdgeFactory.getInstance());
    // Set some defaults for the Edges...
    GraphElements.MyEdgeFactory.setDefaultCapacity(192.0);
    GraphElements.MyEdgeFactory.setDefaultWeight(5.0);
    // Trying out our new popup menu mouse plugin...
    PopupVertexEdgeMenuMousePlugin myPlugin = new PopupVertexEdgeMenuMousePlugin();
    // Add some popup menus for the edges and vertices to our mouse plugin.
    JPopupMenu edgeMenu = new MyMouseMenus.EdgeMenu(frame);
    JPopupMenu vertexMenu = new MyMouseMenus.VertexMenu();
    myPlugin.setEdgePopup(edgeMenu);
    myPlugin.setVertexPopup(vertexMenu);
    gm.remove(gm.getPopupEditingPlugin()); // Removes the existing popup editing plugin

    gm.add(myPlugin); // Add our new plugin to the mouse

    vv.setGraphMouse(gm);

    // JFrame frame = new JFrame("Editing and Mouse Menu Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(vv);

    // Let's add a menu for changing mouse modes
    JMenuBar menuBar = new JMenuBar();
    JMenu modeMenu = gm.getModeMenu();
    modeMenu.setText("Mouse Mode");
    modeMenu.setIcon(null); // I'm using this in a main menu
    modeMenu.setPreferredSize(new Dimension(80, 20)); // Change the size so I can see the text

    menuBar.add(modeMenu);
    frame.setJMenuBar(menuBar);
    gm.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode
    frame.pack();
    frame.setVisible(true);
  }
コード例 #11
0
  public void build() {
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('F');

    saveEdgelistAction.setParent(this);
    JMenuItem saveEdgelist = new JMenuItem(saveEdgelistAction);
    fileMenu.add(saveEdgelist);

    saveAdjAction.setParent(this);
    fileMenu.add(new JMenuItem(saveAdjAction));

    saveAlterAttributesCSVAction.setParent(this);
    fileMenu.add(new JMenuItem(saveAlterAttributesCSVAction));

    saveConsensusAction.setParent(this);
    fileMenu.add(new JMenuItem(saveConsensusAction));

    JMenuBar mb = new JMenuBar();
    mb.add(fileMenu);
    setJMenuBar(mb);

    SparseGraph<WholeNetworkAlter, WholeNetworkTie> graph =
        new SparseGraph<WholeNetworkAlter, WholeNetworkTie>();

    for (WholeNetworkAlter alter : net.getWholeNetworkAlters().values()) {
      graph.addVertex(alter);
      logger.info("Adding vertex " + alter);
    }

    for (WholeNetworkTie tie : net.getWholeNetworkTies()) {
      graph.addEdge(tie, tie.getA(), tie.getB());
      logger.info("Adding edge " + tie);
    }

    Layout<WholeNetworkAlter, WholeNetworkTie> layout =
        new ELSFRLayout2<WholeNetworkAlter, WholeNetworkTie>(graph);
    VisualizationViewer<WholeNetworkAlter, WholeNetworkTie> vv =
        new VisualizationViewer<WholeNetworkAlter, WholeNetworkTie>(layout);
    vv.setGraphMouse(new DefaultModalGraphMouse());
    vv.setPickSupport(new ShapePickSupport<WholeNetworkAlter, WholeNetworkTie>(vv));
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<WholeNetworkAlter>());
    vv.getRenderContext()
        .setEdgeShapeTransformer(new EdgeShape.Line<WholeNetworkAlter, WholeNetworkTie>());

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(vv, BorderLayout.CENTER);

    setContentPane(panel);
    pack();
  }
コード例 #12
0
  public static void main(String[] args) throws IOException {
    JFrame jf = new JFrame();
    Graph g = getGraph();
    VisualizationViewer vv = new VisualizationViewer(new FRLayout(g));
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    //   vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
    //   vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    jf.getContentPane().add(vv);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jf.pack();
    jf.setVisible(true);
  }
コード例 #13
0
  /**
   * copy the visible part of the graph to a file as a jpeg image
   *
   * @param file
   */
  public void writeJPEGImage(File file) {
    int width = vv.getWidth();
    int height = vv.getHeight();

    BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D graphics = bi.createGraphics();
    vv.paint(graphics);
    graphics.dispose();

    try {
      ImageIO.write(bi, "jpeg", file);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #14
0
  public int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
      throws java.awt.print.PrinterException {
    if (pageIndex > 0) {
      return (Printable.NO_SUCH_PAGE);
    } else {
      java.awt.Graphics2D g2d = (java.awt.Graphics2D) graphics;
      vv.setDoubleBuffered(false);
      g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());

      vv.paint(g2d);
      vv.setDoubleBuffered(true);

      return (Printable.PAGE_EXISTS);
    }
  }
コード例 #15
0
ファイル: DendrogramView.java プロジェクト: hardisty/geoviz
 @Override
 public void mousePressed(MouseEvent arg0) {
   // TODO Auto-generated method stub
   PickedState<String> ps = vv.getPickedVertexState();
   Set<String> ss = ps.getPicked();
   if (ss.size() == 1) {
     for (String s : ss) {
       nfc.kids.clear();
       ArrayList<String> kids = new ArrayList<String>();
       kids.add(s);
       for (int i = 0; i < kids.size(); i++) {
         includeKidNodes(kids.get(i), kids);
       }
       nfc.kids.addAll(kids);
       for (int i = kids.size() - 1; i >= 0; i--) {
         String id = kids.get(i);
         if (id.equals("Root") || id.startsWith("V")) {
           kids.remove(i);
         }
       }
       int[] selObj = new int[kids.size()];
       for (int i = 0; i < selObj.length; i++) {
         selObj[i] = Integer.parseInt(kids.get(i));
       }
       fireSelectionChanged(selObj);
       logger.info(Arrays.toString(selObj));
     }
   } else {
     nfc.kids.clear();
   }
 }
コード例 #16
0
 protected void setUpMouseMode() {
   if (visualizer != null) {
     DefaultModalGraphMouse<?, ?> graphMouse = new DefaultModalGraphMouse<Object, Object>();
     graphMouse.setMode(Mode.PICKING);
     visualizer.setGraphMouse(graphMouse);
   }
 }
コード例 #17
0
 protected void setVertexLabeler(RenderContext<CallGraphNode, CallGraphLink> renderContext) {
   renderContext.setVertexLabelTransformer(new ToStringLabeller<CallGraphNode>());
   Renderer<CallGraphNode, CallGraphLink> renderer = visualizer.getRenderer();
   BasicVertexLabelRenderer<CallGraphNode, CallGraphLink> labelRenderer =
       new BasicVertexLabelRenderer<CallGraphNode, CallGraphLink>();
   labelRenderer.setPosition(Renderer.VertexLabel.Position.CNTR);
   renderer.setVertexLabelRenderer(labelRenderer);
 }
コード例 #18
0
  public void paint(Graphics g) {
    // super.repaint();
    pWidth = this.getWidth() - (inset.left + inset.right);
    pHeight = this.getHeight() - (inset.top + inset.bottom);

    top.setBounds(0, 0, pWidth, (int) (pHeight * (1.0f - graphVerticalSize)));

    nodeGraph.setBounds(0, 0, (int) (top.getWidth() * 0.8f) - 5, top.getHeight());

    nodeGraphView.setBounds(0, 20, nodeGraph.getWidth(), nodeGraph.getHeight() - 20);
    nodeGraphView.getGraphLayout().setSize(nodeGraphView.getSize());

    nodeGraphInform.setBounds(
        (int) (top.getWidth() * 0.8f), 20, (int) (top.getWidth() * 0.2f), top.getHeight() - 20);
    nodeGraphMap.setBounds(0, 0, nodeGraphInform.getWidth(), nodeGraphInform.getWidth());
    nodeGraphMap
        .getGraphLayout()
        .setSize(new Dimension(nodeGraphInform.getWidth(), nodeGraphInform.getWidth()));

    nodeGraphProtocolView.setBounds(
        0,
        nodeGraphMap.getHeight() + 5,
        nodeGraphInform.getWidth(),
        nodeGraphInform.getHeight() - nodeGraphMap.getHeight() - 5);
    /*
    Relaxer relaxer = nodeGraphView.getModel().getRelaxer();
    if(relaxer != null) {
    	relaxer.stop();
    	relaxer.prerelax();
    	relaxer.relax();
    }
    */

    trafficGraph.setBounds(
        0,
        (int) (pHeight * (1.0f - graphVerticalSize)) + 10,
        pWidth,
        (int) (pHeight * graphVerticalSize));
    trafficGraph.repaint();

    graphVerticalSizeBt.setBounds(0, (int) (pHeight * (1.0f - graphVerticalSize)), pWidth, 10);
    graphVerticalSizeBt.repaint();

    graphHorizontalSizeBt.setBounds((int) (top.getWidth() * 0.8f) - 5, 20, 5, top.getHeight());
    graphHorizontalSizeBt.repaint();
  }
コード例 #19
0
 private void visualize(UndirectedSparseGraph<String, Integer> coOccurenceGraph) {
   Layout<String, String> layout = new FRLayout(coOccurenceGraph);
   layout.setSize(new Dimension(300, 300));
   VisualizationViewer<String, String> vv = new VisualizationViewer<String, String>(layout);
   vv.setPreferredSize(new Dimension(350, 350));
   // Show vertex and edge labels
   vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
   vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
   // Create a graph mouse and add it to the visualization component
   DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
   vv.setGraphMouse(gm);
   JFrame frame = new JFrame("Co-Occurrence");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.getContentPane().add(vv);
   frame.pack();
   frame.setVisible(true);
 }
コード例 #20
0
 public FSMBuildVisualizer() {
   super("Model Visualizer");
   graph = new DirectedSparseMultigraph<>();
   graph.addVertex(current);
   //    Layout<FSMTransition, String> layout = new CircleLayout<FSMTransition, String>(graph);
   layout = new KKLayout<>(graph);
   layout.setSize(new Dimension(800, 600)); // sets the initial size of the space
   vv = new VisualizationViewer<>(layout);
   vv.setPreferredSize(new Dimension(800, 600)); // Sets the viewing area size
   vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
   vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
   vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
   VertexLabelAsShapeRenderer<String, StepCounter> vlasr =
       new VertexLabelAsShapeRenderer<>(vv.getRenderContext());
   //    vv.getRenderContext().setVertexShapeTransformer(vlasr);
   vv.getRenderContext().setVertexShapeTransformer(new EllipseVertexTransformer());
   //    vv.getRenderContext().setVertexLabelRenderer(new
   // TransitionVertextLabelRenderer(Color.GREEN));
   DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
   vv.addKeyListener(gm.getModeKeyListener());
   gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
   vv.setGraphMouse(gm);
   getContentPane().add(vv);
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   setSize(1024, 768);
   pack();
   setVisible(true);
 }
コード例 #21
0
 protected void setEdgeLabeler(RenderContext<CallGraphNode, CallGraphLink> renderContext) {
   ToStringLabeller<CallGraphLink> toStringLabeller = new ToStringLabeller<CallGraphLink>();
   renderContext.setEdgeLabelTransformer(toStringLabeller);
   Renderer<CallGraphNode, CallGraphLink> renderer = visualizer.getRenderer();
   BasicEdgeLabelRenderer<CallGraphNode, CallGraphLink> labelRenderer =
       new BasicEdgeLabelRenderer<CallGraphNode, CallGraphLink>();
   // labelRenderer.setPosition(Renderer.EdgeLabel.Position.CNTR);
   renderer.setEdgeLabelRenderer(labelRenderer);
 }
コード例 #22
0
 @SuppressWarnings("unchecked")
 public void mouseClicked(MouseEvent e) {
   final VisualizationViewer<RouterVertex, LinkEdge> vv =
       (VisualizationViewer<RouterVertex, LinkEdge>) e.getSource();
   Point2D p = e.getPoint();
   // LEFT MOUSE BUTTON
   if (e.getButton() == MouseEvent.BUTTON1) {
     GraphElementAccessor<RouterVertex, LinkEdge> pickSupport = vv.getPickSupport();
     if (pickSupport != null) {
       final RouterVertex routerVertex =
           pickSupport.getVertex(vv.getGraphLayout(), p.getX(), p.getY());
       if (routerVertex != null) {
         switch (owner.getMapGraphComponentMode()) {
           case MapGraphComponentMode.SHOW_SHORTEST_PATH:
             if (!routerVertex.isMultilink()) {
               owner.setShortestTreeCenter(routerVertex);
               owner.showShortestPath();
             }
             break;
           case MapGraphComponentMode.VERTEX_LOCKING:
             owner.lockVertexPosition(routerVertex);
             break;
         }
       }
       final LinkEdge linkEdge = pickSupport.getEdge(vv.getGraphLayout(), p.getX(), p.getY());
       if (linkEdge != null) {
         if (owner.getMapGraphComponentMode() == MapGraphComponentMode.LINK_FAULT) {
           if (linkEdge.getFaultCount() > 0) {
             owner.getOwner().getManager().showLinkFaultDialog(linkEdge.getLinkIDv4());
           }
         }
       }
     }
     if (owner.getMapGraphComponentMode() == MapGraphComponentMode.ZOOM) {
       owner.zoomPlus(p);
     }
   }
   // RIGHT MOUSE BUTTON
   if (e.getButton() == MouseEvent.BUTTON3) {
     if (owner.getMapGraphComponentMode() == MapGraphComponentMode.ZOOM) {
       owner.zoomMinus(p);
     }
   }
 }
コード例 #23
0
ファイル: StateViewer.java プロジェクト: codeaudit/opendial
 /** Quick fix for a strange bung in JUNG */
 @Override
 public void paintComponent(Graphics g) {
   try {
     super.paintComponent(g);
   } catch (NullPointerException e) {
     log.fine("cannot repaint state viewer, waiting for next update: ");
     e.printStackTrace();
     isUpdating = false;
     // tab.trigger(currentState, currentState.getChanceNodeIds());
   }
 }
コード例 #24
0
ファイル: MapViewer.java プロジェクト: bestdpf/SEU_WSN_SIM
  public MapViewer(String title) {
    super(title);
    setSize(800, 600);
    // setExtendedState(Frame.MAXIMIZED_BOTH);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    edgeCnt = 0;
    startMap();
    Container cp = getContentPane();
    cp.setLayout(new BorderLayout());
    cp.setBackground(Color.lightGray);
    // vv.getModel().getRelaxer().setSleepTime(500);
    vv.setGraphMouse(new DefaultModalGraphMouse<Number, Number>());

    vv.getRenderer()
        .getVertexLabelRenderer()
        .setPosition(edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position.CNTR);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>());
    vv.setForeground(Color.white);
    cp.add(vv, BorderLayout.CENTER);
    getContentPane().setFont(new Font("Serif", Font.PLAIN, 12));
    setVisible(true);
    JMenuBar jb = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    jb.add(fileMenu);
    JMenuItem exitMenu = new JMenuItem("Exit");
    fileMenu.add(exitMenu);
    exitMenu.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            MapViewer.this.dispose();
          }
        });
    JMenu helpMenu = new JMenu("Help");
    jb.add(helpMenu);
    JMenuItem aboutItem = new JMenuItem("About");
    helpMenu.add(aboutItem);
    aboutItem.addActionListener(new AboutActionListener());
    this.setJMenuBar(jb);
    setLocationRelativeTo(null);
  }
コード例 #25
0
 /** @param args the command line arguments */
 public static void main(String[] args) {
   InteractiveGraphView1 sgv = new InteractiveGraphView1(); // Creates the graph...
   // Layout<V, E>, VisualizationViewer<V,E>
   Layout<Integer, String> layout = new CircleLayout(sgv.g);
   layout.setSize(new Dimension(300, 300));
   VisualizationViewer<Integer, String> vv = new VisualizationViewer<Integer, String>(layout);
   vv.setPreferredSize(new Dimension(350, 350));
   // Show vertex and edge labels
   vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
   vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
   // Create a graph mouse and add it to the visualization component
   DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
   gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
   vv.setGraphMouse(gm);
   // Add the mouses mode key listener to work it needs to be added to the visualization component
   vv.addKeyListener(gm.getModeKeyListener());
   JFrame frame = new JFrame("Interactive Graph View 2");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.getContentPane().add(vv);
   frame.pack();
   frame.setVisible(true);
 }
コード例 #26
0
  /** @param args the command line arguments */
  public static void main(String[] args) {
    InteractiveGraphView1 sgv = new InteractiveGraphView1(); // Creates the graph...
    // Layout<V, E>, VisualizationViewer<V,E>
    Layout<Integer, String> layout = new CircleLayout(sgv.g);
    layout.setSize(new Dimension(300, 300));
    VisualizationViewer<Integer, String> vv = new VisualizationViewer<Integer, String>(layout);
    vv.setPreferredSize(new Dimension(350, 350));
    // Show vertex and edge labels
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());

    // Create our "custom" mouse here. We start with a PluggableGraphMouse
    // Then add the plugins you desire.
    PluggableGraphMouse gm = new PluggableGraphMouse();
    gm.add(new TranslatingGraphMousePlugin(MouseEvent.BUTTON1_MASK));
    gm.add(new ScalingGraphMousePlugin(new CrossoverScalingControl(), 0, 1.1f, 0.9f));

    vv.setGraphMouse(gm);
    JFrame frame = new JFrame("Interactive Graph View 3");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(vv);
    frame.pack();
    frame.setVisible(true);
  }
コード例 #27
0
ファイル: DendrogramView.java プロジェクト: hardisty/geoviz
  @Override
  /**
   * @modified by peifeng yin
   * @date Jan 13, 2011
   */
  public void selectionChanged(SelectionEvent e) {
    // TODO Auto-generated method stub

    int[] selObs = e.getSelection();
    // nh.selectedNodes.clear();
    if (selObs.length == 0) {
      return;
    }
    // else if(selObs.length==1)//include the selected node's children
    // selObs=includeChildren(selObs[0]);
    PickedState<String> ps = vv.getPickedVertexState();
    ps.clear();
    nfc.kids.clear();
    for (int obs : selObs) {
      if (obs < 0) {
        return;
      }
      ps.pick(String.valueOf(obs), true);
      /*
       * String name = dsa.getObservationName(obs);
       * System.out.println(DendrogramView.class.getName() +
       * " selection = " + obs + " " + name);
       * nh.selectedNodes.add(String.valueOf(obs));
       */
    }
    /*
     * if (!nh.selectedNodes.isEmpty()) { nh.passive = true; nh.node_count =
     * nh.node_no; this.vv.repaint(); }
     */
    vv.repaint();
  }
コード例 #28
0
 private void addEdge(String step) {
   String edge = current + "->" + step;
   if (!edges.containsKey(edge)) {
     //      System.out.println("EDGE+" + edge);
     if (!vertices.contains(step)) {
       //        System.out.println("VERTEX+" + t);
       graph.addVertex(step);
       vertices.add(step);
     }
     StepCounter counter = new StepCounter();
     edges.put(edge, counter);
     graph.addEdge(counter, current, step);
     vv.repaint();
   } else {
     edges.get(edge).increment();
   }
   layout.reset();
 }
コード例 #29
0
ファイル: DendrogramView.java プロジェクト: hardisty/geoviz
 @Override
 public void mouseReleased(MouseEvent arg0) {
   PickedState<String> ps = vv.getPickedVertexState();
   Set<String> selectedV = ps.getPicked();
   if (selectedV.isEmpty()) {
     return;
   }
   ArrayList<Integer> selNodes = new ArrayList<Integer>();
   Iterator<String> it = selectedV.iterator();
   while (it.hasNext()) {
     try {
       Integer I = Integer.parseInt(it.next());
       selNodes.add(I);
     } catch (Exception e) {
       continue;
     }
   }
   int[] selObjs = new int[selNodes.size()];
   for (int i = 0; i < selObjs.length; i++) {
     selObjs[i] = selNodes.get(i).intValue();
   }
   fireSelectionChanged(selObjs);
   logger.info(Arrays.toString(selObjs));
 }
コード例 #30
0
  private void initComponent() {
    // TODO Auto-generated method stub

    top = new JPanel();

    nodeGraph = new JPanel();
    FRLayout<String, String> graphLayout = new FRLayout<String, String>(graph);
    nodeGraphView = new VisualizationViewer<String, String>(graphLayout);

    // nodeGraphView.setBackground(new Color(228,247,186));
    // nodeGraphView.setBackground(new Color(178,204,255));
    nodeGraphView.setBackground(new Color(255, 216, 216));

    nodeGraphView
        .getRenderContext()
        .setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<String>(
                nodeGraphView.getPickedEdgeState(), Color.black, Color.GREEN));
    nodeGraphView
        .getRenderContext()
        .setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(
                nodeGraphView.getPickedVertexState(),
                new Color(67, 116, 217),
                new Color(5, 0, 153)));
    final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    nodeGraphView.setGraphMouse(graphMouse);

    nodeGraphProtocolFilter = new JPanel();
    nodeGraph.add(nodeGraphProtocolFilter);
    nodeGraph.add(nodeGraphView);

    nodeGraphInform = new JPanel();
    nodeGraphMap = new SatelliteVisualizationViewer<String, String>(nodeGraphView);
    // nodeGraphMap.getRenderContext().setEdgeDrawPaintTransformer(new
    // PickableEdgePaintTransformer<String>(nodeGraphMap.getPickedEdgeState(), Color.black,
    // Color.GREEN));
    nodeGraphMap
        .getRenderContext()
        .setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(
                nodeGraphMap.getPickedVertexState(),
                new Color(67, 116, 217),
                new Color(5, 0, 153)));

    nodeTrafficTableModel = new NodeTrafficTableModel();
    TableColumnModel columnModel = new DefaultTableColumnModel();
    TableColumn column = new TableColumn(0);
    column.setHeaderValue("IP");
    columnModel.addColumn(column);

    column = new TableColumn(1);
    column.setHeaderValue("PORT");
    columnModel.addColumn(column);

    column = new TableColumn(2);
    column.setHeaderValue("PACKETS");
    columnModel.addColumn(column);

    column = new TableColumn(3);
    column.setHeaderValue("BYTES");
    columnModel.addColumn(column);

    column = new TableColumn(4);
    column.setHeaderValue("LEVEL");
    columnModel.addColumn(column);

    DefaultTableCellRenderer cellAlign = new DefaultTableCellRenderer();
    cellAlign.setHorizontalAlignment(JLabel.RIGHT);

    nodeTrafficTable = new JTable(nodeTrafficTableModel, columnModel);
    /*
       nodeTrafficTable.getColumn("IP").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("IP").setPreferredWidth(90);
       nodeTrafficTable.getColumn("PORT").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("PORT").setPreferredWidth(30);
       nodeTrafficTable.getColumn("PACKETS").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("PACKETS").setPreferredWidth(60);
       nodeTrafficTable.getColumn("BYTES").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("BYTES").setPreferredWidth(60);
       nodeTrafficTable.getColumn("LEVEL").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("LEVEL").setPreferredWidth(5);
    */
    nodeGraphicTable = new JTable(nodeGraphicTableModel);

    nodeGraphProtocolView = new JScrollPane(nodeTrafficTable);
    // nodeGraphProtocolView.setLayout(new BorderLayout());
    // nodeGraphProtocolView.add(nodeTrafficTable);

    nodeGraphInform.add(nodeGraphMap);
    nodeGraphInform.add(nodeGraphProtocolView);

    top.add(nodeGraph);
    top.add(nodeGraphInform);
    this.add(top);

    trafficGraph = new ChartPanel(trafficChart);
    trafficGraph.setFocusable(false);
    trafficChart.getLegend().setPosition(RectangleEdge.LEFT);

    this.add(trafficGraph);

    graphVerticalSizeBt = new JButton("::::::::△▽::::::::");
    graphVerticalSizeBt.setFont(graphVerticalSizeBt.getFont().deriveFont(10.0f));
    graphVerticalSizeBt.addMouseMotionListener(new GraphVerticalSizeMotionListener());
    graphVerticalSizeBt.addActionListener(new GraphVerticalSizeMotionListener());
    this.add(graphVerticalSizeBt);

    graphHorizontalSizeBt = new JButton();
    graphHorizontalSizeBt.setEnabled(false);
    top.add(graphHorizontalSizeBt);
  }