Example usage for org.jfree.chart ChartPanel setFillZoomRectangle

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

Introduction

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

Prototype

public void setFillZoomRectangle(boolean flag) 

Source Link

Document

A flag that controls how the zoom rectangle is drawn.

Usage

From source file:DashboardInterface.LaunchGraph.java

/**
 * Creates a panel for the demo (used by SuperDemo.java).
 *
 * @return A panel./*from  www.j  av  a2  s. c o m*/
 */
public JPanel createDemoPanel() {
    JFreeChart chart = createChart(null);
    ChartPanel panel = new ChartPanel(chart);
    panel.setFillZoomRectangle(false);
    panel.setMouseWheelEnabled(false);
    panel.setAutoscrolls(false);
    panel.setDomainZoomable(false);
    panel.setFocusable(false);
    return panel;
}

From source file:org.glotaran.core.datadisplayers.common.ImageSVDPanel.java

private void updateSVDPlots() {
    XYSeriesCollection lSVCollection = new XYSeriesCollection();
    XYSeries seria;//from w  ww . j a v a2 s.c  o  m
    for (int j = 0; j < (Integer) jSnumSV.getValue(); j++) {
        seria = new XYSeries("LSV" + j + 1);
        for (int i = 0; i < timeSteps; i++) {
            seria.add(timeAxe[i], svdResult[0].getAsDouble((long) i, j));
        }
        lSVCollection.addSeries(seria);
    }
    leftSVChart.getXYPlot().setDataset(lSVCollection);

    double[] tempRsingVec = null;
    double minVal = 0;
    double maxVal = 0;

    if (jPRightSingVectors.getComponentCount() < (Integer) jSnumSV.getValue()) {
        double tempValue;
        for (int i = jPRightSingVectors.getComponentCount(); i < (Integer) jSnumSV.getValue(); i++) {
            tempRsingVec = new double[imageWitdth * imageHeight];
            for (int j = 0; j < imageWitdth * imageHeight; j++) {
                tempValue = svdResult[2].getAsDouble(j, i);
                tempRsingVec[j] = tempValue;
                minVal = minVal > tempValue ? tempValue : minVal;
                maxVal = maxVal < tempValue ? tempValue : maxVal;
            }
            IntensImageDataset rSingVec = new IntensImageDataset(imageWitdth, imageHeight, tempRsingVec);
            PaintScale ps = new RedGreenPaintScale(minVal, maxVal);
            JFreeChart rSingVect = CommonDataDispTools.createScatChart(
                    ImageUtilities.createColorCodedImage(rSingVec, ps), ps, imageWitdth, imageHeight);
            //            rSingVect.setTitle("R Singular vector " + String.valueOf(j + 1));
            //rSingVect.getTitle().setFont(new Font(tracechart.getTitle().getFont().getFontName(), Font.PLAIN, 12));
            ChartPanel rSingVectPanel = new ChartPanel(rSingVect);
            rSingVectPanel.setFillZoomRectangle(true);
            rSingVectPanel.setMouseWheelEnabled(true);
            jPRightSingVectors.add(rSingVectPanel);
        }

    } else {
        for (int i = jPRightSingVectors.getComponentCount() - 1; i >= (Integer) jSnumSV.getValue(); i--) {
            jPRightSingVectors.remove(i);
            jPRightSingVectors.repaint();
        }
    }
    jPRightSingVectors.validate();
}

From source file:org.glotaran.core.datadisplayers.common.ImageSVDPanel.java

public void createSVDPlots() {

    int maxSpinnerNumberModel = Math.min(MAX_NUMBER_SINGULAR_VALUES, (int) svdResult[1].getRowCount());
    jTFtotalNumSV//from  w w  w. j a va  2s. c  o m
            .setText("Max " + maxSpinnerNumberModel + " of  " + String.valueOf(svdResult[1].getRowCount()));
    jSnumSV.setModel(new SpinnerNumberModel((int) 1, (int) 0, maxSpinnerNumberModel, (int) 1));

    //creare collection with first 2 LSV
    XYSeriesCollection lSVCollection = new XYSeriesCollection();
    XYSeries seria;
    seria = new XYSeries("LSV1");
    for (int i = 0; i < timeSteps; i++) {
        seria.add(timeAxe[i], svdResult[0].getAsDouble((long) i, 0));
    }
    lSVCollection.addSeries(seria);

    //creare chart for 2 LSV
    leftSVChart = ChartFactory.createXYLineChart("Left singular vectors", "Time (~s)", null, lSVCollection,
            PlotOrientation.VERTICAL, false, false, false);
    //leftSVChart.getTitle().setFont(new Font(leftSVChart.getTitle().getFont().getFontName(), Font.PLAIN, 12));
    leftSVChart.setBackgroundPaint(JFreeChart.DEFAULT_BACKGROUND_PAINT);
    GraphPanel chpan = new GraphPanel(leftSVChart);
    jPLeftSingVectors.removeAll();
    jPLeftSingVectors.add(chpan);

    //creare collection with first RSV
    double[] tempRsingVec = null;
    double minVal = 0;
    double maxVal = 0;

    //            seria = new XYSeries("RSV" + (j + 1));
    tempRsingVec = new double[imageWitdth * imageHeight];
    double tempValue;
    for (int i = 0; i < imageWitdth * imageHeight; i++) {
        tempValue = svdResult[2].getAsDouble(i, 0);
        tempRsingVec[i] = tempValue;
        minVal = minVal > tempValue ? tempValue : minVal;
        maxVal = maxVal < tempValue ? tempValue : maxVal;
    }

    IntensImageDataset rSingVec = new IntensImageDataset(imageWitdth, imageHeight, tempRsingVec);
    PaintScale ps = new RedGreenPaintScale(minVal, maxVal);
    JFreeChart rSingVect = CommonDataDispTools
            .createScatChart(ImageUtilities.createColorCodedImage(rSingVec, ps), ps, imageWitdth, imageHeight);
    //            rSingVect.setTitle("R Singular vector " + String.valueOf(j + 1));
    //rSingVect.getTitle().setFont(new Font(tracechart.getTitle().getFont().getFontName(), Font.PLAIN, 12));
    ChartPanel rSingVectPanel = new ChartPanel(rSingVect);
    rSingVectPanel.setFillZoomRectangle(true);
    rSingVectPanel.setMouseWheelEnabled(true);

    jPRightSingVectors.removeAll();
    jPRightSingVectors.add(rSingVectPanel);

    //creare collection with singular values
    XYSeriesCollection sVCollection = new XYSeriesCollection();
    seria = new XYSeries("SV");
    for (int i = 0; i < maxSpinnerNumberModel; i++) {
        seria.add(i + 1, svdResult[1].getAsDouble((long) i, (long) i));
    }
    sVCollection.addSeries(seria);

    //create chart for singular values
    JFreeChart tracechart = ChartFactory.createXYLineChart("Screeplot", "Singular Value index (n)", null,
            sVCollection, PlotOrientation.VERTICAL, false, false, false);
    LogAxis logAxe = new LogAxis("Log(SVn)");
    final NumberAxis domainAxis = (NumberAxis) tracechart.getXYPlot().getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    tracechart.getXYPlot().setRangeAxis(logAxe);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) tracechart.getXYPlot().getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.white);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));

    //tracechart.getTitle().setFont(new Font(tracechart.getTitle().getFont().getFontName(), Font.PLAIN, 12));
    tracechart.setBackgroundPaint(JFreeChart.DEFAULT_BACKGROUND_PAINT);

    chpan = new GraphPanel(tracechart);
    //add chart with 2 RSV to JPannel
    jPSingValues.removeAll();
    jPSingValues.add(chpan);
}

From source file:mekhq.gui.FinancesTab.java

private JPanel createGraphPanel(GraphType gt) {
    JFreeChart chart = null;/*from  www.  j av a  2s .  com*/
    if (gt.equals(GraphType.BALANCE_AMOUNT)) {
        chart = createAmountChart(setupFinanceDataset());
    } else if (gt.equals(GraphType.MONTHLY_FINANCES)) {
        chart = createMonthlyChart(setupMonthlyDataset());
    }
    ChartPanel panel = new ChartPanel(chart, false);
    panel.setFillZoomRectangle(true);
    panel.setMouseWheelEnabled(true);
    return panel;
}

From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.Chromatogram1DHeatmapViewTopComponent.java

private Chromatogram1DHeatmapViewerPanel createPanel(ADataset2D<IChromatogram1D, IScan> ds) {
    XYPlot p = createPlot(ds);/*from ww w . j  a v  a  2 s .  c o m*/
    final PaintScale ps = ((XYBlockRenderer) p.getRenderer()).getPaintScale();
    p.setDomainGridlinesVisible(false);
    p.setRangeGridlinesVisible(false);
    JFreeChart jfc = new JFreeChart(p);
    final ChartPanel cp = new ChartPanel(jfc, true);
    cp.setZoomFillPaint(new Color(192, 192, 192, 96));
    cp.setZoomOutlinePaint(new Color(220, 220, 220, 192));
    cp.setFillZoomRectangle(false);
    cp.getChart().getLegend().setVisible(true);
    Chromatogram1DHeatmapViewerPanel panel = new Chromatogram1DHeatmapViewerPanel(content, getLookup(), ds);
    if (panel.getBackgroundColor() == null) {
        panel.setBackgroundColor((Color) ps.getPaint(ps.getLowerBound()));
    }
    cp.addKeyListener(panel);
    cp.setFocusable(true);
    cp.setDisplayToolTips(true);
    cp.setDismissDelay(3000);
    cp.setInitialDelay(0);
    cp.setReshowDelay(0);
    cp.setVisible(true);
    cp.setRefreshBuffer(true);
    cp.setMouseWheelEnabled(true);
    //FIXME fix peak overlay
    //      if (project != null) {
    //         for (Peak1DContainer peaks : project.getPeaks(chromatogram)) {
    //            Peak1DHeatmapOverlay overlay = new Peak1DHeatmapOverlay(chromatogram, peaks.getName(), peaks.getDisplayName(), peaks.getShortDescription(), true, peaks);
    //            cp.addOverlay(overlay);
    //            content.add(overlay);
    //         }
    //      }
    panel.setChartPanel(cp);
    if (ps != null) {
        panel.setPaintScale(ps);
    }
    panel.setPlot(p);
    return panel;
}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo.java

public XYDatasetDemo(String title) {
    super(title);
    ChartPanel chartPanel = new ChartPanel(timeSeriesChart);
    //have a bug after show tooltips
    //        chartPanel.setHorizontalAxisTrace(true);
    //        chartPanel.setVerticalAxisTrace(true);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPreferredSize(new Dimension(500, 270));
    getContentPane().add(chartPanel);//  ww w  . j av a2  s.c  om
    getContentPane().add(new ChartComboBox(chartPanel), BorderLayout.SOUTH);
}

From source file:oct.analysis.application.OCTSelection.java

public JPanel createLRPPanel() {
    //create the series collection from the LRP data
    XYSeriesCollection lrp = new XYSeriesCollection();
    lrp.addSeries(getLrpSeriesFromOCT(OCTAnalysisManager.getInstance().getOctImage()));
    //        System.out.println("Processing graph " + lrp.getSeriesKey(0).toString());
    lrp.addSeries(findMaximums(lrp.getSeries(0), selectionName + " LRP Maximums"));
    List<XYSeries> fwhm = getFWHMForLRPPeaks(lrp.getSeries(1), lrp.getSeries(0));
    fwhm.forEach((fwhmSeries) -> {/*from  w  ww . j a  v  a 2s.  c  o m*/
        lrp.addSeries(fwhmSeries);
    });
    //create chart panel for LRP
    JFreeChart chart = ChartFactory.createXYLineChart(lrp.getSeriesKey(0).toString(), "Pixel Height",
            "Reflectivity", lrp, PlotOrientation.HORIZONTAL, false, true, false);
    XYPlot plot = chart.getXYPlot();
    //        plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    //        plot.getDomainAxis().setInverted(true);
    //set up rendering principles
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesShapesFilled(1, true);
    renderer.setSeriesPaint(1, Color.BLUE);
    for (int i = 2; i < fwhm.size() + 2; i++) {
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesShapesVisible(i, false);
        renderer.setSeriesPaint(i, Color.BLACK);
    }
    plot.setRenderer(renderer);
    //make panel
    ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new Dimension(200, 200));
    panel.setFillZoomRectangle(true);
    panel.setMouseWheelEnabled(true);
    return panel;
}

From source file:ioheater.ui.IOHeaterUI.java

/**
 *
 * @return//ww  w. ja va2  s . c  o  m
 */
public final ChartPanel chart() {
    this.createDataset();
    JFreeChart chart = createChart(this.dataSet);
    ChartPanel panel = new ChartPanel(chart);
    panel.setFillZoomRectangle(true);
    panel.setMouseWheelEnabled(true);
    return panel;
}

From source file:org.trade.ui.chart.CandlestickChart.java

/**
 * A demonstration application showing a candlestick chart.
 * //from w w w .  j  a v a  2s  . c om
 * @param title
 *            the frame title.
 * @param strategyData
 *            StrategyData
 */
public CandlestickChart(final String title, StrategyData strategyData, Tradingday tradingday) {

    this.strategyData = strategyData;
    this.setLayout(new BorderLayout());
    // Used to mark the current price
    stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 10, 3 }, 0);
    valueMarker = new ValueMarker(0.00, Color.black, stroke);

    this.chart = createChart(this.strategyData, title, tradingday);

    BlockContainer container = new BlockContainer(new BorderArrangement());
    container.add(titleLegend1, RectangleEdge.LEFT);
    container.add(titleLegend2, RectangleEdge.RIGHT);
    container.add(new EmptyBlock(2000, 0));
    CompositeTitle legends = new CompositeTitle(container);
    legends.setPosition(RectangleEdge.BOTTOM);
    this.chart.addSubtitle(legends);

    final ChartPanel chartPanel = new ChartPanel(this.chart);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseZoomable(true, true);
    chartPanel.setRefreshBuffer(true);
    chartPanel.setDoubleBuffered(true);
    chartPanel.setVerticalAxisTrace(true);
    chartPanel.setHorizontalAxisTrace(true);
    chartPanel.addChartMouseListener(new ChartMouseListener() {

        public void chartMouseMoved(ChartMouseEvent e) {
        }

        public void chartMouseClicked(final ChartMouseEvent e) {
            CombinedDomainXYPlot combinedXYplot = (CombinedDomainXYPlot) e.getChart().getPlot();
            @SuppressWarnings("unchecked")
            List<XYPlot> subplots = combinedXYplot.getSubplots();
            if (e.getTrigger().getClickCount() == 2) {
                double xItem = 0;
                double yItem = 0;
                if (e.getEntity() instanceof XYItemEntity) {
                    XYItemEntity xYItemEntity = ((XYItemEntity) e.getEntity());
                    xItem = xYItemEntity.getDataset().getXValue(xYItemEntity.getSeriesIndex(),
                            xYItemEntity.getItem());
                    yItem = xYItemEntity.getDataset().getYValue(xYItemEntity.getSeriesIndex(),
                            xYItemEntity.getItem());
                } else {
                    PlotEntity plotEntity = ((PlotEntity) e.getEntity());
                    XYPlot plot = (XYPlot) plotEntity.getPlot();
                    xItem = plot.getDomainCrosshairValue();
                    yItem = plot.getRangeCrosshairValue();
                }

                for (XYPlot xyplot : subplots) {

                    double x = xyplot.getDomainCrosshairValue();
                    double y = xyplot.getRangeCrosshairValue();

                    /*
                     * If the cross hair is from a right-hand y axis we need
                     * to convert this to a left-hand y axis.
                     */
                    String rightAxisName = ", Price: ";
                    double rangeLowerLeft = 0;
                    double rangeUpperLeft = 0;
                    double rangeLowerRight = 0;
                    double rangeUpperRight = 0;
                    double yRightLocation = 0;
                    for (int index = 0; index < xyplot.getRangeAxisCount(); index++) {
                        AxisLocation axisLocation = xyplot.getRangeAxisLocation(index);
                        Range range = xyplot.getRangeAxis(index).getRange();

                        if (axisLocation.equals(AxisLocation.BOTTOM_OR_LEFT)
                                || axisLocation.equals(AxisLocation.TOP_OR_LEFT)) {
                            rangeLowerLeft = range.getLowerBound();
                            rangeUpperLeft = range.getUpperBound();
                            rightAxisName = ", " + xyplot.getRangeAxis(index).getLabel() + ": ";
                        }
                        if (y >= range.getLowerBound() && y <= range.getUpperBound()
                                && (axisLocation.equals(AxisLocation.BOTTOM_OR_RIGHT)
                                        || axisLocation.equals(AxisLocation.TOP_OR_RIGHT))) {
                            rangeUpperRight = range.getUpperBound();
                            rangeLowerRight = range.getLowerBound();
                        }
                    }
                    if ((rangeUpperRight - rangeLowerRight) > 0) {
                        yRightLocation = rangeLowerLeft + ((rangeUpperLeft - rangeLowerLeft)
                                * ((y - rangeLowerRight) / (rangeUpperRight - rangeLowerRight)));
                    } else {
                        yRightLocation = y;
                    }

                    String text = " Time: " + dateFormatShort.format(new Date((long) (x))) + rightAxisName
                            + new Money(y);
                    if (x == xItem && y == yItem) {
                        titleLegend1.setText(text);
                        if (null == clickCrossHairs) {
                            clickCrossHairs = new XYTextAnnotation(text, x, yRightLocation);
                            clickCrossHairs.setTextAnchor(TextAnchor.BOTTOM_LEFT);
                            xyplot.addAnnotation(clickCrossHairs);
                        } else {
                            clickCrossHairs.setText(text);
                            clickCrossHairs.setX(x);
                            clickCrossHairs.setY(yRightLocation);
                        }
                    }
                }
            } else if (e.getTrigger().getClickCount() == 1 && null != clickCrossHairs) {
                for (XYPlot xyplot : subplots) {
                    if (xyplot.removeAnnotation(clickCrossHairs)) {
                        clickCrossHairs = null;
                        titleLegend1.setText(" Time: 0, Price :0.0");
                        break;
                    }
                }
            }
        }
    });
    this.add(chartPanel, null);
    this.strategyData.getCandleDataset().getSeries(0).addChangeListener(this);
}

From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo.java

public CategoryDatasetDemo(String title) {
    super(title);
    ChartPanel chartPanel = new ChartPanel(barChart);
    //have a bug after show tooltips
    //        chartPanel.setHorizontalAxisTrace(true);
    //        chartPanel.setVerticalAxisTrace(true);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPreferredSize(new Dimension(500, 270));
    getContentPane().add(chartPanel);//  w  ww .  ja  va 2  s.com
    getContentPane().add(new ChartComboBox(chartPanel), BorderLayout.SOUTH);
}