com.vividsolutions.jump.workbench.ui
Class Viewport

java.lang.Object
  extended by com.vividsolutions.jump.workbench.ui.Viewport
All Implemented Interfaces:
Java2DConverter.PointConverter

public class Viewport
extends java.lang.Object
implements Java2DConverter.PointConverter

Controls the area on the model being viewed by a LayerViewPanel.


Constructor Summary
Viewport(LayerViewPanel panel)
           
 
Method Summary
 void addListener(ViewportListener l)
           
 com.vividsolutions.jts.geom.Envelope fullExtent()
           
 com.vividsolutions.jts.geom.Envelope getEnvelopeInModelCoordinates()
           
 Java2DConverter getJava2DConverter()
           
 java.awt.geom.AffineTransform getModelToViewTransform()
           
 java.awt.geom.Point2D getOriginInModelCoordinates()
           
 LayerViewPanel getPanel()
           
 double getScale()
           
 ZoomHistory getZoomHistory()
           
 void initialize(double newScale, java.awt.geom.Point2D newViewOriginAsPerceivedByModel)
          Set both values but repaint once.
static java.awt.geom.AffineTransform modelToViewTransform(double scale, java.awt.geom.Point2D viewOriginAsPerceivedByModel, double panelHeight)
           
 void removeListener(ViewportListener l)
           
 com.vividsolutions.jts.geom.Coordinate toModelCoordinate(java.awt.geom.Point2D viewPoint)
           
 com.vividsolutions.jts.geom.Envelope toModelEnvelope(double x1, double x2, double y1, double y2)
           
 java.awt.geom.Point2D toModelPoint(java.awt.geom.Point2D viewPoint)
           
 java.awt.geom.Point2D toViewPoint(com.vividsolutions.jts.geom.Coordinate modelCoordinate)
           
 java.awt.geom.Point2D toViewPoint(java.awt.geom.Point2D modelPoint)
           
 java.util.Collection toViewPoints(java.util.Collection modelCoordinates)
           
 java.awt.geom.Rectangle2D toViewRectangle(com.vividsolutions.jts.geom.Envelope envelope)
           
 void update()
           
 void zoom(com.vividsolutions.jts.geom.Envelope modelEnvelope)
           
 void zoom(java.awt.geom.Point2D centreOfNewViewAsPerceivedByOldView, double widthOfNewViewAsPerceivedByOldView, double heightOfNewViewAsPerceivedByOldView)
          Of widthOfNewViewAsPerceivedByOldView and heightOfNewViewAsPerceivedByOldView, this method will choose the one producing the least zoom.
 void zoomToFullExtent()
           
 void zoomToViewPoint(java.awt.geom.Point2D centreOfNewViewAsPerceivedByOldView, double zoomFactor)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Viewport

public Viewport(LayerViewPanel panel)
Method Detail

getPanel

public LayerViewPanel getPanel()

addListener

public void addListener(ViewportListener l)

removeListener

public void removeListener(ViewportListener l)

getJava2DConverter

public Java2DConverter getJava2DConverter()

getZoomHistory

public ZoomHistory getZoomHistory()

update

public void update()
            throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

modelToViewTransform

public static java.awt.geom.AffineTransform modelToViewTransform(double scale,
                                                                 java.awt.geom.Point2D viewOriginAsPerceivedByModel,
                                                                 double panelHeight)

getScale

public double getScale()

initialize

public void initialize(double newScale,
                       java.awt.geom.Point2D newViewOriginAsPerceivedByModel)
Set both values but repaint once.


getOriginInModelCoordinates

public java.awt.geom.Point2D getOriginInModelCoordinates()

zoom

public void zoom(java.awt.geom.Point2D centreOfNewViewAsPerceivedByOldView,
                 double widthOfNewViewAsPerceivedByOldView,
                 double heightOfNewViewAsPerceivedByOldView)
          throws java.awt.geom.NoninvertibleTransformException
Of widthOfNewViewAsPerceivedByOldView and heightOfNewViewAsPerceivedByOldView, this method will choose the one producing the least zoom.

Throws:
java.awt.geom.NoninvertibleTransformException

toModelPoint

public java.awt.geom.Point2D toModelPoint(java.awt.geom.Point2D viewPoint)
                                   throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

toModelCoordinate

public com.vividsolutions.jts.geom.Coordinate toModelCoordinate(java.awt.geom.Point2D viewPoint)
                                                         throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

toViewPoint

public java.awt.geom.Point2D toViewPoint(java.awt.geom.Point2D modelPoint)
                                  throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

toViewPoint

public java.awt.geom.Point2D toViewPoint(com.vividsolutions.jts.geom.Coordinate modelCoordinate)
                                  throws java.awt.geom.NoninvertibleTransformException
Specified by:
toViewPoint in interface Java2DConverter.PointConverter
Throws:
java.awt.geom.NoninvertibleTransformException

toModelEnvelope

public com.vividsolutions.jts.geom.Envelope toModelEnvelope(double x1,
                                                            double x2,
                                                            double y1,
                                                            double y2)
                                                     throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

getModelToViewTransform

public java.awt.geom.AffineTransform getModelToViewTransform()
                                                      throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

getEnvelopeInModelCoordinates

public com.vividsolutions.jts.geom.Envelope getEnvelopeInModelCoordinates()

zoom

public void zoom(com.vividsolutions.jts.geom.Envelope modelEnvelope)
          throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

zoomToFullExtent

public void zoomToFullExtent()
                      throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

fullExtent

public com.vividsolutions.jts.geom.Envelope fullExtent()

zoomToViewPoint

public void zoomToViewPoint(java.awt.geom.Point2D centreOfNewViewAsPerceivedByOldView,
                            double zoomFactor)
                     throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

toViewPoints

public java.util.Collection toViewPoints(java.util.Collection modelCoordinates)
                                  throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

toViewRectangle

public java.awt.geom.Rectangle2D toViewRectangle(com.vividsolutions.jts.geom.Envelope envelope)
                                          throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException