Class sgraphics.CanvasGlyph
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sgraphics.CanvasGlyph

java.lang.Object
   |
   +----sgraphics.GlyphImpl
           |
           +----sgraphics.PolyGlyph
                   |
                   +----sgraphics.CanvasGlyph

public class CanvasGlyph
extends PolyGlyph
A canvas. The canvas calls allocate (Allocation) on each child with the x and y positions equal to the canvas offset. The child should draw itself relative to that offset.

The requirements and the allocation given to each child will be scaled according to the scale factor. A child glyph should scale its x and y position by the amount that its size is scaled. This behavior on the part of the children will allow the canvas to scroll and zoom.

Layout glyphs will generally try to draw themselves at (0,0), relative to their allocation. Therefore, for a canvas to be useful, one should create a figure or composite figure that can manage the scaling.


Constructor Index

 o CanvasGlyph(float, float)
Create a canvas of the given size that can shrink to 0 and stretch forever.

Method Index

 o allocate(Allocation)
 o draw(Painter)
 o getAllocation()
Get the allocation.
 o getScale()
Get the scale factor.
 o requirements()
Ask for the glyph's geometry requirements.
 o setScale(float)
Set the scale factor.
 o setXOffset(float)
Set the horizontal offset of the canvas.
 o setYOffset(float)
Set the vertical offset of the canvas.

Constructors

 o CanvasGlyph
  public CanvasGlyph(float naturalWidth,
                     float naturalHeight)
Create a canvas of the given size that can shrink to 0 and stretch forever.
Parameters:
naturalWidth - the preferred width of the canvas.
naturalHeight - the preferred height of the canvas.

Methods

 o requirements
  public Requirements requirements()
Ask for the glyph's geometry requirements.
Overrides:
requirements in class GlyphImpl
 o allocate
  public void allocate(Allocation allocation)
Overrides:
allocate in class GlyphImpl
 o getAllocation
  public Allocation getAllocation()
Get the allocation. This used by the children of CanvasGlyph so it can know the legal drawing area. (Nor for normal use.)
 o getScale
  public float getScale()
Get the scale factor.
Returns:
the scale factor.
 o setScale
  public void setScale(float scale)
Set the scale factor.
Parameters:
the - scale factor.
 o setXOffset
  public void setXOffset(float offset)
Set the horizontal offset of the canvas. The offset is not scaled.
Parameters:
offset - the offset.
 o setYOffset
  public void setYOffset(float offset)
Set the vertical offset of the canvas. The offset is not scaled.
Parameters:
offset - the offset.
 o draw
  public void draw(Painter painter)
Overrides:
draw in class PolyGlyph

All Packages  Class Hierarchy  This Package  Previous  Next  Index