Example usage for java.awt BasicStroke BasicStroke

List of usage examples for java.awt BasicStroke BasicStroke

Introduction

In this page you can find the example usage for java.awt BasicStroke BasicStroke.

Prototype

public BasicStroke(float width) 

Source Link

Document

Constructs a solid BasicStroke with the specified line width and with default values for the cap and join styles.

Usage

From source file:MainWindowLogic.java

static void drawXYChart(JPanel panelWhenInside, JTable pointsCollector) {
    panelWhenInside.removeAll();// w  w  w. j  a va 2  s  . co  m
    panelWhenInside.setLayout(new java.awt.BorderLayout());

    //TODO 
    XYSeries seriersAllPoints = new XYSeries("All points");
    addPointsToSeries(seriersAllPoints, pointsCollector);

    // Add the seriersAllPoints to your data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(seriersAllPoints);

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart(null, // Title
            null, // x-axis Label
            null, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            false, // Use tooltips
            false // Configure chart to generate URLs?
    );

    final XYPlot plot = chart.getXYPlot();
    ChartPanel chartPanel = new ChartPanel(chart);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));

    plot.setRenderer(renderer);

    panelWhenInside.add(chartPanel, BorderLayout.CENTER);
    panelWhenInside.validate();

}

From source file:no.met.jtimeseries.marinogram.MarinogramWavePlot.java

private XYPlot createPlot(TimeZone timezone, boolean plotWaveDirection, boolean plotWaveHeight) {
    ChartPlotter plotter = new ChartPlotter();
    // default setting
    plotter.setHeight(this.getHeight());
    plotter.setWidth(this.getWidth());
    plotter.setPlotDefaultProperties("", "");
    Color waveHeightColor = new Color(0, 105, 161);
    Color waveDirectionColor = new Color(0, 105, 161);
    // plot style
    PlotStyle.Builder waveStyleBuilder = new PlotStyle.Builder("Wave");
    PlotStyle plotStyle;//from www  .  j a  va  2 s .c om
    NumberPhenomenon waveDirection = getOceanForecastDataModel()
            .getPhenomenen(PhenomenonName.WaveDirection.toString(), NumberPhenomenon.class);
    NumberPhenomenon waveHeight = getOceanForecastDataModel()
            .getPhenomenen(PhenomenonName.WaveHeight.toString(), NumberPhenomenon.class);
    if (waveHeight == null || waveDirection == null) {
        return null;
    }

    double tick = (waveHeight.getMaxValue() - waveHeight.getMinValue()) / 2;
    tick = Math.ceil(tick);
    double lowBound = Math.floor(waveHeight.getMinValue() / (tick)) * (tick);
    //The minimum scale is 0
    lowBound = lowBound < 0 ? 0 : lowBound;
    lowBound = lowBound - tick / 2;
    double upperBound = lowBound + tick * 4;

    // reference the range axis
    NumberAxis leftNumberAxis = new NumberAxis();
    leftNumberAxis.setLabel(messages.getString("parameter.wave") + " (m)");
    leftNumberAxis.setLabelPaint(waveHeightColor);
    leftNumberAxis.setTickLabelPaint(waveHeightColor);
    leftNumberAxis.setLowerBound(lowBound);
    leftNumberAxis.setUpperBound(upperBound);
    leftNumberAxis.setTickUnit(new NumberTickUnit(tick));

    NumberAxis rightNumberAxis = new NumberAxis();
    rightNumberAxis.setLabelPaint(waveHeightColor);
    rightNumberAxis.setTickLabelPaint(waveHeightColor);
    rightNumberAxis.setLowerBound(lowBound);
    rightNumberAxis.setUpperBound(upperBound);
    rightNumberAxis.setTickUnit(new NumberTickUnit(tick));

    List<Date> shortTermTime = this.getShortTermTime(waveDirection.getTime().get(0));

    //set thte plot wave height color to be transparent if show wave height is false
    if (!plotWaveHeight) {
        waveHeightColor = new Color(0, 0, 0, 0);
    }

    // plot style
    plotStyle = waveStyleBuilder.spline(SplineStyle.HYBRID).stroke(new BasicStroke(2.0f))
            .seriesColor(waveHeightColor).numberAxis(leftNumberAxis).nonNegative(true).build();

    //Draw the wave height even if plotWaveHeight is false (but with transparent in such a case)
    //for the purpose to keep the same background grid and tick label on the y-axis 
    //no matter the wave height is shown or not
    plotter.addLineChart(TimeBase.SECOND, waveHeight, plotStyle);

    plotter.getPlot().setRangeAxis(1, rightNumberAxis);
    plotter.getPlot().setOutlineVisible(true);

    // first set domain date format and then add hour based domain grid
    // lines
    // TODO: wrap this inside the addHourBasedDomainGridLines for
    // simplicity

    Date minDate = shortTermTime.get(0);
    Date maxDate = shortTermTime.get(shortTermTime.size() - 1);
    plotter.setDomainRange(minDate, maxDate);
    plotter.setDomainDateFormat(timezone, "HH");
    // set domain range after (must) plot all the data
    plotter.addHourBasedDomainGridLines();
    // invisible domain axis
    plotter.getPlot().getDomainAxis().setTickLabelsVisible(false);
    // add markers
    plotter.addDomainMarkers(shortTermTime, timezone, locale);

    if (plotWaveDirection) {
        List<Date> symbolTimes = Utility.filterMinimumHourInterval(waveDirection.getTime(), 2, 1);
        InListFromDateFilter symbolTimesFilter = new InListFromDateFilter(symbolTimes);
        waveDirection.filter(symbolTimesFilter);
        waveHeight = null;
        if (plotWaveHeight) {
            waveHeight = getOceanForecastDataModel().getPhenomenen(PhenomenonName.WaveHeight.toString(),
                    NumberPhenomenon.class);
            waveHeight.filter(symbolTimesFilter);
        }

        plotStyle = waveStyleBuilder.seriesColor(waveDirectionColor).build();
        plotter.addArrowDirectionPlot(waveDirection, waveHeight, 0.1, plotStyle);
    }
    plotter.getPlot().setRangeZeroBaselineVisible(false);

    return plotter.getPlot();

}

From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java

/**
 *
 *///from   w  w  w . j a v a2s .  c  om
protected void configurePlot(Plot plot, JRChartPlot jrPlot) {

    super.configurePlot(plot, jrPlot);

    if (plot instanceof CategoryPlot) {
        CategoryPlot categoryPlot = (CategoryPlot) plot;
        CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
        CategoryDataset categoryDataset = categoryPlot.getDataset();
        if (categoryDataset != null) {
            for (int i = 0; i < categoryDataset.getRowCount(); i++) {
                categoryRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            }
        }
        categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
        categoryPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
        categoryPlot.setDomainGridlinesVisible(false);
        categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    } else if (plot instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) plot;
        XYItemRenderer xyItemRenderer = xyPlot.getRenderer();
        XYDataset xyDataset = xyPlot.getDataset();
        if (xyDataset != null) {
            for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
                xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            }
        }
        xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
        xyPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
        xyPlot.setDomainGridlinesVisible(false);
        xyPlot.setRangeZeroBaselineVisible(true);
    }
}

From source file:org.gwaspi.reports.PlinkReportLoader.java

private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome,
        XYSeriesCollection seriesCol) {//from   w w  w  . j  a v  a 2s .c o m
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);
    renderer.setSeriesPaint(0, Color.blue);

    JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", seriesCol,
            PlotOrientation.VERTICAL, true, false, false);

    XYPlot subplot = (XYPlot) subchart.getPlot();
    subplot.setRenderer(renderer);
    subplot.setBackgroundPaint(null);

    subplot.setDomainGridlineStroke(new BasicStroke(0.0f));
    subplot.setDomainMinorGridlineStroke(new BasicStroke(0.0f));
    subplot.setDomainGridlinePaint(Color.blue);
    subplot.setRangeGridlineStroke(new BasicStroke(0.0f));
    subplot.setRangeMinorGridlineStroke(new BasicStroke(0.0f));
    subplot.setRangeGridlinePaint(Color.blue);

    NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis();
    chrAxis.setAxisLineVisible(true);
    chrAxis.setTickLabelsVisible(true);
    chrAxis.setTickMarksVisible(true);
    chrAxis.setTickUnit(new NumberTickUnit(10000));
    chrAxis.setAutoRangeIncludesZero(false);

    NumberAxis log10Axis = (NumberAxis) subplot.getRangeAxis();
    log10Axis.setTickMarkInsideLength(2.0f);
    log10Axis.setTickMarkOutsideLength(2.0f);
    log10Axis.setMinorTickCount(2);
    log10Axis.setMinorTickMarksVisible(true);
    log10Axis.setAxisLineVisible(true);
    log10Axis.setAutoRangeIncludesZero(false);

    XYItemRenderer lblRenderer = subplot.getRenderer();
    MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(4.0d, chromosome);

    lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator);
    lblRenderer.setSeriesItemLabelGenerator(1, lblGenerator);
    lblRenderer.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12));
    lblRenderer.setSeriesItemLabelFont(1, new Font("Serif", Font.PLAIN, 12));
    lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0));
    lblRenderer.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0));
    lblRenderer.setSeriesItemLabelsVisible(0, true);
    lblRenderer.setSeriesItemLabelsVisible(1, true);

    combinedPlot.add(subplot, 1);
}

From source file:org.kalypso.ogc.sensor.diagview.jfreechart.ObservationChart.java

protected void setLegendProperties(final String legendName, final boolean showLegend) {
    m_legend.setTitle(legendName);//www .jav  a2  s.  com
    // m_legend.setDisplaySeriesLines( true );
    m_legend.setDisplaySeriesShapes(false);
    m_legend.setOutlineStroke(new BasicStroke(0.0f));
    m_legend.setOutlinePaint(Color.white);

    if (showLegend)
        setLegend(m_legend);
    else
        setLegend(null);
}

From source file:ecosim.gui.SummaryPane.java

/**
 *  Private method to build the binning chart.
 *
 *  @return A ChartPanel containing the binning chart.
 *//*from   ww w  . j  a v a 2s .  c om*/
private ChartPanel makeBinningChart() {
    final DefaultXYDataset binData = new DefaultXYDataset();
    final NumberFormat nf = NumberFormat.getInstance();
    final NumberAxis xAxis = new NumberAxis("Sequence identity criterion");
    nf.setMinimumFractionDigits(2);
    xAxis.setLowerBound(Binning.binLevels[0]);
    xAxis.setUpperBound(1.0D);
    xAxis.setTickUnit(new NumberTickUnit(0.05D, nf));
    LogAxis yAxis = new LogAxis("Number of bins");
    yAxis.setBase(2.0D);
    yAxis.setNumberFormatOverride(NumberFormat.getInstance());
    yAxis.setTickUnit(new NumberTickUnit(2.0D));
    yAxis.setMinorTickMarksVisible(true);
    yAxis.setAutoRangeMinimumSize(4.0D);
    yAxis.setSmallestValue(1.0D);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    for (int i = 0; i < seriesColors.length; i++) {
        renderer.setSeriesPaint(i, seriesColors[i]);
        renderer.setSeriesStroke(i, new BasicStroke(seriesStroke[i]));
    }
    XYPlot plot = new XYPlot(binData, xAxis, yAxis, renderer);
    JFreeChart binChart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    binChart.setPadding(new RectangleInsets(0.0D, 0.0D, 0.0D, 10.0D));
    LegendTitle legend = new LegendTitle(plot);
    legend.setMargin(new RectangleInsets(1.0D, 1.0D, 1.0D, 1.0D));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.white);
    legend.setPosition(RectangleEdge.BOTTOM);
    plot.addAnnotation(new XYTitleAnnotation(0.001D, 0.999D, legend, RectangleAnchor.TOP_LEFT));
    final ChartPanel pane = new ChartPanel(binChart, false, true, true, false, false);
    // Watch for changes to the Summary object.
    summary.addObserver(new Observer() {
        public void update(Observable o, Object obj) {
            Summary s = (Summary) obj;
            ParameterEstimate estimate = s.getEstimate();
            ArrayList<BinLevel> bins = s.getBins();
            if (bins.size() > 0) {
                double[][] values = new double[2][bins.size()];
                Double low = 1.0d;
                for (int i = 0; i < bins.size(); i++) {
                    BinLevel bin = bins.get(i);
                    values[0][i] = bin.getCrit();
                    values[1][i] = bin.getLevel();
                    if (values[0][i] < low)
                        low = values[0][i];
                }
                binData.addSeries("sequences", values);
                xAxis.setLowerBound(low);
                if (low > 0.95d - MasterVariables.EPSILON) {
                    xAxis.setTickUnit(new NumberTickUnit(0.005D, nf));
                } else if (low > 0.90d - MasterVariables.EPSILON) {
                    xAxis.setTickUnit(new NumberTickUnit(0.010D, nf));
                } else if (low > 0.80d - MasterVariables.EPSILON) {
                    xAxis.setTickUnit(new NumberTickUnit(0.025D, nf));
                }
                if (estimate != null) {
                    double[][] omega = new double[2][bins.size()];
                    double[][] sigma = new double[2][bins.size()];
                    double[] omegaLine = estimate.getOmega();
                    double[] sigmaLine = estimate.getSigma();
                    for (int i = 0; i < bins.size(); i++) {
                        double crit = 1.0D - values[0][i];
                        double snp = s.getLength() * crit;
                        omega[0][i] = values[0][i];
                        sigma[0][i] = values[0][i];
                        omega[1][i] = Math.pow(2.0D, snp * omegaLine[0] + omegaLine[1]);
                        sigma[1][i] = Math.pow(2.0D, snp * sigmaLine[0] + sigmaLine[1]);
                    }
                    if (-1.0D * omegaLine[0] > MasterVariables.EPSILON) {
                        binData.addSeries("omega", omega);
                    }
                    if (-1.0D * sigmaLine[0] > MasterVariables.EPSILON) {
                        binData.addSeries("sigma", sigma);
                    }
                }
                // Repaint the summary pane.
                pane.repaint();
            }
        }
    });
    return pane;
}

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

/**
 *
 *///  w  w w  .  j a v a2s  .c o 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:hudson.graph.jfreechart.JFreeChartSupport.java

public JFreeChart createChart() {

    if (chartType == Graph.TYPE_STACKED_AREA) {
        jFreeChart = ChartFactory.createStackedAreaChart(null, // chart
                chartTitle, // // title 
                xAxisLabel, // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                true, // tooltips
                false // urls
        );// w  w w.j a va  2 s  .co  m
    } else if (chartType == Graph.TYPE_LINE) {
        jFreeChart = ChartFactory.createLineChart(null, // chart title
                chartTitle, // // title 
                xAxisLabel, // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips
                false // urls
        );
    }

    jFreeChart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = jFreeChart.getCategoryPlot();

    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    // plot.setDomainGridlinesVisible(true);
    // plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    if (chartType == Graph.TYPE_LINE) {
        final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
        renderer.setBaseStroke(new BasicStroke(3));

        if (multiStageTimeSeries != null) {
            for (int i = 0; i < multiStageTimeSeries.size(); i++) {
                renderer.setSeriesPaint(i, multiStageTimeSeries.get(i).color);
            }
        }
    }

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Utils.adjustChebyshev(dataset, rangeAxis);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    if (chartType == Graph.TYPE_STACKED_AREA) {
        StackedAreaRenderer ar = new StackedAreaRenderer2() {

            @Override
            public Paint getItemPaint(int row, int column) {
                if (row == 2) {
                    return ColorPalette.BLUE;
                }
                if (row == 1) {
                    return ColorPalette.YELLOW;
                }
                if (row == 0) {
                    return ColorPalette.RED;
                }
                ChartLabel key = (ChartLabel) dataset.getColumnKey(column);
                return key.getColor(row, column);
            }

            @Override
            public String generateURL(CategoryDataset dataset, int row, int column) {
                ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
                return label.getLink(row, column);
            }

            @Override
            public String generateToolTip(CategoryDataset dataset, int row, int column) {
                ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
                return label.getToolTip(row, column);
            }
        };
        plot.setRenderer(ar);
        ar.setSeriesPaint(0, ColorPalette.RED); // Failures.
        ar.setSeriesPaint(1, ColorPalette.YELLOW); // Skips.
        ar.setSeriesPaint(2, ColorPalette.BLUE); // Total.
    }

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    return jFreeChart;
}

From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java

public static void preparePropertiesVsOwnAllPropertiesJFreeChart(JFreeChart jfchart,
        CategoryDataset categoryModel) {

    CategoryPlot categoryPlot = ((CategoryPlot) jfchart.getPlot());
    categoryPlot.getRangeAxis().resizeRange(1.2);
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setDomainGridlinePaint(Color.WHITE);
    categoryPlot.setRangeMinorGridlinePaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(Color.BLACK);
    BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);

    renderer.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 10));
    renderer.setItemLabelAnchorOffset(15);

    renderer.setSeriesStroke(0, new BasicStroke(1));
    renderer.setSeriesStroke(1, new BasicStroke(1));
    renderer.setSeriesStroke(2, new BasicStroke(1));
    renderer.setSeriesStroke(3, new BasicStroke(1));
    renderer.setSeriesStroke(4, new BasicStroke(1));
    renderer.setSeriesStroke(5, new BasicStroke(1));
    renderer.setSeriesPaint(0, new Color(0x77, 0x77, 0xFF));
    renderer.setSeriesPaint(1, new Color(0xCC, 0xCC, 0xFF));
    renderer.setSeriesPaint(2, new Color(0x00, 0x00, 0xFF));
    renderer.setSeriesPaint(3, new Color(0xFF, 0x77, 0x77));
    renderer.setSeriesPaint(4, new Color(0xFF, 0xCC, 0xCC));
    renderer.setSeriesPaint(5, new Color(0xFF, 0x00, 0x00));
    for (int i = 0; i < categoryModel.getColumnKeys().size(); i++) {
        String label = (String) categoryModel.getColumnKey(i);
        CategoryMarker marker = new CategoryMarker(label);
        marker.setLabel("");
        marker.setPaint(Color.cyan);
        marker.setOutlinePaint(Color.cyan);
        marker.setAlpha(0.1f);//  w w  w .j  av a2s .  c  o m
        marker.setLabelAnchor(RectangleAnchor.TOP);
        marker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
        marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT);
        categoryPlot.addDomainMarker(marker, Layer.BACKGROUND);
    }
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);
    renderer.setItemMargin(.1);
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_RIGHT));
    renderer.setBaseNegativeItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.BOTTOM_RIGHT));
}

From source file:org.optaplanner.benchmark.impl.statistic.bestscore.BestScoreProblemStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    List<XYPlot> plotList = new ArrayList<XYPlot>(BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE);
    int seriesIndex = 0;
    for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
        List<XYSeries> seriesList = new ArrayList<XYSeries>(BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE);
        // No direct ascending lines between 2 points, but a stepping line instead
        XYItemRenderer renderer = new XYStepRenderer();
        if (singleBenchmarkResult.isSuccess()) {
            BestScoreSingleStatistic singleStatistic = (BestScoreSingleStatistic) singleBenchmarkResult
                    .getSingleStatistic(problemStatisticType);
            for (BestScoreStatisticPoint point : singleStatistic.getPointList()) {
                long timeMillisSpent = point.getTimeMillisSpent();
                double[] levelValues = ScoreUtils.extractLevelDoubles(point.getScore());
                for (int i = 0; i < levelValues.length && i < BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE; i++) {
                    if (i >= seriesList.size()) {
                        seriesList.add(new XYSeries(
                                singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix()));
                    }/*  w w  w.j a  v  a2 s  . co m*/
                    seriesList.get(i).add(timeMillisSpent, levelValues[i]);
                }
            }
            // TODO if startingSolution is initialized and no improvement is made, a horizontal line should be shown
            // Draw a horizontal line from the last new best step to how long the solver actually ran
            long timeMillisSpent = singleBenchmarkResult.getTimeMillisSpent();
            double[] bestScoreLevels = ScoreUtils.extractLevelDoubles(singleBenchmarkResult.getScore());
            for (int i = 0; i < bestScoreLevels.length && i < BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE; i++) {
                if (i >= seriesList.size()) {
                    seriesList.add(new XYSeries(
                            singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix()));
                }
                seriesList.get(i).add(timeMillisSpent, bestScoreLevels[i]);
            }
            if (singleStatistic.getPointList().size() <= 1) {
                // Workaround for https://sourceforge.net/tracker/?func=detail&aid=3387330&group_id=15494&atid=115494
                renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);
            }
        }
        if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) {
            // Make the favorite more obvious
            renderer.setSeriesStroke(0, new BasicStroke(2.0f));
        }
        for (int i = 0; i < seriesList.size(); i++) {
            if (i >= plotList.size()) {
                plotList.add(createPlot(benchmarkReport, i));
            }
            plotList.get(i).setDataset(seriesIndex, new XYSeriesCollection(seriesList.get(i)));
            plotList.get(i).setRenderer(seriesIndex, renderer);
        }
        seriesIndex++;
    }
    graphFileList = new ArrayList<File>(plotList.size());
    for (int scoreLevelIndex = 0; scoreLevelIndex < plotList.size(); scoreLevelIndex++) {
        JFreeChart chart = new JFreeChart(
                problemBenchmarkResult.getName() + " best score level " + scoreLevelIndex + " statistic",
                JFreeChart.DEFAULT_TITLE_FONT, plotList.get(scoreLevelIndex), true);
        graphFileList.add(writeChartToImageFile(chart,
                problemBenchmarkResult.getName() + "BestScoreStatisticLevel" + scoreLevelIndex));
    }
}