com.tensegrity.gui.graphdocument
Class ElementDefinitionUtil

java.lang.Object
  extended bycom.tensegrity.gui.graphdocument.ElementDefinitionUtil

public class ElementDefinitionUtil
extends java.lang.Object

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.

Author:
BurkhardWick

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

INDEX_DESCRIPTORS

public static final int INDEX_DESCRIPTORS
INDEX_DESCRIPTORS: Index of the descriptors in the result array, used in checkForStyleConflicts(AttributeList) and checkForGeometryConflicts(AttributeList)

See Also:
Constant Field Values

INDEX_ITEMS

public static final int INDEX_ITEMS
INDEX_ITEMS: Index of the items in the result array, used in checkForStyleConflicts(AttributeList) and checkForGeometryConflicts(AttributeList)

See Also:
Constant Field Values

NO_CONFLICT

public static final int NO_CONFLICT
There was no conflict for any items

See Also:
Constant Field Values

APPLY_LOADED

public static final int APPLY_LOADED
This option uses the loaded definitions. It is available for rules and layouts and will use the stored document definitions but will not alter the application defaults.

See Also:
Constant Field Values

REPLACE_POOLED

public static final int REPLACE_POOLED
This option uses the loaded definitions and replaces the pooled items. This option is useful when you have a document that contains newer definitions which you would like to use. It is like a temporary application update, so that you can work with the newest definitions. In this case the definitions that differ in the application defaults and pools are replaced by the definitions in the document. Documents subsequently created will use the new definitions.

See Also:
Constant Field Values

RENAME_LOADED

public static final int RENAME_LOADED
This option renames the conflicting items and uses them with their new names. This is considered the "safest" of all options, because both the information in the document and application are retained. If this option is selected you will be prompted to enter new names for the conflicting elements so they can be added to the defaults or application pools. The document will be modified by this option.

See Also:
Constant Field Values

APPLY_POOLED

public static final int APPLY_POOLED
This option uses the pooled definitions and discards the loaded ones. Document definitions are therefore ignored, leading to a modification of the document when it is subsequently saved.

See Also:
Constant Field Values

REPLACE_ALL

public static final int REPLACE_ALL
This option uses the loaded definitions while replacing the pool and all open document definitions. This is nearly the same as REPLACE_POOLED only changes are also applied to all open documents and not just to documents subsequently created.

See Also:
Constant Field Values

USE_MATCHING_ELEMENTS

public static final int USE_MATCHING_ELEMENTS
This option uses an identical element existing in the current definitions. It is only available for rule conflicts during the insertion of elements into the document. In this case you might get the option to use a rule that exists in the document and is identical to the one inserted but has a different name.

See Also:
Constant Field Values
Method Detail

convertLayoutAttributeNames

public static void convertLayoutAttributeNames(AttributeCollection coll)
                                        throws IllegalAttributeException,
                                               ConstraintViolationException,
                                               IllegalNameException,
                                               IllegalValueException,
                                               java.lang.CloneNotSupportedException
Converts the names of layout attributes from the old version to the new one. In the old version some of them contained a '.' which isn't allowed when an AttributeEditorTranslator is used. Call this method to convert a definition from an old file to the new structure.

Parameters:
coll - The attribute collection to convert
Throws:
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.

convertVisualGraphObjectLayoutAttributes

public static final void convertVisualGraphObjectLayoutAttributes(AttributeCollection coll)
                                                           throws IllegalValueException,
                                                                  ConstraintViolationException,
                                                                  ConstraintParserException
Converts layout attributes of VisualGraphObjects that have changed (e.g. after introduction of new attributes to the layout that replace the old ones).

Parameters:
coll - The AttributeCollection containing the serialized VisualGraphView to convert
Throws:
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

checkForRuleConflicts

public static final java.util.List checkForRuleConflicts(RuleRegistry baseRegistry,
                                                         RuleRegistry newRegistry)
Checks if there is a conflict when loading the 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.

Parameters:
baseRegistry - The base registry, usually the registry of the application
newRegistry - The new registry to add, usually loaded from a file
Returns:
A list containing all conflicting rules

checkForLayoutConflicts

public static final 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.

Parameters:
layoutConfiguration - The attributes containing the settings for the layout contexts, usually loaded from a graph xml
lc - The LayoutController currently initialized with default values from the application
Returns:
A list with names of all conflicting layout contexts

checkForGeometryConflicts

public static final java.util.List[] checkForGeometryConflicts(AttributeList geometries)
Checks for conflicts between the given geometry definitions and the items in the pools.

Parameters:
geometries - The attributes defining the GeometryItems and GeometryDescriptors.
Returns:
An array containing two lists: [INDEX_ITEMS]: Contains names of conflicting GeometryItems [INDEX_DESCRIPTORS]: Contains names of conflicting GeometryDescriptors

checkForStyleNameConflicts

public 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.

Parameters:
list - The loaded AttributeList from the graph xml file
Returns:
An array containing two lists: [INDEX_ITEMS]: Contains names of conflicting StyleItems [INDEX_DESCRIPTORS]: Contains names of conflicting StyleDescriptors

checkForStyleConflicts

public static final java.util.List[] checkForStyleConflicts(AttributeList styles)
Checks for conflicts between the given style definitions and the items in the pools.

Parameters:
styles - The attributes defining the StyleItems and StyleDescriptors.
Returns:
An array containing two lists: [INDEX_ITEMS]: Contains names of conflicting StyleItems [INDEX_DESCRIPTORS]: Contains names of conflicting StyleDescriptors

checkForImageConflicts

public static java.util.List checkForImageConflicts(AttributeList images)
Checks if one key in the given image list already exists in pool

Parameters:
images - The images to check
Returns:
A list of all conflicting keys

applyLayoutConfiguration

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)
Applies the layout configuration.

Parameters:
layoutConfiguration - The loaded configuration
xmlData - The complete xml that has been loaded
defaultLayoutController - The default layout controller
vgv - The VisualGraphView this is applied to
applyAction - The applying mode, see constants in this class
visualGraphViews - The VisualGraphViews of other documents that are used for REPLACE_ALL mode.
layoutConflicts - A list with all conflicting layout contexts
addUnconflictingContexts - If true, the layouts contexts without conflicts are added to the other documents and the pool, so they are available there
layoutsRenameMap - The rename map if some contexts have to be renamed
layoutDomain - The layout domain to be applied to the layout controller

applyLayoutConfiguration

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)
Applies the layout configuration.

Parameters:
layoutConfiguration - The loaded configuration
xmlData - The complete xml that has been loaded
defaultLayoutController - The default layout controller
vgv - The VisualGraphView this is applied to
applyAction - The applying mode, see constants in this class
visualGraphViews - The VisualGraphViews of other documents that are used for REPLACE_ALL mode.
layoutConflicts - A list with all conflicting layout contexts
addUnconflictingContexts - If true, the layouts contexts without conflicts are added to the other documents and the pool, so they are available there
layoutsRenameMap - The rename map if some contexts have to be renamed
layoutDomain - The layout domain to be applied to the layout controller
setGlobalOptions - If true, settings like layout contexts and the layout domain are applied to the layout controller

getLayoutControllerContexts

public static java.lang.String[] getLayoutControllerContexts(AttributeCollection data)
Returns the names of the layout controller contexts stored in the given configuration. The given AttributeCollection has to contain the attributes ModelConstants.LAYOUTCONTROLLER_CONTEXT and ModelConstants.LAYOUTCONTROLLER_EDGECONTEXT.

Parameters:
data - The data that contains the attributes
Returns:
A String array of length 2 with these entries: 0: Node layout context name 1: Edge layout context name

applyGeometries

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
Applies the geometry in the given attribute list according to the applyAction.

Parameters:
geometries - The loaded geometries
geometryConflicts - The items and descriptors that have conflicts with the defaults
vgv - The VisualGraphView this is applied to
xmlData - The complete xml that has been loaded
applyAction - The applying mode, see constants in this class
renameMapDesc - The rename map if some descriptors have to be renamed
renameMapItem - The rename map if some items have to be renamed
Throws:
BuildException - When building a descriptor or item fails

applyPoolStyles

public static void applyPoolStyles(VisualGraphView vgv,
                                   java.util.List[] styleConflicts)
Applies the styles from the pool on the elements of the visualgraphview

Parameters:
vgv - The visualgraphview to be altered
styleConflicts - The lists of conflicting elements

applyStyles

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
Applies the geometry in the given attribute list according to the applyAction.

Parameters:
styles - The styles to apply
styleConflicts - The styles that have a conflict
vgv - The visual graph view that has been loaded
xmlData - The complete and unmodified data read from the XML file
applyAction - The type of apply action to do
repository - The repository that has to be updated
visualGraphViews - Additional visualgraphs that have to be updated
renameMapDesc - The map containing new names for conflicting descriptors
renameMapItem - The map containing new names for conflicting items
Throws:
BuildException - If there is a problem while building the style items

applyRules

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)
Apply the rules registry

Parameters:
rules - The rules to apply
baseRegistry - The default rules of the application
ruleConflicts - A list with names of all conflicting rules
vgv - The VisualGraphView to apply the rules to
xmlData - The complete and unmodified data from the XML file.
visualGraphViews - The additional VisualGraphViews to apply the rules to
applyAction - The type of apply action to do
renameMap - A map containing new names for all conflicting elements that should be renamed

applyRules

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)
Apply the rules registry

Parameters:
rules - The rules to apply
baseRegistry - The default rules of the application
ruleConflicts - A list with names of all conflicting rules
vgv - The VisualGraphView to apply the rules to
xmlData - The complete and unmodified data from the XML file.
visualGraphViews - The additional VisualGraphViews to apply the rules to
applyAction - The type of apply action to do
renameMap - A map containing new names for all conflicting elements that should be renamed
addUnconflicting - If this is true, all rules without a conflict will be added to all open documents and the defaults

duplicateRule

public 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.

Parameters:
rule - The rule to duplicate
newName - The name for the new rule
Returns:
The new rule

internalCompareGeometryItemWithAttributeList

public static final boolean internalCompareGeometryItemWithAttributeList(GeometryItem item,
                                                                         AttributeList list)
Compares a GeometryItem instance with an AttributeList of a serialized GeometryItem.

Parameters:
item - The geometry item
list - The serialization of a geometry item
Returns:
True, if these two representations are equal

internalCompareGeometryDescriptorWithAttributeList

public static final boolean internalCompareGeometryDescriptorWithAttributeList(GeometryDescriptor gd,
                                                                               AttributeList list)
Compares a GeometryDescriptor instance with an AttributeList of a serialized GeometryDescriptor.

Parameters:
gd - The geometry descriptor
list - The serialization of a geometry descriptor
Returns:
True, if these two representations are equal

internalCompareStyleItemWithAttributeList

public static final boolean internalCompareStyleItemWithAttributeList(StyleItem si,
                                                                      AttributeList list)
Compares a StyleItem instance with an AttributeList of a serialized StyleItem.

Parameters:
si - The style item
list - The serialization of a style item
Returns:
True, if these two representations are equal

internalCompareStyleDescriptorWithAttributeList

public static final boolean internalCompareStyleDescriptorWithAttributeList(StyleDescriptor sd,
                                                                            AttributeList list)
Compares a StyleDescriptor instance with an AttributeList of a serialized StyleDescriptor.

Parameters:
sd - The style descriptor
list - The serialization of a style descriptor
Returns:
True, if these two representations are equal

getOption

public 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.

Parameters:
prefs - The preferences
key - The key of the setting in the preferences
Returns:
one of the apply action constants that correspond to the value of the setting in the preferences with the given key. A default value of APPLY_LOADED is returned when the preferences do not contain the setting or the value is invalid.

setOption

public 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.

Parameters:
prefs - The preferences to alter
key - The key of the setting in the preferences
option - The apply action represented by one of the constants defined in this class

getLayoutContextOptionDefault

public static int getLayoutContextOptionDefault(Preferences prefs)
Returns the default option for resolving layout conflicts.

Parameters:
prefs - The preferences to get the default option from.
Returns:
The option set in the preferences or APPLY_LOADED as default.

getImagesOptionDefault

public static int getImagesOptionDefault(Preferences prefs)
Returns the default option for resolving image conflicts.

Parameters:
prefs - The preferences to get the default option from.
Returns:
The option set in the preferences or APPLY_LOADED as default.

getStylesOptionDefault

public static int getStylesOptionDefault(Preferences prefs)
Returns the default option for resolving style conflicts.

Parameters:
prefs - The preferences to get the default option from.
Returns:
The option set in the preferences or APPLY_LOADED as default.

getStyleNamesOptionDefault

public static int getStyleNamesOptionDefault(Preferences prefs)
Returns the default option for resolving style name conflicts.

Parameters:
prefs - The preferences to get the default option from.
Returns:
The option set in the preferences or APPLY_LOADED as default.

getGeometriesOptionDefault

public static int getGeometriesOptionDefault(Preferences prefs)
Returns the default option for resolving geometry conflicts.

Parameters:
prefs - The preferences to get the default option from.
Returns:
The option set in the preferences or APPLY_LOADED as default.

getRulesOptionDefault

public static int getRulesOptionDefault(Preferences prefs)
Returns the default option for resolving rule conflicts.

Parameters:
prefs - The preferences to get the default option from.
Returns:
The option set in the preferences or APPLY_LOADED as default.

setLayoutContextOptionDefault

public static void setLayoutContextOptionDefault(Preferences prefs,
                                                 int option)
Sets the default option for resolving layout conflicts.

Parameters:
prefs - The preferences to set the default option to
option - The option to set in the preferences

setImagesOptionDefault

public static void setImagesOptionDefault(Preferences prefs,
                                          int option)
Sets the default option for resolving image conflicts.

Parameters:
prefs - The preferences to set the default option to
option - The option to set in the preferences

setStylesOptionDefault

public static void setStylesOptionDefault(Preferences prefs,
                                          int option)
Sets the default option for resolving style conflicts.

Parameters:
prefs - The preferences to set the default option to
option - The option to set in the preferences

setStyleNamesOptionDefault

public static void setStyleNamesOptionDefault(Preferences prefs,
                                              int option)
Sets the default option for resolving style name conflicts.

Parameters:
prefs - The preferences to set the default option to
option - The option to set in the preferences

setGeometriesOptionDefault

public static void setGeometriesOptionDefault(Preferences prefs,
                                              int option)
Sets the default option for resolving geometry conflicts.

Parameters:
prefs - The preferences to set the default option to
option - The option to set in the preferences

setRulesOptionDefault

public static void setRulesOptionDefault(Preferences prefs,
                                         int option)
Sets the default option for resolving rules conflicts.

Parameters:
prefs - The preferences to set the default option to
option - The option to set in the preferences

isTrueByDefault

public 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.

Parameters:
prefs - The preferences to get the value from
key - The key of the setting to return
Returns:
true, if the setting in the preferences with the given key is a Boolean with the value TRUE.

createListArray

public static java.util.List[] createListArray(java.util.List items,
                                               java.util.List descriptors)
Creates an array with the dimension 2, using the index constants.

Parameters:
items - The items to set
descriptors - The descriptors to set
Returns:
The List-Array

checkForMissingFonts

public static ElementDefinitionUtil.RenameAttributable checkForMissingFonts(AttributeList list,
                                                                            AttributeList styles)
Checks, if fonts are used that are not available. The method creates an attributable which can be used in an AttributableOnSetDialog to select new fonts for all the missing fonts.

Parameters:
list - The loaded document as attribute list
styles - The loaded styles to check for missing fonts
Returns:
The attributable used to rename or null, if nothing is missing

checkForMissingRules

public static ElementDefinitionUtil.RenameAttributable checkForMissingRules(RuleRegistry defaultRegistry,
                                                                            java.util.Map mapRules)
Checks, if rules in the map are not defined in the rule registry. The method creates an attributable which can be used in an AttributableOnSetDialog to select new rules for all the missing rules.

Parameters:
defaultRegistry - The registry defining the available rules
mapRules - A map containing all names of requested rules and the class of the rule (NodeRule.class, GraphRule.class or EdgeRule.class)
Returns:
The attributable used to rename or null, if nothing is missing

checkForMissingLayoutContexts

public static ElementDefinitionUtil.RenameAttributable checkForMissingLayoutContexts(java.lang.String[] controllerContexts,
                                                                                     VisualGraphView vgv)
                                                                              throws ConstraintParserException
Checks, if elements in the 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.

Parameters:
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 context
vgv - The VisualGraphView
Returns:
The attributable used to rename or null, if nothing is missing
Throws:
ConstraintParserException - If a constraint for the attributable can't be created

renameMissingFonts

public static final void renameMissingFonts(AttributeList list,
                                            AttributeList styles,
                                            ElementDefinitionUtil.RenameAttributable attributable)
Renames the missing fonts according to the given rename attributable

Parameters:
list - The loaded document as attribute list
styles - The loaded styles containing the fonts
attributable - The rename attributable containing the new names

renameMissingLayoutContexts

public static final void renameMissingLayoutContexts(VisualGraphView vgv,
                                                     ElementDefinitionUtil.RenameAttributable attributable,
                                                     java.lang.String[] controllerContexts)
Renames the missing layout contexts according to the given rename attributable

Parameters:
vgv - The VisualGraphView containing the layoutables
attributable - The rename attributable containing the new names
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 context

gatherUsedItems

public static ElementDefinitionUtil.UsedItemInfo gatherUsedItems(GraphDocument gDoc)
Gathers all items of type StyleDescriptor, StyleItem, GeometryDescriptor, GeometryItem and Rule that are used in the given GraphDocument.

Parameters:
gDoc - The GraphDocument to check
Returns:
An UsedItemInfo structure containing the infos

gatherUsedItems

public static ElementDefinitionUtil.UsedItemInfo gatherUsedItems(VisualGraphView vgv)
Gathers all items of type StyleDescriptor, StyleItem, GeometryDescriptor, GeometryItem and Rule that are used in the given GraphDocument.

Parameters:
vgv - The VisualGraphView to check
Returns:
An UsedItemInfo structure containing the infos


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.