Example usage for org.jfree.chart JFreeChart setPadding

List of usage examples for org.jfree.chart JFreeChart setPadding

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart setPadding.

Prototype

public void setPadding(RectangleInsets padding) 

Source Link

Document

Sets the padding between the chart border and the chart drawing area, and sends a ChartChangeEvent to all registered listeners.

Usage

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

private static JFreeChart createTsChart() {
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot();

    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickLabelInsets(new RectangleInsets(2, 5, 2, 5));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setLowerMargin(0.02);// w w w .  java2s . c om
    domainAxis.setUpperMargin(0.02);
    plot.setDomainAxis(domainAxis);

    JFreeChart result = new JFreeChart("", null, plot, true);
    result.setPadding(CHART_PADDING);
    result.getLegend().setFrame(BlockBorder.NONE);
    result.getLegend().setBackgroundPaint(null);

    return result;
}

From source file:uom.research.thalassemia.util.PieChartCreator.java

/**
 * Creates a panel for the demo (used by SuperDemo.java).
 *
 * @param pPieDataset dataset/*from  w  w w .  java 2 s .co  m*/
 * @param pTitle title
 * @return A panel.
 */
public JPanel createPanel(final PieDataset pPieDataset, final String pTitle) {
    title = pTitle;
    pieDataset = pPieDataset;

    // set a theme using the new shadow generator feature available in
    // 1.0.14 - for backwards compatibility it is not enabled by default
    ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow", true));
    JFreeChart chart = createChart(pieDataset);
    chart.setPadding(new RectangleInsets(4, 8, 2, 2));
    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);
    panel.setPreferredSize(new Dimension(600, 300));
    return panel;
}

From source file:ec.nbdemetra.chainlinking.outlineview.ChainLinkingChart.java

private JFreeChart createChart() {
    XYPlot plot = new XYPlot();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setAutoPopulateSeriesStroke(false);
    renderer.setBaseStroke(TsCharts.getStrongStroke(ITsChart.LinesThickness.Thin));
    plot.setRenderer(renderer);//from  w w w. j  a v  a2 s .  com

    JFreeChart r = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, true);
    r.setPadding(TsCharts.CHART_PADDING);
    r.setTitle("Chain Linking");

    return r;
}

From source file:ec.nbdemetra.sa.revisionanalysis.RevisionAnalysisChart.java

private JFreeChart createChart() {
    XYPlot plot = new XYPlot();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setAutoPopulateSeriesStroke(false);
    renderer.setBaseStroke(TsCharts.getStrongStroke(ITsChart.LinesThickness.Thin));
    plot.setRenderer(renderer);/* w  ww.jav a  2 s .  c  o  m*/

    JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, true);
    result.setPadding(TsCharts.CHART_PADDING);
    result.setTitle("Standard deviations");

    return result;
}

From source file:by.bsu.zmiecer.PieChartDemo1.java

/**
 * Creates a panel for the demo (used by SuperDemo.java).
 *
 * @return A panel./* ww w  .jav a  2  s .  c  o  m*/
 */
public JPanel createDemoPanel() {
    JFreeChart chart = createChart(createDataset());
    chart.setPadding(new RectangleInsets(4, 8, 2, 2));
    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);
    panel.setPreferredSize(new Dimension(600, 300));
    return panel;
}

From source file:org.deegree.igeo.style.model.Histogram.java

public void update(String title, List<ValueRange<?>> values) {
    if (values != null) {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (ValueRange<?> value : values) {
            value.getCount();/* ww  w.  j a va  2  s.  co m*/
            value.getLabel();
            dataset.addValue(value.getCount(), "1", value.getLabel());
        }

        JFreeChart chart = ChartFactory.createBarChart(null, get("$MD11052"), get("$MD11053"), dataset,
                PlotOrientation.VERTICAL, false, true, false);

        chart.setPadding(new RectangleInsets(10, 10, 10, 10));

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        CategoryAxis cAxis = plot.getDomainAxis();
        cAxis.setCategoryMargin(0);
        cAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(1));

        if (cf == null) {
            cf = new ChartPanel(chart);
            this.add(cf);
            cf.setVisible(true);
        } else {
            cf.setChart(chart);
        }
        this.setTitle(title);
        this.setVisible(true);
        this.pack();
    }
}

From source file:org.gephi.desktop.context.ContextPieChart.java

public ContextPieChart() {
    data = new DefaultPieDataset();
    final JFreeChart chart = ChartFactory.createPieChart("Employee Survey", data, false, false, false);
    chart.setTitle(new TextTitle());
    chart.setBackgroundPaint(null);//from  w  w  w.  ja  v  a  2s.  c om
    chart.setPadding(new RectangleInsets(0, 0, 0, 0));
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setShadowPaint(null);
    plot.setSimpleLabels(true);
    plot.setLabelBackgroundPaint(null);
    plot.setLabelOutlineStroke(null);
    plot.setLabelShadowPaint(null);
    plot.setOutlineVisible(false);
    plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10));
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelGap(0.5);
    plot.setCircular(true);
    plot.setInteriorGap(0);
    plot.setBackgroundPaint(null);
    plot.setBackgroundAlpha(1f);
    plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.visible"), new Color(0x222222));
    plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.notVisible"), new Color(0xDDDDDD));
    chartPanel = new ChartPanel(chart, 100, 100, 10, 10, 300, 300, true, false, false, false, false, false);
    ((FlowLayout) chartPanel.getLayout()).setHgap(0);
    ((FlowLayout) chartPanel.getLayout()).setVgap(0);
    chartPanel.setOpaque(false);
    chartPanel.setPopupMenu(null);
}

From source file:org.webcat.grader.graphs.BoxAndWhiskerChart.java

@Override
protected JFreeChart generateChart(WCChartTheme chartTheme) {
    setChartHeight(36);//from w  w w  .ja  va2 s.  c o m

    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, null, yAxisLabel(), boxAndWhiskerXYDataset(),
            false);
    chart.getXYPlot().setOrientation(PlotOrientation.HORIZONTAL);
    chart.setPadding(new RectangleInsets(0, 6, 0, 6));

    XYPlot plot = chart.getXYPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setOutlineVisible(false);
    plot.setBackgroundPaint(new Color(0, 0, 0, 0));
    XYBoxAndWhiskerRenderer renderer = (XYBoxAndWhiskerRenderer) plot.getRenderer();
    renderer.setAutoPopulateSeriesOutlinePaint(true);

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setRange(-0.5, assignmentOffering.assignment().submissionProfile().availablePoints() + 0.5);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    Font oldFont = rangeAxis.getTickLabelFont();
    rangeAxis.setTickLabelFont(oldFont.deriveFont(oldFont.getSize2D() * 0.8f));

    return chart;
}

From source file:net.praqma.jenkins.memorymap.MemoryMapBuildAction.java

protected JFreeChart createPairedBarCharts(String title, String yaxis, double max, double min,
        CategoryDataset dataset, List<ValueMarker> markers) {
    final CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    final NumberAxis rangeAxis = new NumberAxis(yaxis);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperBound(max);/*from  ww  w.  j ava 2  s  .c  o  m*/
    rangeAxis.setLowerBound(min);
    /*TODO : wrong scale choosen - Jes
     * if the user selects Mega or Giga as the scale, but there only are 
     * a couple of Kilo in the graph it would have no ticks on the axis.
     * this can be solved by. redefining the ticks,
     * We have not done this because it's a bit tricky to figure out the rigth 
     * factor to devid with
     * 
     * but the method wuld be 
     * double factor = 10
     * rangeAxis.setStandardTickUnits(new StandardTickUnitSource(max / factor));
     */

    //StackedAreaRenderer2 renderer = new StackedAreaRenderer2();
    BarRenderer renderer = new BarRenderer();

    CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);

    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    for (ValueMarker mkr : markers) {
        plot.addRangeMarker(mkr);
    }

    JFreeChart chart = new JFreeChart(plot);
    chart.setPadding(new RectangleInsets(30, 15, 15, 15));
    chart.setTitle(title);
    return chart;
}

From source file:ecosim.gui.SummaryPane.java

/**
 *  Private method to build the binning chart.
 *
 *  @return A ChartPanel containing the binning chart.
 *///ww w .java2s .  c  o m
private ChartPanel makeBinningChart() {
    final DefaultXYDataset binData = new DefaultXYDataset();
    final NumberFormat nf = NumberFormat.getInstance();
    final NumberAxis xAxis = new NumberAxis("Sequence identity criterion");
    nf.setMinimumFractionDigits(2);
    xAxis.setLowerBound(Binning.binLevels[0]);
    xAxis.setUpperBound(1.0D);
    xAxis.setTickUnit(new NumberTickUnit(0.05D, nf));
    LogAxis yAxis = new LogAxis("Number of bins");
    yAxis.setBase(2.0D);
    yAxis.setNumberFormatOverride(NumberFormat.getInstance());
    yAxis.setTickUnit(new NumberTickUnit(2.0D));
    yAxis.setMinorTickMarksVisible(true);
    yAxis.setAutoRangeMinimumSize(4.0D);
    yAxis.setSmallestValue(1.0D);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    for (int i = 0; i < seriesColors.length; i++) {
        renderer.setSeriesPaint(i, seriesColors[i]);
        renderer.setSeriesStroke(i, new BasicStroke(seriesStroke[i]));
    }
    XYPlot plot = new XYPlot(binData, xAxis, yAxis, renderer);
    JFreeChart binChart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    binChart.setPadding(new RectangleInsets(0.0D, 0.0D, 0.0D, 10.0D));
    LegendTitle legend = new LegendTitle(plot);
    legend.setMargin(new RectangleInsets(1.0D, 1.0D, 1.0D, 1.0D));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.white);
    legend.setPosition(RectangleEdge.BOTTOM);
    plot.addAnnotation(new XYTitleAnnotation(0.001D, 0.999D, legend, RectangleAnchor.TOP_LEFT));
    final ChartPanel pane = new ChartPanel(binChart, false, true, true, false, false);
    // Watch for changes to the Summary object.
    summary.addObserver(new Observer() {
        public void update(Observable o, Object obj) {
            Summary s = (Summary) obj;
            ParameterEstimate estimate = s.getEstimate();
            ArrayList<BinLevel> bins = s.getBins();
            if (bins.size() > 0) {
                double[][] values = new double[2][bins.size()];
                Double low = 1.0d;
                for (int i = 0; i < bins.size(); i++) {
                    BinLevel bin = bins.get(i);
                    values[0][i] = bin.getCrit();
                    values[1][i] = bin.getLevel();
                    if (values[0][i] < low)
                        low = values[0][i];
                }
                binData.addSeries("sequences", values);
                xAxis.setLowerBound(low);
                if (low > 0.95d - MasterVariables.EPSILON) {
                    xAxis.setTickUnit(new NumberTickUnit(0.005D, nf));
                } else if (low > 0.90d - MasterVariables.EPSILON) {
                    xAxis.setTickUnit(new NumberTickUnit(0.010D, nf));
                } else if (low > 0.80d - MasterVariables.EPSILON) {
                    xAxis.setTickUnit(new NumberTickUnit(0.025D, nf));
                }
                if (estimate != null) {
                    double[][] omega = new double[2][bins.size()];
                    double[][] sigma = new double[2][bins.size()];
                    double[] omegaLine = estimate.getOmega();
                    double[] sigmaLine = estimate.getSigma();
                    for (int i = 0; i < bins.size(); i++) {
                        double crit = 1.0D - values[0][i];
                        double snp = s.getLength() * crit;
                        omega[0][i] = values[0][i];
                        sigma[0][i] = values[0][i];
                        omega[1][i] = Math.pow(2.0D, snp * omegaLine[0] + omegaLine[1]);
                        sigma[1][i] = Math.pow(2.0D, snp * sigmaLine[0] + sigmaLine[1]);
                    }
                    if (-1.0D * omegaLine[0] > MasterVariables.EPSILON) {
                        binData.addSeries("omega", omega);
                    }
                    if (-1.0D * sigmaLine[0] > MasterVariables.EPSILON) {
                        binData.addSeries("sigma", sigma);
                    }
                }
                // Repaint the summary pane.
                pane.repaint();
            }
        }
    });
    return pane;
}