sim.util.geo
Class GeometryUtilities

java.lang.Object
  extended by sim.util.geo.GeometryUtilities

public class GeometryUtilities
extends java.lang.Object


Constructor Summary
GeometryUtilities()
           
 
Method Summary
static java.awt.geom.Rectangle2D.Double computeBounds(com.vividsolutions.jts.geom.Envelope outer, sim.display.Display2D display, GeomGridField gridField)
          compute the MBR for the grid field in display coordinates This is used to determine the display bounds for the grid field for Display2D.attach().
static com.vividsolutions.jts.geom.util.AffineTransformation getPortrayalTransform(java.awt.geom.AffineTransform transform, GeomField field, java.awt.geom.Rectangle2D.Double view)
           
static boolean isWithinBounds(com.vividsolutions.jts.geom.Envelope outer, GeomGridField gridField)
           
static java.awt.geom.Point2D screenToWorldPointTransform(java.awt.geom.AffineTransform worldToScreen, double x, double y)
          Uses the worldToScreen transform to transform the point (x,y) in screen coordinates to world coordinates.
static java.awt.geom.AffineTransform worldToScreenTransform(com.vividsolutions.jts.geom.Envelope mapExtent, sim.portrayal.DrawInfo2D info)
          Determines the affine transform which converts world coordinates into screen coordinates.
static java.awt.geom.AffineTransform worldToScreenTransform(com.vividsolutions.jts.geom.Envelope mapExtent, java.awt.geom.Rectangle2D.Double viewport)
          Determines the affine transform which converts world coordinates into screen coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeometryUtilities

public GeometryUtilities()
Method Detail

worldToScreenTransform

public static java.awt.geom.AffineTransform worldToScreenTransform(com.vividsolutions.jts.geom.Envelope mapExtent,
                                                                   java.awt.geom.Rectangle2D.Double viewport)
Determines the affine transform which converts world coordinates into screen coordinates. Modified from GeoTools RenderUtilities.java.

Parameters:
mapExtent - MBR in world coordinates mapped to viewport defined in 'info'
viewport -
Returns:
AffineTransform suitable for converting from world to screen coordinates

getPortrayalTransform

public static com.vividsolutions.jts.geom.util.AffineTransformation getPortrayalTransform(java.awt.geom.AffineTransform transform,
                                                                                          GeomField field,
                                                                                          java.awt.geom.Rectangle2D.Double view)

worldToScreenTransform

public static java.awt.geom.AffineTransform worldToScreenTransform(com.vividsolutions.jts.geom.Envelope mapExtent,
                                                                   sim.portrayal.DrawInfo2D info)
Determines the affine transform which converts world coordinates into screen coordinates. Modified from GeoTools RenderUtilities.java. convenience variant of other worldToSceenTransform()

Parameters:
mapExtent - MBR in world coordinates mapped to viewport defined in 'info'
info - defines the viewport dimensions
Returns:
AffineTransform suitable for converting from world to screen coordinates

screenToWorldPointTransform

public static java.awt.geom.Point2D screenToWorldPointTransform(java.awt.geom.AffineTransform worldToScreen,
                                                                double x,
                                                                double y)
Uses the worldToScreen transform to transform the point (x,y) in screen coordinates to world coordinates.


computeBounds

public static java.awt.geom.Rectangle2D.Double computeBounds(com.vividsolutions.jts.geom.Envelope outer,
                                                             sim.display.Display2D display,
                                                             GeomGridField gridField)
compute the MBR for the grid field in display coordinates This is used to determine the display bounds for the grid field for Display2D.attach().

Parameters:
outer - denotes MBR that maps to display window in world coordinates
display - is the display into which the grid will be rendered
gridField - for which we wish to find bounds in display coordinates
Returns:
grid field bounds in display coordinates; will return viewport if grid does not intersect given outer MBR

isWithinBounds

public static boolean isWithinBounds(com.vividsolutions.jts.geom.Envelope outer,
                                     GeomGridField gridField)
Parameters:
outer - denotes MBR that maps to display window in world coordinates
gridField - for which we wish to find bounds in display coordinates
Returns:
true iff 'gridField' is within, intersects, or covers 'outer', else returns false Can be used as check for computeBounds()