Java Code Examples for org.jfree.chart.ChartPanel#setDomainZoomable()

The following examples show how to use org.jfree.chart.ChartPanel#setDomainZoomable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultipleAxisChart.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void finish(java.awt.Dimension preferredSize) {
  ChartUtilities.applyCurrentTheme(chart);

  XYPlot plot = (XYPlot) chart.getPlot();
  for (int i = 0; i < axisNum; i++) {
    XYItemRenderer renderer = plot.getRenderer(i);
    if (renderer == null)
      continue;

    renderer.setSeriesPaint(0, colors[i]);

    ValueAxis axis = plot.getRangeAxis(i);
    axis.setLabelPaint(colors[i]);
    axis.setTickLabelPaint(colors[i]);
  }

  ChartPanel chartPanel = new ChartPanel(chart);
  chartPanel.setPreferredSize(preferredSize);
  chartPanel.setDomainZoomable(true);
  chartPanel.setRangeZoomable(true);
}
 
Example 2
Source File: ChartViewerUtil.java    From cst with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static synchronized ChartPanel createChart(DefaultCategoryDataset dataset, String title, String categoryAxisLabel, String valueAxisLabel, PlotOrientation chartType) {

        final JFreeChart chart = ChartFactory.createBarChart(
                title,
                categoryAxisLabel,
                valueAxisLabel,
                dataset,
                chartType,
                true,
                true,
                false
        );

        final CategoryPlot plot = chart.getCategoryPlot();
        plot.setBackgroundPaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
        chart.setBackgroundPaint(Color.lightGray);

        ChartPanel localChartPanel = new ChartPanel(chart);
        localChartPanel.setVisible(true);
        localChartPanel.setDomainZoomable(true);

        return localChartPanel;
    }
 
Example 3
Source File: ChartViewerUtil.java    From cst with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static synchronized ChartPanel createLineXYChart(XYSeriesCollection dataset, String title, String categoryAxisLabel, String valueAxisLabel, long timeRefresh) {

        final JFreeChart chart = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false);

        final XYPlot plot = chart.getXYPlot();
        plot.setBackgroundPaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
        plot.getDomainAxis().setFixedAutoRange(timeRefresh * 100);
        chart.setBackgroundPaint(Color.lightGray);

        ChartPanel localChartPanel = new ChartPanel(chart);
        localChartPanel.setVisible(true);
        localChartPanel.setDomainZoomable(true);

        return localChartPanel;
    }
 
Example 4
Source File: IndustriesPanel.java    From computational-economy with GNU General Public License v3.0 5 votes vote down vote up
protected ChartPanel createPriceTimeSeriesChartPanel(final Currency currency, final GoodType goodType) {
	final JFreeChart priceChart = ChartFactory.createCandlestickChart(goodType + " Prices", "Time",
			"Price in " + currency.getIso4217Code(), getDefaultHighLowDataset(currency, goodType), false);
	final ChartPanel chartPanel = new ChartPanel(priceChart);
	chartPanel.setDomainZoomable(true);
	chartPanel.setPreferredSize(new java.awt.Dimension(800, 400));
	return chartPanel;
}
 
Example 5
Source File: HouseholdsPanel.java    From computational-economy with GNU General Public License v3.0 5 votes vote down vote up
protected ChartPanel createPriceTimeSeriesChartPanel(final Currency currency) {
	final JFreeChart priceChart = ChartFactory.createCandlestickChart(GoodType.LABOURHOUR + " Prices", "Time",
			"Price in " + currency.getIso4217Code(), getDefaultHighLowDataset(currency), false);
	final ChartPanel chartPanel = new ChartPanel(priceChart);
	chartPanel.setDomainZoomable(true);
	chartPanel.setPreferredSize(new java.awt.Dimension(800, 400));
	return chartPanel;
}
 
Example 6
Source File: BanksPanel.java    From computational-economy with GNU General Public License v3.0 5 votes vote down vote up
protected ChartPanel createPriceTimeSeriesChartPanel(final Currency currency, final Currency commodityCurrency) {
	final JFreeChart priceChart = ChartFactory.createCandlestickChart(
			commodityCurrency.getIso4217Code() + " Prices", "Time", "Price in " + currency.getIso4217Code(),
			getDefaultHighLowDataset(currency, commodityCurrency), false);
	final ChartPanel chartPanel = new ChartPanel(priceChart);
	chartPanel.setDomainZoomable(true);
	chartPanel.setPreferredSize(new java.awt.Dimension(800, 400));
	return chartPanel;
}
 
Example 7
Source File: SchedulePlanningPanel.java    From opencards with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SchedulePlanningPanel() {
        setLayout(new BorderLayout());

        // setup the stacked bar chart
        dataset = new DefaultCategoryDataset();
        final JFreeChart chart = ChartFactory.createStackedBarChart(
                null,  // chart title
                Utils.getRB().getString("CardTableModel.stats.weekSchedule"),                  // domain axis label
//                "# cards",                     // range axis label
                null,                     // range axis label
                dataset,                     // data
                PlotOrientation.VERTICAL,    // the plot orientation
                false,                        // legend
                true,                        // tooltips
                false                        // urls
        );

        StackedBarRenderer renderer = new StackedBarRenderer();
        renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));

        //green
        renderer.setItemMargin(0.0);
        Paint greenPaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88));
        renderer.setSeriesPaint(1, greenPaint);
        renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator());


        //blue
        Paint bluePaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF));
        renderer.setSeriesPaint(0, bluePaint);
        renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());


//        Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88));
//        renderer.setSeriesPaint(1, p2);
//        renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator());
//
//        Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88));
//        renderer.setSeriesPaint(2, p3);
//        renderer.setSeriesToolTipGenerator(2, new StandardCategoryToolTipGenerator());

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setRenderer(renderer);
        valueAxis = plot.getRangeAxis();
        TickUnits units = (TickUnits) NumberAxis.createIntegerTickUnits();
        valueAxis.setStandardTickUnits(units);

        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPopupMenu(null);
        chartPanel.setDomainZoomable(false);
        chartPanel.setRangeZoomable(false);

        add(chartPanel, BorderLayout.CENTER);

        rebuildPanel(new HashSet<CardFile>());
    }
 
Example 8
Source File: LTMStateGraphPanel.java    From opencards with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public LTMStateGraphPanel() {
        setLayout(new BorderLayout());

        // setup the stacked bar chart
        dataset = new DefaultCategoryDataset();
        final JFreeChart chart = ChartFactory.createStackedBarChart(
                null,  // chart title
                Utils.getRB().getString("CardTableModel.stats.learnsuccess"),                  // domain axis label
//                "# cards",                     // range axis label
                null,                     // range axis label
                dataset,                     // data
                PlotOrientation.VERTICAL,    // the plot orientation
                false,                        // legend
                true,                        // tooltips
                false                        // urls
        );

        StackedBarRenderer renderer = new StackedBarRenderer();
        renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));

        renderer.setItemMargin(0.0);
        Paint bluePaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF));
        renderer.setSeriesPaint(0, bluePaint);
        renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());

//        Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88));
//        renderer.setSeriesPaint(1, p2);
//        renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator());
//
//        Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88));
//        renderer.setSeriesPaint(2, p3);
//        renderer.setSeriesToolTipGenerator(2, new StandardCategoryToolTipGenerator());

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setRenderer(renderer);
        valueAxis = plot.getRangeAxis();
        TickUnits units = (TickUnits) NumberAxis.createIntegerTickUnits();
        valueAxis.setStandardTickUnits(units);

        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPopupMenu(null);
        chartPanel.setDomainZoomable(false);
        chartPanel.setRangeZoomable(false);
        add(chartPanel, BorderLayout.CENTER);

        rebuildPanel(new HashSet<CardFile>());

        learnedPerfectly = Utils.getRB().getString("CardTableModel.stats.perfect");
        learnedNotYet = Utils.getRB().getString("CardTableModel.stats.notatall");
        learnedNaJa = Utils.getRB().getString("CardTableModel.stats.well");
    }