Class GPML2013aFormatAbstract

java.lang.Object
org.pathvisio.libgpml.model.GPMLFormatAbstract
org.pathvisio.libgpml.model.GPML2013aFormatAbstract
Direct Known Subclasses:
GPML2013aReader, GPML2013aWriter

public abstract class GPML2013aFormatAbstract
extends GPMLFormatAbstract
Abstract class for GPML2013a format. Contains static properties and methods used in reading or writing GPML2013a.
Author:
finterly
  • Field Details

  • Constructor Details

    • GPML2013aFormatAbstract

      protected GPML2013aFormatAbstract​(java.lang.String xsdFile, org.jdom2.Namespace nsGPML)
      Constructor for GPML2013aFormat Abstract.
      Parameters:
      xsdFile - the schema file.
      nsGPML - the GPML namespace.
  • Method Details

    • toCamelCase

      protected java.lang.String toCamelCase​(java.lang.String str) throws ConverterException
      Converts shapeType String to UpperCamelCase convention. In GPML2013a, naming convention was inconsistent. Moving forward, enum types strings are all in UpperCamelCase.
      Parameters:
      str - the string.
      Returns:
      the string in camelCase format, or string as it was.
      Throws:
      ConverterException
    • fromCamelCase

      protected java.lang.String fromCamelCase​(java.lang.String str) throws ConverterException
      Converts shapeType String from UpperCamelCase convention back to its original appearance in GPML2013a.
      Parameters:
      str - the string.
      Returns:
      the string in its original format.
      Throws:
      ConverterException
    • getInteractionPanelType

      protected ArrowHeadType getInteractionPanelType​(java.lang.String arrowHeadStr) throws ConverterException
      Returns the GPML2021 Interaction Panel arrow head type for given GPML2013a arrowHead type string.
      Parameters:
      arrowHeadStr - the string for GPML2013a arrow head type.
      Returns:
      arrowHead the interaction panel arrow head type which corresponds to arrowHeadStr, or null if no corresponding type exists.
      Throws:
      ConverterException
    • getArrowHeadTypeStr

      protected java.lang.String getArrowHeadTypeStr​(ArrowHeadType arrowHead) throws ConverterException
      Returns the prioritized GPML2013a arrowHead type string for given GPML2021 Interaction Panel arrow head type.
      Parameters:
      arrowHead - the interaction panel arrow head type for GPML2021e.
      Returns:
      the first GPML2013a arrow head which corresponds to the interaction panel arrow head type, or null if no corresponding type exists.
      Throws:
      ConverterException
    • initAttributeInfo

      private static java.util.Map<java.lang.String,​GPML2013aFormatAbstract.AttributeInfo> initAttributeInfo()
      The Map initAttributeInfo maps String tag to GPML2013aFormatAbstract.AttributeInfo. For GPML2013a reading/writing, we often use getAttr(java.lang.String, java.lang.String, org.jdom2.Element) and setAttr(java.lang.String, java.lang.String, org.jdom2.Element, java.lang.String) in place of standard jdom methods Element.getAttributeValue(java.lang.String) and Element.setAttribute(java.lang.String, java.lang.String) respectively. If an attribute is null when reading, its default value is fetched from this map. When writing, if trying to set a default value or an optional value to null, the attribute is omitted which results in a leaner xml output. This map defines custom default values not in the GPML2013a schema such as default "Label.Graphics@FillColor" as "Transparent". We do not do this for GPML2021 as it can be confusing to have custom reading/writing resulting in xml which do not adhere to the schema.
      Returns:
    • getAttributeInfo

      protected java.util.Map<java.lang.String,​GPML2013aFormatAbstract.AttributeInfo> getAttributeInfo()
      Returns Map ATTRIBUTE_INFO collection that contains String as key and GPML2013aFormatAbstract.AttributeInfo as value.
    • isEqualsString

      private boolean isEqualsString​(java.lang.String def, java.lang.String value)
      Returns true if given string value and default value are equal.
      Parameters:
      def - the default string.
      value - the given string.
      Returns:
      true if the specified arguments are equal, or both null.
    • isEqualsNumber

      private boolean isEqualsNumber​(java.lang.String def, java.lang.String value)
      Returns true if given string value and default value are numerically equal.
      Parameters:
      def - the string for default number value.
      value - the string for given number value.
      Returns:
      true if absolute value of difference between def and value is less than 1e-6, and false otherwise.
    • isEqualsColor

      private boolean isEqualsColor​(java.lang.String def, java.lang.String value)
      Returns true if given value and default value are the same color object.
      Parameters:
      def - the string for default color object.
      value - the string for given color object.
      Returns:
      true if color is equal, false otherwise.
    • setAttr

      protected void setAttr​(java.lang.String tag, java.lang.String name, org.jdom2.Element el, java.lang.String value) throws ConverterException
      Sets a certain attribute value, performs a basic check for some types, and throws an exception if trying to set an invalid value. If trying to set a default value or an optional value to null, the attribute is omitted, which results in a leaner xml output. This customized method is often used in place of Element.setAttribute(java.lang.String, java.lang.String) for writing GPML2013a.
      Parameters:
      tag - used for lookup in the defaults table.
      name - used for lookup in the defaults table.
      el - jdom element where this attribute belongs in.
      value - value you want to check and set.
      Throws:
      ConverterException - if value invalid.
    • getAttr

      protected java.lang.String getAttr​(java.lang.String tag, java.lang.String name, org.jdom2.Element el) throws ConverterException
      Gets a certain attribute value, and replaces it with a suitable default under certain conditions. This customized method is often used in place of Element.getAttributeValue(java.lang.String) for reading GPML2013a.
      Parameters:
      tag - used for lookup in the defaults table.
      name - used for lookup in the defaults table.
      el - jdom element to get the attribute from.
      Throws:
      ConverterException - if getAttributeInfo() does not contain a mapping for the specified key.