jcckit.renderer
Class GraphicsRenderer

java.lang.Object
  extended byjcckit.renderer.GraphicsRenderer
All Implemented Interfaces:
GraphicalCompositeRenderer, OvalRenderer, PolygonRenderer, RectangleRenderer, Renderer, TextRenderer

public class GraphicsRenderer
extends java.lang.Object
implements GraphicalCompositeRenderer, PolygonRenderer, OvalRenderer, TextRenderer, RectangleRenderer

Renderer who draws the GraphicalElements into a java.awt.Graphics context.

The default color for lines and texts is determined by the current color of the Graphics context when a new instance of GraphicsRenderer is created.

The default font is SansSerif-12.

Author:
Franz-Josef Elmer

Constructor Summary
GraphicsRenderer()
           
 
Method Summary
 void finishRendering(GraphicalComposite composite)
          Finishes rendering of the specified composite.
 GraphicsRenderer init(java.awt.Graphics graphics, java.awt.Component component, Transformation transformation)
          Initializes this instance.
 void render(Oval oval)
          Paints the specified oval into the current Graphics context.
 void render(Polygon polygon)
          Paints the specified polygon into the current Graphics context.
 void render(Rectangle rectangle)
          Paints the specified rectangle into the current Graphics context.
 void render(Text text)
          Paints the specified text into the current Graphics context.
 void startRendering(GraphicalComposite composite)
          Starts rendering of the specified composite.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphicsRenderer

public GraphicsRenderer()
Method Detail

init

public GraphicsRenderer init(java.awt.Graphics graphics,
                             java.awt.Component component,
                             Transformation transformation)
Initializes this instance.

Parameters:
graphics - Graphics context into which the BaiscGraphicalElements are painted.
component - A component needed for creating off-screen images of rotated texts.
transformation - Transformation from the device-independent coordinates into pixel-based Java coordinates.
Returns:
this instance.

startRendering

public void startRendering(GraphicalComposite composite)
Starts rendering of the specified composite. Does nothing except if composite has a ClippingShape. In this case the current Graphics context will be pushed onto a stack. The new Graphics context is a clone of the current one where the clipping rectangle is determined by the bounding box of ClippingShape.

Specified by:
startRendering in interface GraphicalCompositeRenderer

finishRendering

public void finishRendering(GraphicalComposite composite)
Finishes rendering of the specified composite. Does nothing except if composite has a ClippingShape. In this case the Graphics context will be poped from the stack and will replace the current one.

Specified by:
finishRendering in interface GraphicalCompositeRenderer

render

public void render(Polygon polygon)
Paints the specified polygon into the current Graphics context.

Specified by:
render in interface PolygonRenderer

render

public void render(Rectangle rectangle)
Paints the specified rectangle into the current Graphics context.

Specified by:
render in interface RectangleRenderer

render

public void render(Oval oval)
Paints the specified oval into the current Graphics context.

Specified by:
render in interface OvalRenderer

render

public void render(Text text)
Paints the specified text into the current Graphics context.

If the font size is zero the default font size will be used.

If the orientation angle is unequal zero the text will first be painted into an off-screen image and rotated. Finally, it will be drawn into the current Graphics context. Note, that only integer multiples of 90 degree rotation are performed. Other orientation angles will be adjusted to the nearest integer multiple of 90 degree.

Specified by:
render in interface TextRenderer