com.tensegrity.graphics
Class FormatPool

java.lang.Object
  extended bycom.tensegrity.graphics.FormatPool

public class FormatPool
extends java.lang.Object

The FormatPool is the facility that takes over the work of pooling the different types of formats the graphics framework provides. Pooling the formats is necessary because these formats are frequently used objects. The actually pooled types of formats are listed below:

Version:
$Id: FormatPool.java,v 1.37 2005/12/12 15:19:25 MichaelKegel Exp $
Author:
MichaelKegel

Method Summary
static void changeFontFormat(FontFormat format, int size, int weight, java.lang.String family, int color, boolean italic, boolean underline, boolean strikethrough)
          Changes the FontFormat given by format to the values given by size, weight, family, color, italic, underline and strikethrough.
static void changeFontFormat(FontFormat format, int size, int weight, java.lang.String family, int color, boolean italic, boolean underline, boolean strikethrough, StrokeFormat strokeUnderline, StrokeFormat strokeStrikethrough)
          Changes the FontFormat given by format to the values given by size, weight, family, color, italic, underline and strikethrough.
static void changePaintFormat(PaintFormat format, int style, int colorback, int colorfore, int gradienttype, int patterntype, java.lang.String texturerasterkey, int transparency, boolean transparent)
          Changes the PaintFormat given by format to the values given by style,colorfore, colorback,gradienttype, patterntype,texturerasterkey, transparency and transparent.
static void changeStrokeFormat(StrokeFormat format, int style, int weight, int color)
          Changes the StrokeFormat given by format to the values given by style, weight and color.
static void changeStrokeFormat(StrokeFormat format, int style, int weight, int color, double[] pattern)
          Changes the StrokeFormat given by format to the values given by style, weight and color.
static void clear()
          Clears all format pools.
static void clearFontFormatPool()
          Clears the pool for the FontFormats.
static void clearMarkerFormatPool()
          Clears the pool for the MarkerFormats.
static void clearPaintFormatPool()
          Clears the pool for the PaintFormats.
static void clearStrokeFormatPool()
          Clears the pool for the StrokeFormats.
static void dump(java.io.PrintStream s)
          Dumps the FormatPool to the PrintStream given by s.
static java.util.Map getFontFormatPool()
          Returns the Map used to pool FontFormats.
static java.util.Map getMarkerFormatPool()
          Returns the Map used to pool MarkerFormats.
static java.util.Map getPaintFormatPool()
          Returns the Map used to pool PaintFormats.
static java.util.Map getStrokeFormatPool()
          Returns the Map used to pool StrokeFormats.
static FontFormat parseFontFormat(int size, int weight, java.lang.String family, int color, boolean italic, boolean underline, boolean strikethrough)
          Parses the given font format and returns an instance of a FontFormat.
static FontFormat parseFontFormat(int size, int weight, java.lang.String family, int color, boolean italic, boolean underline, boolean strikethrough, StrokeFormat underlineStroke, StrokeFormat strikethroughStroke)
          Parses the given font format and returns an instance of a FontFormat.
static FontFormat parseFontFormat(java.lang.String description)
          Parses the given font format description and returns an instance of a FontFormat.
static MarkerFormat parseMarkerFormat(java.lang.String description)
          Parses the given marker format description and returns an instance of a MarkerFormat.
static PaintFormat parsePaintFormat(java.lang.String description)
          Parses the given paint format description and returns an instance of a PaintFormat.
static StrokeFormat parseStrokeFormat(java.lang.String description)
          Parses the given stroke format description and returns an instance of a StrokeFormat.
static int size()
          Returns the accumulated sizes of all the internal pools.
static int sizeOfFontFormatPool()
          Returns the size of the FontFormat pool.
static int sizeOfMarkerFormatPool()
          Returns the size of the MarkerFormat pool.
static int sizeOfPaintFormatPool()
          Returns the size of the PaintFormat pool.
static int sizeOfStrokeFormatPool()
          Returns the size of the StrokeFormat pool.
static void useThreadLocal()
          A call to this method configures the FormatPool to make use of the ThreadLocal class hence a pool is created for each Thread the FormatPool is used by.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

useThreadLocal

public static final void useThreadLocal()
A call to this method configures the FormatPool to make use of the ThreadLocal class hence a pool is created for each Thread the FormatPool is used by.
Notice: This configuration must be done before the FormatPool is in use by any Thread.

See Also:
ThreadLocal

parseStrokeFormat

public static final StrokeFormat parseStrokeFormat(java.lang.String description)
                                            throws StrokeFormatParseException
Parses the given stroke format description and returns an instance of a StrokeFormat. The instance is pooled if necessary. If the given stroke format description is not valid a StrokeFormatParseException is thrown.

Parameters:
description - of the stroke format
Returns:
the instance of a StrokeFormat
Throws:
StrokeFormatParseException - if the stroke format description is not valid

parsePaintFormat

public static final PaintFormat parsePaintFormat(java.lang.String description)
                                          throws PaintFormatParseException
Parses the given paint format description and returns an instance of a PaintFormat. The instance is pooled if necessary. If the given paint format description is not valid a PaintFormatParseException is thrown.

Parameters:
description - of the paint format
Returns:
the instance of a PaintFormat
Throws:
PaintFormatParseException - if the paint format description is not valid

parseFontFormat

public static final FontFormat parseFontFormat(int size,
                                               int weight,
                                               java.lang.String family,
                                               int color,
                                               boolean italic,
                                               boolean underline,
                                               boolean strikethrough)
Parses the given font format and returns an instance of a FontFormat. The instance is pooled if necessary.

Parameters:
size - the value for the size of the font
weight - the value for the weight of the font
family - the value for the family of the font
color - the value for the color of the font
italic - the flag that indicates an italic font
underline - the flag that indicates an underlined font
strikethrough - the flag that indicates a strikethrough font
Returns:
a (pooled) instance of FontFormat.

Find more information in the class documentation


parseFontFormat

public static final FontFormat parseFontFormat(int size,
                                               int weight,
                                               java.lang.String family,
                                               int color,
                                               boolean italic,
                                               boolean underline,
                                               boolean strikethrough,
                                               StrokeFormat underlineStroke,
                                               StrokeFormat strikethroughStroke)
Parses the given font format and returns an instance of a FontFormat. The instance is pooled if necessary.

Parameters:
size - the value for the size of the font
weight - the value for the weight of the font
family - the value for the family of the font
color - the value for the color of the font
italic - the flag that indicates an italic font
underline - the flag that indicates an underlined font
strikethrough - the flag that indicates a strikethrough font
underlineStroke - the stroke to use for the underline
strikethroughStroke - the stroke to use for the strikethrough
Returns:
a (pooled) instance of FontFormat.

parseFontFormat

public static final FontFormat parseFontFormat(java.lang.String description)
                                        throws FontFormatParseException
Parses the given font format description and returns an instance of a FontFormat. The instance is pooled if necessary. If the given font format description is not valid, a FontFormatParseException is thrown. The String "family=Arial, size=50, weight=400, color=-16777216, italic=false, underline=false, strikethrough=false" is an example for a valid canonical description.

Parameters:
description - of the font format
Returns:
the instance of a FontFormat
Throws:
FontFormatParseException - if the font format description is not valid

Find more information in the class documentation


parseMarkerFormat

public static final MarkerFormat parseMarkerFormat(java.lang.String description)
                                            throws MarkerFormatParseException
Parses the given marker format description and returns an instance of a MarkerFormat. The instance is pooled if necessary. If the given marker format description is not valid a MarkerFormatParseException is thrown.

Parameters:
description - of the marker format
Returns:
the instance of a MarkerFormat
Throws:
MarkerFormatParseException - if the marker format description is not valid

changeStrokeFormat

public static final void changeStrokeFormat(StrokeFormat format,
                                            int style,
                                            int weight,
                                            int color)
Changes the StrokeFormat given by format to the values given by style, weight and color.
Changing the settings of the format involves that the format is stored with another key (according to the new settings of the format) in the corresponding pool.

Parameters:
format - the StrokeFormat to change
style - the new style for the StrokeFormat
weight - the new weight for the StrokeFormat
color - then new color for the StrokeFormat

changeStrokeFormat

public static final void changeStrokeFormat(StrokeFormat format,
                                            int style,
                                            int weight,
                                            int color,
                                            double[] pattern)
Changes the StrokeFormat given by format to the values given by style, weight and color.
Changing the settings of the format involves that the format is stored with another key (according to the new settings of the format) in the corresponding pool.

Parameters:
format - the StrokeFormat to change
style - the new style for the StrokeFormat
weight - the new weight for the StrokeFormat
color - the new color for the StrokeFormat
pattern - the custom pattern for this StrokeFormat

changePaintFormat

public static final void changePaintFormat(PaintFormat format,
                                           int style,
                                           int colorback,
                                           int colorfore,
                                           int gradienttype,
                                           int patterntype,
                                           java.lang.String texturerasterkey,
                                           int transparency,
                                           boolean transparent)
Changes the PaintFormat given by format to the values given by style,colorfore, colorback,gradienttype, patterntype,texturerasterkey, transparency and transparent.
Changing the settings of the format involves that the format is stored with another key (according to the new settings of the format) in the corresponding pool.

Parameters:
format - the PaintFormat to change
style - the new style for the PaintFormat
colorback - the new background color for the PaintFormat
colorfore - the new foreground color for the PaintFormat
gradienttype - the new gradienttype for the PaintFormat
patterntype - the new patterntype for the PaintFormat
texturerasterkey - the new texture for the PaintFormat
transparency - the new tranparency level for the PaintFormat
transparent - the new value for the transparency flag of the PaintFormat

changeFontFormat

public static final void changeFontFormat(FontFormat format,
                                          int size,
                                          int weight,
                                          java.lang.String family,
                                          int color,
                                          boolean italic,
                                          boolean underline,
                                          boolean strikethrough)
Changes the FontFormat given by format to the values given by size, weight, family, color, italic, underline and strikethrough.
Changing the settings of the format involves that the format is stored with another key (according to the new settings of the format) in the corresponding pool.

Parameters:
format - the FontFormat to change
size - the new size for the FontFormat
weight - the new weight for the FontFormat
family - the new family for the FontFormat
color - the new color for the FontFormat
italic - the new value for the italic flag of the FontFormat
underline - the new value for the underline flag of the FontFormat
strikethrough - the new value for the strikethrough flag of the FontFormat

changeFontFormat

public static final void changeFontFormat(FontFormat format,
                                          int size,
                                          int weight,
                                          java.lang.String family,
                                          int color,
                                          boolean italic,
                                          boolean underline,
                                          boolean strikethrough,
                                          StrokeFormat strokeUnderline,
                                          StrokeFormat strokeStrikethrough)
Changes the FontFormat given by format to the values given by size, weight, family, color, italic, underline and strikethrough.
Changing the settings of the format involves that the format is stored with another key (according to the new settings of the format) in the corresponding pool.

Parameters:
format - the FontFormat to change
size - the new size for the FontFormat
weight - the new weight for the FontFormat
family - the new family for the FontFormat
color - the new color for the FontFormat
italic - the new value for the italic flag of the FontFormat
underline - the new value for the underline flag of the FontFormat
strikethrough - the new value for the strikethrough flag of the FontFormat
strokeUnderline - The StrokeFormat to use for the underline font decoration.
strokeStrikethrough - The StrokeFormat to use for the strikethrough font decoration.

getStrokeFormatPool

public static final java.util.Map getStrokeFormatPool()
Returns the Map used to pool StrokeFormats.

Returns:
the Map used to pool StrokeFormats.

getPaintFormatPool

public static final java.util.Map getPaintFormatPool()
Returns the Map used to pool PaintFormats.

Returns:
the Map used to pool PaintFormats.

getFontFormatPool

public static final java.util.Map getFontFormatPool()
Returns the Map used to pool FontFormats.

Returns:
the Map used to pool FontFormats.

getMarkerFormatPool

public static final java.util.Map getMarkerFormatPool()
Returns the Map used to pool MarkerFormats.

Returns:
the Map used to pool MarkerFormats

sizeOfStrokeFormatPool

public static final int sizeOfStrokeFormatPool()
Returns the size of the StrokeFormat pool.

Returns:
the count of pooled StrokeFormats

sizeOfPaintFormatPool

public static final int sizeOfPaintFormatPool()
Returns the size of the PaintFormat pool.

Returns:
the count of pooled PaintFormats

sizeOfFontFormatPool

public static final int sizeOfFontFormatPool()
Returns the size of the FontFormat pool.

Returns:
the count of pooled FontFormats

sizeOfMarkerFormatPool

public static final int sizeOfMarkerFormatPool()
Returns the size of the MarkerFormat pool.

Returns:
the count of pooled MarkerFormats

clearStrokeFormatPool

public static final void clearStrokeFormatPool()
Clears the pool for the StrokeFormats.


clearPaintFormatPool

public static final void clearPaintFormatPool()
Clears the pool for the PaintFormats.


clearFontFormatPool

public static final void clearFontFormatPool()
Clears the pool for the FontFormats.


clearMarkerFormatPool

public static final void clearMarkerFormatPool()
Clears the pool for the MarkerFormats.


clear

public static final void clear()
Clears all format pools.


size

public static final int size()
Returns the accumulated sizes of all the internal pools.

Returns:
accumulated size of all pooled items.

dump

public static final void dump(java.io.PrintStream s)
Dumps the FormatPool to the PrintStream given by s.

Parameters:
s - the PrintStream to dump the FormatPool to


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.