org.argouml.cognitive
Class DesignMaterial

java.lang.Object
  extended byjava.util.Observable
      extended byorg.argouml.cognitive.DesignMaterial
All Implemented Interfaces:
org.tigris.gef.ui.Highlightable, Serializable
Direct Known Subclasses:
Design

public abstract class DesignMaterial
extends Observable
implements org.tigris.gef.ui.Highlightable, Serializable

Abstract class to represent the materials being used in design. The nature of these materials is domain-dependent. For example, in the domain of software architecture the design materials are software components and connectors. There is not much that can be said about generic design materials at this level of abstraction. But the Argo kernel provides for all DesignMaterials to (1) be Observable, (2) have Properties (in addition to instance variables supplied in subclasses) that can be shown in a property sheet, (3) ask Agency to critique them, (4) keep a list of the ToDoItem's that are generated from that critiquing, (5) be notified when the user selects them in an editor, (6) highlight themselves to draw the designer's attention.

TODO: should I implement virtual copying? or instance-based inheritiance of properties? How are properties shared (it at all)? For examples of subclasing see the package jargo.softarch. For instructions on how to define subclasses for DesignMaterials in your domain, see the Argo cookbook entry for define_design_material

See Also:
Design, Serialized Form

Field Summary
private  boolean highlight
           
private  Vector parents
          Other DesignMaterial's that contain this one.
private  ToDoList pendingItems
          ToDoList items that are on the designers ToDoList because of this material.
private  Vector persistObservers
          Observers of this object that should be saved and loaded with this object.
private  Vector propertyListeners
           
private  Hashtable props
          "Soft" Properties that this DesignMaterial may have, but we do not want to allocate an instance variable to them.
 
Fields inherited from class java.util.Observable
 
Constructor Summary
DesignMaterial()
          Construct a new DesignMaterial with empty Properties.
DesignMaterial(Hashtable ht)
          Construct a new DesignMaterial with the given Properties.
 
Method Summary
(package private)  void addParent(Design d)
          Make the given Design be the parent of this DesignMaterial.
 void addPersistantObserver(Observer o)
           
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 boolean canPut(String key)
           
 void changedProperty(String key)
           
 void critique(Designer dsgr)
          Critique this DesignMaterial and post ToDoItem's to the Designer's list.
 void define(String k, boolean v)
          Set the value of a property iff it is not already set.
 void define(String k, int v)
          Set the value of a property iff it is not already set.
 boolean define(String k, Object v)
           
 void dispose()
          Remove this DesignMaterial from the design document and free up memory and other resources as much as possible.
 void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
           
 void firePropertyChange(String propertyName, int oldValue, int newValue)
           
 void firePropertyChange(String propertyName, Object oldValue, Object newValue)
           
 Object get(String k)
           
 Object get(String key, Object defaultValue)
           
 boolean getBoolean(String k)
          Convenient function for getting the value of boolean properties.
 boolean getBoolProperty(String k)
          Reply the value an boolean property, if not found reply false.
 boolean getBoolProperty(String k, boolean defaultValue)
          Reply the value an int property, if not found reply defaultValue.
 boolean getHighlight()
           
 int getIntProperty(String k)
          Reply the value an int property, if not found reply 0.
 int getIntProperty(String k, int defaultValue)
          Reply the value an int property, if not found reply defaultValue.
 Object getProperty(String k)
          Reply the value of one property, if not found reply null.
 Object getProperty(String key, Object defaultValue)
          Reply the value of one property, if not found reply defaultValue.
 void inform(ToDoItem item)
          When a critic produces a ToDoItem, both the Designer and the "offending" DesignMaterial's are notified.
 Enumeration keysIn(String cat)
           
 void notifyObservers(Object arg)
           
 void notifyPersistantObservers(Object arg)
           
 Enumeration parents()
          Enumerate over all my parents.
 void put(Hashtable ht)
           
 boolean put(String k, boolean v)
          Convenient function for setting the value of boolean properties.
 boolean put(String k, int v)
          Convenient function for setting the value of boolean properties.
 boolean put(String k, Object v)
          Set the value of a property.
(package private)  void removeParent(Design d)
          Remove the given parent.
 void removePendingItems(Designer dsgr)
          Remove all the ToDoItem's generated by this DesignMaterial from the ToDoList of the given Designer.
 void removePersistObserver(Observer o)
           
 Object removeProperty(String k)
          Make the given property undefined.
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 void setHighlight(boolean h)
          Draw the Designer's attention to this DesignMaterial in all views.
 void setProperty(String k, boolean v)
           
 void setProperty(String k, int v)
           
 void setProperty(String k, Object v)
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

persistObservers

private Vector persistObservers
Observers of this object that should be saved and loaded with this object.


propertyListeners

private transient Vector propertyListeners

pendingItems

private ToDoList pendingItems
ToDoList items that are on the designers ToDoList because of this material.


parents

private Vector parents
Other DesignMaterial's that contain this one.


props

private Hashtable props
"Soft" Properties that this DesignMaterial may have, but we do not want to allocate an instance variable to them.


highlight

private boolean highlight
Constructor Detail

DesignMaterial

public DesignMaterial()
Construct a new DesignMaterial with empty Properties.


DesignMaterial

public DesignMaterial(Hashtable ht)
Construct a new DesignMaterial with the given Properties.

Parameters:
ht - the hashtable
Method Detail

addParent

void addParent(Design d)
Make the given Design be the parent of this DesignMaterial.


removeParent

void removeParent(Design d)
Remove the given parent. For example, this could be called when a DesignMaterial is removed from a Design.


parents

public Enumeration parents()
Enumerate over all my parents. For now most DesignMaterial's have just one parent, but I think this might be useful in the future.

Returns:
all the parents

getProperty

public Object getProperty(String key,
                          Object defaultValue)
Reply the value of one property, if not found reply defaultValue. Even if subclasses store some properties in instance variables, they should implement this method to give acces to those instance variables by name.

Parameters:
key - the key of the property
defaultValue - the default value if not found
Returns:
the value of the property

getProperty

public Object getProperty(String k)
Reply the value of one property, if not found reply null.

Parameters:
k - the key of the property
Returns:
the value of the property

get

public Object get(String k)
Parameters:
k - the key of the property
Returns:
the value of the property

get

public Object get(String key,
                  Object defaultValue)
Parameters:
key - the key of the property
defaultValue - the default value if not found
Returns:
the value of the property

getIntProperty

public int getIntProperty(String k)
Reply the value an int property, if not found reply 0.

Parameters:
k - the key of the property
Returns:
the value of the property

getIntProperty

public int getIntProperty(String k,
                          int defaultValue)
Reply the value an int property, if not found reply defaultValue.

Parameters:
k - the key of the property
defaultValue - the default value of the property
Returns:
the value of the property

getBoolProperty

public boolean getBoolProperty(String k)
Reply the value an boolean property, if not found reply false.

Parameters:
k - the key of the property
Returns:
the value of the property

getBoolProperty

public boolean getBoolProperty(String k,
                               boolean defaultValue)
Reply the value an int property, if not found reply defaultValue.

Parameters:
k - the key of the property
defaultValue - the default value of the property
Returns:
the value of the property

put

public boolean put(String k,
                   Object v)
Set the value of a property.

Parameters:
k - the key of the property
v - the value of the property
Returns:
always true, because when the key is not yet present, we add it

put

public void put(Hashtable ht)
Parameters:
ht - the hashtable

put

public boolean put(String k,
                   boolean v)
Convenient function for setting the value of boolean properties.

Parameters:
k - the key of the property
v - the value of the property
Returns:
always true, because when the key is not yet present, we add it

put

public boolean put(String k,
                   int v)
Convenient function for setting the value of boolean properties.

Parameters:
k - the key of the property
v - the value of the property
Returns:
always true, because when the key is not yet present, we add it

setProperty

public void setProperty(String k,
                        Object v)
Parameters:
k - the key of the property
v - the value of the property

setProperty

public void setProperty(String k,
                        int v)
Parameters:
k - the key of the property
v - the value of the property

setProperty

public void setProperty(String k,
                        boolean v)
Parameters:
k - the key of the property
v - the value of the property

define

public boolean define(String k,
                      Object v)
Parameters:
k - the key of the property
v - the value of the property
Returns:
true if a new property is created, false if it existed

canPut

public boolean canPut(String key)
Parameters:
key - the key of the property
Returns:
always true

keysIn

public Enumeration keysIn(String cat)
Parameters:
cat - the category
Returns:
the key in this category

define

public void define(String k,
                   boolean v)
Set the value of a property iff it is not already set.

Parameters:
k - the key of the property
v - the value of the property

define

public void define(String k,
                   int v)
Set the value of a property iff it is not already set.

Parameters:
k - the key of the property
v - the value of the property

removeProperty

public Object removeProperty(String k)
Make the given property undefined.

Parameters:
k - the key of the property
Returns:
the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping

getBoolean

public boolean getBoolean(String k)
Convenient function for getting the value of boolean properties.

Parameters:
k - the key of the property
Returns:
the value of the property

critique

public void critique(Designer dsgr)
Critique this DesignMaterial and post ToDoItem's to the Designer's list. By default this is done by asking Agency.

Parameters:
dsgr - the designer

removePendingItems

public void removePendingItems(Designer dsgr)
Remove all the ToDoItem's generated by this DesignMaterial from the ToDoList of the given Designer. For example, this could be called when the DesignMaterial is deleted from the design document.

Parameters:
dsgr - the designer

dispose

public void dispose()
Remove this DesignMaterial from the design document and free up memory and other resources as much as possible.


inform

public void inform(ToDoItem item)
When a critic produces a ToDoItem, both the Designer and the "offending" DesignMaterial's are notified. By default the ToDoItem is added to the list of generated ToDoItem's. Subclasses may, for example, visually change their appearance to indicate the presence of an error. One paper called this 'clarifiers'.

TODO: do I need a Clarifier object in the framework?

Parameters:
item - the todo item

setHighlight

public void setHighlight(boolean h)
Draw the Designer's attention to this DesignMaterial in all views.

Specified by:
setHighlight in interface org.tigris.gef.ui.Highlightable
See Also:
Highlightable.setHighlight(boolean)

getHighlight

public boolean getHighlight()
Specified by:
getHighlight in interface org.tigris.gef.ui.Highlightable
See Also:
Highlightable.getHighlight()

changedProperty

public void changedProperty(String key)
Parameters:
key - the key of the property

addPersistantObserver

public void addPersistantObserver(Observer o)
Parameters:
o - the observer to be added

removePersistObserver

public void removePersistObserver(Observer o)
Parameters:
o - the observer to be removed

notifyPersistantObservers

public void notifyPersistantObservers(Object arg)
Parameters:
arg - the argument

notifyObservers

public void notifyObservers(Object arg)
See Also:
Observable.notifyObservers(java.lang.Object)

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface org.tigris.gef.ui.Highlightable
See Also:
Highlightable.addPropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface org.tigris.gef.ui.Highlightable
See Also:
Highlightable.removePropertyChangeListener(java.beans.PropertyChangeListener)

firePropertyChange

public void firePropertyChange(String propertyName,
                               boolean oldValue,
                               boolean newValue)
Parameters:
propertyName - the key of the property
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(String propertyName,
                               int oldValue,
                               int newValue)
Parameters:
propertyName - the key of the property
oldValue - the old value of the property
newValue - the new value of the property

firePropertyChange

public void firePropertyChange(String propertyName,
                               Object oldValue,
                               Object newValue)
Parameters:
propertyName - the key of the property
oldValue - the old value of the property
newValue - the new value of the property


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook