hep.wired.viewport
Class RectangularViewPort

java.lang.Object
  extended by java.awt.geom.RectangularShape
      extended by java.awt.geom.Rectangle2D
          extended by java.awt.geom.Rectangle2D.Double
              extended by hep.wired.viewport.RectangularViewPort
All Implemented Interfaces:
ViewPort, UVWindices, WiredRegistry.ID, XYZindices, Shape, Serializable, Cloneable, org.freehep.xml.io.XMLIO

public class RectangularViewPort
extends Rectangle2D.Double
implements ViewPort

Defines a Rectangular Viewport using x0, y0, width and height. Applies the viewport functions:

 
 u = (x + 1) * width / 2 + x0; v = height - (y + 1) * height / 2 + y0; w = (z +
 1) * width / 2 + x0; // NOTE: this is done to be able to calculate bounding
 boxes in Z.
 
 
given rectangle(x0, y0, width, height). This projects a viewport of ([-1,1],[-1,1]) onto ([x0,y0+height],[x0+width,y0]).

Version:
$Id: RectangularViewPort.java 8598 2006-08-14 20:38:02Z duns $
Author:
Mark Donszelmann
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D
Rectangle2D.Double, Rectangle2D.Float
 
Field Summary
 
Fields inherited from class java.awt.geom.Rectangle2D.Double
height, width, x, y
 
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
 
Fields inherited from interface hep.wired.util.XYZindices
X, Y, Z
 
Fields inherited from interface hep.wired.util.UVWindices
U, V, W
 
Constructor Summary
RectangularViewPort()
          Creates a rectangular viewport of (0, 0, 800, 600).
RectangularViewPort(double x, double y, double width, double height, int componentWidth, int componentHeight)
          Creates a rectangular viewport from given parameters.
RectangularViewPort(Rectangle2D r, int componentWidth, int componentHeight)
          Creates a rectangular viewport from given rectangle.
 
Method Summary
 ViewPort copy()
          Returns a copy of the viewport
 double[] deltaTransform(double[] xyz)
          Returns an array of length 3: uvw[] = viewport-delta(xyz[]).
 int getComponentHeight()
           
 int getComponentWidth()
           
 String getID()
           
 String getName()
          Returns the name of the View Port.
 double[] inverseDeltaTransform(double[] uvw)
          Returns an array of length 3: xyz[] = inverse-viewport-delta(uvw[]).
 double[] inverseTransform(double[] uvw)
          Returns an array of length 3: xyz[] = inverse-viewport(uvw[]).
 void restore(org.freehep.xml.io.XMLIOManager xmlioManager, org.jdom.Element nodeEl)
           
 void save(org.freehep.xml.io.XMLIOManager xmlioManager, org.jdom.Element nodeEl)
           
 String toString()
           
 double[] transform(double[] xyz)
          Returns an array of length 3: uvw = viewport(xyz).
 double[][] transform(double[][] xyz, int n)
          Returns an array of length 3*n: uvw[][n] = viewport(xyz[][n]).
 
Methods inherited from class java.awt.geom.Rectangle2D.Double
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect
 
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, union
 
Methods inherited from class java.awt.geom.RectangularShape
clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RectangularViewPort

public RectangularViewPort()
Creates a rectangular viewport of (0, 0, 800, 600).


RectangularViewPort

public RectangularViewPort(Rectangle2D r,
                           int componentWidth,
                           int componentHeight)
Creates a rectangular viewport from given rectangle.


RectangularViewPort

public RectangularViewPort(double x,
                           double y,
                           double width,
                           double height,
                           int componentWidth,
                           int componentHeight)
Creates a rectangular viewport from given parameters.

Method Detail

getComponentWidth

public int getComponentWidth()

getComponentHeight

public int getComponentHeight()

getID

public String getID()
Specified by:
getID in interface WiredRegistry.ID

getName

public String getName()
Description copied from interface: ViewPort
Returns the name of the View Port.

Specified by:
getName in interface ViewPort

copy

public ViewPort copy()
Description copied from interface: ViewPort
Returns a copy of the viewport

Specified by:
copy in interface ViewPort

transform

public double[] transform(double[] xyz)
Description copied from interface: ViewPort
Returns an array of length 3: uvw = viewport(xyz). The z component is not touched. The returned array may have a lifetime up to the next call to this method on this object.

Specified by:
transform in interface ViewPort

transform

public double[][] transform(double[][] xyz,
                            int n)
Description copied from interface: ViewPort
Returns an array of length 3*n: uvw[][n] = viewport(xyz[][n]). The z component is not touched. The returned array may have a lifetime up to the next call to this method on this object. The number of "valid" coordinates is given by n.

Specified by:
transform in interface ViewPort

deltaTransform

public double[] deltaTransform(double[] xyz)
Description copied from interface: ViewPort
Returns an array of length 3: uvw[] = viewport-delta(xyz[]). The z component is not touched. The returned array may have a lifetime up to the next call to this method on this object.

Specified by:
deltaTransform in interface ViewPort

inverseTransform

public double[] inverseTransform(double[] uvw)
Description copied from interface: ViewPort
Returns an array of length 3: xyz[] = inverse-viewport(uvw[]). The w component is not touched. The returned array may have a lifetime up to the next call to this method on this object.

Specified by:
inverseTransform in interface ViewPort

inverseDeltaTransform

public double[] inverseDeltaTransform(double[] uvw)
Description copied from interface: ViewPort
Returns an array of length 3: xyz[] = inverse-viewport-delta(uvw[]). The w component is not touched. The returned array may have a lifetime up to the next call to this method on this object.

Specified by:
inverseDeltaTransform in interface ViewPort

toString

public String toString()
Overrides:
toString in class Rectangle2D.Double

save

public void save(org.freehep.xml.io.XMLIOManager xmlioManager,
                 org.jdom.Element nodeEl)
Specified by:
save in interface org.freehep.xml.io.XMLIO

restore

public void restore(org.freehep.xml.io.XMLIOManager xmlioManager,
                    org.jdom.Element nodeEl)
Specified by:
restore in interface org.freehep.xml.io.XMLIO


Copyright © 1996-2013 FreeHEP. All Rights Reserved.