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

📄 categorylabelpositions.java

📁 提供JFreechart图表功能, 提供JFreechart图表功能,提供JFreechart图表功能
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * Default constructor.
     */
    public CategoryLabelPositions() {
        this.positionForAxisAtTop = new CategoryLabelPosition();
        this.positionForAxisAtBottom = new CategoryLabelPosition();
        this.positionForAxisAtLeft = new CategoryLabelPosition();
        this.positionForAxisAtRight = new CategoryLabelPosition();
    }
    
    /**
     * Creates a new position specification.
     * 
     * @param top  the label position info used when an axis is at the top 
     *             (<code>null</code> not permitted).
     * @param bottom  the label position info used when an axis is at the 
     *                bottom (<code>null</code> not permitted).
     * @param left  the label position info used when an axis is at the left 
     *              (<code>null</code> not permitted).
     * @param right  the label position info used when an axis is at the right 
     *               (<code>null</code> not permitted).
     */
    public CategoryLabelPositions(CategoryLabelPosition top,
                                  CategoryLabelPosition bottom,
                                  CategoryLabelPosition left,
                                  CategoryLabelPosition right) {
        
        if (top == null) {
            throw new IllegalArgumentException("Null 'top' argument.");
        }
        if (bottom == null) {
            throw new IllegalArgumentException("Null 'bottom' argument.");
        }
        if (left == null) {
            throw new IllegalArgumentException("Null 'left' argument.");
        }
        if (right == null) {
            throw new IllegalArgumentException("Null 'right' argument.");
        }
        
        this.positionForAxisAtTop = top;
        this.positionForAxisAtBottom = bottom;
        this.positionForAxisAtLeft = left;
        this.positionForAxisAtRight = right;
    
    }
    
    /**
     * Returns the category label position specification for an axis at the 
     * given location.
     * 
     * @param edge  the axis location.
     * 
     * @return The category label position specification.
     */
    public CategoryLabelPosition getLabelPosition(RectangleEdge edge) {
        CategoryLabelPosition result = null;
        if (edge == RectangleEdge.TOP) {
            result = this.positionForAxisAtTop;
        }
        else if (edge == RectangleEdge.BOTTOM) {
            result = this.positionForAxisAtBottom;
        }
        else if (edge == RectangleEdge.LEFT) {
            result = this.positionForAxisAtLeft;
        }
        else if (edge == RectangleEdge.RIGHT) {
            result = this.positionForAxisAtRight;
        }
        return result;
    }
    
    /**
     * Returns a new instance based on an existing instance but with the top 
     * position changed.
     * 
     * @param base  the base (<code>null</code> not permitted).
     * @param top  the top position (<code>null</code> not permitted).
     * 
     * @return A new instance (never <code>null</code>).
     */
    public static CategoryLabelPositions replaceTopPosition(
            CategoryLabelPositions base, CategoryLabelPosition top) {
        
        if (base == null) {
            throw new IllegalArgumentException("Null 'base' argument.");
        }
        if (top == null) {
            throw new IllegalArgumentException("Null 'top' argument.");
        }
        
        return new CategoryLabelPositions(
            top, 
            base.getLabelPosition(RectangleEdge.BOTTOM),
            base.getLabelPosition(RectangleEdge.LEFT),
            base.getLabelPosition(RectangleEdge.RIGHT)
        );
    }
    
    /**
     * Returns a new instance based on an existing instance but with the bottom
     * position changed.
     * 
     * @param base  the base (<code>null</code> not permitted).
     * @param bottom  the bottom position (<code>null</code> not permitted).
     * 
     * @return A new instance (never <code>null</code>).
     */
    public static CategoryLabelPositions replaceBottomPosition(
            CategoryLabelPositions base, CategoryLabelPosition bottom) {
        
        if (base == null) {
            throw new IllegalArgumentException("Null 'base' argument.");
        }
        if (bottom == null) {
            throw new IllegalArgumentException("Null 'bottom' argument.");
        }
        
        return new CategoryLabelPositions(
            base.getLabelPosition(RectangleEdge.TOP),
            bottom,
            base.getLabelPosition(RectangleEdge.LEFT),
            base.getLabelPosition(RectangleEdge.RIGHT)
        );
    }
    
    /**
     * Returns a new instance based on an existing instance but with the left 
     * position changed.
     * 
     * @param base  the base (<code>null</code> not permitted).
     * @param left  the left position (<code>null</code> not permitted).
     * 
     * @return A new instance (never <code>null</code>).
     */
    public static CategoryLabelPositions replaceLeftPosition(
            CategoryLabelPositions base, CategoryLabelPosition left) {
        
        if (base == null) {
            throw new IllegalArgumentException("Null 'base' argument.");
        }
        if (left == null) {
            throw new IllegalArgumentException("Null 'left' argument.");
        }
        
        return new CategoryLabelPositions(
            base.getLabelPosition(RectangleEdge.TOP),
            base.getLabelPosition(RectangleEdge.BOTTOM),
            left,
            base.getLabelPosition(RectangleEdge.RIGHT)
        );
    }
    
    /**
     * Returns a new instance based on an existing instance but with the right 
     * position changed.
     * 
     * @param base  the base (<code>null</code> not permitted).
     * @param right  the right position (<code>null</code> not permitted).
     * 
     * @return A new instance (never <code>null</code>).
     */
    public static CategoryLabelPositions replaceRightPosition(
            CategoryLabelPositions base, CategoryLabelPosition right) {
        
        if (base == null) {
            throw new IllegalArgumentException("Null 'base' argument.");
        }
        if (right == null) {
            throw new IllegalArgumentException("Null 'right' argument.");
        }
        
        return new CategoryLabelPositions(
            base.getLabelPosition(RectangleEdge.TOP),
            base.getLabelPosition(RectangleEdge.BOTTOM),
            base.getLabelPosition(RectangleEdge.LEFT),
            right
        );
    }
    
    /**
     * Returns <code>true</code> if this object is equal to the specified 
     * object, and <code>false</code> otherwise.
     *
     * @param obj  the other object.
     *
     * @return A boolean.
     */
    public boolean equals(Object obj) {

        if (this == obj) {
            return true;
        }
        if (!(obj instanceof CategoryLabelPositions)) {
            return false;
        }

        CategoryLabelPositions that = (CategoryLabelPositions) obj;
        if (!this.positionForAxisAtTop.equals(that.positionForAxisAtTop)) {
            return false;
        }
        if (!this.positionForAxisAtBottom.equals(
                that.positionForAxisAtBottom)) {
            return false;
        }
        if (!this.positionForAxisAtLeft.equals(that.positionForAxisAtLeft)) {
            return false;
        }
        if (!this.positionForAxisAtRight.equals(that.positionForAxisAtRight)) {
            return false;
        }
  
        return true;

    }
    
    /**
     * Returns a hash code for this object.
     * 
     * @return A hash code.
     */
    public int hashCode() {
        int result = 19;
        result = 37 * result + this.positionForAxisAtTop.hashCode();
        result = 37 * result + this.positionForAxisAtBottom.hashCode();
        result = 37 * result + this.positionForAxisAtLeft.hashCode();
        result = 37 * result + this.positionForAxisAtRight.hashCode();
        return result;
    }
}

⌨️ 快捷键说明

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