com.sencha.gxt.chart.client.draw
Class Surface

java.lang.Object
  extended by com.sencha.gxt.chart.client.draw.Surface
Direct Known Subclasses:
SVG, VML

public abstract class Surface
extends Object

A Surface is an interface to render methods inside a draw DrawComponent. A Surface contains methods to render Sprites, get bounding boxes of sprites, add sprites to the canvas, initialize other graphic components, etc. One of the most used methods for this class is the add(Sprite...) method, to add sprites to the surface.


Constructor Summary
Surface()
           
 
Method Summary
 void add(Sprite... sprites)
          Adds a Sprite to the surface.
abstract  void addGradient(Gradient... gradients)
          Adds the passed Gradients to the surface.
static Surface create(DrawComponent component)
          Instantiates a surface instance via deferred binding.
static Surface create(DrawComponent component, int width, int height)
          Instantiates a surface instance via deferred binding.
 void draw()
          Renders the surface to the DOM as well as any sprites already added.
 PreciseRectangle getBBox(Sprite sprite)
          Calculates the bounding box of the given sprite.
 DrawComponent getComponent()
          Returns the draw component that the surface is attached.
 int getHeight()
          Returns the height of the surface.
 SpriteList<Sprite> getSprites()
          Returns the SpriteList containing all the sprites in the surface.
 XElement getSurfaceElement()
          Returns the element of the surface.
 int getWidth()
          Returns the width of the surface.
 void remove(Sprite sprite)
          Removes the given sprite from the surface.
abstract  void renderSprite(Sprite sprite)
          Renders the given sprite to the DOM.
 void setBackground(Color background)
          Set the background color of the surface.
abstract  void setCursor(Sprite sprite, String property)
          Sets the cursor property for the given sprite.
 void setHeight(int height)
          Sets the height of the surface.
abstract  void setViewBox(double x, double y, double width, double height)
          Sets the view box of the surface.
 void setWidth(int width)
          Sets the width of the surface.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Surface

public Surface()
Method Detail

create

public static Surface create(DrawComponent component)
Instantiates a surface instance via deferred binding. The default engine used is SVG. If the user agent is IE 6, 7, or 8 VML will be used.

Parameters:
component - the element that the surface will be attached
Returns:
the instantiated surface

create

public static Surface create(DrawComponent component,
                             int width,
                             int height)
Instantiates a surface instance via deferred binding. The default engine used is SVG. If the user agent is IE 6, 7, or 8 VML will be used.

Parameters:
component - the element that the surface will be attached
width - the width of the surface
height - the height of the surface
Returns:
the instantiated surface

add

public void add(Sprite... sprites)
Adds a Sprite to the surface. The sprite is not rendered to the DOM until draw() or Sprite.redraw() is called.

Parameters:
sprites - the sprites to be added

addGradient

public abstract void addGradient(Gradient... gradients)
Adds the passed Gradients to the surface.

Parameters:
gradients - the gradients to be added

draw

public void draw()
Renders the surface to the DOM as well as any sprites already added.


getBBox

public PreciseRectangle getBBox(Sprite sprite)
Calculates the bounding box of the given sprite.

Parameters:
sprite - the sprite to be used in the calculation
Returns:
bounding box of the sprite

getComponent

public DrawComponent getComponent()
Returns the draw component that the surface is attached.

Returns:
the draw component that the surface is attached

getHeight

public int getHeight()
Returns the height of the surface.

Returns:
the height of the surface

getSprites

public SpriteList<Sprite> getSprites()
Returns the SpriteList containing all the sprites in the surface.

Returns:
the SpriteList containing all the sprites in the surface

getSurfaceElement

public XElement getSurfaceElement()
Returns the element of the surface.

Returns:
the element of the surface

getWidth

public int getWidth()
Returns the width of the surface.

Returns:
the width of the surface

remove

public void remove(Sprite sprite)
Removes the given sprite from the surface.

Parameters:
sprite - the sprite to be removed

renderSprite

public abstract void renderSprite(Sprite sprite)
Renders the given sprite to the DOM.

Parameters:
sprite - the sprite to be rendered

setBackground

public void setBackground(Color background)
Set the background color of the surface.

Parameters:
background - the background color

setCursor

public abstract void setCursor(Sprite sprite,
                               String property)
Sets the cursor property for the given sprite.

Parameters:
sprite - the sprite to be set
property - the property to use

setHeight

public void setHeight(int height)
Sets the height of the surface.

Parameters:
height - the height of the surface.

setViewBox

public abstract void setViewBox(double x,
                                double y,
                                double width,
                                double height)
Sets the view box of the surface. The view box scales the sprites in the surface.

Parameters:
x - the x coordinate of the viewbox
y - the y coordinate of the viewbox
width - the width of the viewbox
height - the height of the viewbox

setWidth

public void setWidth(int width)
Sets the width of the surface.

Parameters:
width - the width of the surface.


Copyright © 2011. All Rights Reserved.