Example usage for org.jfree.chart ChartPanel setMinimumDrawWidth

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

Introduction

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

Prototype

public void setMinimumDrawWidth(int width) 

Source Link

Document

Sets the minimum drawing width for the chart on this panel.

Usage

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

public static JPanel createDemoPanel() {
    JFreeChart jfreechart = createChart("Axis Offsets: 0", createDataset());
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setAxisOffset(RectangleInsets.ZERO_INSETS);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setMinimumDrawWidth(0);
    chartpanel.setMinimumDrawHeight(0);//from   w  ww .  ja v a2s  . c o m
    JFreeChart jfreechart1 = createChart("Axis Offsets: 5", createDataset());
    ChartPanel chartpanel1 = new ChartPanel(jfreechart1);
    chartpanel1.setMinimumDrawWidth(0);
    chartpanel1.setMinimumDrawHeight(0);
    CategoryPlot categoryplot1 = (CategoryPlot) jfreechart1.getPlot();
    categoryplot1.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    DemoPanel demopanel = new DemoPanel(new GridLayout(2, 1));
    demopanel.add(chartpanel);
    demopanel.add(chartpanel1);
    demopanel.addChart(jfreechart);
    demopanel.addChart(jfreechart1);
    return demopanel;
}

From source file:com.haskins.cloudtrailviewer.utils.ChartFactory.java

/**
 * Returns a Bar chart//from   ww w .  j  a v a 2 s.co  m
 * @param events events to include on chart
 * @return 
 */
private static ChartPanel createBarChart(String type, List<Entry<String, Integer>> events, int width,
        int height, PlotOrientation orientation) {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (Entry<String, Integer> event : events) {
        dataset.addValue(event.getValue().intValue(), event.getKey(), "");
    }

    JFreeChart jFChart;
    if (type.contains("3d")) {
        jFChart = org.jfree.chart.ChartFactory.createBarChart3D("", "", "", dataset, orientation, false, true,
                false);
    } else {
        jFChart = org.jfree.chart.ChartFactory.createBarChart("", "", "", dataset, orientation, false, true,
                false);
    }

    final ChartPanel jChartPanel = new ChartPanel(jFChart, width, height, width, height, width, height, false,
            false, true, true, false, true);
    jChartPanel.setMinimumDrawWidth(0);
    jChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    jChartPanel.setMinimumDrawHeight(0);
    jChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);

    return jChartPanel;
}

From source file:com.haskins.cloudtrailviewer.utils.ChartFactory.java

private static ChartPanel createPieChart(String type, List<Entry<String, Integer>> events, int width,
        int height) {

    DefaultPieDataset dataset = new DefaultPieDataset();

    for (Map.Entry<String, Integer> event : events) {
        dataset.setValue(event.getKey(), event.getValue());
    }/*from  ww  w  .  ja  v a  2s .  c o m*/

    JFreeChart jFChart;
    if (type.contains("3d")) {
        jFChart = org.jfree.chart.ChartFactory.createPieChart3D("", dataset, false, true, false);
    } else {
        jFChart = org.jfree.chart.ChartFactory.createPieChart("", dataset, false, true, false);
    }

    PiePlot plot = (PiePlot) jFChart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.01);
    plot.setOutlineVisible(false);
    plot.setLabelGenerator(null);

    // use gradients and white borders for the section colours
    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    TextTitle t = jFChart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setFont(new Font("Arial", Font.BOLD, 16));

    final ChartPanel jChartPanel = new ChartPanel(jFChart, width, height, width, height, width, height, false,
            false, true, true, false, true);
    jChartPanel.setMinimumDrawWidth(0);
    jChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    jChartPanel.setMinimumDrawHeight(0);
    jChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);

    return jChartPanel;
}

From source file:ec.util.chart.swing.Charts.java

@Nonnull
public static ChartPanel avoidScaling(@Nonnull ChartPanel chartPanel) {
    chartPanel.setMinimumDrawWidth(1);
    chartPanel.setMinimumDrawHeight(1);// w  w w  .  j av a2s .  c om
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    return chartPanel;
}

From source file:net.sf.mzmine.chartbasics.ChartLogics.java

/**
 * Removes draw size restrictions/*from w  ww  .  j av  a 2  s.  com*/
 * 
 * @param myChart
 */
public static void makeChartResizable(ChartPanel myChart) {
    myChart.setMaximumDrawWidth(1000000000);
    myChart.setMinimumDrawWidth(0);
    myChart.setMaximumDrawHeight(1000000000);
    myChart.setMinimumDrawHeight(0);
}

From source file:com.jbombardier.console.charts.StackedBarChart.java

public JPanel createChart(String title) {
    JFreeChart jfreechart = ChartFactory.createStackedBarChart(title, "Category", "Value", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    categoryplot = (CategoryPlot) jfreechart.getPlot();
    StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer();
    stackedbarrenderer.setDrawBarOutline(false);
    stackedbarrenderer.setBaseItemLabelsVisible(true);
    stackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());

    ChartPanel moo = new ChartPanel(jfreechart);
    moo.setMinimumDrawHeight(0);/*from www  .j  a  v a2s  . c  om*/
    moo.setMinimumDrawWidth(0);
    moo.setMaximumDrawHeight(Integer.MAX_VALUE);
    moo.setMaximumDrawWidth(Integer.MAX_VALUE);
    return moo;
}

From source file:org.nbrcp.demo.core.views.Barchart.java

private void setUpView() {
    final JFreeChart chart = ChartFactory.createXYBarChart("", "X", false, "Y", Data.getDataset(),
            PlotOrientation.HORIZONTAL, true, true, false);

    XYPlot plot = chart.getXYPlot();/*w  w  w. j  a va 2  s.  com*/
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setShadowVisible(false);
    renderer.setMargin(0.96);

    final ChartPanel panel = new ChartPanel(chart);
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(10);
    panel.setMaximumDrawWidth(2000);
    panel.setSize(this.getSize());
    this.add(panel);
}

From source file:org.nbrcp.demo.core.views.Scatterplot.java

private void setUpView() {
    JFreeChart chart = ChartFactory.createScatterPlot("", "X", "Y", Data.getDataset());
    XYPlot plot = (XYPlot) chart.getPlot();
    Shape dotShape = new Ellipse2D.Double(0, 0, 5, 5);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesShape(0, dotShape);

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setMinimumDrawHeight(10);/*www. jav a  2 s.co  m*/
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(10);
    panel.setMaximumDrawWidth(2000);
    panel.setSize(this.getSize());
    this.add(panel);
}

From source file:jmemorize.gui.swing.panels.SessionChartPanel.java

private JPanel createChartPanel(String title, SessionSummary summary) {
    ChartPanel chartPanel = new ChartPanel(createChart(title, summary));

    chartPanel.setMinimumDrawHeight(100);
    chartPanel.setMinimumDrawWidth(200);

    chartPanel.setMaximumDrawHeight(1600);
    chartPanel.setMaximumDrawWidth(1200);

    return chartPanel;
}

From source file:com.idealista.solrmeter.view.statistic.HistogramChartPanel.java

private Component createChartPanel() {
    XYBarDataset xyBarDataset = new XYBarDataset(xyDataset, BAR_WIDTH);
    NumberAxis xaxis = new NumberAxis(I18n.get("statistic.histogramChartPanel.time"));
    NumberAxis yaxis = new NumberAxis(I18n.get("statistic.histogramChartPanel.numberOfQueries"));

    xaxis.setStandardTickUnits(//from   w ww .j ava  2  s .c  o  m
            new ChartUtils.LowerBoundedTickUnitSource(xaxis.getStandardTickUnits(), LOWER_TICK_UNIT));

    XYPlot plot = new XYPlot(xyBarDataset, xaxis, yaxis, new XYBarRenderer());

    JFreeChart chart = new JFreeChart(I18n.get("statistic.histogramChartPanel.title"), null, plot, false);

    ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setBorder(CHART_BORDER);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);

    return chartPanel;
}