Example usage for org.jfree.ui RectangleEdge RIGHT

List of usage examples for org.jfree.ui RectangleEdge RIGHT

Introduction

In this page you can find the example usage for org.jfree.ui RectangleEdge RIGHT.

Prototype

RectangleEdge RIGHT

To view the source code for org.jfree.ui RectangleEdge RIGHT.

Click Source Link

Document

Right.

Usage

From source file:simulation.Graf.java

public Graf(String applicationTitle, String chartTitle, String chart, String chart2) {
    super(applicationTitle);
    JFreeChart lineChart = ChartFactory.createXYLineChart(chartTitle, chart, chart2, mnozina,
            PlotOrientation.VERTICAL, true, true, false);
    plot = (XYPlot) lineChart.getPlot();
    axis = (NumberAxis) plot.getRangeAxis();
    lineChart.getLegend().setVisible(false);
    lineChart.getLegend().setPosition(RectangleEdge.RIGHT);
    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    p = chartPanel;/* w w w.ja va 2  s . c  o m*/
    setContentPane(chartPanel);
}

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

private static JFreeChart createChart(XYZDataset xyzdataset) {
    NumberAxis numberaxis = new NumberAxis("X");
    numberaxis.setAutoRangeIncludesZero(false);
    NumberAxis numberaxis1 = new NumberAxis("Y");
    numberaxis1.setAutoRangeIncludesZero(false);
    XYShapeRenderer xyshaperenderer = new XYShapeRenderer();
    LookupPaintScale lookuppaintscale = new LookupPaintScale(1.0D, 4D, new Color(0, 0, 255));
    lookuppaintscale.add(2D, new Color(100, 100, 255));
    lookuppaintscale.add(3D, new Color(200, 200, 255));
    xyshaperenderer.setPaintScale(lookuppaintscale);
    XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyshaperenderer);
    xyplot.setDomainPannable(true);// w  w  w. ja v  a  2  s  . c  om
    xyplot.setRangePannable(true);
    JFreeChart jfreechart = new JFreeChart("XYShapeRendererDemo1", xyplot);
    jfreechart.removeLegend();
    NumberAxis numberaxis2 = new NumberAxis("Score");
    numberaxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, numberaxis2);
    paintscalelegend.setPosition(RectangleEdge.RIGHT);
    paintscalelegend.setMargin(4D, 4D, 40D, 4D);
    paintscalelegend.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    jfreechart.addSubtitle(paintscalelegend);
    ChartUtilities.applyCurrentTheme(jfreechart);
    return jfreechart;
}

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

private static JFreeChart createChart(PieDataset piedataset) {
    JFreeChart jfreechart = ChartFactory.createPieChart("Legend Wrapper Demo 1", piedataset, false, true,
            false);//from w  w  w  . j  a v  a  2  s . c  o m
    PiePlot pieplot = (PiePlot) jfreechart.getPlot();
    pieplot.setLabelFont(new Font("SansSerif", 0, 12));
    pieplot.setNoDataMessage("No data available");
    pieplot.setCircular(true);
    pieplot.setLabelGap(0.02D);
    LegendTitle legendtitle = new LegendTitle(jfreechart.getPlot());
    BlockContainer blockcontainer = new BlockContainer(new BorderArrangement());
    blockcontainer.setFrame(new BlockBorder(1.0D, 1.0D, 1.0D, 1.0D));
    LabelBlock labelblock = new LabelBlock("Legend Items:", new Font("SansSerif", 1, 12));
    labelblock.setPadding(5D, 5D, 5D, 5D);
    blockcontainer.add(labelblock, RectangleEdge.TOP);
    LabelBlock labelblock1 = new LabelBlock("Source: http://www.jfree.org");
    labelblock1.setPadding(8D, 20D, 2D, 5D);
    blockcontainer.add(labelblock1, RectangleEdge.BOTTOM);
    BlockContainer blockcontainer1 = legendtitle.getItemContainer();
    blockcontainer1.setPadding(2D, 10D, 5D, 2D);
    blockcontainer.add(blockcontainer1);
    legendtitle.setWrapper(blockcontainer);
    legendtitle.setPosition(RectangleEdge.RIGHT);
    legendtitle.setHorizontalAlignment(HorizontalAlignment.LEFT);
    jfreechart.addSubtitle(legendtitle);
    return jfreechart;
}

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

private static JFreeChart createChart(XYZDataset xyzdataset) {
    NumberAxis numberaxis = new NumberAxis("X");
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setLowerMargin(0.0D);/*ww  w  .  j  a  v a 2 s. c  o m*/
    numberaxis.setUpperMargin(0.0D);
    numberaxis.setAxisLinePaint(Color.white);
    numberaxis.setTickMarkPaint(Color.white);
    NumberAxis numberaxis1 = new NumberAxis("Y");
    numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis1.setLowerMargin(0.0D);
    numberaxis1.setUpperMargin(0.0D);
    numberaxis1.setAxisLinePaint(Color.white);
    numberaxis1.setTickMarkPaint(Color.white);
    XYBlockRenderer xyblockrenderer = new XYBlockRenderer();
    GrayPaintScale graypaintscale = new GrayPaintScale(-2D, 1.0D);
    xyblockrenderer.setPaintScale(graypaintscale);
    XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinesVisible(false);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setOutlinePaint(Color.blue);
    JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo1", xyplot);
    jfreechart.removeLegend();
    NumberAxis numberaxis2 = new NumberAxis("Scale");
    numberaxis2.setAxisLinePaint(Color.white);
    numberaxis2.setTickMarkPaint(Color.white);
    numberaxis2.setTickLabelFont(new Font("Dialog", 0, 7));
    PaintScaleLegend paintscalelegend = new PaintScaleLegend(new GrayPaintScale(), numberaxis2);
    paintscalelegend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    paintscalelegend.setAxisOffset(5D);
    paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D));
    paintscalelegend.setFrame(new BlockBorder(Color.red));
    paintscalelegend.setPadding(new RectangleInsets(10D, 10D, 10D, 10D));
    paintscalelegend.setStripWidth(10D);
    paintscalelegend.setPosition(RectangleEdge.RIGHT);
    paintscalelegend.setBackgroundPaint(new Color(120, 120, 180));
    jfreechart.addSubtitle(paintscalelegend);
    jfreechart.setBackgroundPaint(new Color(180, 180, 250));
    return jfreechart;
}

From source file:ch.zhaw.ias.dito.ui.util.BlockPlotPanel.java

public BlockPlotPanel(Matrix m, double lowerBound, double upperBound) {
    super(new BorderLayout());
    NumberAxis xAxis = new NumberAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setLowerMargin(1.0);/*from  www  .  j  a  v a2s .  c  o  m*/
    xAxis.setUpperMargin(0.0);
    NumberAxis yAxis = new NumberAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setLowerMargin(1.0);
    yAxis.setUpperMargin(0.0);
    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            XYZDataset xyzDataset = (XYZDataset) dataset;
            double x = xyzDataset.getXValue(series, item);
            double y = xyzDataset.getYValue(series, item);
            double z = xyzDataset.getZValue(series, item);
            return ("X=" + x + ", Y=" + y + ", Z=" + z);
        }
    });
    PaintScale scale = new ColorPaintScale(lowerBound, upperBound);
    renderer.setPaintScale(scale);
    ValueAxis axis = new NumberAxis();
    axis.setLowerBound(scale.getLowerBound());
    axis.setUpperBound(scale.getUpperBound());
    PaintScaleLegend legend = new PaintScaleLegend(scale, axis);
    legend.setMargin(new RectangleInsets(10, 10, 10, 10));
    legend.setPosition(RectangleEdge.RIGHT);

    MatrixXYDataset dataset = new MatrixXYDataset(m);
    plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    chart = new JFreeChart(plot);
    chart.removeLegend();
    chart.addSubtitle(legend);
    chart.setBackgroundPaint(Color.white);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setDisplayToolTips(true);
    this.add(chartPanel, BorderLayout.CENTER);
}

From source file:org.tap4j.plugin.util.GraphHelper.java

public static JFreeChart createChart(StaplerRequest req, CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createStackedAreaChart("TAP Tests", // chart title
            null, // unused
            "TAP Tests Count", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );/*from   w w w.j a  va 2s  .  com*/

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    final LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    StackedAreaRenderer ar = new StackedAreaRenderer2() {
        private static final long serialVersionUID = 331915263367089058L;

        @Override
        public String generateURL(CategoryDataset dataset, int row, int column) {
            NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
            return label.build.getNumber() + "/" + AbstractTapProjectAction.URL_NAME + "/";
        }

        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
            TapBuildAction build = label.build.getAction(TapBuildAction.class);
            TapResult report = build.getResult();
            report.tally();

            switch (row) {
            case 0:
                return String.valueOf(report.getFailed()) + " Failure(s)";
            case 1:
                return String.valueOf(report.getPassed()) + " Pass";
            case 2:
                return String.valueOf(report.getSkipped()) + " Skip(s)";
            default:
                return "";
            }
        }

    };

    plot.setRenderer(ar);
    ar.setSeriesPaint(0, ColorPalette.RED); // Failures
    ar.setSeriesPaint(1, ColorPalette.BLUE); // Pass
    ar.setSeriesPaint(2, ColorPalette.YELLOW); // Skips

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    return chart;
}

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

private Component createChartPanel() {
    PiePlot plot = new PiePlot(pieDataset);

    JFreeChart chart = new JFreeChart(I18n.get("statistic.pieChartPanel.title"), null, plot, true);
    chart.getLegend().setPosition(RectangleEdge.RIGHT);

    ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setBorder(CHART_BORDER);//from w w w.  j  a  v a  2  s  .  co m
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);

    return chartPanel;
}

From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreePieChartData.java

@Override
public JFreeChart getJFreeChart() {
    DefaultPieDataset pieDataset = makeDataSet();

    JFreeChart chart = ChartFactory.createPieChart(title, // Title
            pieDataset, // Dataset
            true // Show legend
            , false, false);//from  w  w w . ja  v a  2  s. c o  m
    PiePlot plot = (PiePlot) chart.getPlot();

    StandardPieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0} ({2})");

    plot.setLabelGenerator(gen);
    plot.setMaximumLabelWidth(0.07);
    plot.setLabelFont(plot.getLabelFont().deriveFont(9.0F));

    LegendTitle leg = chart.getLegend();

    leg.setPosition(RectangleEdge.RIGHT);
    if (!colours.isEmpty()) {
        String legends[] = ds.getLegends();

        for (int i = 0; i < ds.getNumSets(); i++) {
            if (legends != null && legends.length > i && colours.size() > i) {
                Color c = colours.get(i);
                plot.setSectionPaint(legends[i], c);
            }
        }
    }

    return chart;

}

From source file:chartsPK.LineChart.java

private JPanel createChartPanel(String color1, String color2) {

    XYDataset dataset = createDataset();

    boolean showLegend = false;
    boolean createURL = false;
    boolean createTooltip = false;

    JFreeChart chart = ChartFactory.createXYLineChart(getMyTitle(), getAxis().getXLabel(),
            getAxis().getYLabel(), dataset, PlotOrientation.VERTICAL, true, true, true);

    Color color;//from   w  w w. j  a  va 2 s .com

    XYPlot plot = (XYPlot) chart.getPlot();

    try {
        Field field = Class.forName("java.awt.Color").getField(color1);
        color = (Color) field.get(null);
    } catch (Exception e) {
        color = null; // Not defined
    }
    plot.setBackgroundPaint(color);

    try {
        Field field = Class.forName("java.awt.Color").getField(color2);
        color = (Color) field.get(null);

    } catch (Exception e) {
        color = null; // Not defined
    }

    chart.setBackgroundPaint(color);

    for (int i = 0; i < dataSeries.size(); i++) {

        try {
            Field field = Class.forName("java.awt.Color").getField(dataSeries.get(i).getColor());
            color = (Color) field.get(null);
        } catch (Exception e) {
            color = null; // Not defined
        }

        plot.getRenderer().setSeriesPaint(i, color);

    }

    RectangleEdge p = RectangleEdge.BOTTOM;
    LegendTitle legend = chart.getLegend();
    switch (getLegend().getPosition().toLowerCase()) {
    case "top":
        p = RectangleEdge.TOP;
        break;
    case "bottom":
        p = RectangleEdge.BOTTOM;
        break;
    case "left":
        p = RectangleEdge.LEFT;
        break;
    case "right":
        p = RectangleEdge.RIGHT;
        break;
    }

    legend.setPosition(p);

    try {
        Field field = Class.forName("java.awt.Color").getField(getLegend().getColor());
        color = (Color) field.get(null);
    } catch (Exception e) {
        color = null; // Not defined
    }
    legend.setBackgroundPaint(color);

    return new ChartPanel(chart);
}

From source file:gavisualizer.LineChart.java

@Override
public void generate() {
    // Creates Line Chart from variables
    JFreeChart chart = ChartFactory.createLineChart(_title, // chart title
            _axisLabelDomain, // domain axis label
            _axisLabelRange, // range axis label
            _dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            false, // tooltips
            false // urls
    );/*from  w  ww.j a va  2  s  .  c  om*/

    // Set the Plot to certain colors
    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setOutlinePaint(Color.white);

    // Set Legend to the right of the chart
    final LegendTitle lt = (LegendTitle) chart.getLegend();
    lt.setPosition(RectangleEdge.RIGHT);

    // Set paints for lines in the chart
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    DefaultDrawingSupplier dw = new DefaultDrawingSupplier(PAINTS,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);
    plot.setDrawingSupplier(dw);

    // Customize stroke width of the series
    ((AbstractRenderer) renderer).setAutoPopulateSeriesStroke(false);
    renderer.setBaseStroke(STROKE_WIDTH);
    renderer.setBaseShapesVisible(false);

    // Include dashed lines if necessary
    List<String> rows = _dataset.getRowKeys();

    // See if the title includes Downloads (Dashed lines are for Download lines)
    if (rows.get(rows.size() - 1).endsWith("Downloads")) {
        // Set the start to half the rows
        int start = _dataset.getRowCount() / 2;

        // Create an initial value
        int init = 0;

        // Iterate through the Download lines
        while (start < _dataset.getRowCount()) {
            // Make sure series and legend have dashes
            renderer.setSeriesStroke(start, DASHED_STROKE);
            LegendItemCollection legend = renderer.getLegendItems();
            LegendItem li = legend.get(start - 1);
            li.setLineStroke(DASHED_STROKE);

            // Make sure the color matches the undashed year
            renderer.setSeriesPaint(start, renderer.getItemPaint(init, 0));
            init++;
            start++;
        }
    }

    // Customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);

    _chart = chart;
}