info.bioinfweb.jphyloio.formats.phyloxml

## Class PhyloXMLColorTranslator

- java.lang.Object
- - info.bioinfweb.jphyloio.objecttranslation.implementations.AbstractObjectTranslator<java.awt.Color>
  - - info.bioinfweb.jphyloio.formats.phyloxml.PhyloXMLColorTranslator

- All Implemented Interfaces:
    PhyloXMLConstants, ObjectTranslator<java.awt.Color>

      public class PhyloXMLColorTranslator
      extends AbstractObjectTranslator<java.awt.Color>
      implements PhyloXMLConstants

  Object translator between `Color` and the PhyloXML complex type BranchColor.
  Since:
    0.0.0
  Author:
    Sarah Wiechers, Ben Stöver

- - ### Field Summary

    - ### Fields inherited from interface info.bioinfweb.jphyloio.formats.phyloxml.PhyloXMLConstants

      `APPLIES_TO_ANNOTATION, APPLIES_TO_CLADE, APPLIES_TO_NODE, APPLIES_TO_OTHER, APPLIES_TO_PARENT_BRANCH, APPLIES_TO_PHYLOGENY, ATTR_ABSENT_COUNT, ATTR_ALT_UNIT, ATTR_APPLIES_TO, ATTR_BRANCH_LENGTH, ATTR_BRANCH_LENGTH_UNIT, ATTR_COLLAPSE, ATTR_COMMENT, ATTR_CONFIDENCE, ATTR_DATATYPE, ATTR_DESC, ATTR_DISTANCE, ATTR_DOI, ATTR_EVIDENCE, ATTR_FROM, ATTR_GAINED_COUNT, ATTR_GEO_DATUM, ATTR_ID, ATTR_ID_PROVIDER, ATTR_ID_REF, ATTR_ID_REF_0, ATTR_ID_REF_1, ATTR_ID_SOURCE, ATTR_IS_ALIGNED, ATTR_LENGTH, ATTR_LOST_COUNT, ATTR_PRESENT_COUNT, ATTR_REF, ATTR_REROOTABLE, ATTR_ROOTED, ATTR_SOURCE, ATTR_STANDARD_DEVIATION, ATTR_TO, ATTR_TYPE, ATTR_UNIT, DATA_TYPE_BRANCH_COLOR, DATA_TYPE_EVENTTYPE, DATA_TYPE_RANK, DATA_TYPE_SEQUENCE_SYMBOL, DATA_TYPE_TAXONOMY_CODE, JPHYLOIO_PHYLOXML_NAMESPACE, PHYLOXML_DATA_TYPE_NAMESPACE, PHYLOXML_DEFAULT_PRE, PHYLOXML_FORMAT_NAME, PHYLOXML_NAMESPACE, PHYLOXML_PREDICATE_NAMESPACE, PHYLOXML_SCHEMA_LOCATION_URI, PREDICATE_ANNOTATION, PREDICATE_ANNOTATION_ATTR_EVIDENCE, PREDICATE_ANNOTATION_ATTR_REF, PREDICATE_ANNOTATION_ATTR_SOURCE, PREDICATE_ANNOTATION_ATTR_TYPE, PREDICATE_ANNOTATION_CONFIDENCE, PREDICATE_ANNOTATION_CONFIDENCE_ATTR_TYPE, PREDICATE_ANNOTATION_CONFIDENCE_VALUE, PREDICATE_ANNOTATION_DESC, PREDICATE_ANNOTATION_PROPERTY, PREDICATE_ANNOTATION_PROPERTY_ATTR_APPLIES_TO, PREDICATE_ANNOTATION_PROPERTY_ATTR_DATATYPE, PREDICATE_ANNOTATION_PROPERTY_ATTR_ID_REF, PREDICATE_ANNOTATION_PROPERTY_ATTR_UNIT, PREDICATE_ANNOTATION_URI, PREDICATE_ANNOTATION_URI_ATTR_DESC, PREDICATE_ANNOTATION_URI_ATTR_TYPE, PREDICATE_ANNOTATION_URI_VALUE, PREDICATE_ATTR_COLLAPSE, PREDICATE_ATTR_ID_SOURCE, PREDICATE_BINARY_CHARACTERS, PREDICATE_BINARY_CHARACTERS_ABSENT, PREDICATE_BINARY_CHARACTERS_ABSENT_BC, PREDICATE_BINARY_CHARACTERS_ATTR_ABSENT_COUNT, PREDICATE_BINARY_CHARACTERS_ATTR_GAINED_COUNT, PREDICATE_BINARY_CHARACTERS_ATTR_LOST_COUNT, PREDICATE_BINARY_CHARACTERS_ATTR_PRESENT_COUNT, PREDICATE_BINARY_CHARACTERS_ATTR_TYPE, PREDICATE_BINARY_CHARACTERS_GAINED, PREDICATE_BINARY_CHARACTERS_GAINED_BC, PREDICATE_BINARY_CHARACTERS_LOST, PREDICATE_BINARY_CHARACTERS_LOST_BC, PREDICATE_BINARY_CHARACTERS_PRESENT, PREDICATE_BINARY_CHARACTERS_PRESENT_BC, PREDICATE_CLADE_REL, PREDICATE_CLADE_REL_ATTR_DISTANCE, PREDICATE_CLADE_REL_ATTR_IDREF0, PREDICATE_CLADE_REL_ATTR_IDREF1, PREDICATE_CLADE_REL_ATTR_TYPE, PREDICATE_COLOR, PREDICATE_COLOR_ALPHA, PREDICATE_COLOR_BLUE, PREDICATE_COLOR_GREEN, PREDICATE_COLOR_RED, PREDICATE_CONFIDENCE, PREDICATE_CONFIDENCE_ATTR_STDDEV, PREDICATE_CONFIDENCE_ATTR_TYPE, PREDICATE_CONFIDENCE_VALUE, PREDICATE_DATE, PREDICATE_DATE_ATTR_UNIT, PREDICATE_DATE_DESC, PREDICATE_DATE_MAXIMUM, PREDICATE_DATE_MINIMUM, PREDICATE_DATE_VALUE, PREDICATE_DISTRIBUTION, PREDICATE_DISTRIBUTION_DESC, PREDICATE_DISTRIBUTION_POINT, PREDICATE_DISTRIBUTION_POINT_ALT, PREDICATE_DISTRIBUTION_POINT_ATTR_ALT_UNIT, PREDICATE_DISTRIBUTION_POINT_ATTR_GEODETIC_DATUM, PREDICATE_DISTRIBUTION_POINT_LAT, PREDICATE_DISTRIBUTION_POINT_LONG, PREDICATE_DISTRIBUTION_POLYGON, PREDICATE_DISTRIBUTION_POLYGON_POINT, PREDICATE_DISTRIBUTION_POLYGON_POINT_ALT, PREDICATE_DISTRIBUTION_POLYGON_POINT_ATTR_ALT_UNIT, PREDICATE_DISTRIBUTION_POLYGON_POINT_ATTR_GEODETIC_DATUM, PREDICATE_DISTRIBUTION_POLYGON_POINT_LAT, PREDICATE_DISTRIBUTION_POLYGON_POINT_LONG, PREDICATE_DOMAIN_ARCHITECTURE, PREDICATE_DOMAIN_ARCHITECTURE_ATTR_LENGTH, PREDICATE_DOMAIN_ARCHITECTURE_DOMAIN, PREDICATE_DOMAIN_ARCHITECTURE_DOMAIN_ATTR_CONFIDENCE, PREDICATE_DOMAIN_ARCHITECTURE_DOMAIN_ATTR_FROM, PREDICATE_DOMAIN_ARCHITECTURE_DOMAIN_ATTR_ID, PREDICATE_DOMAIN_ARCHITECTURE_DOMAIN_ATTR_TO, PREDICATE_DOMAIN_ARCHITECTURE_DOMAIN_VALUE, PREDICATE_EVENTS, PREDICATE_EVENTS_CONFIDENCE, PREDICATE_EVENTS_CONFIDENCE_ATTR_TYPE, PREDICATE_EVENTS_CONFIDENCE_VALUE, PREDICATE_EVENTS_DUPLICATIONS, PREDICATE_EVENTS_LOSSES, PREDICATE_EVENTS_SPECIATIONS, PREDICATE_EVENTS_TYPE, PREDICATE_NODE_ID, PREDICATE_NODE_ID_ATTR_PROVIDER, PREDICATE_NODE_ID_VALUE, PREDICATE_PHYLOGENY_ATTR_BRANCH_LENGTH_UNIT, PREDICATE_PHYLOGENY_ATTR_REROOTABLE, PREDICATE_PHYLOGENY_ATTR_TYPE, PREDICATE_PHYLOGENY_DATE, PREDICATE_PHYLOGENY_DESCRIPTION, PREDICATE_PHYLOGENY_ID, PREDICATE_PHYLOGENY_ID_ATTR_PROVIDER, PREDICATE_PHYLOGENY_ID_VALUE, PREDICATE_PROPERTY, PREDICATE_PROPERTY_ATTR_APPLIES_TO, PREDICATE_PROPERTY_ATTR_ID_REF, PREDICATE_PROPERTY_ATTR_UNIT, PREDICATE_REFERENCE, PREDICATE_REFERENCE_ATTR_DOI, PREDICATE_REFERENCE_DESC, PREDICATE_REFERENCE_VALUE, PREDICATE_SEQ_REL, PREDICATE_SEQ_REL_ATTR_DISTANCE, PREDICATE_SEQ_REL_ATTR_IDREF0, PREDICATE_SEQ_REL_ATTR_IDREF1, PREDICATE_SEQ_REL_ATTR_TYPE, PREDICATE_SEQ_REL_CONFIDENCE, PREDICATE_SEQ_REL_CONFIDENCE_ATTR_TYPE, PREDICATE_SEQ_REL_CONFIDENCE_VALUE, PREDICATE_SEQUENCE, PREDICATE_SEQUENCE_ACCESSION, PREDICATE_SEQUENCE_ACCESSION_ATTR_COMMENT, PREDICATE_SEQUENCE_ACCESSION_ATTR_SOURCE, PREDICATE_SEQUENCE_ACCESSION_VALUE, PREDICATE_SEQUENCE_ATTR_ID_REF, PREDICATE_SEQUENCE_ATTR_TYPE, PREDICATE_SEQUENCE_CROSS_REFERENCES, PREDICATE_SEQUENCE_CROSS_REFERENCES_ACCESSION, PREDICATE_SEQUENCE_CROSS_REFERENCES_ACCESSION_ATTR_COMMENT, PREDICATE_SEQUENCE_CROSS_REFERENCES_ACCESSION_ATTR_SOURCE, PREDICATE_SEQUENCE_CROSS_REFERENCES_ACCESSION_VALUE, PREDICATE_SEQUENCE_GENE_NAME, PREDICATE_SEQUENCE_LOCATION, PREDICATE_SEQUENCE_MOL_SEQ, PREDICATE_SEQUENCE_MOL_SEQ_ATTR_IS_ALIGNED, PREDICATE_SEQUENCE_MOL_SEQ_VALUE, PREDICATE_SEQUENCE_NAME, PREDICATE_SEQUENCE_SYMBOL, PREDICATE_SEQUENCE_URI, PREDICATE_SEQUENCE_URI_ATTR_DESC, PREDICATE_SEQUENCE_URI_ATTR_TYPE, PREDICATE_SEQUENCE_URI_VALUE, PREDICATE_TAXONOMY, PREDICATE_TAXONOMY_AUTHORITY, PREDICATE_TAXONOMY_CODE, PREDICATE_TAXONOMY_COMMON_NAME, PREDICATE_TAXONOMY_ID, PREDICATE_TAXONOMY_ID_ATTR_PROVIDER, PREDICATE_TAXONOMY_ID_VALUE, PREDICATE_TAXONOMY_RANK, PREDICATE_TAXONOMY_SCIENTIFIC_NAME, PREDICATE_TAXONOMY_SYNONYM, PREDICATE_TAXONOMY_URI, PREDICATE_TAXONOMY_URI_ATTR_DESC, PREDICATE_TAXONOMY_URI_ATTR_TYPE, PREDICATE_TAXONOMY_URI_VALUE, PREDICATE_WIDTH, TAG_ABSENT, TAG_ACCESSION, TAG_ALPHA, TAG_ALT, TAG_ANNOTATION, TAG_AUTHORITY, TAG_BC, TAG_BINARY_CHARACTERS, TAG_BLUE, TAG_BRANCH_COLOR, TAG_BRANCH_LENGTH, TAG_BRANCH_WIDTH, TAG_CLADE, TAG_CLADE_RELATION, TAG_CODE, TAG_COMMON_NAME, TAG_CONFIDENCE, TAG_CROSS_REFERENCES, TAG_DATE, TAG_DESC, TAG_DESCRIPTION, TAG_DISTRIBUTION, TAG_DOMAIN, TAG_DOMAIN_ARCHITECTURE, TAG_DUPLICATIONS, TAG_EVENTS, TAG_GAINED, TAG_GENE_NAME, TAG_GREEN, TAG_ID, TAG_LAT, TAG_LOCATION, TAG_LONG, TAG_LOSSES, TAG_LOST, TAG_MAXIMUM, TAG_MINIMUM, TAG_MOL_SEQ, TAG_NAME, TAG_NODE_ID, TAG_PHYLOGENY, TAG_POINT, TAG_POLYGON, TAG_PRESENT, TAG_PROPERTY, TAG_RANK, TAG_RED, TAG_REFERENCE, TAG_ROOT, TAG_SCI_NAME, TAG_SEQUENCE, TAG_SEQUENCE_RELATION, TAG_SPECIATIONS, TAG_SYMBOL, TAG_SYNONYM, TAG_TAXONOMY, TAG_TYPE, TAG_URI, TAG_VALUE, TYPE_NETWORK_EDGE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PhyloXMLColorTranslator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Class<java.awt.Color>` | `getObjectClass()` Returns the Java class of object instances created by this translator.
    `boolean` | `hasStringRepresentation()` Determines whether the objects handled by this instance have a simple string representation or need a more complex XML representation.
    `java.lang.String` | `javaToRepresentation(java.lang.Object object, WriterStreamDataProvider<?> streamDataProvider)` Converts the specified Java object to its string representation.
    `java.awt.Color` | `readXMLRepresentation(javax.xml.stream.XMLEventReader reader, ReaderStreamDataProvider<?> streamDataProvider)` Tries to create a new instance of the handled object type from the data provided by the specified XML reader.
    `java.awt.Color` | `representationToJava(java.lang.String representation, ReaderStreamDataProvider<?> streamDataProvider)` Converts the specified string representation to a new instance of the according Java object.
    `void` | `writeXMLRepresentation(javax.xml.stream.XMLStreamWriter writer, java.lang.Object object, WriterStreamDataProvider<?> streamDataProvider)` Writes the XML representation of the specified object into the specified XML writer.

    - ### Methods inherited from class info.bioinfweb.jphyloio.objecttranslation.implementations.AbstractObjectTranslator

      `equals, hashCode`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PhyloXMLColorTranslator

          public PhyloXMLColorTranslator()

  - ### Method Detail

    - #### getObjectClass

          public java.lang.Class<java.awt.Color> getObjectClass()

      Description copied from interface: `ObjectTranslator`
      Returns the Java class of object instances created by this translator.

      Note that `ObjectTranslator.javaToRepresentation(Object, WriterStreamDataProvider)` and `ObjectTranslator.writeXMLRepresentation(XMLStreamWriter, Object, WriterStreamDataProvider)` may also accept instances of other classes. This is independent from the return value here.

      Specified by:
        `getObjectClass` in interface `ObjectTranslator<java.awt.Color>`
      Returns:
        the class of the handled objects

    - #### hasStringRepresentation

          public boolean hasStringRepresentation()

      Description copied from interface: `ObjectTranslator`
      Determines whether the objects handled by this instance have a simple string representation or need a more complex XML representation.

      Instances that return `false here` will throw an `UnsupportedOperationException`, if `ObjectTranslator.javaToRepresentation(Object, WriterStreamDataProvider)` is called.

      Specified by:
        `hasStringRepresentation` in interface `ObjectTranslator<java.awt.Color>`
      Returns:
        `true` if handled objects have a simple string representation or `false` if XML is necessary to represent the handled objects

    - #### javaToRepresentation

          public java.lang.String javaToRepresentation(java.lang.Object object,
                                                       WriterStreamDataProvider<?> streamDataProvider)
                                                throws java.lang.UnsupportedOperationException,
                                                       java.lang.ClassCastException

      Description copied from interface: `ObjectTranslator`
      Converts the specified Java object to its string representation.
      Specified by:
        `javaToRepresentation` in interface `ObjectTranslator<java.awt.Color>`
      Parameters:
        `object` - the object to be translated
        `streamDataProvider` - TODO
      Returns:
        the string representation of the object
      Throws:
        `java.lang.UnsupportedOperationException` - if objects handled by this instance can only be represented as XML
        `java.lang.ClassCastException` - if the specified object is not an instance of the supported class or does not implement the supported interface
      See Also:
        `ObjectTranslator.hasStringRepresentation()`

    - #### writeXMLRepresentation

          public void writeXMLRepresentation(javax.xml.stream.XMLStreamWriter writer,
                                             java.lang.Object object,
                                             WriterStreamDataProvider<?> streamDataProvider)
                                      throws java.io.IOException,
                                             javax.xml.stream.XMLStreamException

      Description copied from interface: `ObjectTranslator`
      Writes the XML representation of the specified object into the specified XML writer.
      Specified by:
        `writeXMLRepresentation` in interface `ObjectTranslator<java.awt.Color>`
      Parameters:
        `writer` - the writer to be used to write the XML representation
        `object` - the object to be converted
        `streamDataProvider` - TODO
      Throws:
        `java.io.IOException` - if an I/O error occurs while trying to write to the specified writer
        `javax.xml.stream.XMLStreamException` - if an XML stream exception occurs while trying to write to the specified writer

    - #### representationToJava

          public java.awt.Color representationToJava(java.lang.String representation,
                                                     ReaderStreamDataProvider<?> streamDataProvider)
                                              throws InvalidObjectSourceDataException,
                                                     java.lang.UnsupportedOperationException

      Description copied from interface: `ObjectTranslator`
      Converts the specified string representation to a new instance of the according Java object.

      If `#getClass()` returns an interface for this instance, the concrete class of the returned object may depend on the representation.

      Specified by:
        `representationToJava` in interface `ObjectTranslator<java.awt.Color>`
      Parameters:
        `representation` - the string representation of the object to be created
        `streamDataProvider` - the stream data provider of the calling reader (Maybe `null`. Some translators will use it to gain additional status information required for translating, e.g. prefix to namespace mapping for creating QNames.)
      Returns:
        the new object
      Throws:
        `InvalidObjectSourceDataException` - if the specified string representation cannot be parsed to a supported object
        `java.lang.UnsupportedOperationException` - if objects handled by this instance can only be represented as XML

    - #### readXMLRepresentation

          public java.awt.Color readXMLRepresentation(javax.xml.stream.XMLEventReader reader,
                                                      ReaderStreamDataProvider<?> streamDataProvider)
                                               throws java.io.IOException,
                                                      javax.xml.stream.XMLStreamException,
                                                      InvalidObjectSourceDataException

      Description copied from interface: `ObjectTranslator`
      Tries to create a new instance of the handled object type from the data provided by the specified XML reader.

      This method will start reading from the current position of the reader and read only as far as necessary to collect all data for the new object. Therefore the reader should be positioned before the start tag, that represents the object and will read until the according end tag was consumed. If the supported objects have a simple string representation, the reader should be positioned in front of the according characters.

      If this

      Specified by:
        `readXMLRepresentation` in interface `ObjectTranslator<java.awt.Color>`
      Parameters:
        `reader` - the XML reader providing the data to create a new object
        `streamDataProvider` - TODO
      Returns:
        the new object
      Throws:
        `java.io.IOException` - if an I/O error occurs while trying to read from the specified reader
        `javax.xml.stream.XMLStreamException` - if an XML stream exception occurs while trying to read from the specified reader
        `InvalidObjectSourceDataException` - if an unexpected XML event was encountered or an XML event has unexpected contents