org.jdrawing.graphics
Class DrawLine

java.lang.Object
  extended byorg.jdrawing.graphics.GraphicsOperation
      extended byorg.jdrawing.graphics.DrawLine
All Implemented Interfaces:
DrawingElement

public class DrawLine
extends GraphicsOperation

Graphics element which corresponds to Graphics.drawLine(int, int, int, int)


Constructor Summary
DrawLine(int x1, int y1, int x2, int y2)
          Returns DrawLine for line starting at (x1, y1) and ending at (x2, y2).
DrawLine(int x1, int y1, int x2, int y2, Style style)
          Returns DrawLine for line starting at (x1, y1) and ending at (x2, y2).
 
Method Summary
 boolean equals(java.lang.Object object)
          Checks whether two draw line operations are equal.
 java.awt.Rectangle getBounds()
          Returns bounding box of the element.
 java.awt.geom.Rectangle2D getBounds2D()
          Returns high precision bounding box of the element.
 java.awt.Shape getShapeOfOperation()
          Returns shape of the area updated by this operation.
 int getX1()
          Returns X coordinate of start point of the line.
 int getX2()
          Returns X coordinate of end point of the line.
 int getY1()
          Returns Y coordinate of start point of the line.
 int getY2()
          Returns Y coordinate of end point of the line.
 int hashCode()
          Returns the hashcode for this draw line operation.
 boolean intersects(java.awt.geom.Rectangle2D rectangle)
          Tests if the element intersects with the given rectangle.
 void paintOperation(java.awt.Graphics2D graphics)
          Performs drawing operation.
 void setBegin(int x, int y)
          Sets begin point for this line.
 void setEnd(int x, int y)
          Sets end point for this line.
 void setLine(int x1, int y1, int x2, int y2)
          Sets begin and end points for this line.
 void setX1(int x1)
          Sets X coordinate of start point of the line.
 void setX2(int x2)
          Sets X coordinate of end point of the line.
 void setY1(int y1)
          Sets Y coordinate of start point of the line.
 void setY2(int y2)
          Sets Y coordinate of end point of the line.
 
Methods inherited from class org.jdrawing.graphics.GraphicsOperation
contains, getPosition, getStyle, paint, setPosition, setStyle
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DrawLine

public DrawLine(int x1,
                int y1,
                int x2,
                int y2)
Returns DrawLine for line starting at (x1, y1) and ending at (x2, y2).


DrawLine

public DrawLine(int x1,
                int y1,
                int x2,
                int y2,
                Style style)
Returns DrawLine for line starting at (x1, y1) and ending at (x2, y2).

Method Detail

setX1

public void setX1(int x1)
Sets X coordinate of start point of the line.

Parameters:
x1 - the x coordinate

getX1

public int getX1()
Returns X coordinate of start point of the line.

Returns:
the x coordinate

setX2

public void setX2(int x2)
Sets X coordinate of end point of the line.

Parameters:
x2 - the x coordinate

getX2

public int getX2()
Returns X coordinate of end point of the line.

Returns:
the x coordinate

setY1

public void setY1(int y1)
Sets Y coordinate of start point of the line.

Parameters:
y1 - the y coordinate

getY1

public int getY1()
Returns Y coordinate of start point of the line.

Returns:
the y coordinate

setY2

public void setY2(int y2)
Sets Y coordinate of end point of the line.

Parameters:
y2 - the y coordinate

getY2

public int getY2()
Returns Y coordinate of end point of the line.

Returns:
the y coordinate

setBegin

public void setBegin(int x,
                     int y)
Sets begin point for this line.

Parameters:
x - the x coordinate of the begin point
y - the y coordinate of the begin point

setEnd

public void setEnd(int x,
                   int y)
Sets end point for this line.

Parameters:
x - the x coordinate of the end point
y - the y coordinate of the end point

setLine

public void setLine(int x1,
                    int y1,
                    int x2,
                    int y2)
Sets begin and end points for this line.

Parameters:
x1 - the x coordinate of the begin point
y1 - the y coordinate of the begin point
x2 - the x coordinate of the end point
y2 - the y coordinate of the end point

paintOperation

public void paintOperation(java.awt.Graphics2D graphics)
Performs drawing operation. This implementation invokes graphics.drawLine ().

Specified by:
paintOperation in class GraphicsOperation
Parameters:
graphics - graphics context to use for painting

getBounds

public java.awt.Rectangle getBounds()
Returns bounding box of the element. If the element is unbounded then this method returns null.

Specified by:
getBounds in interface DrawingElement
Overrides:
getBounds in class GraphicsOperation
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.

Specified by:
getBounds2D in interface DrawingElement
Overrides:
getBounds2D in class GraphicsOperation
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.

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

getShapeOfOperation

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

Specified by:
getShapeOfOperation in class GraphicsOperation
Returns:
the shape of updated area

equals

public boolean equals(java.lang.Object object)
Checks whether two draw line operations are equal. The result is true if and only if the argument is not null and is a DrawLine object that has the same attributes as this DrawLine.

Overrides:
equals in class GraphicsOperation
Parameters:
object - the Object to compare with this DrawLine
Returns:
true if the objects are equal; false otherwise.

hashCode

public int hashCode()
Returns the hashcode for this draw line operation.

Overrides:
hashCode in class GraphicsOperation
Returns:
a hash code for this draw line operation.