nl.tudelft.simulation.dsol.animation.D2
Class Renderable2DInterface.Util

java.lang.Object
  extended by nl.tudelft.simulation.dsol.animation.D2.Renderable2DInterface.Util
Enclosing interface:
Renderable2DInterface

public static class Renderable2DInterface.Util
extends Object

A Util
(c) copyright 2002-2005 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl
License of use: Lesser General Public License (LGPL) , no warranty.

Version:
1.0 Mar 1, 2004
Author:
Peter Jacobs

Constructor Summary
protected Renderable2DInterface.Util()
          constructs a new Util
 
Method Summary
static Rectangle2D computeVisibleExtent(Rectangle2D extent, Dimension screen)
          computes the visible extent
static double getScale(Rectangle2D extent, Dimension screen)
          returns the scale of a screen compared to an extent.
static Point2D getScreenCoordinates(Point2D worldCoordinates, Rectangle2D extent, Dimension screen)
          returns the frame xy-coordinates of a point in world coordinates.
static Point2D getWorldCoordinates(Point2D screenCoordinates, Rectangle2D extent, Dimension screen)
          returns the frame xy-coordinates of a point in screen coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Renderable2DInterface.Util

protected Renderable2DInterface.Util()
constructs a new Util

Method Detail

getScale

public static double getScale(Rectangle2D extent,
                              Dimension screen)
returns the scale of a screen compared to an extent. The scale can only be computed if the xScale and yScale are equal. If this is not the case, Double.NaN is returned. In order to overcome estimation errors, this equality is computed with Math.abs(yScale-xScale) <0.005xScale. If the height or the width of the screen are <0 Double.NaN is returned.

Parameters:
extent - the extent
screen - the screen
Returns:
double the scale. Can return Double.NaN

computeVisibleExtent

public static Rectangle2D computeVisibleExtent(Rectangle2D extent,
                                               Dimension screen)
computes the visible extent

Parameters:
extent - the extent
screen - the screen
Returns:
a new extent or null if parameters are null or screen is invalid ( <0)

getScreenCoordinates

public static Point2D getScreenCoordinates(Point2D worldCoordinates,
                                           Rectangle2D extent,
                                           Dimension screen)
returns the frame xy-coordinates of a point in world coordinates. If parameters are invalid (i.e. screen.size <0) a null value is returned. If parameter combinations (i.e !extent.contains(point)) are invalid a null value is returned.

Parameters:
worldCoordinates - the world coordinates
extent - the extent of this
screen - the screen
Returns:
Point2D (x,y) on screen. Can be null

getWorldCoordinates

public static Point2D getWorldCoordinates(Point2D screenCoordinates,
                                          Rectangle2D extent,
                                          Dimension screen)
returns the frame xy-coordinates of a point in screen coordinates. If parameters are invalid (i.e. screen.size <0) a null value is returned. If parameter combinations (i.e !screen.contains(point)) are invalid a null value is returned.

Parameters:
screenCoordinates - the screen coordinates
extent - the extent of this
screen - the screen
Returns:
Point2D (x,y) on screen


Copyright © 2002-2010 Delft University of Technology, the Netherlands. All Rights Reserved.