/*
 * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
 */
package ch.psi.plot;

import ch.psi.plot.Plot.AxisId;

/**
 *
 */
public class Axis {

    PlotBase plot;
    AxisId id;

    Axis(String label, PlotBase plot, AxisId id) {
        this.plot = plot;
        this.id = id;
        if (label == null) {
            label = "";
        }
        this.label = label;
    }

    String label = "";

    public String getLabel() {
        return label;
    }

    public void setLabel(String value) {
        label = value;
        plot.onAxisLabelChanged(id);
    }

    double min;

    public double getMin() {
        return min;
    }

    public void setMin(double value) {
        min = value;
        plot.onAxisRangeChanged(id);
    }

    double max;

    public double getMax() {
        return max;
    }

    public void setMax(double value) {
        max = value;
        plot.onAxisRangeChanged(id);
    }

    public void setRange(double min, double max) {
        this.min = min;
        this.max = max;
        plot.onAxisRangeChanged(id);
    }

    public boolean isAutoRange() {
        return (max <= min);
    }

    public void setAutoRange() {
        setRange(0, 0);
    }

}
