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.
-
CanvasGlyph(float, float)
- Create a canvas of the given size that can shrink to 0 and stretch
forever.
-
allocate(Allocation)
-
-
draw(Painter)
-
-
getAllocation()
- Get the allocation.
-
getScale()
- Get the scale factor.
-
requirements()
- Ask for the glyph's geometry requirements.
-
setScale(float)
- Set the scale factor.
-
setXOffset(float)
- Set the horizontal offset of the canvas.
-
setYOffset(float)
- Set the vertical offset of the canvas.
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.
requirements
public Requirements requirements()
- Ask for the glyph's geometry requirements.
- Overrides:
- requirements in class GlyphImpl
allocate
public void allocate(Allocation allocation)
- Overrides:
- allocate in class GlyphImpl
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.)
getScale
public float getScale()
- Get the scale factor.
- Returns:
- the scale factor.
setScale
public void setScale(float scale)
- Set the scale factor.
- Parameters:
- the - scale factor.
setXOffset
public void setXOffset(float offset)
- Set the horizontal offset of the canvas. The offset is not scaled.
- Parameters:
- offset - the offset.
setYOffset
public void setYOffset(float offset)
- Set the vertical offset of the canvas. The offset is not scaled.
- Parameters:
- offset - the offset.
draw
public void draw(Painter painter)
- Overrides:
- draw in class PolyGlyph
All Packages Class Hierarchy This Package Previous Next Index