Example usage for org.jfree.chart.title TextTitle setVerticalAlignment

List of usage examples for org.jfree.chart.title TextTitle setVerticalAlignment

Introduction

In this page you can find the example usage for org.jfree.chart.title TextTitle setVerticalAlignment.

Prototype

public void setVerticalAlignment(VerticalAlignment alignment) 

Source Link

Document

Sets the vertical alignment for the title, and notifies any registered listeners of the change.

Usage

From source file:net.nosleep.superanalyzer.panels.HomePanel.java

public static TextTitle createSubtitle(String s) {
    TextTitle subtitle = new TextTitle(s);
    subtitle.setPosition(RectangleEdge.TOP);
    subtitle.setPadding(new RectangleInsets(UnitType.RELATIVE, 0.05, 0.05, 0.05, 0.05));
    subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
    return subtitle;
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createAreaChart("Area Chart", "Category", "Value", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    TextTitle texttitle = new TextTitle(
            "An area chart demonstration.  We use this subtitle as an example of what happens when you get a really long title or subtitle.");
    texttitle.setFont(new Font("SansSerif", 0, 12));
    texttitle.setPosition(RectangleEdge.TOP);
    texttitle.setPadding(new RectangleInsets(UnitType.RELATIVE, 0.050000000000000003D, 0.050000000000000003D,
            0.050000000000000003D, 0.050000000000000003D));
    texttitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
    jfreechart.addSubtitle(texttitle);//from   w  w  w  .ja  v a 2s. com
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setForegroundAlpha(0.5F);
    categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    categoryaxis.setLowerMargin(0.0D);
    categoryaxis.setUpperMargin(0.0D);
    categoryaxis.addCategoryLabelToolTip("Type 1", "The first type.");
    categoryaxis.addCategoryLabelToolTip("Type 2", "The second type.");
    categoryaxis.addCategoryLabelToolTip("Type 3", "The third type.");
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setLabelAngle(0.0D);
    return jfreechart;
}

From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java

public static void customizeTitle(TextTitle title, ChartParams params, String prefix) {
    if (params.get(prefix + ChartParams.TITLE_FONT_SUFFIX) != null) {
        title.setFont(params.getFont(prefix + ChartParams.TITLE_FONT_SUFFIX));
    } else {// w  ww . jav a 2  s  .co m
        title.setFont(JFreeChart.DEFAULT_TITLE_FONT);
    }

    if (params.get(prefix + ChartParams.TITLE_POSITION_SUFFIX) != null) {
        title.setPosition(params.getRectangleEdge(prefix + ChartParams.TITLE_POSITION_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_HORIZONTAL_ALIGNMENT_SUFFIX) != null) {
        title.setHorizontalAlignment(
                params.getHorizontalAlignment(prefix + ChartParams.TITLE_HORIZONTAL_ALIGNMENT_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_VERTICAL_ALIGNMENT_SUFFIX) != null) {
        title.setVerticalAlignment(
                params.getVerticalAlignment(prefix + ChartParams.TITLE_VERTICAL_ALIGNMENT_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_COLOR_SUFFIX) != null) {
        title.setPaint(params.getColor(prefix + ChartParams.TITLE_COLOR_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_BACKGROUND_COLOR_SUFFIX) != null) {
        title.setBackgroundPaint(params.getColor(prefix + ChartParams.TITLE_BACKGROUND_COLOR_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_PADDING_SUFFIX) != null) {
        title.setPadding(params.getRectangleInsets(prefix + ChartParams.TITLE_PADDING_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_URL_SUFFIX) != null) {
        title.setURLText(params.getString(prefix + ChartParams.TITLE_URL_SUFFIX));
    }
}

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

/**
 * Creates a chart.// ww  w.  j  av a2s  .c  o  m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setAnchor(StandardLegend.SOUTH);

    chart.setBackgroundPaint(Color.white);
    final TextTitle subtitle = new TextTitle("An area chart demonstration.  We use this subtitle "
            + " as an example of what happens when you get a really long title or subtitle.");
    subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12));
    subtitle.setPosition(RectangleEdge.TOP);
    //        subtitle.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.05));
    subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
    chart.addSubtitle(subtitle);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setForegroundAlpha(0.5f);

    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:com.seniorproject.augmentedreality.test.AreaChartDemo.java

/**
 * Creates a chart.//from  ww  w  .ja v a  2  s .c  om
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setAnchor(StandardLegend.SOUTH);

    chart.setBackgroundPaint(Color.white);
    final TextTitle subtitle = new TextTitle("An area chart demonstration.  We use this "
            + "subtitle as an example of what happens when you get a really long title or " + "subtitle.");
    subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12));
    subtitle.setPosition(RectangleEdge.TOP);
    //        subtitle.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.05));
    subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
    chart.addSubtitle(subtitle);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setForegroundAlpha(0.5f);

    //      plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.addCategoryLabelToolTip("Type 1", "The first type.");
    domainAxis.addCategoryLabelToolTip("Type 2", "The second type.");
    domainAxis.addCategoryLabelToolTip("Type 3", "The third type.");

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:org.n52.io.measurement.img.ChartIoHandler.java

private void addNotice(JFreeChart chart) {
    TextTitle notice = new TextTitle();
    String msg = i18n.get("msg.io.chart.notice");
    if (msg != null && !msg.isEmpty()) {
        notice.setText(msg);/*  w  w  w  .ja  va 2  s. com*/
        notice.setPaint(BLACK);
        notice.setFont(FONT_LABEL_SMALL);
        notice.setPosition(RectangleEdge.BOTTOM);
        notice.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        notice.setVerticalAlignment(VerticalAlignment.BOTTOM);
        notice.setPadding(new RectangleInsets(0, 0, 20, 20));
        chart.addSubtitle(notice);
    }
}

From source file:org.n52.io.type.quantity.handler.img.ChartIoHandler.java

private void addNotice(JFreeChart chart) {
    TextTitle notice = new TextTitle();
    String msg = i18n.get("msg.io.chart.notice");
    if (msg != null && !msg.isEmpty()) {
        notice.setText(msg);//from w  w  w  .j  a v a  2 s.c  om
        notice.setPaint(Color.BLACK);
        notice.setFont(LabelConstants.FONT_LABEL_SMALL);
        notice.setPosition(RectangleEdge.BOTTOM);
        notice.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        notice.setVerticalAlignment(VerticalAlignment.BOTTOM);
        notice.setPadding(new RectangleInsets(0, 0, 20, 20));
        chart.addSubtitle(notice);
    }
}

From source file:edu.ucla.stat.SOCR.chart.demo.AreaChartDemo1.java

/**
 * Creates a Area chart.// ww  w  . j av a 2  s  . co  m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createAreaChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    if (isDemo) {
        TextTitle subtitle = new TextTitle("An area chart demonstration.  We use this subtitle as an "
                + "example of what happens when you get a really long title or " + "subtitle.");
        subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12));
        subtitle.setPosition(RectangleEdge.TOP);
        subtitle.setPadding(new RectangleInsets(UnitType.RELATIVE, 0.05, 0.05, 0.05, 0.05));
        subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
        chart.addSubtitle(subtitle);
    }

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setForegroundAlpha(0.5f);

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    AreaRenderer renderer = (AreaRenderer) plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    if (isDemo) {
        domainAxis.addCategoryLabelToolTip("Type 1", "The first type.");
        domainAxis.addCategoryLabelToolTip("Type 2", "The second type.");
        domainAxis.addCategoryLabelToolTip("Type 3", "The third type.");
    }
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    setCategorySummary(dataset);
    return chart;

}

From source file:org.toobsframework.pres.chart.ChartBuilder.java

private JFreeChart finishChart(IRequest componentRequest, ChartDefinition chartDef, Plot plot, Map params) {

    JFreeChart chart = new JFreeChart(
            ChartUtil.evaluateTextLabel(componentRequest, chartDef.getTitle(), params),
            ChartUtil.getFont(chartDef.getTitle(), JFreeChart.DEFAULT_TITLE_FONT), plot,
            chartDef.isShowLegend());//from   ww w.jav a  2s .  c  o  m

    if (chartDef.getSubtitle() != null) {
        TextTitle subtitle = new TextTitle(
                ChartUtil.evaluateTextLabel(componentRequest, chartDef.getSubtitle(), params));
        if (chartDef.getSubtitle().getFont() != null) {
            subtitle.setFont(ChartUtil.getFont(chartDef.getSubtitle(), null));
        }
        subtitle.setPosition(ChartUtil.getPosition(chartDef.getSubtitle().getPosition()));
        subtitle.setPadding(
                ChartUtil.getRectangle(componentRequest, chartDef.getSubtitle().getPadding(), params));
        subtitle.setVerticalAlignment(
                ChartUtil.getVerticalAlignment(chartDef.getSubtitle().getVerticalAlignment()));
        subtitle.setPaint(ChartUtil.getColor(chartDef.getSubtitle().getColor()));
        chart.addSubtitle(subtitle);
    }

    chart.setBackgroundPaint(ChartUtil.getColor(chartDef.getBackgroundColor()));
    if (chartDef.getTitle() != null && chartDef.getTitle().getColor() != null) {
        chart.getTitle().setPaint(ChartUtil.getColor(chartDef.getTitle().getColor()));
    }

    if (chartDef.isShowLegend()) {
        ChartUtil.configureLegend(componentRequest, chart, chartDef.getLegend(), params);
    }

    return chart;
}

From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java

protected void handleTitleSettings(TextTitle title, TitleSettings titleSettings, JRFont titleFont,
        Paint titleForegroundPaint, RectangleEdge titleEdge) {
    JRBaseFont font = new JRBaseFont();
    JRFontUtil.copyNonNullOwnProperties(titleSettings.getFont(), font);
    JRFontUtil.copyNonNullOwnProperties(titleFont, font);
    font = new JRBaseFont(getChart(), font);
    title.setFont(JRFontUtil.getAwtFont(font, getLocale()));

    HorizontalAlignment hAlign = titleSettings.getHorizontalAlignment();
    if (hAlign != null)
        title.setHorizontalAlignment(hAlign);

    VerticalAlignment vAlign = titleSettings.getVerticalAlignment();
    if (vAlign != null)
        title.setVerticalAlignment(vAlign);

    RectangleInsets padding = titleSettings.getPadding();
    if (padding != null)
        title.setPadding(padding);//w ww .j av a  2  s . c o  m

    if (titleForegroundPaint != null)
        title.setPaint(titleForegroundPaint);

    Paint backPaint = titleSettings.getBackgroundPaint() != null ? titleSettings.getBackgroundPaint().getPaint()
            : null;
    if (backPaint != null)
        title.setBackgroundPaint(backPaint);
    if (titleEdge != null)
        title.setPosition(titleEdge);
}