java.lang.Object
org.jhotdraw8.css.model.AbstractSelectorModel<Element>
org.jhotdraw8.css.model.DocumentSelectorModel
- All Implemented Interfaces:
SelectorModel<Element>
DocumentSelectorModel provides an API for CSS
SelectorGroup's.- Author:
- Werner Randelshofer
-
Property Summary
Properties inherited from class org.jhotdraw8.css.model.AbstractSelectorModel
additionalPseudoClassStates -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanattributeValueStartsWith(@NonNull Element element, @Nullable String namespacePattern, @NonNull String attributeName, @NonNull String substring) Returns true if the element has an attribute with the specified name and the attribute value starts with the specified substring.getAttribute(@NonNull Element element, @Nullable javafx.css.StyleOrigin origin, @Nullable String namespacePattern, @NonNull String name) Returns the attribute value with the given name from the specified style origin.getAttributeAsString(@NonNull Element element, @Nullable String namespacePattern, @NonNull String attributeName) Returns the attribute value with the given name from the USER style origin.getAttributeAsString(@NonNull Element elem, javafx.css.StyleOrigin origin, @Nullable String namespacePattern, @NonNull String name) Returns the attribute value with the given name from the specified style origin.getAttributeNames(@NonNull Element element) Returns all styleable attributes of the element.getComposedAttributeNames(@NonNull Element element) Returns all non-decomposed styleable attributes of the element.getDecomposedAttributeNames(@NonNull Element element) Returns all decomposed styleable attributes of the element.Returns the id of the element.Gets the parent of the element.getPreviousSibling(@NonNull Element element) Gets the previous sibling of the element.getPseudoClasses(@NonNull Element elem) Returns the pseudo classes of the element.getStyleClasses(@NonNull Element elem) Returns the style classes of the element.Returns the style type of the element.booleanReturns true if the element has the specified attribute.booleanReturns true if the element has the specified id.booleanhasPseudoClass(@NonNull Element element, @NonNull String pseudoClass) Supports the following pseudo classes: root nth-child(odd) nth-child(even) first-child last-child Does not support the following pseudo classes: nth-child(2n+1) nth-last-child(2n+1) nth-last-child(odd) nth-last-child(even) nth-of-type(2n+1) nth-of-type(even) nth-of-type(odd) nth-last-of-type(2n+1) nth-last-of-type(even) nth-last-of-type(odd) first-of-type() last-of-type() only-child() only-of-type() empty not(...)booleanhasStyleClass(@NonNull Element elem, @NonNull String clazz) Returns true if the element has the specified style class.booleanReturns true if the element has the specified type.voidResets all values with non-StyleOrigin.USERorigin.voidsetAttribute(@NonNull Element element, @NonNull javafx.css.StyleOrigin origin, @Nullable String namespace, @NonNull String name, @Nullable ReadOnlyList<CssToken> value) Sets an attribute value.Methods inherited from class org.jhotdraw8.css.model.AbstractSelectorModel
additionalPseudoClassStatesPropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jhotdraw8.css.model.SelectorModel
attributeValueContains, attributeValueContainsWord, attributeValueEndsWith, attributeValueEquals
-
Constructor Details
-
DocumentSelectorModel
public DocumentSelectorModel()
-
-
Method Details
-
getAttributeAsString
public String getAttributeAsString(@NonNull Element elem, javafx.css.StyleOrigin origin, @Nullable String namespacePattern, @NonNull String name) Description copied from interface:SelectorModelReturns the attribute value with the given name from the specified style origin.- Parameters:
elem- The elementorigin- The style originnamespacePattern- an optional namespace ("*" means any namespace, null means no namespace)name- The attribute name- Returns:
- The attribute value. Returns "initial" if the element does not have an attribute with this name.
-
getAttribute
public @Nullable List<CssToken> getAttribute(@NonNull Element element, @Nullable javafx.css.StyleOrigin origin, @Nullable String namespacePattern, @NonNull String name) Description copied from interface:SelectorModelReturns the attribute value with the given name from the specified style origin.- Parameters:
element- The elementorigin- The style originnamespacePattern- an optional namespace ("*" means any namespace, null means no namespace)name- The attribute name- Returns:
- The attribute value as a list of
CssTokens.
-
hasId
Description copied from interface:SelectorModelReturns true if the element has the specified id.- Parameters:
elem- An element of the documentid- an id- Returns:
- true if the element has the id
-
getId
Description copied from interface:SelectorModelReturns the id of the element.- Parameters:
elem- the element- Returns:
- the id or null if the element does not have an id.
-
hasType
public boolean hasType(@NonNull Element elem, @Nullable String namespacePattern, @NonNull String type) Description copied from interface:SelectorModelReturns true if the element has the specified type.- Parameters:
elem- An element of the documentnamespacePattern- a namespace pattern ("*" means any namespace, null means no namespace)type- an id- Returns:
- true if the element has the id
-
reset
Description copied from interface:SelectorModelResets all values with non-StyleOrigin.USERorigin. -
getType
Description copied from interface:SelectorModelReturns the style type of the element.- Parameters:
elem- the element- Returns:
- the style type of the element, return null if the element is not styleable by type.
-
hasStyleClass
Description copied from interface:SelectorModelReturns true if the element has the specified style class.- Parameters:
elem- An element of the documentclazz- a style class- Returns:
- true if the element has the id
-
getStyleClasses
Description copied from interface:SelectorModelReturns the style classes of the element.- Parameters:
elem- the element- Returns:
- the style classes or an empty set.
-
getPseudoClasses
Description copied from interface:SelectorModelReturns the pseudo classes of the element.- Parameters:
elem- the element- Returns:
- the pseudo classes or an empty set.
-
hasPseudoClass
Supports the following pseudo classes:- root
- nth-child(odd)
- nth-child(even)
- first-child
- last-child
- nth-child(2n+1)
- nth-last-child(2n+1)
- nth-last-child(odd)
- nth-last-child(even)
- nth-of-type(2n+1)
- nth-of-type(even)
- nth-of-type(odd)
- nth-last-of-type(2n+1)
- nth-last-of-type(even)
- nth-last-of-type(odd)
- first-of-type()
- last-of-type()
- only-child()
- only-of-type()
- empty
- not(...)
- Parameters:
element- the elementpseudoClass- the desired pseudo clas- Returns:
- true if the element has the pseudo class
-
getParent
Description copied from interface:SelectorModelGets the parent of the element.- Parameters:
elem- An element of the document- Returns:
- The parent element. Returns null if the element has no parent.
-
getPreviousSibling
Description copied from interface:SelectorModelGets the previous sibling of the element.- Parameters:
element- An element of the document- Returns:
- The previous sibling. Returns null if the element has no previous sibling.
-
hasAttribute
public boolean hasAttribute(@NonNull Element element, @Nullable String namespace, @NonNull String attributeName) Description copied from interface:SelectorModelReturns true if the element has the specified attribute.- Parameters:
element- An element of the documentnamespace- an optional namespace (null means any namespace , an empty String means no namespace)attributeName- an attribute name- Returns:
- true if the element has an attribute with the specified name
-
attributeValueStartsWith
public boolean attributeValueStartsWith(@NonNull Element element, @Nullable String namespacePattern, @NonNull String attributeName, @NonNull String substring) Description copied from interface:SelectorModelReturns true if the element has an attribute with the specified name and the attribute value starts with the specified substring.- Parameters:
element- An element of the documentnamespacePattern- an optional namespace ("*" means any namespace, null means no namespace)attributeName- an attribute namesubstring- the substring- Returns:
- true if the element has an attribute with the specified name and the value starts with the specified substring.
-
getAttributeAsString
public @Nullable String getAttributeAsString(@NonNull Element element, @Nullable String namespacePattern, @NonNull String attributeName) Description copied from interface:SelectorModelReturns the attribute value with the given name from the USER style origin.- Parameters:
element- The elementnamespacePattern- an optional namespace ("*" means any namespace, null means no namespace)attributeName- The attribute name- Returns:
- The attribute value. Returns "initial" if the element does not have an attribute with this name.
-
getAttributeNames
Description copied from interface:SelectorModelReturns all styleable attributes of the element.- Parameters:
element- An element of the document- Returns:
- a set of styleable attributes.
-
getComposedAttributeNames
Description copied from interface:SelectorModelReturns all non-decomposed styleable attributes of the element.If an attribute can be decomposed, only the composite attribute is returned.
- Parameters:
element- An element of the document- Returns:
- a set of styleable attributes.
-
getDecomposedAttributeNames
Description copied from interface:SelectorModelReturns all decomposed styleable attributes of the element.If an attribute can be composed, only the decomposed attributes are returned.
- Parameters:
element- An element of the document- Returns:
- a set of styleable attributes.
-
setAttribute
public void setAttribute(@NonNull Element element, @NonNull javafx.css.StyleOrigin origin, @Nullable String namespace, @NonNull String name, @Nullable ReadOnlyList<CssToken> value) Description copied from interface:SelectorModelSets an attribute value.- Parameters:
element- The elementorigin- The style originnamespace- an optional namespace ("*" means any namespace, null means no namespace)name- The attribute namevalue- The attribute value.nullremoves the attribute from the element. That is,nullhas the same effect like the keyword "unset".
-