use of org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel in project knime-core by knime.
the class InteractiveHistogramPlotter method setAggregationMethod.
/**
* {@inheritDoc}
*/
@Override
public boolean setAggregationMethod(final AggregationMethod aggrMethod) {
if (aggrMethod == null) {
throw new IllegalArgumentException("Aggregation method must not" + " be null");
}
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
final Collection<? extends ColorColumn> oldAggrCols = vizModel.getAggrColumns();
if (oldAggrCols == null || oldAggrCols.size() < 1) {
// aggregation column
if (vizModel instanceof InteractiveHistogramVizModel) {
final InteractiveHistogramVizModel interactiveVizModel = (InteractiveHistogramVizModel) vizModel;
final AbstractHistogramProperties abstHistoProps = getHistogramPropertiesPanel();
if (abstHistoProps instanceof InteractiveHistogramProperties) {
final InteractiveHistogramProperties props = (InteractiveHistogramProperties) abstHistoProps;
final DataTableSpec spec = interactiveVizModel.getTableSpec();
final int numColumns = spec.getNumColumns();
boolean found = false;
for (int i = 0; i < numColumns; i++) {
final DataColumnSpec colSpec = spec.getColumnSpec(i);
if (AbstractHistogramPlotter.AGGREGATION_COLUMN_FILTER.includeColumn(colSpec)) {
final ColorColumn aggrColumn = new ColorColumn(Color.LIGHT_GRAY, colSpec.getName());
final ArrayList<ColorColumn> aggrCols = new ArrayList<ColorColumn>(1);
aggrCols.add(aggrColumn);
props.updateColumnSelection(spec, getXColName(), aggrCols, aggrMethod);
final List<ColorColumn> selectedAggrCols = props.getSelectedAggrColumns();
interactiveVizModel.setAggregationColumns(selectedAggrCols);
// set the current hilited keys in the new bins
vizModel.updateHiliteInfo(delegateGetHiLitKeys(), true);
found = true;
break;
}
}
if (!found) {
props.updateHistogramSettings(interactiveVizModel);
return false;
}
} else {
throw new IllegalStateException("ProeprtiesPanel should be of interactive type.");
}
} else {
throw new IllegalStateException("Visualization model should " + " be of interactive type.");
}
}
return super.setAggregationMethod(aggrMethod);
}
use of org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel in project knime-core by knime.
the class AbstractHistogramPlotter method updateSize.
/**
* {@inheritDoc}
*/
@Override
public void updateSize() {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel == null) {
LOGGER.debug("VizModel was null");
return;
}
final Dimension newDrawingSpace = getDrawingPaneDimension();
if (!vizModel.setDrawingSpace(newDrawingSpace)) {
return;
}
if (HistogramLayout.SIDE_BY_SIDE.equals(vizModel.getHistogramLayout()) && vizModel.containsNotPresentableBin()) {
// set the bin with to the maximum bin if the layout
// is side-by-side or the bin is not presentable with
// the current width
vizModel.setBinWidth(vizModel.getMaxBinWidth());
}
updatePaintModel();
}
use of org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel in project knime-core by knime.
the class AbstractHistogramPlotter method updateBinWidth.
/**
* Updates ONLY the width of the bins.
* @param binWidth the new bin width
*/
protected void updateBinWidth(final int binWidth) {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel == null) {
LOGGER.debug("VizModel was null");
return;
}
if (!vizModel.setBinWidth(binWidth)) {
return;
}
final Dimension drawingSpace = vizModel.getDrawingSpace();
if (drawingSpace == null) {
throw new IllegalStateException("Drawing space must not be null");
}
final double drawingWidth = drawingSpace.getWidth();
final double drawingHeight = drawingSpace.getHeight();
final Coordinate xCoordinates = getXCoordinate();
final Coordinate aggrCoordinate = getAggregationCoordinate();
final int baseLine = (int) (drawingHeight - aggrCoordinate.calculateMappedValue(new DoubleCell(0), drawingHeight));
final HistogramDrawingPane drawingPane = getHistogramDrawingPane();
final int newBinWidth = vizModel.getBinWidth();
final List<Color> barElementColors = vizModel.getRowColors();
final HistogramHiliteCalculator calculator = vizModel.getHiliteCalculator();
final Collection<ColorColumn> aggrColumns = vizModel.getAggrColumns();
for (final BinDataModel bin : vizModel.getBins()) {
final DataCell captionCell = bin.getXAxisCaptionCell();
final double labelCoord = xCoordinates.calculateMappedValue(captionCell, drawingWidth);
// subtract half of the bar width from the start position to place
// the middle point of the bar on the mapped coordinate position
final int xCoord = (int) (labelCoord - (newBinWidth / 2.0));
bin.updateBinWidth(xCoord, newBinWidth, barElementColors, aggrColumns, baseLine, calculator);
}
// if only the bar width changes we don't need to update the properties
// since the bar width change is triggered by the property component
// itself
drawingPane.setHistogramVizModel(vizModel, false);
}
use of org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel in project knime-core by knime.
the class AbstractHistogramPlotter method setShowEmptyBins.
/**
* @param showEmptyBins set to <code>true</code> if the empty bins should
* be displayed
* @return <code>true</code> if the value has changed
*/
public boolean setShowEmptyBins(final boolean showEmptyBins) {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel == null) {
LOGGER.debug("VizModel was null");
throw new IllegalStateException("Exception in setShowEmptyBins: " + "Viz model must not be null");
}
if (vizModel.setShowEmptyBins(showEmptyBins)) {
setXCoordinates();
setYCoordinates();
if (HistogramLayout.SIDE_BY_SIDE.equals(vizModel.getHistogramLayout()) && vizModel.containsNotPresentableBin() && (vizModel.getAggrColumns() != null && vizModel.getAggrColumns().size() > 1)) {
vizModel.setBinWidth(vizModel.getMaxBinWidth());
}
return true;
}
return false;
}
use of org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel in project knime-core by knime.
the class AbstractHistogramPlotter method selectElementsIn.
/**
* {@inheritDoc}
*/
@Override
public void selectElementsIn(final Rectangle selectionRectangle) {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel == null) {
LOGGER.debug("VizModel was null");
return;
}
vizModel.selectElement(selectionRectangle);
m_histoProps.updateHTMLDetailsPanel(vizModel.getHTMLDetailData());
repaint();
}
Aggregations