Package com.nomagic.magicdraw.properties
Class Style
java.lang.Object
com.nomagic.magicdraw.properties.Style
- All Implemented Interfaces:
com.nomagic.magicdraw.core.project.options.PersistentStyle
,PropertyVisitorAcceptor
,PropertyChangeListener
,Cloneable
,EventListener
@OpenApiAll
public class Style
extends Object
implements Cloneable, PropertyVisitorAcceptor, PropertyChangeListener, com.nomagic.magicdraw.core.project.options.PersistentStyle
Style stores and manages a set of
PropertyManagers
.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(PropertyVisitor visitor) Accepts the given visitor.void
addManager
(PropertyManager manager) Adds given property manager.void
Registers the listener to the element.void
Adds all managers from given style to this style.void
Applies all managers from given style to the existing managers here.clone()
/** Creates and returns a copy of this style.protected void
cloneManagers
(Style newS) static PropertyManager
findPropertyManagerWithPath
(Style findIn, Collection<PropertyManager> path) static PropertyManager
findPropertyManagerWithSamePath
(Style findIn, PropertyManager find) Finds same property manager(with same path) in given style.static void
Generate default description id.void
Returns property class type.getID()
getManager
(String name) Returns property manager with given name.int
Returns managers count.Returns a collection of all managers.getManagers
(String name) Returns property managers with given name.getName()
Returns the name of the style.Returns collection of managers sorted by name.boolean
hasStereotype
(String id) Check if style has stereotype with given id.boolean
Is this style a default one?boolean
boolean
Checks if given style has same property managers with same values.boolean
void
On CHANGE_STYLE_PROPERTY property change takes the manager from property's new Value and replaces itself properties with properties from this manager.void
Called when property manager name is changedvoid
removeManager
(PropertyManager manager) Removes given property manager.void
Unregisters the given listener from the element.void
setAppliedPropertyManagerIDs
(Map<PropertyManager, PropertyManager> propertyManagers) Sets applied property manager id to managers which does not have it.void
setDefault
(boolean def) Sets default flag value.void
Set Idvoid
setManagers
(Collection<PropertyManager> managers) Sets the collection of all managers.void
Set the name of the style.toString()
Returns a string representation of the style.void
updateDefinedIn
(Style src) Update allExtendablePropertyManager
in this style defined in.
-
Field Details
-
SHARED
- See Also:
-
MERGED
- See Also:
-
MERGED_PRE1704
- See Also:
-
CHANGE_STYLE_PROPERTY
Name of property fired on some style change.- See Also:
-
CHANGE_STYLE_PROPERTY_VALUE
- See Also:
-
ADDED_STYLE_MANAGER
Deprecated.- See Also:
-
-
Constructor Details
-
Style
public Style()Constructs new Style. Style will have name "default", but it will not be default.
-
-
Method Details
-
addManager
Adds given property manager.- Parameters:
manager
- the manager to add.
-
removeManager
Removes given property manager.- Parameters:
manager
- the manager to remove.
-
getManagerCount
public int getManagerCount()Returns managers count.- Returns:
- count of managers.
-
setManagers
Sets the collection of all managers.- Parameters:
managers
- a collection of new managers.
-
getName
Returns the name of the style.- Returns:
- name of the style.
-
setName
Set the name of the style.- Parameters:
name
- the new name of the style.
-
setAppliedPropertyManagerIDs
Sets applied property manager id to managers which does not have it.- Parameters:
propertyManagers
- property managers to analyze
-
toString
Returns a string representation of the style. Used for debug. -
setDefault
public void setDefault(boolean def) Sets default flag value.- Parameters:
def
- new flag value.
-
isDefault
public boolean isDefault()Is this style a default one?- Returns:
- default flag value.
-
clone
/** Creates and returns a copy of this style. Does deep clone. -
cloneManagers
-
getManagers
Returns a collection of all managers.- Returns:
- all managers.
-
getOrderedManagers
Returns collection of managers sorted by name.- Returns:
- collection of managers sorted by name.
-
getManager
Returns property manager with given name.- Parameters:
name
- the name of manager.- Returns:
- manager with given name or null.
-
getManagers
Returns property managers with given name.- Parameters:
name
- the name of manager.- Returns:
- managers with given name or null.
-
accept
Accepts the given visitor.- Specified by:
accept
in interfacePropertyVisitorAcceptor
- Parameters:
visitor
- the PropertyVisitor.- Throws:
Exception
-
getClassType
Returns property class type.- Specified by:
getClassType
in interfacePropertyVisitorAcceptor
- Returns:
- PropertyID.SIMPLE_STYLE
- See Also:
-
append
Adds all managers from given style to this style. If some manager exists in given style, but does not exist in this style - clone this manager and add. If some manager exists in given style and exists in this style - append properties from given manager to this manager.- Parameters:
s
- the given style.
-
apply
Applies all managers from given style to the existing managers here. If some manager exists in given style, but does not exist in this style - do nothing.- Parameters:
s
- the given style.
-
appendExtendedManagers
-
isDiagramStyle
public boolean isDiagramStyle()- Returns:
- if it is diagram style
-
propertyChange
On CHANGE_STYLE_PROPERTY property change takes the manager from property's new Value and replaces itself properties with properties from this manager.- Specified by:
propertyChange
in interfacePropertyChangeListener
- Parameters:
evt
- PropertyChangeEvent.
-
getManagersFromParent
-
findPropertyManagerWithSamePath
@CheckForNull public static PropertyManager findPropertyManagerWithSamePath(Style findIn, PropertyManager find) Finds same property manager(with same path) in given style.- Parameters:
findIn
- style where find manager.find
- manager to find.- Returns:
- found manager, or null if not found.
-
findPropertyManagerWithPath
@CheckForNull public static PropertyManager findPropertyManagerWithPath(Style findIn, Collection<PropertyManager> path) -
generateID
public void generateID() -
getID
- Returns:
- Returns the iD. Can return null if ID was not generated. ID is generated only for styles used for not loaded diagrams.
-
setID
Set Id- Parameters:
id
- given ID.
-
addPropertyChangeListener
Registers the listener to the element. The given listener will get notifications about property changes in this element.- Parameters:
listener
- thePropertyChangeListener
to be added.- See Also:
-
removePropertyChangeListener
Unregisters the given listener from the element. The given listener will not get any notifications about property changes in this element.- Parameters:
listener
- the PropertyChangeListener to be removed.- See Also:
-
generateDefaultDescriptionID
Generate default description id.- Parameters:
style
- style
-
isSnapshotStyleForDiagramSymbols
public boolean isSnapshotStyleForDiagramSymbols()- Returns:
- true if style is clone used for diagram style preserving.
-
isEqual
Checks if given style has same property managers with same values.- Parameters:
style
- given style.- Returns:
- true if given style has same values as this style.
-
updateDefinedIn
Update allExtendablePropertyManager
in this style defined in.- Parameters:
src
- source to get defined in values
-
hasStereotype
Check if style has stereotype with given id. This method is faster than iterate through all property managers.- Parameters:
id
- stereotype id- Returns:
- true if stereotype with given id has property manager in this style.
-
propertyManagerNameChanged
Called when property manager name is changed- Parameters:
manager
- manager which name is changed
-