nodebox.graphics
Class Canvas

java.lang.Object
  extended by nodebox.graphics.AbstractTransformable
      extended by nodebox.graphics.Canvas
All Implemented Interfaces:
Cloneable, Drawable, Grob

public class Canvas
extends AbstractTransformable


Field Summary
static double DEFAULT_HEIGHT
           
static double DEFAULT_WIDTH
           
 
Constructor Summary
Canvas()
           
Canvas(Canvas other)
           
Canvas(double width, double height)
           
 
Method Summary
 void add(Grob g)
           
 Geometry asGeometry()
          Convert the current canvas into a geometry object.
 Geometry asGeometry(boolean clone)
          Convert the current canvas into a geometry object.
 BufferedImage asImage()
           
 void clear()
           
 Canvas clone()
           
 void draw(Graphics2D g)
           
 boolean equals(Object obj)
           
 void extend(Canvas c)
          Create copies of all grobs of the given group and append them to myself.
 Grob get(int index)
           
 Color getBackground()
           
 Rect getBounds()
          Returns the bounding box of the canvas.
 double getHeight()
           
 List<Grob> getItems()
           
 double getOffsetX()
           
 double getOffsetY()
           
 double getWidth()
           
 void inheritFromContext(GraphicsContext ctx)
           
 boolean isEmpty()
           
 void save(File file)
           
 Color setBackground(Color background)
           
 void setHeight(double height)
           
 void setOffsetX(double offsetX)
           
 void setOffsetY(double offsetY)
           
 void setSize(double width, double height)
           
 void setWidth(double width)
           
 int size()
           
 String toString()
           
 void transform(Transform t)
           
 
Methods inherited from class nodebox.graphics.AbstractTransformable
getTransformDelegate, rotate, rotateRadians, scale, scale, setTransformDelegate, skew, skew, translate
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_WIDTH

public static final double DEFAULT_WIDTH
See Also:
Constant Field Values

DEFAULT_HEIGHT

public static final double DEFAULT_HEIGHT
See Also:
Constant Field Values
Constructor Detail

Canvas

public Canvas()

Canvas

public Canvas(double width,
              double height)

Canvas

public Canvas(Canvas other)
Method Detail

asGeometry

public Geometry asGeometry()
Convert the current canvas into a geometry object. Only objects of a geometric nature can be present in the output.

Returns:
a Geometry object

asGeometry

public Geometry asGeometry(boolean clone)
Convert the current canvas into a geometry object. Only objects of a geometric nature can be present in the output.

Parameters:
clone - if the items on the canvas need to be cloned.
Returns:
a Geometry object

getBackground

public Color getBackground()

setBackground

public Color setBackground(Color background)

getOffsetX

public double getOffsetX()

setOffsetX

public void setOffsetX(double offsetX)

getOffsetY

public double getOffsetY()

setOffsetY

public void setOffsetY(double offsetY)

getWidth

public double getWidth()

setWidth

public void setWidth(double width)

getHeight

public double getHeight()

setHeight

public void setHeight(double height)

setSize

public void setSize(double width,
                    double height)

add

public void add(Grob g)

size

public int size()

clear

public void clear()

getItems

public List<Grob> getItems()

get

public Grob get(int index)

extend

public void extend(Canvas c)
Create copies of all grobs of the given group and append them to myself.

Parameters:
c - the canvas whose elements are appended.

transform

public void transform(Transform t)

isEmpty

public boolean isEmpty()

getBounds

public Rect getBounds()
Returns the bounding box of the canvas.

This does not compute the bounding boxes of the children, but always returns the requested canvas bounds.

Returns:
a bounding box with x/y at the center and width/height of the canvas.

clone

public Canvas clone()
Specified by:
clone in interface Grob
Specified by:
clone in class AbstractTransformable

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

inheritFromContext

public void inheritFromContext(GraphicsContext ctx)

draw

public void draw(Graphics2D g)

asImage

public BufferedImage asImage()

save

public void save(File file)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.