edu.stanford.hci.r3.util.graphics
Class GraphicsUtils

java.lang.Object
  extended by edu.stanford.hci.r3.util.graphics.GraphicsUtils

public class GraphicsUtils
extends java.lang.Object

This software is distributed under the BSD License.


Constructor Summary
GraphicsUtils()
           
 
Method Summary
static java.awt.Polygon createPolygon(java.awt.geom.Point2D... points)
          Creates a polygon from an array of points.
static java.awt.RenderingHints getBestRenderingHints()
           
static java.lang.String getPathAsString(java.awt.geom.PathIterator pathIterator)
           
static java.awt.geom.Point2D[] getPointsRecentered(java.awt.geom.Point2D[] points, double originX, double originY)
          Recenter the points around x and y.
static java.awt.geom.Point2D[] getPointsWithConvertedUnits(Units sourceUnit, Units destUnit, java.awt.geom.Point2D... points)
          Takes an input array of points, and returns a new array of points where all the values have been converted from the old unit to the new destination unit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphicsUtils

public GraphicsUtils()
Method Detail

createPolygon

public static java.awt.Polygon createPolygon(java.awt.geom.Point2D... points)
Creates a polygon from an array of points. It rounds off all the points' x & y values to the nearest integer, as the Java Polygons only work with ints.

Parameters:
points -
Returns:
the Polygon

getBestRenderingHints

public static java.awt.RenderingHints getBestRenderingHints()
Returns:
smooth as silk rendering hints, useful for nice scaling. Use this with Graphics2D, to create nice graphics.

getPathAsString

public static java.lang.String getPathAsString(java.awt.geom.PathIterator pathIterator)
Parameters:
pathIterator -
Returns:

getPointsRecentered

public static java.awt.geom.Point2D[] getPointsRecentered(java.awt.geom.Point2D[] points,
                                                          double originX,
                                                          double originY)
Recenter the points around x and y.

Parameters:
points - each point will be recalculatd relative to the new origin.
originX - the new originX
originY -
Returns:

getPointsWithConvertedUnits

public static java.awt.geom.Point2D[] getPointsWithConvertedUnits(Units sourceUnit,
                                                                  Units destUnit,
                                                                  java.awt.geom.Point2D... points)
Takes an input array of points, and returns a new array of points where all the values have been converted from the old unit to the new destination unit.

Parameters:
sourceUnit - the input points are defined in this unit
destUnit - the output Point2D[] is definited in this unit.
points - the input points.
Returns:

Copyright 2006 Stanford University