Package elki.visualization.css
Class CSSClassManager
- java.lang.Object
-
- elki.visualization.css.CSSClassManager
-
public class CSSClassManager extends java.lang.ObjectManager class to track CSS classes used in a particular SVG document.- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCSSClassManager.CSSNamingConflictClass to signal a CSS naming conflict.
-
Constructor Summary
Constructors Constructor Description CSSClassManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CSSClassaddClass(CSSClass clss)Add a single class to the map.booleancontains(java.lang.String name)Check if a name is already used in the classes.CSSClassgetClass(java.lang.String name)Retrieve a single class by name onlyCSSClassgetClass(java.lang.String name, java.lang.Object owner)Retrieve a single class by name and ownerjava.util.Collection<CSSClass>getClasses()Get all CSS classes in this manager.org.w3c.dom.ElementmakeStyleElement(org.w3c.dom.Document document)Make a (filled) CSS style element for the given document.booleanmergeCSSFrom(CSSClassManager other)Merge CSS classes, for example to merge two plots.voidremoveClass(CSSClass clss)Remove a single CSS class from the map.voidserialize(java.lang.StringBuilder buf)Serialize managed CSS classes to rule file.booleantestMergeable(CSSClassManager other)Check whether or not CSS classes of two plots can be mergedvoidupdateStyleElement(org.w3c.dom.Document document, org.w3c.dom.Element style)Update the text contents of an existing style element.
-
-
-
Field Detail
-
store
private java.util.HashMap<java.lang.String,CSSClass> store
Store the contained CSS classes.
-
-
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(java.lang.String name, java.lang.Object owner) throws CSSClassManager.CSSNamingConflict
Retrieve a single class by name and owner- Parameters:
name- Class nameowner- Class owner- Returns:
- existing (old) class
- Throws:
CSSClassManager.CSSNamingConflict- if an owner was specified and doesn't match
-
getClass
public CSSClass getClass(java.lang.String name)
Retrieve a single class by name only- Parameters:
name- CSS class name- Returns:
- existing (old) class
-
contains
public boolean contains(java.lang.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(java.lang.StringBuilder buf)
Serialize managed CSS classes to rule file.- Parameters:
buf- String buffer
-
getClasses
public java.util.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(org.w3c.dom.Document document, org.w3c.dom.Element style)Update the text contents of an existing style element.- Parameters:
document- Document element (factory)style- Style element
-
makeStyleElement
public org.w3c.dom.Element makeStyleElement(org.w3c.dom.Document document)
Make a (filled) CSS style element for the given document.- Parameters:
document- Document- Returns:
- Style element
-
-