Example usage for org.jfree.chart.axis Axis setPlot

List of usage examples for org.jfree.chart.axis Axis setPlot

Introduction

In this page you can find the example usage for org.jfree.chart.axis Axis setPlot.

Prototype

public void setPlot(Plot plot) 

Source Link

Document

Sets a reference to the plot that the axis is assigned to.

Usage

From source file:com.choicemaker.cm.modelmaker.gui.utils.HistoChartPanel.java

public HistoChartPanel(final JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom,
        boolean tooltips, final ModelMaker modelMaker) {
    super(chart, properties, save, print, zoom, tooltips);
    this.modelMaker = modelMaker;
    // horizontal zoom doesn't work, by setting false we don't get bogus menu item
    //      setHorizontalZoom(false);
    //      setVerticalZoom(true);
    final JCheckBoxMenuItem logYScale = new JCheckBoxMenuItem(
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.test.logscale.y"));
    logYScale.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            CategoryPlot p = (CategoryPlot) chart.getPlot();
            Axis oldAxis = p.getRangeAxis();
            if (logYScale.isSelected()) {
                LogarithmicAxis yAxis = new LogarithmicAxis(ChoiceMakerCoreMessages.m
                        .formatMessage("train.gui.modelmaker.panel.histogram.cm.numpairs"));
                yAxis.setStrictValuesFlag(false);
                p.setRangeAxis(yAxis);/*w  w w  .  ja  v a  2  s  .  c  o m*/
            } else {
                p.setRangeAxis(new NumberAxis(ChoiceMakerCoreMessages.m
                        .formatMessage("train.gui.modelmaker.panel.histogram.cm.numpairs")));
            }
            oldAxis.setPlot(null);
            chartChanged(new ChartChangeEvent(this));
        }
    });
    JPopupMenu popup = getPopupMenu();
    popup.addSeparator();
    popup.add(logYScale);
    popup.addSeparator();
    select = new JMenu("Select");
    final JMenuItem all = new JMenuItem("All");
    select.add(all);
    final JMenuItem cmDiffer = new JMenuItem("Human marked differ");
    select.add(cmDiffer);
    final JMenuItem cmHold = new JMenuItem("Human marked hold");
    select.add(cmHold);
    final JMenuItem cmMatch = new JMenuItem("Human marked match");
    select.add(cmMatch);
    ActionListener l = new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            ListeningMarkedRecordPairFilter filter = modelMaker.getFilter();
            filter.reset();
            filter.setFromPercentage(rangeFrom);
            filter.setToPercentage(rangeTo);
            Object src = ev.getSource();
            if (src != all) {
                boolean[] b = new boolean[Decision.NUM_DECISIONS];
                if (src == cmDiffer) {
                    b[Decision.DIFFER.toInt()] = true;
                } else if (src == cmHold) {
                    b[Decision.HOLD.toInt()] = true;
                } else if (src == cmMatch) {
                    b[Decision.MATCH.toInt()] = true;
                }
                filter.setHumanDecision(b);
            }
            modelMaker.filterMarkedRecordPairList();
        }
    };
    all.addActionListener(l);
    cmDiffer.addActionListener(l);
    cmHold.addActionListener(l);
    cmMatch.addActionListener(l);
    popup.add(select);
    addChartMouseListener(new ChartMouseListener() {
        public void chartMouseClicked(ChartMouseEvent evt) {
            ChartEntity e = evt.getEntity();
            if (e instanceof CategoryItemEntity) {
                CategoryItemEntity c = (CategoryItemEntity) e;
                int cat = c.getCategoryIndex();
                HistoCategoryDataset data = (HistoCategoryDataset) ((CategoryPlot) getChart().getPlot())
                        .getDataset();
                int len = data.getColumnCount();
                float step = 1f / len;
                rangeFrom = cat * step;
                rangeTo = rangeFrom + step;
                ListeningMarkedRecordPairFilter filter = modelMaker.getFilter();
                filter.reset();
                filter.setFromPercentage(rangeFrom);
                filter.setToPercentage(rangeTo);
                boolean[] b = new boolean[Decision.NUM_DECISIONS];
                int series = c.getSeries();
                if (data.isIncludeHolds() && series != 0) {
                    if (series == 1) {
                        series = 2;
                    } else {
                        series = 1;
                    }
                }
                b[series] = true;
                filter.setHumanDecision(b);
                modelMaker.filterMarkedRecordPairList();

            }
        }

        public void chartMouseMoved(ChartMouseEvent arg0) {
        }
    });
}

From source file:ucar.unidata.idv.control.chart.MyXYPlot.java

/**
 * Provides serialization support./*  w  ww  .  j av a  2s  .c om*/
 *
 * @param stream  the input stream.
 *
 * @throws IOException  if there is an I/O error.
 * @throws ClassNotFoundException  if there is a classpath problem.
 */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {

    stream.defaultReadObject();
    this.domainGridlineStroke = SerialUtilities.readStroke(stream);
    this.domainGridlinePaint = SerialUtilities.readPaint(stream);
    this.rangeGridlineStroke = SerialUtilities.readStroke(stream);
    this.rangeGridlinePaint = SerialUtilities.readPaint(stream);
    this.rangeZeroBaselineStroke = SerialUtilities.readStroke(stream);
    this.rangeZeroBaselinePaint = SerialUtilities.readPaint(stream);
    this.domainCrosshairStroke = SerialUtilities.readStroke(stream);
    this.domainCrosshairPaint = SerialUtilities.readPaint(stream);
    this.rangeCrosshairStroke = SerialUtilities.readStroke(stream);
    this.rangeCrosshairPaint = SerialUtilities.readPaint(stream);
    this.domainTickBandPaint = SerialUtilities.readPaint(stream);
    this.rangeTickBandPaint = SerialUtilities.readPaint(stream);
    this.quadrantOrigin = SerialUtilities.readPoint2D(stream);
    this.quadrantPaint = new Paint[4];
    for (int i = 0; i < 4; i++) {
        this.quadrantPaint[i] = SerialUtilities.readPaint(stream);
    }

    // register the plot as a listener with its axes, datasets, and 
    // renderers...
    int domainAxisCount = this.domainAxes.size();
    for (int i = 0; i < domainAxisCount; i++) {
        Axis axis = (Axis) this.domainAxes.get(i);
        if (axis != null) {
            axis.setPlot(this);
            axis.addChangeListener(this);
        }
    }
    int rangeAxisCount = this.rangeAxes.size();
    for (int i = 0; i < rangeAxisCount; i++) {
        Axis axis = (Axis) this.rangeAxes.get(i);
        if (axis != null) {
            axis.setPlot(this);
            axis.addChangeListener(this);
        }
    }
    int datasetCount = this.datasets.size();
    for (int i = 0; i < datasetCount; i++) {
        Dataset dataset = (Dataset) this.datasets.get(i);
        if (dataset != null) {
            dataset.addChangeListener(this);
        }
    }
    int rendererCount = this.renderers.size();
    for (int i = 0; i < rendererCount; i++) {
        XYItemRenderer renderer = (XYItemRenderer) this.renderers.get(i);
        if (renderer != null) {
            renderer.addChangeListener(this);
        }
    }

}