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.HorizonColorModel

java.lang.Object
  |
  +--java.awt.image.ColorModel
        |
        +--ncsa.horizon.awt.color.HorizonColorModel
Subclasses:
EditableColorModel, FunctionalColorModel, RemappableColorModel

public abstract class HorizonColorModel
extends java.awt.image.ColorModel
implements HorizonColorModelListener.Flags, java.io.Serializable, java.lang.Cloneable
a ColorModel that supports the Horizon color index convention.

This class allows one to define and/or edit the lookup table that can be applied to data for display as an image. Although it extends the ColorModel class, it is not meant to be used directly as such; instead, one should convert this ColorModel to an IndexColorModel via the createIndexColorModel() method for higher performance during image rendering.

One of the goals of this ColorModel is to support the color index convention employed by the TransferFunction and its implementations. That is, the first index points to the color to be given to undefined datum values; the second, to datum values less than a minimum value; the last index, to values greater than a maximum value. These are set with the setUndefinedColor(), setUnderflowColor(), and setUnderflowColor() methods, respectively. One can also set an index to be transparent with the setTransparentIndex() method.

The protected methods getReds(), getGreens(), getBlues(), and getAlphas() are used to convert a HorizonColroModel to an IndexColorModel via createIndexColorModel. Subclasses should return references for these methods when possible.

See Also:
ncsa.horizon.awt.image.FunctionalColorModel, ncsa.horizon.awt.image.EditableColorModel, TransferFunction, Serialized Form

Field Summary
int mapsz
          the size of the color table
int transi
          the index to the transparent pixel.
 
Fields inherited from class java.awt.image.ColorModel
pixel_bits, transferType
 
Constructor Summary
HorizonColorModel(int bits, int size)
          instantiate a HorizonColorModel.
 
Method Summary
void addHorizonColorModelListener(HorizonColorModelListener l)
          add a listener of changes to this color model
void clearChanged()
          clear the change status of this ColorModel
java.lang.Object clone()
          clone this color model.
java.awt.image.IndexColorModel createIndexColorModel()
          convert this ColorModel into an IndexColorModel
boolean delayNotify()
          return true if notification of Listeners is delayed until an explicit call to notifyListeners().
boolean delayNotify(boolean yes)
          set whether notification of Listeners is delayed until an explicit call to notifyListeners().
byte[] getAlpha()
          return the alpha components of the color table as an array A reference rather than a copy should be returned when possible.
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 A reference rather than a copy should be returned when possible.
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 A reference rather than a copy should be returned when possible.
void getGreens(byte[] g)
          copy the green components of the color table as an array
int getMapSize()
          return the number of colors in this table
int[] getOverflowColor()
          return the color to be given to datum values greater than some minimum threshold.
byte[] getRed()
          return the red components of the color table as an array.
void getReds(byte[] r)
          copy the red components of the color table into an array
int getTransparentIndex()
          return the index that is to be completely transparent (alpha=255).
int[] getUndefinedColor()
          return the color to be given to undefined datum values.
int[] getUnderflowColor()
          return the color to be given to datum values less than some minimum threshold.
boolean hasChanged()
          return true if there have been changes made that are pending notification of listeners
void notifyListeners()
          notify listeners of any changes
void removeAllListeners()
          remove all listeners
void removeListener(HorizonColorModelListener l)
          remove a listener
void saveColorModel(java.io.Writer out, PixelFormat pfmt)
          save the color table to an output stream
void saveColorModel(java.io.Writer out)
          save the color table to an output stream
void saveColorModel(java.io.File file)
          save the color table to a file.
void setChanged()
          indicate that model has changed in an unspecified way
void setChanged(int flags)
          indicate that model has changed in an specified ways
void setOverflowColor(int red, int green, int blue, int alpha)
          set the color to be given to datum values greater than some minimum threshold.
void setTransparentIndex(int index)
          get the index that is to be completely transparent (alpha=255).
void setUndefinedColor(int red, int green, int blue, int alpha)
          set the color to be given to undefined datum values.
void setUnderflowColor(int red, int green, int blue, int alpha)
          set the color to be given to datum values less than some minimum threshold.
 
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

mapsz

protected int mapsz
the size of the color table

transi

protected int transi
the index to the transparent pixel. By default, this is set to to no index.
Constructor Detail

HorizonColorModel

public HorizonColorModel(int bits,
                         int size)
instantiate a HorizonColorModel.
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 4.
Method Detail

getMapSize

public int getMapSize()
return the number of colors in this table

getRed

protected abstract byte[] getRed()
return the red components of the color table as an array. A reference rather than a copy should be returned when possible.

getGreen

protected abstract byte[] getGreen()
return the green components of the color table as an array A reference rather than a copy should be returned when possible.

getBlue

protected abstract byte[] getBlue()
return the blue components of the color table as an array A reference rather than a copy should be returned when possible.

getAlpha

protected abstract byte[] getAlpha()
return the alpha components of the color table as an array A reference rather than a copy should be returned when possible.

createIndexColorModel

public java.awt.image.IndexColorModel createIndexColorModel()
convert this ColorModel into an IndexColorModel

getUndefinedColor

public final int[] getUndefinedColor()
return the color to be given to undefined datum values. By convention, this is the color with index zero.
Returns:
int[] a 4-element array containing the red, green, blue, and alpha values

setUndefinedColor

public abstract void setUndefinedColor(int red,
                                       int green,
                                       int blue,
                                       int alpha)
set the color to be given to undefined datum values. By convention, this is the color with index zero.

getUnderflowColor

public final int[] getUnderflowColor()
return the color to be given to datum values less than some minimum threshold. By convention, this is the color with index one.
Returns:
int[] a 4-element array containing the red, green, blue, and alpha values

setUnderflowColor

public abstract void setUnderflowColor(int red,
                                       int green,
                                       int blue,
                                       int alpha)
set the color to be given to datum values less than some minimum threshold. By convention, this is the color with index one.

getOverflowColor

public final int[] getOverflowColor()
return the color to be given to datum values greater than some minimum threshold. By convention, this is the last color in the table
Returns:
int[] a 4-element array containing the red, green, blue, and alpha values

setOverflowColor

public abstract void setOverflowColor(int red,
                                      int green,
                                      int blue,
                                      int alpha)
set the color to be given to datum values greater than some minimum threshold. By convention, this is the color with index one.

getTransparentIndex

public final int getTransparentIndex()
return the index that is to be completely transparent (alpha=255). A value less than zero or greater than or equal to the number of colors in this table indicates that this feature is turned off.

setTransparentIndex

public final void setTransparentIndex(int index)
get the index that is to be completely transparent (alpha=255). A value less than zero or greater than or equal to the number of colors in this table indicates that this feature is turned off. The old transparent index is restored to its default color.

addHorizonColorModelListener

public void addHorizonColorModelListener(HorizonColorModelListener l)
add a listener of changes to this color model

notifyListeners

public void notifyListeners()
notify listeners of any changes

clearChanged

protected void clearChanged()
clear the change status of this ColorModel

hasChanged

public boolean hasChanged()
return true if there have been changes made that are pending notification of listeners

removeListener

public void removeListener(HorizonColorModelListener l)
remove a listener

removeAllListeners

public void removeAllListeners()
remove all listeners

setChanged

protected void setChanged()
indicate that model has changed in an unspecified way

setChanged

protected void setChanged(int flags)
indicate that model has changed in an specified ways
Parameters:
flags - change flags ORed together. These will be ORed with the already pending changes.

delayNotify

public boolean delayNotify()
return true if notification of Listeners is delayed until an explicit call to notifyListeners(). False indicates that notification will occur automatically whenever a change is made.

delayNotify

public boolean delayNotify(boolean yes)
set whether notification of Listeners is delayed until an explicit call to notifyListeners(). False indicates that notification will occur automatically whenever a change is made.
Returns:
boolean the notification prior to this update

getReds

public void getReds(byte[] r)
copy the red components of the color table into an array

getGreens

public void getGreens(byte[] g)
copy the green components of the color table as an array

getBlues

public void getBlues(byte[] b)
copy the blue components of the color table as an array

getAlphas

public void getAlphas(byte[] a)
copy the alpha components of the color table as an array

saveColorModel

public void saveColorModel(java.io.Writer out,
                           PixelFormat pfmt)
                   throws java.io.IOException
save the color table to an output stream
Parameters:
out - the output stream
pfmt - the format to use

saveColorModel

public void saveColorModel(java.io.Writer out)
                   throws java.io.IOException
save the color table to an output stream
Parameters:
out - the output stream
pfmt - the format to use

saveColorModel

public void saveColorModel(java.io.File file)
                   throws java.io.IOException
save the color table to a file. If the file exists, it is overwritten.

clone

public java.lang.Object clone()
clone this color model. The returned clone will not contain any listeners
Overrides:
clone in class java.lang.Object

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