Package org.jgraph

Examples of org.jgraph.JGraph$GraphSelectionRedirector


    /*
     * (non-Javadoc)
     */
    public void mouseDragged(MouseEvent e) {
      if (lastPoint != null) {
        JGraph graph = getCurrentGraph();
        JScrollPane scrollPane = getParentScrollPane(graph);
        if (scrollPane != null && currentGraph != null) {
          JViewport viewport = scrollPane.getViewport();
          Rectangle rect = viewport.getViewRect();
          double scale = backingGraph.getScale() / graph.getScale();
          double x = (e.getX() - lastPoint.getX()) / scale;
          double y = (e.getY() - lastPoint.getY()) / scale;
          lastPoint = e.getPoint();
          x = rect.getX() + ((x > 0) ? rect.getWidth() : 0) + x;
          y = rect.getY() + ((y > 0) ? rect.getHeight() : 0) + y;
          Point2D pt = new Point2D.Double(x, y);
          graph.scrollPointToVisible(pt);
          navigatorPane.repaint();
        }
      }
    }
View Full Code Here


    try {
      if (e != null && marqueeBounds != null) {
        if (!(e.getSource() instanceof JGraph))
          throw new IllegalArgumentException("MarqueeHandler cannot "
              + "handle event from unknown source: " + e);
        JGraph graph = (JGraph) e.getSource();
        Rectangle2D bounds = graph
            .fromScreen((Rectangle2D) marqueeBounds.clone());
        handleMarqueeEvent(e, graph, bounds);
        graph.setCursor(previousCursor);
        Rectangle dirty = new Rectangle((int) marqueeBounds.getX(),
            (int) marqueeBounds.getY(), (int) marqueeBounds
                .getWidth() + 1, (int) marqueeBounds
                .getHeight() + 1);
        dirty.width++;
        dirty.height++;
        graph.repaint(dirty);
      }
    } finally {
      currentPoint = null;
      startPoint = null;
      marqueeBounds = null;
View Full Code Here

    if (startPoint != null) {
      if (!(e.getSource() instanceof JGraph))
        throw new IllegalArgumentException(
            "MarqueeHandler cannot handle event from unknown source: "
                + e);
      JGraph graph = (JGraph) e.getSource();
      Graphics g = graph.getGraphics();

      // Xor the current display
      Color bg = graph.getBackground();
      Color fg = graph.getMarqueeColor();
      if (graph.isXorEnabled()) {
        g.setColor(fg);
        g.setXORMode(bg);
        overlay(graph, g, true);
      }
      Rectangle2D dirty = (Rectangle2D) marqueeBounds.clone();
      processMouseDraggedEvent(e);

      // Repaint
      if (graph.isXorEnabled()) {
        g.setColor(bg);
        g.setXORMode(fg);
        overlay(graph, g, false);
      } else {
        dirty.add(marqueeBounds);
        graph.repaint((int) dirty.getX()-1, (int) dirty.getY()-1,
            (int) dirty.getWidth()+2, (int) dirty.getHeight()+2);
      }
    }
  }
View Full Code Here

        .getY(), 0, 0);
    if (!(e.getSource() instanceof JGraph))
      throw new IllegalArgumentException(
          "MarqueeHandler cannot handle event from unknown source: "
              + e);
    JGraph graph = (JGraph) e.getSource();
    if (isMarqueeTriggerEvent(e, graph)) {
      previousCursor = graph.getCursor();
      graph.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    }
  }
View Full Code Here

                g2.setStroke(new BasicStroke(lineWidth, c, j, 10.0f, lineDash, dashOffset));
                if (view.lineShape != null) g2.draw(view.lineShape);

        Object[] labels = GraphConstants.getExtraLabels(view
            .getAllAttributes());
        JGraph graph = (JGraph)this.graph.get();
        g.setFont(DefaultStaticConfiguration.DEFAULT_SMALLLABEL_FONT);
        if (labels != null) {
          for (int i = 0; i < labels.length; i++)
            paintLabel(g, graph.convertValueToString(labels[i]),
                getExtraLabelPosition(view, i),
                false || !simpleExtraLabels);
        }

               
View Full Code Here

   *
   * @param event
   *            The object that describes the event.
   */
  public void mousePressed(MouseEvent event) {
    JGraph graph = getGraphForEvent(event);
    startPoint = event.getPoint();
    previousCursor = graph.getCursor();
    // Workaround for the fact that you have to click the button
    // twice to get the panning cursor to appear properly, this
    // makes it appear after the first drag, which is a
    // slight improvement -- DCP 29/06/2006 (case 147).
    graph.setCursor(panningCursor);
    marqueeBounds = null;
    m_XDifference = event.getX();
    m_YDifference = event.getY();
    dx = 0;
    dy = 0;
View Full Code Here

   *
   * @param event
   *            The object that describes the event.
   */
  protected void processMouseDraggedEvent(MouseEvent event) {
    JGraph graph = getGraphForEvent(event);
    Component c = graph.getParent();

    // Added this test to move up the hierarchy and get the parent ViewPort,
    // if the graph is actually contained in a JPanel
    if (c instanceof JPanel) {
      c = c.getParent();
    }

    if (c instanceof JViewport) {
      JViewport jv = (JViewport) c;
      Point p = jv.getViewPosition();
      int newX = p.x - (event.getX() - m_XDifference);
      int newY = p.y - (event.getY() - m_YDifference);
      dx += (event.getX() - startPoint.getX());
      dy += (event.getY() - m_YDifference);

      int maxX = graph.getWidth() - jv.getWidth();
      int maxY = graph.getHeight() - jv.getHeight();
      if (newX < 0)
        newX = 0;
      if (newX > maxX)
        newX = maxX;
      if (newY < 0)
View Full Code Here

   *
   * @param event
   *            The object that describes the event.
   */
  public void mouseReleased(MouseEvent event) {
    JGraph graph = getGraphForEvent(event);
    if (previousCursor != null) {
      graph.setCursor(previousCursor);
    }
    event.consume();
  }
View Full Code Here

   *            The current graph to set.
   */
  public void setCurrentGraph(JGraph sourceGraph) {
    if (sourceGraph == null || getParentGraph(sourceGraph) == null) {
      if (sourceGraph != null) {
        JGraph oldValue = getCurrentGraph();

        // Removes listeners from the previous graph
        if (oldValue != null && sourceGraph != oldValue) {
          oldValue.getModel().removeGraphModelListener(this);
          oldValue.getGraphLayoutCache()
              .removeGraphLayoutCacheListener(this);
          oldValue.removePropertyChangeListener(this);
          JScrollPane scrollPane = getParentScrollPane(oldValue);
          if (scrollPane != null) {
            scrollPane.removeComponentListener(componentListener);
            scrollPane.getVerticalScrollBar()
                .removeAdjustmentListener(this);
View Full Code Here

   * Updates the scale of the backing graph.
   */
  protected void updateScale() {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        JGraph graph = getCurrentGraph();
        if (graph != null) {
          Dimension d = graph.getPreferredSize();
          Dimension b = graph.getBounds().getSize();
          d.width = Math.max(d.width, b.width);
          b.height = Math.max(d.height, b.height);
          double scale = graph.getScale();
          d.setSize(d.width * 1 / scale, d.height * 1 / scale);
          Dimension s = getScrollPane().getViewport().getSize();
          double sx = s.getWidth() / d.getWidth();
          double sy = s.getHeight() / d.getHeight();
          scale = Math.min(Math.min(sx, sy), getMaximumScale());
View Full Code Here

TOP

Related Classes of org.jgraph.JGraph$GraphSelectionRedirector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.