org.knime.base.node.viz.histogram.datamodel
Class BarDataModel

java.lang.Object
  extended by org.knime.base.node.viz.aggregation.AggregationValModel<BarElementDataModel,Rectangle2D,Rectangle2D>
      extended by org.knime.base.node.viz.histogram.datamodel.BarDataModel
All Implemented Interfaces:
Serializable, AggregationModel<Rectangle2D,Rectangle2D>
Direct Known Subclasses:
InteractiveBarDataModel

public class BarDataModel
extends AggregationValModel<BarElementDataModel,Rectangle2D,Rectangle2D>
implements Serializable

This class represents one bar in the histogram. A bar corresponds to one selected aggregation column and belongs to one BinDataModel. It contains one or more BarElementDataModel.

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

Constructor Summary
protected BarDataModel(String barName, Color color)
          Constructor for class BarDataModel.
protected BarDataModel(String barName, Color color, boolean supportHiliting)
          Constructor for class BarDataModel.
 
Method Summary
protected  BarDataModel clone()
          
protected  BarElementDataModel createElement(Color color)
          
 double getMaxAggregationValue(AggregationMethod method, HistogramLayout layout)
           
 double getMinAggregationValue(AggregationMethod method, HistogramLayout layout)
           
 List<BarElementDataModel> getSelectedElements()
          
 Rectangle2D getSurroundingRectangle()
           
protected  Collection<BarElementDataModel> loadElements(ConfigRO config, ExecutionMonitor exec)
          
static BarDataModel loadFromFile(Config config, ExecutionMonitor exec)
           
protected  void saveElements(Collection<BarElementDataModel> elements, ConfigWO config, ExecutionMonitor exec)
          
protected  void setBarRectangle(Rectangle2D barRect, int baseLine, List<Color> barElementColors, AbstractHistogramVizModel.HistogramHiliteCalculator calculator)
           
 void updateBarWidth(int startX, int newWidth, List<Color> barElementColors, int baseLine, AbstractHistogramVizModel.HistogramHiliteCalculator calculator)
           
 
Methods inherited from class org.knime.base.node.viz.aggregation.AggregationValModel
addDataRow, calculateHiliteShape, clearHilite, getAggregationSum, getAggregationValue, getColor, getElement, getElements, getHiliteRowCount, getHiliteShape, getName, getNoOfElements, getRowCount, getSelectedSubElement, getShape, getValueCount, isEmpty, isHilited, isPresentable, isSelected, removeHilitedKeys, save2File, selectElement, selectElement, setColor, setHilitedKeys, setHiliteShape, setPresentable, setSelected, setShape, supportsHiliting
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BarDataModel

protected BarDataModel(String barName,
                       Color color)
Constructor for class BarDataModel.

Parameters:
barName - the name of this bar
color - the color to use for this bar

BarDataModel

protected BarDataModel(String barName,
                       Color color,
                       boolean supportHiliting)
Constructor for class BarDataModel.

Parameters:
barName - the name of this bar
color - the color to use for this bar
supportHiliting - if hiliting should be supported
Method Detail

createElement

protected BarElementDataModel createElement(Color color)

Specified by:
createElement in class AggregationValModel<BarElementDataModel,Rectangle2D,Rectangle2D>
Parameters:
color - the color of the new sub element
Returns:
the new sub element with the given color

getSurroundingRectangle

public Rectangle2D getSurroundingRectangle()
Returns:
the Rectangle the aggregation color of this bar should be drawn on the screen

getMinAggregationValue

public double getMinAggregationValue(AggregationMethod method,
                                     HistogramLayout layout)
Parameters:
method - the AggregationMethod to use
layout - the histogram layout
Returns:
the minimum aggregation value

getMaxAggregationValue

public double getMaxAggregationValue(AggregationMethod method,
                                     HistogramLayout layout)
Parameters:
method - the AggregationMethod to use
layout - the histogram layout
Returns:
the maximum aggregation value

setBarRectangle

protected void setBarRectangle(Rectangle2D barRect,
                               int baseLine,
                               List<Color> barElementColors,
                               AbstractHistogramVizModel.HistogramHiliteCalculator calculator)
Parameters:
barRect - the Rectangle the bar should be drawn on the screen
baseLine - the x coordinate of the base line (0) on the screen
barElementColors - all element colors which define the order the elements should be drawn
calculator - the hilite shape calculator

updateBarWidth

public void updateBarWidth(int startX,
                           int newWidth,
                           List<Color> barElementColors,
                           int baseLine,
                           AbstractHistogramVizModel.HistogramHiliteCalculator calculator)
Parameters:
startX - the x coordinate
newWidth - the new bar width
barElementColors - all element colors which define the order the elements should be drawn
baseLine - the base line
calculator - the hilite shape calculator

getSelectedElements

public List<BarElementDataModel> getSelectedElements()

Overrides:
getSelectedElements in class AggregationValModel<BarElementDataModel,Rectangle2D,Rectangle2D>
Returns:
all selected sub elements of this element

clone

protected BarDataModel clone()

Overrides:
clone in class AggregationValModel<BarElementDataModel,Rectangle2D,Rectangle2D>

loadFromFile

public static BarDataModel loadFromFile(Config config,
                                        ExecutionMonitor exec)
                                 throws CanceledExecutionException,
                                        InvalidSettingsException
Parameters:
config - the config object to use
exec - the ExecutionMonitor to provide progress messages
Returns:
the BarDataModel
Throws:
CanceledExecutionException - if the operation is canceled
InvalidSettingsException - if the config object is invalid

saveElements

protected void saveElements(Collection<BarElementDataModel> elements,
                            ConfigWO config,
                            ExecutionMonitor exec)
                     throws CanceledExecutionException

Specified by:
saveElements in class AggregationValModel<BarElementDataModel,Rectangle2D,Rectangle2D>
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

loadElements

protected Collection<BarElementDataModel> loadElements(ConfigRO config,
                                                       ExecutionMonitor exec)
                                                throws CanceledExecutionException,
                                                       InvalidSettingsException

Specified by:
loadElements in class AggregationValModel<BarElementDataModel,Rectangle2D,Rectangle2D>
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


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.