Example usage for org.jfree.chart ChartPanel setMouseZoomable

List of usage examples for org.jfree.chart ChartPanel setMouseZoomable

Introduction

In this page you can find the example usage for org.jfree.chart ChartPanel setMouseZoomable.

Prototype

public void setMouseZoomable(boolean flag) 

Source Link

Document

A convenience method that switches on mouse-based zooming.

Usage

From source file:scatterplot1k.JFreeScatter2.java

public JFreeScatter2(String title, int samplesCount) {
    super(title);
    this.samplesCount = samplesCount;
    JFreeChart chart = createChart(title, createDataset());
    ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new Dimension(800, 600));
    panel.setMouseZoomable(false);
    this.add(panel);
}

From source file:ws.moor.bt.gui.charts.BlockOrigin.java

public BlockOrigin(CounterRepository counterRepository) {
    super();/* w  w w .  j a  v  a 2s .c o  m*/
    this.counterRepository = counterRepository;

    chart = createChart(getDataSet());
    setLayout(new BorderLayout());
    ChartPanel panel = new ChartPanel(chart, false, true, false, false, false);
    panel.setMouseZoomable(false);
    add(panel, BorderLayout.CENTER);
}

From source file:ws.moor.bt.gui.charts.RemotePeerCompletion.java

public RemotePeerCompletion(TorrentDownload download) {
    super();//from  w  w  w.ja v  a 2 s . co  m
    this.download = download;

    chart = createChart(getDataSet());
    setLayout(new BorderLayout());
    ChartPanel panel = new ChartPanel(chart, false, true, false, false, false);
    panel.setMouseZoomable(false);
    add(panel, BorderLayout.CENTER);
}

From source file:ws.moor.bt.gui.charts.ConnectionTypes.java

public ConnectionTypes(CounterRepository counterRepository) {
    super();//from   ww  w .j a va 2s  . c  om

    seederSource = new CounterStatisticsDataSource(
            counterRepository.getStatistics("network.connections.seed")) {
        protected double getValueToShowAt(long time) {
            return statistics.getValueAt(time);
        }
    };
    leecherSource = new CounterStatisticsDataSource(
            counterRepository.getStatistics("network.connections.leecher")) {
        protected double getValueToShowAt(long time) {
            return statistics.getValueAt(time);
        }
    };

    chart = createChart(getTimeSeriesCollection());
    setLayout(new BorderLayout());
    ChartPanel panel = new ChartPanel(chart, false, true, false, false, false);
    panel.setMouseZoomable(false);
    add(panel, BorderLayout.CENTER);
}

From source file:org.uncommons.watchmaker.swing.evolutionmonitor.JVMView.java

JVMView() {
    super(new BorderLayout());
    double maxMemory = (double) memoryBean.getHeapMemoryUsage().getMax() / MEGABYTE;

    ChartPanel heapPanel = new ChartPanel(createHeapChart(maxMemory), false, // Properties
            true, // Save
            true, // Print
            false, // Zoom
            true); // Tooltips
    heapPanel.setMouseZoomable(false);
    add(heapPanel, BorderLayout.CENTER);
    add(createControls(), BorderLayout.SOUTH);

    Timer timer = new Timer(5000, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            addMemoryDataPoint();//from  w  ww.  j  av a2  s  . c om
        }
    });

    // Plot start values.
    addMemoryDataPoint();

    timer.start();
}

From source file:org.fhcrc.cpl.viewer.quant.gui.PanelWithLogRatioHistAndFields.java

/**
 * Set the log ratios, build the histogram and display, removing the old one if there was one.  Nothing gets
 * cleaned up related to the old chart; it'll just hang around intil GC
 * todo: do I need to dispose of the old chart in a better way?
 * @param logRatios//from   w  ww .  ja va 2 s  .c om
 */
public void setLogRatios(List<Float> logRatios) {
    _log.debug("setLogRatios 1");
    if (logRatioHistogram != null) {
        remove(logRatioHistogram);
    }
    this.logRatios = logRatios;

    float minLogRatioBound = (float) Math.log(minRatioBound);
    float maxLogRatioBound = (float) Math.log(maxRatioBound);

    _log.debug("setLogRatios 2");

    List<Float> boundedLogRatios = new ArrayList<Float>(logRatios.size());
    for (float logRatio : logRatios)
        boundedLogRatios.add(Math.min(maxLogRatioBound, Math.max(minLogRatioBound, logRatio)));

    logRatioHistogram = new PanelWithHistogram(boundedLogRatios, "Log Ratios", 200);
    Dimension histDimension = new Dimension(300, 80);
    if (!Float.isNaN(domainCrosshairValue)) {
        logRatioHistogram.getChart().getXYPlot().setDomainCrosshairValue(domainCrosshairValue, true);
        logRatioHistogram.getChart().getXYPlot().setDomainCrosshairVisible(true);
    }

    _log.debug("setLogRatios 1");

    logRatioHistogram.setPreferredSize(histDimension);
    logRatioHistogram.getChart().removeLegend();
    logRatioHistogram.getChart().getXYPlot().getDomainAxis().setLowerBound(minLogRatioBound);
    logRatioHistogram.getChart().getXYPlot().getDomainAxis().setUpperBound(maxLogRatioBound);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.weighty = 10;
    gbc.weightx = 1;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(logRatioHistogram, gbc);

    histMouseListener = new LogRatioHistMouseListener(logRatioHistogram);
    ChartPanel histChartPanel = logRatioHistogram.getChartPanel();
    histChartPanel.setMouseZoomable(false);
    logRatioHistogram.getChartPanel().addMouseListener(histMouseListener);
    logRatioHistogram.getChartPanel().addMouseMotionListener(histMouseListener);
    histMouseListener.addRangeUpdateListener(new LogRatioHistogramListener(this));

    logRatioHistogram.updateUI();
    //if there are specified minHigh and maxHigh values, and they're valid, draw the initially selected region
    if (minHighRatio > maxLowRatio && minHighRatio > 0 && maxLowRatio > 0)
        updateSelectedRegion();

    //remove axes from chart
    ((XYPlot) logRatioHistogram.getPlot()).getRangeAxis().setVisible(false);
    ((XYPlot) logRatioHistogram.getPlot()).getDomainAxis().setVisible(false);

    logRatioHistogram.updateUI();
}

From source file:org.spf4j.ui.TSDBViewJInternalFrame.java

private void addChartToPanel(final String tableName, final JPanel content) throws IOException {
    TSTable info = tsDb.getTSTable(tableName);
    long startTime = ((Date) startDate.getValue()).getTime();
    long endTime = ((Date) endDate.getValue()).getTime();
    if (TSDBMeasurementStore.canGenerateHeatChart(info)) {
        JFreeChart chart = tsDb.createHeatJFreeChart(info.getTableName(), startTime, endTime);
        ChartPanel pannel = new ChartPanel(chart);
        pannel.setPreferredSize(new Dimension(600, 800));
        pannel.setDomainZoomable(false);
        pannel.setMouseZoomable(false);
        pannel.setRangeZoomable(false);/*from   w ww  .java2  s  .co  m*/
        pannel.setZoomAroundAnchor(false);
        pannel.setZoomInFactor(1);
        pannel.setZoomOutFactor(1);
        content.add(pannel);
    }
    if (TSDBMeasurementStore.canGenerateMinMaxAvgCount(info)) {
        JFreeChart chart = tsDb.createMinMaxAvgJFreeChart(info.getTableName(), startTime, endTime);
        ChartPanel pannel = new ChartPanel(chart);
        pannel.setPreferredSize(new Dimension(600, 600));
        content.add(pannel);

    }
    if (TSDBMeasurementStore.canGenerateCount(info)) {
        JFreeChart chart = tsDb.createCountJFreeChart(info.getTableName(), startTime, endTime);
        ChartPanel pannel = new ChartPanel(chart);
        pannel.setPreferredSize(new Dimension(600, 600));
        content.add(pannel);
    } else {
        List<JFreeChart> createJFreeCharts = tsDb.createJFreeCharts(info.getTableName(), startTime, endTime);
        for (JFreeChart chart : createJFreeCharts) {
            ChartPanel pannel = new ChartPanel(chart);
            pannel.setPreferredSize(new Dimension(600, 600));
            content.add(pannel);
        }
    }
}

From source file:org.jfree.chart.demo.JFreeChartDemo.java

/**
 * Handles menu selections by passing control to an appropriate method.
 *
 * @param event  the event./* w  ww.j  a  v  a  2  s . c  o m*/
 */
public void actionPerformed(final ActionEvent event) {

    final String command = event.getActionCommand();
    if (command.equals(EXIT_COMMAND)) {
        attemptExit();
    } else if (command.equals(ABOUT_COMMAND)) {
        about();
    } else {
        /// Loop through available commands to find index to current command.
        int chartnum = -1;
        int i = CHART_COMMANDS.length;
        while (i > 0) {
            --i;
            if (command.equals(CHART_COMMANDS[i][0])) {
                chartnum = i;
                i = 0;
            }
        }

        /// check our index is valid
        if ((chartnum >= 0) && (chartnum < this.frame.length)) {
            /// Check we have not already created chart.
            if (this.frame[chartnum] == null) {
                // setup the chart.
                DEMO.getChart(chartnum);

                // present it in a frame...
                String str = this.resources.getString(CHART_COMMANDS[chartnum][2] + ".title");
                this.frame[chartnum] = new ChartFrame(str, DEMO.getChart(chartnum));
                this.frame[chartnum].getChartPanel().setPreferredSize(new java.awt.Dimension(500, 270));
                this.frame[chartnum].pack();
                RefineryUtilities.positionFrameRandomly(this.frame[chartnum]);

                /// Set panel to zoomable if required
                try {
                    str = this.resources.getString(CHART_COMMANDS[chartnum][2] + ".zoom");
                    if ((str != null) && (str.toLowerCase().equals("true"))) {
                        final ChartPanel panel = this.frame[chartnum].getChartPanel();
                        panel.setMouseZoomable(true);
                        panel.setHorizontalAxisTrace(true);
                        panel.setVerticalAxisTrace(true);
                    }
                } catch (Exception ex) {
                    /// Filter out messages which for charts which do not have zoom
                    /// specified.
                    if (ex.getMessage().indexOf("MissingResourceException") == 0) {
                        ex.printStackTrace();
                    }
                }

                this.frame[chartnum].setVisible(true);

            } else {
                this.frame[chartnum].setVisible(true);
                this.frame[chartnum].requestFocus();
            }
        }
    }
}

From source file:fi.smaa.jsmaa.gui.views.CriterionView.java

private JPanel buildValueFunctionChartPanel(ScaleCriterion criterion) {
    UtilityFunctionDataset dataset = new UtilityFunctionDataset(criterion);

    JFreeChart chart = ChartFactory.createXYLineChart("", "x", "v(x)", dataset, PlotOrientation.VERTICAL, false,
            true, true);//www . j ava2 s .  c  om

    final XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(0, renderer);
    renderer.setSeriesPaint(0, Color.black);
    renderer.setSeriesShape(0, ShapeUtilities.createDiamond(3.0f));
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());

    ValueAxis rAxis = plot.getRangeAxis();
    rAxis.setAutoRange(false);
    rAxis.setRange(new Range(-0.03, 1.03));
    ValueAxis dAxis = plot.getDomainAxis();
    dAxis.setLowerMargin(0.03);
    dAxis.setUpperMargin(0.03);

    ChartPanel chartPanel = new ChartPanel(chart, false, true, true, false, true);
    chartPanel.addChartMouseListener(new ValueFunctionMouseListener(chartPanel, criterion, parent));

    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    chartPanel.setDisplayToolTips(true);
    chartPanel.setToolTipText("Click to add/remove partial value function points");
    chartPanel.setMouseWheelEnabled(false);
    chartPanel.setMouseZoomable(false);

    plot.setDomainCrosshairLockedOnData(false);
    plot.setRangeCrosshairLockedOnData(false);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    FormLayout layout = new FormLayout("left:pref", "p, 3dlu, p");

    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();
    builder.add(chartPanel, cc.xy(1, 1));
    builder.add(new ValueFunctionPointsPanel(criterion), cc.xy(1, 3));

    return builder.getPanel();
}

From source file:org.schreibubi.JCombinations.ui.GridChartPanel.java

private void updateDisplay(ArrayList<TreePath> selection) {
    GridChartPanel.logger.info("updateDisplay called");

    removeAll();/*from  w w w.j av a  2s.c om*/
    repaint();
    ArrayList<ExtendedJFreeChart> charts = this.dm.getCharts(selection);
    if ((charts.size() > 0) && (charts.size() < 20)) {
        int n = charts.size();
        double aspectratio = Math.sqrt(2);
        double y = Math.sqrt(n / aspectratio);
        double x = y * aspectratio;
        int xi = (int) Math.ceil(x);
        int yi = (int) Math.ceil(y);
        setLayout(new GridLayout(xi, yi));
        setPreferredSize(new Dimension(yi * GridChartPanel.DEFAULT_WIDTH, xi * GridChartPanel.DEFAULT_HEIGHT));
        revalidate();
        setTransferHandler(new ImageTransferHandler());
        fireSetupProgress(this, 0, charts.size() - 1);
        for (int i = 0; i < charts.size(); i++) {
            JFreeChart chart = charts.get(i);
            ChartPanel chartPanel = new ChartPanel(chart, false);
            chartPanel.setPreferredSize(
                    new Dimension(GridChartPanel.DEFAULT_WIDTH, GridChartPanel.DEFAULT_HEIGHT));
            chartPanel.revalidate();
            chartPanel.setMouseZoomable(true);
            add(chartPanel);
            fireProgressIncremented(this, i);
        }
        fireProgressEnded(this);
    }
}