Class DiscreteColourMap

java.lang.Object
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
  • Field Details

    • RANDOM_600

      public static DiscreteColourMap RANDOM_600
    • colours

      public java.util.HashMap<java.lang.Integer,​Colour> colours
    • nameMap

      public NameMap nameMap
  • Constructor Details

    • DiscreteColourMap

      public DiscreteColourMap()
    • DiscreteColourMap

      public DiscreteColourMap​(java.lang.String name)
    • DiscreteColourMap

      public DiscreteColourMap​(NameMap map)
  • Method Details

    • getObjectIcon

      public javax.swing.Icon getObjectIcon()
      Description copied from interface: IconObject
      Returns the Icon associated with this object.
      Returns:
    • getIndices

      public java.util.ArrayList<java.lang.Integer> getIndices()
    • getColour

      public Colour getColour​(java.lang.Comparable<?> o)
      Overrides:
      getColour in class ColourMap
    • getColour

      public Colour getColour​(int i)
      Overrides:
      getColour in class ColourMap
    • setColour

      public void setColour​(java.lang.String name, Colour c)
    • setColour

      public void setColour​(int i, Colour c)
    • setColour

      public void setColour​(int i, java.lang.String n, Colour c)
    • getAsContinuousMap

      public ContinuousColourMap getAsContinuousMap​(int no_anchors)
      Converts this discrete map to a continuous map by sampling at 0, N and no_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

      public void setNameMap​(NameMap map)
    • setNameMap

      public void setNameMap​(boolean b)
    • getNameMap

      public NameMap getNameMap()
    • getColour

      public Colour getColour​(java.lang.String value)
    • getRandom600

      public static DiscreteColourMap 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 size size with channels interleaved data channels. For a given colour model (e.g., RGBA), each colour component c will be represented by the index (i * 4) + c.
      Specified by:
      getDiscreteMap in class ColourMap
      setAlphaFromMax - sets the alpha value from position rather than colour map
      Returns:
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.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 the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Overrides:
      getXML in class ColourMap
      Parameters:
      tab - The number of tabs to place before the opening XML wrapper
      Returns:
    • 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 interface XMLObject
      Overrides:
      handleXMLElementStart in class ColourMap
      Parameters:
      localName - Local name of the element
      attributes - Set of element attributes
      type - The XMLType 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 interface XMLObject
      Overrides:
      handleXMLElementEnd in class ColourMap
      Parameters:
      localName - Local name of the element
    • getXMLInstance

      public static XMLObject getXMLInstance​(org.xml.sax.Attributes attributes)
    • getLayoutPanel

      public InterfaceLayoutPanel getLayoutPanel()
      Overrides:
      getLayoutPanel in class ColourMap
    • clone

      public java.lang.Object clone()
      Specified by:
      clone in class ColourMap