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

java.lang.Object
  extended by org.knime.base.node.viz.histogram.datamodel.BinDataModel
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
InteractiveBinDataModel

public class BinDataModel
extends Object
implements Serializable

This class represents one bin in the histogram. A bin represents a value of the selected x column and contains one or more BarDataModel objects depending on the number of aggregation columns.

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

Constructor Summary
BinDataModel(String xAxisCaption, double lowerBound, double upperBound)
          Constructor for class BinDataModel.
 
Method Summary
 void addDataRow(RowKey id, Color rowColor, Collection<ColorColumn> aggrCols, DataCell... aggrVals)
           
 void clear()
          Clears all bars and rows from this bin.
protected  BinDataModel clone()
          
protected  BarDataModel createBar(String barName, Color color)
          Creates a new BarDataModel with the given color.
 BarDataModel getBar(Color color)
           
 Collection<BarDataModel> getBars()
           
 Rectangle2D getBinRectangle()
           
 int getBinRowCount()
           
 Double getLowerBound()
           
 double getMaxAggregationValue(AggregationMethod method, HistogramLayout layout)
           
 int getMaxBarRowCount()
           
 double getMinAggregationValue(AggregationMethod method, HistogramLayout layout)
           
 int getMinRowCount()
           
 int getNoOfBars()
           
 List<BarDataModel> getSelectedBars()
           
 Rectangle2D getSurroundingRectangle()
           
 Double getUpperBound()
           
 String getXAxisCaption()
           
 DataCell getXAxisCaptionCell()
           
 boolean isPresentable()
           
 boolean isSelected()
           
static BinDataModel loadFromFile(ConfigRO config, ExecutionMonitor exec)
           
 void save2File(ConfigWO config, ExecutionMonitor exec)
           
 boolean selectElement(Point point)
          Selects all elements which contain the given point.
 boolean selectElement(Rectangle rect)
          Selects all elements which intersect with the given rectangle.
 void setBinRectangle(Rectangle binRectangle, int baseLine, List<Color> barElementColors, Collection<ColorColumn> aggrColumns, AbstractHistogramVizModel.HistogramHiliteCalculator calculator)
          THE HEIGHT OF THE RECTANGLE SHOULD BE CALCULATED USING THE MIN AND MAX AGGREGATION VALUE TO HANDLES BINS WITH POSITIVE AND NEGATIVE BARS!!!
 boolean setSelected(boolean selected)
           
 void updateBinWidth(int startX, int binWidth, List<Color> barElementColors, Collection<ColorColumn> aggrColumns, int baseLine, AbstractHistogramVizModel.HistogramHiliteCalculator calculator)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinDataModel

public BinDataModel(String xAxisCaption,
                    double lowerBound,
                    double upperBound)
Constructor for class BinDataModel.

Parameters:
xAxisCaption - the caption of this bin on the x axis
lowerBound - the lower bound of the bin interval
upperBound - the higher bound of the bin interval
Method Detail

addDataRow

public void addDataRow(RowKey id,
                       Color rowColor,
                       Collection<ColorColumn> aggrCols,
                       DataCell... aggrVals)
Parameters:
id - the row id
rowColor - the row color
aggrCols - the ColorColumn objects in the same order like the aggregation values
aggrVals - the aggregation value in the same order like the columns

getXAxisCaption

public String getXAxisCaption()
Returns:
the x axis caption

getXAxisCaptionCell

public DataCell getXAxisCaptionCell()
Returns:
the x axis caption as DataCell

createBar

protected BarDataModel createBar(String barName,
                                 Color color)
Creates a new BarDataModel with the given color.

Parameters:
barName - the name of this bar
color - the Color of the bar
Returns:
the created bar

getBar

public BarDataModel getBar(Color color)
Parameters:
color - the color of the bar of interest
Returns:
the bar with the given color or null if no bar exists for the given color

getBars

public Collection<BarDataModel> getBars()
Returns:
all BarDataModel objects of this bin

getSelectedBars

public List<BarDataModel> getSelectedBars()
Returns:
all selected bars of this bin

getNoOfBars

public int getNoOfBars()
Returns:
the number of bars in this bin

getMaxAggregationValue

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

getBinRowCount

public int getBinRowCount()
Returns:
the number of rows in this bin

getMaxBarRowCount

public int getMaxBarRowCount()
Returns:
the maximum row count of all bars in this bin

getMinAggregationValue

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

getMinRowCount

public int getMinRowCount()
Returns:
the minimum row count of all bars in this bin

getLowerBound

public Double getLowerBound()
Returns:
the lower bound of this bin could be null

getUpperBound

public Double getUpperBound()
Returns:
the higher bound of this bin could be null

isPresentable

public boolean isPresentable()
Returns:
true if the number of bars fit in the bin

getBinRectangle

public Rectangle2D getBinRectangle()
Returns:
the Rectangle the bin should be drawn on the screen

getSurroundingRectangle

public Rectangle2D getSurroundingRectangle()
Returns:
the surroundingRectangle to draw to distinguish between the different bins

setBinRectangle

public void setBinRectangle(Rectangle binRectangle,
                            int baseLine,
                            List<Color> barElementColors,
                            Collection<ColorColumn> aggrColumns,
                            AbstractHistogramVizModel.HistogramHiliteCalculator calculator)
THE HEIGHT OF THE RECTANGLE SHOULD BE CALCULATED USING THE MIN AND MAX AGGREGATION VALUE TO HANDLES BINS WITH POSITIVE AND NEGATIVE BARS!!!

Parameters:
binRectangle - the Rectangle the bin 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
aggrColumns - the aggregation column array which indicates the order of the bars
calculator - the hilite shape calculator

updateBinWidth

public void updateBinWidth(int startX,
                           int binWidth,
                           List<Color> barElementColors,
                           Collection<ColorColumn> aggrColumns,
                           int baseLine,
                           AbstractHistogramVizModel.HistogramHiliteCalculator calculator)
Parameters:
startX - new x coordinate
binWidth - new bin width
barElementColors - all element colors which define the order the elements should be drawn
aggrColumns - the current aggregation columns
baseLine - the base line
calculator - the hilite shape calculator

clear

public void clear()
Clears all bars and rows from this bin.


isSelected

public boolean isSelected()
Returns:
true if at least one bar is selected

setSelected

public boolean setSelected(boolean selected)
Parameters:
selected - true to select the given bar otherwise false
Returns:
true if the parameter has changed

selectElement

public boolean selectElement(Point point)
Selects all elements which contain the given point.

Parameters:
point - the Point to check
Returns:
true if at least one bar of the bin contains the point

selectElement

public boolean selectElement(Rectangle rect)
Selects all elements which intersect with the given rectangle.

Parameters:
rect - the Rectangle to check
Returns:
true if at least one bar of the bin contains the rectangle

clone

protected BinDataModel clone()

Overrides:
clone in class Object

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

loadFromFile

public static BinDataModel loadFromFile(ConfigRO config,
                                        ExecutionMonitor exec)
                                 throws CanceledExecutionException,
                                        InvalidSettingsException
Parameters:
config - the config object to use
exec - the ExecutionMonitor to provide progress messages
Returns:
the ColorColumn
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.