Class WindowedColourModel
- All Implemented Interfaces:
java.awt.Transparency,java.lang.Cloneable,XMLObject
public class WindowedColourModel extends java.awt.image.ColorModel implements java.lang.Cloneable, XMLObject
NB: This colour model is mutable, meaning that it can be changed and its changes
will be reflected in all objects that reference it. Use the clone() method to
make a copy of a particular model state.
NB: an alpha of zero will always map to zero; this is necessary for the current implementation of Volume3DTexture, which requires a power-of-two volume, part of which will be outside the bounds of any non-power-of-two volume, and thus should be always invisible.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType -
Field Summary
Fields Modifier and Type Field Description protected doublealphaprotected doublealphaMaxprotected doublealphaMinprotected intchannelsprotected ColourMapcolourMapintdata_sizeprotected intdiscrete_minprotected java.util.HashMap<java.lang.Integer,java.lang.Integer>index_mapprotected doubleinterceptbooleanis_discretebooleanis_solidprotected booleanlow_is_transparentprotected intmap_sizeprotected byte[]rgbaprotected doublescaleprotected int[]solid_colourprotected doublewindow_midprotected doublewindow_widthFields inherited from class java.awt.image.ColorModel
pixel_bits, transferTypeFields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT -
Constructor Summary
Constructors Constructor Description WindowedColourModel()Constructor produces a greyscale model of typeDataBuffer.TYPE_DOUBLE.WindowedColourModel(int transferType)Constructor produces a greyscale model of typetransferType.WindowedColourModel(ColourMap cm, double min, double max, boolean has_alpha, int transfer_type)Constructor specifying min and max values only.WindowedColourModel(ColourMap cm, double scale, double intercept, double window_mid, double window_width, boolean has_alpha, int transferType)Constructors specifying the full set of model parameters. -
Method Summary
Modifier and Type Method Description java.lang.Objectclone()java.awt.image.SampleModelcreateCompatibleSampleModel(int w, int h)java.awt.image.WritableRastercreateCompatibleWritableRaster(int w, int h)doublegetAlpha()intgetAlpha(int pixel)intgetAlpha(java.lang.Object inData)intgetAlphaIndex()doublegetAlphaMax()doublegetAlphaMin()intgetBlue(int pixel)intgetBlue(java.lang.Object inData)intgetBlueIndex()ColourMapgetColourMap()java.lang.StringgetDTD()Returns the Data Type Declaration (DTD) for this object's XML representationintgetGreen(int pixel)intgetGreen(java.lang.Object inData)intgetGreenIndex()booleangetHasAlpha()doublegetIntercept()doublegetInverseMappedValue(double value)Maps a value according to the inverse of the linear window model:double[]getLimits()Returns the limits of this windowed modeljava.lang.StringgetLocalName()Returns the local name associated with this XML object.booleangetLowIsTransparent()doublegetMappedValue(double value)Maps a value according to the linear window model:intgetRed(int pixel)intgetRed(java.lang.Object inData)intgetRedIndex()intgetRGB(int pixel)intgetRGB(java.lang.Object inData)doublegetScale()java.lang.StringgetShortXML(int tab)Returns a short XML representation of this object.java.awt.ColorgetSolidColour()doublegetWindowMid()doublegetWindowWidth()java.lang.StringgetXML()Returns this object's XML representation as a single string.java.lang.StringgetXML(int tab)Returns this object's XML representation as a single string.java.lang.StringgetXMLSchema()Returns the XML schema for this object's XML representationstatic doublegetZeroValue(int transferType)Returns the "zero" value for the given transfer type.voidhandleXMLElementEnd(java.lang.String localName)Handles the end of an XML element.voidhandleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)Handles the start of an XML element.voidhandleXMLString(java.lang.String s)Handles a string within an XML element.booleanisCompatibleRaster(java.awt.image.Raster raster)voidsetAlpha(double alpha)voidsetAlphaMax(double alphaMax)voidsetAlphaMin(double alphaMin)booleansetColourMap(ColourMap cm)voidsetFromColourModel(WindowedColourModel model)voidsetHasAlpha(boolean b)voidsetIntercept(double i)voidsetIsSolidColour(boolean b)voidsetLimits(double[] limits)Set the window from limits.voidsetLimits(double min, double max)Set the window from limits.voidsetLowIsTransparent(boolean b)voidsetScale(double s)voidsetSolidColour(java.awt.Color clr)voidsetWindowMid(double mid)voidsetWindowWidth(double width)voidwriteXML(int tab, java.io.Writer writer)Writes the XML representation of this object to file.voidwriteXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar)Writes the XML representation of this object to file, asXMLType.Normal.voidwriteXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar)Writes the XML representation of this object to file.Methods inherited from class java.awt.image.ColorModel
coerceData, equals, finalize, getAlphaRaster, getColorSpace, getComponents, getComponents, getComponentSize, getComponentSize, getDataElement, getDataElement, getDataElements, getDataElements, getDataElements, getNormalizedComponents, getNormalizedComponents, getNumColorComponents, getNumComponents, getPixelSize, getRGBdefault, getTransferType, getTransparency, getUnnormalizedComponents, hasAlpha, hashCode, isAlphaPremultiplied, isCompatibleSampleModel, toStringMethods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
rgba
protected byte[] rgba -
colourMap
-
channels
protected int channels -
data_size
public int data_size -
map_size
protected int map_size -
scale
protected double scale -
intercept
protected double intercept -
window_mid
protected double window_mid -
window_width
protected double window_width -
alphaMin
protected double alphaMin -
alphaMax
protected double alphaMax -
is_discrete
public boolean is_discrete -
is_solid
public boolean is_solid -
discrete_min
protected int discrete_min -
alpha
protected double alpha -
low_is_transparent
protected boolean low_is_transparent -
index_map
protected java.util.HashMap<java.lang.Integer,java.lang.Integer> index_map -
solid_colour
protected int[] solid_colour
-
-
Constructor Details
-
WindowedColourModel
public WindowedColourModel()Constructor produces a greyscale model of typeDataBuffer.TYPE_DOUBLE.- Parameters:
transfer_type-
-
WindowedColourModel
public WindowedColourModel(int transferType)Constructor produces a greyscale model of typetransferType.- Parameters:
transferType-
-
WindowedColourModel
public WindowedColourModel(ColourMap cm, double min, double max, boolean has_alpha, int transfer_type)Constructor specifying min and max values only.- Parameters:
cm-min-max-has_alpha-transfer_type-
-
WindowedColourModel
public WindowedColourModel(ColourMap cm, double scale, double intercept, double window_mid, double window_width, boolean has_alpha, int transferType)Constructors specifying the full set of model parameters.- Parameters:
cm-scale-intercept-window_mid-window_width-has_alpha-transferType-
-
-
Method Details
-
setIsSolidColour
public void setIsSolidColour(boolean b) -
setSolidColour
public void setSolidColour(java.awt.Color clr) -
getSolidColour
public java.awt.Color getSolidColour() -
setHasAlpha
public void setHasAlpha(boolean b) -
getHasAlpha
public boolean getHasAlpha() -
getScale
public double getScale() -
getIntercept
public double getIntercept() -
setScale
public void setScale(double s) -
setIntercept
public void setIntercept(double i) -
setWindowMid
public void setWindowMid(double mid) -
getWindowMid
public double getWindowMid() -
setWindowWidth
public void setWindowWidth(double width) -
getWindowWidth
public double getWindowWidth() -
setLowIsTransparent
public void setLowIsTransparent(boolean b) -
getLowIsTransparent
public boolean getLowIsTransparent() -
setLimits
public void setLimits(double[] limits)Set the window from limits.- Parameters:
limits-
-
setLimits
public void setLimits(double min, double max)Set the window from limits.- Parameters:
min-max-
-
getLimits
public double[] getLimits()Returns the limits of this windowed model- Returns:
-
getRedIndex
public int getRedIndex() -
getGreenIndex
public int getGreenIndex() -
getBlueIndex
public int getBlueIndex() -
getAlphaIndex
public int getAlphaIndex() -
createCompatibleWritableRaster
public java.awt.image.WritableRaster createCompatibleWritableRaster(int w, int h)- Overrides:
createCompatibleWritableRasterin classjava.awt.image.ColorModel
-
createCompatibleSampleModel
public java.awt.image.SampleModel createCompatibleSampleModel(int w, int h)- Overrides:
createCompatibleSampleModelin classjava.awt.image.ColorModel
-
isCompatibleRaster
public boolean isCompatibleRaster(java.awt.image.Raster raster)- Overrides:
isCompatibleRasterin classjava.awt.image.ColorModel
-
getRGB
public int getRGB(int pixel)- Overrides:
getRGBin classjava.awt.image.ColorModel
-
getRGB
public int getRGB(java.lang.Object inData)- Overrides:
getRGBin classjava.awt.image.ColorModel
-
getRed
public int getRed(java.lang.Object inData)- Overrides:
getRedin classjava.awt.image.ColorModel
-
getRed
public int getRed(int pixel)- Specified by:
getRedin classjava.awt.image.ColorModel
-
getGreen
public int getGreen(java.lang.Object inData)- Overrides:
getGreenin classjava.awt.image.ColorModel
-
getGreen
public int getGreen(int pixel)- Specified by:
getGreenin classjava.awt.image.ColorModel
-
getBlue
public int getBlue(java.lang.Object inData)- Overrides:
getBluein classjava.awt.image.ColorModel
-
getBlue
public int getBlue(int pixel)- Specified by:
getBluein classjava.awt.image.ColorModel
-
getAlpha
public int getAlpha(java.lang.Object inData)- Overrides:
getAlphain classjava.awt.image.ColorModel
-
getAlpha
public int getAlpha(int pixel)- Specified by:
getAlphain classjava.awt.image.ColorModel
-
getMappedValue
public double getMappedValue(double value)Maps a value according to the linear window model:Y = (value - intercept) * scale * m + bwhere
m = data_size * window_widthand
b = data_size * (window_mid - 0.5)- Parameters:
value-- Returns:
-
getInverseMappedValue
public double getInverseMappedValue(double value)Maps a value according to the inverse of the linear window model:Y = (value - b) / (scale * m) + interceptwhere
m = data_size * window_widthand
b = data_size * (window_mid - 0.5)- Parameters:
value-- Returns:
-
getZeroValue
public static double getZeroValue(int transferType)Returns the "zero" value for the given transfer type. This value is used to set transparency for masked pixels.- Parameters:
transferType-- Returns:
-
setColourMap
-
getColourMap
-
setFromColourModel
-
clone
public java.lang.Object clone()- Overrides:
clonein classjava.lang.Object
-
getAlphaMin
public double getAlphaMin() -
setAlphaMin
public void setAlphaMin(double alphaMin) -
getAlphaMax
public double getAlphaMax() -
setAlphaMax
public void setAlphaMax(double alphaMax) -
getAlpha
public double getAlpha() -
setAlpha
public void setAlpha(double alpha) -
getDTD
public java.lang.String getDTD()Description copied from interface:XMLObjectReturns the Data Type Declaration (DTD) for this object's XML representationSee http://en.wikipedia.org/wiki/Document_Type_Definition for a description.
-
getXMLSchema
public java.lang.String getXMLSchema()Description copied from interface:XMLObjectReturns the XML schema for this object's XML representation- Specified by:
getXMLSchemain interfaceXMLObject- Returns:
-
getXML
public java.lang.String getXML()Description copied from interface:XMLObjectReturns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)functions to write larger objects to file. -
getXML
public java.lang.String getXML(int tab)Description copied from interface:XMLObjectReturns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)functions to write larger objects to file. -
handleXMLElementStart
public void handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObjectHandles the start of an XML element.- Specified by:
handleXMLElementStartin interfaceXMLObject- Parameters:
localName- Local name of the elementattributes- Set of element attributestype- TheXMLTypeof this element- Throws:
org.xml.sax.SAXException
-
handleXMLElementEnd
public void handleXMLElementEnd(java.lang.String localName) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObjectHandles the end of an XML element.- Specified by:
handleXMLElementEndin interfaceXMLObject- Parameters:
localName- Local name of the element- Throws:
org.xml.sax.SAXException
-
handleXMLString
public void handleXMLString(java.lang.String s) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObjectHandles a string within an XML element.- Specified by:
handleXMLStringin interfaceXMLObject- Parameters:
s- String to handle- Throws:
org.xml.sax.SAXException
-
getLocalName
public java.lang.String getLocalName()Description copied from interface:XMLObjectReturns the local name associated with this XML object.- Specified by:
getLocalNamein interfaceXMLObject- Returns:
-
writeXML
public void writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format ofXMLFormat.Asciiwill be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites the XML representation of this object to file, asXMLType.Normal. The default format ofXMLFormat.Asciiwill be used. The basic contract for this method is that it should not write a newline character at its start or end. -
writeXML
public void writeXML(int tab, java.io.Writer writer) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format ofXMLFormat.Asciiwill be used. -
getShortXML
public java.lang.String getShortXML(int tab)Description copied from interface:XMLObjectReturns a short XML representation of this object.- Specified by:
getShortXMLin interfaceXMLObject- Returns:
-