http://www.jpicedt.org

jpicedt.graphic.io.formatter
Class XmlAttributeSet

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,String>
          extended by jpicedt.graphic.io.formatter.XmlAttributeSet
All Implemented Interfaces:
Serializable, Cloneable, Map<String,String>

public class XmlAttributeSet
extends HashMap<String,String>

A map that contains XML-like name=value pairs, to be ultimately formatted as XML. With respect to jpicedt.graphic.element.AttributeSet, this is more XML-oriented, and not all attributes contained in AttributeSet are included in this map so as to reduce the size of the ultimate StringBuffer. In comparison with the older scheme, where we would directly append succesive XML-formatted name=value pairs to the main StringBuffer, this offers the benefit of avoiding redundant definition of XML parameters, which XML strictly forbids.

Since:
jpicedt 1.4.pre5
Author:
Sylvain Reynal
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
XmlAttributeSet()
          Constructs an empty map
 
Method Summary
protected  String colorToHex(Color c)
          Convert the given Color to a XML-like RGB string, each colour being expressed in the hexadecimal radix
protected  void putCommonAttributes(Element obj)
          Fills the given map with XML-like entries (name->value will translate into name="value" once text formatted) for common attributes of the given Element, that is, attributes specific to a given subclass of Element are not included here, but should be handled directly by the appropriate formatter.
protected
<T> void
putNameValuePair(PicAttributeName<T> name, PicAttributeSet set)
          Given an attribute name and an attribute set, retrieve the value associated with the given name in the set, compares it with the default value, and add a name/value entry to the given map if they differ.
protected  void putNameValuePair(String name, boolean bol)
          Given attribute name and value, append a name/value entry to the given map.
protected  void putNameValuePair(String name, Color col, Color def)
          Given attribute name and value, append a name/value entry to the given map if value differs from the given default value.
protected  void putNameValuePair(String name, double value)
          Given attribute name and value, append a name/value entry to the given map.
protected  void putNameValuePair(String name, double[] values)
          Given attribute name and an array of doubles, append a name/value entry to the given map.
protected  void putNameValuePair(String name, double value, double def)
          Given attribute name and value, append a name/value entry to the given map if value differs from the given default value.
protected  void putNameValuePair(String name, PicPoint pt)
          Given attribute name and value, append a name/value entry to the given map
protected  void putNameValuePair(String name, PicPoint[] values)
          Given attribute name and an array of PicPoint's, append a name/value entry to the given map.
protected  void putNameValuePair(String name, String value)
          Given attribute name and value, append a name/value entry to the given map.
protected  StringBuffer toXML()
          Returns a buffer constructed by iterating over the entries in this and appending a name="value" string to the buffer for each attribute.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

XmlAttributeSet

public XmlAttributeSet()
Constructs an empty map

Method Detail

toXML

protected StringBuffer toXML()
Returns a buffer constructed by iterating over the entries in this and appending a name="value" string to the buffer for each attribute.


putCommonAttributes

protected void putCommonAttributes(Element obj)
Fills the given map with XML-like entries (name->value will translate into name="value" once text formatted) for common attributes of the given Element, that is, attributes specific to a given subclass of Element are not included here, but should be handled directly by the appropriate formatter.

Attributes handled in this method include stroke-, fill-, shadow- and double-line attributes, as well as arrows, and are appended only if they differ from the default value in PicAttributeSet. See documentation on top of this class for details on the JPIC-XML syntax.

Not supported yet : "border" and "bordercolor"


putNameValuePair

protected <T> void putNameValuePair(PicAttributeName<T> name,
                                    PicAttributeSet set)
Given an attribute name and an attribute set, retrieve the value associated with the given name in the set, compares it with the default value, and add a name/value entry to the given map if they differ.


putNameValuePair

protected void putNameValuePair(String name,
                                String value)
Given attribute name and value, append a name/value entry to the given map.


putNameValuePair

protected void putNameValuePair(String name,
                                Color col,
                                Color def)
Given attribute name and value, append a name/value entry to the given map if value differs from the given default value.


putNameValuePair

protected void putNameValuePair(String name,
                                boolean bol)
Given attribute name and value, append a name/value entry to the given map.


putNameValuePair

protected void putNameValuePair(String name,
                                PicPoint pt)
Given attribute name and value, append a name/value entry to the given map


putNameValuePair

protected void putNameValuePair(String name,
                                double value)
Given attribute name and value, append a name/value entry to the given map. double are formatted with two-digit precision.


putNameValuePair

protected void putNameValuePair(String name,
                                double value,
                                double def)
Given attribute name and value, append a name/value entry to the given map if value differs from the given default value. double are formatted with two-digit precision.


putNameValuePair

protected void putNameValuePair(String name,
                                double[] values)
Given attribute name and an array of doubles, append a name/value entry to the given map. doubles are formatted with two-digit precision, and are separated by semicolons.


putNameValuePair

protected void putNameValuePair(String name,
                                PicPoint[] values)
Given attribute name and an array of PicPoint's, append a name/value entry to the given map. Points are formatted by means of their toString() method, and are separated by semicolons.


colorToHex

protected String colorToHex(Color c)
Convert the given Color to a XML-like RGB string, each colour being expressed in the hexadecimal radix


http://www.jpicedt.org

Submit a bug : syd@jpicedt.org