de.lmu.ifi.dbs.elki.visualization.css
Class CSSClassManager

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.visualization.css.CSSClassManager

public class CSSClassManager
extends Object

Manager class to track CSS classes used in a particular SVG document.


Nested Class Summary
 class CSSClassManager.CSSNamingConflict
          Class to signal a CSS naming conflict.
 
Field Summary
private  HashMap<String,CSSClass> store
          Store the contained CSS classes.
 
Constructor Summary
CSSClassManager()
           
 
Method Summary
 CSSClass addClass(CSSClass clss)
          Add a single class to the map.
 boolean contains(String name)
          Check if a name is already used in the classes.
 CSSClass getClass(String name)
          Retrieve a single class by name only
 CSSClass getClass(String name, Object owner)
          Retrieve a single class by name and owner
 Collection<CSSClass> getClasses()
          Get all CSS classes in this manager.
 Element makeStyleElement(Document document)
          Make a (filled) CSS style element for the given document.
 boolean mergeCSSFrom(CSSClassManager other)
          Merge CSS classes, for example to merge two plots.
 void removeClass(CSSClass clss)
          Remove a single CSS class from the map.
 void serialize(StringBuffer buf)
          Serialize managed CSS classes to rule file.
 boolean testMergeable(CSSClassManager other)
          Check whether or not CSS classes of two plots can be merged
 void updateStyleElement(Document document, Element style)
          Update the text contents of an existing style element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

store

private HashMap<String,CSSClass> store
Store the contained CSS classes.

Constructor Detail

CSSClassManager

public CSSClassManager()
Method Detail

addClass

public CSSClass addClass(CSSClass clss)
                  throws CSSClassManager.CSSNamingConflict
Add a single class to the map.

Parameters:
clss - new CSS class
Returns:
existing (old) class
Throws:
CSSClassManager.CSSNamingConflict - when a class of the same name but different owner object exists.

removeClass

public void removeClass(CSSClass clss)
Remove a single CSS class from the map. Note that classes are removed by reference, not by name!

Parameters:
clss - Class to remove

getClass

public CSSClass getClass(String name,
                         Object owner)
                  throws CSSClassManager.CSSNamingConflict
Retrieve a single class by name and owner

Parameters:
name - Class name
owner - Class owner
Returns:
existing (old) class
Throws:
CSSClassManager.CSSNamingConflict - if an owner was specified and doesn't match

getClass

public CSSClass getClass(String name)
Retrieve a single class by name only

Parameters:
name - CSS class name
Returns:
existing (old) class

contains

public boolean contains(String name)
Check if a name is already used in the classes.

Parameters:
name - CSS class name
Returns:
true if the class name is already used.

serialize

public void serialize(StringBuffer buf)
Serialize managed CSS classes to rule file.

Parameters:
buf - String buffer

getClasses

public Collection<CSSClass> getClasses()
Get all CSS classes in this manager.

Returns:
CSS classes.

testMergeable

public boolean testMergeable(CSSClassManager other)
Check whether or not CSS classes of two plots can be merged

Parameters:
other - Other class
Returns:
true if able to merge

mergeCSSFrom

public boolean mergeCSSFrom(CSSClassManager other)
                     throws CSSClassManager.CSSNamingConflict
Merge CSS classes, for example to merge two plots.

Parameters:
other - Other class to merge with
Returns:
success code
Throws:
CSSClassManager.CSSNamingConflict - If there is a naming conflict.

updateStyleElement

public void updateStyleElement(Document document,
                               Element style)
Update the text contents of an existing style element.

Parameters:
document - Document element (factory)
style - Style element

makeStyleElement

public Element makeStyleElement(Document document)
Make a (filled) CSS style element for the given document.

Parameters:
document - Document
Returns:
Style element

Release 0.4.0 (2011-09-20_1324)