📄 rectangleedge.java
字号:
/* ======================================
* JFreeChart : a free Java chart library
* ======================================
*
* Project Info: http://www.jfree.org/jfreechart/index.html
* Project Lead: David Gilbert (david.gilbert@object-refinery.com);
*
* (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* -------------
* RectangleEdge
* -------------
* (C) Copyright 2003 by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* $Id: RectangleEdge.java,v 1.2 2003/07/24 11:14:13 mungady Exp $
*
* Changes:
* --------
* 14-Jul-2003 (DG);
*/
package org.jfree.ui;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;
/**
* Used to indicate the edge of a rectangle.
*
* @author David Gilbert
*/
public class RectangleEdge implements Serializable {
/** Top. */
public static final RectangleEdge TOP = new RectangleEdge("RectangleEdge.TOP");
/** Bottom. */
public static final RectangleEdge BOTTOM = new RectangleEdge("RectangleEdge.BOTTOM");
/** Left. */
public static final RectangleEdge LEFT = new RectangleEdge("RectangleEdge.LEFT");
/** Right. */
public static final RectangleEdge RIGHT = new RectangleEdge("RectangleEdge.RIGHT");
/** The name. */
private String name;
/**
* Private constructor.
*
* @param name the name.
*/
private RectangleEdge(String name) {
this.name = name;
}
/**
* Returns a string representing the object.
*
* @return The string.
*/
public String toString() {
return this.name;
}
/**
* Returns <code>true</code> if this object is equal to the specified object, and
* <code>false</code> otherwise.
*
* @param o the other object.
*
* @return A boolean.
*/
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof RectangleEdge)) {
return false;
}
final RectangleEdge order = (RectangleEdge) o;
if (!this.name.equals(order.toString())) {
return false;
}
return true;
}
/**
* Returns <code>true</code> if the edge is <code>TOP</code> or <code>BOTTOM</code>, and
* <code>false</code> otherwise.
*
* @param edge the edge.
*
* @return A boolean.
*/
public static boolean isTopOrBottom(RectangleEdge edge) {
return (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM);
}
/**
* Returns <code>true</code> if the edge is <code>LEFT</code> or <code>RIGHT</code>, and
* <code>false</code> otherwise.
*
* @param edge the edge.
*
* @return A boolean.
*/
public static boolean isLeftOrRight(RectangleEdge edge) {
return (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT);
}
/**
* Returns the opposite edge.
*
* @param edge an edge.
*
* @return The opposite edge.
*/
public static RectangleEdge opposite(RectangleEdge edge) {
RectangleEdge result = null;
if (edge == RectangleEdge.TOP) {
result = RectangleEdge.BOTTOM;
}
else if (edge == RectangleEdge.BOTTOM) {
result = RectangleEdge.TOP;
}
else if (edge == RectangleEdge.LEFT) {
result = RectangleEdge.RIGHT;
}
else if (edge == RectangleEdge.RIGHT) {
result = RectangleEdge.LEFT;
}
return result;
}
/**
* Returns the x or y coordinate of the specified edge.
*
* @param rectangle the rectangle.
* @param edge the edge.
*
* @return The coordinate.
*/
public static double coordinate(Rectangle2D rectangle, RectangleEdge edge) {
double result = 0.0;
if (edge == RectangleEdge.TOP) {
result = rectangle.getMinY();
}
else if (edge == RectangleEdge.BOTTOM) {
result = rectangle.getMaxY();
}
else if (edge == RectangleEdge.LEFT) {
result = rectangle.getMinX();
}
else if (edge == RectangleEdge.RIGHT) {
result = rectangle.getMaxX();
}
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -