org.jdrawing.graphics
Class GraphicsOperation

java.lang.Object
  extended byorg.jdrawing.graphics.GraphicsOperation
All Implemented Interfaces:
DrawingElement
Direct Known Subclasses:
DrawImage, DrawLine, DrawString, PolygonOperation, RectangleOperation, ShapeOperation

public abstract class GraphicsOperation
extends java.lang.Object
implements DrawingElement

This is the base class for all elements, representing drawing operations.


Constructor Summary
GraphicsOperation()
          Constructs GraphicsOperation with default style.
GraphicsOperation(Style style)
          Constructs GraphicsOperation with given style.
 
Method Summary
 boolean contains(java.awt.geom.Point2D point)
          Tests if the element contains a given point.
 java.awt.Rectangle getBounds()
          Returns bounding box of the element.
 java.awt.geom.Rectangle2D getBounds2D()
          Returns high precision bounding box of the element.
 int getPosition()
          Returns the position of this operation in the painting sequence of the model.
abstract  java.awt.Shape getShapeOfOperation()
          Returns shape of the area updated by this operation.
 Style getStyle()
          Gets Style object encapsulating style attibutes of this operation.
 boolean intersects(java.awt.geom.Rectangle2D rectangle)
          Tests if the element intersects with the given rectangle.
 void paint(java.awt.Graphics graphics)
          Paint the element.
abstract  void paintOperation(java.awt.Graphics2D graphics)
          Performs drawing operation.
 void setPosition(int position)
          Stores the position of this operation in the painting sequence of the model.
 void setStyle(Style style)
          Sets Style object encapsulating style attibutes of this operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphicsOperation

public GraphicsOperation()
Constructs GraphicsOperation with default style.


GraphicsOperation

public GraphicsOperation(Style style)
Constructs GraphicsOperation with given style.

Parameters:
style - the style for this graphics operation
Method Detail

setPosition

public void setPosition(int position)
Stores the position of this operation in the painting sequence of the model. Do not call this method directly.

Parameters:
position - new position value

getPosition

public int getPosition()
Returns the position of this operation in the painting sequence of the model. Do not call this method directly.

Returns:
position value

setStyle

public void setStyle(Style style)
Sets Style object encapsulating style attibutes of this operation.

Parameters:
style - the Style object

getStyle

public Style getStyle()
Gets Style object encapsulating style attibutes of this operation.

Returns:
the Style object

paint

public void paint(java.awt.Graphics graphics)
Paint the element. This implementation applies all styles and then calls paintOperation(java.awt.Graphics2D).

Specified by:
paint in interface DrawingElement
Parameters:
graphics - graphics context to use for painting

paintOperation

public abstract void paintOperation(java.awt.Graphics2D graphics)
Performs drawing operation.

Parameters:
graphics - graphics context to use for painting

getShapeOfOperation

public abstract java.awt.Shape getShapeOfOperation()
Returns shape of the area updated by this operation.

Returns:
the shape of updated area

getBounds

public java.awt.Rectangle getBounds()
Returns bounding box of the element. If the element is unbounded then this method returns null. This implementation returns bounding box of the shape returned by getShapeOfOperation().

Specified by:
getBounds in interface DrawingElement
Returns:
bounding box of the element or null is the element is unbounded

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Returns high precision bounding box of the element. If the element is unbounded then this method returns null. This implementation returns bounding box of the shape returned by getShapeOfOperation().

Specified by:
getBounds2D in interface DrawingElement
Returns:
high precision bounding box of the element or null if the element is unbounded

intersects

public boolean intersects(java.awt.geom.Rectangle2D rectangle)
Tests if the element intersects with the given rectangle. This implementation queries the shape returned by getShapeOfOperation() for intersection.

Specified by:
intersects in interface DrawingElement
Parameters:
rectangle - rectangle to be checked for intersection
Returns:
true if the element intersects with the given rectangle; false otherwase

contains

public boolean contains(java.awt.geom.Point2D point)
Tests if the element contains a given point. This implementation queries the shape returned by getShapeOfOperation() if it contains given point.

Specified by:
contains in interface DrawingElement
Parameters:
point - to be checked
Returns:
true if the element contains given point; false otherwise