Package edu.uci.ics.jung.visualization.transform

Examples of edu.uci.ics.jung.visualization.transform.MutableTransformer


    /**
     * scale to the absolute value passed as 'amount'.
     *
     */
    public void scale(VisualizationViewer<?,?> vv, float amount, Point2D at) {
        MutableTransformer layoutTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
        MutableTransformer viewTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);
        double modelScale = layoutTransformer.getScale();
        double viewScale = viewTransformer.getScale();
        double inverseModelScale = Math.sqrt(crossover)/modelScale;
        double inverseViewScale = Math.sqrt(crossover)/viewScale;
       
        Point2D transformedAt = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(Layer.VIEW, at);
       
        // return the transformers to 1.0
        layoutTransformer.scale(inverseModelScale, inverseModelScale, transformedAt);
        viewTransformer.scale(inverseViewScale, inverseViewScale, at);

        super.scale(vv, amount, at);
    }
View Full Code Here


   */
    public void mouseDragged(MouseEvent e) {
        VisualizationViewer vv = (VisualizationViewer)e.getSource();
        boolean accepted = checkModifiers(e);
        if(accepted) {
            MutableTransformer modelTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
            vv.setCursor(cursor);
            try {
                Point2D q = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
                Point2D p = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(e.getPoint());
                float dx = (float) (p.getX()-q.getX());
                float dy = (float) (p.getY()-q.getY());
               
                modelTransformer.translate(dx, dy);
                down.x = e.getX();
                down.y = e.getY();
            } catch(RuntimeException ex) {
                System.err.println("down = "+down+", e = "+e);
                throw ex;
View Full Code Here

        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 {
View Full Code Here

            Dimension d = vv.getSize();
            deviceRectangle = new Rectangle(
                    0,0,
                    d.width,d.height);
        }
        MutableTransformer vt = rc.getMultiLayerTransformer().getTransformer(Layer.VIEW);
        if(vt instanceof MutableTransformerDecorator) {
          vt = ((MutableTransformerDecorator)vt).getDelegate();
        }
        return vt.transform(s).intersects(deviceRectangle);
    }
View Full Code Here

    public void mouseWheelMoved(MouseWheelEvent e) {
        boolean accepted = checkModifiers(e);
        float delta = this.delta;
        if(accepted == true) {
            VisualizationViewer vv = (VisualizationViewer)e.getSource();
            MutableTransformer modelTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
            MutableTransformer viewTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);
            int amount = e.getWheelRotation();
            if(amount < 0) {
                delta = -delta;
            }
            changeMagnification(modelTransformer, delta);
View Full Code Here

        float y1 = (float) p1.getY();
        float x2 = (float) p2.getX();
        float y2 = (float) p2.getY();
       
        float flatness = 0;
        MutableTransformer transformer = rc.getMultiLayerTransformer().getTransformer(Layer.VIEW);
        if(transformer instanceof LensTransformer) {
            LensTransformer ht = (LensTransformer)transformer;
            RectangularShape lensShape = ht.getLensShape();
            if(lensShape.contains(x1,y1) || lensShape.contains(x2,y2)) {
                flatness = .05f;
            }
        }

        boolean isLoop = v1.equals(v2);
        Shape s2 = rc.getVertexShapeTransformer().transform(v2);
        Shape edgeShape = rc.getEdgeShapeTransformer().transform(Context.<Graph<V,E>,E>getInstance(graph, e));
       
        boolean edgeHit = true;
        boolean arrowHit = true;
        Rectangle deviceRectangle = null;
        JComponent vv = rc.getScreenDevice();
        if(vv != null) {
            Dimension d = vv.getSize();
            deviceRectangle = new Rectangle(0,0,d.width,d.height);
        }

        AffineTransform xform = AffineTransform.getTranslateInstance(x1, y1);
       
        if(isLoop) {
            // this is a self-loop. scale it is larger than the vertex
            // it decorates and translate it so that its nadir is
            // at the center of the vertex.
            Rectangle2D s2Bounds = s2.getBounds2D();
            xform.scale(s2Bounds.getWidth(),s2Bounds.getHeight());
            xform.translate(0, -edgeShape.getBounds2D().getWidth()/2);
        } else {
            // this is a normal edge. Rotate it to the angle between
            // vertex endpoints, then scale it to the distance between
            // the vertices
            float dx = x2-x1;
            float dy = y2-y1;
            float thetaRadians = (float) Math.atan2(dy, dx);
            xform.rotate(thetaRadians);
            float dist = (float) Math.sqrt(dx*dx + dy*dy);
            xform.scale(dist, 1.0);
        }
       
        edgeShape = xform.createTransformedShape(edgeShape);
       
        MutableTransformer vt = rc.getMultiLayerTransformer().getTransformer(Layer.VIEW);
        if(vt instanceof LensTransformer) {
          vt = ((LensTransformer)vt).getDelegate();
        }
        edgeHit = vt.transform(edgeShape).intersects(deviceRectangle);

        if(edgeHit == true) {
           
            Paint oldPaint = g.getPaint();
           
View Full Code Here

            xform.scale(dist, 1.0);
        }
       
        edgeShape = xform.createTransformedShape(edgeShape);
       
        MutableTransformer vt = rc.getMultiLayerTransformer().getTransformer(Layer.VIEW);
        if(vt instanceof LensTransformer) {
          vt = ((LensTransformer)vt).getDelegate();
        }
        edgeHit = vt.transform(edgeShape).intersects(deviceRectangle);

        if(edgeHit == true) {
           
            Paint oldPaint = g.getPaint();
           
View Full Code Here

    public void mouseDragged(MouseEvent e) {
        if(down == null) return;
        VisualizationViewer vv = (VisualizationViewer)e.getSource();
        boolean accepted = checkModifiers(e);
        if(accepted) {
            MutableTransformer modelTransformer =
                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
            // rotate
            vv.setCursor(cursor);
           
            Point2D center = vv.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);
            modelTransformer.rotate(theta, vv.getRenderContext().getMultiLayerTransformer().inverseTransform(Layer.VIEW, center));
            down.x = e.getX();
            down.y = e.getY();
       
            e.consume();
        }
View Full Code Here

        if(accepted) {
            if(vv instanceof SatelliteVisualizationViewer) {
                VisualizationViewer vvMaster =
                    ((SatelliteVisualizationViewer)vv).getMaster();
               
                MutableTransformer modelTransformerMaster =
                  vvMaster.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
                vv.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
                try {
                    Point2D q = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
                    Point2D p = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(e.getPoint());
                    float dx = (float) (p.getX()-q.getX());
                    float dy = (float) (p.getY()-q.getY());
                   
                    modelTransformerMaster.translate(-dx, -dy);
                    down.x = e.getX();
                    down.y = e.getY();
                } catch(RuntimeException ex) {
                    System.err.println("down = "+down+", e = "+e);
                    throw ex;
View Full Code Here

  /**
     * @see edu.uci.ics.jung.visualization.control.ScalingControl#scale(VisualizationViewer, float, Point2D)
     */
  public void scale(VisualizationServer<?,?> vv, float amount, Point2D at) {
         
      MutableTransformer layoutTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
      MutableTransformer viewTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);
      double modelScale = layoutTransformer.getScale();
      double viewScale = viewTransformer.getScale();
      double inverseModelScale = Math.sqrt(crossover)/modelScale;
      double inverseViewScale = Math.sqrt(crossover)/viewScale;
      double scale = modelScale * viewScale;
     
      Point2D transformedAt = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(Layer.VIEW, at);
     
        if((scale*amount - crossover)*(scale*amount - crossover) < 0.001) {
            // close to the control point, return both transformers to a scale of sqrt crossover value
            layoutTransformer.scale(inverseModelScale, inverseModelScale, transformedAt);
            viewTransformer.scale(inverseViewScale, inverseViewScale, at);
        } else if(scale*amount < crossover) {
            // scale the viewTransformer, return the layoutTransformer to sqrt crossover value
          viewTransformer.scale(amount, amount, at);
          layoutTransformer.scale(inverseModelScale, inverseModelScale, transformedAt);
      } else {
            // scale the layoutTransformer, return the viewTransformer to crossover value
          layoutTransformer.scale(amount, amount, transformedAt);
          viewTransformer.scale(inverseViewScale, inverseViewScale, at);
      }
      vv.repaint();
  }
View Full Code Here

TOP

Related Classes of edu.uci.ics.jung.visualization.transform.MutableTransformer

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.