S-PLUS Connect/Java v1.0

com.insightful.gdevice
Class ColorScheme

java.lang.Object
  extended by com.insightful.gdevice.ColorScheme
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ColorScheme.PDFColorScheme

public class ColorScheme
extends Object
implements Serializable

A ColorScheme object represents a set of colors for drawing a graph. It consists of a background color, 16 palette colors, and 256 image colors.

See Also:
Serialized Form

Nested Class Summary
static class ColorScheme.PDFColorScheme
           
 
Field Summary
protected  String m_name
          Friendly name for the color scheme.
static int NUMBER_IMAGE_COLORS
          Number of image colors (256).
 
Constructor Summary
ColorScheme()
          Constructs a ColorScheme object by querying the engine for a palette.
ColorScheme(boolean queryEngine)
          Constructs a ColorScheme object by querying the engine or by using a standard set of colors.
ColorScheme(String name, Color backgroundColor, Color[] paletteColors, Color[] imageColors)
          Constructs a ColorScheme object with the specified name and colors.
ColorScheme(String name, int[] colorInts)
          Constructs a ColorScheme object with the specified name, and with colors constructed from the specified integers.
 
Method Summary
static ColorScheme createFromXML(XMLElement elt)
          Creates a ColorScheme object from an XML element.
 Color getBackgroundColor()
          Returns the background color.
 Color getImageColor(int index)
          Returns the image color of the given index.
 Color[] getImageColors()
          Returns all the image colors.
 IndexColorModel getImageIndexColorModel()
          Creates an IndexColorModel representing the image colors.
 int[] getInts()
          Returns an integer array representing this color scheme.
 Color getLineColor(int index)
          Return color for drawing lines, given color int.
 String getName()
          Returns the friendly name for this color scheme.
protected  Color[] getPalette()
          Retrieve a palette...try to get existing palette, and, if that fails, get default palette
 Color getPaletteColor(int index)
          Returns the palette color of the given index.
 String[] getPaletteColorLabels()
          Retrieve a list of numbered labels representing the colors (assuming background color is first)
 Color[] getPaletteColors()
          Returns all the palette colors.
 Color getPolygonColor(int index)
          Return color for drawing polygons, given color int.
 Color getTextColor(int index)
          Return color for drawing text, given color int.
 boolean isPDF()
          returns true if this is a pdf-style colorscheme, so we don't use weird image colors for polygon.
 void writeXML(PrintWriter out, String colorschemeTag)
          Creates an XML representation for this color scheme.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUMBER_IMAGE_COLORS

public static final int NUMBER_IMAGE_COLORS
Number of image colors (256).

See Also:
Constant Field Values

m_name

protected String m_name
Friendly name for the color scheme.

Constructor Detail

ColorScheme

public ColorScheme()
Constructs a ColorScheme object by querying the engine for a palette.


ColorScheme

public ColorScheme(boolean queryEngine)
Constructs a ColorScheme object by querying the engine or by using a standard set of colors. Note that the standard set of colors is still important because we can't query the engine in the middle of a java.graph being created (because the engine is busy).


ColorScheme

public ColorScheme(String name,
                   Color backgroundColor,
                   Color[] paletteColors,
                   Color[] imageColors)
Constructs a ColorScheme object with the specified name and colors.

Parameters:
name - friendly name for this color scheme.
backgroundColor - background color. If this value is null, white is used.
paletteColors - array of colors for the palette. If the array has more than 16 colors, only the first 16 are used. If the array has fewer than 16 colors, black is used for the remaining palette colors.
imageColors - array of 256 colors for images. If the array has more than 256 colors, only the first 256 are used. If the array has fewer than 256 colors, the remaining colors will match those for the default color scheme.

ColorScheme

public ColorScheme(String name,
                   int[] colorInts)
Constructs a ColorScheme object with the specified name, and with colors constructed from the specified integers. Each triplet of integers represents one color in RGB format; that is, the three numbers specify the red, green, and blue intensity respectively on a scale from 0 to 255.

The colorInts parameter should have 3 x (1 + 16 + 256) = 819 elements. If it has too few, black is used for the unspecified colors. If the it has too many elements the extra ones are ignored.

Parameters:
name - friendly name for this color scheme.
colorInts - array of 819 integers, each triplet of which represents a number in RGB format.
Method Detail

getPalette

protected Color[] getPalette()
Retrieve a palette...try to get existing palette, and, if that fails, get default palette


getName

public String getName()
Returns the friendly name for this color scheme.


getInts

public int[] getInts()
Returns an integer array representing this color scheme. The array contains 3 * (1 + number of palette colors + NUMBER_IMAGE_COLORS) integers. Each triplet represents a color in this color scheme, in RGB format.

Returns:
integer array representing this color scheme.

getBackgroundColor

public Color getBackgroundColor()
Returns the background color.


isPDF

public boolean isPDF()
returns true if this is a pdf-style colorscheme, so we don't use weird image colors for polygon.


getLineColor

public Color getLineColor(int index)
Return color for drawing lines, given color int.


getTextColor

public Color getTextColor(int index)
Return color for drawing text, given color int.


getPolygonColor

public Color getPolygonColor(int index)
Return color for drawing polygons, given color int.


getPaletteColor

public Color getPaletteColor(int index)
Returns the palette color of the given index. The index should be between 1 and NUMBER_PALETTE_COLORS. If the index is too small (less than 1), this method returns the background color. If the index is too large, wrap around is performed.

Parameters:
index - index of the color in the palette.
Returns:
the specified palette color.

getPaletteColors

public Color[] getPaletteColors()
Returns all the palette colors.


getImageColor

public Color getImageColor(int index)
Returns the image color of the given index. The index should be between 1 and NUMBER_IMAGE_COLORS. If the index is too small (less than 1), this method returns the first image color. If the index is too large, this method returns the last image color.

Parameters:
index - index of the color in the image color array.
Returns:
the specified image color.

getImageColors

public Color[] getImageColors()
Returns all the image colors.


getImageIndexColorModel

public IndexColorModel getImageIndexColorModel()
Creates an IndexColorModel representing the image colors.

Returns:
the IndexColorModel, or null if its creation throws an exception.

writeXML

public void writeXML(PrintWriter out,
                     String colorschemeTag)
Creates an XML representation for this color scheme.

Parameters:
out - stream for writing the XML.
colorschemeTag - XML tag to use.

createFromXML

public static ColorScheme createFromXML(XMLElement elt)
Creates a ColorScheme object from an XML element.

Parameters:
elt - XML element representing a color scheme.
Returns:
the color scheme that the XML element represents.

getPaletteColorLabels

public String[] getPaletteColorLabels()
Retrieve a list of numbered labels representing the colors (assuming background color is first)


S-PLUS Connect/Java v1.0

Copyright © 2000, 2002 Insightful Corporation
Warning: Classes not documented in the S-PLUS Programmer's Guide may change in future releases.