com.rubecula.darwin.visualization
Class VisualizationModel_

java.lang.Object
  extended by net.sf.tostring0.AToString
      extended by com.rubecula.darwin.visualization.VisualizationModel_
All Implemented Interfaces:
Countable, VisualizationModel, net.sf.tostring0.IToString
Direct Known Subclasses:
VisualizationModel_Standard

public abstract class VisualizationModel_
extends net.sf.tostring0.AToString
implements VisualizationModel

Base implementation of fields/methods for a VisualizationModel. In particular, this class maintains the following properties:

Subclasses should have permanent lifespan.

Author:
Robin Hillyard

Field Summary
protected  java.util.Map<Individual,Avatar> _avatars
           
protected static org.apache.commons.logging.Log LOG
           
 
Fields inherited from interface net.sf.tostring0.IToString
ANGBR_OPEN, ANGBRA_CLSE, BRA_CLSE, BRA_OPEN, BRCE_OPEN, BRCS_CLSE, COLON, LIST_SEPARATOR, MAX_ELEMENTS_DEFAULT, S_MT, S_PERCENT, SEPARATOR, SPACE
 
Constructor Summary
protected VisualizationModel_(java.lang.String title)
          Protected constructor which creates new instances for the _avatars and _attributes properties.
 
Method Summary
 void addAvatar(Avatar avatar)
          Get the current count, then add the individual.
 int clean()
          Loop through all the individuals and remove any which are dead and buried.
 void clear()
          Method to remove all individuals from the model.
 Avatar findAvatar(Individual individual)
           
 void fireModelChange()
          Notify the listeners that the model has changed.
 java.util.Map<java.lang.String,java.lang.Object> getAttributes()
           
protected  java.awt.Component getComponent()
           
 int getCount()
           
 java.util.Collection<Avatar> getIndividuals()
           
 java.lang.String getTitle()
           
 boolean isVisible()
           
 void putAttribute(java.lang.String attrName, java.lang.Object attrValue)
          Method to set (or reset) an attribute.
 boolean removeIndividual(Avatar avatar)
          Remove from the _avatars map that avatar which is indexed by the individual referenced by the parameter avatar.
 void setAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
          Getter/setter normally invoked by reflection.
 void setComponent(java.awt.Component component)
           
 void setVisible(boolean visible)
          Getter/setter normally invoked by reflection.
static int updateModel(VisualizationModel model, Individual individual, VisualizationFactory factory)
          XXX consider moving this to VisualizationModel (but beware architecture constraints).
 void visualize(Visualizable visualizable, VisualizationFactory visualizationFactory)
           
 
Methods inherited from class net.sf.tostring0.AToString
toString, toString, toStringBrief, toStringId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_avatars

protected final java.util.Map<Individual,Avatar> _avatars

LOG

protected static final org.apache.commons.logging.Log LOG
Constructor Detail

VisualizationModel_

protected VisualizationModel_(java.lang.String title)
Protected constructor which creates new instances for the _avatars and _attributes properties. It also sets the _title as given by title and initializes visible to true.

Parameters:
title - the title for this model.
Method Detail

updateModel

public static int updateModel(VisualizationModel model,
                              Individual individual,
                              VisualizationFactory factory)
XXX consider moving this to VisualizationModel (but beware architecture constraints).

Parameters:
model -
individual -
factory - VisualizationFactory to create avatars
Returns:
net change in number of individuals

addAvatar

public void addAvatar(Avatar avatar)
Get the current count, then add the individual. Return the original count as the new index.

Specified by:
addAvatar in interface VisualizationModel
Parameters:
avatar - an individual which is to be added to the population.
See Also:
VisualizationModel.addAvatar(Avatar)

clean

public int clean()
Loop through all the individuals and remove any which are dead and buried.

Specified by:
clean in interface VisualizationModel
Returns:
the number remaining in the list.
See Also:
VisualizationModel.clean()

clear

public void clear()
Description copied from interface: VisualizationModel
Method to remove all individuals from the model. Consider eliminating.

Specified by:
clear in interface VisualizationModel
See Also:
ArrayList.clear()

findAvatar

public Avatar findAvatar(Individual individual)
Specified by:
findAvatar in interface VisualizationModel
Returns:
an Avatar based on the given individual.
See Also:
VisualizationModel.findAvatar(com.rubecula.darwin.foundation.Individual)

fireModelChange

public void fireModelChange()
Notify the listeners that the model has changed. This is always invoked by some external agency which has made some calls to addAvatar(Avatar) or removeIndividual(Avatar).

Specified by:
fireModelChange in interface VisualizationModel
See Also:
()

getAttributes

public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Specified by:
getAttributes in interface VisualizationModel
Returns:
a map which specifies various attributes of the visualization model, derived typically from the environment.
See Also:
VisualizationModel.getAttributes()

getCount

public int getCount()
Specified by:
getCount in interface Countable
Returns:
the number of members of this group.
See Also:
Countable.getCount()

getIndividuals

public java.util.Collection<Avatar> getIndividuals()
Specified by:
getIndividuals in interface VisualizationModel
Returns:
the current collection of individual objects.
See Also:
VisualizationModel.getIndividuals()

getTitle

public java.lang.String getTitle()
Specified by:
getTitle in interface VisualizationModel
Returns:
get the title for this visualization model.
See Also:
VisualizationModel.getTitle()

isVisible

public boolean isVisible()
Specified by:
isVisible in interface VisualizationModel
Returns:
true if this visualization model is visible.
See Also:
VisualizationModel.isVisible()

putAttribute

public void putAttribute(java.lang.String attrName,
                         java.lang.Object attrValue)
Description copied from interface: VisualizationModel
Method to set (or reset) an attribute.

Specified by:
putAttribute in interface VisualizationModel
See Also:
VisualizationModel.putAttribute(java.lang.String, java.lang.Object)

removeIndividual

public boolean removeIndividual(Avatar avatar)
Remove from the _avatars map that avatar which is indexed by the individual referenced by the parameter avatar. TODO consider passing in Individual instead of Avatar. XXX consider eliminating synchronized since it should be handled by the _avatars object

Specified by:
removeIndividual in interface VisualizationModel
Parameters:
avatar - an individual which is to be removed from the population.
Returns:
true if the population model has changed (result would be false if individual was not a member of this population model).
See Also:
VisualizationModel.removeIndividual(Avatar)

setAttributes

public void setAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
Getter/setter normally invoked by reflection.

Specified by:
setAttributes in interface VisualizationModel
See Also:
VisualizationModel.setAttributes(java.util.Map)

setComponent

public void setComponent(java.awt.Component component)
Specified by:
setComponent in interface VisualizationModel
Parameters:
component - the component to set

setVisible

public void setVisible(boolean visible)
Getter/setter normally invoked by reflection. XXX check that. Maybe we can eliminate.

Specified by:
setVisible in interface VisualizationModel
Parameters:
visible - the visible to set
See Also:
VisualizationModel.setVisible(boolean)

visualize

public void visualize(Visualizable visualizable,
                      VisualizationFactory visualizationFactory)
Specified by:
visualize in interface VisualizationModel
Parameters:
visualizable -
visualizationFactory -

getComponent

protected java.awt.Component getComponent()
Returns:
the component


Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.