Search in sources :

Example 1 with AbstractDrawingPane

use of org.knime.base.node.viz.plotter.AbstractDrawingPane 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)

Aggregations

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 PieVizModel (org.knime.base.node.viz.pie.datamodel.PieVizModel)1 AbstractDrawingPane (org.knime.base.node.viz.plotter.AbstractDrawingPane)1