Class VertexDataColumn

java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.interfaces.shapes.VertexDataColumn
All Implemented Interfaces:
java.lang.Comparable<VertexDataColumn>, AttributeListener, InterfaceObject, PopupMenuObject, NamedObject, TreeObject, CleanableObject, XMLObject, IconObject
Direct Known Subclasses:
GridVertexDataColumn

public class VertexDataColumn
extends AbstractInterfaceObject
implements java.lang.Comparable<VertexDataColumn>, AttributeListener, IconObject, XMLObject, PopupMenuObject
Encapsulates a column of vertex-wise numerical data. Allows this data column to be associated with a NameMap, a ColourMap, and a list of LinkedDataStreams.
Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • Field Details

    • data

      protected java.util.ArrayList<MguiNumber> data
    • attributes

      protected AttributeList attributes
    • linked_data

      protected java.util.HashMap<java.lang.String,​LinkedDataStream<?>> linked_data
    • listeners

      protected java.util.TreeSet<VertexDataColumnListener> listeners
    • xml_data_type

      protected java.lang.String xml_data_type
    • xml_data_encoding

      protected XMLObject.XMLEncoding xml_data_encoding
    • xml_data_size

      protected int xml_data_size
    • xml_data

      protected java.lang.String xml_data
    • xml_current_block

      protected java.lang.String xml_current_block
    • xml_current_cmap

      protected java.lang.String xml_current_cmap
    • xml_cmap_handler

      protected ColourMapXMLHandler xml_cmap_handler
    • xml_attribute_handler

      protected AttributeXMLHandler xml_attribute_handler
    • xml_nmap_handler

      protected NameMapXMLHandler xml_nmap_handler
  • Constructor Details

    • VertexDataColumn

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

      public VertexDataColumn​(java.lang.String name, java.util.ArrayList<MguiNumber> data)
  • Method Details

    • copyAttributes

      public boolean copyAttributes​(VertexDataColumn source_column)
      Copies the attributes of source_column to this column.
      Parameters:
      source_column -
      Returns:
    • getAttributes

      public AttributeList getAttributes()
    • updateDataLimits

      public void updateDataLimits()
      Updates this column's data limits based upon its current data
      Parameters:
      update -
    • updateDataLimits

      public void updateDataLimits​(boolean update)
      Updates this column's data limits based upon its current data
      Parameters:
      update - If true, fires an AttributeEvent after limits are updated
    • getObjectIcon

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

      public static javax.swing.Icon getIcon()
    • attributeUpdated

      public void attributeUpdated​(AttributeEvent e)
      Description copied from interface: AttributeListener
      Called when an Attribute's value has been updated.
      Specified by:
      attributeUpdated in interface AttributeListener
    • setFromVertexDataColumn

      public void setFromVertexDataColumn​(VertexDataColumn column)
      Set this data column to match the values, limits, and colour map of column.
      Parameters:
      column -
    • getDataMin

      public double getDataMin()
      Returns the data minimum for this column
      Returns:
    • setDataMin

      public void setDataMin​(double min)
      Sets the data minimum for this column, and fires an event.
      Parameters:
      min -
    • setDataMin

      public void setDataMin​(double min, boolean update)
      Sets the data minimum for this column; fires an event if update is true.
      Parameters:
      max -
      update -
    • setDataLimits

      public void setDataLimits​(double min, double max)
      Sets the data limits for this column; fires an event if update is true.
      Parameters:
      max -
      update -
    • setDataLimits

      public void setDataLimits​(double min, double max, boolean update)
      Sets the data limits for this column; fires an event if update is true.
      Parameters:
      max -
      update -
    • setColourLimits

      public void setColourLimits​(double min, double max)
      Sets the data limits for this column; fires an event if update is true.
      Parameters:
      max -
      update -
    • setColourLimits

      public void setColourLimits​(double min, double max, boolean update)
      Sets the colour limits for this column; fires an event if update is true.
      Parameters:
      max -
      update -
    • getDataMax

      public double getDataMax()
      Returns the data maximum for this column
      Returns:
    • setDataMax

      public void setDataMax​(double max)
      Sets the data maximum for this column, and fires an event.
      Parameters:
      max -
    • setDataMax

      public void setDataMax​(double max, boolean update)
      Sets the data maximum for this column; fires an event if update is true.
      Parameters:
      max -
      update -
    • getColourMax

      public double getColourMax()
      Returns the data maximum for this column
      Returns:
    • setColourMax

      public void setColourMax​(double max)
      Sets the data maximum for this column, and fires an event.
      Parameters:
      max -
    • setColourMax

      public void setColourMax​(double max, boolean update)
      Sets the data maximum for this column; fires an event if update is true.
      Parameters:
      max -
      update -
    • getColourMin

      public double getColourMin()
      Returns the data maximum for this column
      Returns:
    • setColourMin

      public void setColourMin​(double min)
      Sets the data maximum for this column, and fires an event.
      Parameters:
      max -
    • setColourMin

      public void setColourMin​(double min, boolean update)
      Sets the data maximum for this column; fires an event if update is true.
      Parameters:
      max -
      update -
    • addListener

      public void addListener​(VertexDataColumnListener listener)
    • removeListener

      public void removeListener​(VertexDataColumnListener listener)
    • compareTo

      public int compareTo​(VertexDataColumn column)
      Specified by:
      compareTo in interface java.lang.Comparable<VertexDataColumn>
    • getName

      public java.lang.String getName()
      Description copied from interface: NamedObject
      Gets the name for this object.
      Specified by:
      getName in interface NamedObject
      Overrides:
      getName in class AbstractInterfaceObject
      Returns:
    • setName

      public void setName​(java.lang.String name)
      Description copied from interface: NamedObject
      Sets the name for this object.
      Specified by:
      setName in interface NamedObject
      Overrides:
      setName in class AbstractInterfaceObject
    • hasNameMap

      public boolean hasNameMap()
      Returns true if this column has an associated name map
      Returns:
    • getNameMap

      public NameMap getNameMap()
      Returns the associated name map, or null if none exists.
      Returns:
    • setNameMap

      public void setNameMap​(NameMap name_map)
      Associates map with this column.
      Parameters:
      map -
    • getColourMap

      public ColourMap getColourMap()
      Returns the colour map associated with this column, or null if there is no associated colour map
      Returns:
    • setColourMap

      public void setColourMap​(ColourMap map)
      Sets the colour map associated with this column. Sets data min and data max to the limits of the colour map
      Parameters:
      map -
    • setColourMap

      public void setColourMap​(ColourMap map, double colour_min, double colour_max, boolean update)
      Sets the colour map associated with this column. Sets data min and data max to the limits of the colour map
      Parameters:
      map -
      colour_min - Sets the colour minimum
      colour_min - Sets the colour maximum
      update - Whether to fire an event to this column's listeners
    • setColourMap

      public void setColourMap​(ColourMap map, boolean update)
      Sets the colour map associated with this column. Sets data min and data max to the limits of the colour map
      Parameters:
      map -
      update - Whether to fire an event to this column's listeners
    • getDoubleValueAtVertex

      public double getDoubleValueAtVertex​(int index)
      Returns the value in this column for the vertex at index, as a double
      Parameters:
      index -
      Returns:
    • getValueAtVertex

      public MguiNumber getValueAtVertex​(int index)
      Returns the value in this column for the vertex at index, as an {link MguiDouble}
      Parameters:
      index -
      Returns:
      The value, or null if the index is out of bounds
    • getDataAsDouble

      public double[] getDataAsDouble()
      Returns the vertex-wise data as type double
      Returns:
    • setValues

      public boolean setValues​(java.util.ArrayList<MguiNumber> values)
      Sets the values for this data column.
      Parameters:
      values -
      Returns:
    • setValues

      public boolean setValues​(java.util.ArrayList<MguiNumber> values, boolean update)
      Sets the values for this data column.
      Parameters:
      values - New values for this column
      update - Whether to fire this column's listeners
      Returns:
    • setValues

      public boolean setValues​(java.util.ArrayList<MguiNumber> values, boolean update, boolean check_size)
      Sets the values for this data column.
      Parameters:
      values - New values for this column
      update - Whether to fire this column's listeners
      check_size - Whether to check the data size first; should be true unless the caller wants to perform its own check
      Returns:
    • resetDataLimits

      protected void resetDataLimits​(boolean update)
    • setDoubleValueAtVertex

      public void setDoubleValueAtVertex​(int index, double value)
      Sets the value in this column for the vertex at index
      Parameters:
      index -
      value -
    • setValueAtVertex

      public void setValueAtVertex​(int index, MguiNumber value)
      Sets the value in this column for the vertex at index
      Parameters:
      index -
      value -
    • getData

      public java.util.ArrayList<MguiNumber> getData()
      Returns the data array underlying this column. This is not a copy, so changes to this array will affect the column.
      Returns:
    • getDataTransferType

      public int getDataTransferType()
      Determines the data transfer type (as defined by DataBuffer) for this data column.
      Returns:
    • addDataLink

      public void addDataLink​(java.lang.String name, LinkedDataStream<?> stream)
      Adds a data link to this column.
      Parameters:
      name -
      stream -
    • addDataLink

      public void addDataLink​(java.lang.String name, LinkedDataStream<?> stream, boolean name_mapped)
      Adds a data link to this column.
      Parameters:
      name -
      stream -
      name_mapped - If true, and this column has a name map, name map values will be used as keys instead of the numeric ones.
    • removeDataLink

      public void removeDataLink​(java.lang.String name)
      Removes the data link specified by name from this column
      Parameters:
      name -
    • fireDataColumnChanged

      protected void fireDataColumnChanged​(VertexDataColumnEvent event)
    • fireDataColumnColourMapChanged

      protected void fireDataColumnColourMapChanged​(VertexDataColumnEvent event)
    • getLinkedDataNames

      public java.util.ArrayList<java.lang.String> getLinkedDataNames()
      Returns a list of names for all data linked to this column
      Returns:
    • getLinkedData

      public LinkedDataStream<?> getLinkedData​(java.lang.String name)
      Returns a LinkedDataStream specified by name
      Parameters:
      name -
      Returns:
    • isNameMapped

      public boolean isNameMapped​(java.lang.String name)
      Returns true if the data link specified by name has an associated name map.
      Parameters:
      name -
      Returns:
    • setTreeNode

      public void setTreeNode​(InterfaceTreeNode treeNode)
      Description copied from interface: TreeObject
      Sets the children for this node's InterfaceTreeNode.
      Specified by:
      setTreeNode in interface TreeObject
      Overrides:
      setTreeNode in class AbstractInterfaceObject
    • getTreeLabel

      public java.lang.String getTreeLabel()
      Description copied from interface: TreeObject
      Returns the label text to appear in a tree node.
      Specified by:
      getTreeLabel in interface TreeObject
      Overrides:
      getTreeLabel in class AbstractInterfaceObject
      Returns:
    • getDTD

      public java.lang.String getDTD()
      Description copied from interface: XMLObject
      Returns the Data Type Declaration (DTD) for this object's XML representation

      See http://en.wikipedia.org/wiki/Document_Type_Definition for a description.

      Specified by:
      getDTD in interface XMLObject
      Returns:
    • getXMLSchema

      public java.lang.String getXMLSchema()
      Description copied from interface: XMLObject
      Returns the XML schema for this object's XML representation

      See http://en.wikipedia.org/wiki/XML_schema.

      Specified by:
      getXMLSchema in interface XMLObject
      Returns:
    • getXML

      public java.lang.String getXML()
      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
      Returns:
    • 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
      Parameters:
      tab - The number of tabs to place before the opening XML wrapper
      Returns:
    • handleXMLElementStart

      public void handleXMLElementStart​(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type) throws org.xml.sax.SAXException
      Description copied from interface: XMLObject
      Handles the start of an XML element.
      Specified by:
      handleXMLElementStart in interface XMLObject
      Parameters:
      localName - Local name of the element
      attributes - Set of element attributes
      type - The XMLType of this element
      Throws:
      org.xml.sax.SAXException
    • handleXMLElementEnd

      public void handleXMLElementEnd​(java.lang.String localName) throws org.xml.sax.SAXException
      Description copied from interface: XMLObject
      Handles the end of an XML element.
      Specified by:
      handleXMLElementEnd in interface XMLObject
      Parameters:
      localName - Local name of the element
      Throws:
      org.xml.sax.SAXException
    • handleXMLString

      public void handleXMLString​(java.lang.String s) throws org.xml.sax.SAXException
      Description copied from interface: XMLObject
      Handles a string within an XML element.
      Specified by:
      handleXMLString in interface XMLObject
      Parameters:
      s - String to handle
      Throws:
      org.xml.sax.SAXException
    • getLocalName

      public java.lang.String getLocalName()
      Description copied from interface: XMLObject
      Returns the local name associated with this XML object.
      Specified by:
      getLocalName in interface XMLObject
      Returns:
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes 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 of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      options - XMLOutputOptions defining the write parameters
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file, as XMLType.Normal. The default format of XMLFormat.Ascii will be used. The basic contract for this method is that it should not write a newline character at its start or end.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes 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 of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      Throws:
      java.io.IOException
    • getShortXML

      public java.lang.String getShortXML​(int tab)
      Description copied from interface: XMLObject
      Returns a short XML representation of this object.
      Specified by:
      getShortXML in interface XMLObject
      Returns:
    • writeBinaryData

      protected void writeBinaryData​(java.io.Writer writer, int tab, int compress) throws java.io.IOException
      Writes this vertex column's data as Base64 binary.
      Parameters:
      tab -
      compress - ; compression: 0 = none, 1 = zipped; 2 = gzipped
      Throws:
      java.io.IOException
    • writeAsciiData

      protected void writeAsciiData​(java.io.Writer writer, int tab, int line_size, int sig_digits) throws java.io.IOException
      Writes this vertex column's data as Ascii
      Parameters:
      tab -
      compress - ; compression: 0 = none, 1 = zipped; 2 = gzipped
      Throws:
      java.io.IOException
    • loadBinaryData

      protected void loadBinaryData​(java.lang.String string_data, int compression)
      Load vertices from Base64 binary encoded data.
      Parameters:
      string_data -
      compression - Compression; 0 for none, 1 for zip, 2 for gzip
    • loadAsciiData

      protected void loadAsciiData​(java.lang.String string_data)
      Load vertices from Ascii encoded data
      Parameters:
      string_data -
    • getPopupMenu

      public InterfacePopupMenu getPopupMenu()
      Description copied from interface: PopupMenuObject
      Produces and returns a popup menu for this object.
      Specified by:
      getPopupMenu in interface PopupMenuObject
      Returns:
    • getPopupMenu

      public InterfacePopupMenu getPopupMenu​(java.util.List<java.lang.Object> selection)
      Description copied from interface: PopupMenuObject
      Produces and returns a popup menu for this object. Allows an associated list of objects to be passed as an argument.
      Specified by:
      getPopupMenu in interface PopupMenuObject
      Returns:
    • handlePopupEvent

      public void handlePopupEvent​(java.awt.event.ActionEvent e)
      Description copied from interface: PopupMenuObject
      Handles an event on this object's popup menu.
      Specified by:
      handlePopupEvent in interface PopupMenuObject
    • showPopupMenu

      public void showPopupMenu​(java.awt.event.MouseEvent e)
      Description copied from interface: PopupMenuObject
      Shows a popup menu at the point of the given MouseEvent.
      Specified by:
      showPopupMenu in interface PopupMenuObject