org.jdrawing.graphics
Class DrawLine

java.lang.Object
  extended byorg.jdrawing.graphics.GraphicsElement
      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)


Field Summary
 
Fields inherited from class org.jdrawing.graphics.GraphicsElement
BACKGROUND, COLOR, COMPOSITE, FONT, PAINT, parent, position, STROKE, TRANSFORM
 
Constructor Summary
DrawLine(int x1, int x2, int y1, int y2)
          Returns DrawLine for line starting at (x1, y1) and ending at (x2, y2).
 
Method Summary
 boolean contains(java.awt.geom.Point2D point)
          Tests if the element containes 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 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.
 boolean intersects(java.awt.geom.Rectangle2D rectangle)
          Tests if the element intersects with the given rectangle.
 void paintOperation(java.awt.Graphics2D graphics)
          Performs grawing 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
paint, update
 
Methods inherited from class org.jdrawing.graphics.GraphicsElement
addStyle, getParent, getStyle, getStyles, getTransform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DrawLine

public DrawLine(int x1,
                int x2,
                int y1,
                int y2)
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 grawing 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.

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.

Returns:
high precision bounding box of the element or null of the element is unbounded

intersects

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

Parameters:
rectangle - rectangle to be cheched 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 containes given point.

Parameters:
point - to be checked
Returns:
true if the element contains given point; false otherwise