twaver.gis.gadget
Class VoronoiDiagram

java.lang.Object
  extended bytwaver.gis.gadget.VoronoiDiagram

public class VoronoiDiagram
extends java.lang.Object

VoronoiDiagram is designed to create voronoi diagram and paint the diagram.


Field Summary
static int pointRadius
           
 
Constructor Summary
VoronoiDiagram()
          Constructs VoronoiDiagram instance.
 
Method Summary
 void addSite(twaver.Element element)
          Adds a site to the diagram.
 void clear()
          Clears all the sites stored in the diagram.
 void draw(java.awt.Graphics g, boolean withFill, boolean withSites)
          Draws the diagram.
 boolean isBoundsVisible()
          Determines whether the bounds of the the diagram's visible part should be drawn.
 boolean isVisible()
          Determines whether this diagram should be visible.
 void setAreaColorGenerator(twaver.Generator generator)
          Sets the color generator to the diagram.
 void setBoundsVisible(boolean isBoundsVisible)
          Makes the bounds of the diagram's visible part be drawn or not when the diagram is required to be draw.
 void setClipShape(java.awt.Shape area)
          Defines the clip shape.
 void setVisible(boolean isVisible)
          Makes the diagram visible or invisible.
 void setVisibleBounds(java.awt.geom.Rectangle2D bounds)
          Sets the visible bounds of the diagram.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pointRadius

public static int pointRadius
Constructor Detail

VoronoiDiagram

public VoronoiDiagram()
Constructs VoronoiDiagram instance.

Method Detail

addSite

public void addSite(twaver.Element element)
Adds a site to the diagram. An Element instance will be seemed as a site of the diagram, and the site's location is the element's center location.

Parameters:
element - the element object which will be seemed as a site of the diagram.

clear

public void clear()
Clears all the sites stored in the diagram.


draw

public void draw(java.awt.Graphics g,
                 boolean withFill,
                 boolean withSites)
Draws the diagram.

Parameters:
g - the Graphics object
withFill - true to fill the polygon areas; false not to fill the areas.
withSites - true to draw the sites; false not to draw the sites.

isBoundsVisible

public boolean isBoundsVisible()
Determines whether the bounds of the the diagram's visible part should be drawn.

Returns:
true, if should be drawn; false otherwise.

isVisible

public boolean isVisible()
Determines whether this diagram should be visible. The diagram is initially visible.

See Also:
setVisible(boolean)

setAreaColorGenerator

public void setAreaColorGenerator(twaver.Generator generator)
Sets the color generator to the diagram. Voronoi diagram can create many polygon areas. When this diagram is drawn, if you want to fill those polygon areas with specified color, the method should be invoked. All those polygon areas are initially filled with the same but random color.

Parameters:
generator - an instance of the Generator interface.

setBoundsVisible

public void setBoundsVisible(boolean isBoundsVisible)
Makes the bounds of the diagram's visible part be drawn or not when the diagram is required to be draw.

Parameters:
isBoundsVisible - true to make the bounds drawn; false not to make the bounds drawn

setClipShape

public void setClipShape(java.awt.Shape area)
Defines the clip shape.

Parameters:
area - the defined clip shape.

setVisible

public void setVisible(boolean isVisible)
Makes the diagram visible or invisible.

Parameters:
isVisible - true to make the diagram should be visible; false to make it invisible

setVisibleBounds

public void setVisibleBounds(java.awt.geom.Rectangle2D bounds)
Sets the visible bounds of the diagram. The visible bounds limits which part of the diagram will be visible. The visible bounds is initially Rectange(0,0,0,0);

Parameters:
bounds - the specified bounds
See Also:
setClipShape(Shape)