Coverage Report - edu.uci.ics.jung.visualization.jai.PerspectiveLayoutTransformSupport
 
Classes in this File Line Coverage Branch Coverage Complexity
PerspectiveLayoutTransformSupport
0%
0/18
0%
0/2
1.333
 
 1  
 /*
 2  
  * Copyright (c) 2005, the JUNG Project and the Regents of the University of
 3  
  * California All rights reserved.
 4  
  *
 5  
  * This software is open-source under the BSD license; see either "license.txt"
 6  
  * or http://jung.sourceforge.net/license.txt for a description.
 7  
  *
 8  
  * Created on Jul 21, 2005
 9  
  */
 10  
 
 11  
 package edu.uci.ics.jung.visualization.jai;
 12  
 
 13  
 import javax.media.jai.PerspectiveTransform;
 14  
 
 15  
 import edu.uci.ics.jung.algorithms.layout.GraphElementAccessor;
 16  
 import edu.uci.ics.jung.visualization.Layer;
 17  
 import edu.uci.ics.jung.visualization.VisualizationViewer;
 18  
 import edu.uci.ics.jung.visualization.picking.LayoutLensShapePickSupport;
 19  
 /**
 20  
  * A class to make it easy to add a Perspective projection
 21  
  * to a jung graph application. See PerspectiveTransformerDemo
 22  
  * for an example of how to use it.
 23  
  * 
 24  
  * @author Tom Nelson
 25  
  *
 26  
  *
 27  
  */
 28  
 public class PerspectiveLayoutTransformSupport<V,E> extends AbstractPerspectiveTransformSupport<V,E> 
 29  
     implements PerspectiveTransformSupport {
 30  
 
 31  
         protected GraphElementAccessor<V,E> pickSupport;
 32  
     /**
 33  
      * @param vv the VisualizationViewer to work on
 34  
      */
 35  
     public PerspectiveLayoutTransformSupport(VisualizationViewer<V,E> vv) {
 36  0
         super(vv);
 37  0
         this.perspectiveTransformer = 
 38  
             new PerspectiveShapeTransformer(new PerspectiveTransform(), 
 39  
                             vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT));
 40  0
         this.pickSupport = vv.getPickSupport();
 41  0
    }
 42  
     
 43  
     public void activate() {
 44  0
         lens = new Lens(perspectiveTransformer, vv.getSize());
 45  0
         vv.getRenderContext().setPickSupport(new LayoutLensShapePickSupport<V,E>(vv));
 46  0
         vv.getRenderContext().getMultiLayerTransformer().setTransformer(Layer.LAYOUT, perspectiveTransformer);
 47  0
         vv.addPreRenderPaintable(lens);
 48  0
         vv.setToolTipText(instructions);
 49  0
         vv.repaint();
 50  0
     }
 51  
     
 52  
     public void deactivate() {
 53  0
         vv.getRenderContext().setPickSupport(pickSupport);
 54  0
         if(perspectiveTransformer != null) {
 55  0
             vv.removePreRenderPaintable(lens);
 56  0
             vv.getRenderContext().getMultiLayerTransformer().setTransformer(Layer.LAYOUT, perspectiveTransformer.getDelegate());
 57  
         }
 58  0
         vv.setToolTipText(defaultToolTipText);
 59  0
         vv.repaint();
 60  0
     }
 61  
 }