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

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

Introduction

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

Prototype

public String getLabel() 

Source Link

Document

Returns the label for the axis.

Usage

From source file:MWC.GUI.JFreeChart.BearingRateFormatter.java

public void format(final XYPlot thePlot) {
    final NumberAxis theAxis = (NumberAxis) thePlot.getRangeAxis();
    theAxis.setRange(-180, +180);//  ww  w. jav a2s.c  o m
    theAxis.setLabel("(Left)    " + theAxis.getLabel() + "     (Right)");
}

From source file:MWC.GUI.JFreeChart.RelBearingFormatter.java

public void format(final XYPlot thePlot) {
    final NumberAxis theAxis = (NumberAxis) thePlot.getRangeAxis();
    theAxis.setRange(-180, +180);/* w  w  w . ja  v  a 2  s .  c o  m*/
    theAxis.setLabel("(Red)    " + theAxis.getLabel() + "     (Green)");

    // create some tick units suitable for degrees
    theAxis.setStandardTickUnits(CourseFormatter.getDegreeTickUnits());
    theAxis.setAutoTickUnitSelection(true);
}

From source file:jmbench.plots.OperationsVersusSizePlot.java

public void setLogScale(boolean range, boolean domain) {

    if (domain) {
        NumberAxis axis = (NumberAxis) plot.getDomainAxis();
        axis = new LogarithmicAxis(axis.getLabel());
        plot.setDomainAxis(axis);//  w ww . j  av a  2  s . com
    }

    if (range) {
        NumberAxis axis = (NumberAxis) plot.getRangeAxis();
        axis = new LogarithmicAxis(axis.getLabel());
        plot.setRangeAxis(axis);
    }
}

From source file:org.cds06.speleograph.data.fileio.SpeleoFileWriter.java

private Integer writeHeaders(List<Series> series, Integer[][] columns) {
    ArrayList<NumberAxis> axes = new ArrayList<>();
    for (Series s : series) {
        NumberAxis axis = s.getAxis();
        if (axes.contains(axis))
            continue;
        axes.add(axis);/*from  w  w w  .  j ava 2 s  .  c  o m*/
        int id = axes.indexOf(axis);
        boolean typeAxis = axis.equals(s.getType().getAxis());
        try {
            write("axis", Integer.toString(id), '"' + axis.getLabel() + '"',
                    DecimalFormat.getInstance().format(axis.getLowerBound()),
                    DecimalFormat.getInstance().format(axis.getUpperBound()), "type:" + (typeAxis ? "1" : "0"));
        } catch (Exception e) {
            log.error("Can not write axis to file", e);
        }
    }
    write("date", "", Integer.toString(allocatedColumns), "d/M/y H:m:s");
    allocatedColumns++;
    for (Series s : series) {
        String[] seriesDescriptor = { Integer.toString(allocatedColumns), s.getType().getName(),
                s.getType().getUnit() };
        if (s.isMinMax()) {
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "min-max:1"); // NON-NLS
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "min:" + Integer.toString(allocatedColumns)); // NON-NLS
            seriesDescriptor = ArrayUtils.add(seriesDescriptor,
                    "max:" + Integer.toString(allocatedColumns + 1)); // NON-NLS
            columns[series.indexOf(s)] = new Integer[] { allocatedColumns, allocatedColumns + 1 };
            allocatedColumns++;
            allocatedColumns++;
        } else {
            columns[series.indexOf(s)] = new Integer[] { allocatedColumns };
            allocatedColumns++;
        }
        if (s.isShow())
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "show:1"); // NON-NLS
        if (s.getColor() != null)
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "color:" + s.getColor().getRGB()); // NON-NLS
        if (s.isMinMax())
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "stepped:1"); // NON-NLS
        if (s.getStyle() != null) {
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "style:" + s.getStyle().toString()); // NON-NLS
        }
        if (s.isNameHumanSet()) {
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "name:" + s.getName()); // NON-NLS
        }
        seriesDescriptor = ArrayUtils.add(seriesDescriptor, "axis:" + axes.indexOf(s.getAxis()));
        write(seriesDescriptor);
    }
    return allocatedColumns;
}

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

@Override
public void resetAxes(final IScope scope) {
    final CategoryPlot pp = (CategoryPlot) this.chart.getPlot();
    NumberAxis rangeAxis = (NumberAxis) ((CategoryPlot) this.chart.getPlot()).getRangeAxis();
    if (getY_LogScale(scope)) {
        final LogarithmicAxis logAxis = new LogarithmicAxis(rangeAxis.getLabel());
        logAxis.setAllowNegativesFlag(true);
        ((CategoryPlot) this.chart.getPlot()).setRangeAxis(logAxis);
        rangeAxis = logAxis;// w  w  w  .  j a  va2  s.  c o  m
    }

    if (!useyrangeinterval && !useyrangeminmax) {
        rangeAxis.setAutoRange(true);
    }

    if (this.useyrangeinterval) {
        rangeAxis.setFixedAutoRange(yrangeinterval);
        rangeAxis.setAutoRangeMinimumSize(yrangeinterval);
        rangeAxis.setAutoRange(true);

    }
    if (this.useyrangeminmax) {
        rangeAxis.setRange(yrangemin, yrangemax);

    }

    resetDomainAxis(scope);

    final CategoryAxis domainAxis = ((CategoryPlot) this.chart.getPlot()).getDomainAxis();

    pp.setDomainGridlinePaint(axesColor);
    pp.setRangeGridlinePaint(axesColor);
    pp.setRangeCrosshairVisible(true);

    pp.getRangeAxis().setAxisLinePaint(axesColor);
    pp.getRangeAxis().setLabelFont(getLabelFont());
    pp.getRangeAxis().setTickLabelFont(getTickFont());
    if (textColor != null) {
        pp.getRangeAxis().setLabelPaint(textColor);
        pp.getRangeAxis().setTickLabelPaint(textColor);
    }
    if (getYTickUnit(scope) > 0) {
        ((NumberAxis) pp.getRangeAxis()).setTickUnit(new NumberTickUnit(getYTickUnit(scope)));
    }

    if (getYLabel(scope) != null && !getYLabel(scope).isEmpty()) {
        pp.getRangeAxis().setLabel(getYLabel(scope));
    }
    if (this.series_label_position.equals("yaxis")) {
        pp.getRangeAxis().setLabel(this.getChartdataset().getDataSeriesIds(scope).iterator().next());
        chart.getLegend().setVisible(false);
    }

    if (getXLabel(scope) != null && !getXLabel(scope).isEmpty()) {
        pp.getDomainAxis().setLabel(getXLabel(scope));
    }

    if (this.useSubAxis) {
        for (final String serieid : chartdataset.getDataSeriesIds(scope)) {
            ((SubCategoryAxis) domainAxis).addSubCategory(serieid);
        }

    }
    if (!this.getYTickLineVisible(scope)) {
        pp.setDomainGridlinesVisible(false);
    }

    if (!this.getYTickLineVisible(scope)) {
        pp.setRangeCrosshairVisible(false);

    }

    if (!this.getYTickValueVisible(scope)) {
        pp.getRangeAxis().setTickMarksVisible(false);
        pp.getRangeAxis().setTickLabelsVisible(false);

    }

}

From source file:br.upe.ecomp.dosa.controller.chart.FileBoxplotChartManager.java

private JFreeChart createChart(String title, String xLabel, String yLabel, BoxAndWhiskerCategoryDataset dataset,
        boolean logarithmicYAxis) {

    final CategoryAxis xAxis = new CategoryAxis("Sample");
    final NumberAxis yAxis;
    if (logarithmicYAxis) {
        yAxis = new LogarithmicAxis("Fitness (Log10)");
        ((LogarithmicAxis) yAxis).setExpTickLabelsFlag(true);
    } else {/*from   w w w .  j a  v a2  s.c  o m*/
        yAxis = new NumberAxis("Fitness");
    }
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setAutoRange(true);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(true);
    renderer.setBaseCreateEntities(true);
    // renderer.setArtifactPaint(Color.green);
    renderer.setBaseOutlinePaint(Color.blue);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(title, xAxis.getLabel(), yAxis.getLabel(),
            dataset, true);
    final CategoryPlot plot = chart.getCategoryPlot();// new CategoryPlot(dataset, xAxis, yAxis,
                                                      // renderer);
    plot.setBackgroundPaint(Color.white);
    // chart.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setRenderer(renderer);
    plot.setRangeAxis(yAxis);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}

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

@Override
public void resetAxes(final IScope scope) {
    NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis();

    if (getX_LogScale(scope)) {
        LogarithmicAxis logAxis = new LogarithmicAxis(domainAxis.getLabel());
        logAxis.setAllowNegativesFlag(true);
        ((XYPlot) this.chart.getPlot()).setDomainAxis(logAxis);
        domainAxis = logAxis;// ww w  . j  av a2 s .c  om
    }
    if (getY_LogScale(scope)) {
        LogarithmicAxis logAxis = new LogarithmicAxis(rangeAxis.getLabel());
        logAxis.setAllowNegativesFlag(true);
        ((XYPlot) this.chart.getPlot()).setRangeAxis(logAxis);
        rangeAxis = logAxis;
    }
    if (!usexrangeinterval && !usexrangeminmax) {
        //         domainAxis.setAutoRangeMinimumSize(0.5);
        //         domainAxis.setAutoRange(true);
    }

    if (this.usexrangeinterval) {
        domainAxis.setFixedAutoRange(xrangeinterval);
        domainAxis.setAutoRangeMinimumSize(xrangeinterval);
        domainAxis.setAutoRange(true);
    }
    if (this.usexrangeminmax) {
        domainAxis.setRange(xrangemin, xrangemax);
    }

    if (!useyrangeinterval && !useyrangeminmax) {
        //      rangeAxis.setAutoRangeMinimumSize(0.5);
        //      rangeAxis.setAutoRange(true);
    }

    if (this.useyrangeinterval) {
        rangeAxis.setFixedAutoRange(yrangeinterval);
        rangeAxis.setAutoRangeMinimumSize(yrangeinterval);
        rangeAxis.setAutoRange(true);
    }
    if (this.useyrangeminmax) {
        rangeAxis.setRange(yrangemin, yrangemax);
    }
    if (this.series_label_position.equals("none")) {
        if ((this.chart).getLegend() != null)
            (this.chart).getLegend().setVisible(false);
    }
    if (!this.getXTickLineVisible(scope)) {
        ((XYPlot) this.chart.getPlot()).setDomainGridlinesVisible(false);

    }
    if (!this.getYTickLineVisible(scope)) {
        ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(false);

    }

}

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

private void createChart() {

    //String xLabel = factor1.toString();
    String xLabel = factor1AxisLabel;
    //String yLabel = factor2.toString();
    String yLabel = factor2AxisLabel;

    clinicalChart = ChartFactory.createScatterPlot("Clinical Plot", xLabel, yLabel, null,
            PlotOrientation.VERTICAL, true, true, false);

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

    buildLegend();/* ww w .j  a v  a  2  s .  c o  m*/

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

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

    //should determine axis range using datapoints.

    domainAxis.setAutoRangeIncludesZero(false);

    //get domain and range of the axis.
    DataRange domainAxisLimits = getDataRange(dataPoints, factor1, true);
    DataRange rangeAxisLimits = getDataRange(dataPoints, factor2, true);

    //domainAxis.setRange(domainAxisLimits.getMinRange(), domainAxisLimits.getMaxRange());
    //rangeAxis.setRange(rangeAxisLimits.getMinRange(), rangeAxisLimits.getMaxRange());

    double domainMax = Math.max(100.0, domainAxisLimits.getMaxRange()) + 5.0;
    double rangeMax = Math.max(100.0, rangeAxisLimits.getMaxRange()) + 5.0;

    domainAxis.setRange(0.0, domainMax);
    rangeAxis.setRange(0.0, rangeMax);

    System.out.println("domainAxis=" + domainAxis.getLabel());
    System.out.println("rangeAxis=" + rangeAxis.getLabel());

    createGlyphsAndAddToPlot(plot);
}

From source file:com.chart.SwingChart.java

/**
 * Set lower and upper limits for an ordinate
 * @param axis Axis to configure/*from   w  ww  . j  a  v  a2  s . c o  m*/
 */
void setOrdinateRange(final NumberAxis axis) {
    axis.setAutoRange(false);
    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(0, 10, 0, 10));
    final TextField tfMax;
    final TextField tfMin;
    final TextField tfTick;
    final TextField tfFuente;
    grid.add(new Label("Axis"), 0, 0);
    grid.add(new Label(axis.getLabel()), 1, 0);
    grid.add(new Label("Lower"), 0, 1);
    grid.add(tfMin = new TextField(), 1, 1);
    grid.add(new Label("Upper"), 0, 2);
    grid.add(tfMax = new TextField(), 1, 2);
    grid.add(new Label("Space"), 0, 3);
    grid.add(tfTick = new TextField(), 1, 3);

    tfMin.setText(String.valueOf(axis.getLowerBound()));
    tfMax.setText(String.valueOf(axis.getUpperBound()));
    tfTick.setText(String.valueOf(axis.getTickUnit().getSize()));

    new PseudoModalDialog(skeleton, grid, true) {
        @Override
        public boolean validation() {
            axis.setLowerBound(Double.valueOf(tfMin.getText()));
            axis.setUpperBound(Double.valueOf(tfMax.getText()));
            axis.setTickUnit(new NumberTickUnit(Double.valueOf(tfTick.getText())));
            return true;
        }
    }.show();

}

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

@Override
public void resetAxes(final IScope scope) {
    NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis();
    NumberAxis range2Axis = rangeAxis;//from  w  w w .j ava  2  s.  c  o  m
    boolean secondaxis = false;
    if (getUseSecondYAxis(scope)) {
        secondaxis = true;
        range2Axis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(1);
        if (range2Axis == null) {
            NumberAxis secondAxis = new NumberAxis("");
            ((XYPlot) this.chart.getPlot()).setRangeAxis(1, secondAxis);
            range2Axis = secondAxis;
            range2Axis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(1);
            range2Axis = formatYAxis(scope, range2Axis);

            ((XYPlot) this.chart.getPlot()).setRangeAxis(1, range2Axis);
        }
    }

    if (getX_LogScale(scope)) {
        LogarithmicAxis logAxis = new LogarithmicAxis(domainAxis.getLabel());
        logAxis.setAllowNegativesFlag(true);
        ((XYPlot) this.chart.getPlot()).setDomainAxis(logAxis);
        domainAxis = logAxis;
    }
    if (getY_LogScale(scope)) {
        LogarithmicAxis logAxis = new LogarithmicAxis(rangeAxis.getLabel());
        logAxis.setAllowNegativesFlag(true);
        logAxis = (LogarithmicAxis) formatYAxis(scope, logAxis);
        ((XYPlot) this.chart.getPlot()).setRangeAxis(logAxis);
        rangeAxis = logAxis;
    }
    if (secondaxis) {
        if (getY2_LogScale(scope)) {
            LogarithmicAxis logAxis = new LogarithmicAxis(range2Axis.getLabel());
            logAxis.setAllowNegativesFlag(true);
            logAxis = (LogarithmicAxis) formatYAxis(scope, logAxis);
            ((XYPlot) this.chart.getPlot()).setRangeAxis(1, logAxis);
            range2Axis = logAxis;
        }

    }

    if (!getUseXRangeInterval(scope) && !getUseXRangeMinMax(scope)) {
        domainAxis.setAutoRange(true);
    }

    if (this.getUseXRangeInterval(scope)) {
        domainAxis.setFixedAutoRange(getXRangeInterval(scope));
        domainAxis.setAutoRangeMinimumSize(getXRangeInterval(scope));
        domainAxis.setAutoRange(true);

    }
    if (this.getUseXRangeMinMax(scope)) {
        domainAxis.setRange(getXRangeMin(scope), getXRangeMax(scope));

    }
    if (this.getXTickLineVisible(scope)) {
        ((XYPlot) this.chart.getPlot()).setDomainGridlinePaint(this.tickColor);
        if (getXTickUnit(scope) > 0) {
            domainAxis.setTickUnit(new NumberTickUnit(getXTickUnit(scope)));
            ((XYPlot) this.chart.getPlot()).setDomainGridlinesVisible(true);
        } else
            ((XYPlot) this.chart.getPlot())
                    .setDomainGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue());

    } else {
        ((XYPlot) this.chart.getPlot()).setDomainGridlinesVisible(false);

    }

    if (!getUseYRangeInterval(scope) && !getUseYRangeMinMax(scope)) {
        rangeAxis.setAutoRange(true);
    }

    if (this.getUseYRangeInterval(scope)) {
        rangeAxis.setFixedAutoRange(getYRangeInterval(scope));
        rangeAxis.setAutoRangeMinimumSize(getYRangeInterval(scope));
        rangeAxis.setAutoRange(true);
    }
    if (this.getUseYRangeMinMax(scope)) {
        rangeAxis.setRange(getYRangeMin(scope), getYRangeMax(scope));

    }
    if (this.getYTickLineVisible(scope)) {
        ((XYPlot) this.chart.getPlot()).setRangeGridlinePaint(this.tickColor);
        if (getYTickUnit(scope) > 0) {
            rangeAxis.setTickUnit(new NumberTickUnit(getYTickUnit(scope)));
            ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(true);
        } else
            ((XYPlot) this.chart.getPlot())
                    .setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue());

    } else {
        ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(false);

    }

    if (secondaxis) {
        if (!getUseY2RangeInterval(scope) && !getUseY2RangeMinMax(scope)) {
            range2Axis.setAutoRange(true);
        }

        if (this.getUseY2RangeInterval(scope)) {
            range2Axis.setFixedAutoRange(getY2RangeInterval(scope));
            range2Axis.setAutoRangeMinimumSize(getY2RangeInterval(scope));
            range2Axis.setAutoRange(true);
        }
        if (this.getUseY2RangeMinMax(scope)) {
            range2Axis.setRange(getY2RangeMin(scope), getY2RangeMax(scope));

        }
        if (this.getYTickLineVisible(scope)) {
            ((XYPlot) this.chart.getPlot()).setRangeGridlinePaint(this.tickColor);
            if (getY2TickUnit(scope) > 0) {
                range2Axis.setTickUnit(new NumberTickUnit(getY2TickUnit(scope)));
                ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(true);
            } else
                ((XYPlot) this.chart.getPlot())
                        .setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue());

        } else {
            ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(false);

        }

    }

    if (getXLabel(scope) != null && !getXLabel(scope).isEmpty()) {
        domainAxis.setLabel(getXLabel(scope));
    }
    if (getYLabel(scope) != null && !getYLabel(scope).isEmpty()) {
        rangeAxis.setLabel(getYLabel(scope));
    }
    if (secondaxis) {
        if (getY2Label(scope) != null && !getY2Label(scope).isEmpty()) {
            range2Axis.setLabel(getY2Label(scope));
        }

    }
    if (this.series_label_position.equals("none")) {
        (this.chart).getLegend().setVisible(false);
    }
    if (!this.getXTickValueVisible(scope)) {
        domainAxis.setTickMarksVisible(false);
        domainAxis.setTickLabelsVisible(false);

    }

}