org.patterncoder.pattern
Class PatternModel

java.lang.Object
  extended by java.util.Observable
      extended by org.patterncoder.pattern.PatternModel

public class PatternModel
extends java.util.Observable

The PatternModel class is used to represent the data that is being used to display information to the user. All data used in the Graphical user interface is stored within this model structure, allowing for a clear seperation of control and data.

model in the Model View Controllor architecture.

PatternModel extends the Observable class from the java.util library, and allows all objects with the code to registar an interest in any changes being made to the model.


Constructor Summary
PatternModel()
          Class constructor.
PatternModel(PatternSourceManager edh, PatternFileReader pfr)
          Class Constructor specifying what PatternSourceManager and PatternFileReader objects to use.
 
Method Summary
 java.util.HashMap<java.lang.Object,PatternClass> getComponents()
          Returns a hash map containing the PatternClass objects for a pattern as created from the pattern source file.
 java.lang.String getCurrentPatternName()
          Returns the name of the pattern that is currently selected and is populating the model.
 java.io.File getCurrentSourceFile()
          Returns the source file of the pattern currently being displayed.
 java.lang.String getDescription()
          Returns the currently selected patterns decription
 java.lang.String getImage()
          Returns the pattern image of the current pattern.
 PatternClass getPatternComp(java.lang.Object id)
          Returns the PatternClass object that is represented in the model by the supplied Object identifier.
 java.util.List<java.lang.String> getPatterns()
          Returns the array of currently loaded patterns
 void populateModel()
          Populates the model used to display information.
 void setComponents()
          Creates a list of components of type PatternClass.
 void setCurrentPattern(java.lang.String curPattern, int index)
          Is called passing details of the currently selected pattern Changes currently selected pattern variables accordingly.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PatternModel

public PatternModel()
             throws PatternCoderException
Class constructor.

Throws:
patext.BlueDPException
PatternCoderException

PatternModel

public PatternModel(PatternSourceManager edh,
                    PatternFileReader pfr)
Class Constructor specifying what PatternSourceManager and PatternFileReader objects to use.

Parameters:
edh - the PatternSourceManager to use when locating files.
pfr - the PatternFileReader to use when reading files.
Method Detail

populateModel

public void populateModel()
                   throws java.io.FileNotFoundException,
                          java.lang.Exception
Populates the model used to display information. The model is populated by the Pattern files specified by the PatternSourceManager object, all pattern data required is loaded into the model.

Throws:
java.lang.Exception - thrown if a general exception occurs.
java.io.FileNotFoundException - thrown if the file used to populate creates a problem.

getPatterns

public java.util.List<java.lang.String> getPatterns()
Returns the array of currently loaded patterns

Returns:
the array of patterns currently loaded in memory

getCurrentSourceFile

public java.io.File getCurrentSourceFile()
Returns the source file of the pattern currently being displayed.

Returns:
the source file of the currently displayed pattern.

getDescription

public java.lang.String getDescription()
Returns the currently selected patterns decription

Returns:
A description of the current pattern

getImage

public java.lang.String getImage()
Returns the pattern image of the current pattern.

Returns:
the name of the image file used by the current pattern.

setCurrentPattern

public void setCurrentPattern(java.lang.String curPattern,
                              int index)
Is called passing details of the currently selected pattern Changes currently selected pattern variables accordingly. Notifys all observing objects of the change

Parameters:
curPattern - The pattern currently selected by the user
index - The index of the pattern in the ComboBox

setComponents

public void setComponents()
Creates a list of components of type PatternClass. This list is generated from the currently selected patterns source file and is a List of all classes used in the implementation of the Pattern.

See Also:
PatternClass

getComponents

public java.util.HashMap<java.lang.Object,PatternClass> getComponents()
Returns a hash map containing the PatternClass objects for a pattern as created from the pattern source file. The key values are specified from the class id value from the source file.

Returns:
comps a hash map of PatternClass objects with key values from pattern source file.
See Also:
PatternClass

getPatternComp

public PatternClass getPatternComp(java.lang.Object id)
Returns the PatternClass object that is represented in the model by the supplied Object identifier.

Parameters:
id - the Object id of the component.
Returns:
the PatternClass object represented by the id.

getCurrentPatternName

public java.lang.String getCurrentPatternName()
Returns the name of the pattern that is currently selected and is populating the model.

Returns:
the name of the current pattern.