use of org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel in project knime-core by knime.
the class AbstractHistogramPlotter method hiLite.
// *************************************************************************
// Selection and hiliting section
// *************************************************************************
/**
* {@inheritDoc}
*/
@Override
public void hiLite(final KeyEvent event) {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel == null || !vizModel.supportsHiliting()) {
LOGGER.debug("VizModel doesn't support hiliting or was null");
return;
}
final Set<RowKey> hilited = event.keys();
vizModel.updateHiliteInfo(hilited, true);
repaint();
}
use of org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel in project knime-core by knime.
the class AbstractHistogramPlotter method getAggregationColSpec.
/**
* @return the <code>DataColumnSpec</code> of the aggregation column
*/
public DataColumnSpec getAggregationColSpec() {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel == null) {
LOGGER.debug("VizModel was null");
throw new IllegalStateException("Exception in getAggregationColSpec: " + "Viz model must not be null");
}
double lowerBound = vizModel.getMinAggregationValue();
double upperBound = vizModel.getMaxAggregationValue();
// coordinate
if (lowerBound > 0) {
lowerBound = 0;
} else if (upperBound < 0) {
upperBound = 0;
}
final AggregationMethod aggrMethod = vizModel.getAggregationMethod();
// set the column type depending on the aggregation method and type of
// the aggregation column. If the method is count set it to integer. If
// the aggregation method is summary and the data type of the
// aggregation column is integer the result must be an integer itself
DataType type = DoubleCell.TYPE;
final Collection<? extends ColorColumn> columnNames = vizModel.getAggrColumns();
if (AggregationMethod.COUNT.equals(aggrMethod) || AggregationMethod.VALUE_COUNT.equals(aggrMethod)) {
type = IntCell.TYPE;
}
if (AggregationMethod.SUM.equals(aggrMethod) && columnNames != null) {
// if the aggregation method is summary and ...
boolean allInteger = true;
for (final ColorColumn column : columnNames) {
final DataColumnSpec colSpec = m_tableSpec.getColumnSpec(column.getColumnName());
if (colSpec == null || !colSpec.getType().isCompatible(IntValue.class)) {
allInteger = false;
break;
}
}
// ... all columns of the int type we can set the column type to int
if (allInteger) {
type = IntCell.TYPE;
}
}
final String displayColumnName = createAggregationColumnName(columnNames, aggrMethod);
final DataColumnSpec spec = createColumnSpec(displayColumnName, type, lowerBound, upperBound, null);
return spec;
}
use of org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel in project knime-core by knime.
the class AbstractHistogramPlotter method setHistogramLayout.
/**
* @param layout the {@link HistogramLayout} to use
*/
public void setHistogramLayout(final HistogramLayout layout) {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel == null) {
return;
}
if (vizModel.setHistogramLayout(layout)) {
// if the layout has changed we have to update the y coordinates
setYCoordinates();
// save the current bin width
final int currentWidth = vizModel.getBinWidth();
if (m_lastBinWidth > 0) {
// set the bin width to the last used width for this layout
vizModel.setBinWidth(m_lastBinWidth);
} else if (HistogramLayout.SIDE_BY_SIDE.equals(layout)) {
// one element
if (vizModel.getNoOfElements() > 1) {
vizModel.setBinWidth(vizModel.getMaxBinWidth());
}
}
// and save the bin width for the next change
m_lastBinWidth = currentWidth;
updatePaintModel();
}
}
use of org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel in project knime-core by knime.
the class AbstractHistogramPlotter method registerPropertiesChangeListener.
/**
* Registers all histogram properties listener to the histogram
* properties panel.
*/
private void registerPropertiesChangeListener() {
if (m_histoProps == null) {
throw new IllegalStateException("Properties panel must not be null");
}
m_histoProps.addShowGridChangedListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
setShowGridLines(e.getStateChange() == ItemEvent.SELECTED);
}
});
m_histoProps.addShowBinOutlineChangedListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel != null) {
vizModel.setShowBinOutline(e.getStateChange() == ItemEvent.SELECTED);
final HistogramDrawingPane histoDrawingPane = getHistogramDrawingPane();
histoDrawingPane.repaint();
}
}
});
m_histoProps.addShowBarOutlineChangedListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel != null) {
vizModel.setShowBarOutline(e.getStateChange() == ItemEvent.SELECTED);
final HistogramDrawingPane histoDrawingPane = getHistogramDrawingPane();
histoDrawingPane.repaint();
}
}
});
m_histoProps.addShowElementOutlineChangedListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel != null) {
vizModel.setShowElementOutline(e.getStateChange() == ItemEvent.SELECTED);
final HistogramDrawingPane histoDrawingPane = getHistogramDrawingPane();
histoDrawingPane.repaint();
}
}
});
m_histoProps.addLabelOrientationListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel != null) {
final AbstractHistogramProperties histoProps = getHistogramPropertiesPanel();
if (histoProps != null) {
vizModel.setShowLabelVertical(histoProps.isShowLabelVertical());
final HistogramDrawingPane histoDrawingPane = getHistogramDrawingPane();
histoDrawingPane.repaint();
}
}
}
});
m_histoProps.addLabelDisplayListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel != null) {
final AbstractHistogramProperties histoProps = getHistogramPropertiesPanel();
if (histoProps != null) {
vizModel.setLabelDisplayPolicy(histoProps.getLabelDisplayPolicy());
final HistogramDrawingPane histoDrawingPane = getHistogramDrawingPane();
histoDrawingPane.repaint();
}
}
}
});
m_histoProps.addLayoutListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
final AbstractHistogramProperties histoProps = getHistogramPropertiesPanel();
if (histoProps != null) {
setHistogramLayout(histoProps.getHistogramLayout());
}
}
});
m_histoProps.addBinWidthChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
final int binWidth = m_histoProps.getBinWidth();
updateBinWidth(binWidth);
}
});
m_histoProps.addNoOfBinsChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
final int noOfBins = m_histoProps.getNoOfBins();
if (setNumberOfBins(noOfBins)) {
updatePaintModel();
}
}
});
m_histoProps.addAggrMethodListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
final String methodName = e.getActionCommand();
if (!AggregationMethod.valid(methodName)) {
throw new IllegalArgumentException("No valid aggregation method");
}
final AggregationMethod aggrMethod = AggregationMethod.getMethod4Command(methodName);
if (setAggregationMethod(aggrMethod)) {
updatePaintModel();
}
}
});
m_histoProps.addShowEmptyBinListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (setShowEmptyBins(e.getStateChange() == ItemEvent.SELECTED)) {
updatePaintModel();
}
}
});
m_histoProps.addShowMissingValBinListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (setShowMissingValBin(e.getStateChange() == ItemEvent.SELECTED)) {
updatePaintModel();
}
}
});
m_histoProps.addShowInvalidValBinListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (setShowInvalidValBin(e.getStateChange() == ItemEvent.SELECTED)) {
updatePaintModel();
}
}
});
}
use of org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel in project knime-core by knime.
the class AbstractHistogramPlotter method setShowInvalidValBin.
/**
* @param showInvalidValBin the showMissingvalBar to set
* @return <code>true</code> if the value has changed
* @since 2.9
*/
public boolean setShowInvalidValBin(final boolean showInvalidValBin) {
final AbstractHistogramVizModel vizModel = getHistogramVizModel();
if (vizModel == null) {
LOGGER.debug("VizModel was null");
throw new IllegalStateException("Exception in setShowInvalidValBin: " + "Viz model must not be null");
}
if (vizModel.setShowInvalidValBin(showInvalidValBin)) {
// set the coordinates to the new boundaries
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;
}
Aggregations