Package snap.gfx

Class Painter

java.lang.Object
snap.gfx.Painter
Direct Known Subclasses:
J2DPainter, PainterImpl, PainterProxy

public abstract class Painter extends Object
A base class for painting Shapes, Text and Images.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
    static class 
    A class that provide extra painter properties.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clearRect(double aX, double aY, double aW, double aH)
    Clears a rect.
    abstract void
    Clip by shape.
    void
    clipRect(double aX, double aY, double aW, double aH)
    Clip to rect.
    abstract void
    draw(Shape aShape)
    Stroke the given shape.
    void
    drawButton(double x, double y, double w, double h, boolean isPressed)
    Draws a button for the given rect with an option for pressed.
    void
    drawButton(Rect aRect, boolean isPressed)
    Draws a button for the given rect with an option for pressed.
    void
    drawImage(Image anImage, double aX, double aY)
    Draw image in rect.
    void
    drawImage(Image anImage, double aX, double aY, double aWidth, double aHeight)
    Draw image in rect.
    abstract void
    drawImage(Image anImage, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh)
    Draw image in rect.
    void
    drawImage(Image anImage, Transform xform)
    Draw image with transform.
    void
    drawLine(double x1, double y1, double x2, double y2)
    Draw the given line.
    void
    drawLineWithPaint(double x1, double y1, double x2, double y2, Paint aPaint)
    Draw the given line.
    void
    drawRect(double x, double y, double w, double h)
    Draw the given rect.
    void
    drawRectWithPaint(double aX, double aY, double aW, double aH, Paint aPaint)
    Draw given rect with given paint.
    void
    drawString(String aStr, double aX, double aY)
    Draw string at location.
    void
    drawString(String aStr, double aX, double aY, double aCSpace)
    Draw string at location with char spacing.
    void
    drawWithPaint(Shape aShape, Paint aPaint)
    Convenience to stroke given shape with given paint.
    abstract void
    fill(Shape aShape)
    Fill the given shape.
    void
    fill3DRect(double x, double y, double w, double h, boolean raised)
    Paints a 3D rect.
    void
    fillRect(double x, double y, double w, double h)
    Fill the given rect.
    void
    fillRectWithPaint(double aX, double aY, double aW, double aH, Paint aPaint)
    Fill given rect with given paint.
    void
    fillWithPaint(Shape aShape, Paint aPaint)
    Convenience to fill given shape with given paint.
    void
    Flush any buffered paint operations.
    abstract Shape
    Return clip shape.
    Return clip bounds.
    Returns the current color.
    Returns the composite mode.
    abstract Font
    Returns the current font.
    double
    Returns image rendering quality.
    Return native helper for painter, if available.
    <T> T
    getNative(Class<T> aClass)
    Return native helper for painter as given class, if available.
    abstract double
    Returns the opacity.
    abstract Paint
    Returns the current paint.
    Returns the object that provides extra painter properties.
    abstract Stroke
    Returns the current stroke.
    abstract Transform
    Return transform.
    boolean
    Returns whether painting is for static output.
    boolean
    Returns whether stroked path is used as is (otherwise, points might be rounded).
    abstract void
    Restores the graphics state.
    void
    rotate(double theDegrees)
    Rotate by angle in degrees.
    void
    rotateAround(double theDegrees, double aX, double aY)
    Rotate by angle in degrees.
    abstract void
    Saves the graphics state.
    void
    scale(double sx, double sy)
    Scale by sx, sy.
    boolean
    setAntialiasing(boolean aValue)
    Sets whether antialiasing.
    void
    setColor(Color aColor)
    Sets the current color.
    void
    Sets the composite mode.
    abstract void
    setFont(Font font)
    Sets the current font.
    void
    setImageQuality(double aValue)
    Sets image rendering quality.
    abstract void
    setOpacity(double aValue)
    Sets the opacity.
    abstract void
    setPaint(Paint paint)
    Sets the current paint.
    void
    setPrinting(boolean aValue)
    Sets whether shape painting is for static output.
    void
    Sets the object that provides extra painter properties.
    abstract void
    Sets the current stroke.
    void
    setStrokePure(boolean aValue)
    Sets whether stroked path is used as is (otherwise, points might be rounded).
    void
    setStrokeWidth(double aWidth)
    Sets the current stroke.
    void
    setTransform(double a, double b, double c, double d, double tx, double ty)
    Transform by transform.
    abstract void
    Set to transform.
    Standard toString implementation.
    void
    transform(double a, double b, double c, double d, double tx, double ty)
    Transform by transform.
    abstract void
    Transform by transform.
    void
    translate(double tx, double ty)
    Translate by x,y.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Painter

      public Painter()
  • Method Details

    • getColor

      public Color getColor()
      Returns the current color.
    • setColor

      public void setColor(Color aColor)
      Sets the current color.
    • getFont

      public abstract Font getFont()
      Returns the current font.
    • setFont

      public abstract void setFont(Font font)
      Sets the current font.
    • getPaint

      public abstract Paint getPaint()
      Returns the current paint.
    • setPaint

      public abstract void setPaint(Paint paint)
      Sets the current paint.
    • getStroke

      public abstract Stroke getStroke()
      Returns the current stroke.
    • setStroke

      public abstract void setStroke(Stroke s)
      Sets the current stroke.
    • setStrokeWidth

      public void setStrokeWidth(double aWidth)
      Sets the current stroke.
    • getOpacity

      public abstract double getOpacity()
      Returns the opacity.
    • setOpacity

      public abstract void setOpacity(double aValue)
      Sets the opacity.
    • clearRect

      public void clearRect(double aX, double aY, double aW, double aH)
      Clears a rect.
    • draw

      public abstract void draw(Shape aShape)
      Stroke the given shape.
    • fill

      public abstract void fill(Shape aShape)
      Fill the given shape.
    • drawLine

      public void drawLine(double x1, double y1, double x2, double y2)
      Draw the given line.
    • fillRect

      public void fillRect(double x, double y, double w, double h)
      Fill the given rect.
    • drawRect

      public void drawRect(double x, double y, double w, double h)
      Draw the given rect.
    • drawWithPaint

      public void drawWithPaint(Shape aShape, Paint aPaint)
      Convenience to stroke given shape with given paint.
    • fillWithPaint

      public void fillWithPaint(Shape aShape, Paint aPaint)
      Convenience to fill given shape with given paint.
    • drawLineWithPaint

      public void drawLineWithPaint(double x1, double y1, double x2, double y2, Paint aPaint)
      Draw the given line.
    • drawRectWithPaint

      public void drawRectWithPaint(double aX, double aY, double aW, double aH, Paint aPaint)
      Draw given rect with given paint.
    • fillRectWithPaint

      public void fillRectWithPaint(double aX, double aY, double aW, double aH, Paint aPaint)
      Fill given rect with given paint.
    • drawImage

      public void drawImage(Image anImage, Transform xform)
      Draw image with transform.
    • drawImage

      public void drawImage(Image anImage, double aX, double aY)
      Draw image in rect.
    • drawImage

      public void drawImage(Image anImage, double aX, double aY, double aWidth, double aHeight)
      Draw image in rect.
    • drawImage

      public abstract void drawImage(Image anImage, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh)
      Draw image in rect.
    • drawString

      public void drawString(String aStr, double aX, double aY)
      Draw string at location.
    • drawString

      public void drawString(String aStr, double aX, double aY, double aCSpace)
      Draw string at location with char spacing.
    • translate

      public void translate(double tx, double ty)
      Translate by x,y.
    • rotate

      public void rotate(double theDegrees)
      Rotate by angle in degrees.
    • rotateAround

      public void rotateAround(double theDegrees, double aX, double aY)
      Rotate by angle in degrees.
    • scale

      public void scale(double sx, double sy)
      Scale by sx, sy.
    • getTransform

      public abstract Transform getTransform()
      Return transform.
    • setTransform

      public abstract void setTransform(Transform aTrans)
      Set to transform.
    • setTransform

      public void setTransform(double a, double b, double c, double d, double tx, double ty)
      Transform by transform.
    • transform

      public abstract void transform(Transform aTrans)
      Transform by transform.
    • transform

      public void transform(double a, double b, double c, double d, double tx, double ty)
      Transform by transform.
    • getClip

      public abstract Shape getClip()
      Return clip shape.
    • getClipBounds

      public Rect getClipBounds()
      Return clip bounds.
    • clip

      public abstract void clip(Shape s)
      Clip by shape.
    • clipRect

      public void clipRect(double aX, double aY, double aW, double aH)
      Clip to rect.
    • getComposite

      public Painter.Composite getComposite()
      Returns the composite mode.
    • setComposite

      public void setComposite(Painter.Composite aComp)
      Sets the composite mode.
    • setAntialiasing

      public boolean setAntialiasing(boolean aValue)
      Sets whether antialiasing.
    • getImageQuality

      public double getImageQuality()
      Returns image rendering quality.
    • setImageQuality

      public void setImageQuality(double aValue)
      Sets image rendering quality.
    • isStrokePure

      public boolean isStrokePure()
      Returns whether stroked path is used as is (otherwise, points might be rounded).
    • setStrokePure

      public void setStrokePure(boolean aValue)
      Sets whether stroked path is used as is (otherwise, points might be rounded).
    • isPrinting

      public boolean isPrinting()
      Returns whether painting is for static output.
    • setPrinting

      public void setPrinting(boolean aValue)
      Sets whether shape painting is for static output.
    • getProps

      public Painter.Props getProps()
      Returns the object that provides extra painter properties.
    • setProps

      public void setProps(Painter.Props theProps)
      Sets the object that provides extra painter properties.
    • save

      public abstract void save()
      Saves the graphics state.
    • restore

      public abstract void restore()
      Restores the graphics state.
    • flush

      public void flush()
      Flush any buffered paint operations.
    • fill3DRect

      public void fill3DRect(double x, double y, double w, double h, boolean raised)
      Paints a 3D rect.
    • drawButton

      public void drawButton(Rect aRect, boolean isPressed)
      Draws a button for the given rect with an option for pressed.
    • drawButton

      public void drawButton(double x, double y, double w, double h, boolean isPressed)
      Draws a button for the given rect with an option for pressed.
    • getNative

      public Object getNative()
      Return native helper for painter, if available.
    • getNative

      public <T> T getNative(Class<T> aClass)
      Return native helper for painter as given class, if available.
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class Object