jfpointnode.java
来自「用Java开发的、实现类似Visio功能的应用程序源码」· Java 代码 · 共 183 行
JAVA
183 行
/**
* $Id:JFPointNode.java $
*
* Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All rights reserved. *
*/
package com.jfimagine.jfgraph.geom;
import com.jfimagine.jfgraph.geom.JFPoint;
/**
* JFPointNode class. A point class used to represents a node of a Regular Line or poly line.
*
*
* @author CookieMaker
*
* @version $Revision: 1.00 $
*/
public class JFPointNode extends JFPoint{
/** An END POINT point node type that the node is the beginning or end point or corner of the whole line*/
public static final int NODETYPE_END =0;
/** An MIDDLE POINT point node type that the node is on the middle of one line segment*/
public static final int NODETYPE_MIDDLE =1;
/** An SUB MIDDLE POINT point node type that the node is on the middle of corner point and middle point*/
public static final int NODETYPE_SUBMIDDLE =2;
/**
* A node type variable.
*/
private int m_nodeType =NODETYPE_END;
/**
* Getter for node type
* @return the node type.
*/
public int getNodeType(){
return m_nodeType;
}
/**
* Setter for node type
* @param nodeType the node type.
*/
public void setNodeType(int nodeType){
m_nodeType =nodeType;
}
/**
* Set value of current JFPointNode.
*
* @param val A new JFPoint object.
*
*/
public void setValue(JFPointNode node){
super.setValue(node);
m_nodeType =node.getNodeType();
}
/**
* Set value of current JFPointNode.
*
* @param x, y A new JFPoint coordinates.
*
* @param nodeType A new node type.
*/
public void setValue(double x, double y, int nodeType){
super.setValue(x,y);
m_nodeType =nodeType;
}
/**
* Constructor for JFPoint.
* Default to 0 for x and y coordinates.
*
*/
public JFPointNode(){
}
/**
* Constructor for JFPoint.
*
* @param x X coordiate.
*
* @param y Y coordiate.
*
* @param nodeType A new node type.
*
*/
public JFPointNode(double x, double y, int nodeType){
setValue(x,y,nodeType);
}
/**
* Constructor for JFPoint.
*
* @param pnt A JFPoint.
*
* @param nodeType A new node type.
*/
public JFPointNode(JFPoint pnt, int nodeType){
setValue(pnt.getX(),pnt.getY(),nodeType);
}
/**
* Constructor for JFPoint.
*
* @param node A JFPointNode object.
*/
public JFPointNode(JFPointNode node){
setValue(node);
}
/**
* 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(";nodeType="); buf.append(m_nodeType);
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 JFPointNode(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_nodeType;
}
/**
* Determines whether or not two objects are equal.
*
* @param obj an object to be compared with this object
*
* @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){
if (obj == this)
return true;
if (!super.equals(obj))
return false;
if (!(obj instanceof JFPointNode))
return false;
JFPointNode node =(JFPointNode)obj;
return (m_nodeType==node.getNodeType());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?