public class PCamera extends PNode
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 FormPNode.PSceneGraphDelegate
Modifier and Type | Field and Description |
---|---|
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 String |
PROPERTY_LAYERS
The property name that identifies a change in the set of this camera's
layers (see
getLayer , getLayerCount , getLayersReference ). |
static 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
Enforces that the view be able to see all nodes in the scene.
|
static int |
VIEW_CONSTRAINT_CENTER
Constrains the the view to be centered on the scene's full bounds.
|
static int |
VIEW_CONSTRAINT_NONE
Denotes that the view has no constraints.
|
FILL_STRATEGY_ASPECT_COVER, FILL_STRATEGY_ASPECT_FIT, FILL_STRATEGY_EXACT_FIT, PROPERTY_BOUNDS, PROPERTY_CHILDREN, PROPERTY_CHILDREN_PICKABLE, PROPERTY_CLIENT_PROPERTIES, PROPERTY_CODE_BOUNDS, PROPERTY_CODE_CHILDREN, PROPERTY_CODE_CHILDREN_PICKABLE, PROPERTY_CODE_CLIENT_PROPERTIES, PROPERTY_CODE_FULL_BOUNDS, PROPERTY_CODE_PAINT, PROPERTY_CODE_PARENT, PROPERTY_CODE_PICKABLE, PROPERTY_CODE_TRANSFORM, PROPERTY_CODE_TRANSPARENCY, PROPERTY_CODE_VISIBLE, PROPERTY_FULL_BOUNDS, PROPERTY_PAINT, PROPERTY_PARENT, PROPERTY_PICKABLE, PROPERTY_TRANSFORM, PROPERTY_TRANSPARENCY, PROPERTY_VISIBLE, SCENE_GRAPH_DELEGATE
NO_SUCH_PAGE, PAGE_EXISTS
Constructor and Description |
---|
PCamera()
Create a new camera with an empy list of layers.
|
Modifier and Type | Method and Description |
---|---|
void |
addLayer(int index,
PLayer layer)
Inserts the specified layer at the specified position in the list of layers viewed by this camera.
|
void |
addLayer(PLayer layer)
Inserts the specified layer at the end of the list of layers viewed by this camera.
|
PTransformActivity |
animateViewToCenterBounds(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
layer's coordinate system into the cameras view bounds.
|
PTransformActivity |
animateViewToPanToBounds(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(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)
Paint this node and all of its descendants.
|
PComponent |
getComponent()
Return the component for this camera, or
null if no
component has been associated with this camera, as may be the case for
internal cameras. |
PLayer |
getLayer(int index)
Return the layer at the specified position in the list of layers viewed by this camera.
|
int |
getLayerCount()
Return the number of layers in the list of layers viewed by this camera.
|
List |
getLayersReference()
Return a reference to the list of layers viewed by this camera.
|
PBounds |
getUnionOfLayerFullBounds()
Return the union of the full bounds of each layer in the list of layers
viewed by this camera, or empty bounds if the list of layers viewed by
this camera is empty.
|
PBounds |
getViewBounds()
Return the bounds of this camera in the view coordinate system.
|
int |
getViewConstraint()
Return the constraint applied to the view.
|
double |
getViewScale()
Return the scale applied by the view transform to the list of layers
viewed by this camera.
|
PAffineTransform |
getViewTransform()
Return a copy of the view transform applied to the list of layers
viewed by this camera.
|
PAffineTransform |
getViewTransformReference()
Return a reference to the view transform applied to the list of layers
viewed by this camera.
|
int |
indexOfLayer(PLayer layer)
Return the index of the first occurrence of the specified layer in the
list of layers viewed by this camera, or
-1 if the list of layers
viewed by this camera does not contain the specified layer. |
Dimension2D |
localToView(Dimension2D localDimension)
Convert the dimension from the camera's local coordinate system to the
camera's view coordinate system.
|
Point2D |
localToView(Point2D localPoint)
Convert the point from the camera's local coordinate system to the
camera's view coordinate system.
|
Rectangle2D |
localToView(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 and then paint this camera's view through its view
transform.
|
protected void |
paintCameraView(PPaintContext paintContext)
Paint all the layers in the list of layers viewed by this camera.
|
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)
Try to pick this node after its children have had a chance to be picked.
|
protected boolean |
pickCameraView(PPickPath pickPath)
Try to pick all of the layers in the list of layers viewed by this
camera.
|
PLayer |
removeLayer(int index)
Removes the element at the specified position from the list of layers
viewed by this camera.
|
PLayer |
removeLayer(PLayer layer)
Removes the first occurrence of the specified layer from the list of
layers viewed by this camera, if it is present.
|
void |
repaintFrom(PBounds localBounds,
PNode sourceNode)
Repaint this camera and forward the repaint request to the component
for this camera, if it is non-null.
|
void |
repaintFromLayer(PBounds viewBounds,
PLayer repaintedLayer)
Repaint from one of the camera's layers.
|
void |
scaleView(double scale)
Scale the view transform applied to the list of layers viewed by this
camera by
scale about the point [0, 0] . |
void |
scaleViewAboutPoint(double scale,
double x,
double y)
Scale the view transform applied to the list of layers viewed by this
camera by
scale about the specified point
[x, y] . |
void |
setComponent(PComponent component)
Set the component for this camera to
component . |
void |
setViewBounds(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 viewConstraint)
Set the view constraint to apply to the view to
viewConstraint . |
void |
setViewOffset(double x,
double y)
Set the offset for the view transform applied to the list of layers
viewed by this camera to
[x, y] . |
void |
setViewScale(double scale)
Set the scale applied by the view transform to the list of layers
viewed by this camera to
scale . |
void |
setViewTransform(AffineTransform viewTransform)
Set the view transform applied to the list of layers
viewed by this camera to
viewTransform . |
void |
translateView(double dx,
double dy)
Translate the view transform applied to the list of layers viewed by this
camera by
[dx, dy] . |
Dimension2D |
viewToLocal(Dimension2D viewDimension)
Convert the dimension from the camera's view coordinate system to the
camera's local coordinate system.
|
Point2D |
viewToLocal(Point2D viewPoint)
Convert the point from the camera's view coordinate system to the
camera's local coordinate system.
|
Rectangle2D |
viewToLocal(Rectangle2D viewRectangle)
Convert the rectangle from the camera's view coordinate system to the
camera's local coordinate system.
|
addActivity, addAttribute, addChild, addChild, addChildren, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToRelativePosition, animateToTransform, animateToTransparency, animateTransformToBounds, centerBoundsOnPoint, centerFullBoundsOnPoint, clone, computeFullBounds, endResizeBounds, findIntersectingNodes, fireChildPropertyChange, firePropertyChange, fullIntersects, fullPick, getAllNodes, getAllNodes, getAttribute, getAttribute, getBooleanAttribute, getBounds, getBoundsChanged, getBoundsReference, getBoundsVolatile, getChild, getChildBoundsInvalid, getChildBoundsVolatile, getChildPaintInvalid, getChildrenCount, getChildrenIterator, getChildrenPickable, getChildrenReference, getClientProperties, getClientPropertyKeysEnumeration, getDoubleAttribute, getFullBounds, getFullBoundsInvalid, getFullBoundsReference, getGlobalBounds, getGlobalFullBounds, getGlobalRotation, getGlobalScale, getGlobalToLocalTransform, getGlobalTranslation, getHeight, getInputEventListeners, getIntegerAttribute, getInverseTransform, getListenerList, getLocalToGlobalTransform, getName, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, getPropertyChangeParentMask, getRoot, getRotation, getScale, getTransform, getTransformReference, getTransparency, getUnionOfChildrenBounds, getVisible, getWidth, getX, getXOffset, getY, getYOffset, globalToLocal, globalToLocal, globalToLocal, indexOfChild, internalUpdateBounds, intersects, invalidateFullBounds, invalidateLayout, invalidatePaint, isAncestorOf, isDescendentOf, isDescendentOfRoot, isOpaque, layoutChildren, lerp, localToGlobal, localToGlobal, localToGlobal, localToParent, localToParent, localToParent, lower, lower, lowerBelow, lowerToBottom, lowerToBottom, offset, paintAfterChildren, parentBoundsChanged, parentToLocal, parentToLocal, parentToLocal, pick, print, print, raise, raise, raiseAbove, raiseToTop, raiseToTop, removeAllChildren, removeChild, removeChild, removeChildren, removeFromParent, removeInputEventListener, removePropertyChangeListener, removePropertyChangeListener, repaint, reparent, replaceWith, resetBounds, rotate, rotateAboutPoint, rotateAboutPoint, rotateInPlace, scale, scaleAboutPoint, scaleAboutPoint, setBounds, setBounds, setBoundsChanged, setChildBoundsInvalid, setChildBoundsVolatile, setChildPaintInvalid, setChildrenPickable, setFullBoundsInvalid, setGlobalRotation, setGlobalScale, setGlobalTranslation, setHeight, setName, setOccluded, setOffset, setOffset, setPaint, setPaintInvalid, setParent, setPickable, setPropertyChangeParentMask, setRotation, setScale, setTransform, setTransparency, setVisible, setWidth, setX, setY, signalBoundsChanged, startResizeBounds, toImage, toImage, toImage, toImage, transformBy, translate, validateFullBounds, validateFullPaint
public static final 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 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
public PComponent getComponent()
null
if no
component has been associated with this camera, as may be the case for
internal cameras.null
if no such
component existspublic void setComponent(PComponent component)
component
. The
component, if non-null, receives repaint notification from this camera.component
- component for this camerapublic void repaintFrom(PBounds localBounds, PNode sourceNode)
repaintFrom
in class PNode
localBounds
- bounds that require repainting, in local coordinatessourceNode
- node from which the repaint message originates, may
be the camera itselfpublic void repaintFromLayer(PBounds viewBounds, PLayer repaintedLayer)
viewBounds
parameter.viewBounds
- bounds that require repainting, in view coordinatesrepaintedLayer
- layer dispatching the repaint notificationpublic List getLayersReference()
public int getLayerCount()
public PLayer getLayer(int index)
index
- index of the layer to returnIndexOutOfBoundsException
- if the specified index is out of range
(index < 0 || index >= getLayerCount()
)public int indexOfLayer(PLayer layer)
-1
if the list of layers
viewed by this camera does not contain the specified layer.layer
- layer to search for-1
if the list of
layers viewed by this camera does not contain the specified layerpublic void addLayer(PLayer layer)
layer
- layer to addpublic void addLayer(int index, PLayer layer)
index
- index at which the specified layer is to be insertedlayer
- layer to addIndexOutOfBoundsException
- if the specified index is out of range
(index < 0 || index >= getLayerCount()
)public PLayer removeLayer(PLayer layer)
layer
- layer to be removedpublic PLayer removeLayer(int index)
index
- index of the layer to removeIndexOutOfBoundsException
- if the specified index is out of range
(index < 0 || index >= getLayerCount()
)public PBounds getUnionOfLayerFullBounds()
protected void paint(PPaintContext paintContext)
protected void paintCameraView(PPaintContext paintContext)
paintContext
- context in which painting occursprotected void paintDebugInfo(PPaintContext paintContext)
paintContext
- context in which painting occurspublic void fullPaint(PPaintContext paintContext)
paint
or
paintAfterChildren
instead.
Pushes this camera onto the specified paint context so that it
can be accessed later by PPaintContext.getCamera()
.
public 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 pathprotected boolean pickAfterChildren(PPickPath pickPath)
After the direct children of this camera have been given a chance to be picked all of the layers in the list of layers viewed by this camera are given a chance to be picked.
pickAfterChildren
in class PNode
pickPath
- the pick path used for the pick operationprotected boolean pickCameraView(PPickPath pickPath)
pickPath
- pick pathpublic PBounds getViewBounds()
public void setViewBounds(Rectangle2D centerBounds)
centerBounds
- the targetBoundspublic double getViewScale()
public void scaleView(double scale)
scale
about the point [0, 0]
.scale
- view transform scalepublic void scaleViewAboutPoint(double scale, double x, double y)
scale
about the specified point
[x, y]
.scale
- view transform scalex
- scale about point, x coordinatey
- scale about point, y coordinatepublic void setViewScale(double scale)
scale
.scale
- view transform scalepublic void translateView(double dx, double dy)
[dx, dy]
.dx
- translate delta xdy
- translate delta ypublic void setViewOffset(double x, double y)
[x, y]
.x
- offset xy
- offset ypublic PAffineTransform getViewTransform()
public PAffineTransform getViewTransformReference()
public void setViewTransform(AffineTransform viewTransform)
viewTransform
.viewTransform
- view transform applied to the list of layers
viewed by this camerapublic PTransformActivity animateViewToCenterBounds(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 takepublic PTransformActivity animateViewToPanToBounds(Rectangle2D panToBounds, long duration)
panToBounds
- the bounds to which the view will animate toduration
- the duration of the animation given in millisecondspublic PTransformActivity animateViewToTransform(AffineTransform destination, long duration)
destination
- the transform to which the view should be transformed
intoduration
- the duraiton in milliseconds the animation should takepublic int getViewConstraint()
VIEW_CONSTRAINT_NONE
,
VIEW_CONSTRAINT_CENTER
, or VIEW_CONSTRAINT_CENTER
. Defaults to VIEW_CONSTRAINT_NONE
.public void setViewConstraint(int viewConstraint)
viewConstraint
. The view constraint must be one of
VIEW_CONSTRAINT_NONE
, VIEW_CONSTRAINT_CENTER
, or VIEW_CONSTRAINT_CENTER
.viewConstraint
- constraint to apply to the viewIllegalArgumentException
- if viewConstraint
is not one of VIEW_CONSTRAINT_NONE
,
VIEW_CONSTRAINT_CENTER
, or VIEW_CONSTRAINT_CENTER
protected void applyViewConstraints()
public Point2D viewToLocal(Point2D viewPoint)
viewPoint
- the point to transform to the local coordinate system
from the view's coordinate systempublic Dimension2D viewToLocal(Dimension2D viewDimension)
viewDimension
- the dimension to transform from the view system to
the local coordinate systempublic Rectangle2D viewToLocal(Rectangle2D viewRectangle)
viewRectangle
- the rectangle to transform from view to local
coordinate Systempublic Point2D localToView(Point2D localPoint)
localPoint
- point to transform from local to view coordinate systempublic Dimension2D localToView(Dimension2D localDimension)
localDimension
- the dimension to transform from local to view
coordinate systemspublic Rectangle2D localToView(Rectangle2D localRectangle)
localRectangle
- the rectangle to transform from local to view
coordinate systemCopyright © 1995-2013 Piccolo2D. All Rights Reserved.