Search in sources :

Example 1 with RectangleInsets

use of org.jfree.chart.ui.RectangleInsets in project series-rest-api by 52North.

the class ChartIoHandler method createPlotArea.

private XYPlot createPlotArea(JFreeChart chart) {
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    showCrosshairsOnAxes(plot);
    configureDomainAxis(plot);
    showGridlinesOnChart(plot);
    configureTimeAxis(plot);
    configureTitle(chart);
    addNotice(chart);
    return plot;
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) RectangleInsets(org.jfree.chart.ui.RectangleInsets)

Example 2 with RectangleInsets

use of org.jfree.chart.ui.RectangleInsets in project series-rest-api by 52North.

the class ChartIoHandler method addNotice.

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);
        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);
    }
}
Also used : TextTitle(org.jfree.chart.title.TextTitle) RectangleInsets(org.jfree.chart.ui.RectangleInsets)

Example 3 with RectangleInsets

use of org.jfree.chart.ui.RectangleInsets in project MassBank-web by MassBank.

the class Contents method drawDataset.

private static JFreeChart drawDataset(PieDataset dataset, String title) {
    // JFreeChartオブジェクト生成
    JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false);
    // グラフ全体背景色設定
    chart.setBackgroundPaint(new ChartColor(242, 246, 255));
    // グラフ全体境界線設定
    chart.setBorderVisible(true);
    // グラフエリアパディング設定
    chart.setPadding(new RectangleInsets(10, 10, 10, 10));
    // グラフタイトルフォント設定
    chart.getTitle().setFont(new Font("Arial", Font.BOLD, 22));
    // 凡例の表示位置設定
    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);
    // 凡例パディング設定
    legend.setPadding(10, 10, 10, 10);
    // 凡例マージン設定
    legend.setMargin(0, 10, 0, 5);
    // 凡例表示位置上寄せ
    legend.setVerticalAlignment(VerticalAlignment.TOP);
    // グラフの描画領域を取得
    PiePlot plot = (PiePlot) chart.getPlot();
    // グラフの楕円表示を許可する
    plot.setCircular(true);
    // グラフ境界線色設定
    plot.setDefaultSectionOutlinePaint(ChartColor.BLACK);
    // グラフラベル背景色設定
    plot.setLabelBackgroundPaint(new Color(240, 255, 255));
    // グラフラベルフォント設定
    plot.setLabelFont(new Font("Arial", Font.PLAIN, 12));
    // グラフラベル幅設定
    plot.setMaximumLabelWidth(0.3);
    // グラフラベル間距離設定
    plot.setLabelGap(0.05);
    // グラフ前景色透明度設定
    plot.setForegroundAlpha(0.9f);
    return chart;
}
Also used : ChartColor(org.jfree.chart.ChartColor) Color(java.awt.Color) ChartColor(org.jfree.chart.ChartColor) RectangleInsets(org.jfree.chart.ui.RectangleInsets) PiePlot(org.jfree.chart.plot.PiePlot) LegendTitle(org.jfree.chart.title.LegendTitle) JFreeChart(org.jfree.chart.JFreeChart) Font(java.awt.Font)

Example 4 with RectangleInsets

use of org.jfree.chart.ui.RectangleInsets in project dhis2-core by dhis2.

the class DefaultChartService method getMarker.

/**
 * Returns a horizontal line marker for the given x value and label.
 */
private Marker getMarker(Double value, String label) {
    Marker marker = new ValueMarker(value);
    marker.setPaint(Color.BLACK);
    marker.setStroke(new BasicStroke(1.1f));
    marker.setLabel(label);
    marker.setLabelOffset(new RectangleInsets(-10, 50, 0, 0));
    marker.setLabelFont(SUB_TITLE_FONT);
    return marker;
}
Also used : RectangleInsets(org.jfree.chart.ui.RectangleInsets) ValueMarker(org.jfree.chart.plot.ValueMarker) Marker(org.jfree.chart.plot.Marker) ValueMarker(org.jfree.chart.plot.ValueMarker)

Aggregations

RectangleInsets (org.jfree.chart.ui.RectangleInsets)4 Color (java.awt.Color)1 Font (java.awt.Font)1 ChartColor (org.jfree.chart.ChartColor)1 JFreeChart (org.jfree.chart.JFreeChart)1 Marker (org.jfree.chart.plot.Marker)1 PiePlot (org.jfree.chart.plot.PiePlot)1 ValueMarker (org.jfree.chart.plot.ValueMarker)1 XYPlot (org.jfree.chart.plot.XYPlot)1 LegendTitle (org.jfree.chart.title.LegendTitle)1 TextTitle (org.jfree.chart.title.TextTitle)1