org.jdrawing
Class TransformingDrawingRenderer

java.lang.Object
  extended byorg.jdrawing.TransformingDrawingRenderer
All Implemented Interfaces:
DrawingElementRenderer, DrawingRenderer

public class TransformingDrawingRenderer
extends java.lang.Object
implements DrawingRenderer, DrawingElementRenderer

This implementation of DrawingElementRenderer allows user to apply affine transform to drawing. It actually does not render any elements but delegates rendering requests to another element renderer.


Constructor Summary
TransformingDrawingRenderer(java.awt.geom.AffineTransform transform, DrawingRenderer renderer)
          Returns a TransformingDrawingElementRenderer with given transform and renderer.
 
Method Summary
 boolean elementContains(java.lang.Object element, java.awt.geom.Point2D point)
          Tests if the given element contains the given point.
 boolean elementIntersects(java.lang.Object element, java.awt.geom.Rectangle2D rectangle)
          Tests if the given element intersects with the given rectangle.
 java.awt.Rectangle getElementBounds(java.lang.Object element)
          Gets the bounding box for the element.
 java.awt.geom.Rectangle2D getElementBounds2D(java.lang.Object element)
          Return the high precision bounding box of the element.
 DrawingElementRenderer getElementRenderer(java.lang.Object element)
          Gets DrawingElementRenderer to be used to render specified element.
 DrawingRenderer getRenderer()
          Gets the DrawingElementRenderer which is used by this renderer to delegate rendering requests to.
 java.awt.geom.AffineTransform getTransform()
          Gets the AffineTransform used by this transforming renderer.
 void paintDrawingElement(java.awt.Graphics graphics, java.lang.Object element)
          Paints the given element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformingDrawingRenderer

public TransformingDrawingRenderer(java.awt.geom.AffineTransform transform,
                                   DrawingRenderer renderer)
Returns a TransformingDrawingElementRenderer with given transform and renderer.

Parameters:
transform - an AffineTransform to be applied to drawing
renderer - a DrawingElementRenderer which all rendering requests will be delegated to
Method Detail

getTransform

public java.awt.geom.AffineTransform getTransform()
Gets the AffineTransform used by this transforming renderer.

Returns:
transform used by this renderer

getRenderer

public DrawingRenderer getRenderer()
Gets the DrawingElementRenderer which is used by this renderer to delegate rendering requests to.

Returns:
renderer used to delegate rendering requests

getElementRenderer

public DrawingElementRenderer getElementRenderer(java.lang.Object element)
Description copied from interface: DrawingRenderer
Gets DrawingElementRenderer to be used to render specified element.

Specified by:
getElementRenderer in interface DrawingRenderer
Parameters:
element - drawing element
Returns:
DrawingElementRenderer for the given element

paintDrawingElement

public void paintDrawingElement(java.awt.Graphics graphics,
                                java.lang.Object element)
Paints the given element.

Specified by:
paintDrawingElement in interface DrawingElementRenderer
Parameters:
graphics - graphics context to use for painting
element - element to be painted
Throws:
java.lang.IllegalArgumentException - if graphics is not instance of Graphics2D

getElementBounds

public java.awt.Rectangle getElementBounds(java.lang.Object element)
Description copied from interface: DrawingElementRenderer
Gets the bounding box for the element. If the element is unbounded then this method returns null.

Specified by:
getElementBounds in interface DrawingElementRenderer
Parameters:
element - element to be queried for bounding box
Returns:
bounding box of the element or null is the element is unbounded

getElementBounds2D

public java.awt.geom.Rectangle2D getElementBounds2D(java.lang.Object element)
Description copied from interface: DrawingElementRenderer
Return the high precision bounding box of the element. If the element is unbounded then this method returns null.

Specified by:
getElementBounds2D in interface DrawingElementRenderer
Parameters:
element - element to be queried for bounding box
Returns:
high precision bounding box of the element or null is the element is unbounded

elementIntersects

public boolean elementIntersects(java.lang.Object element,
                                 java.awt.geom.Rectangle2D rectangle)
Tests if the given element intersects with the given rectangle.

Specified by:
elementIntersects in interface DrawingElementRenderer
Parameters:
element - element to be checked for intersection
rectangle - rectangle to be checked for intersection
Returns:
true the given element intersects with the given rectangle; false otherwise
Throws:
java.lang.IllegalArgumentException - if rectangle is null

elementContains

public boolean elementContains(java.lang.Object element,
                               java.awt.geom.Point2D point)
Tests if the given element contains the given point.

Specified by:
elementContains in interface DrawingElementRenderer
Parameters:
element - element to be checked
point - point to be checked
Returns:
true the given element containes the given point; false otherwise
Throws:
java.lang.IllegalArgumentException - if point is null