Class PPaintContext

java.lang.Object
edu.umd.cs.piccolo.util.PPaintContext

public class PPaintContext extends Object
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 Details

    • LOW_QUALITY_RENDERING

      public static final int LOW_QUALITY_RENDERING
      Used for lowering quality of rendering when requested.
      See Also:
    • HIGH_QUALITY_RENDERING

      public static final int HIGH_QUALITY_RENDERING
      Used for improving quality of rendering when requested.
      See Also:
    • RENDER_QUALITY_LOW_FRC

      public static FontRenderContext RENDER_QUALITY_LOW_FRC
      Font context to use while in low quality rendering.
    • RENDER_QUALITY_HIGH_FRC

      public static FontRenderContext RENDER_QUALITY_HIGH_FRC
      Font context to use while in high quality rendering.
    • CURRENT_PAINT_CONTEXT

      public static PPaintContext CURRENT_PAINT_CONTEXT
      Deprecated.
      will disappear as soon as possible Global for accessing the current paint context while painting.
    • compositeStack

      protected PStack compositeStack
      Used while computing transparency.
    • clipStack

      protected PStack clipStack
      Used to optimize clipping region.
    • localClipStack

      protected PStack localClipStack
      Tracks clipping region in local coordinate system.
    • cameraStack

      protected PStack cameraStack
      Stack of cameras through which the node being painted is being viewed.
    • transformStack

      protected PStack transformStack
      Stack of transforms being applied to the drawing context.
    • renderQuality

      protected int renderQuality
      The current render quality that all rendering should be done in.
  • Constructor Details

    • PPaintContext

      public PPaintContext(Graphics2D graphics)
      Creates a PPaintContext associated with the given graphics context.
      Parameters:
      graphics - graphics context to associate with this paint context
  • Method Details

    • getGraphics

      public Graphics2D getGraphics()
      Returns the graphics context associated with this paint context.
      Returns:
      graphics context associated with this paint context
    • getLocalClip

      public Rectangle2D 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

      public void pushCamera(PCamera aCamera)
      Pushes the camera onto the camera stack.
      Parameters:
      aCamera - camera to push onto the stack
    • popCamera

      public void popCamera(PCamera aCamera)
      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

      public PCamera 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

      public void pushClip(Shape clip)
      Pushes the given clip to the pain context.
      Parameters:
      clip - clip to be pushed
    • popClip

      public void popClip(Shape clip)
      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

      public void pushTransform(PAffineTransform transform)
      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

      public void popTransform(PAffineTransform transform)
      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