Example usage for org.jfree.ui RectangleEdge BOTTOM

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

Introduction

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

Prototype

RectangleEdge BOTTOM

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

Click Source Link

Document

Bottom.

Usage

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("US Budget Deficit", "Year", true, "$ Billion",
            intervalxydataset, PlotOrientation.VERTICAL, false, false, false);
    TextTitle texttitle = new TextTitle("Source: http://www.cbo.gov/showdoc.cfm?index=1821&sequence=0#table12");
    texttitle.setFont(new Font("Dialog", 0, 8));
    texttitle.setPosition(RectangleEdge.BOTTOM);
    texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    jfreechart.addSubtitle(texttitle);// w w w  .  java2 s. co  m
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    StandardXYToolTipGenerator standardxytooltipgenerator = new StandardXYToolTipGenerator("{1} = {2}",
            new SimpleDateFormat("yyyy"), new DecimalFormat("0"));
    xyitemrenderer.setBaseToolTipGenerator(standardxytooltipgenerator);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setRangeGridlinePaint(Color.white);
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    dateaxis.setLowerMargin(0.01D);
    dateaxis.setUpperMargin(0.01D);
    return jfreechart;
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Java Standard Class Library", "Release",
            "Class Count", categorydataset, PlotOrientation.VERTICAL, false, true, false);
    jfreechart.addSubtitle(new TextTitle("Number of Classes By Release"));
    TextTitle texttitle = new TextTitle(
            "Source: Java In A Nutshell (4th Edition) by David Flanagan (O'Reilly)");
    texttitle.setFont(new Font("SansSerif", 0, 10));
    texttitle.setPosition(RectangleEdge.BOTTOM);
    texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    jfreechart.addSubtitle(texttitle);/*from  w  w  w.j  a v  a2s. co  m*/
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setUpperMargin(0.14999999999999999D);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setBaseShapesVisible(true);
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    lineandshaperenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    lineandshaperenderer.setBaseItemLabelsVisible(true);
    return jfreechart;
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Java Standard Class Library", "Release",
            "Class Count", categorydataset, PlotOrientation.VERTICAL, false, true, false);
    jfreechart.addSubtitle(new TextTitle("Number of Classes By Release"));
    TextTitle texttitle = new TextTitle(
            "Source: Java In A Nutshell (4th Edition) by David Flanagan (O'Reilly)");
    texttitle.setFont(new Font("SansSerif", 0, 10));
    texttitle.setPosition(RectangleEdge.BOTTOM);
    texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    jfreechart.addSubtitle(texttitle);/*from w w w  .  j  av a2  s.co m*/
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setBaseShapesVisible(true);
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    CategoryPointerAnnotation categorypointerannotation = new CategoryPointerAnnotation("Released 4-Dec-1998",
            "JDK 1.2", 1530D, -2.3561944901923448D);
    categorypointerannotation.setTextAnchor(TextAnchor.BOTTOM_RIGHT);
    categoryplot.addAnnotation(categorypointerannotation);
    return jfreechart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date",
            "Price Per Unit", xydataset, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    LegendTitle legendtitle = new LegendTitle(xyplot);
    legendtitle.setItemFont(new Font("Dialog", 0, 9));
    legendtitle.setBackgroundPaint(new Color(200, 200, 255, 100));
    legendtitle.setFrame(new BlockBorder(Color.white));
    legendtitle.setPosition(RectangleEdge.BOTTOM);
    XYTitleAnnotation xytitleannotation = new XYTitleAnnotation(0.97999999999999998D, 0.02D, legendtitle,
            RectangleAnchor.BOTTOM_RIGHT);
    xytitleannotation.setMaxWidth(0.47999999999999998D);
    xyplot.addAnnotation(xytitleannotation);
    org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(true);
        xylineandshaperenderer.setBaseShapesFilled(true);
    }/*from   w  ww.j a  va  2s .  c o  m*/
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    ValueAxis valueaxis = xyplot.getRangeAxis();
    valueaxis.setLowerMargin(0.34999999999999998D);
    return jfreechart;
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    SpiderWebPlot plot = new SpiderWebPlot(categorydataset);
    plot.setStartAngle(54D);/*from  w  ww. ja  va 2s  . com*/
    plot.setInteriorGap(0.40000000000000002D);
    plot.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    JFreeChart chart = new JFreeChart("Spider Web Chart Demo 1", TextTitle.DEFAULT_FONT, plot, false);
    LegendTitle legendtitle = new LegendTitle(plot);
    legendtitle.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendtitle);
    return chart;
}

From source file:org.openfaces.component.chart.impl.helpers.LegendAdapter.java

public LegendAdapter(Plot plot, Chart chart) {
    super(plot);//from   ww  w.j  ava 2 s .c o m
    ChartLegend legend = chart.getLegend();

    setPosition(RectangleEdge.BOTTOM);

    StyleObjectModel cssLegendModel = (legend != null) ? legend.getStyleObjectModel()
            : chart.getStyleObjectModel();

    final boolean chartBackgroundPaintDefined = chart.getChartView().getBackgroundPaint() != null;
    if (chartBackgroundPaintDefined) {
        setBackgroundPaint(chart.getChartView().getBackgroundPaint());
    } else {
        setBackgroundPaint(cssLegendModel.getBackground());
    }

    StyleBorderModel border = cssLegendModel.getBorder();

    if (border != null && !border.isNone()) {
        setBorder(new BlockBorder(border.getColor()));
    } else {
        setBorder(new BlockBorder(cssLegendModel.getBackground()));
    }

    setMargin(cssLegendModel.getMargin(0), cssLegendModel.getMargin(1), cssLegendModel.getMargin(2),
            cssLegendModel.getMargin(3));

    if (legend != null) {
        LegendPosition position = legend.getPosition();
        setPosition(position != null ? position.toRectangleEdge() : RectangleEdge.BOTTOM);
    }

    //from legend labels
    ChartLabels labels = (legend != null) ? legend.getLabels() : null;
    if (labels != null) {
        StyleObjectModel cssLabelsModel = labels.getStyleObjectModel();
        setItemPaint(cssLabelsModel.getColor());
        setItemFont(CSSUtil.getFont(cssLabelsModel));
    } else {
        setItemPaint(cssLegendModel.getColor());
        setItemFont(CSSUtil.getFont(cssLegendModel));
    }

}

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);/*  w  w w  .j a v  a  2  s.  c  om*/
    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.encog.workbench.tabs.visualize.scatter.LegendPanel.java

public LegendPanel(LegendItemSource source) {
    this.legend = new LegendTitle(source);
    legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.white);
    legend.setPosition(RectangleEdge.BOTTOM);
    setPreferredSize(new Dimension(1024, 35));
}

From source file:st.jigasoft.dbutil.util.ReportTheme.java

public static void circularTheme(JFreeChart chart, String... colunsName) {
    chart.setBackgroundPaint(/*from   ww w. j  a va  2s. c  o  m*/
            new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);
    int iCount = 0;

    // use gradients and white borders for the section colours
    for (Object s : colunsName) {
        plot.setSectionPaint(s.toString(), createGradientPaint(new Color(200, 200, 255), colorItems(iCount++)));
        if (iCount == MAX_COLUNS_COLOR)
            iCount = 0;
    }

    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);

    //        // add a subtitle giving the data source
    TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523",
            new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
}

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

private static JFreeChart createChart(XYZDataset xyzdataset) {
    NumberAxis numberaxis = new NumberAxis("X");
    numberaxis.setLowerMargin(0.0D);//from  w ww . jav a2  s.  c  o m
    numberaxis.setUpperMargin(0.0D);
    NumberAxis numberaxis1 = new NumberAxis("Y");
    numberaxis1.setAutoRangeIncludesZero(false);
    numberaxis1.setInverted(true);
    numberaxis1.setLowerMargin(0.0D);
    numberaxis1.setUpperMargin(0.0D);
    numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBlockRenderer xyblockrenderer = new XYBlockRenderer();
    LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 3.5D, Color.black);
    lookuppaintscale.add(0.5D, Color.green);
    lookuppaintscale.add(1.5D, Color.orange);
    lookuppaintscale.add(2.5D, Color.red);
    xyblockrenderer.setPaintScale(lookuppaintscale);
    XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setForegroundAlpha(0.66F);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo3", xyplot);
    jfreechart.removeLegend();
    jfreechart.setBackgroundPaint(Color.white);
    SymbolAxis symbolaxis = new SymbolAxis(null, new String[] { "", "OK", "Uncertain", "Bad" });
    symbolaxis.setRange(0.5D, 3.5D);
    symbolaxis.setPlot(new PiePlot());
    symbolaxis.setGridBandsVisible(false);
    PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis);
    paintscalelegend.setAxisOffset(5D);
    paintscalelegend.setPosition(RectangleEdge.BOTTOM);
    paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D));
    jfreechart.addSubtitle(paintscalelegend);
    return jfreechart;
}