|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.piccolo.PNode
edu.umd.cs.piccolo.PCamera
public class PCamera
PCamera represents a viewport onto a list of layer nodes. Each camera maintains a view transform through which it views these layers. Translating and scaling this view transform is how zooming and panning are implemented.
Cameras are also the point through which all PInputEvents enter Piccolo. The canvas coordinate system, and the local coordinate system of the topmost camera should always be the same.
PLayer
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class edu.umd.cs.piccolo.PNode |
---|
PNode.PSceneGraphDelegate |
Field Summary | |
---|---|
static int |
PROPERTY_CODE_LAYERS
The property code that identifies a change in the set of this camera's layers (see getLayer , getLayerCount , getLayersReference ). |
static int |
PROPERTY_CODE_VIEW_TRANSFORM
The property code that identifies a change in this camera's view transform (see getViewTransform ,
getViewTransformReference ). |
static java.lang.String |
PROPERTY_LAYERS
The property name that identifies a change in the set of this camera's layers (see getLayer , getLayerCount , getLayersReference ). |
static java.lang.String |
PROPERTY_VIEW_TRANSFORM
The property name that identifies a change in this camera's view transform (see getViewTransform ,
getViewTransformReference ). |
static int |
VIEW_CONSTRAINT_ALL
|
static int |
VIEW_CONSTRAINT_CENTER
|
static int |
VIEW_CONSTRAINT_NONE
Denotes that the view has no constraints. |
Fields inherited from interface java.awt.print.Printable |
---|
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary | |
---|---|
PCamera()
Construct a new camera with no layers and a default white color. |
Method Summary | |
---|---|
void |
addLayer(int index,
PLayer layer)
Add the layer at the given index in this camera's list of layers. |
void |
addLayer(PLayer layer)
Add the layer to the end of this camera's list of layers. |
PTransformActivity |
animateViewToCenterBounds(java.awt.geom.Rectangle2D centerBounds,
boolean shouldScaleToFit,
long duration)
Animate the camera's view from its current transform when the activity starts to a new transform that centers the given bounds in the camera layers coordinate system into the cameras view bounds. |
PTransformActivity |
animateViewToIncludeBounds(java.awt.geom.Rectangle2D includeBounds,
long duration)
Deprecated. Renamed to animateViewToPanToBounds |
PTransformActivity |
animateViewToPanToBounds(java.awt.geom.Rectangle2D panToBounds,
long duration)
Pan the camera's view from its current transform when the activity starts to a new transform so that the view bounds will contain (if possible, intersect if not possible) the new bounds in the camera layers coordinate system. |
PTransformActivity |
animateViewToTransform(java.awt.geom.AffineTransform destination,
long duration)
Animate the cameras view transform from its current value when the activity starts to the new destination transform value. |
protected void |
applyViewConstraints()
Transforms the view so that it conforms to the given constraint. |
void |
fullPaint(PPaintContext paintContext)
Override fullPaint to push the camera onto the paintContext so that it can be later be accessed by PPaintContext.getCamera(). |
PComponent |
getComponent()
Get the canvas associated with this camera. |
PLayer |
getLayer(int index)
Returns the layer at the given index. |
int |
getLayerCount()
Returns the number of layers attached to this camera. |
java.util.List |
getLayersReference()
Return a reference to the list of layers managed by this camera. |
PBounds |
getUnionOfLayerFullBounds()
Return the total bounds of all the layers that this camera looks at. |
PBounds |
getViewBounds()
Return the bounds of this camera in the view coordinate system. |
int |
getViewConstraint()
Returns the constraint being applied to the view. |
double |
getViewScale()
Return the scale applied by the view transform to the layers viewed by this camera. |
PAffineTransform |
getViewTransform()
Get a copy of the view transform that is applied to the camera's layers. |
PAffineTransform |
getViewTransformReference()
Get a reference to the view transform that is applied to the camera's layers. |
int |
indexOfLayer(PLayer layer)
Returns the index of the given layer or -1 it not found. |
java.awt.geom.Dimension2D |
localToView(java.awt.geom.Dimension2D localDimension)
Convert the dimension from the camera's local coordinate system to the camera's view coordinate system. |
java.awt.geom.Point2D |
localToView(java.awt.geom.Point2D localPoint)
Convert the point from the camera's local coordinate system to the camera's view coordinate system. |
java.awt.geom.Rectangle2D |
localToView(java.awt.geom.Rectangle2D localRectangle)
Convert the rectangle from the camera's local coordinate system to the camera's view coordinate system. |
protected void |
paint(PPaintContext paintContext)
Paint this camera (default background color is white) and then paint the cameras view through the view transform. |
protected void |
paintCameraView(PPaintContext paintContext)
Paint all the layers that the camera is looking at, this method is called after the cameras view transform and clip are applied to the paintContext. |
protected void |
paintDebugInfo(PPaintContext paintContext)
Renders debug info onto the newly painted scene. |
PPickPath |
pick(double x,
double y,
double halo)
Generate and return a PPickPath for the point x,y specified in the local coord system of this camera. |
protected boolean |
pickAfterChildren(PPickPath pickPath)
After the direct children of the camera have been given a chance to be picked objects viewed by the camera are given a chance to be picked. |
protected boolean |
pickCameraView(PPickPath pickPath)
Pick all the layers that the camera is looking at, this method is called after the cameras view transform and clip are applied to the pickPath. |
PLayer |
removeLayer(int index)
Remove the layer at the given index from the list of layers managed by this camera. |
PLayer |
removeLayer(PLayer layer)
Remove the given layer from the list of layers managed by this camera. |
void |
repaintFrom(PBounds localBounds,
PNode sourceNode)
Repaint this camera, and forward the repaint request to the camera's canvas if it is not null. |
void |
repaintFromLayer(PBounds viewBounds,
PLayer repaintedLayer)
Repaint from one of the cameras layers. |
void |
repaintFromLayer(PBounds viewBounds,
PNode repaintedLayer)
Deprecated. since a more specific repaintFromLayer method is available Repaint from one of the cameras layers. The repaint region needs to be transformed from view to local in this case. Unlike most repaint methods in piccolo this one must not modify the viewBounds parameter. |
void |
scaleView(double scale)
Scale the view transform that is applied to the layers viewed by this camera by the given amount. |
void |
scaleViewAboutPoint(double scale,
double x,
double y)
Scale the view transform that is applied to the layers viewed by this camera by the given amount about the given point. |
void |
setComponent(PComponent newComponent)
Set the canvas associated with this camera. |
void |
setViewBounds(java.awt.geom.Rectangle2D centerBounds)
Animates the camera's view so that the given bounds (in camera layer's coordinate system) are centered within the cameras view bounds. |
void |
setViewConstraint(int constraint)
Sets the view constraint to apply to the view. |
void |
setViewOffset(double x,
double y)
Sets the offset of the view transform that is applied to the camera's layers. |
void |
setViewScale(double scale)
Set the scale of the view transform that is applied to the layers viewed by this camera. |
void |
setViewTransform(java.awt.geom.AffineTransform aTransform)
Set the view transform that is applied to the views layers. |
void |
translateView(double dx,
double dy)
Translate the view transform that is applied to the camera's layers. |
java.awt.geom.Dimension2D |
viewToLocal(java.awt.geom.Dimension2D viewDimension)
Convert the dimension from the camera's view coordinate system to the camera's local coordinate system. |
java.awt.geom.Point2D |
viewToLocal(java.awt.geom.Point2D viewPoint)
Convert the point from the camera's view coordinate system to the camera's local coordinate system. |
java.awt.geom.Rectangle2D |
viewToLocal(java.awt.geom.Rectangle2D viewRectangle)
Convert the rectangle from the camera's view coordinate system to the camera's local coordinate system. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PROPERTY_LAYERS
getLayer
, getLayerCount
, getLayersReference
). A
property change event's new value will be a reference to the list of this
nodes layers, but old value will always be null.
public static final int PROPERTY_CODE_LAYERS
getLayer
, getLayerCount
, getLayersReference
). A
property change event's new value will be a reference to the list of this
nodes layers, but old value will always be null.
public static final java.lang.String PROPERTY_VIEW_TRANSFORM
getViewTransform
,
getViewTransformReference
). A property
change event's new value will be a reference to the view transform, but
old value will always be null.
public static final int PROPERTY_CODE_VIEW_TRANSFORM
getViewTransform
,
getViewTransformReference
). A property
change event's new value will be a reference to the view transform, but
old value will always be null.
public static final int VIEW_CONSTRAINT_NONE
public static final int VIEW_CONSTRAINT_ALL
public static final int VIEW_CONSTRAINT_CENTER
Constructor Detail |
---|
public PCamera()
Method Detail |
---|
public PComponent getComponent()
public void setComponent(PComponent newComponent)
newComponent
- the component to which this camera will dispatch
repaint requests topublic void repaintFrom(PBounds localBounds, PNode sourceNode)
repaintFrom
in class PNode
localBounds
- the area that requires repaintingsourceNode
- the node from which the repaint message originates, may
be the camera itselfpublic void repaintFromLayer(PBounds viewBounds, PLayer repaintedLayer)
viewBounds
- the bounds of the region needing paintingrepaintedLayer
- layer dispatching the repaint notificationpublic void repaintFromLayer(PBounds viewBounds, PNode repaintedLayer)
viewBounds
- the bounds of the region needing paintingrepaintedLayer
- layer dispatching the repaint notificationpublic java.util.List getLayersReference()
public int getLayerCount()
public PLayer getLayer(int index)
index
- the index of the layer
public int indexOfLayer(PLayer layer)
layer
- layer to search for
public void addLayer(PLayer layer)
layer
- layer to add to this camerapublic void addLayer(int index, PLayer layer)
index
- index before which to add this layerlayer
- Layer to addpublic PLayer removeLayer(PLayer layer)
layer
- the layer to be removed
public PLayer removeLayer(int index)
index
- the index of the layer to remove
public PBounds getUnionOfLayerFullBounds()
protected void paint(PPaintContext paintContext)
paint
in class PNode
paintContext
- the context in which the painting occursprotected void paintCameraView(PPaintContext paintContext)
paintContext
- the context in which the painting occursprotected void paintDebugInfo(PPaintContext paintContext)
paintContext
- the context in which the painting occurspublic void fullPaint(PPaintContext paintContext)
fullPaint
in class PNode
paintContext
- the context in which the painting occurspublic PPickPath pick(double x, double y, double halo)
x
- the x coordinate of the pick path given in local coordinatesy
- the y coordinate of the pick path given in local coordinateshalo
- the distance from the x,y coordinate that is considered for
inclusion in the pick path
protected boolean pickAfterChildren(PPickPath pickPath)
pickAfterChildren
in class PNode
pickPath
- picked layer children add added to this pick path
protected boolean pickCameraView(PPickPath pickPath)
pickPath
- picked layer children add added to this pick path
public PBounds getViewBounds()
public void setViewBounds(java.awt.geom.Rectangle2D centerBounds)
centerBounds
- the targetBoundspublic double getViewScale()
public void scaleView(double scale)
scale
- the scale to change the Layers' view transformpublic void scaleViewAboutPoint(double scale, double x, double y)
scale
- the scale at which the view should bex
- the x coordinate the view should change toy
- the y coordinate the view should change topublic void setViewScale(double scale)
scale
- the scale of the transform viewing the layerspublic void translateView(double dx, double dy)
dx
- the delta which the x coordinate should be increased bydy
- the delta which the y coordinate should be increased bypublic void setViewOffset(double x, double y)
x
- the new x translation of the view transformy
- the new y translation of the view transformpublic PAffineTransform getViewTransform()
public PAffineTransform getViewTransformReference()
public void setViewTransform(java.awt.geom.AffineTransform aTransform)
aTransform
- the new view transformpublic PTransformActivity animateViewToCenterBounds(java.awt.geom.Rectangle2D centerBounds, boolean shouldScaleToFit, long duration)
centerBounds
- the bounds which the animation will pace at the
center of the viewshouldScaleToFit
- whether the camera should scale the view while
animating to itduration
- how many milliseconds the animations should take
public PTransformActivity animateViewToPanToBounds(java.awt.geom.Rectangle2D panToBounds, long duration)
panToBounds
- the bounds to which the view will animate toduration
- the duration of the animation given in milliseconds
public PTransformActivity animateViewToIncludeBounds(java.awt.geom.Rectangle2D includeBounds, long duration)
includeBounds
- the bounds to which the view will animate toduration
- the duration of the animation given in milliseconds
public PTransformActivity animateViewToTransform(java.awt.geom.AffineTransform destination, long duration)
destination
- the transform to which the view should be transformed
intoduration
- the duraiton in milliseconds the animation should take
public int getViewConstraint()
public void setViewConstraint(int constraint)
constraint
- the new constraint to apply to the viewprotected void applyViewConstraints()
public java.awt.geom.Point2D viewToLocal(java.awt.geom.Point2D viewPoint)
viewPoint
- the point to transform to the local coordinate system
from the view's coordinate system
public java.awt.geom.Dimension2D viewToLocal(java.awt.geom.Dimension2D viewDimension)
viewDimension
- the dimension to transform from the view system to
the local coordinate system
public java.awt.geom.Rectangle2D viewToLocal(java.awt.geom.Rectangle2D viewRectangle)
viewRectangle
- the rectangle to transform from view to local
coordinate System
public java.awt.geom.Point2D localToView(java.awt.geom.Point2D localPoint)
localPoint
- point to transform from local to view coordinate system
public java.awt.geom.Dimension2D localToView(java.awt.geom.Dimension2D localDimension)
localDimension
- the dimension to transform from local to view
coordinate systems
public java.awt.geom.Rectangle2D localToView(java.awt.geom.Rectangle2D localRectangle)
localRectangle
- the rectangle to transform from local to view
coordinate system
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |