Example usage for org.jfree.chart.axis NumberAxis setLabel

List of usage examples for org.jfree.chart.axis NumberAxis setLabel

Introduction

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

Prototype

public void setLabel(String label) 

Source Link

Document

Sets the label for the axis and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:com.att.aro.ui.view.overviewtab.TraceBenchmarkChartPanel.java

private JFreeChart initializeChart() {

    JFreeChart chart = ChartFactory.createBarChart(
            ResourceBundleHelper.getMessageString("overview.traceoverview.title"), null, null, createDataset(),
            PlotOrientation.HORIZONTAL, false, true, false);
    chart.setBackgroundPaint(this.getBackground());
    chart.getTitle().setFont(AROUIManager.HEADER_FONT);

    this.plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    CategoryAxis valueRangeAxis = plot.getDomainAxis();
    valueRangeAxis.setMaximumCategoryLabelWidthRatio(1.0f);
    valueRangeAxis.setMaximumCategoryLabelLines(2);
    valueRangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    valueRangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentile"));
    rangeAxis.setRange(0.0, 100.0);/*www . j a  va 2 s .  c  o  m*/
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    BarRenderer renderer = new StackedBarRenderer();
    renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBaseItemLabelGenerator(new PercentLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.black);

    // Make second bar in stack invisible
    renderer.setSeriesItemLabelsVisible(1, false);
    renderer.setSeriesPaint(1, new Color(0, 0, 0, 0));

    ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    renderer.setBasePositiveItemLabelPosition(insideItemlabelposition);

    ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
            TextAnchor.CENTER_LEFT);
    renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition);

    renderer.setBarPainter(new StandardBarPainter());
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT);
    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        @Override
        public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) {
            String traceInfo = "";
            switch (arg2) {
            case TRACE_AVERAGE:
                traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.avg");
                break;
            case TRACE_ENERGY:
                traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.engy");
                break;
            case TRACE_OVERHEAD:
                traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.ovrhd");
                break;
            default:
                break;
            }

            return traceInfo;
        }
    });

    plot.setRenderer(renderer);
    plot.getDomainAxis().setMaximumCategoryLabelLines(2);

    return chart;

}

From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeTimeChartData.java

@Override
public void setQuantityName(String s) {
    super.setQuantityName(s);
    if (chart != null) {
        NumberAxis n_axis = (NumberAxis) ((XYPlot) chart.getPlot()).getRangeAxis();
        n_axis.setLabel(s);
    }/*from www  .j  av  a2s . co m*/
}

From source file:com.att.aro.ui.view.overviewtab.ConnectionStatisticsChartPanel.java

public JFreeChart initializeChart() {
    JFreeChart chart = ChartFactory.createBarChart(
            ResourceBundleHelper.getMessageString("overview.sessionoverview.title"), null, null,
            createDataset(), PlotOrientation.HORIZONTAL, false, false, false);
    chart.setBackgroundPaint(this.getBackground());
    chart.getTitle().setFont(AROUIManager.HEADER_FONT);

    this.plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setMaximumCategoryLabelWidthRatio(1.0f);
    domainAxis.setMaximumCategoryLabelLines(2);
    domainAxis.setLabelFont(AROUIManager.LABEL_FONT);
    domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentage"));
    rangeAxis.setRange(0.0, 100.0);/*from  w ww .  j a v a 2  s  .c o  m*/
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    BarRenderer renderer = new StackedBarRenderer();
    renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBaseItemLabelGenerator(new PercentLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.black);

    // Make second bar in stack invisible
    renderer.setSeriesItemLabelsVisible(1, false);
    renderer.setSeriesPaint(1, new Color(0, 0, 0, 0));

    ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    renderer.setBasePositiveItemLabelPosition(insideItemlabelposition);

    ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
            TextAnchor.CENTER_LEFT);
    renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition);

    renderer.setBarPainter(new StandardBarPainter());
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT);

    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        @Override
        public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) {
            String sessionInfo = "";
            switch (arg2) {
            case SESSION_TERMINATION:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTermination");
                break;
            case SESSION_TIGHT_CONN:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTightConn");
                break;
            case SESSION_BURST:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionBurst");
                break;
            case SESSION_LONG_BURST:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionLongBurst");
                break;
            default:
                break;
            }

            return sessionInfo;
        }
    });

    plot.setRenderer(renderer);
    plot.getDomainAxis().setMaximumCategoryLabelLines(2);

    return chart;
}

From source file:org.spantus.exp.segment.draw.AbstractGraphGenerator.java

public JFreeChart getChart(ComparisionResult result) {
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Time"));
    plot.setGap(10.0);// ww w .j  a  v  a2 s.  co  m
    plot.setOrientation(PlotOrientation.VERTICAL);

    XYSeriesCollection[] seriesArr = createSeries(result);
    for (XYSeriesCollection series : seriesArr) {
        XYSeriesCollection data = series;
        StandardXYItemRenderer renderer = new StandardXYItemRenderer();
        renderer.setAutoPopulateSeriesPaint(false);
        renderer.setBasePaint(Color.BLACK);
        NumberAxis rangeAxis = new NumberAxis();
        rangeAxis.setLabel(((XYSeries) series.getSeries().get(0)).getDescription());
        rangeAxis.setAutoRange(true);
        XYPlot subplot = new XYPlot(data, null, rangeAxis, renderer);
        plot.add(subplot);
    }
    String name = result.getName() == null ? "Segmentation" : "Segmentation: " + result.getName();

    JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    return chart;

}

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

private XYPlot createPlot(TimeZone timezone, boolean plotAirTemp, boolean plotWaterTemp,
        boolean plotDewpointTemp) throws ParseException {
    Date startTime = null;//from   w w w  . j av a  2 s  .  co  m
    NumberPhenomenon aTemperature = null;
    NumberPhenomenon wTemperature = null;
    NumberPhenomenon dTemperature = null;
    // default setting
    ChartPlotter plotter = new ChartPlotter();
    plotter.setHeight(this.getHeight());
    plotter.setWidth(this.getWidth());
    plotter.setPlotDefaultProperties("", "");

    double minValue = 100;
    double maxValue = -100;
    int plotIndex = 0;
    if (plotAirTemp) {
        aTemperature = getLocationForecastDataModel().getPhenomenen(PhenomenonName.AirTemperature.toString(),
                NumberPhenomenon.class);
        minValue = aTemperature.getMinValue() < minValue ? aTemperature.getMinValue() : minValue;
        maxValue = aTemperature.getMaxValue() > maxValue ? aTemperature.getMaxValue() : maxValue;
        startTime = aTemperature.getTime().get(0);
        plotTemperature(plotter, aTemperature, new BasicStroke(2.0f), Color.RED,
                messages.getString("label.air"), true);
        plotter.getPlot().getRenderer(plotIndex).setSeriesVisibleInLegend(0, true);
        plotter.getPlot().getRenderer(plotIndex).setSeriesVisibleInLegend(1, true);
        plotIndex++;
    }

    if (plotWaterTemp) {
        wTemperature = getOceanForecastDataModel().getPhenomenen(PhenomenonName.seaTemperature.toString(),
                NumberPhenomenon.class);
        // only plot water temperature if it is availbe for this location
        if (wTemperature != null) {
            minValue = wTemperature.getMinValue() < minValue ? wTemperature.getMinValue() : minValue;
            maxValue = wTemperature.getMaxValue() > maxValue ? wTemperature.getMaxValue() : maxValue;
            startTime = wTemperature.getTime().get(0);
            BasicStroke dottedStroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                    1.0f, new float[] { 2.0f, 6.0f }, 0.0f);
            plotTemperature(plotter, wTemperature, dottedStroke, Color.RED, messages.getString("label.water"),
                    true);
            plotter.getPlot().getRenderer(plotIndex++).setSeriesVisibleInLegend(0, true);
        }
    }

    if (plotDewpointTemp) {
        dTemperature = getLocationForecastDataModel()
                .getPhenomenen(PhenomenonName.dewPointTemperature.toString(), NumberPhenomenon.class);
        minValue = dTemperature.getMinValue() < minValue ? dTemperature.getMinValue() : minValue;
        maxValue = dTemperature.getMaxValue() > maxValue ? dTemperature.getMaxValue() : maxValue;
        startTime = dTemperature.getTime().get(0);
        plotTemperature(plotter, dTemperature, new BasicStroke(2.0f), Color.ORANGE,
                messages.getString("label.dewpoint"), false);
        plotter.getPlot().getRenderer(plotIndex).setSeriesVisibleInLegend(0, true);
    }

    double tick = (maxValue - minValue) / 3.5;
    tick = Math.ceil(tick);
    double lowBound = Math.floor(minValue / (tick)) * (tick);
    lowBound = lowBound - tick / 2;
    double upperBound = lowBound + tick * 7;

    // set range axis
    NumberAxis numberAxis = new NumberAxis();
    numberAxis.setLabelPaint(Color.RED);
    numberAxis.setTickLabelPaint(Color.RED);
    numberAxis.setLabel(messages.getString("parameter.temperature") + " (\u00B0 C)");
    numberAxis.setTickUnit(new NumberTickUnit(tick));
    numberAxis.setLowerBound(lowBound);
    numberAxis.setUpperBound(upperBound);

    //Set left axis and right axis
    plotter.getPlot().setRangeAxis(0, numberAxis);
    plotter.getPlot().setRangeAxis(1, numberAxis);
    //Set the third axis and hide the third axis
    if (plotAirTemp && plotWaterTemp && plotDewpointTemp) {
        NumberAxis numberAxis2 = new NumberAxis();
        numberAxis2.setTickUnit(new NumberTickUnit(tick));
        numberAxis2.setLowerBound(lowBound);
        numberAxis2.setUpperBound(upperBound);
        plotter.getPlot().setRangeAxis(2, numberAxis2);
        plotter.getPlot().getRangeAxis(2).setVisible(false);
    }

    //Show legend at the top right position of the plot
    LegendTitle lt = new LegendTitle(plotter.getPlot());
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 9));
    lt.setBackgroundPaint(new Color(255, 255, 255, 100));
    lt.setFrame(new BlockBorder(Color.white));
    lt.setPosition(RectangleEdge.TOP);
    XYTitleAnnotation ta = new XYTitleAnnotation(0.99, 0.95, lt, RectangleAnchor.TOP_RIGHT);
    plotter.getPlot().addAnnotation(ta);

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

    return plotter.getPlot();

}

From source file:edu.cudenver.bios.chartsvc.resource.ScatterPlotResource.java

/**
 * Create a JFreeChart object from the chart specification.  JFreechart provides 
 * functionality to render 2D scatter plots as jpeg images
 * /*from   w  w w  .j  a v  a 2s.c om*/
 * @param chart chart specification object
 * @return JFreeChart object
 * @throws ResourceException
 */
private JFreeChart buildScatterPlot(Chart chart) throws ResourceException {
    ArrayList<LineStyle> lineStyleList = chart.getLineStyleList();

    float dashedLength = 1.0f;
    float spaceLength = 1.0f;
    float thickness = 1.0f;

    // the first series is treated as the x values
    if (chart.getSeries() == null || chart.getSeries().size() <= 0)
        throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No data series specified");

    // create the jfree chart series
    XYSeriesCollection chartData = new XYSeriesCollection();
    // use a spline renderer to make the connecting lines smooth
    XYSplineRenderer rend = new XYSplineRenderer();

    int seriesIdx = 0;

    for (Series series : chart.getSeries()) {
        XYSeries xySeries = new XYSeries(series.getLabel());

        List<Double> xList = series.getXCoordinates();
        List<Double> yList = series.getYCoordinates();
        if (xList != null && yList != null && xList.size() == yList.size()) {
            for (int i = 0; i < xList.size(); i++) {
                xySeries.add(xList.get(i), yList.get(i));
            }
        }

        if (seriesIdx >= 0 && seriesIdx < lineStyleList.size()) {
            LineStyle lineStyle = lineStyleList.get(seriesIdx);
            dashedLength = (float) lineStyle.getDashLength();
            spaceLength = (float) lineStyle.getSpaceLength();
            thickness = (float) lineStyle.getWidth();
        } else {
            dashedLength = 1.0f;
            spaceLength = 1.0f;
            thickness = 1.0f;
        }

        // set the line style
        rend.setSeriesPaint(seriesIdx, Color.BLACK);

        if (seriesIdx >= 0) {
            /*rend.setSeriesStroke(seriesIdx, 
                  new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                1.0f, new float[] {(float) seriesIdx, (float) 2*seriesIdx}, 0.0f));*/
            rend.setSeriesStroke(seriesIdx, new BasicStroke(thickness, BasicStroke.CAP_ROUND,
                    BasicStroke.JOIN_ROUND, 1.0f, new float[] { dashedLength, spaceLength }, 0.0f));
        }
        // add the series to the data set
        chartData.addSeries(xySeries);
        seriesIdx++;
    }

    // turn off shapes displayed at each data point to make a smooth curve
    rend.setBaseShapesVisible(false);

    // Create the line chart
    NumberAxis xAxis = new NumberAxis();
    xAxis.setAutoRangeIncludesZero(false);
    if (chart.getXAxis() != null) {
        Axis xAxisSpec = chart.getXAxis();
        xAxis.setLabel(xAxisSpec.getLabel());
        if (!Double.isNaN(xAxisSpec.getRangeMin()) && !Double.isNaN(xAxisSpec.getRangeMax())) {
            xAxis.setRange(xAxisSpec.getRangeMin(), xAxisSpec.getRangeMax());
        }
    }
    NumberAxis yAxis = new NumberAxis();
    if (chart.getYAxis() != null) {
        Axis yAxisSpec = chart.getYAxis();
        yAxis.setLabel(chart.getYAxis().getLabel());
        if (!Double.isNaN(yAxisSpec.getRangeMin()) && !Double.isNaN(yAxisSpec.getRangeMax())) {
            xAxis.setRange(yAxisSpec.getRangeMin(), yAxisSpec.getRangeMax());
        }
    }
    XYPlot plot = new XYPlot((XYDataset) chartData, xAxis, yAxis, rend);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    JFreeChart renderedChart = new JFreeChart(chart.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    renderedChart.setBackgroundPaint(Color.WHITE);
    if (chart.hasLegend()) {
        LegendTitle legend = new LegendTitle(plot, new ColumnArrangement(), new ColumnArrangement());
        legend.setFrame(BlockBorder.NONE);
        legend.setPosition(RectangleEdge.BOTTOM);
        renderedChart.addLegend(legend);
    }

    return renderedChart;
}

From source file:io.github.mzmine.modules.plots.chromatogram.ChromatogramPlotWindowController.java

@FXML
public void initialize() {

    final JFreeChart chart = chartNode.getChart();
    final XYPlot plot = chart.getXYPlot();

    // Do not set colors and strokes dynamically. They are instead provided
    // by the dataset and configured in configureRenderer()
    plot.setDrawingSupplier(null);//from  w  ww. jav  a 2 s.  c  o  m
    plot.setDomainGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
    plot.setRangeGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
    plot.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setDomainCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor));
    plot.setRangeCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    // chart properties
    chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));

    // legend properties
    LegendTitle legend = chart.getLegend();
    // legend.setItemFont(legendFont);
    legend.setFrame(BlockBorder.NONE);

    // set the X axis (retention time) properties
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setLabel("Retention time (min)");
    xAxis.setUpperMargin(0.03);
    xAxis.setLowerMargin(0.03);
    xAxis.setRangeType(RangeType.POSITIVE);
    xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20));

    // set the Y axis (intensity) properties
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setLabel("Intensity");
    yAxis.setRangeType(RangeType.POSITIVE);
    yAxis.setAutoRangeIncludesZero(true);

    // set the fixed number formats, because otherwise JFreeChart sometimes
    // shows exponent, sometimes it doesn't
    DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
    xAxis.setNumberFormatOverride(mzFormat);
    DecimalFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
    yAxis.setNumberFormatOverride(intensityFormat);

    chartTitle = chartNode.getChart().getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);
    chartTitle.setText("Chromatogram");

    chartNode.setCursor(Cursor.CROSSHAIR);

    // Remove the dataset if it is removed from the list
    datasets.addListener((Change<? extends ChromatogramPlotDataSet> c) -> {
        while (c.next()) {
            if (c.wasRemoved()) {
                for (ChromatogramPlotDataSet ds : c.getRemoved()) {
                    int index = plot.indexOf(ds);
                    plot.setDataset(index, null);
                }
            }
        }
    });

    itemLabelsVisible.addListener((prop, oldVal, newVal) -> {
        for (ChromatogramPlotDataSet dataset : datasets) {
            int datasetIndex = plot.indexOf(dataset);
            XYItemRenderer renderer = plot.getRenderer(datasetIndex);
            renderer.setBaseItemLabelsVisible(newVal);
        }
    });

    legendVisible.addListener((prop, oldVal, newVal) -> {
        legend.setVisible(newVal);
    });
}

From source file:org.jax.haplotype.analysis.visualization.GenomicGraphFactory.java

/**
 * Creates a plot which contains multiple chromosome histograms
 * @param chromosomeHistograms/*from  w ww .  j  a  v a  2  s  .c  o  m*/
 *          the chromosome histograms
 * @param xAxisLabel
 *          the X axis label
 * @param yAxisLabel
 *          the Y axis label
 * @return
 *          the object for the multiple chromosome plots
 */
public JFreeChart createMultiChromosomeHistogram(
        final List<? extends ChromosomeHistogramValues> chromosomeHistograms, final String xAxisLabel,
        final String yAxisLabel) {
    // create the y-axis that is shared by all of the chromosomes
    NumberAxis yAxis = new NumberAxis();
    if (yAxisLabel != null) {
        yAxis.setLabel(yAxisLabel);
    }

    // the combined plot makes all of the chromosomes to share the same
    // y-axis but to have thier own x-axis
    CombinedRangeXYPlot combinedChromosomePlot = new CombinedRangeXYPlot(yAxis);
    combinedChromosomePlot.setGap(4.0);

    // iterate through the chromosomes adding a new plot for each one
    for (ChromosomeHistogramValues currChromHist : chromosomeHistograms) {
        // use a weight to ensure that the amount of space that the
        // subgraph gets on the x-axis is proportional to the chromosome's
        // extent
        final int currWeight = (int) (currChromHist.getExtentInBasePairs() / 1000 + 1);

        final NumberAxis currXAxis = new NumberAxis();
        currXAxis.setAutoRangeIncludesZero(false);
        currXAxis.setTickLabelsVisible(false);
        currXAxis.setTickMarksVisible(false);
        currXAxis.setLabel(Integer.toString(currChromHist.getChromosomeNumber()));

        final XYPlot currPlot = this.createSnpIntervalHistogramPlot(currChromHist.getIntervals(),
                currChromHist.getVisualInterval(), currXAxis, null);

        combinedChromosomePlot.add(currPlot, currWeight);
    }

    JFreeChart multiChromosomeChart = new JFreeChart(combinedChromosomePlot);
    multiChromosomeChart.removeLegend();

    return multiChromosomeChart;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.XYCharts.BlockChart.java

/**
 * Creates a chart for the specified dataset.
 * /*from   ww  w  . ja  v a 2s.co  m*/
 * @param dataset  the dataset.
 * 
 * @return A chart instance.
 */
public JFreeChart createChart(DatasetMap datasets) {
    XYZDataset dataset = (XYZDataset) datasets.getDatasets().get("1");
    //Creates the xAxis with its label and style
    NumberAxis xAxis = new NumberAxis(xLabel);
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    xAxis.setLabel(xLabel);
    if (addLabelsStyle != null && addLabelsStyle.getFont() != null) {
        xAxis.setLabelFont(addLabelsStyle.getFont());
        xAxis.setLabelPaint(addLabelsStyle.getColor());
    }
    //Creates the yAxis with its label and style
    NumberAxis yAxis = new NumberAxis(yLabel);

    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setInverted(false);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    yAxis.setTickLabelsVisible(true);
    yAxis.setLabel(yLabel);
    if (addLabelsStyle != null && addLabelsStyle.getFont() != null) {
        yAxis.setLabelFont(addLabelsStyle.getFont());
        yAxis.setLabelPaint(addLabelsStyle.getColor());
    }
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    Color outboundCol = new Color(Integer.decode(outboundColor).intValue());

    //Sets the graph paint scale and the legend paintscale
    LookupPaintScale paintScale = new LookupPaintScale(zvalues[0], (new Double(zrangeMax)).doubleValue(),
            outboundCol);
    LookupPaintScale legendPaintScale = new LookupPaintScale(0.5, 0.5 + zvalues.length, outboundCol);

    for (int ke = 0; ke <= (zvalues.length - 1); ke++) {
        Double key = (new Double(zvalues[ke]));
        Color temp = (Color) colorRangeMap.get(key);
        paintScale.add(zvalues[ke], temp);
        legendPaintScale.add(0.5 + ke, temp);
    }
    //Configures the renderer
    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setPaintScale(paintScale);
    double blockHeight = (new Double(blockH)).doubleValue();
    double blockWidth = (new Double(blockW)).doubleValue();
    renderer.setBlockWidth(blockWidth);
    renderer.setBlockHeight(blockHeight);

    //configures the plot with title, subtitle, axis ecc.
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);
    plot.setDomainCrosshairPaint(Color.black);

    plot.setForegroundAlpha(0.66f);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    JFreeChart chart = new JFreeChart(plot);
    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);

    //Sets legend labels
    SymbolAxis scaleAxis = new SymbolAxis(null, legendLabels);
    scaleAxis.setRange(0.5, 0.5 + zvalues.length);
    scaleAxis.setPlot(new PiePlot());
    scaleAxis.setGridBandsVisible(false);
    scaleAxis.setLabel(zLabel);
    //scaleAxis.setLabelAngle(3.14/2);
    scaleAxis.setLabelFont(addLabelsStyle.getFont());
    scaleAxis.setLabelPaint(addLabelsStyle.getColor());

    //draws legend as chart subtitle
    PaintScaleLegend psl = new PaintScaleLegend(legendPaintScale, scaleAxis);
    psl.setAxisOffset(2.0);
    psl.setPosition(RectangleEdge.RIGHT);
    psl.setMargin(new RectangleInsets(5, 1, 5, 1));
    chart.addSubtitle(psl);

    if (yLabels != null) {
        //Sets y legend labels
        LookupPaintScale legendPaintScale2 = new LookupPaintScale(0, (yLabels.length - 1), Color.white);

        for (int ke = 0; ke < yLabels.length; ke++) {
            Color temp = Color.white;
            legendPaintScale2.add(1 + ke, temp);
        }

        SymbolAxis scaleAxis2 = new SymbolAxis(null, yLabels);
        scaleAxis2.setRange(0, (yLabels.length - 1));
        scaleAxis2.setPlot(new PiePlot());
        scaleAxis2.setGridBandsVisible(false);

        //draws legend as chart subtitle
        PaintScaleLegend psl2 = new PaintScaleLegend(legendPaintScale2, scaleAxis2);
        psl2.setAxisOffset(5.0);
        psl2.setPosition(RectangleEdge.LEFT);
        psl2.setMargin(new RectangleInsets(8, 1, 40, 1));
        psl2.setStripWidth(0);
        psl2.setStripOutlineVisible(false);
        chart.addSubtitle(psl2);
    }

    return chart;
}

From source file:loci.slim.ui.ExcitationGraph.java

/**
 * Creates the chart//from w  w  w  . jav a  2s  .  c  om
 *
 * @param bins number of bins
 * @param timeInc time increment per bin
 * @param data fitted data
 * @return the chart
 */
JFreeChart createChart(final int bins, final double timeInc, final double[] values) {

    // create chart data
    createDataset(bins, timeInc, values);

    // make a horizontal axis
    final NumberAxis timeAxis = new NumberAxis(TIME_AXIS_LABEL);
    timeAxis.setLabel(UNITS_LABEL);
    timeAxis.setRange(0.0, (bins - 1) * timeInc);

    // make a vertical axis
    NumberAxis photonAxis;
    if (_logarithmic) {
        photonAxis = new LogarithmicAxis(PHOTON_AXIS_LABEL);
    } else {
        photonAxis = new NumberAxis(PHOTON_AXIS_LABEL);
    }

    // make an excitation plot
    final XYSplineRenderer excitationRenderer = new XYSplineRenderer();
    excitationRenderer.setSeriesShapesVisible(0, false);
    excitationRenderer.setSeriesPaint(0, EXCITATION_COLOR);

    _excitationPlot = new XYPlot(_excitationDataset, timeAxis, photonAxis, excitationRenderer);
    _excitationPlot.setDomainCrosshairVisible(true);
    _excitationPlot.setRangeCrosshairVisible(true);

    // now make the top level JFreeChart
    final JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, _excitationPlot, true);
    chart.removeLegend();

    return chart;
}