|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.gui.graphdocument.ElementDefinitionUtil
ElementDefinitionUtil is a collection of utility methods to check for conflicts between new definitions loaded from files (geometry, style, rules, layout contexts) and the current settings in the document or the application.
| Nested Class Summary | |
static class |
ElementDefinitionUtil.RenameAttributable
Abstract class for an AttributableOnSet that can be used to rename multiple items in the context of an AttributeEditor. |
static class |
ElementDefinitionUtil.UsedItemInfo
Struct to store the information the method gatherUsedItems(GraphDocument) returns
|
| Field Summary | |
static int |
APPLY_LOADED
This option uses the loaded definitions. |
static int |
APPLY_POOLED
This option uses the pooled definitions and discards the loaded ones. |
static int |
INDEX_DESCRIPTORS
INDEX_DESCRIPTORS: Index of the descriptors in the result
array, used in checkForStyleConflicts(AttributeList) and
checkForGeometryConflicts(AttributeList) |
static int |
INDEX_ITEMS
INDEX_ITEMS: Index of the items in the result array,
used in checkForStyleConflicts(AttributeList) and
checkForGeometryConflicts(AttributeList) |
static int |
NO_CONFLICT
There was no conflict for any items |
static int |
RENAME_LOADED
This option renames the conflicting items and uses them with their new names. |
static int |
REPLACE_ALL
This option uses the loaded definitions while replacing the pool and all open document definitions. |
static int |
REPLACE_POOLED
This option uses the loaded definitions and replaces the pooled items. |
static int |
USE_MATCHING_ELEMENTS
This option uses an identical element existing in the current definitions. |
| Method Summary | |
static void |
applyGeometries(AttributeList geometries,
java.util.List[] geometryConflicts,
VisualGraphView vgv,
AttributeList xmlData,
int applyAction,
java.util.Map renameMapDesc,
java.util.Map renameMapItem)
Applies the geometry in the given attribute list according to the applyAction. |
static void |
applyLayoutConfiguration(AttributeSet layoutConfiguration,
AttributeList xmlData,
LayoutController defaultLayoutController,
VisualGraphView vgv,
int applyAction,
java.util.List visualGraphViews,
java.util.List layoutConflicts,
boolean addUnconflictingContexts,
java.util.Map layoutsRenameMap,
int layoutDomain)
Applies the layout configuration. |
static void |
applyLayoutConfiguration(AttributeSet layoutConfiguration,
AttributeList xmlData,
LayoutController defaultLayoutController,
VisualGraphView vgv,
int applyAction,
java.util.List visualGraphViews,
java.util.List layoutConflicts,
boolean addUnconflictingContexts,
java.util.Map layoutsRenameMap,
int layoutDomain,
boolean setGlobalOptions)
Applies the layout configuration. |
static void |
applyPoolStyles(VisualGraphView vgv,
java.util.List[] styleConflicts)
Applies the styles from the pool on the elements of the visualgraphview |
static void |
applyRules(RuleRegistry rules,
RuleRegistry baseRegistry,
java.util.List ruleConflicts,
VisualGraphView vgv,
AttributeList xmlData,
java.util.List visualGraphViews,
int applyAction,
java.util.Map renameMap)
Apply the rules registry |
static void |
applyRules(RuleRegistry rules,
RuleRegistry baseRegistry,
java.util.List ruleConflicts,
VisualGraphView vgv,
AttributeList xmlData,
java.util.List visualGraphViews,
int applyAction,
java.util.Map renameMap,
boolean addUnconflicting)
Apply the rules registry |
static void |
applyStyles(AttributeList styles,
java.util.List[] styleConflicts,
VisualGraphView vgv,
AttributeList xmlData,
int applyAction,
RepositoryContainer repository,
java.util.List visualGraphViews,
java.util.Map renameMapDesc,
java.util.Map renameMapItem)
Applies the geometry in the given attribute list according to the applyAction. |
static java.util.List[] |
checkForGeometryConflicts(AttributeList geometries)
Checks for conflicts between the given geometry definitions and the items in the pools. |
static java.util.List |
checkForImageConflicts(AttributeList images)
Checks if one key in the given image list already exists in pool |
static java.util.List |
checkForLayoutConflicts(AttributeSet layoutConfiguration,
LayoutController lc)
Checks for a conflict between the settings of the given layout contexts attributes and the layout contexts in the service of the layout controller. |
static ElementDefinitionUtil.RenameAttributable |
checkForMissingFonts(AttributeList list,
AttributeList styles)
Checks, if fonts are used that are not available. |
static ElementDefinitionUtil.RenameAttributable |
checkForMissingLayoutContexts(java.lang.String[] controllerContexts,
VisualGraphView vgv)
Checks, if elements in the VisualGraphView are using a layout context
that is not defined in the layout controller. |
static ElementDefinitionUtil.RenameAttributable |
checkForMissingRules(RuleRegistry defaultRegistry,
java.util.Map mapRules)
Checks, if rules in the map are not defined in the rule registry. |
static java.util.List |
checkForRuleConflicts(RuleRegistry baseRegistry,
RuleRegistry newRegistry)
Checks if there is a conflict when loading the newRegistry
into the baseRegistry. |
static java.util.List[] |
checkForStyleConflicts(AttributeList styles)
Checks for conflicts between the given style definitions and the items in the pools. |
static java.util.List[] |
checkForStyleNameConflicts(AttributeList list)
Checks for possible conflicts between the loaded elements and the style pools by checking whether items with the names of the styles of the loaded elements are in the pools. |
static void |
convertLayoutAttributeNames(AttributeCollection coll)
Converts the names of layout attributes from the old version to the new one. |
static void |
convertVisualGraphObjectLayoutAttributes(AttributeCollection coll)
Converts layout attributes of VisualGraphObjects that have
changed (e.g. after introduction of new attributes to the layout that
replace the old ones). |
static java.util.List[] |
createListArray(java.util.List items,
java.util.List descriptors)
Creates an array with the dimension 2, using the index constants. |
static Rule |
duplicateRule(Rule rule,
java.lang.String newName)
Creates a new rule that is identical to the old one but has the given new name. |
static ElementDefinitionUtil.UsedItemInfo |
gatherUsedItems(GraphDocument gDoc)
Gathers all items of type StyleDescriptor, StyleItem, GeometryDescriptor, GeometryItem and Rule that are used in the given GraphDocument. |
static ElementDefinitionUtil.UsedItemInfo |
gatherUsedItems(VisualGraphView vgv)
Gathers all items of type StyleDescriptor, StyleItem, GeometryDescriptor, GeometryItem and Rule that are used in the given GraphDocument. |
static int |
getGeometriesOptionDefault(Preferences prefs)
Returns the default option for resolving geometry conflicts. |
static int |
getImagesOptionDefault(Preferences prefs)
Returns the default option for resolving image conflicts. |
static int |
getLayoutContextOptionDefault(Preferences prefs)
Returns the default option for resolving layout conflicts. |
static java.lang.String[] |
getLayoutControllerContexts(AttributeCollection data)
Returns the names of the layout controller contexts stored in the given configuration. |
static int |
getOption(Preferences prefs,
java.lang.String key)
Returns one of the apply action constants that correspond to the value of the setting in the preferences with the given key. |
static int |
getRulesOptionDefault(Preferences prefs)
Returns the default option for resolving rule conflicts. |
static int |
getStyleNamesOptionDefault(Preferences prefs)
Returns the default option for resolving style name conflicts. |
static int |
getStylesOptionDefault(Preferences prefs)
Returns the default option for resolving style conflicts. |
static boolean |
internalCompareGeometryDescriptorWithAttributeList(GeometryDescriptor gd,
AttributeList list)
Compares a GeometryDescriptor instance with an AttributeList
of a serialized GeometryDescriptor. |
static boolean |
internalCompareGeometryItemWithAttributeList(GeometryItem item,
AttributeList list)
Compares a GeometryItem instance with an AttributeList
of a serialized GeometryItem. |
static boolean |
internalCompareStyleDescriptorWithAttributeList(StyleDescriptor sd,
AttributeList list)
Compares a StyleDescriptor instance with an AttributeList
of a serialized StyleDescriptor. |
static boolean |
internalCompareStyleItemWithAttributeList(StyleItem si,
AttributeList list)
Compares a StyleItem instance with an AttributeList
of a serialized StyleItem. |
static boolean |
isTrueByDefault(Preferences prefs,
java.lang.String key)
Returns true, if the setting in the preferences with the given key is a Boolean with the value TRUE. |
static void |
renameMissingFonts(AttributeList list,
AttributeList styles,
ElementDefinitionUtil.RenameAttributable attributable)
Renames the missing fonts according to the given rename attributable |
static void |
renameMissingLayoutContexts(VisualGraphView vgv,
ElementDefinitionUtil.RenameAttributable attributable,
java.lang.String[] controllerContexts)
Renames the missing layout contexts according to the given rename attributable |
static void |
setGeometriesOptionDefault(Preferences prefs,
int option)
Sets the default option for resolving geometry conflicts. |
static void |
setImagesOptionDefault(Preferences prefs,
int option)
Sets the default option for resolving image conflicts. |
static void |
setLayoutContextOptionDefault(Preferences prefs,
int option)
Sets the default option for resolving layout conflicts. |
static void |
setOption(Preferences prefs,
java.lang.String key,
int option)
Sets the value of a setting in the preferences corresponding to the given apply action constant. |
static void |
setRulesOptionDefault(Preferences prefs,
int option)
Sets the default option for resolving rules conflicts. |
static void |
setStyleNamesOptionDefault(Preferences prefs,
int option)
Sets the default option for resolving style name conflicts. |
static void |
setStylesOptionDefault(Preferences prefs,
int option)
Sets the default option for resolving style conflicts. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int INDEX_DESCRIPTORS
INDEX_DESCRIPTORS: Index of the descriptors in the result
array, used in checkForStyleConflicts(AttributeList) and
checkForGeometryConflicts(AttributeList)
public static final int INDEX_ITEMS
INDEX_ITEMS: Index of the items in the result array,
used in checkForStyleConflicts(AttributeList) and
checkForGeometryConflicts(AttributeList)
public static final int NO_CONFLICT
public static final int APPLY_LOADED
public static final int REPLACE_POOLED
public static final int RENAME_LOADED
public static final int APPLY_POOLED
public static final int REPLACE_ALL
public static final int USE_MATCHING_ELEMENTS
| Method Detail |
public static void convertLayoutAttributeNames(AttributeCollection coll)
throws IllegalAttributeException,
ConstraintViolationException,
IllegalNameException,
IllegalValueException,
java.lang.CloneNotSupportedException
AttributeEditorTranslator is used. Call this
method to convert a definition from an old file to the new structure.
coll - The attribute collection to convert
ConstraintViolationException - this might be thrown during
construction of the new attribute
structure to indicate inconsistency.
IllegalAttributeException - this might be thrown during
construction of the new attribute
structure to indicate inconsistency.
IllegalValueException - this might be thrown during
construction of the new attribute
structure to indicate inconsistency.
IllegalNameException - this might be thrown during
construction of the new attribute
structure to indicate inconsistency.
java.lang.CloneNotSupportedException - this might be thrown during
construction of the new attribute
structure to indicate inconsistency.
public static final void convertVisualGraphObjectLayoutAttributes(AttributeCollection coll)
throws IllegalValueException,
ConstraintViolationException,
ConstraintParserException
VisualGraphObjects that have
changed (e.g. after introduction of new attributes to the layout that
replace the old ones).
coll - The AttributeCollection containing the
serialized VisualGraphView to convert
ConstraintViolationException - thrown if applying a converted
value fails because of a constraint
IllegalValueException - thrown if a converted value is
illegal
ConstraintParserException - thrown if the construction of a
constraint fails
public static final java.util.List checkForRuleConflicts(RuleRegistry baseRegistry,
RuleRegistry newRegistry)
newRegistry
into the baseRegistry. A conflict occurs when the new
registry contains a rule that differs from a rule in the base registry
carrying the same name.
baseRegistry - The base registry, usually the registry of the
applicationnewRegistry - The new registry to add, usually loaded from a
file
public static final java.util.List checkForLayoutConflicts(AttributeSet layoutConfiguration,
LayoutController lc)
layoutConfiguration - The attributes containing the settings for the
layout contexts, usually loaded from a graph xmllc - The LayoutController currently initialized with
default values from the application
public static final java.util.List[] checkForGeometryConflicts(AttributeList geometries)
geometries - The attributes defining the GeometryItems and
GeometryDescriptors.
GeometryItems
[INDEX_DESCRIPTORS]: Contains names of conflicting GeometryDescriptorspublic static java.util.List[] checkForStyleNameConflicts(AttributeList list)
list - The loaded AttributeList from the graph xml file
StyleItems
[INDEX_DESCRIPTORS]: Contains names of conflicting StyleDescriptorspublic static final java.util.List[] checkForStyleConflicts(AttributeList styles)
styles - The attributes defining the StyleItems and
StyleDescriptors.
StyleItems
[INDEX_DESCRIPTORS]: Contains names of conflicting StyleDescriptorspublic static java.util.List checkForImageConflicts(AttributeList images)
images - The images to check
public static void applyLayoutConfiguration(AttributeSet layoutConfiguration,
AttributeList xmlData,
LayoutController defaultLayoutController,
VisualGraphView vgv,
int applyAction,
java.util.List visualGraphViews,
java.util.List layoutConflicts,
boolean addUnconflictingContexts,
java.util.Map layoutsRenameMap,
int layoutDomain)
layoutConfiguration - The loaded configurationxmlData - The complete xml that has been loadeddefaultLayoutController - The default layout controllervgv - The VisualGraphView this is applied toapplyAction - The applying mode, see constants in this
classvisualGraphViews - The VisualGraphViews of other documents
that are used for REPLACE_ALL mode.layoutConflicts - A list with all conflicting layout
contextsaddUnconflictingContexts - If true, the layouts contexts without
conflicts are added to the other
documents and the pool, so they are
available therelayoutsRenameMap - The rename map if some contexts have to
be renamedlayoutDomain - The layout domain to be applied to
the layout controller
public static void applyLayoutConfiguration(AttributeSet layoutConfiguration,
AttributeList xmlData,
LayoutController defaultLayoutController,
VisualGraphView vgv,
int applyAction,
java.util.List visualGraphViews,
java.util.List layoutConflicts,
boolean addUnconflictingContexts,
java.util.Map layoutsRenameMap,
int layoutDomain,
boolean setGlobalOptions)
layoutConfiguration - The loaded configurationxmlData - The complete xml that has been loadeddefaultLayoutController - The default layout controllervgv - The VisualGraphView this is applied toapplyAction - The applying mode, see constants in this
classvisualGraphViews - The VisualGraphViews of other documents
that are used for REPLACE_ALL mode.layoutConflicts - A list with all conflicting layout
contextsaddUnconflictingContexts - If true, the layouts contexts without
conflicts are added to the other
documents and the pool, so they are
available therelayoutsRenameMap - The rename map if some contexts have to
be renamedlayoutDomain - The layout domain to be applied to
the layout controllersetGlobalOptions - If true, settings like layout contexts
and the layout domain are applied to the
layout controllerpublic static java.lang.String[] getLayoutControllerContexts(AttributeCollection data)
AttributeCollection has to contain
the attributes ModelConstants.LAYOUTCONTROLLER_CONTEXT and
ModelConstants.LAYOUTCONTROLLER_EDGECONTEXT.
data - The data that contains the attributes
public static void applyGeometries(AttributeList geometries,
java.util.List[] geometryConflicts,
VisualGraphView vgv,
AttributeList xmlData,
int applyAction,
java.util.Map renameMapDesc,
java.util.Map renameMapItem)
throws BuildException
geometries - The loaded geometriesgeometryConflicts - The items and descriptors that have
conflicts with the defaultsvgv - The VisualGraphView this is applied toxmlData - The complete xml that has been loadedapplyAction - The applying mode, see constants in this
classrenameMapDesc - The rename map if some descriptors have to
be renamedrenameMapItem - The rename map if some items have to
be renamed
BuildException - When building a descriptor or item fails
public static void applyPoolStyles(VisualGraphView vgv,
java.util.List[] styleConflicts)
vgv - The visualgraphview to be alteredstyleConflicts - The lists of conflicting elements
public static void applyStyles(AttributeList styles,
java.util.List[] styleConflicts,
VisualGraphView vgv,
AttributeList xmlData,
int applyAction,
RepositoryContainer repository,
java.util.List visualGraphViews,
java.util.Map renameMapDesc,
java.util.Map renameMapItem)
throws BuildException
styles - The styles to applystyleConflicts - The styles that have a conflictvgv - The visual graph view that has been loadedxmlData - The complete and unmodified data read from the
XML fileapplyAction - The type of apply action to dorepository - The repository that has to be updatedvisualGraphViews - Additional visualgraphs that have to be updatedrenameMapDesc - The map containing new names for conflicting
descriptorsrenameMapItem - The map containing new names for conflicting
items
BuildException - If there is a problem while building the style items
public static void applyRules(RuleRegistry rules,
RuleRegistry baseRegistry,
java.util.List ruleConflicts,
VisualGraphView vgv,
AttributeList xmlData,
java.util.List visualGraphViews,
int applyAction,
java.util.Map renameMap)
rules - The rules to applybaseRegistry - The default rules of the applicationruleConflicts - A list with names of all conflicting rulesvgv - The VisualGraphView to apply the
rules toxmlData - The complete and unmodified data from the
XML file.visualGraphViews - The additional VisualGraphViews
to apply the rules toapplyAction - The type of apply action to dorenameMap - A map containing new names for all conflicting
elements that should be renamed
public static void applyRules(RuleRegistry rules,
RuleRegistry baseRegistry,
java.util.List ruleConflicts,
VisualGraphView vgv,
AttributeList xmlData,
java.util.List visualGraphViews,
int applyAction,
java.util.Map renameMap,
boolean addUnconflicting)
rules - The rules to applybaseRegistry - The default rules of the applicationruleConflicts - A list with names of all conflicting rulesvgv - The VisualGraphView to apply the
rules toxmlData - The complete and unmodified data from the
XML file.visualGraphViews - The additional VisualGraphViews
to apply the rules toapplyAction - The type of apply action to dorenameMap - A map containing new names for all conflicting
elements that should be renamedaddUnconflicting - If this is true, all rules without a conflict
will be added to all open documents and the
defaults
public static Rule duplicateRule(Rule rule,
java.lang.String newName)
rule - The rule to duplicatenewName - The name for the new rule
public static final boolean internalCompareGeometryItemWithAttributeList(GeometryItem item,
AttributeList list)
GeometryItem instance with an AttributeList
of a serialized GeometryItem.
item - The geometry itemlist - The serialization of a geometry item
public static final boolean internalCompareGeometryDescriptorWithAttributeList(GeometryDescriptor gd,
AttributeList list)
GeometryDescriptor instance with an AttributeList
of a serialized GeometryDescriptor.
gd - The geometry descriptorlist - The serialization of a geometry descriptor
public static final boolean internalCompareStyleItemWithAttributeList(StyleItem si,
AttributeList list)
StyleItem instance with an AttributeList
of a serialized StyleItem.
si - The style itemlist - The serialization of a style item
public static final boolean internalCompareStyleDescriptorWithAttributeList(StyleDescriptor sd,
AttributeList list)
StyleDescriptor instance with an AttributeList
of a serialized StyleDescriptor.
sd - The style descriptorlist - The serialization of a style descriptor
public static int getOption(Preferences prefs,
java.lang.String key)
prefs - The preferenceskey - The key of the setting in the preferences
public static void setOption(Preferences prefs,
java.lang.String key,
int option)
prefs - The preferences to alterkey - The key of the setting in the preferencesoption - The apply action represented by one of the constants
defined in this classpublic static int getLayoutContextOptionDefault(Preferences prefs)
prefs - The preferences to get the default option from.
public static int getImagesOptionDefault(Preferences prefs)
prefs - The preferences to get the default option from.
public static int getStylesOptionDefault(Preferences prefs)
prefs - The preferences to get the default option from.
public static int getStyleNamesOptionDefault(Preferences prefs)
prefs - The preferences to get the default option from.
public static int getGeometriesOptionDefault(Preferences prefs)
prefs - The preferences to get the default option from.
public static int getRulesOptionDefault(Preferences prefs)
prefs - The preferences to get the default option from.
public static void setLayoutContextOptionDefault(Preferences prefs,
int option)
prefs - The preferences to set the default option tooption - The option to set in the preferences
public static void setImagesOptionDefault(Preferences prefs,
int option)
prefs - The preferences to set the default option tooption - The option to set in the preferences
public static void setStylesOptionDefault(Preferences prefs,
int option)
prefs - The preferences to set the default option tooption - The option to set in the preferences
public static void setStyleNamesOptionDefault(Preferences prefs,
int option)
prefs - The preferences to set the default option tooption - The option to set in the preferences
public static void setGeometriesOptionDefault(Preferences prefs,
int option)
prefs - The preferences to set the default option tooption - The option to set in the preferences
public static void setRulesOptionDefault(Preferences prefs,
int option)
prefs - The preferences to set the default option tooption - The option to set in the preferences
public static boolean isTrueByDefault(Preferences prefs,
java.lang.String key)
prefs - The preferences to get the value fromkey - The key of the setting to return
public static java.util.List[] createListArray(java.util.List items,
java.util.List descriptors)
items - The items to setdescriptors - The descriptors to set
public static ElementDefinitionUtil.RenameAttributable checkForMissingFonts(AttributeList list,
AttributeList styles)
list - The loaded document as attribute liststyles - The loaded styles to check for missing fonts
public static ElementDefinitionUtil.RenameAttributable checkForMissingRules(RuleRegistry defaultRegistry,
java.util.Map mapRules)
defaultRegistry - The registry defining the available rulesmapRules - A map containing all names of requested rules and
the class of the rule (NodeRule.class,
GraphRule.class or EdgeRule.class)
public static ElementDefinitionUtil.RenameAttributable checkForMissingLayoutContexts(java.lang.String[] controllerContexts,
VisualGraphView vgv)
throws ConstraintParserException
VisualGraphView are using a layout context
that is not defined in the layout controller. The method creates an attributable
which can be used in an AttributableOnSetDialog to select new names for all the
missing layout contexts.
controllerContexts - An array containing the names of the controller contexts:
0: The name of the node layout context
1: The name of the edge layout contextvgv - The VisualGraphView
ConstraintParserException - If a constraint for the attributable can't
be created
public static final void renameMissingFonts(AttributeList list,
AttributeList styles,
ElementDefinitionUtil.RenameAttributable attributable)
list - The loaded document as attribute liststyles - The loaded styles containing the fontsattributable - The rename attributable containing the new names
public static final void renameMissingLayoutContexts(VisualGraphView vgv,
ElementDefinitionUtil.RenameAttributable attributable,
java.lang.String[] controllerContexts)
vgv - The VisualGraphView containing the layoutablesattributable - The rename attributable containing the new namescontrollerContexts - An array containing the names of the controller contexts:
0: The name of the node layout context
1: The name of the edge layout contextpublic static ElementDefinitionUtil.UsedItemInfo gatherUsedItems(GraphDocument gDoc)
gDoc - The GraphDocument to check
public static ElementDefinitionUtil.UsedItemInfo gatherUsedItems(VisualGraphView vgv)
vgv - The VisualGraphView to check
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||