infovis.utils
Class RectPool

java.lang.Object
  extended by infovis.utils.RectPool

public class RectPool
extends Object

Pool of rectangle that can be allocated or freed.

Improves speed by avoiding garbage collection of rectangles that are used extensively by the toolkit.

Version:
$Revision: 1.7 $
Author:
Jean-Daniel Fekete

Constructor Summary
RectPool()
          Creates a rectangle pool.
 
Method Summary
 Rectangle2D.Float allocate()
          Returns an available rectangle from the pool.
static Rectangle2D.Float allocateRect()
          Returns an available rectangle.
 Rectangle2D.Float copy(Rectangle2D rect)
          Returns the copy of a specified rectangle.
static Rectangle2D.Float copyRect(Rectangle2D rect)
          Returns the copy of a specified rectangle.
 void free(Shape r)
          Frees a shape, adding it back to the pool if it is a rectangle.
static void freeRect(Shape r)
          Frees a shape, adding it back to the pool if it is a rectangle.
static RectPool getInstance()
          Returns the current instance of the Rectangle pool.
 String getStatistics()
          Returns statistics of use.
 boolean isDebugging()
          Returns true if debugging the pool.
 boolean isEnabled()
          Returns true if the pool manages rectangles.
 void reset()
          Clears the whole pool.
 boolean setDebugging(boolean s)
          Sets the debugging parameter.
 void setEnabled(boolean enabled)
          Allow/disallow the pool to manage rectangles.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RectPool

public RectPool()
Creates a rectangle pool.

Method Detail

getInstance

public static RectPool getInstance()
Returns the current instance of the Rectangle pool.

Returns:
the current instance of the Rectangle pool.

allocateRect

public static Rectangle2D.Float allocateRect()
Returns an available rectangle.

Returns:
an available rectangle.

copyRect

public static Rectangle2D.Float copyRect(Rectangle2D rect)
Returns the copy of a specified rectangle.

Parameters:
rect - the rectangle to copy
Returns:
the copy of a specified rectangle.

freeRect

public static void freeRect(Shape r)
Frees a shape, adding it back to the pool if it is a rectangle.

Parameters:
r - the shape

allocate

public Rectangle2D.Float allocate()
Returns an available rectangle from the pool.

Returns:
an available rectangle from the pool.

copy

public Rectangle2D.Float copy(Rectangle2D rect)
Returns the copy of a specified rectangle.

Parameters:
rect - the rectangle to copy
Returns:
the copy of a specified rectangle.

free

public void free(Shape r)
Frees a shape, adding it back to the pool if it is a rectangle.

Parameters:
r - the shape

isDebugging

public boolean isDebugging()
Returns true if debugging the pool.

Returns:
true if debugging the pool.

setDebugging

public boolean setDebugging(boolean s)
Sets the debugging parameter.

Parameters:
s - value of the parameter
Returns:
true if the value changed.

reset

public void reset()
Clears the whole pool.


getStatistics

public String getStatistics()
Returns statistics of use.

Returns:
statistics of use.

isEnabled

public boolean isEnabled()
Returns true if the pool manages rectangles.

Returns:
true if the pool manages rectangles.

setEnabled

public void setEnabled(boolean enabled)
Allow/disallow the pool to manage rectangles.

Parameters:
enabled - set to true if the pool has to manage rectangles, false otherwise.


Copyright © 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.