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

java.lang.Object
  extended by org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel
Direct Known Subclasses:
FixedHistogramVizModel, InteractiveHistogramVizModel

public abstract class AbstractHistogramVizModel
extends Object

This is the basic visualization model for a histogram. It handles bin creation and hilite handling and defines the constants which effect the drawing like minimum space between bins and elements.

Author:
Tobias Koetter, University of Konstanz

Nested Class Summary
 class AbstractHistogramVizModel.HistogramHiliteCalculator
          The histogram hilite shape calculator.
 
Field Summary
static int BAR_SURROUNDING_SPACE
          The space around a bar which is used to show the aggregation column color.
static int BIN_SURROUNDING_SPACE
          The thickness of a bin which is used to show the different bins.
static int DEFAULT_NO_OF_BINS
          The default number of bars which get created if the createBinnedBars method is called with a number smaller then 1.
static double HILITE_RECT_WIDTH_FACTOR
          The width of the hilite rectangle in percent of the surrounding rectangle.
static int INTERVAL_DIGITS
          Defines the number of decimal places which are used by default in the binning method.
static int MIN_BIN_WIDTH
          Defines the minimum width of a bin.
static int MINIMUM_BAR_HEIGHT
          The minimum height of a bar.
static int MINIMUM_ELEMENT_WIDTH
          The minimum width of an bar/element.
static String MISSING_VAL_BAR_CAPTION
          The caption of the bar which holds all missing values.
static int SPACE_BETWEEN_BARS
          The space between to bars in pixel.
static int SPACE_BETWEEN_BINS
          This is the minimum space between two bins.
static int SPACE_BETWEEN_ELEMENTS
          The space between to elements in the SIDE_BY_SIDE HistogramLayout layout in pixel.
 
Constructor Summary
AbstractHistogramVizModel(List<Color> rowColors, AggregationMethod aggrMethod, HistogramLayout layout, int noOfBins)
          Constructor for class HistogramVizModel.
 
Method Summary
static Rectangle2D calculateSurroundingRectangle(Rectangle2D rect, int baseLine, int thickness)
          Calculates a surrounding rectangle with the given thickness for the given rectangle.
 void clearSelection()
          Clears all selections.
 boolean containsEmptyBins()
           
 boolean containsMissingValueBin()
           
 boolean containsNotPresentableBin()
           
abstract  Collection<ColorColumn> getAggrColumns()
           
 AggregationMethod getAggregationMethod()
           
 BinDataModel getBin(int idx)
           
 BinDataModel getBin(String caption)
           
 Set<DataCell> getBinCaptions()
           
 List<BinDataModel> getBins()
           
 int getBinWidth()
           
 int getDisplayedNoOfBins()
           
 Dimension getDrawingSpace()
           
 AbstractHistogramVizModel.HistogramHiliteCalculator getHiliteCalculator()
           
abstract  Set<RowKey> getHilitedKeys()
           
 HistogramLayout getHistogramLayout()
           
 String getHTMLDetailData()
           
 LabelDisplayPolicy getLabelDisplayPolicy()
           
 double getMaxAggregationValue()
           
 int getMaxBinWidth()
           
 int getMaxNoOfBins()
           
 double getMinAggregationValue()
           
protected  BinDataModel getMissingValueBin()
           
 int getNoOfBins()
           
 int getNoOfElements()
           
 List<Color> getRowColors()
           
 List<BinDataModel> getSelectedBins()
           
 BarDataModel getSelectedElement(Point p)
           
abstract  Set<RowKey> getSelectedKeys()
           
abstract  String getXColumnName()
           
abstract  DataColumnSpec getXColumnSpec()
           
 boolean isBinNominal()
           
 boolean isShowBarOutline()
           
 boolean isShowBinOutline()
           
 boolean isShowElementOutline()
           
 boolean isShowEmptyBins()
           
 boolean isShowGridLines()
           
 boolean isShowLabelVertical()
           
 boolean isShowMissingValBin()
           
 void selectElement(Point point)
          Selects the element which contains the given point.
 void selectElement(Rectangle rect)
          Selects all elements which are touched by the given rectangle.
 boolean setAggregationMethod(AggregationMethod aggrMethod)
           
protected  void setBinNominal(boolean nominal)
           
protected  void setBins(List<? extends BinDataModel> bins, BinDataModel missingValueBin)
           
 boolean setBinWidth(int binWidth)
           
 boolean setDrawingSpace(Dimension drawingSpace)
           
 boolean setHistogramLayout(HistogramLayout layout)
           
 boolean setLabelDisplayPolicy(LabelDisplayPolicy labelDisplayPolicy)
           
 boolean setNoOfBins(int noOfBins)
           
 boolean setShowBarOutline(boolean showBarOutline)
           
 boolean setShowBinOutline(boolean showBinOutline)
           
 boolean setShowElementOutline(boolean showElementOutline)
           
 boolean setShowEmptyBins(boolean showEmptyBins)
           
 boolean setShowGridLines(boolean showGridLines)
           
 boolean setShowLabelVertical(boolean showLabelVertical)
           
 boolean setShowMissingValBin(boolean inclMissingValBin)
           
abstract  boolean supportsHiliting()
           
abstract  void unHiliteAll()
          Unhilites all rows.
abstract  void updateHiliteInfo(Set<RowKey> hilited, boolean hilite)
          This method un/hilites all rows with the given key.
protected  void updateNoOfBins(int noOfBins)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MISSING_VAL_BAR_CAPTION

public static final String MISSING_VAL_BAR_CAPTION
The caption of the bar which holds all missing values.

See Also:
Constant Field Values

MIN_BIN_WIDTH

public static final int MIN_BIN_WIDTH
Defines the minimum width of a bin. Should be more than the base line stroke.

See Also:
Constant Field Values

DEFAULT_NO_OF_BINS

public static final int DEFAULT_NO_OF_BINS
The default number of bars which get created if the createBinnedBars method is called with a number smaller then 1.

See Also:
Constant Field Values

INTERVAL_DIGITS

public static final int INTERVAL_DIGITS
Defines the number of decimal places which are used by default in the binning method.

See Also:
Constant Field Values

HILITE_RECT_WIDTH_FACTOR

public static final double HILITE_RECT_WIDTH_FACTOR
The width of the hilite rectangle in percent of the surrounding rectangle. Should be greater 0 and less than 1. 0.8 = 80%

See Also:
Constant Field Values

BIN_SURROUNDING_SPACE

public static final int BIN_SURROUNDING_SPACE
The thickness of a bin which is used to show the different bins.

See Also:
Constant Field Values

SPACE_BETWEEN_BINS

public static final int SPACE_BETWEEN_BINS
This is the minimum space between two bins.

See Also:
Constant Field Values

BAR_SURROUNDING_SPACE

public static final int BAR_SURROUNDING_SPACE
The space around a bar which is used to show the aggregation column color.


SPACE_BETWEEN_BARS

public static final int SPACE_BETWEEN_BARS
The space between to bars in pixel. Must be greater 0.


SPACE_BETWEEN_ELEMENTS

public static final int SPACE_BETWEEN_ELEMENTS
The space between to elements in the SIDE_BY_SIDE HistogramLayout layout in pixel. Must be greater 0.

See Also:
Constant Field Values

MINIMUM_ELEMENT_WIDTH

public static final int MINIMUM_ELEMENT_WIDTH
The minimum width of an bar/element.

See Also:
Constant Field Values

MINIMUM_BAR_HEIGHT

public static final int MINIMUM_BAR_HEIGHT
The minimum height of a bar.

See Also:
Constant Field Values
Constructor Detail

AbstractHistogramVizModel

public AbstractHistogramVizModel(List<Color> rowColors,
                                 AggregationMethod aggrMethod,
                                 HistogramLayout layout,
                                 int noOfBins)
Constructor for class HistogramVizModel.

Parameters:
rowColors - all possible colors the user has defined for a row
layout - the HistogramLayout to use
aggrMethod - the AggregationMethod to use
noOfBins - the no of bins to create
Method Detail

getDrawingSpace

public Dimension getDrawingSpace()
Returns:
the drawingSpace

setDrawingSpace

public boolean setDrawingSpace(Dimension drawingSpace)
Parameters:
drawingSpace - the drawingSpace to set
Returns:
true if the parameter has changed

getBins

public List<BinDataModel> getBins()
Returns:
all BinDataModel objects of this histogram including the missing value bin if the showMissingValue bin variable is set to true

getSelectedBins

public List<BinDataModel> getSelectedBins()
Returns:
all bins which are selected

getAggrColumns

public abstract Collection<ColorColumn> getAggrColumns()
Returns:
the aggregation columns. Could be null!

getXColumnSpec

public abstract DataColumnSpec getXColumnSpec()
Returns:
the x column specification

getXColumnName

public abstract String getXColumnName()
Returns:
the x column name

getRowColors

public List<Color> getRowColors()
Returns:
all available element colors. This is the color the user has set for one attribute in the Color Manager node.

getNoOfElements

public int getNoOfElements()
Returns:
the number of different elements which depends on the coloration of the input data

getNoOfBins

public int getNoOfBins()
Returns:
the noOfBins without the missing value bin but including the empty bins displayed or not.

getMaxNoOfBins

public int getMaxNoOfBins()
Returns:
the maximum number of bins which fit into the current drawing space

getBinWidth

public int getBinWidth()
Returns:
the binWidth

getMaxBinWidth

public int getMaxBinWidth()
Returns:
the maximum bin width

setBinWidth

public boolean setBinWidth(int binWidth)
Parameters:
binWidth - the binWidth to set
Returns:
true if the with has changed

setNoOfBins

public boolean setNoOfBins(int noOfBins)
Parameters:
noOfBins - the new number of bins to create
Returns:
true if the number of bins has changed

updateNoOfBins

protected void updateNoOfBins(int noOfBins)
Parameters:
noOfBins - updates the number of bins but doesn't check if the number has changed and thus doesn't recreate the bins if the number has changed.

getDisplayedNoOfBins

public int getDisplayedNoOfBins()
Returns:
the number of bins which are displayed.

getBin

public BinDataModel getBin(String caption)
Parameters:
caption - the caption of the bin of interest
Returns:
the bin with the given caption or null if no bin with the given caption exists

getBin

public BinDataModel getBin(int idx)
Parameters:
idx - the index of the bin
Returns:
the BinDataModel at the given index

getBinCaptions

public Set<DataCell> getBinCaptions()
Returns:
all bin captions in the order they should be displayed

isBinNominal

public boolean isBinNominal()
Returns:
true if the bins are nominal or false if the bins are intervals

supportsHiliting

public abstract boolean supportsHiliting()
Returns:
true if the bins support hiliting otherwise false

getMaxAggregationValue

public double getMaxAggregationValue()
Returns:
the maximum aggregation value

getMinAggregationValue

public double getMinAggregationValue()
Returns:
the minimum aggregation value

getMissingValueBin

protected BinDataModel getMissingValueBin()
Returns:
the missingValueBin

containsMissingValueBin

public boolean containsMissingValueBin()
Returns:
true if this model contains a missing value bin

containsEmptyBins

public boolean containsEmptyBins()
Returns:
true if the histogram contains at least one bin with no rows in it.

isShowEmptyBins

public boolean isShowEmptyBins()
Returns:
true if the empty bins should be displayed

setShowEmptyBins

public boolean setShowEmptyBins(boolean showEmptyBins)
Parameters:
showEmptyBins - set to true if also the empty bins should be shown
Returns:
true if the variable has changed

getAggregationMethod

public AggregationMethod getAggregationMethod()
Returns:
the aggregation method which is used to calculate the aggregation value

setAggregationMethod

public boolean setAggregationMethod(AggregationMethod aggrMethod)
Parameters:
aggrMethod - the aggregation method to use to calculate the aggregation value
Returns:
true if the aggregation method has changed

getHistogramLayout

public HistogramLayout getHistogramLayout()
Returns:
the layout

setHistogramLayout

public boolean setHistogramLayout(HistogramLayout layout)
Parameters:
layout - the layout to set
Returns:
true if the layout has changed

isShowMissingValBin

public boolean isShowMissingValBin()
Returns:
the inclMissingValBin

setShowMissingValBin

public boolean setShowMissingValBin(boolean inclMissingValBin)
Parameters:
inclMissingValBin - the inclMissingValBin to set
Returns:
true if the parameter has changed

isShowGridLines

public boolean isShowGridLines()
Returns:
the showGridLines

setShowGridLines

public boolean setShowGridLines(boolean showGridLines)
Parameters:
showGridLines - the showGridLines to set
Returns:
true if the parameter has changed

isShowBinOutline

public boolean isShowBinOutline()
Returns:
the showBinOutline

setShowBinOutline

public boolean setShowBinOutline(boolean showBinOutline)
Parameters:
showBinOutline - the showBinOutline to set
Returns:
true if the parameter has changed

isShowBarOutline

public boolean isShowBarOutline()
Returns:
the showBarOutline

setShowBarOutline

public boolean setShowBarOutline(boolean showBarOutline)
Parameters:
showBarOutline - the showBarOutline to set
Returns:
true if the parameter has changed

setShowElementOutline

public boolean setShowElementOutline(boolean showElementOutline)
Parameters:
showElementOutline - the showElementOutlines to set
Returns:
true if the parameter has changed

isShowElementOutline

public boolean isShowElementOutline()
Returns:
true if the bar outline should be also shown for none highlighted blocks

isShowLabelVertical

public boolean isShowLabelVertical()
Returns:
the showLabelVertical

setShowLabelVertical

public boolean setShowLabelVertical(boolean showLabelVertical)
Parameters:
showLabelVertical - if true the bar labels are displayed vertical otherwise horizontal.
Returns:
true if the parameter has changed

getLabelDisplayPolicy

public LabelDisplayPolicy getLabelDisplayPolicy()
Returns:
the labelDisplayPolicy

setLabelDisplayPolicy

public boolean setLabelDisplayPolicy(LabelDisplayPolicy labelDisplayPolicy)
Parameters:
labelDisplayPolicy - the display policy
Returns:
true if the parameter has changed

getHilitedKeys

public abstract Set<RowKey> getHilitedKeys()
Returns:
all keys of hilited rows

getSelectedKeys

public abstract Set<RowKey> getSelectedKeys()
Returns:
all keys of the selected elements

getSelectedElement

public BarDataModel getSelectedElement(Point p)
Parameters:
p - the point to select
Returns:
the BinDataModel that contains the point or null

selectElement

public void selectElement(Point point)
Selects the element which contains the given point.

Parameters:
point - the point on the screen to select

selectElement

public void selectElement(Rectangle rect)
Selects all elements which are touched by the given rectangle.

Parameters:
rect - the rectangle on the screen select

clearSelection

public void clearSelection()
Clears all selections.


updateHiliteInfo

public abstract void updateHiliteInfo(Set<RowKey> hilited,
                                      boolean hilite)
This method un/hilites all rows with the given key.

Parameters:
hilited - the rowKeys of the rows to un/hilite
hilite - if the given keys should be hilited true or unhilited false

unHiliteAll

public abstract void unHiliteAll()
Unhilites all rows.


getHTMLDetailData

public String getHTMLDetailData()
Returns:
a HTML String which contains details information about the current selected elements

setBinNominal

protected void setBinNominal(boolean nominal)
Parameters:
nominal - set to true if the nominal binning method should be used.

setBins

protected void setBins(List<? extends BinDataModel> bins,
                       BinDataModel missingValueBin)
Parameters:
bins - the bins to display
missingValueBin - the missing value bin

containsNotPresentableBin

public boolean containsNotPresentableBin()
Returns:
true if at least one bin is not presentable since the number of aggregation columns doesn't fit into the bin

calculateSurroundingRectangle

public static Rectangle2D calculateSurroundingRectangle(Rectangle2D rect,
                                                        int baseLine,
                                                        int thickness)
Calculates a surrounding rectangle with the given thickness for the given rectangle.

Parameters:
rect - the rectangle to draw the surrounding for
baseLine - the base line to know if the bar is negative or positive
thickness - the thickness of the surrounding rectangle
Returns:
the surrounding rectangle

getHiliteCalculator

public AbstractHistogramVizModel.HistogramHiliteCalculator getHiliteCalculator()
Returns:
the hilite shape calculator


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.