Example usage for org.jfree.chart.plot CategoryPlot setRangePannable

List of usage examples for org.jfree.chart.plot CategoryPlot setRangePannable

Introduction

In this page you can find the example usage for org.jfree.chart.plot CategoryPlot setRangePannable.

Prototype

public void setRangePannable(boolean pannable) 

Source Link

Document

Sets the flag that enables or disables panning of the plot along the range axes.

Usage

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

public static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Min/Max Category Plot", "Category", "Value",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setRangePannable(true);
    MinMaxCategoryRenderer minmaxcategoryrenderer = new MinMaxCategoryRenderer();
    minmaxcategoryrenderer.setDrawLines(false);
    categoryplot.setRenderer(minmaxcategoryrenderer);
    ChartUtilities.applyCurrentTheme(jfreechart);
    return jfreechart;
}

From source file:sas.BarChart.java

public static JFreeChart createChart(CategoryDataset categorydataset, String name, String type, String t) {
    JFreeChart jfreechart = ChartFactory.createLineChart(name, null, type, categorydataset,
            PlotOrientation.VERTICAL, false, true, false);
    jfreechart.addSubtitle(new TextTitle(t));
    TextTitle texttitle = new TextTitle("");
    texttitle.setFont(new Font("SansSerif", 0, 10));
    texttitle.setPosition(RectangleEdge.BOTTOM);
    texttitle.setHorizontalAlignment(HorizontalAlignment.CENTER);
    jfreechart.addSubtitle(texttitle);/*from w  w  w . j av  a2s  .  co m*/
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setRangePannable(true);
    categoryplot.setRangeGridlinesVisible(false);
    java.net.URL url = (BarChart.class).getClassLoader().getResource("line_Chart_example.png");
    if (url != null) {
        ImageIcon imageicon = new ImageIcon(url);
        jfreechart.setBackgroundImage(imageicon.getImage());
        categoryplot.setBackgroundPaint(null);
    }
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    ChartUtilities.applyCurrentTheme(jfreechart);
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setBaseShapesVisible(true);
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    lineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F));
    lineandshaperenderer.setSeriesOutlineStroke(0, new BasicStroke(2.0F));
    lineandshaperenderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D));
    return jfreechart;
}

From source file:eu.delving.sip.base.ReportChartHelper.java

private static JPanel finishBarChart(JFreeChart chart, Color... colors) {
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangePannable(true);
    if (colors.length > 0)
        plot.setRenderer(new CustomRenderer(colors));
    BarRenderer bar = (BarRenderer) plot.getRenderer();
    bar.setItemLabelAnchorOffset(9D);/*www  .  j  a v  a 2 s.  c  om*/
    bar.setBaseItemLabelsVisible(true);
    bar.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    bar.setMaximumBarWidth(0.05);
    bar.setItemMargin(0.03D);
    bar.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(INSIDE12, CENTER_RIGHT, CENTER_RIGHT, -1.5707963267948966D));
    bar.setPositiveItemLabelPositionFallback(
            new ItemLabelPosition(OUTSIDE12, CENTER_LEFT, CENTER_LEFT, -1.5707963267948966D));
    CategoryAxis x = plot.getDomainAxis();
    x.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    x.setCategoryMargin(0.25D);
    x.setUpperMargin(0.02D);
    x.setLowerMargin(0.02D);
    NumberAxis y = (NumberAxis) plot.getRangeAxis();
    y.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    y.setUpperMargin(0.10000000000000001D);
    ChartUtilities.applyCurrentTheme(chart);
    return new ChartPanel(chart);
}

From source file:wsattacker.plugin.intelligentdos.ui.helper.ChartHelper.java

public static JFreeChart createWhiskerChart(SuccessfulAttack sa) {
    BoxAndWhiskerCategoryDataset boxandwhiskercategorydataset = createDataset(sa);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setMaximumBarWidth(0.05);/*from  ww w.j  a v  a2  s.co  m*/
    renderer.setMeanVisible(false);
    renderer.setSeriesPaint(0, Color.GREEN);
    renderer.setSeriesPaint(1, Color.RED);
    renderer.setSeriesPaint(2, Color.BLUE);

    NumberAxis numberAxis = new NumberAxis("duration in ms");
    CategoryPlot categoryplot = new CategoryPlot(boxandwhiskercategorydataset, new CategoryAxis(""), numberAxis,
            renderer);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangePannable(true);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    JFreeChart jFreeChart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 14), categoryplot, true);
    jFreeChart.removeLegend();
    return jFreeChart;
}

From source file:eu.delving.stats.ChartHelper.java

private static JFreeChart finishBarChart(JFreeChart chart, Color... colors) {
    CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    categoryplot.setRangePannable(true);
    if (colors.length > 0)
        categoryplot.setRenderer(new CustomRenderer(colors));
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setItemLabelAnchorOffset(9D);
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    barrenderer.setMaximumBarWidth(0.05);
    barrenderer.setItemMargin(0.03D);//from  w w w  .  j  ava2s  .c  o m
    ItemLabelPosition itemlabelposition = new ItemLabelPosition(INSIDE12, CENTER_RIGHT, CENTER_RIGHT,
            -1.5707963267948966D);
    barrenderer.setBasePositiveItemLabelPosition(itemlabelposition);
    ItemLabelPosition itemlabelposition1 = new ItemLabelPosition(OUTSIDE12, CENTER_LEFT, CENTER_LEFT,
            -1.5707963267948966D);
    barrenderer.setPositiveItemLabelPositionFallback(itemlabelposition1);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    categoryaxis.setCategoryMargin(0.25D);
    categoryaxis.setUpperMargin(0.02D);
    categoryaxis.setLowerMargin(0.02D);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setUpperMargin(0.10000000000000001D);
    ChartUtilities.applyCurrentTheme(chart);
    return chart;
}

From source file:net.nosleep.superanalyzer.analysis.views.TimeView.java

private void createChart() {
    // create the chart...
    _chart = ChartFactory.createLineChart(Misc.getString("LISTENING_TIMES"), // chart
            // title
            Misc.getString("HOUR_OF_DAY"), // domain axis label
            Misc.getString("SONG_COUNT"), // range axis label
            _dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );/*from  www.  j a v  a 2  s .c  om*/

    CategoryPlot plot = (CategoryPlot) _chart.getPlot();
    plot.setRangePannable(true);
    plot.setRangeZeroBaselineVisible(false);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);

    _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("LISTENING_TIMES_TOOLTIP")));

    ChartUtilities.applyCurrentTheme(_chart);

    // format the renderer after applying the theme
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.white);
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));

    // get rid of the little line above/next to the axis
    // plot.setRangeZeroBaselinePaint(Color.white);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);

    Misc.formatChart(plot);
    renderer.setSeriesPaint(0, Theme.getColorSet()[1]);

}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createBarChart(String xAxisLabel, String yAxisLabel, CategoryDataset dataset) {
    if (dataset == null) {
        throw new IllegalArgumentException("No dataset.");
    }//from   ww w . j  a va 2 s.  c o  m

    JFreeChart jfreechart = ChartFactory.createBarChart(null, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    categoryplot.setBackgroundPaint(null);
    categoryplot.setOutlinePaint(null);
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    categoryplot.setRangePannable(true);
    categoryplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY);
    categoryplot.getRangeAxis().setLabelFont(UIConstants.H5_FONT);
    categoryplot.getDomainAxis().setLabelFont(UIConstants.H5_FONT);

    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setBarPainter(new StandardBarPainter());
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setShadowVisible(false);
    barrenderer.setSeriesPaint(0, UIConstants.INTEL_BLUE);

    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryMargin(0.02D);
    categoryaxis.setUpperMargin(0.01D);
    categoryaxis.setLowerMargin(0.01D);
    // categoryaxis.setAxisLineVisible(false);
    categoryaxis.setMaximumCategoryLabelWidthRatio(0.95F);

    NumberAxis axis = (NumberAxis) categoryplot.getRangeAxis();
    axis.setRangeType(RangeType.POSITIVE);

    return jfreechart;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createTopNBarChart(String yAxisLabel, CategoryDataset dataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart(null, null, yAxisLabel, dataset,
            PlotOrientation.HORIZONTAL, true, true, false);
    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    categoryplot.setBackgroundPaint(null);
    categoryplot.setOutlinePaint(null);/*from   w w  w. j  a  v  a2  s  . c  o  m*/
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    categoryplot.setRangePannable(true);
    categoryplot.setRangeGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY);

    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setBarPainter(new StandardBarPainter());
    barrenderer.setShadowVisible(false);
    barrenderer.setItemMargin(0.015);
    barrenderer.setSeriesPaint(0, UIConstants.INTEL_BLUE);
    barrenderer.setSeriesPaint(1, UIConstants.INTEL_LIGHT_BLUE);

    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryMargin(0.15D);
    categoryaxis.setUpperMargin(0.02D);
    categoryaxis.setLowerMargin(0.02D);
    categoryaxis.setMaximumCategoryLabelWidthRatio(0.5F);

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setRangeType(RangeType.POSITIVE);
    numberaxis.setStandardTickUnits(createLargeNumberTickUnits());
    numberaxis.setUpperMargin(0.20000000000000001D);
    numberaxis.setLabelFont(UIConstants.H5_FONT);
    numberaxis.setLabelInsets(new RectangleInsets(0, 0, 0, 0));
    numberaxis.setTickMarksVisible(true);
    numberaxis.setTickLabelsVisible(true);

    LegendTitle legend = jfreechart.getLegend();
    legend.setFrame(BlockBorder.NONE);
    legend.setItemFont(barrenderer.getBaseItemLabelFont().deriveFont(10.0f));

    return jfreechart;
}

From source file:userInterface.SystemAdmin.PovertyAnalysisJPanel.java

private JFreeChart createChart(DefaultCategoryDataset crimeDataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Poverty Rate vs Crime Chart", "Network Values",
            "Value", crimeDataset, PlotOrientation.HORIZONTAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();

    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangePannable(true);
    categoryplot.setRangeZeroBaselineVisible(true);
    categoryplot.configureRangeAxes();//from www. j av a 2s . c  o  m

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LayeredBarRenderer layeredbarrenderer = new LayeredBarRenderer();
    layeredbarrenderer.setDrawBarOutline(false);
    categoryplot.setRenderer(layeredbarrenderer);

    return jfreechart;
}

From source file:org.locationtech.udig.processingtoolbox.tools.BoxPlotDialog.java

private void createGraphTab(final CTabFolder parentTabFolder) {
    plotTab = new CTabItem(parentTabFolder, SWT.NONE);
    plotTab.setText(Messages.ScatterPlotDialog_Graph);

    CategoryPlot plot = new CategoryPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(java.awt.Color.WHITE);
    plot.setRangePannable(false);

    JFreeChart chart = new JFreeChart(EMPTY, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(java.awt.Color.WHITE);
    chart.setBorderVisible(false);/*from  w  w  w .j ava2  s. c o m*/

    chartComposite = new ChartComposite(parentTabFolder, SWT.NONE | SWT.EMBEDDED, chart, true);
    chartComposite.setLayout(new FillLayout());
    chartComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    chartComposite.setDomainZoomable(false);
    chartComposite.setRangeZoomable(false);
    // chartComposite.setMap(map);
    chartComposite.addChartMouseListener(new PlotMouseListener());

    plotTab.setControl(chartComposite);

    chartComposite.pack();
}