Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class ncsa.horizon.awt.color.EditableColorModel

java.lang.Object
  |
  +--java.awt.image.ColorModel
        |
        +--ncsa.horizon.awt.color.HorizonColorModel
              |
              +--ncsa.horizon.awt.color.EditableColorModel

public class EditableColorModel
extends HorizonColorModel
a ColorModel represented by a set of 4 editable color component arrays.

This class supports the HorizonColorModel via 4 internal byte arrays. References to these arrays can be obtains via the getColors() methods and edited directly to update the table.

Although it extends the ColorModel class, this class (like its superclass) is not meant to be used directly as such; instead, one should convert this ColorModel to an IndexColorModel via the superclass's createIndexColorModel() method for higher performance during image rendering.

See Also:
Serialized Form

Field Summary
byte[] alphas
          the alpha component arrays
byte[] blues
          the blue component arrays
byte[] greens
          the green component arrays
byte[] reds
          the red component arrays
 
Fields inherited from class ncsa.horizon.awt.color.HorizonColorModel
mapsz, transi
 
Fields inherited from class java.awt.image.ColorModel
pixel_bits, transferType
 
Constructor Summary
EditableColorModel(int bits, int size)
          instantiate a color model with a particular size
EditableColorModel(int bits, int size, byte[] r, byte[] g, byte[] b, byte[] a)
          construct a color model from a given set of arrays
EditableColorModel(java.awt.image.IndexColorModel icm)
          construct a color model, initializing it with values from a given IndexColorModel.
EditableColorModel(HorizonColorModel hcm)
          construct a color model, initializing it with values from a given HorizonColorModel.
EditableColorModel(int size, java.io.Reader in, PixelFormat pf)
          construct and fill our color table from an input stream.
 
Method Summary
java.lang.Object clone()
           
byte[] getAlpha()
          return the alpha components of the color table as an array
int getAlpha(int index)
          Return the alpha color compoment for the specified pixel in the range 0-255.
void getAlphas(byte[] a)
          copy the alpha components of the color table as an array
byte[] getBlue()
          return the blue components of the color table as an array
int getBlue(int index)
          Return the blue color compoment for the specified pixel in the range 0-255.
void getBlues(byte[] b)
          copy the blue components of the color table as an array
byte[] getGreen()
          return the green components of the color table as an array
int getGreen(int index)
          Return the green color compoment for the specified pixel in the range 0-255.
void getGreens(byte[] g)
          copy the green components of the color table as an array
static EditableColorModel getPresetColorModel(java.lang.String name)
          read in a preset color table identified by a name.
byte[] getRed()
          return the red components of the color table as an array
int getRed(int index)
          Return the red color compoment for the specified pixel in the range 0-255.
void getReds(byte[] r)
          copy the red components of the color table into an array
void loadFromReader(java.io.Reader in, PixelFormat pf)
           
static EditableColorModel readEditableColorModel(java.io.Reader in, PixelFormat pf)
          read in a color table from an input stream and return it as an EditableColorModel.
static EditableColorModel readEditableColorModel(java.io.File file, PixelFormat pf)
          read in a color table from a File and return it as an EditableColorModel.
static EditableColorModel readEditableColorModel(java.io.File file)
          read in a color table from a File and return it as an EditableColorModel.
void setAlpha(int index, int value)
          set the alpha color compoment for the specified pixel.
void setAlpha(byte[] a)
          sets the alpha color compoments.
void setBlue(int index, int value)
          set the blue color compoment for the specified pixel.
void setBlue(byte[] b)
          sets the blue color compoments.
void setGreen(int index, int value)
          set the green color compoment for the specified pixel.
void setGreen(byte[] g)
          sets the green color compoments.
void setOverflowColor(int r, int g, int b, int a)
          set the color to be given to datum values greater than some minimum threshold.
void setRed(int index, int value)
          set the red color compoment for the specified pixel.
void setRed(byte[] r)
          set the red color compoments.
void setUndefinedColor(int r, int g, int b, int a)
          set the color to be given to undefined datum values.
void setUnderflowColor(int r, int g, int b, int a)
          set the color to be given to datum values less than some minimum threshold.
 
Methods inherited from class ncsa.horizon.awt.color.HorizonColorModel
addHorizonColorModelListener, clearChanged, clone, createIndexColorModel, delayNotify, delayNotify, getAlpha, getAlphas, getBlue, getBlues, getGreen, getGreens, getMapSize, getOverflowColor, getRed, getReds, getTransparentIndex, getUndefinedColor, getUnderflowColor, hasChanged, notifyListeners, removeAllListeners, removeListener, saveColorModel, saveColorModel, saveColorModel, setChanged, setChanged, setOverflowColor, setTransparentIndex, setUndefinedColor, setUnderflowColor
 
Methods inherited from class java.awt.image.ColorModel
coerceData, createCompatibleSampleModel, createCompatibleWritableRaster, equals, finalize, getAlpha, getAlpha, getAlphaRaster, getBlue, getBlue, getColorSpace, getComponents, getComponents, getComponentSize, getComponentSize, getDataElement, getDataElements, getGreen, getGreen, getNormalizedComponents, getNumColorComponents, getNumComponents, getPixelSize, getRed, getRed, getRGB, getRGB, getRGBdefault, getTransparency, getUnnormalizedComponents, hasAlpha, isAlphaPremultiplied, isCompatibleRaster, isCompatibleSampleModel, setDataElements, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

reds

protected byte[] reds
the red component arrays

greens

protected byte[] greens
the green component arrays

blues

protected byte[] blues
the blue component arrays

alphas

protected byte[] alphas
the alpha component arrays
Constructor Detail

EditableColorModel

protected EditableColorModel(int bits,
                             int size)
instantiate a color model with a particular size
Parameters:
bits - the number of bits each pixel
size - the number of colors in the color table
Throws:
java.lang.IndexOutOfBoundsException - if size is less than 3.

EditableColorModel

public EditableColorModel(int bits,
                          int size,
                          byte[] r,
                          byte[] g,
                          byte[] b,
                          byte[] a)
construct a color model from a given set of arrays
Parameters:
bits - the number of bits each pixel
size - the number of colors in the color table
r - the red components; a null array means set all values to zero
g - the green components; a null array means set all values to zero
b - the blue components; a null array means set all values to zero
Throws:
java.lang.IndexOutOfBoundsException - if size is less than 4.

EditableColorModel

public EditableColorModel(java.awt.image.IndexColorModel icm)
construct a color model, initializing it with values from a given IndexColorModel.
Parameters:
icm - the IndexColorModel to extract colors from
Throws:
java.lang.IndexOutOfBoundsException - if the map size of icm is less than 4.

EditableColorModel

public EditableColorModel(HorizonColorModel hcm)
construct a color model, initializing it with values from a given HorizonColorModel.
Parameters:
icm - the IndexColorModel to extract colors from
Throws:
java.lang.IndexOutOfBoundsException - if the map size of icm is less than 4.

EditableColorModel

public EditableColorModel(int size,
                          java.io.Reader in,
                          PixelFormat pf)
                   throws java.io.IOException
construct and fill our color table from an input stream. This method assumes the colors have been written in the format used by saveColorModel() and that the next line to be read contains the first color. Most applications wanting to read a table in from a stream should use readEditableColorModel() instead.
Method Detail

loadFromReader

protected void loadFromReader(java.io.Reader in,
                              PixelFormat pf)
                      throws java.io.IOException

getRed

protected byte[] getRed()
return the red components of the color table as an array
Overrides:
getRed in class HorizonColorModel

getGreen

protected byte[] getGreen()
return the green components of the color table as an array
Overrides:
getGreen in class HorizonColorModel

getBlue

protected byte[] getBlue()
return the blue components of the color table as an array
Overrides:
getBlue in class HorizonColorModel

getAlpha

protected byte[] getAlpha()
return the alpha components of the color table as an array
Overrides:
getAlpha in class HorizonColorModel

setUndefinedColor

public void setUndefinedColor(int r,
                              int g,
                              int b,
                              int a)
set the color to be given to undefined datum values. By convention, this is the color with index zero.
Overrides:
setUndefinedColor in class HorizonColorModel

setUnderflowColor

public void setUnderflowColor(int r,
                              int g,
                              int b,
                              int a)
set the color to be given to datum values less than some minimum threshold. By convention, this is the color with index one.
Overrides:
setUnderflowColor in class HorizonColorModel

setOverflowColor

public void setOverflowColor(int r,
                             int g,
                             int b,
                             int a)
set the color to be given to datum values greater than some minimum threshold. By convention, this is the color with index one.
Overrides:
setOverflowColor in class HorizonColorModel

getRed

public int getRed(int index)
Return the red color compoment for the specified pixel in the range 0-255.
Overrides:
getRed in class java.awt.image.ColorModel

getGreen

public int getGreen(int index)
Return the green color compoment for the specified pixel in the range 0-255.
Overrides:
getGreen in class java.awt.image.ColorModel

getBlue

public int getBlue(int index)
Return the blue color compoment for the specified pixel in the range 0-255.
Overrides:
getBlue in class java.awt.image.ColorModel

getAlpha

public int getAlpha(int index)
Return the alpha color compoment for the specified pixel in the range 0-255.
Overrides:
getAlpha in class java.awt.image.ColorModel

setRed

public void setRed(int index,
                   int value)
set the red color compoment for the specified pixel. The input value, which should be in the range 0-255, will be cast to a byte.

setGreen

public void setGreen(int index,
                     int value)
set the green color compoment for the specified pixel. The input value, which should be in the range 0-255, will be cast to a byte.

setBlue

public void setBlue(int index,
                    int value)
set the blue color compoment for the specified pixel. The input value, which should be in the range 0-255, will be cast to a byte.

setAlpha

public void setAlpha(int index,
                     int value)
set the alpha color compoment for the specified pixel. The input value, which should be in the range 0-255, will be cast to a byte.

setRed

public void setRed(byte[] r)
set the red color compoments. The input values should be in the range 0-255.

setGreen

public void setGreen(byte[] g)
sets the green color compoments. The input values should be in the range 0-255.

setBlue

public void setBlue(byte[] b)
sets the blue color compoments. The input values should be in the range 0-255.

setAlpha

public void setAlpha(byte[] a)
sets the alpha color compoments. The input values should be in the range 0-255.

getReds

public void getReds(byte[] r)
copy the red components of the color table into an array
Overrides:
getReds in class HorizonColorModel

getGreens

public void getGreens(byte[] g)
copy the green components of the color table as an array
Overrides:
getGreens in class HorizonColorModel

getBlues

public void getBlues(byte[] b)
copy the blue components of the color table as an array
Overrides:
getBlues in class HorizonColorModel

getAlphas

public void getAlphas(byte[] a)
copy the alpha components of the color table as an array
Overrides:
getAlphas in class HorizonColorModel

readEditableColorModel

public static EditableColorModel readEditableColorModel(java.io.Reader in,
                                                        PixelFormat pf)
                                                                       throws java.io.IOException
read in a color table from an input stream and return it as an EditableColorModel.
Parameters:
in - the input stream as a Reader
pf - the PixelFormat object that tells how to parse the table; null means use the default format object

readEditableColorModel

public static EditableColorModel readEditableColorModel(java.io.File file,
                                                        PixelFormat pf)
                                                                       throws java.io.IOException
read in a color table from a File and return it as an EditableColorModel.
Parameters:
file - the input file
pf - the PixelFormat object that tells how to parse the table.

readEditableColorModel

public static EditableColorModel readEditableColorModel(java.io.File file)
                                                                       throws java.io.IOException
read in a color table from a File and return it as an EditableColorModel. This assumes the table is in one of the standard formats.
Parameters:
file - the input file

getPresetColorModel

public static EditableColorModel getPresetColorModel(java.lang.String name)
read in a preset color table identified by a name. The data is stored in resource files the ncsa.horizon.awt.color.tables package.
Returns:
EditableColorModel the named color model or null if none is found with that name

clone

public java.lang.Object clone()
Overrides:
clone in class HorizonColorModel

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD