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

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

Introduction

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

Prototype

public void setTickLabelsVisible(boolean flag) 

Source Link

Document

Sets the flag that determines whether or not the tick labels are visible and sends an AxisChangeEvent to all registered listeners.

Usage

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;/*ww w .  ja v  a  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);

    }

}