Example usage for org.jfree.chart.axis NumberTickUnit NumberTickUnit

List of usage examples for org.jfree.chart.axis NumberTickUnit NumberTickUnit

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberTickUnit NumberTickUnit.

Prototype

public NumberTickUnit(double size) 

Source Link

Document

Creates a new number tick unit.

Usage

From source file:gov.nih.nci.cma.web.graphing.CMAPrincipalComponentAnalysisPlot.java

private void createChart() {

    String xLabel = component1.toString();
    String yLabel = component2.toString();

    pcaChart = ChartFactory.createScatterPlot("Principal Component Analysis", xLabel, yLabel, null,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) pcaChart.getPlot();

    buildLegend();//from ww  w. jav  a2 s  .  c om

    plot.setNoDataMessage(null);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setUseOutlinePaint(true);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairVisible(false);

    //        XYShapeAnnotation annotation = new XYShapeAnnotation(new Rectangle2D.Double(25.0, 25.0, 5, 5));
    //
    //        plot.addAnnotation(annotation);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    //should determine axis range using datapoints.
    DataRange component1Range = getDataRange(dataPoints, PCAcomponent.PC1);
    DataRange component2Range = getDataRange(dataPoints, PCAcomponent.PC2);
    DataRange component3Range = getDataRange(dataPoints, PCAcomponent.PC3);

    Double pc1AbsMax = Math.max(Math.abs(component1Range.getMaxRange()),
            Math.abs(component1Range.getMinRange()));
    Double pc2AbsMax = Math.max(Math.abs(component2Range.getMaxRange()),
            Math.abs(component2Range.getMinRange()));
    Double pc3AbsMax = Math.max(Math.abs(component3Range.getMaxRange()),
            Math.abs(component3Range.getMinRange()));

    Double maxAbsVal = Math.max(pc1AbsMax, pc2AbsMax);

    maxAbsVal = Math.max(maxAbsVal, pc3AbsMax);

    //maxAbsVal = Math.max(100.0, maxAbsVal);

    domainAxis.setAutoRangeIncludesZero(false);

    double tickUnit = 25.0;

    if (maxAbsVal <= 50.0 && maxAbsVal >= 25.0) {
        tickUnit = 10.0; //5.0;
    } else if (maxAbsVal <= 25.0) {
        tickUnit = 5.0;
    }

    domainAxis.setTickUnit(new NumberTickUnit(tickUnit));
    rangeAxis.setTickUnit(new NumberTickUnit(tickUnit));

    double glyphScaleFactor = (maxAbsVal * 2.0) / 600.0; //assuming 600 pixels for the graph

    double adjAbsVal = Math.ceil(maxAbsVal + (glyphScaleFactor * 8.0));

    //domainAxis.setRange(-maxAbsVal, maxAbsVal);
    domainAxis.setRange(-adjAbsVal, adjAbsVal);

    //rangeAxis.setRange(-maxAbsVal, maxAbsVal);
    rangeAxis.setRange(-adjAbsVal, adjAbsVal);

    createGlyphsAndAddToPlot(plot); //, glyphScaleFactor);

    // Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green);
    //try and match the UI e9e9e9
    Paint p = new Color(233, 233, 233);

    pcaChart.setBackgroundPaint(p);
}

From source file:edu.fullerton.viewerplugin.TsPlot.java

@Override
public ArrayList<Integer> makePlot(ArrayList<ChanDataBuffer> dbufs, boolean compact) throws WebUtilException {
    int imageId;/*from   w  w w  . j  a  va 2 s .  co  m*/
    try {
        if (parameterMap.containsKey("ts_newplt")) {
            imageId = makeAddPlotFiles(dbufs, compact);
        } else {
            String gtitle = getTitle(dbufs, compact);

            XYSeriesCollection xyds = new XYSeriesCollection();
            TimeSeriesCollection mtds = new TimeSeriesCollection();

            compact = dbufs.size() > 2 ? false : compact;
            for (ChanDataBuffer dbuf : dbufs) {
                if (timeAxis.equalsIgnoreCase("utc")) {
                    addTimeSeries(dbuf, compact, mtds);
                } else {
                    addXySeries(dbuf, compact, xyds);
                }
            }
            Double minx, miny, maxx, maxy;
            Double[] rng = new Double[4];

            if (timeAxis.equalsIgnoreCase("utc")) {
                PluginSupport.getRangeLimits(mtds, rng);
            } else {
                PluginSupport.getRangeLimits(xyds, rng, 0);
            }
            minx = rng[0];
            miny = rng[1];
            maxx = rng[2];
            maxy = rng[3];

            int exp;
            if (timeAxis.equalsIgnoreCase("utc")) {
                exp = PluginSupport.scaleRange(mtds, miny, maxy);
            } else {
                exp = PluginSupport.scaleRange(xyds, miny, maxy);
            }

            ChartPanel cpnl;
            DefaultXYDataset ds = new DefaultXYDataset();
            JFreeChart chart;
            if (timeAxis.equalsIgnoreCase("utc")) {
                chart = ChartFactory.createTimeSeriesChart(gtitle, "Time (UTC)", "Amplitude (Counts)", ds, true,
                        true, false);
            } else {
                chart = ChartFactory.createXYLineChart(gtitle, xAxisLabel, "Amplitude (Counts)", ds,
                        PlotOrientation.VERTICAL, true, false, false);
            }

            XYPlot plot = (XYPlot) chart.getPlot();
            NumberAxis rangeAxis = new NumberAxis("Amplitude (Counts)");
            ScaledAxisNumberFormat sanf = new ScaledAxisNumberFormat();
            sanf.setExp(exp);
            if (maxy != 0 && Math.abs(maxy - miny) <= Math.abs(maxy) * 1e-25) {
                // this garbage is to get jFreeChart to put labels on the Y axis
                double dt = Math.abs(miny) / 10;
                double scaledMin = (miny - dt) * Math.pow(10., exp);
                double scaledMax = (maxy + dt) * Math.pow(10., exp);
                rangeAxis.setRange(scaledMin, scaledMax);
                NumberTickUnit unit = new NumberTickUnit((scaledMax - scaledMin) / 10.);
                rangeAxis.setTickUnit(unit);
                rangeAxis.setAutoRange(false);
            }
            //                else
            //                {
            //                    sanf.setMinMax(miny, maxy);
            //                    rangeAxis.setRange(miny, maxy);
            //                    NumberTickUnit unit = new NumberTickUnit((maxy  - miny)/6.);
            //                    rangeAxis.setTickUnit(unit);
            //                    rangeAxis.setAutoRange(false);
            //                }
            rangeAxis.setNumberFormatOverride(sanf);
            rangeAxis.setAutoRangeIncludesZero(false);
            plot.setRangeAxis(rangeAxis);

            if (timeAxis.equalsIgnoreCase("utc")) {
                plot.setDataset(0, mtds);

            } else {
                plot.setDataset(0, xyds);
            }
            // Set the line thickness
            XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
            BasicStroke str = new BasicStroke(lineThickness);
            int n = plot.getSeriesCount();
            for (int i = 0; i < n; i++) {
                r.setSeriesStroke(i, str);
            }
            plot.setBackgroundPaint(Color.WHITE);
            // add 
            plot.setDomainGridlinesVisible(true);
            plot.setDomainGridlinePaint(Color.BLACK);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.BLACK);

            r.setBaseFillPaint(Color.WHITE);
            if (compact) {
                chart.removeLegend();
            }

            chart.setBackgroundPaint(Color.WHITE);

            cpnl = new ChartPanel(chart);
            imageId = saveImageAsPNG(cpnl);
        }
    } catch (LdvTableException | NoSuchAlgorithmException | SQLException | IOException ex) {
        throw new WebUtilException("Making time series plot: ", ex);
    }
    ArrayList<Integer> ret = new ArrayList<Integer>();
    ret.add(imageId);
    return ret;
}

From source file:org.webcat.grader.graphs.StackedAreaChart.java

@Override
protected JFreeChart generateChart(WCChartTheme chartTheme) {
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, xAxisLabel(), yAxisLabel(), tableXYDataset(),
            orientation(), true, false, false);

    XYPlot plot = chart.getXYPlot();/*from  w w  w .j a v  a  2 s  .  c o  m*/

    long diff = (long) tableXYDataset().getXValue(0, tableXYDataset().getItemCount() - 1)
            - (long) tableXYDataset().getXValue(0, 0);

    GregorianCalendar calDiff = new GregorianCalendar();
    calDiff.setTime(new NSTimestamp(diff));

    // Set the time axis
    PeriodAxis axis = new PeriodAxis(null); // ( "Date" );
    PeriodAxisLabelInfo labelinfo[] = new PeriodAxisLabelInfo[2];

    if (calDiff.get(Calendar.DAY_OF_YEAR) > 1) {
        axis.setTimeZone(TimeZone.getTimeZone(user().timeZoneName()));
        axis.setAutoRangeTimePeriodClass(org.jfree.data.time.Day.class);
        axis.setMajorTickTimePeriodClass(org.jfree.data.time.Week.class);

        labelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("d"),
                PeriodAxisLabelInfo.DEFAULT_INSETS, chartTheme.smallFont(), chartTheme.textColor(), true,
                PeriodAxisLabelInfo.DEFAULT_DIVIDER_STROKE, PeriodAxisLabelInfo.DEFAULT_DIVIDER_PAINT);

        labelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class, new SimpleDateFormat("MMM"),
                PeriodAxisLabelInfo.DEFAULT_INSETS, chartTheme.smallFont(), chartTheme.textColor(), true,
                PeriodAxisLabelInfo.DEFAULT_DIVIDER_STROKE, PeriodAxisLabelInfo.DEFAULT_DIVIDER_PAINT);
    } else {
        axis.setAutoRangeTimePeriodClass(org.jfree.data.time.Hour.class);

        labelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("ha"),
                PeriodAxisLabelInfo.DEFAULT_INSETS, chartTheme.smallFont(), chartTheme.textColor(), true,
                PeriodAxisLabelInfo.DEFAULT_DIVIDER_STROKE, PeriodAxisLabelInfo.DEFAULT_DIVIDER_PAINT);

        labelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class, new SimpleDateFormat("MMM-d"),
                PeriodAxisLabelInfo.DEFAULT_INSETS, chartTheme.smallFont(), chartTheme.textColor(), true,
                PeriodAxisLabelInfo.DEFAULT_DIVIDER_STROKE, PeriodAxisLabelInfo.DEFAULT_DIVIDER_PAINT);
    }

    axis.setLabelInfo(labelinfo);
    plot.setDomainAxis(axis);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    NumberTickUnit tickUnit = new NumberTickUnit(5);
    rangeAxis.setTickUnit(tickUnit);

    XYAreaRenderer2 renderer = (XYAreaRenderer2) plot.getRenderer();
    renderer.setOutline(true);
    renderer.setAutoPopulateSeriesOutlinePaint(true);

    plot.setDomainMinorGridlinesVisible(false);
    plot.setRangeMinorGridlinesVisible(false);

    if (markValue != null) {
        plot.setDomainCrosshairVisible(true);
        plot.setDomainCrosshairValue(markValue.doubleValue());
        plot.setDomainCrosshairPaint(Color.red);
        plot.setDomainCrosshairStroke(MARKER_STROKE);
    }

    chart.getLegend().setBorder(0, 0, 0, 0);

    return chart;
}

From source file:com.xilinx.virtex7.PowerChart.java

private void makeChart() {
    dataset = new DefaultCategoryDataset();
    chart = ChartFactory.createBarChart("", "Time Interval", "", dataset, PlotOrientation.HORIZONTAL, true,
            true, false);//from  w w w  . ja  v a2 s  . c  om

    TextTitle ttitle = new TextTitle(title, new Font(title, Font.BOLD, 15));
    ttitle.setPaint(Color.WHITE);
    chart.setTitle(ttitle);
    chart.setBackgroundPaint(bg);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    ValueAxis axis = plot.getRangeAxis();
    axis.setUpperBound(10.0);
    TickUnits tickUnits = new TickUnits();
    tickUnits.add(new NumberTickUnit(2));
    axis.setStandardTickUnits(tickUnits);
    axis.setLowerBound(0.0);
    axis.setTickLabelPaint(new Color(185, 185, 185));

    CategoryAxis caxis = plot.getDomainAxis();
    caxis.setTickLabelPaint(new Color(185, 185, 185));
    caxis.setLabelPaint(new Color(185, 185, 185));

    renderer.setItemMargin(0);
    renderer.setSeriesPaint(0, new Color(0x17, 0x7b, 0x7c));
    renderer.setSeriesPaint(1, new Color(0xa2, 0x45, 0x73));
    renderer.setSeriesPaint(2, new Color(0xff, 0x80, 0x40));
    renderer.setSeriesPaint(3, new Color(0x6f, 0x2c, 0x85));
    renderer.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator("{0}:{2}", new DecimalFormat("0.000")));
    addDummy();
}

From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYPrincipalComponentAnalysisPlot.java

private void createChart() {

    String xLabel = component1.toString();
    String yLabel = component2.toString();

    pcaChart = ChartFactory.createScatterPlot("Principal Component Analysis", xLabel, yLabel, null,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) pcaChart.getPlot();

    buildLegend();/*  w w w.ja v a2  s  . c om*/

    plot.setNoDataMessage(null);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setUseOutlinePaint(true);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairVisible(false);

    //        XYShapeAnnotation annotation = new XYShapeAnnotation(new Rectangle2D.Double(25.0, 25.0, 5, 5));
    //           
    //        plot.addAnnotation(annotation);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    //should determine axis range using datapoints.
    DataRange component1Range = getDataRange(dataPoints, PCAcomponent.PC1);
    DataRange component2Range = getDataRange(dataPoints, PCAcomponent.PC2);
    DataRange component3Range = getDataRange(dataPoints, PCAcomponent.PC3);

    Double pc1AbsMax = Math.max(Math.abs(component1Range.getMaxRange()),
            Math.abs(component1Range.getMinRange()));
    Double pc2AbsMax = Math.max(Math.abs(component2Range.getMaxRange()),
            Math.abs(component2Range.getMinRange()));
    Double pc3AbsMax = Math.max(Math.abs(component3Range.getMaxRange()),
            Math.abs(component3Range.getMinRange()));

    Double maxAbsVal = Math.max(pc1AbsMax, pc2AbsMax);

    maxAbsVal = Math.max(maxAbsVal, pc3AbsMax);

    //maxAbsVal = Math.max(100.0, maxAbsVal);

    domainAxis.setAutoRangeIncludesZero(false);

    double tickUnit = 25.0;

    if (maxAbsVal <= 25.0) {
        tickUnit = 5.0;
    } else if (maxAbsVal <= 50.0) {
        tickUnit = 10.0;
    }

    domainAxis.setTickUnit(new NumberTickUnit(tickUnit));
    rangeAxis.setTickUnit(new NumberTickUnit(tickUnit));

    double glyphScaleFactor = (maxAbsVal * 2.0) / 600.0; //assuming 600 pixels for the graph

    double adjAbsVal = Math.ceil(maxAbsVal + (glyphScaleFactor * 8.0));

    //domainAxis.setRange(-maxAbsVal, maxAbsVal);
    domainAxis.setRange(-adjAbsVal, adjAbsVal);

    //rangeAxis.setRange(-maxAbsVal, maxAbsVal);
    rangeAxis.setRange(-adjAbsVal, adjAbsVal);

    createGlyphsAndAddToPlot(plot, glyphScaleFactor);

    // Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green);
    //try and match the UI e9e9e9
    Paint p = new Color(233, 233, 233);

    pcaChart.setBackgroundPaint(p);
}

From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.PrincipalComponentAnalysisPlot.java

protected void createChart() {

    String xLabel = component1.toString();
    String yLabel = component2.toString();

    pcaChart = ChartFactory.createScatterPlot("Principal Component Analysis", xLabel, yLabel, null,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) pcaChart.getPlot();

    if (!this.colorBy.equals(PCAcolorByType.NONE)) {
        buildLegend();//from  w  ww  .  j a  va 2 s.  co  m
    }

    plot.setNoDataMessage(null);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setUseOutlinePaint(true);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairVisible(false);

    //        XYShapeAnnotation annotation = new XYShapeAnnotation(new Rectangle2D.Double(25.0, 25.0, 5, 5));
    //           
    //        plot.addAnnotation(annotation);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    //should determine axis range using datapoints.
    DataRange component1Range = getDataRange(dataPoints, PCAcomponent.PC1);
    DataRange component2Range = getDataRange(dataPoints, PCAcomponent.PC2);
    DataRange component3Range = getDataRange(dataPoints, PCAcomponent.PC3);

    Double pc1AbsMax = Math.max(Math.abs(component1Range.getMaxRange()),
            Math.abs(component1Range.getMinRange()));
    Double pc2AbsMax = Math.max(Math.abs(component2Range.getMaxRange()),
            Math.abs(component2Range.getMinRange()));
    Double pc3AbsMax = Math.max(Math.abs(component3Range.getMaxRange()),
            Math.abs(component3Range.getMinRange()));

    Double maxAbsVal = Math.max(pc1AbsMax, pc2AbsMax);

    maxAbsVal = Math.max(maxAbsVal, pc3AbsMax);

    maxAbsVal = Math.max(150.0, maxAbsVal);

    domainAxis.setAutoRangeIncludesZero(false);

    domainAxis.setRange(-maxAbsVal, maxAbsVal);
    rangeAxis.setRange(-maxAbsVal, maxAbsVal);

    domainAxis.setTickUnit(new NumberTickUnit(25.0));
    rangeAxis.setTickUnit(new NumberTickUnit(25.0));

    createGlyphsAndAddToPlot(plot);

    // Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green);
    //try and match the UI e9e9e9
    Paint p = new Color(233, 233, 233);

    pcaChart.setBackgroundPaint(p);
}

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

private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome,
        XYSeriesCollection seriesCol) {/*from  w w w.j a va 2  s . 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:com.xilinx.ultrascale.gui.BarCharts.java

License:asdf

public void upperBounds(int topVal) {
    CategoryPlot plot = chart.getCategoryPlot();
    //        BarRenderer renderer = (BarRenderer)plot.getRenderer();
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);/*from  w  w w .  j ava2 s . c o  m*/
    ValueAxis axis = plot.getRangeAxis();
    axis.setUpperBound(topVal);
    axis.setLowerBound(0.0);
    if (topVal == 32) {
        TickUnits tu = new TickUnits();
        tu.add(new NumberTickUnit(4));
        axis.setStandardTickUnits(tu);
    }

    //        axis.setAutoRangeMinimumSize(1.0);
    //        axis.setAutoRange(true);
    ////        axis.setLowerMargin(0);
    //        axis.setLowerMargin(0);
    //        axis.setUpperMargin(0.40);
    //        axis.setAutoRangeMinimumSize(1.0);
    //        axis.setDefaultAutoRange(new Range(0, 1000));
}

From source file:GUI.PlotCreator.java

private ChartPanel createWindDirectionByTimePanel() {
    JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Time(Hours)", "Wind Direction",
            createWindDirectionByTime(), PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) jfreechart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(0, Color.BLACK);
    NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
    domain.setTickUnit(new NumberTickUnit(1.0));
    domain.setVerticalTickLabels(true);/*from  w  ww  . java2s  . c  o  m*/

    return new ChartPanel(jfreechart);
}

From source file:com.greenpepper.confluence.macros.historic.AggregationExecutionChartBuilder.java

private void customizeChart(JFreeChart chart) throws IOException {
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(settings.isBorder());

    TextTitle chartTitle = chart.getTitle();
    customizeTitle(chartTitle, DEFAULT_TITLE_FONT);

    addSubTitle(chart, settings.getSubTitle(), DEFAULT_SUBTITLE_FONT);
    addSubTitle(chart, settings.getSubTitle2(), DEFAULT_SUBTITLE2_FONT);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage(gpUtil.getText("greenpepper.historic.nodata"));

    StackedBarRenderer renderer = new StackedBarRenderer(true);
    plot.setRenderer(renderer);//from   ww  w .j  a v a  2  s . c o  m

    int index = 0;
    renderer.setSeriesPaint(index++, GREEN_COLOR);
    if (settings.isShowIgnored())
        renderer.setSeriesPaint(index++, Color.yellow);
    renderer.setSeriesPaint(index, Color.red);

    renderer.setToolTipGenerator(new DefaultTooltipGenerator());
    renderer.setItemURLGenerator(new CategoryURLGenerator() {

        public String generateURL(CategoryDataset data, int series, int category) {
            Comparable valueKey = data.getColumnKey(category);
            ChartLongValue value = (ChartLongValue) valueKey;
            return "javascript:" + settings.getExecutionUID() + "_showHistoricChart('" + value.getId() + "');";
        }
    });

    CategoryAxis domainAxis = plot.getDomainAxis();
    customizeAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setCategoryMargin(0.01);

    ValueAxis rangeAxis = plot.getRangeAxis();
    customizeAxis(rangeAxis);
    rangeAxis.setLowerBound(0);
    rangeAxis.setUpperBound(1.0);

    if (rangeAxis instanceof NumberAxis) {
        NumberAxis numberAxis = (NumberAxis) rangeAxis;
        numberAxis.setTickUnit(new NumberTickUnit(.10));
        numberAxis.setNumberFormatOverride(PERCENT_FORMATTER);
    }

    plot.setForegroundAlpha(0.8f);
}