org.knime.base.node.viz.aggregation
Class AggregationValModel<T extends AggregationValSubModel<S,H>,S extends Shape,H extends Shape>

java.lang.Object
  extended by org.knime.base.node.viz.aggregation.AggregationValModel<T,S,H>
Type Parameters:
T - the type of the concrete sub model implementation
S - the basic shape
H - the optional hilite shape
All Implemented Interfaces:
Serializable, AggregationModel<S,H>
Direct Known Subclasses:
BarDataModel, PieSectionDataModel

public abstract class AggregationValModel<T extends AggregationValSubModel<S,H>,S extends Shape,H extends Shape>
extends Object
implements Serializable, AggregationModel<S,H>

This abstract class holds the data of a particular aggregation value and its AggregationValSubModels.

Author:
Tobias Koetter, University of Konstanz
See Also:
Serialized Form

Constructor Summary
protected AggregationValModel(ConfigRO config, ExecutionMonitor exec)
          Constructor for class AggregationValModel.
protected AggregationValModel(String name, Color color, boolean supportHiliting)
          Constructor for class AttributeValModel.
protected AggregationValModel(String name, Color color, Map<Color,T> elements, int rowCounter, int valueCounter, double aggrSum, boolean supportHiliting)
          Constructor for class AttributeValModel.
 
Method Summary
 void addDataRow(Color color, RowKey rowKey, DataCell cell)
          Adds a new row to this element.
protected  void calculateHiliteShape(HiliteShapeCalculator<S,H> calculator)
          Overwrite this method to support hiliting.
 void clearHilite()
          Clears all hilite information.
protected  AggregationValModel<T,S,H> clone()
          
protected abstract  T createElement(Color color)
           
 double getAggregationSum()
          
 double getAggregationValue(AggregationMethod method)
          
 Color getColor()
          
 T getElement(Color color)
           
 Collection<T> getElements()
           
 int getHiliteRowCount()
          Call the AggregationModel.supportsHiliting() method to check if hiliting is supported.
 H getHiliteShape()
          Call the AggregationModel.supportsHiliting() method to check if hiliting is supported.
 String getName()
          
 int getNoOfElements()
           
 int getRowCount()
          
 List<T> getSelectedElements()
           
 T getSelectedSubElement(Point p)
          Returns the sub element of this element that contains the given point or null if none contains the point.
 S getShape()
          
 int getValueCount()
          
 boolean isEmpty()
          
 boolean isHilited()
          
 boolean isPresentable()
          
 boolean isSelected()
          
protected abstract  Collection<T> loadElements(ConfigRO config, ExecutionMonitor exec)
           
 boolean removeHilitedKeys(Collection<RowKey> hilited, HiliteShapeCalculator<S,H> calculator)
           
 void save2File(ConfigWO config, ExecutionMonitor exec)
           
protected abstract  void saveElements(Collection<T> elements, ConfigWO config, ExecutionMonitor exec)
           
 boolean selectElement(Point point, boolean detailed)
           
 boolean selectElement(Rectangle2D rect, boolean detailed)
          Selects all sub element of this element which intersect the given rectangle.
 void setColor(Color color)
           
 boolean setHilitedKeys(Collection<RowKey> hilited, HiliteShapeCalculator<S,H> calculator)
           
protected  void setHiliteShape(H shape)
           
protected  void setPresentable(boolean presentable, HiliteShapeCalculator<S,H> calculator)
           
 boolean setSelected(boolean selected)
           
 void setShape(S shape, HiliteShapeCalculator<S,H> calculator)
           
 boolean supportsHiliting()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AggregationValModel

protected AggregationValModel(String name,
                              Color color,
                              boolean supportHiliting)
Constructor for class AttributeValModel.

Parameters:
name - the name of this element
color - the color to use for this element
supportHiliting - if hiliting should be supported

AggregationValModel

protected AggregationValModel(String name,
                              Color color,
                              Map<Color,T> elements,
                              int rowCounter,
                              int valueCounter,
                              double aggrSum,
                              boolean supportHiliting)
Constructor for class AttributeValModel.

Parameters:
name - the name of this element
color - the color of this element
elements - the sub elements
rowCounter - the number of rows including missing values
valueCounter - the number of values exl. missing values
aggrSum - the aggregation sum
supportHiliting - if hiliting should be supported

AggregationValModel

protected AggregationValModel(ConfigRO config,
                              ExecutionMonitor exec)
                       throws InvalidSettingsException,
                              CanceledExecutionException
Constructor for class AggregationValModel.

Parameters:
config - the config object to use
exec - the ExecutionMonitor to provide progress information
Throws:
InvalidSettingsException - if the config object is invalid
CanceledExecutionException - if the operation is canceled
Method Detail

loadElements

protected abstract Collection<T> loadElements(ConfigRO config,
                                              ExecutionMonitor exec)
                                                                           throws CanceledExecutionException,
                                                                                  InvalidSettingsException
Parameters:
config - the config object to use
exec - the ExecutionMonitor to provide progress information
Returns:
the elements
Throws:
CanceledExecutionException - if the operation is canceled
InvalidSettingsException - if the config object is invalid

addDataRow

public void addDataRow(Color color,
                       RowKey rowKey,
                       DataCell cell)
Adds a new row to this element.

Parameters:
color - the color of the data row
rowKey - the row key
cell - the optional aggregation value cell

createElement

protected abstract T createElement(Color color)
Parameters:
color - the color of the new sub element
Returns:
the new sub element with the given color

getName

public String getName()

Specified by:
getName in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
the optional name of this element (could be null)

setColor

public void setColor(Color color)
Parameters:
color - the new color of this aggregation value model

getColor

public Color getColor()

Specified by:
getColor in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
the color to use for this element

getElement

public T getElement(Color color)
Parameters:
color - the color of the sub element
Returns:
the sub element with the given color or null if none sub element with the given color exists

getElements

public Collection<T> getElements()
Returns:
all sub elements of this element

getSelectedElements

public List<T> getSelectedElements()
Returns:
all selected sub elements of this element

getSelectedSubElement

public T getSelectedSubElement(Point p)
Returns the sub element of this element that contains the given point or null if none contains the point.

Parameters:
p - the point to select
Returns:
the sub element that contains the point or null

getNoOfElements

public int getNoOfElements()
Returns:
the number of sub elements

getRowCount

public int getRowCount()

Specified by:
getRowCount in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
the number of rows of this element

getAggregationSum

public double getAggregationSum()

Specified by:
getAggregationSum in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
the sum of all aggregation values

getValueCount

public int getValueCount()

Specified by:
getValueCount in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
the number of real values (without missing values)

getAggregationValue

public double getAggregationValue(AggregationMethod method)

Specified by:
getAggregationValue in interface AggregationModel<S extends Shape,H extends Shape>
Parameters:
method - the AggregationMethod to use
Returns:
the aggregation value of this element

getShape

public S getShape()

Specified by:
getShape in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
the shape of this element

setShape

public void setShape(S shape,
                     HiliteShapeCalculator<S,H> calculator)
Parameters:
shape - the shape check for selection and drawing
calculator - the hilite shape calculator

getHiliteShape

public H getHiliteShape()
Call the AggregationModel.supportsHiliting() method to check if hiliting is supported.

Specified by:
getHiliteShape in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
the hilite shape of this element

setHiliteShape

protected void setHiliteShape(H shape)
Parameters:
shape - the hilite shape to draw

setPresentable

protected void setPresentable(boolean presentable,
                              HiliteShapeCalculator<S,H> calculator)
Parameters:
presentable - true if this element is presentable
calculator - the hilite shape calculator

isPresentable

public boolean isPresentable()

Specified by:
isPresentable in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
true if the sub elements should be drawn

isSelected

public boolean isSelected()

Specified by:
isSelected in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
true if this element is selected

setSelected

public boolean setSelected(boolean selected)
Parameters:
selected - true if this element is selected
Returns:
true if the parameter has changed

selectElement

public boolean selectElement(Point point,
                             boolean detailed)
Parameters:
point - the Point to check
detailed - if also the sub sections should be checked
Returns:
true if at least one sub element of this element contains the point

selectElement

public boolean selectElement(Rectangle2D rect,
                             boolean detailed)
Selects all sub element of this element which intersect the given rectangle.

Parameters:
rect - the Rectangle2D to check
detailed - if also the sub sections should be checked
Returns:
true if at least one sub element of this element intersects the rectangle

supportsHiliting

public boolean supportsHiliting()
Specified by:
supportsHiliting in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
true if hiliting is supported

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
true if this model contains no rows

isHilited

public boolean isHilited()

Specified by:
isHilited in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
true if at least one row of this element is hilited

getHiliteRowCount

public int getHiliteRowCount()
Call the AggregationModel.supportsHiliting() method to check if hiliting is supported.

Specified by:
getHiliteRowCount in interface AggregationModel<S extends Shape,H extends Shape>
Returns:
the number of hilited rows in this element

removeHilitedKeys

public boolean removeHilitedKeys(Collection<RowKey> hilited,
                                 HiliteShapeCalculator<S,H> calculator)
Parameters:
hilited - the row keys to unhilite
calculator - the hilite shape calculator
Returns:
if the hilite keys have changed

setHilitedKeys

public boolean setHilitedKeys(Collection<RowKey> hilited,
                              HiliteShapeCalculator<S,H> calculator)
Parameters:
hilited - the row keys to hilite
calculator - the hilite shape calculator
Returns:
if the hilite keys have changed

clearHilite

public void clearHilite()
Clears all hilite information.


calculateHiliteShape

protected void calculateHiliteShape(HiliteShapeCalculator<S,H> calculator)
Overwrite this method to support hiliting.

Parameters:
calculator - the optional hilite calculator

clone

protected AggregationValModel<T,S,H> clone()
                                                                                                    throws CloneNotSupportedException

Overrides:
clone in class Object
Throws:
CloneNotSupportedException

save2File

public void save2File(ConfigWO config,
                      ExecutionMonitor exec)
               throws CanceledExecutionException
Parameters:
config - the config object to use
exec - the ExecutionMonitor to provide progress messages
Throws:
CanceledExecutionException - if the operation is canceled

saveElements

protected abstract void saveElements(Collection<T> elements,
                                     ConfigWO config,
                                     ExecutionMonitor exec)
                              throws CanceledExecutionException
Parameters:
elements - the elements to save
config - the config object to use
exec - the ExecutionMonitor to provide progress information
Throws:
CanceledExecutionException - if the operation is canceled


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.