Search in sources :

Example 6 with PieVizModel

use of org.knime.base.node.viz.pie.datamodel.PieVizModel in project knime-core by knime.

the class PiePlotter method registerPropertiesChangeListener.

/**
 * Registers all histogram properties listener to the histogram
 * properties panel.
 */
private void registerPropertiesChangeListener() {
    m_props.addShowSectionOutlineChangedListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel != null) {
                vizModel.setDrawSectionOutline(e.getStateChange() == ItemEvent.SELECTED);
                final AbstractDrawingPane drawingPane = getPieDrawingPane();
                drawingPane.repaint();
            }
        }
    });
    m_props.addLabelDisplayListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel != null) {
                final P props = getPropertiesPanel();
                if (props != null) {
                    vizModel.setLabelDisplayPolicy(props.getLabelDisplayPolicy());
                    final AbstractDrawingPane drawingPane = getPieDrawingPane();
                    drawingPane.repaint();
                }
            }
        }
    });
    m_props.addValueScaleListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel != null) {
                final P props = getPropertiesPanel();
                if (props != null) {
                    vizModel.setValueScale(props.getValueScale());
                    final AbstractDrawingPane drawingPane = getPieDrawingPane();
                    drawingPane.repaint();
                }
            }
        }
    });
    m_props.addShowDetailsListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel != null) {
                if (vizModel.setShowDetails(e.getStateChange() == ItemEvent.SELECTED)) {
                    final AbstractDrawingPane drawingPane = getPieDrawingPane();
                    drawingPane.repaint();
                }
            }
        }
    });
    m_props.addPieSizeChangeListener(new ChangeListener() {

        public void stateChanged(final ChangeEvent e) {
            final JSlider source = (JSlider) e.getSource();
            final int pieSize = source.getValue();
            final PieVizModel vizModel = getVizModel();
            if (vizModel == null) {
                return;
            }
            if (vizModel.setPieSize((pieSize / 100.0))) {
                updatePaintModel();
            }
        }
    });
    m_props.addExplodeSizeChangeListener(new ChangeListener() {

        public void stateChanged(final ChangeEvent e) {
            final JSlider source = (JSlider) e.getSource();
            final int explodeSize = source.getValue();
            final PieVizModel vizModel = getVizModel();
            if (vizModel == null) {
                return;
            }
            if (vizModel.setExplodeSize((explodeSize / 100.0))) {
                updatePaintModel();
            }
        }
    });
    m_props.addAggrMethodListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel == null) {
                return;
            }
            final String methodName = e.getActionCommand();
            if (!AggregationMethod.valid(methodName)) {
                throw new IllegalArgumentException("No valid aggregation method");
            }
            final AggregationMethod aggrMethod = AggregationMethod.getMethod4Command(methodName);
            if (vizModel.setAggregationMethod(aggrMethod)) {
                updatePaintModel();
            }
        }
    });
    m_props.addShowMissingValSectionListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel == null) {
                return;
            }
            if (vizModel.setShowMissingValSection(e.getStateChange() == ItemEvent.SELECTED)) {
                // reset the details view if the missing section was selected
                final P properties = getPropertiesPanel();
                if (properties != null) {
                    properties.updateHTMLDetailsPanel(vizModel.getHTMLDetailData());
                }
                updatePaintModel();
            }
        }
    });
    m_props.addExplodeSelectedSectionListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel == null) {
                return;
            }
            if (vizModel.setExplodeSelectedSections(e.getStateChange() == ItemEvent.SELECTED)) {
                updatePaintModel();
            }
        }
    });
}
Also used : AggregationMethod(org.knime.base.node.viz.aggregation.AggregationMethod) ItemEvent(java.awt.event.ItemEvent) PieVizModel(org.knime.base.node.viz.pie.datamodel.PieVizModel) ActionEvent(java.awt.event.ActionEvent) AbstractDrawingPane(org.knime.base.node.viz.plotter.AbstractDrawingPane) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) JSlider(javax.swing.JSlider) ItemListener(java.awt.event.ItemListener) ChangeListener(javax.swing.event.ChangeListener)

Example 7 with PieVizModel

use of org.knime.base.node.viz.pie.datamodel.PieVizModel in project knime-core by knime.

the class PiePlotter method updatePaintModel.

/**
 * {@inheritDoc}
 */
@Override
public void updatePaintModel() {
    final PieVizModel vizModel = getVizModel();
    if (vizModel == null) {
        LOGGER.debug("VizModel was null");
        return;
    }
    final PieDrawingPane drawingPane = getPieDrawingPane();
    drawingPane.reset();
    if (m_infoMsg == null) {
        setPieSections(vizModel);
    } else {
        drawingPane.setInfoMsg(m_infoMsg);
    }
    drawingPane.setVizModel(vizModel);
}
Also used : PieVizModel(org.knime.base.node.viz.pie.datamodel.PieVizModel)

Example 8 with PieVizModel

use of org.knime.base.node.viz.pie.datamodel.PieVizModel in project knime-core by knime.

the class PiePlotter method hiLiteSelected.

/**
 * {@inheritDoc}
 */
@Override
public void hiLiteSelected() {
    final PieVizModel vizModel = getVizModel();
    if (vizModel == null || !vizModel.supportsHiliting()) {
        LOGGER.debug("VizModel doesn't support hiliting or was null");
        return;
    }
    final Set<RowKey> selectedKeys = vizModel.getSelectedKeys();
    delegateHiLite(selectedKeys);
    repaint();
}
Also used : PieVizModel(org.knime.base.node.viz.pie.datamodel.PieVizModel) RowKey(org.knime.core.data.RowKey)

Example 9 with PieVizModel

use of org.knime.base.node.viz.pie.datamodel.PieVizModel in project knime-core by knime.

the class PiePlotter method selectElementsIn.

/**
 * {@inheritDoc}
 */
@Override
public void selectElementsIn(final Rectangle selectionRectangle) {
    final PieVizModel vizModel = getVizModel();
    if (vizModel == null) {
        return;
    }
    vizModel.selectElement(selectionRectangle);
    if (vizModel.explodeSelectedSections()) {
        updatePaintModel();
    }
    final P properties = getPropertiesPanel();
    if (properties != null) {
        properties.updateHTMLDetailsPanel(vizModel.getHTMLDetailData());
    }
    repaint();
}
Also used : PieVizModel(org.knime.base.node.viz.pie.datamodel.PieVizModel)

Example 10 with PieVizModel

use of org.knime.base.node.viz.pie.datamodel.PieVizModel in project knime-core by knime.

the class PiePlotter method unHiLiteAll.

/**
 * {@inheritDoc}
 */
public void unHiLiteAll(KeyEvent event) {
    final PieVizModel vizModel = getVizModel();
    if (vizModel == null || !vizModel.supportsHiliting()) {
        LOGGER.debug("VizModel doesn't support hiliting or was null");
        return;
    }
    vizModel.unHiliteAll();
    repaint();
}
Also used : PieVizModel(org.knime.base.node.viz.pie.datamodel.PieVizModel)

Aggregations

PieVizModel (org.knime.base.node.viz.pie.datamodel.PieVizModel)11 RowKey (org.knime.core.data.RowKey)4 Dimension (java.awt.Dimension)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 JSlider (javax.swing.JSlider)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1 AggregationMethod (org.knime.base.node.viz.aggregation.AggregationMethod)1 AbstractDrawingPane (org.knime.base.node.viz.plotter.AbstractDrawingPane)1