Package edu.umd.cs.piccolo.util
Class PPaintContext
java.lang.Object
edu.umd.cs.piccolo.util.PPaintContext
PPaintContext is used by piccolo nodes to paint themselves on the
screen. PPaintContext wraps a Graphics2D to implement painting.
- Version:
- 1.0
- Author:
- Jesse Grosjean
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PStackStack of cameras through which the node being painted is being viewed.protected PStackUsed to optimize clipping region.protected PStackUsed while computing transparency.static PPaintContextDeprecated.will disappear as soon as possible Global for accessing the current paint context while painting.static final intUsed for improving quality of rendering when requested.protected PStackTracks clipping region in local coordinate system.static final intUsed for lowering quality of rendering when requested.static FontRenderContextFont context to use while in high quality rendering.static FontRenderContextFont context to use while in low quality rendering.protected intThe current render quality that all rendering should be done in.protected PStackStack of transforms being applied to the drawing context. -
Constructor Summary
ConstructorsConstructorDescriptionPPaintContext(Graphics2D graphics) Creates a PPaintContext associated with the given graphics context. -
Method Summary
Modifier and TypeMethodDescriptionReturns the camera at the top of the camera stack, or null if stack is empty.Returns the graphics context associated with this paint context.Returns the clipping region in the local coordinate system applied by graphics.intReturn the render quality used by this paint context.doublegetScale()Returns scale of the current graphics context.voidRemoves the camera at the top of the camera stack.voidDeprecated.in favor of popCamera()voidRemoves the topmost clipping region from the clipping stack.voidpopTransform(PAffineTransform transform) Pops the topmost Transform from the top of the transform if the passed in transform is not null.voidpopTransparency(float transparency) Removes the topmost transparency if the given transparency is not opaque (1f).voidpushCamera(PCamera aCamera) Pushes the camera onto the camera stack.voidPushes the given clip to the pain context.voidpushTransform(PAffineTransform transform) Pushed the provided transform onto the transform stack if it is not null.voidpushTransparency(float transparency) Pushes the provided transparency onto the transparency stack if necessary.voidsetRenderQuality(int requestedQuality) Set the rendering hints for this paint context.
-
Field Details
-
LOW_QUALITY_RENDERING
public static final int LOW_QUALITY_RENDERINGUsed for lowering quality of rendering when requested.- See Also:
-
HIGH_QUALITY_RENDERING
public static final int HIGH_QUALITY_RENDERINGUsed for improving quality of rendering when requested.- See Also:
-
RENDER_QUALITY_LOW_FRC
Font context to use while in low quality rendering. -
RENDER_QUALITY_HIGH_FRC
Font context to use while in high quality rendering. -
CURRENT_PAINT_CONTEXT
Deprecated.will disappear as soon as possible Global for accessing the current paint context while painting. -
compositeStack
Used while computing transparency. -
clipStack
Used to optimize clipping region. -
localClipStack
Tracks clipping region in local coordinate system. -
cameraStack
Stack of cameras through which the node being painted is being viewed. -
transformStack
Stack of transforms being applied to the drawing context. -
renderQuality
protected int renderQualityThe current render quality that all rendering should be done in.
-
-
Constructor Details
-
PPaintContext
Creates a PPaintContext associated with the given graphics context.- Parameters:
graphics- graphics context to associate with this paint context
-
-
Method Details
-
getGraphics
Returns the graphics context associated with this paint context.- Returns:
- graphics context associated with this paint context
-
getLocalClip
Returns the clipping region in the local coordinate system applied by graphics.- Returns:
- clipping region in the local coordinate system applied by graphics
-
getScale
public double getScale()Returns scale of the current graphics context. By calculating how a unit segment gets transformed after transforming it by the graphics context's transform.- Returns:
- scale of the current graphics context's transformation
-
pushCamera
Pushes the camera onto the camera stack.- Parameters:
aCamera- camera to push onto the stack
-
popCamera
Deprecated.in favor of popCamera()- Parameters:
aCamera- absolute not used in any way
-
popCamera
public void popCamera()Removes the camera at the top of the camera stack.- Since:
- 1.3
-
getCamera
Returns the camera at the top of the camera stack, or null if stack is empty.- Returns:
- topmost camera on camera stack or null if stack is empty
-
pushClip
Pushes the given clip to the pain context.- Parameters:
clip- clip to be pushed
-
popClip
Removes the topmost clipping region from the clipping stack.- Parameters:
clip- not used in this method
-
pushTransparency
public void pushTransparency(float transparency) Pushes the provided transparency onto the transparency stack if necessary. If the transparency is fully opaque, then it does nothing.- Parameters:
transparency- transparency to be pushed onto the transparency stack
-
popTransparency
public void popTransparency(float transparency) Removes the topmost transparency if the given transparency is not opaque (1f).- Parameters:
transparency- transparency to be popped
-
pushTransform
Pushed the provided transform onto the transform stack if it is not null.- Parameters:
transform- will be pushed onto the transform stack if not null
-
popTransform
Pops the topmost Transform from the top of the transform if the passed in transform is not null.- Parameters:
transform- transform that should be at the top of the stack
-
getRenderQuality
public int getRenderQuality()Return the render quality used by this paint context.- Returns:
- the current render quality
-
setRenderQuality
public void setRenderQuality(int requestedQuality) Set the rendering hints for this paint context. The render quality is most often set by the rendering PCanvas. Use PCanvas.setRenderQuality() and PCanvas.setInteractingRenderQuality() to set these values.- Parameters:
requestedQuality- supports PPaintContext.HIGH_QUALITY_RENDERING or PPaintContext.LOW_QUALITY_RENDERING
-