Class de.unikl.AWTNode.ConnectionLinePoints
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class de.unikl.AWTNode.ConnectionLinePoints

java.lang.Object
   |
   +----java.awt.Component
           |
           +----de.unikl.AWTNode.ConnectionLinePoints

public class ConnectionLinePoints
extends Component
The class ConnectionLinePoints is a lightweight component. The basic idea is, that this class stores only lines, given with a StartPoint (x1,y1) and an endpoint (x2,y2)

Important: This class uses the graphics-context of its container

If you call the paint method of this class, all the lines are painted in the parents graphic context. Thus this lightweigth component have to know ist parent. You can set the parent of the Component with the method:


  setParent(Component parent)
  

To get a higher performance between the steps:

1. hide the actual Objekt 2. fill the Objekt with new lines 3. paint these lines

there is a possibility to put the "invalid" lines in a Buffer. If there are invalid lines in the buffer the paint method of this component first hide these invalid lines, and then it paints the new lines.

For what is this class good for?

As an example you can store all the lines in it, which you need if you implement a tree-view. In a tree-view you have lines from each parent-Node to its son-nodes.

internal implementation:

The lines are stored in a vector structure.


Method Index

 o addElement(Point, Point)
adds a new Line to the Object Note: Lines are stored in the coordinate space of the Container, or Component to which this Object belongs to.
 o elementAt(int)
return the LinePoints Object at the given index position
 o getLineCount()
returns the number of currentLines-Elements in this Object
 o isPainted()
returns whether the Object is painted in the paint method or not.
 o paint(Graphics)
Paints the object.
 o resetLines()
Clears the currentLine variable, and append the current lines to the oldLines object.
 o setPainted(boolean)
This method sets the painted flag for the Object.
 o setParent(Component)
This Method is important if the Object should draw its Lines in the parents graphic context.
 o toString()

Methods

 o addElement
  public void addElement(Point a,
                         Point b)
adds a new Line to the Object Note: Lines are stored in the coordinate space of the Container, or Component to which this Object belongs to. This is important if you construct the graphics context in which the lines should draw themselves
Parameters:
a - the Startpoint of the line (in parents coordiante space)
b - the EndPoint of the line (in parents coordiante space)
 o getLineCount
  public int getLineCount()
returns the number of currentLines-Elements in this Object
 o elementAt
  public LinePoints elementAt(int pos)
return the LinePoints Object at the given index position
 o resetLines
  public void resetLines()
Clears the currentLine variable, and append the current lines to the oldLines object.
 o isPainted
  public boolean isPainted()
returns whether the Object is painted in the paint method or not.
 o setParent
  public void setParent(Component parent)
This Method is important if the Object should draw its Lines in the parents graphic context. You must specify a parent or the Object cannot get the graphic context and cannot be drawn.
 o setPainted
  public void setPainted(boolean lpaint)
This method sets the painted flag for the Object.
 o paint
  public void paint(Graphics g)
Paints the object. If isPainted()==false, we hide the oldLines and no currentLines are drawn. otherwise we hide the oldLines as well, but draw the currentLines in the parent Grapics Context.
Overrides:
paint in class Component
 o toString
  public String toString()
Overrides:
toString in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index