Author: tfmorris
Date: 2008-11-15 11:19:09-0800
New Revision: 16052
Added:
trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramSettings.java (contents, props changed)
trunk/src/argouml-app/tests/org/argouml/uml/diagram/TestDiagramSettings.java (contents, props changed)
Modified:
trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java
Log:
Factor diagram related settings into a separate class so that the diagram subsystem can be decoupled from dependency on Project
Modified: trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java?view=diff&rev=16052&p1=trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java&p2=trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java&r1=16051&r2=16052
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java (original)
+++ trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java 2008-11-15 11:19:09-0800
@@ -37,6 +37,7 @@
import org.argouml.notation.NotationName;
import org.argouml.notation.NotationProviderFactory2;
import org.argouml.uml.diagram.DiagramAppearance;
+import org.argouml.uml.diagram.DiagramSettings;
import org.tigris.gef.undo.Memento;
import org.tigris.gef.undo.UndoManager;
@@ -47,7 +48,7 @@
* This is also the reason all these attributes
* are not part of a Map or something. <p>
*
- * TODO: The header comment is curently not used - this function
+ * TODO: The header comment is currently not used - this function
* is not completely implemented yet. How do we store this in the project?
* Where should the user enter his header comment? See issue 4813.
*
@@ -55,30 +56,9 @@
*/
public class ProjectSettings {
- /* The notation settings with project scope: */
- private String notationLanguage;
- private boolean showBoldNames;
- private boolean useGuillemots;
- private boolean showAssociationNames;
- private boolean showVisibility;
- private boolean showMultiplicity;
- private boolean showInitialValue;
- private boolean showProperties;
- private boolean showTypes;
- private boolean showStereotypes;
- private boolean showSingularMultiplicities;
- private int defaultShadowWidth;
- private int defaultStereotypeView;
-
- /* Diagram appearance settings with project scope: */
- private String fontName;
- private int fontSize;
- private boolean hideBidirectionalArrows;
- /* Keep some fonts around depending on the above settings: */
- private Font fontPlain;
- private Font fontItalic;
- private Font fontBold;
- private Font fontBoldItalic;
+ // Default diagram settings
+ private DiagramSettings diaDefault;
+
/* Generation preferences: */
private String headerComment =
@@ -95,165 +75,124 @@
ProjectSettings() {
super();
- notationLanguage =
+ diaDefault = new DiagramSettings();
+
+ String notationLanguage =
Notation.getConfiguredNotation().getConfigurationValue();
+ // TODO: The concept of a single global notation language doesn't
+ // work with multiple projects
NotationProviderFactory2.setCurrentLanguage(notationLanguage);
- showBoldNames = Configuration.getBoolean(
- Notation.KEY_SHOW_BOLD_NAMES);
- useGuillemots = Configuration.getBoolean(
- Notation.KEY_USE_GUILLEMOTS, false);
+ diaDefault.setNotationLanguage(notationLanguage);
+
+ diaDefault.setShowBoldNames(Configuration.getBoolean(
+ Notation.KEY_SHOW_BOLD_NAMES));
+ diaDefault.setUseGuillemets(Configuration.getBoolean(
+ Notation.KEY_USE_GUILLEMOTS, false));
/*
* The next one defaults to TRUE, to stay compatible with older
* ArgoUML versions that did not have this setting:
*/
- showAssociationNames = Configuration.getBoolean(
- Notation.KEY_SHOW_ASSOCIATION_NAMES, true);
- showVisibility = Configuration.getBoolean(
- Notation.KEY_SHOW_VISIBILITY);
- showMultiplicity = Configuration.getBoolean(
- Notation.KEY_SHOW_MULTIPLICITY);
- showInitialValue = Configuration.getBoolean(
- Notation.KEY_SHOW_INITIAL_VALUE);
- showProperties = Configuration.getBoolean(
- Notation.KEY_SHOW_PROPERTIES);
+ diaDefault.setShowAssociationNames(Configuration.getBoolean(
+ Notation.KEY_SHOW_ASSOCIATION_NAMES, true));
+ diaDefault.setShowVisibility(Configuration.getBoolean(
+ Notation.KEY_SHOW_VISIBILITY));
+ diaDefault.setShowMultiplicity(Configuration.getBoolean(
+ Notation.KEY_SHOW_MULTIPLICITY));
+ diaDefault.setShowInitialValue(Configuration.getBoolean(
+ Notation.KEY_SHOW_INITIAL_VALUE));
+ diaDefault.setShowProperties(Configuration.getBoolean(
+ Notation.KEY_SHOW_PROPERTIES));
/*
* The next ones defaults to TRUE, to stay compatible with older
* ArgoUML versions that did not have this setting:
*/
- showTypes = Configuration.getBoolean(Notation.KEY_SHOW_TYPES, true);
- hideBidirectionalArrows = Configuration.getBoolean(
- Notation.KEY_HIDE_BIDIRECTIONAL_ARROWS, true);
+ diaDefault.setShowTypes(Configuration.getBoolean(
+ Notation.KEY_SHOW_TYPES, true));
+ diaDefault.setShowBidirectionalArrows(!Configuration.getBoolean(
+ Notation.KEY_HIDE_BIDIRECTIONAL_ARROWS, true));
- showStereotypes = Configuration.getBoolean(
- Notation.KEY_SHOW_STEREOTYPES);
+ diaDefault.setShowStereotypes(Configuration.getBoolean(
+ Notation.KEY_SHOW_STEREOTYPES));
/*
* The next one defaults to TRUE, despite that this is
* NOT compatible with older ArgoUML versions
* (before 0.24) that did
* not have this setting - see issue 1395 for the rationale:
*/
- showSingularMultiplicities = Configuration.getBoolean(
- Notation.KEY_SHOW_SINGULAR_MULTIPLICITIES, true);
- defaultShadowWidth = Configuration.getInteger(
- Notation.KEY_DEFAULT_SHADOW_WIDTH, 1);
- defaultStereotypeView = Configuration.getInteger(
+ diaDefault.setShowSingularMultiplicities(Configuration.getBoolean(
+ Notation.KEY_SHOW_SINGULAR_MULTIPLICITIES, true));
+ diaDefault.setDefaultShadowWidth(Configuration.getInteger(
+ Notation.KEY_DEFAULT_SHADOW_WIDTH, 1));
+ diaDefault.setDefaultStereotypeView(Configuration.getInteger(
ProfileConfiguration.KEY_DEFAULT_STEREOTYPE_VIEW,
- DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL);
+ DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL));
/*
* Diagram appearance settings:
*/
- fontName = DiagramAppearance.getInstance().getConfiguredFontName();
- fontSize = Configuration.getInteger(DiagramAppearance.KEY_FONT_SIZE);
- /* And initialise some fonts: */
- initFonts();
+ diaDefault.setFontName(
+ DiagramAppearance.getInstance().getConfiguredFontName());
+ diaDefault.setFontSize(
+ Configuration.getInteger(DiagramAppearance.KEY_FONT_SIZE));
+
}
/**
- * Send all events... <p>
- * This code fixes the following problem when loading a project:
- * In the ProjectBrowser, the new project is loaded,
- * and only when successful, the old one is removed.
- * While loading, the Figs read the notation settings to be able
- * to draw themselves correctly from the wrong project,
- * since the old project is still the "current" one.
- * Hence, after the ProjectBrowser finished loading,
- * it sets the current project to the new one, removes the
- * old project, and then calls this init() method, to set
- * all notation settings right - which refreshes the screen. <p>
- * TODO: Find a better way,
- * which does not cause the diagrams to be drawn wrongly
- * first, and then corrected.
+ * Send all events required for post-load of project.<p>
+ * @deprecated for 0.27.2 by tfmorris. No replacement. Diagrams/Figs are
+ * now created with the correct initial settings.
*/
+ @Deprecated
public void init() {
- /* Since this is (hopefully) a temporary solution,
- * and nobody ever looks at the type of notation event,
- * we can simplify from sending every existing event
- * to one event only. But since there is no
- * catch-all event defined, we just make one up.
- * Rationale: reduce the number of total
- * refreshes of the drawing. */
+ /*
+ * Since this is (hopefully) a temporary solution, and nobody ever looks
+ * at the type of notation event, we can simplify from sending every
+ * existing event to one event only. But since there is no catch-all
+ * event defined, we just make one up. Rationale: reduce the number of
+ * total refreshes of the drawing.
+ */
init(true, Configuration.makeKey("notation", "all"));
- /* The above hence replaces the following statements.
- * If ever someone needs to dissect notation events,
- * we may need to add these again. */
-// init(notationLanguage,
-// Notation.KEY_DEFAULT_NOTATION);
-// init(showBoldNames,
-// Notation.KEY_SHOW_BOLD_NAMES);
-// init(useGuillemots,
-// Notation.KEY_USE_GUILLEMOTS);
-// init(showAssociationNames,
-// Notation.KEY_SHOW_ASSOCIATION_NAMES);
-// init(showVisibility,
-// Notation.KEY_SHOW_VISIBILITY);
-// init(showMultiplicity,
-// Notation.KEY_SHOW_MULTIPLICITY);
-// init(showInitialValue,
-// Notation.KEY_SHOW_INITIAL_VALUE);
-// init(showProperties,
-// Notation.KEY_SHOW_PROPERTIES);
-// init(showTypes,
-// Notation.KEY_SHOW_TYPES);
-// init(showStereotypes,
-// Notation.KEY_SHOW_STEREOTYPES);
-// init(showSingularMultiplicities,
-// Notation.KEY_SHOW_SINGULAR_MULTIPLICITIES);
-// init(defaultShadowWidth,
-// Notation.KEY_DEFAULT_SHADOW_WIDTH);
-
- /* Since this is (hopefully) a temporary solution,
- * and nobody ever looks at the type of the
- * diagram appearance event,
- * we can simplify from sending every existing event
- * to one event only. But since there is no
- * catch-all event defined, we just use one.
- * Rationale: reduce the number of total
- * refreshes of the drawing. */
+ /*
+ * Since this is (hopefully) a temporary solution, and nobody ever looks
+ * at the type of the diagram appearance event, we can simplify from
+ * sending every existing event to one event only. But since there is no
+ * catch-all event defined, we just use one. Rationale: reduce the
+ * number of total refreshes of the drawing.
+ */
fireDiagramAppearanceEvent(
Configuration.makeKey("diagramappearance", "all"),
0, 0);
- /* The above hence replaces the following statements.
- * If ever someone needs to dissect
- * diagram-appearance events,
- * we may need to add these again. */
-// fireDiagramAppearanceEvent(DiagramAppearance.KEY_FONT_NAME,
-// fontName, fontName);
-// fireDiagramAppearanceEvent(DiagramAppearance.KEY_FONT_SIZE,
-// fontSize, fontSize);
- }
-
- @SuppressWarnings("unused")
- private void init(String value, ConfigurationKey key) {
- fireNotationEvent(key, value, value);
}
private void init(boolean value, ConfigurationKey key) {
fireNotationEvent(key, value, value);
}
-
- @SuppressWarnings("unused")
- private void init(int value, ConfigurationKey key) {
- fireNotationEvent(key, value, value);
+
+ /**
+ * @return the default diagram settings
+ */
+ public DiagramSettings getDefaultDiagramSettings() {
+ return diaDefault;
}
+
/**
* Used by "argo.tee".
*
* @return Returns the notation language.
*/
public String getNotationLanguage() {
- return notationLanguage;
+ return diaDefault.getNotationLanguage();
}
/**
* @return Returns the notation language.
*/
public NotationName getNotationName() {
- return Notation.findNotation(notationLanguage);
+ return Notation.findNotation(getNotationLanguage());
}
/**
@@ -261,7 +200,7 @@
* @return true if the notation is set - false if it does not exist
*/
public boolean setNotationLanguage(final String newLanguage) {
- if (notationLanguage.equals(newLanguage)) {
+ if (getNotationLanguage().equals(newLanguage)) {
return true;
}
if (Notation.findNotation(newLanguage) == null) {
@@ -269,29 +208,35 @@
return false;
}
- final String oldLanguage = notationLanguage;
+ final String oldLanguage = getNotationLanguage();
Memento memento = new Memento() {
private final ConfigurationKey key = Notation.KEY_DEFAULT_NOTATION;
public void redo() {
- notationLanguage = newLanguage;
+ diaDefault.setNotationLanguage(newLanguage);
NotationProviderFactory2.setCurrentLanguage(newLanguage);
fireNotationEvent(key, oldLanguage, newLanguage);
}
public void undo() {
- notationLanguage = oldLanguage;
+ diaDefault.setNotationLanguage(oldLanguage);
NotationProviderFactory2.setCurrentLanguage(oldLanguage);
fireNotationEvent(key, newLanguage, oldLanguage);
}
};
+ doUndoable(memento);
+ return true;
+ }
+
+ private void doUndoable(Memento memento) {
+ // TODO: This needs to be managing undo on a per-project basis
+ // instead of using GEF's global undo manager
if (UndoManager.getInstance().isGenerateMementos()) {
UndoManager.getInstance().addMemento(memento);
}
memento.redo();
ProjectManager.getManager().setSaveEnabled(true);
- return true;
}
/**
@@ -307,28 +252,34 @@
* @return Returns "true" if we show bold names.
*/
public String getShowBoldNames() {
- return Boolean.toString(showBoldNames);
+ return Boolean.toString(getShowBoldNamesValue());
}
/**
* @return Returns <code>true</code> if we show bold names.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public boolean getShowBoldNamesValue() {
- return showBoldNames;
+ return diaDefault.isShowBoldNames();
}
/**
* @param showbold <code>true</code> if names are to be shown in bold font.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowBoldNames(String showbold) {
setShowBoldNames(Boolean.valueOf(showbold).booleanValue());
}
/**
* @param showem <code>true</code> if names are to be shown in bold font.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowBoldNames(final boolean showem) {
- if (showBoldNames == showem) {
+ if (diaDefault.isShowBoldNames() == showem) {
return;
}
@@ -336,52 +287,56 @@
private final ConfigurationKey key = Notation.KEY_SHOW_BOLD_NAMES;
public void redo() {
- showBoldNames = showem;
+ diaDefault.setShowBoldNames(showem);
fireNotationEvent(key, !showem, showem);
}
public void undo() {
- showBoldNames = !showem;
+ diaDefault.setShowBoldNames(!showem);
fireNotationEvent(key, showem, !showem);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
* Used by "argo.tee".
*
- * @return Returns "true" if we show guillemots.
+ * @see #getUseGuillemotsValue()
+ * @return Returns "true" if we show guillemets.
*/
public String getUseGuillemots() {
- return Boolean.toString(useGuillemots);
+ return Boolean.toString(getUseGuillemotsValue());
}
/**
- * @return Returns <code>true</code> if we show guillemots.
+ * Get setting controlling whether guillemets (the double angle brackets
+ * quotation mark characters from Unicode) are to be used for formatting
+ * instead of two individual characters for each quote mark (e.g. >>). NOTE:
+ * This affects not only the Diagrams, but also display in the explorer view
+ * and other places.
+ *
+ * @return Returns <code>true</code> if we show guillemets.
*/
public boolean getUseGuillemotsValue() {
- return useGuillemots;
+ return diaDefault.isUseGuillemets();
}
/**
- * @param showem <code>true</code> if guillemots are to be shown.
+ * @see #getUseGuillemotsValue()
+ * @param showem <code>true</code> if guillemets are to be used.
*/
public void setUseGuillemots(String showem) {
setUseGuillemots(Boolean.valueOf(showem).booleanValue());
}
/**
- * @param showem <code>true</code> if guillemots are to be shown.
+ * @see #getUseGuillemotsValue()
+ * @param showem <code>true</code> if guillemets are to be shown.
*/
-
public void setUseGuillemots(final boolean showem) {
- if (useGuillemots == showem) {
+ if (getUseGuillemotsValue() == showem) {
return;
}
@@ -389,64 +344,76 @@
private final ConfigurationKey key = Notation.KEY_USE_GUILLEMOTS;
public void redo() {
- useGuillemots = showem;
+ diaDefault.setUseGuillemets(showem);
fireNotationEvent(key, !showem, showem);
}
public void undo() {
- useGuillemots = !showem;
+ diaDefault.setUseGuillemets(!showem);
fireNotationEvent(key, showem, !showem);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
- * @return the left pointing guillemot, i.e. << or the one-character symbol
+ * @return the left pointing guillemet, i.e. << or the one-character symbol
+ * @deprecated for 0.27.2 by tfmorris. There's no need for a separate method
+ * for this. It can be easily handled in a format string using
+ * the results of {@link DiagramSettings#isUseGuillemets()}.
*/
+ @Deprecated
public String getLeftGuillemot() {
- return useGuillemots ? "\u00ab" : "<<";
+ return getUseGuillemotsValue() ? "\u00ab" : "<<";
}
/**
- * @return the right pointing guillemot, i.e. >> or the one-character symbol
+ * @return the right pointing guillemet, i.e. >> or the one-character symbol
+ * @deprecated for 0.27.2 by tfmorris. There's no need for a separate method
+ * for this. It can be easily handled in a format string using
+ * the results of {@link DiagramSettings#isUseGuillemets()}.
*/
+ @Deprecated
public String getRightGuillemot() {
- return useGuillemots ? "\u00bb" : ">>";
+ return getUseGuillemotsValue() ? "\u00bb" : ">>";
}
/**
* Used by "argo.tee".
*
* @return Returns "true" if we show association names.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getShowAssociationNames() {
- return Boolean.toString(showAssociationNames);
+ return Boolean.toString(getShowAssociationNamesValue());
}
/**
* @return Returns <code>true</code> if we show association names.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public boolean getShowAssociationNamesValue() {
- return showAssociationNames;
+ return diaDefault.isShowAssociationNames();
}
/**
* @param showem <code>true</code> if association names are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowAssociationNames(String showem) {
setShowAssociationNames(Boolean.valueOf(showem).booleanValue());
}
/**
* @param showem <code>true</code> if association names are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowAssociationNames(final boolean showem) {
- if (showAssociationNames == showem) {
+ if (diaDefault.isShowAssociationNames() == showem) {
return;
}
@@ -455,50 +422,54 @@
Notation.KEY_SHOW_ASSOCIATION_NAMES;
public void redo() {
- showAssociationNames = showem;
+ diaDefault.setShowAssociationNames(showem);
fireNotationEvent(key, !showem, showem);
}
public void undo() {
- showAssociationNames = !showem;
+ diaDefault.setShowAssociationNames(!showem);
fireNotationEvent(key, showem, !showem);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
* Used by "argo.tee".
*
* @return Returns "true" if we show visibilities.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getShowVisibility() {
- return Boolean.toString(showVisibility);
+ return Boolean.toString(getShowVisibilityValue());
}
/**
* @return Returns <code>true</code> if we show visibilities.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public boolean getShowVisibilityValue() {
- return showVisibility;
+ return diaDefault.isShowVisibility();
}
/**
* @param showem <code>true</code> if visibilities are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowVisibility(String showem) {
setShowVisibility(Boolean.valueOf(showem).booleanValue());
}
/**
* @param showem <code>true</code> if visibilities are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowVisibility(final boolean showem) {
- if (showVisibility == showem) {
+ if (diaDefault.isShowVisibility() == showem) {
return;
}
@@ -506,50 +477,54 @@
private final ConfigurationKey key = Notation.KEY_SHOW_VISIBILITY;
public void redo() {
- showVisibility = showem;
+ diaDefault.setShowVisibility(showem);
fireNotationEvent(key, !showem, showem);
}
public void undo() {
- showVisibility = !showem;
+ diaDefault.setShowVisibility(!showem);
fireNotationEvent(key, showem, !showem);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
* Used by "argo.tee".
*
* @return Returns "true" if we show multiplicities.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getShowMultiplicity() {
- return Boolean.toString(showMultiplicity);
+ return Boolean.toString(getShowMultiplicityValue());
}
/**
* @return Returns <code>true</code> if we show multiplicities.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public boolean getShowMultiplicityValue() {
- return showMultiplicity;
+ return diaDefault.isShowMultiplicity();
}
/**
* @param showem <code>true</code> if multiplicity is to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowMultiplicity(String showem) {
setShowMultiplicity(Boolean.valueOf(showem).booleanValue());
}
/**
* @param showem <code>true</code> if the multiplicity is to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowMultiplicity(final boolean showem) {
- if (showMultiplicity == showem) {
+ if (diaDefault.isShowMultiplicity() == showem) {
return;
}
@@ -557,50 +532,54 @@
private final ConfigurationKey key = Notation.KEY_SHOW_MULTIPLICITY;
public void redo() {
- showMultiplicity = showem;
+ diaDefault.setShowMultiplicity(showem);
fireNotationEvent(key, !showem, showem);
}
public void undo() {
- showMultiplicity = !showem;
+ diaDefault.setShowMultiplicity(!showem);
fireNotationEvent(key, showem, !showem);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
* Used by "argo.tee".
*
* @return Returns "true" if we show initial values.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getShowInitialValue() {
- return Boolean.toString(showInitialValue);
+ return Boolean.toString(getShowInitialValueValue());
}
/**
* @return Returns <code>true</code> if we show initial values.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public boolean getShowInitialValueValue() {
- return showInitialValue;
+ return diaDefault.isShowInitialValue();
}
/**
* @param showem <code>true</code> if initial values are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowInitialValue(String showem) {
setShowInitialValue(Boolean.valueOf(showem).booleanValue());
}
/**
* @param showem <code>true</code> if initial values are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowInitialValue(final boolean showem) {
- if (showInitialValue == showem) {
+ if (diaDefault.isShowInitialValue() == showem) {
return;
}
@@ -609,50 +588,54 @@
Notation.KEY_SHOW_INITIAL_VALUE;
public void redo() {
- showInitialValue = showem;
+ diaDefault.setShowInitialValue(showem);
fireNotationEvent(key, !showem, showem);
}
public void undo() {
- showInitialValue = !showem;
+ diaDefault.setShowInitialValue(!showem);
fireNotationEvent(key, showem, !showem);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
* Used by "argo.tee".
*
* @return Returns "true" if we show properties.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getShowProperties() {
- return Boolean.toString(showProperties);
+ return Boolean.toString(getShowPropertiesValue());
}
/**
* @return Returns <code>true</code> if we show properties.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public boolean getShowPropertiesValue() {
- return showProperties;
+ return diaDefault.isShowProperties();
}
/**
* @param showem <code>true</code> if properties are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowProperties(String showem) {
setShowProperties(Boolean.valueOf(showem).booleanValue());
}
/**
* @param showem <code>true</code> if properties are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowProperties(final boolean showem) {
- if (showProperties == showem) {
+ if (diaDefault.isShowProperties() == showem) {
return;
}
@@ -661,50 +644,54 @@
Notation.KEY_SHOW_PROPERTIES;
public void redo() {
- showProperties = showem;
+ diaDefault.setShowProperties(showem);
fireNotationEvent(key, !showem, showem);
}
public void undo() {
- showProperties = !showem;
+ diaDefault.setShowProperties(!showem);
fireNotationEvent(key, showem, !showem);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
* Used by "argo.tee".
*
* @return Returns "true" if we show types.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getShowTypes() {
- return Boolean.toString(showTypes);
+ return Boolean.toString(getShowTypesValue());
}
/**
* @return Returns <code>true</code> if we show types.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public boolean getShowTypesValue() {
- return showTypes;
+ return diaDefault.isShowTypes();
}
/**
* @param showem <code>true</code> if types are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowTypes(String showem) {
setShowTypes(Boolean.valueOf(showem).booleanValue());
}
/**
* @param showem <code>true</code> if types are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowTypes(final boolean showem) {
- if (showTypes == showem) {
+ if (diaDefault.isShowTypes() == showem) {
return;
}
@@ -712,20 +699,16 @@
private final ConfigurationKey key = Notation.KEY_SHOW_TYPES;
public void redo() {
- showTypes = showem;
+ diaDefault.setShowTypes(showem);
fireNotationEvent(key, !showem, showem);
}
public void undo() {
- showTypes = !showem;
+ diaDefault.setShowTypes(!showem);
fireNotationEvent(key, showem, !showem);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
@@ -733,30 +716,41 @@
* Used by "argo.tee".
*
* @return Returns "true" if we show stereotypes.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getShowStereotypes() {
- return Boolean.toString(showStereotypes);
+ return Boolean.toString(getShowStereotypesValue());
}
/**
+ * TODO: Is this used in places other than on Diagrams? If so, it needs to
+ * stay in ProjectSettings (as well as being a DiagramSetting).
+ *
* @return Returns <code>true</code> if we show stereotypes.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public boolean getShowStereotypesValue() {
- return showStereotypes;
+ return diaDefault.isShowStereotypes();
}
/**
* @param showem <code>true</code> if stereotypes are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowStereotypes(String showem) {
setShowStereotypes(Boolean.valueOf(showem).booleanValue());
}
/**
* @param showem <code>true</code> if stereotypes are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowStereotypes(final boolean showem) {
- if (showStereotypes == showem) {
+ if (diaDefault.isShowStereotypes() == showem) {
return;
}
@@ -764,50 +758,54 @@
private final ConfigurationKey key = Notation.KEY_SHOW_STEREOTYPES;
public void redo() {
- showStereotypes = showem;
+ diaDefault.setShowStereotypes(showem);
fireNotationEvent(key, !showem, showem);
}
public void undo() {
- showStereotypes = !showem;
+ diaDefault.setShowStereotypes(!showem);
fireNotationEvent(key, showem, !showem);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
* Used by "argo.tee".
*
* @return Returns "true" if we show "1" Multiplicities.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getShowSingularMultiplicities() {
- return Boolean.toString(showSingularMultiplicities);
+ return Boolean.toString(getShowSingularMultiplicitiesValue());
}
/**
* @return Returns <code>true</code> if we show "1" Multiplicities.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public boolean getShowSingularMultiplicitiesValue() {
- return showSingularMultiplicities;
+ return diaDefault.isShowSingularMultiplicities();
}
/**
* @param showem <code>true</code> if "1" Multiplicities are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowSingularMultiplicities(String showem) {
setShowSingularMultiplicities(Boolean.valueOf(showem).booleanValue());
}
/**
* @param showem <code>true</code> if "1" Multiplicities are to be shown.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setShowSingularMultiplicities(final boolean showem) {
- if (showSingularMultiplicities == showem) {
+ if (diaDefault.isShowSingularMultiplicities() == showem) {
return;
}
@@ -816,20 +814,16 @@
Notation.KEY_SHOW_SINGULAR_MULTIPLICITIES;
public void redo() {
- showSingularMultiplicities = showem;
+ diaDefault.setShowSingularMultiplicities(showem);
fireNotationEvent(key, !showem, showem);
}
public void undo() {
- showSingularMultiplicities = !showem;
+ diaDefault.setShowSingularMultiplicities(!showem);
fireNotationEvent(key, showem, !showem);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
@@ -837,24 +831,30 @@
*
* @return Returns "true" if we show the arrows when
* both association ends of an association are navigable.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getHideBidirectionalArrows() {
- return Boolean.toString(hideBidirectionalArrows);
+ return Boolean.toString(getHideBidirectionalArrowsValue());
}
/**
* @return Returns <code>true</code> if we show the arrows when
* both association ends of an association are navigable.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public boolean getHideBidirectionalArrowsValue() {
- return hideBidirectionalArrows;
+ return !diaDefault.isShowBidirectionalArrows();
}
/**
* @param hideem <code>true</code> if both arrows are to be shown when
* both association ends of an association are navigable.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setHideBidirectionalArrows(String hideem) {
setHideBidirectionalArrows(Boolean.valueOf(hideem).booleanValue());
}
@@ -862,10 +862,11 @@
/**
* @param hideem <code>true</code> if both arrows are to be shown when
* both association ends of an association are navigable.
-
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setHideBidirectionalArrows(final boolean hideem) {
- if (hideBidirectionalArrows == hideem) {
+ if (diaDefault.isShowBidirectionalArrows() == !hideem) {
return;
}
@@ -874,72 +875,71 @@
Notation.KEY_HIDE_BIDIRECTIONAL_ARROWS;
public void redo() {
- hideBidirectionalArrows = hideem;
+ diaDefault.setShowBidirectionalArrows(!hideem);
fireNotationEvent(key, !hideem, hideem);
}
public void undo() {
- hideBidirectionalArrows = !hideem;
+ diaDefault.setShowBidirectionalArrows(hideem);
fireNotationEvent(key, hideem, !hideem);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
* Used by "argo.tee".
*
* @return Returns the shadow width.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getDefaultShadowWidth() {
- return Integer.valueOf(defaultShadowWidth).toString();
+ return Integer.valueOf(getDefaultShadowWidthValue()).toString();
}
/**
* @return Returns the shadow width.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public int getDefaultShadowWidthValue() {
- return defaultShadowWidth;
+ return diaDefault.getDefaultShadowWidth();
}
/**
* @param newWidth The Shadow Width.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setDefaultShadowWidth(final int newWidth) {
- if (defaultShadowWidth == newWidth) {
+ final int oldValue = diaDefault.getDefaultShadowWidth();
+ if (oldValue == newWidth) {
return;
}
- final int oldValue = defaultShadowWidth;
-
Memento memento = new Memento() {
private final ConfigurationKey key =
Notation.KEY_DEFAULT_SHADOW_WIDTH;
public void redo() {
- defaultShadowWidth = newWidth;
+ diaDefault.setDefaultShadowWidth(newWidth);
fireNotationEvent(key, oldValue, newWidth);
}
public void undo() {
- defaultShadowWidth = oldValue;
+ diaDefault.setDefaultShadowWidth(oldValue);
fireNotationEvent(key, newWidth, oldValue);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
* @param width The shadow width to set.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setDefaultShadowWidth(String width) {
setDefaultShadowWidth(Integer.parseInt(width));
}
@@ -948,16 +948,20 @@
* Used by "argo.tee".
*
* @return Returns the default stereotype view
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getDefaultStereotypeView() {
- return Integer.valueOf(defaultStereotypeView).toString();
+ return Integer.valueOf(getDefaultStereotypeViewValue()).toString();
}
/**
* @return Returns the default stereotype view
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public int getDefaultStereotypeViewValue() {
- return defaultStereotypeView;
+ return diaDefault.getDefaultStereotypeViewInt();
}
@@ -992,34 +996,30 @@
/**
* @param newView the default stereotype view
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setDefaultStereotypeView(final int newView) {
-
- if (defaultStereotypeView == newView) {
+ final int oldValue = diaDefault.getDefaultStereotypeViewInt();
+ if (oldValue == newView) {
return;
}
- final int oldValue = defaultStereotypeView;
-
Memento memento = new Memento() {
private final ConfigurationKey key =
ProfileConfiguration.KEY_DEFAULT_STEREOTYPE_VIEW;
public void redo() {
- defaultStereotypeView = newView;
+ diaDefault.setDefaultStereotypeView(newView);
fireNotationEvent(key, oldValue, newView);
}
public void undo() {
- defaultStereotypeView = oldValue;
+ diaDefault.setDefaultStereotypeView(oldValue);
fireNotationEvent(key, newView, oldValue);
}
};
- if (UndoManager.getInstance().isGenerateMementos()) {
- UndoManager.getInstance().addMemento(memento);
- }
- memento.redo();
- ProjectManager.getManager().setSaveEnabled(true);
+ doUndoable(memento);
}
/**
@@ -1104,22 +1104,25 @@
* Used by "argo.tee".
*
* @return diagram font name.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public String getFontName() {
- return fontName;
+ return diaDefault.getFontName();
}
/**
* Diagram font name.
* @param newFontName diagram font name.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setFontName(String newFontName) {
- String old = fontName;
- fontName = newFontName;
- initFonts();
+ String old = diaDefault.getFontName();
+ diaDefault.setFontName(newFontName);
fireDiagramAppearanceEvent(DiagramAppearance.KEY_FONT_NAME, old,
- this.fontName);
+ newFontName);
}
/**
@@ -1128,40 +1131,38 @@
* Used by "argo.tee".
*
* @return diagram font size.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public int getFontSize() {
- return fontSize;
+ return diaDefault.getFontSize();
}
/**
* Diagram font size.
* @param newFontSize diagram font size.
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public void setFontSize(int newFontSize) {
- int old = fontSize;
- fontSize = newFontSize;
- initFonts();
+ int old = diaDefault.getFontSize();
+ diaDefault.setFontSize(newFontSize);
fireDiagramAppearanceEvent(DiagramAppearance.KEY_FONT_SIZE, old,
- this.fontSize);
+ newFontSize);
}
- private void initFonts() {
- fontPlain = new Font(fontName, Font.PLAIN, fontSize);
- fontItalic = new Font(fontName, Font.ITALIC, fontSize + 2);
- fontBold = new Font(fontName, Font.BOLD, fontSize + 2);
- fontBoldItalic = new Font(fontName,
- Font.BOLD | Font.ITALIC, fontSize + 2);
- }
/**
* Returns the Plain diagram font which corresponds
* to selected parameters.
*
* @return plain diagram font
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public Font getFontPlain() {
- return fontPlain;
+ return diaDefault.getFontPlain();
}
/**
@@ -1169,9 +1170,11 @@
* to selected parameters.
*
* @return italic diagram font
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public Font getFontItalic() {
- return fontItalic;
+ return diaDefault.getFontItalic();
}
/**
@@ -1179,9 +1182,11 @@
* to selected parameters.
*
* @return bold diagram font
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public Font getFontBold() {
- return fontBold;
+ return diaDefault.getFontBold();
}
/**
@@ -1189,9 +1194,11 @@
* to selected parameters.
*
* @return bold-italic diagram font
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public Font getFontBoldItalic() {
- return fontBoldItalic;
+ return diaDefault.getFontBoldItalic();
}
/**
@@ -1199,20 +1206,10 @@
*
* @param fontStyle the style; see the predefined constants in Font
* @return the Font that corresponds to the style
+ * @deprecated for 0.27.2 by tfmorris. Use {@link DiagramSettings}.
*/
+ @Deprecated
public Font getFont(int fontStyle) {
- if ((fontStyle & Font.ITALIC) != 0) {
- if ((fontStyle & Font.BOLD) != 0) {
- return fontBoldItalic;
- } else {
- return fontItalic;
- }
- } else {
- if ((fontStyle & Font.BOLD) != 0) {
- return fontBold;
- } else {
- return fontPlain;
- }
- }
+ return diaDefault.getFont(fontStyle);
}
}
Added: trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramSettings.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramSettings.java?view=auto&rev=16052
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramSettings.java 2008-11-15 11:19:09-0800
@@ -0,0 +1,849 @@
+// $Id$
+// Copyright (c) 2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.uml.diagram;
+
+import java.awt.Font;
+
+import org.argouml.notation.Notation;
+import org.tigris.gef.undo.Memento;
+
+/**
+ * Diagram appearance settings. This includes basic things like colors and
+ * fonts, but also settings that affect more complex things like whether or
+ * not certain labels and text fields are displayed.
+ * <p>
+ * The special value <code>null</code> is used internally to indicate that the
+ * default value should be inherited from the next level of settings.
+ *
+ * @author Tom Morris <[email protected]>
+ */
+public class DiagramSettings {
+
+ /**
+ * Enumeration representing different stereotype presentation styles
+ */
+ public enum StereotypeStyle {
+
+ // *IMPORTANT* - These MUST remain in order!
+
+ /**
+ * Textual rendering for stereotype
+ */
+ TEXTUAL(DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL),
+ /**
+ * Stereotype rendered with large icon
+ */
+ BIG_ICON(DiagramAppearance.STEREOTYPE_VIEW_BIG_ICON),
+ /**
+ * Stereotype rendered with small ico
+ */
+ SMALL_ICON(DiagramAppearance.STEREOTYPE_VIEW_SMALL_ICON);
+
+ StereotypeStyle(int value) {
+ assert value == this.ordinal();
+ }
+
+
+ /**
+ * Convert old style int representation to an enum. The enum returned
+ * is the one at the given ordinal (ie this is the inverse of the
+ * mapping done by ordinal()).
+ *
+ * @param value one of the defined int values in DiagramAppearance
+ * @return the corresponding StereotypeView enum
+ */
+ public static StereotypeStyle getEnum(int value) {
+ int counter = 0;
+ for (StereotypeStyle sv : StereotypeStyle.values()) {
+ if (counter == value) {
+ return sv;
+ }
+ counter++;
+ }
+ return null;
+ }
+ }
+
+// private static final StereotypeView[] stereotypeViewMap;
+//
+// static {
+// stereotypeViewMap = new StereotypeView[3];
+// StereotypeView.
+// stereotypeViewMap[DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL] =
+// StereotypeView.TEXTUAL;
+// stereotypeViewMap[DiagramAppearance.STEREOTYPE_VIEW_BIG_ICON] =
+// StereotypeView.BIG_ICON;
+// stereotypeViewMap[DiagramAppearance.STEREOTYPE_VIEW_SMALL_ICON] =
+// StereotypeView.SMALL_ICON;
+// }
+
+ private DiagramSettings parent;
+
+ /* Diagram appearance settings with project scope: */
+ private String fontName;
+ private Integer fontSize;
+
+ // TODO: Can we remove this and have the application manage things directly
+ // based on the font?
+ private Boolean showBoldNames;
+
+ /* Some cached fonts based on the above settings */
+ private Font fontPlain;
+ private Font fontItalic;
+ private Font fontBold;
+ private Font fontBoldItalic;
+
+ /* Notation settings */
+ private String notationLanguage;
+ private Boolean showBidirectionalArrows;
+ private Boolean showAssociationNames;
+ private Boolean showVisibility;
+ private Boolean showMultiplicity;
+ private Boolean showInitialValue;
+ private Boolean showProperties;
+ private Boolean showTypes;
+ private Boolean showStereotypes;
+ private Boolean showSingularMultiplicities;
+ private Integer defaultShadowWidth;
+ private StereotypeStyle defaultStereotypeView;
+
+ private Boolean useGuillemets;
+
+
+ /**
+ * Construct an empty project settings with no parent and all values
+ * defaulted. <p>
+ */
+ public DiagramSettings() {
+ super();
+ parent = null;
+ }
+
+
+ /**
+ * Construct a DiagramSettings object which inherits from the given
+ * parent settings (e.g. project default diagram settings).
+ *
+ * @param parentSettings settings to inherit from if default values aren't
+ * overridden.
+ */
+ public DiagramSettings(DiagramSettings parentSettings) {
+ this();
+ parent = parentSettings;
+ }
+
+
+ /**
+ * @return Return the notation language.
+ */
+ public String getNotationLanguage() {
+ if (notationLanguage == null) {
+ if (parent != null) {
+ return parent.getNotationLanguage();
+ } else {
+ // TODO: What's the correct fallback default?
+ return "UML";
+ }
+ }
+ return notationLanguage;
+ }
+
+
+ /**
+ * @param newLanguage the notation language.
+ * @return true if the notation is set - false if it does not exist
+ */
+ public boolean setNotationLanguage(final String newLanguage) {
+ if (notationLanguage != null
+ && notationLanguage.equals(newLanguage)) {
+ return true;
+ }
+
+ // TODO: Do we care?
+ if (Notation.findNotation(newLanguage) == null) {
+ /* This Notation is not available! */
+ return false;
+ }
+
+ final String oldLanguage = notationLanguage;
+
+ Memento memento = new Memento() {
+ public void redo() {
+ notationLanguage = newLanguage;
+ // TODO: We can't have a global "current" language
+ // NotationProviderFactory2.setCurrentLanguage(newLanguage);
+ }
+
+ public void undo() {
+ notationLanguage = oldLanguage;
+ // TODO: We can't have a global "current" language
+ // NotationProviderFactory2.setCurrentLanguage(oldLanguage);
+ }
+ };
+ doUndoable(memento);
+ return true;
+ }
+
+ /**
+ * @return Returns <code>true</code> if we show bold names.
+ */
+ public boolean isShowBoldNames() {
+ if (showBoldNames == null) {
+ if (parent != null) {
+ return parent.isShowBoldNames();
+ } else {
+ return false;
+ }
+ }
+ return showBoldNames;
+ }
+
+ /**
+ * @param showem <code>true</code> if names are to be shown in bold font.
+ */
+ public void setShowBoldNames(final boolean showem) {
+ if (showBoldNames != null && showBoldNames == showem) {
+ return;
+ }
+
+ Memento memento = new Memento() {
+ public void redo() {
+ showBoldNames = showem;
+ }
+
+ public void undo() {
+ showBoldNames = !showem;
+ }
+ };
+ doUndoable(memento);
+ }
+
+ /**
+ * @return Returns <code>true</code> if we show guillemets.
+ */
+ public boolean isUseGuillemets() {
+ if (useGuillemets == null) {
+ if (parent != null) {
+ return parent.isUseGuillemets();
+ } else {
+ return false;
+ }
+ }
+ return useGuillemets;
+ }
+
+
+ /**
+ * @param showem <code>true</code> if guillemets are to be shown.
+ */
+ public void setUseGuillemets(final boolean showem) {
+ if (useGuillemets != null && useGuillemets == showem) {
+ return;
+ }
+
+ Memento memento = new Memento() {
+ public void redo() {
+ useGuillemets = showem;
+ }
+
+ public void undo() {
+ useGuillemets = !showem;
+ }
+ };
+ doUndoable(memento);
+ }
+
+
+ /**
+ * @return Returns <code>true</code> if we show association names.
+ */
+ public boolean isShowAssociationNames() {
+ if (showAssociationNames == null) {
+ if (parent != null) {
+ return parent.isShowAssociationNames();
+ } else {
+ return false;
+ }
+ }
+ return showAssociationNames;
+ }
+
+ /**
+ * @param showem <code>true</code> if association names are to be shown.
+ */
+ public void setShowAssociationNames(final boolean showem) {
+ if (showAssociationNames != null && showAssociationNames == showem) {
+ return;
+ }
+
+ Memento memento = new Memento() {
+
+ public void redo() {
+ showAssociationNames = showem;
+ }
+
+ public void undo() {
+ showAssociationNames = !showem;
+ }
+ };
+ doUndoable(memento);
+ }
+
+ /**
+ * @return Returns <code>true</code> if we show visibilities.
+ */
+ public boolean isShowVisibility() {
+ if (showVisibility == null) {
+ if (parent != null) {
+ return parent.isShowVisibility();
+ } else {
+ return false;
+ }
+ }
+ return showVisibility;
+ }
+
+ /**
+ * @param showem <code>true</code> if visibilities are to be shown.
+ */
+ public void setShowVisibility(final boolean showem) {
+ if (showVisibility != null && showVisibility == showem) {
+ return;
+ }
+
+ Memento memento = new Memento() {
+ public void redo() {
+ showVisibility = showem;
+ }
+
+ public void undo() {
+ showVisibility = !showem;
+ }
+ };
+ doUndoable(memento);
+ }
+
+
+ /**
+ * @return Returns <code>true</code> if we show multiplicities.
+ */
+ public boolean isShowMultiplicity() {
+ if (showMultiplicity == null) {
+ if (parent != null) {
+ return parent.isShowMultiplicity();
+ } else {
+ return false;
+ }
+ }
+ return showMultiplicity;
+ }
+
+
+ /**
+ * @param showem <code>true</code> if the multiplicity is to be shown.
+ */
+ public void setShowMultiplicity(final boolean showem) {
+ if (showMultiplicity != null && showMultiplicity == showem) {
+ return;
+ }
+
+ Memento memento = new Memento() {
+ public void redo() {
+ showMultiplicity = showem;
+ }
+
+ public void undo() {
+ showMultiplicity = !showem;
+ }
+ };
+ doUndoable(memento);
+ }
+
+ /**
+ * @return Returns <code>true</code> if we show initial values.
+ */
+ public boolean isShowInitialValue() {
+ if (showInitialValue == null) {
+ if (parent != null) {
+ return parent.isShowInitialValue();
+ } else {
+ return false;
+ }
+ }
+ return showInitialValue;
+ }
+
+
+ /**
+ * @param showem <code>true</code> if initial values are to be shown.
+ */
+ public void setShowInitialValue(final boolean showem) {
+ if (showInitialValue != null && showInitialValue == showem) {
+ return;
+ }
+
+ Memento memento = new Memento() {
+ public void redo() {
+ showInitialValue = showem;
+ }
+
+ public void undo() {
+ showInitialValue = !showem;
+ }
+ };
+ doUndoable(memento);
+
+ }
+
+
+ /**
+ * @return Returns <code>true</code> if we show properties.
+ */
+ public boolean isShowProperties() {
+ if (showProperties == null) {
+ if (parent != null) {
+ return parent.isShowProperties();
+ } else {
+ return false;
+ }
+ }
+ return showProperties;
+ }
+
+
+ /**
+ * @param showem <code>true</code> if properties are to be shown.
+ */
+ public void setShowProperties(final boolean showem) {
+ if (showProperties != null && showProperties == showem) {
+ return;
+ }
+
+ Memento memento = new Memento() {
+ public void redo() {
+ showProperties = showem;
+ }
+
+ public void undo() {
+ showProperties = !showem;
+ }
+ };
+ doUndoable(memento);
+
+ }
+
+
+ /**
+ * @return Returns <code>true</code> if we show types.
+ */
+ public boolean isShowTypes() {
+ if (showTypes == null) {
+ if (parent != null) {
+ return parent.isShowTypes();
+ } else {
+ return false;
+ }
+ }
+ return showTypes;
+ }
+
+
+ /**
+ * @param showem <code>true</code> if types are to be shown.
+ */
+ public void setShowTypes(final boolean showem) {
+ if (showTypes != null && showTypes == showem) {
+ return;
+ }
+
+ Memento memento = new Memento() {
+ public void redo() {
+ showTypes = showem;
+ }
+
+ public void undo() {
+ showTypes = !showem;
+ }
+ };
+ doUndoable(memento);
+
+ }
+
+ /**
+ * @return Returns <code>true</code> if we show stereotypes.
+ */
+ public boolean isShowStereotypes() {
+ if (showStereotypes == null) {
+ if (parent != null) {
+ return parent.isShowStereotypes();
+ } else {
+ return true;
+ }
+ }
+ return showStereotypes;
+ }
+
+
+ /**
+ * @param showem <code>true</code> if stereotypes are to be shown.
+ */
+ public void setShowStereotypes(final boolean showem) {
+ if (showStereotypes != null && showStereotypes == showem) {
+ return;
+ }
+
+ Memento memento = new Memento() {
+ public void redo() {
+ showStereotypes = showem;
+ }
+
+ public void undo() {
+ showStereotypes = !showem;
+ }
+ };
+ doUndoable(memento);
+
+ }
+
+ /**
+ * @return Returns <code>true</code> if we show "1" Multiplicities.
+ */
+ public boolean isShowSingularMultiplicities() {
+ if (showSingularMultiplicities == null) {
+ if (parent != null) {
+ return parent.isShowSingularMultiplicities();
+ } else {
+ return false;
+ }
+ }
+ return showSingularMultiplicities;
+ }
+
+
+ /**
+ * @param showem <code>true</code> if "1" Multiplicities are to be shown.
+ */
+ public void setShowSingularMultiplicities(final boolean showem) {
+ if (showSingularMultiplicities != null
+ && showSingularMultiplicities == showem) {
+ return;
+ }
+
+ Memento memento = new Memento() {
+ public void redo() {
+ showSingularMultiplicities = showem;
+ }
+
+ public void undo() {
+ showSingularMultiplicities = !showem;
+ }
+ };
+ doUndoable(memento);
+ }
+
+
+ /**
+ * @return Returns <code>true</code> if we show the arrows when
+ * both association ends of an association are navigable.
+ */
+ public boolean isShowBidirectionalArrows() {
+ if (showBidirectionalArrows == null) {
+ if (parent != null) {
+ return parent.isShowBidirectionalArrows();
+ } else {
+ return false;
+ }
+ }
+ return showBidirectionalArrows;
+ }
+
+ /**
+ * @param showem <code>true</code> if both arrows are to be shown when
+ * both association ends of an association are navigable.
+ */
+ public void setShowBidirectionalArrows(final boolean showem) {
+ if (showBidirectionalArrows != null
+ && showBidirectionalArrows == showem) {
+ return;
+ }
+
+ Memento memento = new Memento() {
+ public void redo() {
+ showBidirectionalArrows = showem;
+ }
+
+ public void undo() {
+ showBidirectionalArrows = !showem;
+ }
+ };
+ doUndoable(memento);
+
+ }
+
+
+ /**
+ * @return Returns the shadow width.
+ */
+ public int getDefaultShadowWidth() {
+ if (defaultShadowWidth == null) {
+ if (parent != null) {
+ return parent.getDefaultShadowWidth();
+ } else {
+ return 0;
+ }
+ }
+ return defaultShadowWidth;
+ }
+
+ /**
+ * @param newWidth The Shadow Width.
+ */
+ public void setDefaultShadowWidth(final int newWidth) {
+ if (defaultShadowWidth != null && defaultShadowWidth == newWidth) {
+ return;
+ }
+
+ final Integer oldValue = defaultShadowWidth;
+
+ Memento memento = new Memento() {
+ public void redo() {
+ defaultShadowWidth = newWidth;
+ }
+
+ public void undo() {
+ defaultShadowWidth = oldValue;
+ }
+ };
+ doUndoable(memento);
+
+ }
+
+
+ /**
+ * @return Returns the default stereotype view
+ * TODO: Enumeration here?
+ */
+ public StereotypeStyle getDefaultStereotypeView() {
+ if (defaultStereotypeView == null) {
+ if (parent != null) {
+ return parent.getDefaultStereotypeView();
+ } else {
+ return StereotypeStyle.TEXTUAL;
+ }
+ }
+ return defaultStereotypeView;
+ }
+
+ /**
+ * @return Returns the default stereotype view as an int compatible with
+ * old users of DiagramAppearance-defined ints.
+ * @deprecated for 0.27.2 by tfmorris. For backward compatibility only.
+ */
+ public int getDefaultStereotypeViewInt() {
+ return getDefaultStereotypeView().ordinal();
+ }
+
+ /**
+ * @param newView the default stereotype view
+ * @deprecated for 0.27.2 by tfmorris. Not for use in new code. Only for
+ * help in transitioning to enum based methods. Use
+ * {@link #setDefaultStereotypeView(StereotypeStyle)}.
+ */
+ public void setDefaultStereotypeView(final int newView) {
+ StereotypeStyle sv = StereotypeStyle.getEnum(newView);
+ if (sv == null) {
+ throw new IllegalArgumentException("Bad argument " + newView);
+ }
+ setDefaultStereotypeView(sv);
+ }
+
+ /**
+ * @param newView the default stereotype view
+ */
+ public void setDefaultStereotypeView(final StereotypeStyle newView) {
+ if (defaultStereotypeView != null && defaultStereotypeView == newView) {
+ return;
+ }
+
+ final StereotypeStyle oldValue = defaultStereotypeView;
+
+ Memento memento = new Memento() {
+ public void redo() {
+ defaultStereotypeView = newView;
+ }
+
+ public void undo() {
+ defaultStereotypeView = oldValue;
+ }
+ };
+ doUndoable(memento);
+ }
+
+
+ /**
+ * Diagram font name. <p>
+ *
+ * @return diagram font name.
+ */
+ public String getFontName() {
+ if (fontName == null) {
+ if (parent != null) {
+ return parent.getFontName();
+ } else {
+ return "Dialog";
+ }
+ }
+ return fontName;
+ }
+
+ /**
+ * Diagram font name.
+ * @param newFontName diagram font name.
+ */
+ public void setFontName(String newFontName) {
+ if (fontName != null && fontName.equals(newFontName)) {
+ return;
+ }
+ fontName = newFontName;
+ recomputeFonts();
+ }
+
+ /**
+ * Diagram font size. <p>
+ *
+ * @return diagram font size.
+ */
+ public int getFontSize() {
+ if (fontSize == null) {
+ if (parent != null) {
+ return parent.getFontSize();
+ } else {
+ return 10;
+ }
+ }
+ return fontSize;
+ }
+
+ /**
+ * Diagram font size.
+ * @param newFontSize diagram font size.
+ */
+ public void setFontSize(int newFontSize) {
+ if (fontSize != null && fontSize == newFontSize) {
+ return;
+ }
+ fontSize = newFontSize;
+ recomputeFonts();
+ }
+
+ private void recomputeFonts() {
+ String name = getFontName();
+ int size = getFontSize();
+// if (size == 0) {
+// size = 10;
+// }
+
+ if (name != null && !"".equals(name) && size > 0) {
+ fontPlain = new Font(name, Font.PLAIN, size);
+ fontItalic = new Font(name, Font.ITALIC, size);
+ fontBold = new Font(name, Font.BOLD, size);
+ fontBoldItalic = new Font(name, Font.BOLD | Font.ITALIC, size);
+ }
+ }
+
+ /**
+ * Returns the Plain diagram font which corresponds
+ * to selected parameters.
+ *
+ * @return plain diagram font
+ */
+ public Font getFontPlain() {
+ return fontPlain;
+ }
+
+ /**
+ * Returns the Italic diagram font which corresponds
+ * to selected parameters.
+ *
+ * @return italic diagram font
+ */
+ public Font getFontItalic() {
+ return fontItalic;
+ }
+
+ /**
+ * Returns the Bold diagram font which corresponds
+ * to selected parameters.
+ *
+ * @return bold diagram font
+ */
+ public Font getFontBold() {
+ return fontBold;
+ }
+
+ /**
+ * Returns the Bold-Italic diagram font which corresponds
+ * to selected parameters.
+ *
+ * @return bold-italic diagram font
+ */
+ public Font getFontBoldItalic() {
+ return fontBoldItalic;
+ }
+
+ /**
+ * Utility function to convert a font style integer into a Font.
+ *
+ * @param fontStyle the style; see the predefined constants in Font
+ * @return the Font that corresponds to the style
+ */
+ public Font getFont(int fontStyle) {
+ if ((fontStyle & Font.ITALIC) != 0) {
+ if ((fontStyle & Font.BOLD) != 0) {
+ return fontBoldItalic;
+ } else {
+ return fontItalic;
+ }
+ } else {
+ if ((fontStyle & Font.BOLD) != 0) {
+ return fontBold;
+ } else {
+ return fontPlain;
+ }
+ }
+ }
+
+
+ private void doUndoable(Memento memento) {
+ // TODO: Undo should be managed externally or we should be given
+ // an Undo manager to use (the project's) rather than using a global one
+// if (DiagramUndoManager.getInstance().isGenerateMementos()) {
+// DiagramUndoManager.getInstance().addMemento(memento);
+// }
+ memento.redo();
+ // TODO: Mark diagram/project as dirty?
+ }
+}
+
Added: trunk/src/argouml-app/tests/org/argouml/uml/diagram/TestDiagramSettings.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/uml/diagram/TestDiagramSettings.java?view=auto&rev=16052
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/tests/org/argouml/uml/diagram/TestDiagramSettings.java 2008-11-15 11:19:09-0800
@@ -0,0 +1,287 @@
+// $Id$
+// Copyright (c) 2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.uml.diagram;
+
+import org.argouml.uml.diagram.DiagramSettings.StereotypeStyle;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Tests for the DiagramSettings.
+ *
+ * TODO: Test chaining of settings.
+ *
+ * @author Tom Morris (based on TestProjectSettings by Michiel)
+ */
+public class TestDiagramSettings extends TestCase {
+
+ private DiagramSettings settings;
+
+ /**
+ * Constructor.
+ *
+ * @param name is the name of the test case.
+ */
+ public TestDiagramSettings(String name) {
+ super(name);
+ }
+
+ /**
+ * Test the default shadow width.
+ */
+ public void testDefaultShadowWidth() {
+ assertEquals("Default shadow width wrong",
+ 0, settings.getDefaultShadowWidth());
+ settings.setDefaultShadowWidth(4);
+ assertEquals("Shadow width setting incorrect",
+ 4, settings.getDefaultShadowWidth());
+ }
+
+ /**
+ * Test the default stereotype view settings, including compatibility
+ * methods.
+ */
+ public void testStereotypeView() {
+ assertEquals("Default stereotype view incorrect",
+ StereotypeStyle.TEXTUAL,
+ settings.getDefaultStereotypeView());
+ assertEquals("Default stereotype view wrong",
+ DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL,
+ settings.getDefaultStereotypeViewInt());
+ settings.setDefaultStereotypeView(
+ DiagramAppearance.STEREOTYPE_VIEW_BIG_ICON);
+ assertEquals("stereotype view setting incorrect",
+ StereotypeStyle.BIG_ICON,
+ settings.getDefaultStereotypeView());
+ assertEquals("stereotype view setting incorrect",
+ DiagramAppearance.STEREOTYPE_VIEW_BIG_ICON,
+ settings.getDefaultStereotypeViewInt());
+
+ settings.setDefaultStereotypeView(StereotypeStyle.SMALL_ICON);
+ assertEquals("stereotype view setting incorrect",
+ StereotypeStyle.SMALL_ICON,
+ settings.getDefaultStereotypeView());
+ assertEquals("stereotype view setting incorrect",
+ DiagramAppearance.STEREOTYPE_VIEW_SMALL_ICON,
+ settings.getDefaultStereotypeViewInt());
+
+ settings.setDefaultStereotypeView(StereotypeStyle.TEXTUAL);
+ assertEquals("stereotype view setting incorrect",
+ StereotypeStyle.TEXTUAL,
+ settings.getDefaultStereotypeView());
+ assertEquals("stereotype view setting incorrect",
+ DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL,
+ settings.getDefaultStereotypeViewInt());
+}
+
+ /**
+ * Test the project setting for showing Association names.
+ */
+ public void testAssociationNames() {
+ assertFalse("Association names not correct",
+ settings.isShowAssociationNames());
+ settings.setShowAssociationNames(true);
+ assertTrue("Association names not correct",
+ settings.isShowAssociationNames());
+ settings.setShowAssociationNames(false);
+ assertFalse("Association names not correct",
+ settings.isShowAssociationNames());
+ }
+
+ public void testShowBidirectionalArrows() {
+ assertFalse("BidirectionalArrows is not correct",
+ settings.isShowBidirectionalArrows());
+ settings.setShowBidirectionalArrows(true);
+ assertTrue("BidirectionalArrows is not correct",
+ settings.isShowBidirectionalArrows());
+ settings.setShowBidirectionalArrows(false);
+ assertFalse("BidirectionalArrows is not correct",
+ settings.isShowBidirectionalArrows());
+ }
+
+ public void testShowBoldNames() {
+ assertFalse("BoldNames is not correct",
+ settings.isShowBoldNames());
+ settings.setShowBoldNames(true);
+ assertTrue("BoldNames is not correct",
+ settings.isShowBoldNames());
+ settings.setShowBoldNames(false);
+ assertFalse("BoldNames is not correct",
+ settings.isShowBoldNames());
+ }
+
+ public void testShowInitialValue() {
+ assertFalse("InitialValue is not correct",
+ settings.isShowInitialValue());
+ settings.setShowInitialValue(true);
+ assertTrue("InitialValue is not correct",
+ settings.isShowInitialValue());
+ settings.setShowInitialValue(false);
+ assertFalse("InitialValue is not correct",
+ settings.isShowBoldNames());
+
+ }
+
+ public void testShowProperties() {
+ assertFalse("Properties is not correct",
+ settings.isShowProperties());
+ settings.setShowProperties(true);
+ assertTrue("Properties is not correct",
+ settings.isShowProperties());
+ settings.setShowProperties(false);
+ assertFalse("Properties is not correct",
+ settings.isShowProperties());
+ }
+
+ public void testShowMultiplicity() {
+ assertFalse("Multiplicities is not correct",
+ settings.isShowMultiplicity());
+ settings.setShowMultiplicity(true);
+ assertTrue("Multiplicity is not correct",
+ settings.isShowMultiplicity());
+ settings.setShowMultiplicity(false);
+ assertFalse("Multiplicity is not correct",
+ settings.isShowMultiplicity());
+
+ }
+
+ public void testSingularMultiplicities() {
+ assertFalse("ShowSingularMultiplicities is not correct",
+ settings.isShowSingularMultiplicities());
+ settings.setShowSingularMultiplicities(true);
+ assertTrue("ShowSingularMultiplicities is not correct",
+ settings.isShowSingularMultiplicities());
+ settings.setShowSingularMultiplicities(false);
+ assertFalse("SingularMultiplicities is not correct",
+ settings.isShowSingularMultiplicities());
+ }
+
+ public void testShowStereotypes() {
+ assertTrue("Stereotypes is not correct",
+ settings.isShowStereotypes());
+ settings.setShowStereotypes(true);
+ assertTrue("Stereotypes is not correct",
+ settings.isShowStereotypes());
+ settings.setShowStereotypes(false);
+ assertFalse("Stereotypes is not correct",
+ settings.isShowStereotypes());
+
+ }
+
+ public void testShowTypes() {
+ assertFalse("Types is not correct",
+ settings.isShowTypes());
+ settings.setShowTypes(true);
+ assertTrue("Types is not correct",
+ settings.isShowTypes());
+ settings.setShowTypes(false);
+ assertFalse("Types is not correct",
+ settings.isShowTypes());
+
+ }
+
+ public void testNotationLanguage() {
+ assertEquals("NotationLanguage default is not correct",
+ "UML", settings.getNotationLanguage());
+
+ }
+
+ public void testFont() {
+ assertEquals("Font default is not correct",
+ "Dialog", settings.getFontName());
+ settings.setFontName("Courier");
+ assertEquals("Font is not correct",
+ "Courier", settings.getFontName());
+ assertEquals("Font size default is not correct",
+ 10, settings.getFontSize());
+ settings.setFontSize(20);
+ assertEquals("Font size is not correct",
+ 20, settings.getFontSize());
+
+ assertTrue("Bold font is incorrect",
+ settings.getFontBold().isBold());
+
+ assertTrue("Italic font is incorrect",
+ settings.getFontItalic().isItalic());
+ }
+
+ /**
+ * Test the project setting for showing Multiplicity.
+ */
+ public void testMultiplicity() {
+ assertFalse("Multiplicity not correct",
+ settings.isShowMultiplicity());
+
+ settings.setShowMultiplicity(true);
+ assertTrue("Multiplicity not correct",
+ settings.isShowMultiplicity());
+
+ settings.setShowMultiplicity(false);
+ assertFalse("Multiplicity not correct",
+ settings.isShowMultiplicity());
+
+ }
+
+ /**
+ * Test the project setting for showing Visibility.
+ */
+ public void testVisibility() {
+ assertFalse("Visibility not correct",
+ settings.isShowVisibility());
+
+ settings.setShowVisibility(true);
+ assertTrue("Visibility not correct",
+ settings.isShowVisibility());
+
+ settings.setShowVisibility(false);
+ assertFalse("Visibility not correct",
+ settings.isShowVisibility());
+ }
+
+ /**
+ * Test the use of Guillemets.
+ */
+ public void testUseGuillemets() {
+ assertFalse("Guillemots not correct",
+ settings.isUseGuillemets());
+ settings.setUseGuillemets(true);
+ assertTrue("Guillemots not correct",
+ settings.isUseGuillemets());
+ settings.setUseGuillemets(false);
+ assertFalse("Guillemots not correct",
+ settings.isUseGuillemets());
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ settings = new DiagramSettings();
+ }
+
+
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.