Class MergedStyleNode
java.lang.Object
net.sourceforge.plantuml.style.parser.MergedStyleNode
One node of the canonical, merged style tree: unlike
matches against, or resolve
RawStyleRule, there is at
most one node per (selector name, *-or-not) pair at a given level, whatever comma
lists or repeated declarations produced it in the source file.
Building this tree from a RawStyleSheet does exactly two things the raw parse
tree deliberately left undone:
- a comma-separated selector list, e.g.
composite,package { title {...} }, is expanded so each alternative gets its own independent node (so a later declaration ofpackage { title {...} }elsewhere only ever affectspackage, nevercomposite); - repeated declarations of the very same selector path with the same
*-ness, e.g. two separate top-levelmindmapDiagram { ... }blocks, are folded into a single node: properties are overwritten by whichever declaration comes last in the file (the same last-one-wins rule the legacyStyle#mergeWithalready applies), and children accumulate across every occurrence.
.europeStyle { node { FontSize
20 } } alongside .europeStyle * { node { FontColor red } } , is deliberately
not folded together the way two identically-starred declarations are: they land in two
separate child slots (see getOrCreateChild(net.sourceforge.plantuml.style.parser.RawSelector, boolean)), because * changes what the
declaration actually means -- FontSize 20 must stay on the Europe node alone, while FontColor
red must cascade to every descendant too. The legacy character-level parser never had to get
this right on purpose: its Context#push always allocates a brand new Context
per occurrence, so a plain and a starred declaration of the same name were simply never the
same object to begin with. Collapsing them into one node here (as an earlier version of this
class did, keying a child purely by selector name) would silently let FontSize leak onto
England, Germany and Spain along with FontColor -- a real regression, not a hypothetical one.
What this tree still does not do: turn a nested path such as
sequenceDiagram > participant into the flat, order-independent signature
(a set of SName) the legacy
invalid reference
net.sourceforge.plantuml.style.StyleSignature
depth(n) into an actual matching rule. Those are later
steps; see net.sourceforge.plantuml.style.LegacyStyleFlattener.
A property set inside @media (prefers-color-scheme:dark) { ... } is not kept apart
from its plain (light) counterpart either: both land in the very same node, folded into one
PrioritizedValue carrying both -- see mergeRule(net.sourceforge.plantuml.style.parser.RawStyleRule, net.sourceforge.plantuml.style.AutomaticCounter, boolean).-
Method Summary
Modifier and TypeMethodDescriptionChildren reached through a plain (non-starred) named selector.getOtherChildKind(String canonicalKey) WhichRawSelector.Kindproduced the "other" child stored under this canonical key --STEREOTYPE,DEPTHorUNKNOWN-- so a later compilation step can tell a stereotype selector from an unrecognized one, whichRawSelector.canonicalOtherKey()alone does not always disambiguate.Children reached through a plain (non-starred) stereotype/depth/unknown selector.Properties declared anywhere for this exact selector, already merged -- light and dark declarations for the same property folded into onePrioritizedValue, permergeRule(net.sourceforge.plantuml.style.parser.RawStyleRule, net.sourceforge.plantuml.style.AutomaticCounter, boolean).getProperty(PName name) Children reached through a starred named selector, e.g.The starred counterpart ofgetOtherChildren()-- seegetStarredNamedChildren().booleanisStar()voidmergeAll(RawStyleSheet raw, AutomaticCounter counter) Merges every top-level rule inrawinto this node,@mediacontent dispatched to its dark half exactly as the plain case is -- whatnet.sourceforge.plantuml.style.StyleLoader#parseStyleTextcalls to fold a whole .skin file, or a hand-written<style>...</style>block, into one throwaway tree, immediately flattened back to legacynet.sourceforge.plantuml.style.Styleobjects byLegacyStyleFlattener.voidmergeRule(RawStyleRule rule, AutomaticCounter counter, boolean dark) Merges one raw declaration -- and, recursively, everything nested inside it -- into this node, which stands for its parent selector (the top-level container for a top-level declaration).static MergedStyleNodetoString()
-
Method Details
-
newTopLevelContainer
-
mergeRule
Merges one raw declaration -- and, recursively, everything nested inside it -- into this node, which stands for its parent selector (the top-level container for a top-level declaration).counterassigns each property value an increasing priority as it is met, exactly like the legacyStyleBuilder(itself anAutomaticCounter) does when loading a .skin file -- so it must be the very same counter for everymergeRulecall across one sheet,@mediacontent included, for priorities to be comparable across every declaration in the file.darksays whetherrulesits inside an@mediablock: every property it sets is then wrapped as adarkvalue instead of alightone, andPrioritizedValue.mergeWith(PrioritizedValue)takes care of folding it together with whatever light value the very same property already has at this node (in file order, either one may come first). This mirrors the legacy parser's own@mediahandling (net.sourceforge.plantuml.style.parser.StyleParser'sschemefield): it does not look at the actual media condition text at all, it only cares that some@-rule switched parsing into "dark" mode. -
mergeAll
Merges every top-level rule inrawinto this node,@mediacontent dispatched to its dark half exactly as the plain case is -- whatnet.sourceforge.plantuml.style.StyleLoader#parseStyleTextcalls to fold a whole .skin file, or a hand-written<style>...</style>block, into one throwaway tree, immediately flattened back to legacynet.sourceforge.plantuml.style.Styleobjects byLegacyStyleFlattener.countermust be the very same one across every call contributing to one logical load (a whole file, or a file followed by its overlays), exactly like a single top-levelmergeRule(net.sourceforge.plantuml.style.parser.RawStyleRule, net.sourceforge.plantuml.style.AutomaticCounter, boolean)call requires. -
getOtherChildKind
WhichRawSelector.Kindproduced the "other" child stored under this canonical key --STEREOTYPE,DEPTHorUNKNOWN-- so a later compilation step can tell a stereotype selector from an unrecognized one, whichRawSelector.canonicalOtherKey()alone does not always disambiguate. -
getNamedChildren
Children reached through a plain (non-starred) named selector. SeegetStarredNamedChildren(). -
getStarredNamedChildren
Children reached through a starred named selector, e.g. thenodeineuropeStyle * { node {...} }. Kept apart fromgetNamedChildren()rather than merged with it -- see the class javadoc -- so a caller building a child signature must visit both maps andaddStar()unconditionally for entries found here. -
getOtherChildren
Children reached through a plain (non-starred) stereotype/depth/unknown selector. SeegetStarredOtherChildren(). -
getStarredOtherChildren
The starred counterpart ofgetOtherChildren()-- seegetStarredNamedChildren(). -
getProperties
Properties declared anywhere for this exact selector, already merged -- light and dark declarations for the same property folded into onePrioritizedValue, permergeRule(net.sourceforge.plantuml.style.parser.RawStyleRule, net.sourceforge.plantuml.style.AutomaticCounter, boolean). -
getProperty
-
isStar
public boolean isStar() -
toString
-