Package mgui.interfaces.maps
Class DiscreteColourMap
java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.interfaces.maps.ColourMap
mgui.interfaces.maps.DiscreteColourMap
- All Implemented Interfaces:
java.lang.Cloneable
,InterfaceObject
,NamedObject
,TreeObject
,CleanableObject
,XMLObject
,IconObject
public class DiscreteColourMap extends ColourMap
Colour map for discrete 1-to-1 mappings (integers to colours).
- 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 java.util.HashMap<java.lang.Integer,Colour>
colours
NameMap
nameMap
static DiscreteColourMap
RANDOM_600
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 DiscreteColourMap()
DiscreteColourMap(java.lang.String name)
DiscreteColourMap(NameMap map)
-
Method Summary
Modifier and Type Method Description java.lang.Object
clone()
ContinuousColourMap
getAsContinuousMap(int no_anchors)
Converts this discrete map to a continuous map by sampling at 0, N andno_anchors
- 2 evenly-spaced indices.Colour
getColour(int i)
Colour
getColour(java.lang.Comparable<?> o)
Colour
getColour(java.lang.String value)
byte[]
getDiscreteMap(int max_size, int channels, boolean setAlphaFromMax)
Compile and return a discrete colour map of sizesize
withchannels
interleaved data channels.java.util.HashMap<java.lang.Integer,java.lang.Integer>
getIndexMap()
Returns a mapping from the index values of this discrete colour map to the byte map indices return by getDiscreteMap(int,int,boolean).java.util.ArrayList<java.lang.Integer>
getIndices()
InterfaceLayoutPanel
getLayoutPanel()
int
getMax()
Returns the maximum value in this map's indicesint
getMin()
Returns the minimum value in this map's indicesNameMap
getNameMap()
javax.swing.Icon
getObjectIcon()
Returns theIcon
associated with this object.static DiscreteColourMap
getRandom600()
java.lang.String
getShortXML(int tab)
Returns a short XML representation of this object.int
getSize()
java.lang.String
getXML(int tab)
Returns this object's XML representation as a single string.static 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.boolean
hasNameMap()
void
setColour(int i, java.lang.String n, Colour c)
void
setColour(int i, Colour c)
void
setColour(java.lang.String name, Colour c)
void
setNameMap(boolean b)
void
setNameMap(NameMap map)
java.lang.String
toString()
Methods inherited from class mgui.interfaces.maps.ColourMap
getColor3fArray, getColor3fArray, getColor4fArray, getColor4fArray, getColour, getColour, getDiscreteMap, getDTD, 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
-
RANDOM_600
-
colours
-
nameMap
-
-
Constructor Details
-
DiscreteColourMap
public DiscreteColourMap() -
DiscreteColourMap
public DiscreteColourMap(java.lang.String name) -
DiscreteColourMap
-
-
Method Details
-
getObjectIcon
public javax.swing.Icon getObjectIcon()Description copied from interface:IconObject
Returns theIcon
associated with this object.- Returns:
-
getIndices
public java.util.ArrayList<java.lang.Integer> getIndices() -
getColour
-
getColour
-
setColour
-
setColour
-
setColour
-
getAsContinuousMap
Converts this discrete map to a continuous map by sampling at 0, N andno_anchors
- 2 evenly-spaced indices. The discrete map should be a discretized continuous map for this to make sense.- Parameters:
no_anchors
-- Returns:
-
hasNameMap
public boolean hasNameMap() -
setNameMap
-
setNameMap
public void setNameMap(boolean b) -
getNameMap
-
getColour
-
getRandom600
-
getMax
public int getMax()Returns the maximum value in this map's indices- Returns:
-
getMin
public int getMin()Returns the minimum value in this map's indices- Returns:
-
getSize
public int getSize() -
getIndexMap
public java.util.HashMap<java.lang.Integer,java.lang.Integer> getIndexMap()Returns a mapping from the index values of this discrete colour map to the byte map indices return by getDiscreteMap(int,int,boolean).- Returns:
-
getDiscreteMap
public byte[] getDiscreteMap(int max_size, int channels, boolean setAlphaFromMax)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
setAlphaFromMax
- sets the alpha value from position rather than colour map- Returns:
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
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:
-
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
-
getXMLInstance
-
getLayoutPanel
- Overrides:
getLayoutPanel
in classColourMap
-
clone
public java.lang.Object clone()
-