nodebox.graphics
Class CanvasContext

java.lang.Object
  extended by nodebox.graphics.AbstractGraphicsContext
      extended by nodebox.graphics.CanvasContext
All Implemented Interfaces:
GraphicsContext

public class CanvasContext
extends AbstractGraphicsContext


Nested Class Summary
static class CanvasContext.ImageMode
           
 
Nested classes/interfaces inherited from interface nodebox.graphics.GraphicsContext
GraphicsContext.ArrowType, GraphicsContext.EllipseMode, GraphicsContext.RectMode, GraphicsContext.VarType
 
Field Summary
static double DEFAULT_HEIGHT
           
static double DEFAULT_WIDTH
           
protected  CanvasContext.ImageMode imageMode
           
 
Fields inherited from class nodebox.graphics.AbstractGraphicsContext
align, autoClosePath, colorMode, colorRange, ellipseMode, fillColor, fontName, fontSize, lineHeight, path, pathClosed, rectMode, strokeColor, strokeWidth, transform, transformMode, transformStack
 
Fields inherited from interface nodebox.graphics.GraphicsContext
BOOLEAN, CENTER, cm, CMYK, CORNER, CORNERS, FONT, FORTYFIVE, HSB, inch, JUSTIFY, LEFT, mm, NORMAL, NUMBER, RADIUS, RGB, RIGHT, TEXT
 
Constructor Summary
CanvasContext()
           
CanvasContext(Canvas canvas)
           
 
Method Summary
protected  void addImage(Image i)
           
protected  void addPath(Path p)
           
protected  void addText(Text t)
           
 Color background()
          Get the current background color.
 Color background(Color c)
          Set the current background color to the given color.
 Color background(double x)
          Set the current background color to given grayscale value.
 Color background(double x, double y)
          Set the current background color to given grayscale and alpha value.
 Color background(double x, double y, double z)
          Set the current background color to the given R/G/B value.
 Color background(double x, double y, double z, double a)
          Set the current background color to the given R/G/B/A value.
 void draw(Grob grob)
          The draw method doesn't actually draw anything, but rather appends grobs to the canvas.
 Canvas getCanvas()
           
 double getHeight()
           
 double getHEIGHT()
           
 double getWidth()
           
 double getWIDTH()
           
 Image image(BufferedImage img, double x, double y, double width, double height, double alpha, boolean draw)
           
 Image image(Image img, double x, double y, double width, double height, double alpha, boolean draw)
           
 Image image(String path, double x, double y)
           
 Image image(String path, double x, double y, double width)
           
 Image image(String path, double x, double y, double width, double height)
           
 Image image(String path, double x, double y, double width, double height, boolean draw)
           
 Image image(String path, double x, double y, double width, double height, double alpha)
           
 Image image(String path, double x, double y, double width, double height, double alpha, boolean draw)
           
 CanvasContext.ImageMode imagemode()
           
 CanvasContext.ImageMode imagemode(CanvasContext.ImageMode m)
           
 Size imagesize(BufferedImage img)
           
 Size imagesize(Image img)
           
 Size imagesize(String path)
           
protected  void inheritFromContext(Image i)
           
 void nobackground()
           
 void resetContext()
           
 void resetContext(boolean resetBackground)
           
 void size(double width, double height)
           
 
Methods inherited from class nodebox.graphics.AbstractGraphicsContext
align, align, align, align, arrow, arrow, arrow, arrow, arrow, arrow, arrow, arrow, arrow, arrow, arrow, arrow, autoclosepath, autoclosepath, beginclip, beginpath, beginpath, BezierPath, choice, closepath, color, color, color, color, color, color, colormode, colormode, colormode, colormode, colormode, colormode, colormode, colorrange, colorrange, curveto, drawpath, drawpath, ellipse, ellipse, ellipsemode, ellipsemode, ellipsemode, ellipsemode, endclip, endpath, endpath, fill, fill, fill, fill, fill, fill, findpath, findpath, findVar, font, font, font, fontsize, fontsize, grid, grid, grid, grid, inheritFromContext, inheritFromContext, line, line, lineheight, lineheight, lineto, moveto, nofill, normalize, nostroke, outputmode, outputmode, oval, oval, Path, pop, push, random, random, random, random, random, rect, rect, rect, rect, rect, rect, rect, rect, rect, rect, rectmode, rectmode, rectmode, rectmode, reset, rotate, scale, scale, skew, skew, star, star, star, star, star, stroke, stroke, stroke, stroke, stroke, stroke, strokewidth, strokewidth, text, text, text, text, textheight, textheight, textmetrics, textmetrics, textmetrics, textpath, textpath, textpath, textwidth, textwidth, transform, transform, transform, transform, translate, var, var, var, var, var, var, var, var, var
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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

imageMode

protected CanvasContext.ImageMode imageMode
Constructor Detail

CanvasContext

public CanvasContext()

CanvasContext

public CanvasContext(Canvas canvas)
Method Detail

resetContext

public void resetContext()
Overrides:
resetContext in class AbstractGraphicsContext

resetContext

public void resetContext(boolean resetBackground)

imagemode

public CanvasContext.ImageMode imagemode()

imagemode

public CanvasContext.ImageMode imagemode(CanvasContext.ImageMode m)

size

public void size(double width,
                 double height)

getWidth

public double getWidth()

getHeight

public double getHeight()

getWIDTH

public double getWIDTH()

getHEIGHT

public double getHEIGHT()

background

public Color background()
Get the current background color.

Returns:
the current background color.

background

public Color background(double x)
Set the current background color to given grayscale value.

Parameters:
x - the gray component.
Returns:
the current background color.

background

public Color background(double x,
                        double y)
Set the current background color to given grayscale and alpha value.

Parameters:
x - the grayscale value.
y - the alpha value.
Returns:
the current background color.

background

public Color background(double x,
                        double y,
                        double z)
Set the current background color to the given R/G/B value.

Parameters:
x - the red component.
y - the green component.
z - the blue component.
Returns:
the current background color.

background

public Color background(double x,
                        double y,
                        double z,
                        double a)
Set the current background color to the given R/G/B/A value.

Parameters:
x - the red component.
y - the green component.
z - the blue component.
a - the alpha component.
Returns:
the current background color.

background

public Color background(Color c)
Set the current background color to the given color.

The color object is cloned; you can change the original afterwards. If the color object is null, the current background color is turned off (same as nobackground).

Parameters:
c - the color object.
Returns:
the current background color.

nobackground

public void nobackground()

getCanvas

public Canvas getCanvas()

image

public Image image(String path,
                   double x,
                   double y)
Specified by:
image in interface GraphicsContext
Overrides:
image in class AbstractGraphicsContext

image

public Image image(String path,
                   double x,
                   double y,
                   double width)
Specified by:
image in interface GraphicsContext
Overrides:
image in class AbstractGraphicsContext

image

public Image image(String path,
                   double x,
                   double y,
                   double width,
                   double height)
Specified by:
image in interface GraphicsContext
Overrides:
image in class AbstractGraphicsContext

image

public Image image(String path,
                   double x,
                   double y,
                   double width,
                   double height,
                   double alpha)
Specified by:
image in interface GraphicsContext
Overrides:
image in class AbstractGraphicsContext

image

public Image image(String path,
                   double x,
                   double y,
                   double width,
                   double height,
                   boolean draw)
Specified by:
image in interface GraphicsContext
Overrides:
image in class AbstractGraphicsContext

image

public Image image(String path,
                   double x,
                   double y,
                   double width,
                   double height,
                   double alpha,
                   boolean draw)
Specified by:
image in interface GraphicsContext
Overrides:
image in class AbstractGraphicsContext

image

public Image image(Image img,
                   double x,
                   double y,
                   double width,
                   double height,
                   double alpha,
                   boolean draw)
Specified by:
image in interface GraphicsContext
Overrides:
image in class AbstractGraphicsContext

image

public Image image(BufferedImage img,
                   double x,
                   double y,
                   double width,
                   double height,
                   double alpha,
                   boolean draw)
Specified by:
image in interface GraphicsContext
Overrides:
image in class AbstractGraphicsContext

imagesize

public Size imagesize(String path)
Specified by:
imagesize in interface GraphicsContext
Overrides:
imagesize in class AbstractGraphicsContext

imagesize

public Size imagesize(Image img)
Specified by:
imagesize in interface GraphicsContext
Overrides:
imagesize in class AbstractGraphicsContext

imagesize

public Size imagesize(BufferedImage img)
Specified by:
imagesize in interface GraphicsContext
Overrides:
imagesize in class AbstractGraphicsContext

draw

public void draw(Grob grob)
The draw method doesn't actually draw anything, but rather appends grobs to the canvas. When the canvas gets drawn, this grob will be drawn also.

Specified by:
draw in interface GraphicsContext
Overrides:
draw in class AbstractGraphicsContext
Parameters:
grob - the grob to append to the canvas

addPath

protected void addPath(Path p)
Specified by:
addPath in class AbstractGraphicsContext

addText

protected void addText(Text t)
Specified by:
addText in class AbstractGraphicsContext

addImage

protected void addImage(Image i)

inheritFromContext

protected void inheritFromContext(Image i)


Copyright © 2013. All Rights Reserved.