jfellipsepoint.java
来自「用Java开发的、实现类似Visio功能的应用程序源码」· Java 代码 · 共 176 行
JAVA
176 行
/**
* $Id:JFEllipsePoint.java $
*
* Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All rights reserved. *
*/
package com.jfimagine.jfgraph.geom;
import com.jfimagine.jfgraph.geom.Angle;
import com.jfimagine.jfgraph.geom.JFVector;
/**
* JFEllipsePoint class. This class is an assistant class used to represent
* a certain position on an ellispe.
*
* @author CookieMaker
*
* @version $Revision: 1.00 $
*/
public class JFEllipsePoint extends JFPoint {
/**
* a target side type is the type of the rectangle's side that the radiant line from center to this point intersects.
* note: the RECTANGLE means the outer rectangle of this ellipse.
*/
private int m_targetSideType=0;
/**
* a target point is the point that the radiant line from center to this point intersects the outer rectangle.
*/
private JFPoint m_targetPoint =new JFPoint();
/**
* Get the target side type of current point.
*
* @return The target side type.
*
*/
public int getTargetSideType(){
return m_targetSideType;
}
/**
* Set the target side type of current point.
*
* @param targetSideType A new target side type
*
*/
public void setTargetSideType(int targetSideType){
m_targetSideType =targetSideType;
}
/**
* Get target point on one side of the outer rectangle.
*
* @return The target point on one side of the outer rectangle.
*
*/
public JFPoint getTargetPoint(){
return m_targetPoint;
}
/**
* Set value of current JFEllipsePoint.
*
* @param val A new JFEllipsePoint object.
*
*/
public void setValue(JFEllipsePoint pnt){
if (pnt==null)
return;
super.setValue(pnt.getX(),pnt.getY());
m_targetSideType =pnt.getTargetSideType();
m_targetPoint.setValue(pnt.getTargetPoint());
}
/**
* Constructor for JFEllipsePoint.
* Default to 0 for x and y coordinates.
*
*/
public JFEllipsePoint(){
}
/**
* Constructor for JFEllipsePoint.
*
* @param pnt A JFEllipsePoint.
*
*/
public JFEllipsePoint(JFEllipsePoint pnt){
setValue(pnt);
}
/**
* Convert this object to String
*
* @return An string represents the content of the object
*
*/
public String toString(){
StringBuffer buf =new StringBuffer();
buf.append(super.toString());
buf.append(";targetSideType="); buf.append(m_targetSideType);
buf.append(";targetPoint="); buf.append(m_targetPoint);
return buf.toString();
}
/**
* Creates a new object of the same class and with the same contents as this object.
*
* @return A clone of this instance.
*
*/
public Object clone() throws CloneNotSupportedException{
try{
return new JFEllipsePoint(this);
}catch(Exception e){
throw new CloneNotSupportedException(e.getMessage());
}
}
/**
* Returns the hashcode for this Object.
*
* @return hash code for this Point2D.
*
*/
public int hashCode(){
return super.hashCode() ^
m_targetSideType ^
m_targetPoint.hashCode();
}
/**
* Determines whether or not two objects are equal.
*
* @param obj an object to be compared with this object
* @param analog True if use integer type to compare two points,False use double.
*
* @return true if the object to be compared is an instance of Port and has the same values; false otherwise.
*
*/
public boolean equals(Object obj, boolean analog){
if (super.equals(obj,analog))
return true;
if (obj == this)
return true;
if (!(obj instanceof JFEllipsePoint))
return false;
JFEllipsePoint pnt =(JFEllipsePoint)obj;
return m_targetSideType==pnt.getTargetSideType() &&
m_targetPoint.equals(pnt.getTargetPoint(),analog);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?