Example usage for org.jfree.util UnitType ABSOLUTE

List of usage examples for org.jfree.util UnitType ABSOLUTE

Introduction

In this page you can find the example usage for org.jfree.util UnitType ABSOLUTE.

Prototype

UnitType ABSOLUTE

To view the source code for org.jfree.util UnitType ABSOLUTE.

Click Source Link

Document

Absolute.

Usage

From source file:org.eobjects.datacleaner.util.ChartUtils.java

public static void applyStyles(JFreeChart chart) {
    TextTitle title = chart.getTitle();/*from  w w w  .j a  v a2s. c o m*/
    if (title != null) {
        title.setFont(WidgetUtils.FONT_HEADER1);
        title.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    }

    for (int i = 0; i < chart.getSubtitleCount(); i++) {
        Title subtitle = chart.getSubtitle(i);
        if (subtitle instanceof TextTitle) {
            ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL);
        }
    }

    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setItemFont(WidgetUtils.FONT_SMALL);
    }

    // transparent background
    chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    chart.setBorderVisible(false);

    final Plot plot = chart.getPlot();
    plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d));
    plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    plot.setOutlineVisible(true);

    if (plot instanceof PiePlot) {
        // tweaks for pie charts
        final PiePlot piePlot = (PiePlot) plot;
        piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK);
        piePlot.setBaseSectionOutlineStroke(normalStroke);
        piePlot.setLabelFont(WidgetUtils.FONT_SMALL);
        piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT);
        piePlot.setLabelOutlineStroke(normalStroke);
        piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK);
        piePlot.setSectionOutlinesVisible(false);
        piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE);
    } else if (plot instanceof CategoryPlot) {
        // tweaks for bar charts
        final CategoryPlot categoryPlot = (CategoryPlot) plot;

        int columnCount = categoryPlot.getDataset().getColumnCount();
        if (columnCount > 1) {
            categoryPlot.setDomainGridlinesVisible(true);
        } else {
            categoryPlot.setDomainGridlinesVisible(false);
        }
        categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK);
        categoryPlot.setDomainGridlinePosition(CategoryAnchor.END);

        categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.setDrawingSupplier(new DCDrawingSupplier());

        final CategoryItemRenderer renderer = categoryPlot.getRenderer();
        renderer.setBaseOutlinePaint(WidgetUtils.BG_COLOR_DARK);
        renderer.setBaseOutlineStroke(wideStroke);

        if (renderer instanceof BarRenderer) {
            BarRenderer barRenderer = (BarRenderer) renderer;
            barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT);
            barRenderer.setBarPainter(new StandardBarPainter());
        }

    } else if (plot instanceof XYPlot) {
        // tweaks for line charts
        final XYPlot xyPlot = (XYPlot) plot;

        xyPlot.setDrawingSupplier(new DCDrawingSupplier());

        xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);

        final XYItemRenderer renderer = xyPlot.getRenderer();
        final int seriesCount = xyPlot.getSeriesCount();
        for (int i = 0; i < seriesCount; i++) {
            renderer.setSeriesStroke(i, wideStroke);
        }
    }
}

From source file:org.datacleaner.util.ChartUtils.java

public static void applyStyles(JFreeChart chart) {
    TextTitle title = chart.getTitle();// w  w w .j  a  v a2  s  .  co m
    if (title != null) {
        title.setFont(WidgetUtils.FONT_HEADER1);
        title.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    }

    for (int i = 0; i < chart.getSubtitleCount(); i++) {
        Title subtitle = chart.getSubtitle(i);
        if (subtitle instanceof TextTitle) {
            ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL);
        }
    }

    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setItemFont(WidgetUtils.FONT_SMALL);
    }

    // transparent background
    chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    chart.setBorderVisible(false);

    final Plot plot = chart.getPlot();
    plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d));
    plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    plot.setOutlineVisible(true);

    if (plot instanceof PiePlot) {
        // tweaks for pie charts
        final PiePlot piePlot = (PiePlot) plot;
        piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK);
        piePlot.setBaseSectionOutlineStroke(STROKE_NORMAL);
        piePlot.setLabelFont(WidgetUtils.FONT_SMALL);
        piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT);
        piePlot.setLabelOutlineStroke(STROKE_NORMAL);
        piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK);
        piePlot.setSectionOutlinesVisible(false);
        piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE);
        piePlot.setDrawingSupplier(new DCDrawingSupplier());

    } else if (plot instanceof CategoryPlot) {
        // tweaks for bar charts
        final CategoryPlot categoryPlot = (CategoryPlot) plot;

        int columnCount = categoryPlot.getDataset().getColumnCount();
        if (columnCount > 1) {
            categoryPlot.setDomainGridlinesVisible(true);
        } else {
            categoryPlot.setDomainGridlinesVisible(false);
        }
        categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK);
        categoryPlot.setDomainGridlinePosition(CategoryAnchor.END);

        categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.setDrawingSupplier(new DCDrawingSupplier());

        final CategoryItemRenderer renderer = categoryPlot.getRenderer();
        renderer.setBaseOutlinePaint(WidgetUtils.BG_COLOR_DARK);
        renderer.setBaseOutlineStroke(STROKE_WIDE);

        if (renderer instanceof BarRenderer) {
            BarRenderer barRenderer = (BarRenderer) renderer;
            barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT);
            barRenderer.setBarPainter(new StandardBarPainter());
        }

    } else if (plot instanceof XYPlot) {
        // tweaks for line charts
        final XYPlot xyPlot = (XYPlot) plot;

        xyPlot.setDrawingSupplier(new DCDrawingSupplier());

        xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);

        final XYItemRenderer renderer = xyPlot.getRenderer();
        final int seriesCount = xyPlot.getSeriesCount();
        for (int i = 0; i < seriesCount; i++) {
            renderer.setSeriesStroke(i, STROKE_WIDE);
        }
    }
}

From source file:org.infoglue.deliver.util.charts.TimeSeriesDiagram.java

/**
 * Creates a chart.//w  ww.  j a va2  s .c  o m
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */

private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(header, axisXHeader, axisYHeader, dataset, true, true,
            false);

    chart.setBackgroundPaint(Color.white);

    LegendTitle legend = chart.getLegend();
    //legend.set .setDisplaySeriesShapes(true);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(UnitType.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = plot.getRenderer();
    if (renderer instanceof StandardXYItemRenderer) {
        StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        //rr.setPlotShapes(true);
        rr.setShapesFilled(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();

    if (this.timeGranulariry.equalsIgnoreCase("Week")) {
        DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat(this.dateFormat));
        axis.setTickUnit(unit);
        axis.setTickMarkPosition(DateTickMarkPosition.START);

        axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat));
    } else {
        axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat));
    }
    /*
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat));
      */
    return chart;

}

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

/**
 *
 *//*  w ww  .j a  va  2  s.  c om*/
public static final ChartThemeSettings createChartThemeSettings() {
    ChartThemeSettings settings = new ChartThemeSettings();

    ChartSettings chartSettings = settings.getChartSettings();
    chartSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    chartSettings.setBackgroundImage(new FileImageProvider("net/sf/fspdfs/chartthemes/simple/fspdfs.png"));
    chartSettings.setBackgroundImageAlignment(new Integer(Align.TOP_RIGHT));
    chartSettings.setBackgroundImageAlpha(new Float(1f));
    chartSettings.setBorderVisible(Boolean.TRUE);
    chartSettings.setBorderPaint(new ColorProvider(Color.GREEN));
    chartSettings.setBorderStroke(new BasicStroke(1f));
    chartSettings.setAntiAlias(Boolean.TRUE);
    chartSettings.setTextAntiAlias(Boolean.TRUE);
    chartSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings titleSettings = settings.getTitleSettings();
    titleSettings.setShowTitle(Boolean.TRUE);
    titleSettings.setPosition(EdgeEnum.TOP);
    titleSettings.setForegroundPaint(new ColorProvider(Color.black));
    titleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    titleSettings.getFont().setBold(Boolean.TRUE);
    titleSettings.getFont().setFontSize(22);
    titleSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    titleSettings.setVerticalAlignment(VerticalAlignment.TOP);
    titleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings subtitleSettings = settings.getSubtitleSettings();
    subtitleSettings.setShowTitle(Boolean.TRUE);
    subtitleSettings.setPosition(EdgeEnum.TOP);
    subtitleSettings.setForegroundPaint(new ColorProvider(Color.red));
    subtitleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    subtitleSettings.getFont().setBold(Boolean.TRUE);
    subtitleSettings.setHorizontalAlignment(HorizontalAlignment.LEFT);
    subtitleSettings.setVerticalAlignment(VerticalAlignment.CENTER);
    subtitleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    LegendSettings legendSettings = settings.getLegendSettings();
    legendSettings.setShowLegend(Boolean.TRUE);
    legendSettings.setPosition(EdgeEnum.BOTTOM);
    legendSettings.setForegroundPaint(new ColorProvider(Color.black));
    legendSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    legendSettings.getFont().setBold(Boolean.TRUE);
    legendSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    legendSettings.setVerticalAlignment(VerticalAlignment.BOTTOM);
    //FIXMETHEME legendSettings.setBlockFrame();
    legendSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    PlotSettings plotSettings = settings.getPlotSettings();
    plotSettings.setOrientation(PlotOrientation.VERTICAL);
    //      plotSettings.setForegroundAlpha(new Float(0.5f));
    plotSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    //      plotSettings.setBackgroundAlpha(new Float(0.5f));
    plotSettings.setBackgroundImage(new FileImageProvider("net/sf/fspdfs/chartthemes/simple/fspdfs.png"));
    plotSettings.setBackgroundImageAlpha(new Float(0.5f));
    plotSettings.setBackgroundImageAlignment(new Integer(Align.NORTH_WEST));
    plotSettings.setLabelRotation(new Double(0));
    plotSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));
    plotSettings.setOutlineVisible(Boolean.TRUE);
    plotSettings.setOutlinePaint(new ColorProvider(Color.red));
    plotSettings.setOutlineStroke(new BasicStroke(1f));
    plotSettings.setSeriesColorSequence(COLORS);
    //      plotSettings.setSeriesGradientPaintSequence(GRADIENT_PAINTS);
    plotSettings.setSeriesOutlinePaintSequence(COLORS_DARKER);
    plotSettings.setSeriesStrokeSequence(STROKES);
    plotSettings.setSeriesOutlineStrokeSequence(OUTLINE_STROKES);
    plotSettings.setDomainGridlineVisible(Boolean.TRUE);
    plotSettings.setDomainGridlinePaint(new ColorProvider(Color.DARK_GRAY));
    plotSettings.setDomainGridlineStroke(new BasicStroke(0.5f));
    plotSettings.setRangeGridlineVisible(Boolean.TRUE);
    plotSettings.setRangeGridlinePaint(new ColorProvider(Color.BLACK));
    plotSettings.setRangeGridlineStroke(new BasicStroke(0.5f));
    plotSettings.getTickLabelFont().setFontName("Courier");
    plotSettings.getTickLabelFont().setBold(Boolean.TRUE);
    plotSettings.getTickLabelFont().setFontSize(10);
    plotSettings.getDisplayFont().setFontName("Arial");
    plotSettings.getDisplayFont().setBold(Boolean.TRUE);
    plotSettings.getDisplayFont().setFontSize(12);

    AxisSettings domainAxisSettings = settings.getDomainAxisSettings();
    domainAxisSettings.setVisible(Boolean.TRUE);
    domainAxisSettings.setLocation(AxisLocation.BOTTOM_OR_RIGHT);
    domainAxisSettings.setLinePaint(new ColorProvider(Color.green));
    domainAxisSettings.setLineStroke(new BasicStroke(1f));
    domainAxisSettings.setLineVisible(Boolean.TRUE);
    //      domainAxisSettings.setLabel("Domain Axis");
    domainAxisSettings.setLabelAngle(new Double(0.0));
    domainAxisSettings.setLabelPaint(new ColorProvider(Color.magenta));
    domainAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getLabelFont().setItalic(Boolean.TRUE);
    domainAxisSettings.getLabelFont().setFontName("Comic Sans MS");
    domainAxisSettings.getLabelFont().setFontSize(12);
    domainAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    domainAxisSettings.setLabelVisible(Boolean.TRUE);
    domainAxisSettings.setTickLabelPaint(new ColorProvider(Color.cyan));
    domainAxisSettings.getTickLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getTickLabelFont().setItalic(Boolean.FALSE);
    domainAxisSettings.getTickLabelFont().setFontName("Arial");
    domainAxisSettings.getTickLabelFont().setFontSize(10);
    domainAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    domainAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    domainAxisSettings.setTickMarksInsideLength(new Float(0.1f));
    domainAxisSettings.setTickMarksOutsideLength(new Float(0.2f));
    domainAxisSettings.setTickMarksPaint(new ColorProvider(Color.ORANGE));
    domainAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    domainAxisSettings.setTickMarksVisible(Boolean.TRUE);
    domainAxisSettings.setTickCount(new Integer(5));

    AxisSettings rangeAxisSettings = settings.getRangeAxisSettings();
    rangeAxisSettings.setVisible(Boolean.TRUE);
    rangeAxisSettings.setLocation(AxisLocation.TOP_OR_RIGHT);
    rangeAxisSettings.setLinePaint(new ColorProvider(Color.yellow));
    rangeAxisSettings.setLineStroke(new BasicStroke(1f));
    rangeAxisSettings.setLineVisible(Boolean.TRUE);
    //      rangeAxisSettings.setLabel("Range Axis");
    rangeAxisSettings.setLabelAngle(new Double(Math.PI / 2.0));
    rangeAxisSettings.setLabelPaint(new ColorProvider(Color.green));
    rangeAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    rangeAxisSettings.getLabelFont().setItalic(Boolean.TRUE);
    rangeAxisSettings.getLabelFont().setFontName("Comic Sans MS");
    rangeAxisSettings.getLabelFont().setFontSize(12);
    rangeAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    rangeAxisSettings.setLabelVisible(Boolean.TRUE);
    rangeAxisSettings.setTickLabelPaint(new ColorProvider(Color.pink));
    rangeAxisSettings.getTickLabelFont().setBold(Boolean.FALSE);
    rangeAxisSettings.getTickLabelFont().setItalic(Boolean.TRUE);
    rangeAxisSettings.getTickLabelFont().setFontName("Arial");
    rangeAxisSettings.getTickLabelFont().setFontSize(10);
    rangeAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    rangeAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    rangeAxisSettings.setTickMarksInsideLength(new Float(0.2f));
    rangeAxisSettings.setTickMarksOutsideLength(new Float(0.1f));
    rangeAxisSettings.setTickMarksPaint(new ColorProvider(Color.black));
    rangeAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    rangeAxisSettings.setTickMarksVisible(Boolean.TRUE);
    rangeAxisSettings.setTickCount(new Integer(6));

    return settings;
}

From source file:net.sf.jasperreports.chartthemes.simple.SimpleSettingsFactory.java

/**
 *
 *///from ww  w .j ava2  s  .  c  om
public static final ChartThemeSettings createChartThemeSettings() {
    ChartThemeSettings settings = new ChartThemeSettings();

    ChartSettings chartSettings = settings.getChartSettings();
    chartSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    chartSettings.setBackgroundImage(
            new FileImageProvider("net/sf/jasperreports/chartthemes/simple/jasperreports.png"));
    chartSettings.setBackgroundImageAlignment(Align.TOP_RIGHT);
    chartSettings.setBackgroundImageAlpha(1f);
    chartSettings.setBorderVisible(Boolean.TRUE);
    chartSettings.setBorderPaint(new ColorProvider(Color.GREEN));
    chartSettings.setBorderStroke(new BasicStroke(1f));
    chartSettings.setAntiAlias(Boolean.TRUE);
    chartSettings.setTextAntiAlias(Boolean.TRUE);
    chartSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings titleSettings = settings.getTitleSettings();
    titleSettings.setShowTitle(Boolean.TRUE);
    titleSettings.setPosition(EdgeEnum.TOP);
    titleSettings.setForegroundPaint(new ColorProvider(Color.black));
    titleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    titleSettings.getFont().setBold(Boolean.TRUE);
    titleSettings.getFont().setFontSize(22f);
    titleSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    titleSettings.setVerticalAlignment(VerticalAlignment.TOP);
    titleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings subtitleSettings = settings.getSubtitleSettings();
    subtitleSettings.setShowTitle(Boolean.TRUE);
    subtitleSettings.setPosition(EdgeEnum.TOP);
    subtitleSettings.setForegroundPaint(new ColorProvider(Color.red));
    subtitleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    subtitleSettings.getFont().setBold(Boolean.TRUE);
    subtitleSettings.setHorizontalAlignment(HorizontalAlignment.LEFT);
    subtitleSettings.setVerticalAlignment(VerticalAlignment.CENTER);
    subtitleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    LegendSettings legendSettings = settings.getLegendSettings();
    legendSettings.setShowLegend(Boolean.TRUE);
    legendSettings.setPosition(EdgeEnum.BOTTOM);
    legendSettings.setForegroundPaint(new ColorProvider(Color.black));
    legendSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    legendSettings.getFont().setBold(Boolean.TRUE);
    legendSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    legendSettings.setVerticalAlignment(VerticalAlignment.BOTTOM);
    //FIXMETHEME legendSettings.setBlockFrame();
    legendSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    PlotSettings plotSettings = settings.getPlotSettings();
    plotSettings.setOrientation(PlotOrientation.VERTICAL);
    //      plotSettings.setForegroundAlpha(0.5f);
    plotSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    //      plotSettings.setBackgroundAlpha(0.5f);
    plotSettings.setBackgroundImage(
            new FileImageProvider("net/sf/jasperreports/chartthemes/simple/jasperreports.png"));
    plotSettings.setBackgroundImageAlpha(0.5f);
    plotSettings.setBackgroundImageAlignment(Align.NORTH_WEST);
    plotSettings.setLabelRotation(0d);
    plotSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));
    plotSettings.setOutlineVisible(Boolean.TRUE);
    plotSettings.setOutlinePaint(new ColorProvider(Color.red));
    plotSettings.setOutlineStroke(new BasicStroke(1f));
    plotSettings.setSeriesColorSequence(COLORS);
    //      plotSettings.setSeriesGradientPaintSequence(GRADIENT_PAINTS);
    plotSettings.setSeriesOutlinePaintSequence(COLORS_DARKER);
    plotSettings.setSeriesStrokeSequence(STROKES);
    plotSettings.setSeriesOutlineStrokeSequence(OUTLINE_STROKES);
    plotSettings.setDomainGridlineVisible(Boolean.TRUE);
    plotSettings.setDomainGridlinePaint(new ColorProvider(Color.DARK_GRAY));
    plotSettings.setDomainGridlineStroke(new BasicStroke(0.5f));
    plotSettings.setRangeGridlineVisible(Boolean.TRUE);
    plotSettings.setRangeGridlinePaint(new ColorProvider(Color.BLACK));
    plotSettings.setRangeGridlineStroke(new BasicStroke(0.5f));
    plotSettings.getTickLabelFont().setFontName("Courier");
    plotSettings.getTickLabelFont().setBold(Boolean.TRUE);
    plotSettings.getTickLabelFont().setFontSize(10f);
    plotSettings.getDisplayFont().setFontName("Arial");
    plotSettings.getDisplayFont().setBold(Boolean.TRUE);
    plotSettings.getDisplayFont().setFontSize(12f);

    AxisSettings domainAxisSettings = settings.getDomainAxisSettings();
    domainAxisSettings.setVisible(Boolean.TRUE);
    domainAxisSettings.setLocation(AxisLocation.BOTTOM_OR_RIGHT);
    domainAxisSettings.setLinePaint(new ColorProvider(Color.green));
    domainAxisSettings.setLineStroke(new BasicStroke(1f));
    domainAxisSettings.setLineVisible(Boolean.TRUE);
    //      domainAxisSettings.setLabel("Domain Axis");
    domainAxisSettings.setLabelAngle(0.0d);
    domainAxisSettings.setLabelPaint(new ColorProvider(Color.magenta));
    domainAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getLabelFont().setItalic(Boolean.TRUE);
    domainAxisSettings.getLabelFont().setFontName("Comic Sans MS");
    domainAxisSettings.getLabelFont().setFontSize(12f);
    domainAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    domainAxisSettings.setLabelVisible(Boolean.TRUE);
    domainAxisSettings.setTickLabelPaint(new ColorProvider(Color.cyan));
    domainAxisSettings.getTickLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getTickLabelFont().setItalic(Boolean.FALSE);
    domainAxisSettings.getTickLabelFont().setFontName("Arial");
    domainAxisSettings.getTickLabelFont().setFontSize(10f);
    domainAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    domainAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    domainAxisSettings.setTickMarksInsideLength(0.1f);
    domainAxisSettings.setTickMarksOutsideLength(0.2f);
    domainAxisSettings.setTickMarksPaint(new ColorProvider(Color.ORANGE));
    domainAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    domainAxisSettings.setTickMarksVisible(Boolean.TRUE);
    domainAxisSettings.setTickCount(5);

    AxisSettings rangeAxisSettings = settings.getRangeAxisSettings();
    rangeAxisSettings.setVisible(Boolean.TRUE);
    rangeAxisSettings.setLocation(AxisLocation.TOP_OR_RIGHT);
    rangeAxisSettings.setLinePaint(new ColorProvider(Color.yellow));
    rangeAxisSettings.setLineStroke(new BasicStroke(1f));
    rangeAxisSettings.setLineVisible(Boolean.TRUE);
    //      rangeAxisSettings.setLabel("Range Axis");
    rangeAxisSettings.setLabelAngle(Math.PI / 2.0d);
    rangeAxisSettings.setLabelPaint(new ColorProvider(Color.green));
    rangeAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    rangeAxisSettings.getLabelFont().setItalic(Boolean.TRUE);
    rangeAxisSettings.getLabelFont().setFontName("Comic Sans MS");
    rangeAxisSettings.getLabelFont().setFontSize(12f);
    rangeAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    rangeAxisSettings.setLabelVisible(Boolean.TRUE);
    rangeAxisSettings.setTickLabelPaint(new ColorProvider(Color.pink));
    rangeAxisSettings.getTickLabelFont().setBold(Boolean.FALSE);
    rangeAxisSettings.getTickLabelFont().setItalic(Boolean.TRUE);
    rangeAxisSettings.getTickLabelFont().setFontName("Arial");
    rangeAxisSettings.getTickLabelFont().setFontSize(10f);
    rangeAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    rangeAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    rangeAxisSettings.setTickMarksInsideLength(0.2f);
    rangeAxisSettings.setTickMarksOutsideLength(0.1f);
    rangeAxisSettings.setTickMarksPaint(new ColorProvider(Color.black));
    rangeAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    rangeAxisSettings.setTickMarksVisible(Boolean.TRUE);
    rangeAxisSettings.setTickCount(6);

    return settings;
}

From source file:net.sf.maltcms.chromaui.foldChangeViewer.tasks.FoldChangeViewLoaderWorker.java

@Override
public void run() {
    ProgressHandle handle = ProgressHandleFactory.createHandle("Creating fold change plot");
    try {//w  w  w  .  ja va  2s . co m
        handle.setDisplayName("Loading fold change elements");//+new File(this.files.getResourceLocation()).getName());
        handle.start(5);
        handle.progress("Reading settings", 1);
        RTUnit rtAxisUnit = RTUnit.valueOf(sp.getProperty("rtAxisUnit", "SECONDS"));
        handle.progress("Retrieving data", 2);
        XYShapeRenderer renderer = new XYShapeRenderer() {

            @Override
            protected Paint getPaint(XYDataset dataset, int series, int item) {
                double x = dataset.getXValue(series, item);
                double y = dataset.getYValue(series, item);
                if (Math.abs(x) < 1.0) {
                    Paint p = super.getPaint(dataset, series, item);
                    if (p instanceof Color) {
                        Color color = (Color) p;
                        float[] values = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(),
                                new float[3]);
                        Color hsb = new Color(
                                Color.HSBtoRGB(values[0], (float) Math.max(0.1, values[1] - 0.9), values[2]));
                        return new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue(), 64);
                    }
                }
                return super.getPaint(dataset, series, item);
            }

        };
        renderer.setAutoPopulateSeriesFillPaint(true);
        renderer.setAutoPopulateSeriesOutlinePaint(true);
        renderer.setBaseCreateEntities(true);
        handle.progress("Building plot", 3);
        XYPlot plot = new XYPlot(dataset, new NumberAxis("log2 fold change"), new NumberAxis("-log10 p-value"),
                renderer);
        BasicStroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f,
                new float[] { 5.0f }, 0.0f);
        ValueMarker marker = new ValueMarker(-Math.log10(0.05), Color.RED, dashed);
        marker.setLabel("p-value=0.05");
        marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
        marker.setLabelOffset(new RectangleInsets(UnitType.ABSOLUTE, 0, 50, 10, 0));
        marker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
        marker.setLabelPaint(Color.LIGHT_GRAY);
        plot.addRangeMarker(marker);

        Font font1 = new Font("SansSerif", Font.PLAIN, 12);
        SelectionAwareXYTooltipGenerator tooltipGenerator = cvtc.getLookup()
                .lookup(SelectionAwareXYTooltipGenerator.class);
        if (tooltipGenerator == null) {
            tooltipGenerator = new SelectionAwareXYTooltipGenerator(tooltipGenerator) {
                @Override
                public String createSelectionAwareTooltip(XYDataset xyd, int i, int i1) {
                    FoldChangeDataset dataset = (FoldChangeDataset) xyd;
                    FoldChangeElement fce = dataset.getNamedElementProvider().get(i).get(i1);
                    StringBuilder sb = new StringBuilder();
                    sb.append("<html>");
                    sb.append(fce.getPeakGroup().getMajorityDisplayName());
                    sb.append("<br>");
                    sb.append("log2 fold change=");
                    sb.append(fce.getFoldChange());
                    sb.append("<br>");
                    sb.append("p-value=");
                    sb.append(Math.pow(10, -fce.getPvalue()));
                    sb.append("</html>");
                    return sb.toString();
                }
            };
        }
        tooltipGenerator.setXYToolTipGenerator(new XYToolTipGenerator() {
            @Override
            public String generateToolTip(XYDataset xyd, int i, int i1) {
                Comparable comp = xyd.getSeriesKey(i);
                double x = xyd.getXValue(i, i1);
                double y = xyd.getYValue(i, i1);
                StringBuilder sb = new StringBuilder();
                sb.append("<html>");
                sb.append(comp);
                sb.append("<br>");
                sb.append("log2 fold change=");
                sb.append(x);
                sb.append("<br>");
                sb.append("p-value=");
                sb.append(sb.append(Math.pow(10, -y)));
                sb.append("</html>");
                return sb.toString();
            }
        });
        plot.getRenderer().setBaseToolTipGenerator(tooltipGenerator);
        handle.progress("Configuring plot", 4);
        configurePlot(plot, rtAxisUnit);
        final FoldChangeViewPanel cmhp = cvtc.getLookup().lookup(FoldChangeViewPanel.class);
        Range domainRange = null;
        Range valueRange = null;
        if (cmhp != null) {
            XYPlot xyplot = cmhp.getPlot();
            if (xyplot != null) {
                ValueAxis domain = xyplot.getDomainAxis();
                domainRange = domain.getRange();
                ValueAxis range = xyplot.getRangeAxis();
                valueRange = range.getRange();
            }
        }

        if (domainRange != null) {
            plot.getDomainAxis().setRange(domainRange);
        }
        if (valueRange != null) {
            Logger.getLogger(getClass().getName()).info("Setting previous value range!");
        }
        handle.progress("Adding plot to panel", 5);
        final XYPlot targetPlot = plot;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                final FoldChangeViewPanel cmhp = cvtc.getLookup().lookup(FoldChangeViewPanel.class);
                cmhp.setPlot(targetPlot);
                cvtc.requestActive();
            }
        });
    } finally {
        handle.finish();
    }
}

From source file:reports.util.BarChart2Scriptlet.java

/**
 *
 *//*from   w  w w .  j  a v a2 s  . co m*/
public void afterReportInit() throws JRScriptletException {

    JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo", // chart title
            "States", // X Label
            "Sell Amount", // Y Label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.white);

    LegendTitle legendtitle = (LegendTitle) jfreechart.getSubtitle(0);
    legendtitle.setPosition(RectangleEdge.RIGHT);
    legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D));

    IntervalMarker intervalmarker = new IntervalMarker(200D, 250D);
    intervalmarker.setLabel("Target Range");
    intervalmarker.setLabelFont(new Font("SansSerif", 2, 11));
    intervalmarker.setLabelAnchor(RectangleAnchor.LEFT);
    intervalmarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    intervalmarker.setPaint(new Color(222, 222, 255, 128));
    categoryplot.addRangeMarker(intervalmarker, Layer.BACKGROUND);

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    barrenderer.setItemMargin(0.10000000000000001D);

    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
    GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));

    barrenderer.setSeriesPaint(0, gradientpaint);
    barrenderer.setSeriesPaint(1, gradientpaint1);
    barrenderer.setSeriesPaint(2, gradientpaint2);

    barrenderer.setItemLabelGenerator(new LabelGenerator());
    barrenderer.setItemLabelsVisible(true);
    //ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -1.5707963267948966D);
    //barrenderer.setPositiveItemLabelPosition(itemlabelposition);

    ItemLabelPosition itemlabelposition1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
            TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -1.5707963267948966D);
    barrenderer.setPositiveItemLabelPositionFallback(itemlabelposition1);

    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    /*   */
    this.setVariableValue("Chart", new JCommonDrawableRenderer(jfreechart));
}

From source file:com.jaspersoft.studio.components.chart.editor.wizard.BaseSettingsFactory.java

/**
 *
 *///from w ww.ja  va 2 s .  co  m
public static final ChartThemeSettings createChartThemeSettings() {
    ChartThemeSettings settings = new ChartThemeSettings();

    ChartSettings chartSettings = settings.getChartSettings();
    chartSettings.setBackgroundPaint(new GradientPaintProvider(CHART_BACKGROUND1, CHART_BACKGROUND2));
    chartSettings.setBackgroundImage(
            new FileImageProvider("net/sf/jasperreports/chartthemes/simple/jasperreports.png"));
    chartSettings.setBackgroundImageAlignment(new Integer(Align.TOP_RIGHT));
    chartSettings.setBackgroundImageAlpha(new Float(1f));
    chartSettings.setBorderVisible(Boolean.FALSE);
    chartSettings.setBorderPaint(new ColorProvider(Color.BLACK));
    chartSettings.setBorderStroke(new BasicStroke(1f));
    chartSettings.setAntiAlias(Boolean.TRUE);
    chartSettings.setTextAntiAlias(Boolean.TRUE);
    chartSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings titleSettings = settings.getTitleSettings();
    titleSettings.setShowTitle(Boolean.TRUE);
    titleSettings.setPosition(EdgeEnum.TOP);
    titleSettings.setForegroundPaint(new ColorProvider(Color.black));
    titleSettings.setBackgroundPaint(new ColorProvider(TITLE_BACKGROUND));
    titleSettings.getFont().setBold(Boolean.TRUE);
    titleSettings.getFont().setFontSize(22);
    titleSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    titleSettings.setVerticalAlignment(VerticalAlignment.TOP);
    titleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings subtitleSettings = settings.getSubtitleSettings();
    subtitleSettings.setShowTitle(Boolean.TRUE);
    subtitleSettings.setPosition(EdgeEnum.TOP);
    subtitleSettings.setForegroundPaint(new ColorProvider(Color.BLACK));
    subtitleSettings.setBackgroundPaint(new ColorProvider(SUBTITLE_BACKGROUND));
    subtitleSettings.getFont().setBold(Boolean.TRUE);
    subtitleSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    subtitleSettings.setVerticalAlignment(VerticalAlignment.TOP);
    subtitleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    LegendSettings legendSettings = settings.getLegendSettings();
    legendSettings.setShowLegend(Boolean.TRUE);
    legendSettings.setPosition(EdgeEnum.BOTTOM);
    legendSettings.setForegroundPaint(new ColorProvider(Color.black));
    legendSettings.setBackgroundPaint(new ColorProvider(Color.white));
    legendSettings.getFont().setBold(Boolean.TRUE);
    legendSettings.getFont().setFontSize(7);
    legendSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    legendSettings.setVerticalAlignment(VerticalAlignment.BOTTOM);
    //FIXMETHEME legendSettings.setBlockFrame();
    legendSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    PlotSettings plotSettings = settings.getPlotSettings();
    plotSettings.setOrientation(PlotOrientation.VERTICAL);
    //      plotSettings.setForegroundAlpha(new Float(0.5f));
    plotSettings.setBackgroundPaint(new ColorProvider(Color.white));
    plotSettings.setBackgroundAlpha(new Float(0.0f));
    plotSettings.setBackgroundImage(
            new FileImageProvider("net/sf/jasperreports/chartthemes/simple/jasperreports.png"));
    plotSettings.setBackgroundImageAlpha(new Float(0.5f));
    plotSettings.setBackgroundImageAlignment(new Integer(Align.NORTH_WEST));
    plotSettings.setLabelRotation(new Double(0));
    plotSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));
    plotSettings.setOutlineVisible(Boolean.TRUE);
    plotSettings.setOutlinePaint(new ColorProvider(Color.BLACK));
    plotSettings.setOutlineStroke(new BasicStroke(1f));
    plotSettings.setSeriesColorSequence(COLORS);
    //      plotSettings.setSeriesGradientPaintSequence(GRADIENT_PAINTS);
    plotSettings.setSeriesOutlinePaintSequence(COLORS_DARKER);
    plotSettings.setSeriesStrokeSequence(STROKES);
    plotSettings.setSeriesOutlineStrokeSequence(OUTLINE_STROKES);
    plotSettings.setDomainGridlineVisible(Boolean.TRUE);
    plotSettings.setDomainGridlinePaint(new ColorProvider(Color.BLACK));
    plotSettings.setDomainGridlineStroke(new BasicStroke(0.5f));
    plotSettings.setRangeGridlineVisible(Boolean.TRUE);
    plotSettings.setRangeGridlinePaint(new ColorProvider(Color.BLACK));
    plotSettings.setRangeGridlineStroke(new BasicStroke(0.5f));
    plotSettings.getTickLabelFont().setFontName("Arial");
    plotSettings.getTickLabelFont().setBold(Boolean.TRUE);
    plotSettings.getTickLabelFont().setFontSize(10);
    plotSettings.getDisplayFont().setFontName("Arial");
    plotSettings.getDisplayFont().setBold(Boolean.TRUE);
    plotSettings.getDisplayFont().setFontSize(12);

    AxisSettings domainAxisSettings = settings.getDomainAxisSettings();
    domainAxisSettings.setVisible(Boolean.TRUE);
    domainAxisSettings.setLocation(AxisLocation.BOTTOM_OR_RIGHT);
    domainAxisSettings.setLinePaint(new ColorProvider(Color.white));
    domainAxisSettings.setLineStroke(new BasicStroke(1f));
    domainAxisSettings.setLineVisible(Boolean.TRUE);
    //      domainAxisSettings.setLabel("Domain Axis");
    domainAxisSettings.setLabelAngle(new Double(0.0));
    domainAxisSettings.setLabelPaint(new ColorProvider(Color.black));
    domainAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getLabelFont().setItalic(Boolean.FALSE);
    domainAxisSettings.getLabelFont().setFontName("Times New Roman");
    domainAxisSettings.getLabelFont().setFontSize(10);
    domainAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    domainAxisSettings.setLabelVisible(Boolean.TRUE);
    domainAxisSettings.setTickLabelPaint(new ColorProvider(Color.cyan));
    domainAxisSettings.getTickLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getTickLabelFont().setItalic(Boolean.FALSE);
    domainAxisSettings.getTickLabelFont().setFontName("Times New Roman");
    domainAxisSettings.getTickLabelFont().setFontSize(7);
    domainAxisSettings.getTickLabelFont().setItalic(Boolean.TRUE);
    domainAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    domainAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    domainAxisSettings.setTickMarksInsideLength(new Float(0.1f));
    domainAxisSettings.setTickMarksOutsideLength(new Float(0.2f));
    domainAxisSettings.setTickMarksPaint(new ColorProvider(Color.black));
    domainAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    domainAxisSettings.setTickMarksVisible(Boolean.TRUE);
    domainAxisSettings.setTickCount(new Integer(5));

    AxisSettings rangeAxisSettings = settings.getRangeAxisSettings();
    rangeAxisSettings.setVisible(Boolean.TRUE);
    rangeAxisSettings.setLocation(AxisLocation.TOP_OR_RIGHT);
    rangeAxisSettings.setLinePaint(new ColorProvider(Color.white));
    rangeAxisSettings.setLineStroke(new BasicStroke(1f));
    rangeAxisSettings.setLineVisible(Boolean.TRUE);
    //      rangeAxisSettings.setLabel("Range Axis");
    rangeAxisSettings.setLabelAngle(new Double(Math.PI / 2.0));
    rangeAxisSettings.setLabelPaint(new ColorProvider(Color.black));
    rangeAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    rangeAxisSettings.getLabelFont().setItalic(Boolean.FALSE);
    rangeAxisSettings.getLabelFont().setFontName("Times New Roman");
    rangeAxisSettings.getLabelFont().setFontSize(10);
    rangeAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    rangeAxisSettings.setLabelVisible(Boolean.TRUE);
    rangeAxisSettings.setTickLabelPaint(new ColorProvider(Color.pink));
    rangeAxisSettings.getTickLabelFont().setBold(Boolean.FALSE);
    rangeAxisSettings.getTickLabelFont().setItalic(Boolean.FALSE);
    rangeAxisSettings.getTickLabelFont().setFontName("Times New Roman");
    rangeAxisSettings.getTickLabelFont().setFontSize(7);
    rangeAxisSettings.getTickLabelFont().setItalic(Boolean.TRUE);
    rangeAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    rangeAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    rangeAxisSettings.setTickMarksInsideLength(new Float(0.2f));
    rangeAxisSettings.setTickMarksOutsideLength(new Float(0.1f));
    rangeAxisSettings.setTickMarksPaint(new ColorProvider(Color.black));
    rangeAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    rangeAxisSettings.setTickMarksVisible(Boolean.TRUE);
    rangeAxisSettings.setTickCount(new Integer(6));

    return settings;
}

From source file:reports.util.BarChartScriptlet.java

/**
 *
 *//*from   w w  w  . j a  v  a  2  s.c o m*/
public void afterReportInit() throws JRScriptletException {

    JFreeChart jfreechart = ChartFactory.createBarChart3D("Bar Chart Demo", // chart title
            "States", // X Label              
            "Sell Amount", // Y Label 
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips? 
            false // URLs? 
    );

    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(
            CategoryLabelPositions.createUpRotationLabelPositions(0.39269908169872414D));

    LegendTitle legendtitle = (LegendTitle) jfreechart.getSubtitle(0);
    legendtitle.setPosition(RectangleEdge.RIGHT);
    legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D));

    IntervalMarker intervalmarker = new IntervalMarker(4000D, 5000D);
    intervalmarker.setLabel("Target Range");
    intervalmarker.setLabelFont(new Font("SansSerif", 2, 11));
    intervalmarker.setLabelAnchor(RectangleAnchor.LEFT);
    intervalmarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    intervalmarker.setPaint(new Color(222, 222, 255, 128));
    categoryplot.addRangeMarker(intervalmarker, Layer.BACKGROUND);

    CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer();
    categoryitemrenderer.setItemLabelsVisible(true);
    BarRenderer barrenderer = (BarRenderer) categoryitemrenderer;
    barrenderer.setMaxBarWidth(0.050000000000000003D);

    barrenderer.setItemLabelGenerator(new LabelGenerator());
    barrenderer.setItemLabelsVisible(true);

    ItemLabelPosition itemlabelposition1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
            TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -1.5707963267948966D);
    barrenderer.setPositiveItemLabelPositionFallback(itemlabelposition1);

    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);

    /*
    jfreechart.setBackgroundPaint(Color.white); 
    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    categoryplot.setBackgroundPaint(Color.lightGray); 
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis)categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer barrenderer = (BarRenderer)categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
    GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
    barrenderer.setSeriesPaint(0, gradientpaint);
    barrenderer.setSeriesPaint(1, gradientpaint1);
    barrenderer.setSeriesPaint(2, gradientpaint2);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D));
       */
    this.setVariableValue("Chart", new JCommonDrawableRenderer(jfreechart));
}

From source file:msi.gama.outputs.layers.charts.FastXYItemRenderer.java

/** {@inheritDoc} */
@Override//from w  w  w .j a v  a2  s. c om
public void drawItem(final Graphics2D g2, final XYItemRendererState state, final Rectangle2D dataArea,
        final PlotRenderingInfo info, final XYPlot plot, final ValueAxis domainAxis, final ValueAxis rangeAxis,
        final XYDataset dataset, final int series, final int item, final CrosshairState crosshairState,
        final int pass) {

    if (!getItemVisible(series, item)) {
        return;
    }
    // setup for collecting optional entity info...
    boolean bAddEntity = false;
    Shape entityArea = null;
    EntityCollection entities = null;
    if (info != null) {
        entities = info.getOwner().getEntityCollection();
    }

    final PlotOrientation orientation = plot.getOrientation();
    final Paint paint = getItemPaint(series, item);
    final Stroke seriesStroke = getItemStroke(series, item);
    g2.setPaint(paint);
    g2.setStroke(seriesStroke);

    // get the data point...
    final double x1 = dataset.getXValue(series, item);
    final double y1 = dataset.getYValue(series, item);
    if (Double.isNaN(x1) || Double.isNaN(y1)) {
        return;
    }

    final RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    final RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    final double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
    final double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);

    if (getPlotLines()) {
        if (item == 0) {
            if (this.drawSeriesLineAsPath) {
                final State s = (State) state;
                s.seriesPath.reset();
                s.lastPointGood = false;
            }
            previousDrawnItem = 0;
        }

        if (this.drawSeriesLineAsPath) {
            final State s = (State) state;
            // update path to reflect latest point
            if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) {
                float x = (float) transX1;
                float y = (float) transY1;
                if (orientation == PlotOrientation.HORIZONTAL) {
                    x = (float) transY1;
                    y = (float) transX1;
                }
                if (s.isLastPointGood()) {
                    // TODO: check threshold
                    s.seriesPath.lineTo(x, y);
                } else {
                    s.seriesPath.moveTo(x, y);
                }
                s.setLastPointGood(true);
            } else {
                s.setLastPointGood(false);
            }
            if (item == dataset.getItemCount(series) - 1) {
                // draw path
                g2.setStroke(getSeriesStroke(series));
                g2.setPaint(getSeriesPaint(series));
                g2.draw(s.seriesPath);
            }
        }

        else if (item != 0) {
            // get the previous data point...
            final double x0 = dataset.getXValue(series, item - previousDrawnItem);
            final double y0 = dataset.getYValue(series, item - previousDrawnItem);
            if (!Double.isNaN(x0) && !Double.isNaN(y0)) {
                boolean drawLine = true;
                if (getPlotDiscontinuous()) {
                    // only draw a line if the gap between the current and
                    // previous data point is within the threshold
                    final int numX = dataset.getItemCount(series);
                    final double minX = dataset.getXValue(series, 0);
                    final double maxX = dataset.getXValue(series, numX - 1);
                    if (this.gapThresholdType == UnitType.ABSOLUTE) {
                        drawLine = Math.abs(x1 - x0) <= this.gapThreshold;
                    } else {
                        drawLine = Math.abs(x1 - x0) <= (maxX - minX) / numX * getGapThreshold();
                    }
                }
                if (drawLine) {
                    final double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);
                    final double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation);

                    // only draw if we have good values
                    if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1)
                            || Double.isNaN(transY1)) {
                        return;
                    }

                    // Only draw line if it is more than a pixel away from the previous one
                    if (transX1 - transX0 > 2 || transX1 - transX0 < -2 || transY1 - transY0 > 2
                            || transY1 - transY0 < -2 || 0 == previousDrawnItem) {
                        previousDrawnItem = 1;

                        if (orientation == PlotOrientation.HORIZONTAL) {
                            state.workingLine.setLine(transY0, transX0, transY1, transX1);
                        } else if (orientation == PlotOrientation.VERTICAL) {
                            state.workingLine.setLine(transX0, transY0, transX1, transY1);
                        }

                        if (state.workingLine.intersects(dataArea)) {
                            g2.draw(state.workingLine);
                        }
                    } else {
                        // Increase counter for the previous drawn item.
                        previousDrawnItem++;
                        bAddEntity = false;
                    }
                }
            }
        }
    }

    if (getBaseShapesVisible()) {

        Shape shape = getItemShape(series, item);
        if (orientation == PlotOrientation.HORIZONTAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1);
        } else if (orientation == PlotOrientation.VERTICAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1);
        }
        if (shape.intersects(dataArea)) {
            bAddEntity = true;
            if (getItemShapeFilled(series, item)) {
                g2.fill(shape);
            } else {
                g2.draw(shape);
            }
        }
        entityArea = shape;

    }

    if (getPlotImages()) {
        final Image image = getImage(plot, series, item, transX1, transY1);
        if (image != null) {
            final Point hotspot = getImageHotspot(plot, series, item, transX1, transY1, image);
            g2.drawImage(image, (int) (transX1 - hotspot.getX()), (int) (transY1 - hotspot.getY()), null);
            entityArea = new Rectangle2D.Double(transX1 - hotspot.getX(), transY1 - hotspot.getY(),
                    image.getWidth(null), image.getHeight(null));
        }

    }

    // draw the item label if there is one...
    if (isItemLabelVisible(series, item)) {
        double xx = transX1;
        double yy = transY1;
        if (orientation == PlotOrientation.HORIZONTAL) {
            xx = transY1;
            yy = transX1;
        }
        drawItemLabel(g2, orientation, dataset, series, item, xx, yy, y1 < 0.0);
    }

    updateCrosshairValues(crosshairState, x1, y1, transX1, transY1, orientation);

    // add an entity for the item...
    if (entities != null && bAddEntity) {
        addEntity(entities, entityArea, dataset, series, item, transX1, transY1);
    }
}