⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 valueaxis.java

📁 jfreechart安装程序和使用说明
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     * selected from a range of standard tick units.
     *
     * @param flag  the new value of the flag.
     * @param notify  notify listeners?
     */
    public void setAutoTickUnitSelection(boolean flag, boolean notify) {

        if (this.autoTickUnitSelection != flag) {
            this.autoTickUnitSelection = flag;
            if (notify) {
                notifyListeners(new AxisChangeEvent(this));
            }
        }
    }

    /**
     * Returns the source for obtaining standard tick units for the axis.
     *
     * @return the source (possibly <code>null</code>).
     */
    public TickUnitSource getStandardTickUnits() {
        return this.standardTickUnits;
    }

    /**
     * Sets the source for obtaining standard tick units for the axis and sends an 
     * {@link AxisChangeEvent} to all registered listeners.  The axis will try to select the
     * smallest tick unit from the source that does not cause the tick labels to overlap (see 
     * also the {@link #setAutoTickUnitSelection(boolean)} method.
     *
     * @param source  the source for standard tick units (<code>null</code> permitted).
     */
    public void setStandardTickUnits(TickUnitSource source) {
        this.standardTickUnits = source;
        notifyListeners(new AxisChangeEvent(this));
    }
    
    /**
     * Converts a data value to a coordinate in Java2D space, assuming that the
     * axis runs along one edge of the specified dataArea.
     * <p>
     * Note that it is possible for the coordinate to fall outside the area.
     *
     * @param value  the data value.
     * @param area  the area for plotting the data.
     * @param edge  the edge along which the axis lies.
     *
     * @return the Java2D coordinate.
     */
    public abstract double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge);
    
    /**
     * Converts a length in data coordinates into the corresponding length in Java2D
     * coordinates.
     * 
     * @param length  the length.
     * @param area  the plot area.
     * @param edge  the edge along which the axis lies.
     * 
     * @return The length in Java2D coordinates.
     */
    public double lengthToJava2D(double length, Rectangle2D area, RectangleEdge edge) {
        double zero = valueToJava2D(0.0, area, edge);
        double l = valueToJava2D(length, area, edge);
        return Math.abs(l - zero);
    }

    /**
     * Converts a coordinate in Java2D space to the corresponding data value,
     * assuming that the axis runs along one edge of the specified dataArea.
     *
     * @param java2DValue  the coordinate in Java2D space.
     * @param area  the area in which the data is plotted.
     * @param edge  the edge along which the axis lies.
     *
     * @return the data value.
     */
    public abstract double java2DToValue(double java2DValue,
                                         Rectangle2D area,
                                         RectangleEdge edge);

    /**
     * Automatically sets the axis range to fit the range of values in the dataset.
     * Sometimes this can depend on the renderer used as well (for example, the
     * renderer may "stack" values, requiring an axis range greater than otherwise
     * necessary).
     */
    protected abstract void autoAdjustRange();

    /**
     * Centers the axis range about the specified value and sends an {@link AxisChangeEvent}
     * to all registered listeners.
     *
     * @param value  the center value.
     */
    public void centerRange(double value) {

        double central = this.range.getCentralValue();
        Range adjusted = new Range(
            this.range.getLowerBound() + value - central,
            this.range.getUpperBound() + value - central
        );
        setRange(adjusted);

    }

    /**
     * Increases or decreases the axis range by the specified percentage about the
     * central value and sends an {@link AxisChangeEvent} to all registered listeners.
     * <P>
     * To double the length of the axis range, use 200% (2.0).
     * To halve the length of the axis range, use 50% (0.5).
     *
     * @param percent  the resize factor.
     */
    public void resizeRange(double percent) {
        resizeRange(percent, this.range.getCentralValue());
    }

    /**
     * Increases or decreases the axis range by the specified percentage about the
     * specified anchor value and sends an {@link AxisChangeEvent} to all registered 
     * listeners.
     * <P>
     * To double the length of the axis range, use 200% (2.0).
     * To halve the length of the axis range, use 50% (0.5).
     *
     * @param percent  the resize factor.
     * @param anchorValue  the new central value after the resize.
     */
    public void resizeRange(double percent, double anchorValue) {

        if (percent > 0.0) {
            double halfLength = this.range.getLength() * percent / 2;
            Range adjusted = new Range(anchorValue - halfLength, anchorValue + halfLength);
            setRange(adjusted);
        }
        else {
            setAutoRange(true);
        }

    }
    
    /**
     * Zooms in on the current range.
     * 
     * @param lowerPercent  the new lower bound.
     * @param upperPercent  the new upper bound.
     */
    public void zoomRange(double lowerPercent, double upperPercent) {
        double start = this.range.getLowerBound();
        double length = this.range.getLength();
        Range adjusted = null;
        if (isInverted()) {
            adjusted = new Range(start + (length * (1 - upperPercent)), 
                                 start + (length * (1 - lowerPercent)));            
        }
        else {
            adjusted = new Range(start + length * lowerPercent, start + length * upperPercent);
        }
        setRange(adjusted);
    }

    /**
     * Returns the auto tick index.
     *
     * @return the auto tick index.
     */
    protected int getAutoTickIndex() {
        return this.autoTickIndex;
    }

    /**
     * Sets the auto tick index.
     *
     * @param index  the new value.
     */
    protected void setAutoTickIndex(int index) {
        this.autoTickIndex = index;
    }

    /**
     * Tests the axis for equality with an arbitrary object.
     *
     * @param obj  the object (<code>null</code> permitted).
     *
     * @return <code>true</code> or <code>false</code>.
     */
    public boolean equals(Object obj) {

        if (obj == null) {
            return false;
        }

        if (obj == this) {
            return true;
        }

        if (obj instanceof ValueAxis) {
            ValueAxis axis = (ValueAxis) obj;

        
            if (super.equals(obj)) {
                boolean b1 = (this.positiveArrowVisible == axis.positiveArrowVisible);
                boolean b2 = (this.negativeArrowVisible == axis.negativeArrowVisible);
                boolean b3 = (this.inverted == axis.inverted);
                boolean b4 = ObjectUtils.equal(this.range, axis.range);
                boolean b5 = (this.autoRange == axis.autoRange);
                boolean b6 = (this.autoRangeMinimumSize == axis.autoRangeMinimumSize);
                boolean b7 = (Math.abs(this.upperMargin - axis.upperMargin) < 0.000001);
                boolean b8 = (Math.abs(this.lowerMargin - axis.lowerMargin) < 0.000001);
                boolean b9 = (Math.abs(this.fixedAutoRange - axis.fixedAutoRange) < 0.000001);
                boolean b10 = (this.autoTickUnitSelection == axis.autoTickUnitSelection);
                boolean b11 = ObjectUtils.equal(this.standardTickUnits, axis.standardTickUnits);
                boolean b12 = (this.verticalTickLabels == axis.verticalTickLabels);
                return b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12;
            }
            else {
                return false;
            }

        }

        return false;

    }
    
    /**
     * Returns a clone of the object.
     * 
     * @return A clone.
     * 
     * @throws CloneNotSupportedException if some component of the axis does not support cloning.
     */
    public Object clone() throws CloneNotSupportedException {
        ValueAxis clone = (ValueAxis) super.clone();
        return clone;
    }
    
    /**
     * Provides serialization support.
     *
     * @param stream  the output stream.
     *
     * @throws IOException  if there is an I/O error.
     */
    private void writeObject(ObjectOutputStream stream) throws IOException {

        stream.defaultWriteObject();
        SerialUtilities.writeShape(this.upArrow, stream);
        SerialUtilities.writeShape(this.downArrow, stream);
        SerialUtilities.writeShape(this.leftArrow, stream);
        SerialUtilities.writeShape(this.rightArrow, stream);

    }

    /**
     * Provides serialization support.
     *
     * @param stream  the input stream.
     *
     * @throws IOException  if there is an I/O error.
     * @throws ClassNotFoundException  if there is a classpath problem.
     */
    private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {

        stream.defaultReadObject();
        this.upArrow = SerialUtilities.readShape(stream);
        this.downArrow = SerialUtilities.readShape(stream);
        this.leftArrow = SerialUtilities.readShape(stream);
        this.rightArrow = SerialUtilities.readShape(stream);

    }
    
    //// DEPRECATED METHODS ///////////////////////////////////////////////////////////////////////
    
    /**
     * Returns the minimum value for the axis.
     *
     * @return the minimum value for the axis.
     * 
     * @deprecated Use getLowerBound().
     */
    public double getMinimumAxisValue() {
        return getLowerBound();
    }

    /**
     * Sets the minimum value for the axis.
     * <P>
     * Registered listeners are notified that the axis has been modified.
     *
     * @param min  the new minimum.
     * 
     * @deprecated Use setLowerBound(...).
     */
    public void setMinimumAxisValue(double min) {
        setLowerBound(min);
    }

    /**
     * Returns the maximum value for the axis.
     *
     * @return the maximum value.
     * 
     * @deprecated Use getUpperBound().
     */
    public double getMaximumAxisValue() {
        return getUpperBound();
    }

    /**
     * Sets the maximum value for the axis.
     * <P>
     * Registered listeners are notified that the axis has been modified.
     *
     * @param max  the new maximum.
     * 
     * @deprecated Use setUpperBound(...).
     */
    public void setMaximumAxisValue(double max) {
        setUpperBound(max);
    }
    
    /**
     * Converts a data value to a coordinate in Java2D space, assuming that the
     * axis runs along one edge of the specified dataArea.
     * <p>
     * Note that it is possible for the coordinate to fall outside the plotArea.
     *
     * @param value  the data value.
     * @param area  the area for plotting the data.
     * @param edge  the edge along which the axis lies.
     *
     * @return The Java2D coordinate.
     * 
     * @deprecated Use valueToJava2D instead.
     */
    public double translateValueToJava2D(double value,
            Rectangle2D area,
            RectangleEdge edge) {
        return valueToJava2D(value, area, edge);   
    }
    
    /**
     * Converts a coordinate in Java2D space to the corresponding data value,
     * assuming that the axis runs along one edge of the specified dataArea.
     *
     * @param java2DValue  the coordinate in Java2D space.
     * @param dataArea  the area in which the data is plotted.
     * @param edge  the edge along which the axis lies.
     *
     * @return the data value.
     * 
     * @deprecated Use translateJava2DToValue(double, ...).
     */
    public double translateJava2DtoValue(float java2DValue,
            Rectangle2D dataArea,
            RectangleEdge edge) {
        
        return translateJava2DToValue(java2DValue, dataArea, edge);
        
    }
    
    /**
     * Converts a coordinate in Java2D space to the corresponding data value,
     * assuming that the axis runs along one edge of the specified area.
     *
     * @param java2DValue  the coordinate in Java2D space.
     * @param area  the area in which the data is plotted.
     * @param edge  the edge along which the axis lies.
     *
     * @return the data value.
     * 
     * @deprecated Use java2DToValue instead.
     */
    public double translateJava2DToValue(double java2DValue,
                                         Rectangle2D area,
                                         RectangleEdge edge) {
        return java2DToValue(java2DValue, area, edge);   
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -