|
||||||||||
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
|
static int |
PROPERTY_CODE_VIEW_TRANSFORM
|
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
|
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()
|
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)
|
int |
getLayerCount()
|
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()
|
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)
|
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 only called when the cameras view transform and clip are applied to the paintContext. |
protected void |
paintDebugInfo(PPaintContext paintContext)
|
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 only called when 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 descendentOrThis)
Repaint this camera, and forward the repaint request to the camera's canvas if it is not null. |
void |
repaintFromLayer(PBounds viewBounds,
PNode repaintedLayer)
Repaint from one of the cameras layers. |
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 aComponent)
Set the canvas associated with this camera. |
void |
setViewBounds(java.awt.geom.Rectangle2D centerBounds)
Translates and scales the camera's view transform so that the given bounds (in camera layer's coordinate system)are centered withing the cameras view bounds. |
void |
setViewConstraint(int constraint)
|
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, 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
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
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 aComponent)
public void repaintFrom(PBounds localBounds, PNode descendentOrThis)
repaintFrom
in class PNode
localBounds
- the bounds to repaintdescendentOrThis
- if childOrThis does not equal this then this nodes transform will be applied to the localBounds parampublic void repaintFromLayer(PBounds viewBounds, PNode repaintedLayer)
public java.util.List getLayersReference()
public int getLayerCount()
public PLayer getLayer(int index)
public int indexOfLayer(PLayer layer)
public void addLayer(PLayer layer)
public void addLayer(int index, PLayer layer)
public PLayer removeLayer(PLayer layer)
public PLayer removeLayer(int index)
public PBounds getUnionOfLayerFullBounds()
protected void paint(PPaintContext paintContext)
paint
in class PNode
paintContext
- the paint context to use for painting the nodeprotected void paintCameraView(PPaintContext paintContext)
protected void paintDebugInfo(PPaintContext paintContext)
public void fullPaint(PPaintContext paintContext)
fullPaint
in class PNode
paintContext
- the paint context to use for painting this node and its childrenpublic PPickPath pick(double x, double y, double halo)
protected boolean pickAfterChildren(PPickPath pickPath)
pickAfterChildren
in class PNode
pickPath
- the pick path used for the pick operation
protected boolean pickCameraView(PPickPath pickPath)
public PBounds getViewBounds()
public void setViewBounds(java.awt.geom.Rectangle2D centerBounds)
public double getViewScale()
public void scaleView(double scale)
public void scaleViewAboutPoint(double scale, double x, double y)
public void setViewScale(double scale)
public void translateView(double dx, double dy)
public void setViewOffset(double x, double y)
public PAffineTransform getViewTransform()
public PAffineTransform getViewTransformReference()
public void setViewTransform(java.awt.geom.AffineTransform aTransform)
public PTransformActivity animateViewToCenterBounds(java.awt.geom.Rectangle2D centerBounds, boolean shouldScaleToFit, long duration)
public PTransformActivity animateViewToPanToBounds(java.awt.geom.Rectangle2D panToBounds, long duration)
public PTransformActivity animateViewToIncludeBounds(java.awt.geom.Rectangle2D includeBounds, long duration)
public PTransformActivity animateViewToTransform(java.awt.geom.AffineTransform destination, long duration)
public int getViewConstraint()
public void setViewConstraint(int constraint)
protected void applyViewConstraints()
public java.awt.geom.Point2D viewToLocal(java.awt.geom.Point2D viewPoint)
public java.awt.geom.Dimension2D viewToLocal(java.awt.geom.Dimension2D viewDimension)
public java.awt.geom.Rectangle2D viewToLocal(java.awt.geom.Rectangle2D viewRectangle)
public java.awt.geom.Point2D localToView(java.awt.geom.Point2D localPoint)
public java.awt.geom.Dimension2D localToView(java.awt.geom.Dimension2D localDimension)
public java.awt.geom.Rectangle2D localToView(java.awt.geom.Rectangle2D localRectangle)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |