edu.uci.ics.jung.visualization
Class BasicTransformer

java.lang.Object
  extended by edu.uci.ics.jung.visualization.BasicTransformer
All Implemented Interfaces:
MultiLayerTransformer, BidirectionalTransformer, ShapeTransformer, ChangeEventSupport, EventListener, ChangeListener

public class BasicTransformer
extends Object
implements MultiLayerTransformer, ShapeTransformer, ChangeListener, ChangeEventSupport

A basic implementation of the MultiLayerTransformer interface that provides two Layers: VIEW and LAYOUT. It also provides ChangeEventSupport

Author:
Tom Nelson - tomnelson@dev.java.net

Field Summary
protected  ChangeEventSupport changeSupport
           
protected  MutableTransformer layoutTransformer
           
protected  MutableTransformer viewTransformer
           
 
Constructor Summary
BasicTransformer()
          Creates an instance and notifies the view and layout transformers to listen to changes published by this instance.
 
Method Summary
 void addChangeListener(ChangeListener l)
           
 void fireStateChanged()
           
 ChangeListener[] getChangeListeners()
          Returns an array of all the ChangeListeners added with addChangeListener().
protected  MutableTransformer getLayoutTransformer()
           
 MutableTransformer getTransformer(Layer layer)
           
protected  MutableTransformer getViewTransformer()
           
protected  Point2D inverseLayoutTransform(Point2D p)
           
protected  Shape inverseLayoutTransform(Shape shape)
           
 Point2D inverseTransform(Layer layer, Point2D p)
           
 Shape inverseTransform(Layer layer, Shape shape)
           
 Point2D inverseTransform(Point2D p)
          convert the supplied screen coordinate to the graph coordinate.
 Shape inverseTransform(Shape shape)
           
protected  Point2D inverseViewTransform(Point2D p)
           
protected  Shape inverseViewTransform(Shape shape)
           
protected  Point2D layoutTransform(Point2D p)
           
protected  Shape layoutTransform(Shape shape)
           
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener.
protected  void setLayoutTransformer(MutableTransformer transformer)
           
 void setToIdentity()
           
 void setTransformer(Layer layer, MutableTransformer transformer)
           
protected  void setViewTransformer(MutableTransformer transformer)
           
 void stateChanged(ChangeEvent e)
           
 Point2D transform(Layer layer, Point2D p)
           
 Shape transform(Layer layer, Shape shape)
           
 Point2D transform(Point2D p)
          convert the supplied graph coordinate to the screen coordinate
 Shape transform(Shape shape)
          map a shape from graph coordinate system to the screen coordinate system
protected  Point2D viewTransform(Point2D p)
           
protected  Shape viewTransform(Shape shape)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

changeSupport

protected ChangeEventSupport changeSupport

viewTransformer

protected MutableTransformer viewTransformer

layoutTransformer

protected MutableTransformer layoutTransformer
Constructor Detail

BasicTransformer

public BasicTransformer()
Creates an instance and notifies the view and layout transformers to listen to changes published by this instance.

Method Detail

setViewTransformer

protected void setViewTransformer(MutableTransformer transformer)
See Also:
edu.uci.ics.jung.visualization.MultiLayerTransformer#setViewTransformer(edu.uci.ics.jung.visualization.transform.MutableTransformer)

setLayoutTransformer

protected void setLayoutTransformer(MutableTransformer transformer)

getLayoutTransformer

protected MutableTransformer getLayoutTransformer()

getViewTransformer

protected MutableTransformer getViewTransformer()

inverseTransform

public Point2D inverseTransform(Point2D p)
Description copied from interface: BidirectionalTransformer
convert the supplied screen coordinate to the graph coordinate.

Specified by:
inverseTransform in interface BidirectionalTransformer
Parameters:
p - screen point to convert
Returns:
the graph point

inverseViewTransform

protected Point2D inverseViewTransform(Point2D p)

inverseLayoutTransform

protected Point2D inverseLayoutTransform(Point2D p)

transform

public Point2D transform(Point2D p)
Description copied from interface: BidirectionalTransformer
convert the supplied graph coordinate to the screen coordinate

Specified by:
transform in interface BidirectionalTransformer
Parameters:
p - graph point to convert
Returns:
screen point

viewTransform

protected Point2D viewTransform(Point2D p)

layoutTransform

protected Point2D layoutTransform(Point2D p)

inverseTransform

public Shape inverseTransform(Shape shape)
Specified by:
inverseTransform in interface BidirectionalTransformer
Specified by:
inverseTransform in interface ShapeTransformer
Returns:

inverseViewTransform

protected Shape inverseViewTransform(Shape shape)

inverseLayoutTransform

protected Shape inverseLayoutTransform(Shape shape)

transform

public Shape transform(Shape shape)
Description copied from interface: ShapeTransformer
map a shape from graph coordinate system to the screen coordinate system

Specified by:
transform in interface BidirectionalTransformer
Specified by:
transform in interface ShapeTransformer
Returns:
a GeneralPath (Shape) representing the screen points of the shape

viewTransform

protected Shape viewTransform(Shape shape)

layoutTransform

protected Shape layoutTransform(Shape shape)

setToIdentity

public void setToIdentity()
Specified by:
setToIdentity in interface MultiLayerTransformer

addChangeListener

public void addChangeListener(ChangeListener l)
Specified by:
addChangeListener in interface ChangeEventSupport

removeChangeListener

public void removeChangeListener(ChangeListener l)
Description copied from interface: ChangeEventSupport
Removes a ChangeListener.

Specified by:
removeChangeListener in interface ChangeEventSupport
Parameters:
l - the listener to be removed

getChangeListeners

public ChangeListener[] getChangeListeners()
Description copied from interface: ChangeEventSupport
Returns an array of all the ChangeListeners added with addChangeListener().

Specified by:
getChangeListeners in interface ChangeEventSupport
Returns:
all of the ChangeListeners added or an empty array if no listeners have been added

fireStateChanged

public void fireStateChanged()
Specified by:
fireStateChanged in interface ChangeEventSupport

stateChanged

public void stateChanged(ChangeEvent e)
Specified by:
stateChanged in interface ChangeListener

getTransformer

public MutableTransformer getTransformer(Layer layer)
Specified by:
getTransformer in interface MultiLayerTransformer
Returns:
the layoutTransformer

inverseTransform

public Point2D inverseTransform(Layer layer,
                                Point2D p)
Specified by:
inverseTransform in interface MultiLayerTransformer

setTransformer

public void setTransformer(Layer layer,
                           MutableTransformer transformer)
Specified by:
setTransformer in interface MultiLayerTransformer
See Also:
edu.uci.ics.jung.visualization.VisualizationServer#setViewTransformer(edu.uci.ics.jung.visualization.transform.MutableTransformer)

transform

public Point2D transform(Layer layer,
                         Point2D p)
Specified by:
transform in interface MultiLayerTransformer

transform

public Shape transform(Layer layer,
                       Shape shape)
Specified by:
transform in interface MultiLayerTransformer

inverseTransform

public Shape inverseTransform(Layer layer,
                              Shape shape)
Specified by:
inverseTransform in interface MultiLayerTransformer


Copyright © 2009. All Rights Reserved.