edu.stanford.hci.r3.paper.regions
Class PolygonalRegion

java.lang.Object
  extended by edu.stanford.hci.r3.paper.Region
      extended by edu.stanford.hci.r3.paper.regions.PolygonalRegion

public class PolygonalRegion
extends Region

Polygonal Regions store the individual vertices and the units to interpret the vertices. WARNING: Java2D Polygons only accept integer values! Thus, it might not be smart to pass in fractional values (even though we accept Floats/Doubles). We WILL round off each input value with Math.round(...). So, if you pass in a point to the main constructor PolygonalRegion(Units, Point2D) with vertices such as 0.45 inches, your vertex may be snapped to 0.0 inches! Instead, you may use the alternate convenience constructor PolygonalRegion(Units current, Units destination, Point2D). This constructor will take in your Polygon in the current units, and convert all the values to the (presumably finer) destination unit. For example, to convert your Points from Inches to Points, call PolygonalRegion(new Inches(), new Points(), Point2D vertex1, Point2D vertex2, ...). Of course, with Java's varargs, you can pass in a Point2D[] as the final argument.

This software is distributed under the BSD License.


Field Summary
 
Fields inherited from class edu.stanford.hci.r3.paper.Region
referenceUnits, scaleX, scaleY
 
Constructor Summary
PolygonalRegion(java.lang.String name, Units u, java.awt.geom.Point2D... points)
          Creates a polygon with origin at the first point that was passed in.
PolygonalRegion(java.lang.String name, Units currUnits, Units destUnits, java.awt.geom.Point2D... pts)
          Alternate constructor, if your current units are not optimal (e.g., Inches, Centimeters, and anything really big).
 
Method Summary
 Units getOffsetX()
           
 Units getOffsetY()
           
 java.awt.Polygon getPolygonReference()
           
 RegionRenderer getRenderer()
          Subclasses should override this, to customize rendering.
 java.awt.Color getStrokeColor()
           
 int getStrokeThickness()
           
 void setStrokeColor(java.awt.Color strokeColor)
           
 void setStrokeThickness(int strokeThickness)
           
 java.lang.String toString()
          Please override for more interesting output.
 
Methods inherited from class edu.stanford.hci.r3.paper.Region
addEventHandler, getEventHandlers, getFillColor, getHeight, getIsActiveString, getName, getOpacity, getOriginX, getOriginY, getParentSheet, getScaleX, getScaleY, getShape, getUnits, getUnscaledBounds2D, getUnscaledBoundsHeight, getUnscaledBoundsWidth, getUnscaledShapeCopy, getWidth, isActive, isVisible, resetScale, scaleRegion, scaleRegionUniformly, setActive, setFillColor, setName, setOpacity, setParentSheet, setScale, setShape, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PolygonalRegion

public PolygonalRegion(java.lang.String name,
                       Units u,
                       java.awt.geom.Point2D... points)
Creates a polygon with origin at the first point that was passed in.

Parameters:
u -
points -

PolygonalRegion

public PolygonalRegion(java.lang.String name,
                       Units currUnits,
                       Units destUnits,
                       java.awt.geom.Point2D... pts)
Alternate constructor, if your current units are not optimal (e.g., Inches, Centimeters, and anything really big). For destinationUnits, choose something fine, like Millimeters, Points, or your desired Screen Pixel or PrinterDPI conversion.

Parameters:
currUnits -
destUnits -
pts -
Method Detail

getOffsetX

public Units getOffsetX()
Returns:

getOffsetY

public Units getOffsetY()
Returns:

getPolygonReference

public java.awt.Polygon getPolygonReference()
Returns:
the internal polygon (unscaled).

getRenderer

public RegionRenderer getRenderer()
Description copied from class: Region
Subclasses should override this, to customize rendering. Otherwise, you'll just get gray boxes, which is what RegionRenderer does.

Overrides:
getRenderer in class Region
Returns:
the renderer for this region
See Also:
Region.getRenderer()

getStrokeColor

public java.awt.Color getStrokeColor()
Overrides:
getStrokeColor in class Region

getStrokeThickness

public int getStrokeThickness()

setStrokeColor

public void setStrokeColor(java.awt.Color strokeColor)
Overrides:
setStrokeColor in class Region

setStrokeThickness

public void setStrokeThickness(int strokeThickness)

toString

public java.lang.String toString()
Please override for more interesting output.

Overrides:
toString in class Region
Returns:
the String representation of this Region
See Also:
Object.toString()

Copyright 2006 Stanford University