Package mgui.interfaces.maps
Class ContinuousColourMap
java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.interfaces.maps.ColourMap
mgui.interfaces.maps.ContinuousColourMap
- All Implemented Interfaces:
java.lang.Cloneable
,InterfaceObject
,NamedObject
,TreeObject
,CleanableObject
,XMLObject
,IconObject
- Direct Known Subclasses:
Vector3ColourMap
public class ContinuousColourMap extends ColourMap
Maps colours to values based upon a set of anchors (expressed on the range [0:1]) and an interpolator.
- Since:
- 1.0 TODO: allow specific colour models; currently is 4-channel RGBA only
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ContinuousColourMap.Anchor
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType
-
Field Summary
Fields Modifier and Type Field Description java.util.ArrayList<ContinuousColourMap.Anchor>
anchors
static ContinuousColourMap
DEFAULT_2
static ContinuousColourMap
DEFAULT_3
static ContinuousColourMap
GREY_SCALE
protected boolean
xml_anchors_failed
protected boolean
xml_in_anchors
Fields inherited from class mgui.interfaces.maps.ColourMap
name, nullColour
Fields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes
-
Constructor Summary
Constructors Constructor Description ContinuousColourMap()
ContinuousColourMap(java.lang.String name)
-
Method Summary
Modifier and Type Method Description int
addAnchor(double value, Colour colour)
int
addAnchor(MguiNumber value, Colour colour)
java.lang.Object
clone()
int
getAnchor(double val, float radius)
org.jogamp.vecmath.Color4f[]
getColor4fArray(java.util.ArrayList<MguiNumber> list, double min, double max)
Get an array of colours for the given list of values, given the specified limits.Colour
getColour(double d, double min, double max)
Get colour for the specified value, given the specified limits.Colour
getColour(int i)
Colour
getColour(java.lang.Comparable o)
protected Colour
getColourAtValue(double n)
protected Colour
getColourAtValue(double n, double min, double max)
protected Colour
getColourAtValue(MguiNumber n)
protected Colour
getColourAtValue(MguiNumber n, double min, double max)
static ContinuousColourMap
getDefault2()
static ContinuousColourMap
getDefault3()
byte[]
getDiscreteMap(int size, int channels, boolean setAlphaFromPos)
Compile and return a discrete colour map of sizesize
withchannels
interleaved data channels.static ContinuousColourMap
getGreyScale()
protected double
getInterpolation(MguiNumber n1, MguiNumber n2, MguiNumber a3)
javax.swing.Icon
getObjectIcon()
Returns theIcon
associated with this object.java.lang.String
getShortXML(int tab)
Returns a short XML representation of this object.java.lang.String
getXML(int tab)
Returns this object's XML representation as a single string.XMLObject
getXMLInstance(org.xml.sax.Attributes attributes)
void
handleXMLElementEnd(java.lang.String localName)
Handles the end of an XML element.void
handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)
Handles the start of an XML element.protected MguiNumber
normalize(MguiNumber n, double mn, double mx)
void
removeAnchor(int anchor)
void
removeAnchors(MguiNumber min, MguiNumber max)
Remove all anchor points between min and maxvoid
resort()
void
setFromMap(ContinuousColourMap map)
Set this map frommap
.java.lang.String
toString()
Methods inherited from class mgui.interfaces.maps.ColourMap
getColor3fArray, getColor3fArray, getColor4fArray, getColour, getDiscreteMap, getDTD, getLayoutPanel, getLocalName, getName, getXML, getXMLSchema, handleXMLString, printToConsole, setName, writeXML, writeXML, writeXML
Methods inherited from class mgui.interfaces.AbstractInterfaceObject
clean, destroy, getTreeLabel, isDestroyed, issueTreeNode, setTreeNode, updateTreeNodes
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
DEFAULT_2
-
DEFAULT_3
-
GREY_SCALE
-
anchors
-
xml_in_anchors
protected boolean xml_in_anchors -
xml_anchors_failed
protected boolean xml_anchors_failed
-
-
Constructor Details
-
ContinuousColourMap
public ContinuousColourMap() -
ContinuousColourMap
public ContinuousColourMap(java.lang.String name)
-
-
Method Details
-
getObjectIcon
public javax.swing.Icon getObjectIcon()Description copied from interface:IconObject
Returns theIcon
associated with this object.- Returns:
-
setFromMap
Set this map frommap
.- Parameters:
map
-
-
getDefault2
-
getDefault3
-
getGreyScale
-
getColour
-
getColour
-
getColour
Description copied from class:ColourMap
Get colour for the specified value, given the specified limits. -
addAnchor
-
addAnchor
-
removeAnchors
Remove all anchor points between min and max- Parameters:
min
-max
-
-
removeAnchor
public void removeAnchor(int anchor) -
getAnchor
public int getAnchor(double val, float radius) -
resort
public void resort() -
getColor4fArray
public org.jogamp.vecmath.Color4f[] getColor4fArray(java.util.ArrayList<MguiNumber> list, double min, double max)Description copied from class:ColourMap
Get an array of colours for the given list of values, given the specified limits.- Overrides:
getColor4fArray
in classColourMap
- Returns:
-
getColourAtValue
-
getColourAtValue
-
getColourAtValue
-
getColourAtValue
-
normalize
-
getInterpolation
-
getDiscreteMap
public byte[] getDiscreteMap(int size, int channels, boolean setAlphaFromPos)Description copied from class:ColourMap
Compile and return a discrete colour map of sizesize
withchannels
interleaved data channels. For a given colour model (e.g., RGBA), each colour componentc
will be represented by the index(i * 4) + c
.- Specified by:
getDiscreteMap
in classColourMap
setAlphaFromPos
- sets the alpha value from position rather than colour map- Returns:
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
clone
public java.lang.Object clone() -
getXML
public java.lang.String getXML(int tab)Description copied from interface:XMLObject
Returns 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. -
getShortXML
public java.lang.String getShortXML(int tab)Description copied from interface:XMLObject
Returns a short XML representation of this object.- Returns:
-
getXMLInstance
-
handleXMLElementStart
public void handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)Description copied from interface:XMLObject
Handles the start of an XML element.- Specified by:
handleXMLElementStart
in interfaceXMLObject
- Overrides:
handleXMLElementStart
in classColourMap
- Parameters:
localName
- Local name of the elementattributes
- Set of element attributestype
- TheXMLType
of this element
-
handleXMLElementEnd
public void handleXMLElementEnd(java.lang.String localName)Description copied from interface:XMLObject
Handles the end of an XML element.- Specified by:
handleXMLElementEnd
in interfaceXMLObject
- Overrides:
handleXMLElementEnd
in classColourMap
- Parameters:
localName
- Local name of the element
-