Example usage for org.jfree.ui HorizontalAlignment RIGHT

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

Introduction

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

Prototype

HorizontalAlignment RIGHT

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

Click Source Link

Document

Right alignment.

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);//from  ww  w.j  av a2s. 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);//w w w  .ja  v  a2  s  .c  om
    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);//ww w  .  j av a  2  s.  c o 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:st.jigasoft.dbutil.util.ReportTheme.java

public static void circularTheme(JFreeChart chart, String... colunsName) {
    chart.setBackgroundPaint(/*  w w w  .j av  a  2 s.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:lisong_mechlab.view.graphs.DpsGraph.java

JFreeChart makechart() {
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("Max DPS over range for " + loadout, "range [m]",
            "damage / second", getSeries(), PlotOrientation.VERTICAL, true, true, false);
    chart.getPlot().setDrawingSupplier(colours);

    chart.getLegend().setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.getLegend().setVerticalAlignment(VerticalAlignment.TOP);

    LegendTitle legendTitle = chart.getLegend();
    XYTitleAnnotation titleAnnotation = new XYTitleAnnotation(0.98, 0.98, legendTitle,
            RectangleAnchor.TOP_RIGHT);/*w  w w  .ja  va2s . c om*/
    titleAnnotation.setMaxWidth(0.4);
    ((XYPlot) (chart.getPlot())).addAnnotation(titleAnnotation);
    chart.removeLegend();

    return chart;
}

From source file:net.sf.statcvs.output.xml.chart.AbstractChart.java

/**
 * create chart with titles and credit information
 *//* www  .  j  av  a2s . com*/
public void placeTitle() {
    Font font = new Font("SansSerif", Font.PLAIN, 12);
    Font creditInformationFont = new Font("SansSerif", Font.PLAIN, 9);

    TextTitle title = new TextTitle(this.title, font);
    title.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.0));
    chart.addSubtitle(title);

    if (Settings.getShowCreditInformation()) {
        TextTitle copyright = new TextTitle("generated by statcvs-xml", creditInformationFont);
        copyright.setPosition(RectangleEdge.BOTTOM);
        copyright.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        chart.addSubtitle(copyright);
    }

    chart.setBackgroundPaint(Color.white);
}

From source file:playground.yu.utils.charts.DoubleBarChart.java

public void saveAsPng(final String filename, final String title, final int width, final int height) {
    for (int i = 0; i < subCharts.length; i++)
        plot.add((CategoryPlot) subCharts[i].getChart().getPlot(), 1);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    // add MATSim logo
    Image image = MatsimResource.getAsImage("matsim_logo_transparent_small.png");
    Title subtitle = new ImageTitle(image, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM);/*from w  w w  . j  av  a  2 s .  c o m*/
    chart.addSubtitle(subtitle);
    // add default Formatting
    chart.setBackgroundPaint(new Color(1.0f, 1.0f, 1.0f, 1.0f));
    chart.getLegend().setBorder(0.0, 0.0, 0.0, 0.0);

    try {
        ChartUtilities.saveChartAsPNG(new File(filename), chart, width, height, null, true, 9);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

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

/**
 * Creates a new demo.//from w w w.jav  a 2s .c o m
 * 
 * @param title  the frame title.
 */
public WaferMapChartDemo(final String title) {
    super(title);
    final WaferMapDataset dataset = DemoDatasetFactory.createRandomWaferMapDataset(5);
    final JFreeChart chart = ChartFactory.createWaferMapChart("Wafer Map Demo", // title
            dataset, // wafermapdataset
            PlotOrientation.VERTICAL, // vertical = notchdown
            true, // legend           
            false, // tooltips
            false);

    //        final Legend legend = chart.getLegend();
    //      legend.setAnchor(Legend.EAST);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));

    final TextTitle copyright = new TextTitle("JFreeChart WaferMapPlot", new Font("SansSerif", Font.PLAIN, 9));
    copyright.setPosition(RectangleEdge.BOTTOM);
    copyright.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(copyright);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 400));
    setContentPane(chartPanel);
}

From source file:lisong_mechlab.view.graphs.SustainedDpsGraph.java

JFreeChart makechart() {
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("Max Sustained DPS over range for " + loadout,
            "range [m]", "damage / second", getSeries(), PlotOrientation.VERTICAL, true, true, false);
    chart.getPlot().setDrawingSupplier(colours);

    chart.getLegend().setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.getLegend().setVerticalAlignment(VerticalAlignment.TOP);

    LegendTitle legendTitle = chart.getLegend();
    XYTitleAnnotation titleAnnotation = new XYTitleAnnotation(0.98, 0.98, legendTitle,
            RectangleAnchor.TOP_RIGHT);/*from w w  w.  j av a 2  s .c  om*/
    titleAnnotation.setMaxWidth(0.4);
    ((XYPlot) (chart.getPlot())).addAnnotation(titleAnnotation);
    chart.removeLegend();

    return chart;
}

From source file:org.matsim.core.utils.charts.ChartUtil.java

/**
 * Adds the MATSim Logo in the lower right corner of the chart.
 *//*from  w w  w  . ja  v  a2s. c  o m*/
public void addMatsimLogo() {
    try {
        Image image = MatsimResource.getAsImage("matsim_logo_transparent_small.png");
        Title subtitle = new ImageTitle(image, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT,
                VerticalAlignment.BOTTOM);
        this.chart.addSubtitle(subtitle);
    } catch (Exception e) {
        e.printStackTrace();
        // I just had a resource-not-found error inside the method; don't know what that means but does not feel like a reason 
        // to not continue.  kai, apr'30
    }
}