Search in sources :

Example 1 with InteractiveHistogramVizModel

use of org.knime.base.node.viz.histogram.datamodel.InteractiveHistogramVizModel 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);
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) AbstractHistogramVizModel(org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel) ColorColumn(org.knime.base.node.viz.histogram.util.ColorColumn) ArrayList(java.util.ArrayList) AbstractHistogramProperties(org.knime.base.node.viz.histogram.impl.AbstractHistogramProperties) InteractiveHistogramVizModel(org.knime.base.node.viz.histogram.datamodel.InteractiveHistogramVizModel) DataColumnSpec(org.knime.core.data.DataColumnSpec)

Example 2 with InteractiveHistogramVizModel

use of org.knime.base.node.viz.histogram.datamodel.InteractiveHistogramVizModel in project knime-core by knime.

the class InteractiveHistogramPlotter method onAggrColChanged.

/**
 * Called whenever the user changes the aggregation column.
 */
protected void onAggrColChanged() {
    final AbstractHistogramVizModel abstractVizModel = getHistogramVizModel();
    if (abstractVizModel == null) {
        LOGGER.debug("VizModel was null");
        return;
    }
    final AbstractHistogramProperties abstractHistogramProperties = getHistogramPropertiesPanel();
    if (abstractHistogramProperties == null) {
        LOGGER.debug("ProeprtiesPanel was null");
        return;
    }
    if (abstractVizModel instanceof InteractiveHistogramVizModel) {
        final InteractiveHistogramVizModel vizModel = (InteractiveHistogramVizModel) abstractVizModel;
        if (abstractHistogramProperties instanceof InteractiveHistogramProperties) {
            final InteractiveHistogramProperties props = (InteractiveHistogramProperties) abstractHistogramProperties;
            final List<ColorColumn> aggrCols = props.getSelectedAggrColumns();
            if (vizModel.setAggregationColumns(aggrCols)) {
                // show the bar outline automatically depending on the
                // number of selected aggregation columns
                vizModel.setShowBarOutline(aggrCols != null && aggrCols.size() > 1);
                setYCoordinates();
                // set the current hilited keys in the new bins
                vizModel.updateHiliteInfo(delegateGetHiLitKeys(), true);
                if (vizModel.containsNotPresentableBin()) {
                    vizModel.setBinWidth(vizModel.getMaxBinWidth());
                }
                // update the details tab
                getHistogramPropertiesPanel().updateHTMLDetailsPanel(vizModel.getHTMLDetailData());
                updatePaintModel();
            }
        } else {
            throw new IllegalStateException(" PropertiesPanel should be of type interactive");
        }
    } else {
        throw new IllegalStateException("VizModel should be of type interactive");
    }
}
Also used : AbstractHistogramVizModel(org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel) ColorColumn(org.knime.base.node.viz.histogram.util.ColorColumn) AbstractHistogramProperties(org.knime.base.node.viz.histogram.impl.AbstractHistogramProperties) InteractiveHistogramVizModel(org.knime.base.node.viz.histogram.datamodel.InteractiveHistogramVizModel)

Example 3 with InteractiveHistogramVizModel

use of org.knime.base.node.viz.histogram.datamodel.InteractiveHistogramVizModel in project knime-core by knime.

the class InteractiveHistogramPlotter method onXColChanged.

/**
 * Called whenever user changes the x column selection.
 *
 * @param xColName the new selected x column
 */
protected void onXColChanged(final String xColName) {
    if (xColName == null || xColName.trim().length() < 1) {
        return;
    }
    // if it's the same name we don't need to do anything
    if (getXColName() != null && getXColName().equals(xColName)) {
        return;
    }
    final AbstractHistogramVizModel abstractVizModel = getHistogramVizModel();
    if (abstractVizModel == null) {
        LOGGER.debug("VizModel was null");
        return;
    }
    if (abstractVizModel instanceof InteractiveHistogramVizModel) {
        final InteractiveHistogramVizModel vizModel = (InteractiveHistogramVizModel) abstractVizModel;
        final DataColumnSpec xColSpec = getDataTableSpec().getColumnSpec(xColName);
        if (vizModel.setXColumn(xColSpec)) {
            // set the current hilited keys in the new bins
            vizModel.updateHiliteInfo(delegateGetHiLitKeys(), true);
            // set the new axis
            setXCoordinates();
            setYCoordinates();
            // update the details tab
            getHistogramPropertiesPanel().updateHTMLDetailsPanel(vizModel.getHTMLDetailData());
            // repaint the plotter
            updatePaintModel();
        }
    } else {
        throw new IllegalStateException("VizModel should be of type interactive");
    }
// update the slider values and the select boxes
// getHistogramPropertiesPanel().updateHistogramSettings(this);
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) AbstractHistogramVizModel(org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel) InteractiveHistogramVizModel(org.knime.base.node.viz.histogram.datamodel.InteractiveHistogramVizModel)

Aggregations

AbstractHistogramVizModel (org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel)3 InteractiveHistogramVizModel (org.knime.base.node.viz.histogram.datamodel.InteractiveHistogramVizModel)3 AbstractHistogramProperties (org.knime.base.node.viz.histogram.impl.AbstractHistogramProperties)2 ColorColumn (org.knime.base.node.viz.histogram.util.ColorColumn)2 DataColumnSpec (org.knime.core.data.DataColumnSpec)2 ArrayList (java.util.ArrayList)1 DataTableSpec (org.knime.core.data.DataTableSpec)1