📄 abstractobject.java
字号:
/**
* $Id:AbstractObject.java $
*
* Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All rights reserved. *
*/
package com.jfimagine.jfgraph.shape.base;
import java.util.List;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import com.jfimagine.jfdom.Document;
import com.jfimagine.jfdom.Element;
import com.jfimagine.jfgraph.shape.base.JFVersion;
import com.jfimagine.utils.log.*;
/**
* Abstract object class. All classes that can be stored to and recovered from xml/binary file must instance/extend this abstract class.
*
* @author CookieMaker
*
* @version $Revision: 1.00 $
*/
public abstract class AbstractObject implements Cloneable{
/**
* A XML string tag represents the object id, an object id is unique in one layer
* when the object is a shape, or unique in one shape(when the object is a port or node)
*/
public static final String XML_OBJECTID ="objectId";
/**
* A XML string tag represents a new integer id, this integer id is used for
* customization purpose, you can manage your own objects by specify a meaningful
* integer id here.
*/
public static final String XML_INTID ="IntId";
/**
* A XML string tag represents a new string id, this string id is used for
* customization purpose, you can manage your own objects by specify a meaningful
* string id here.
*/
public static final String XML_STRID ="StringId";
/**
* A XML string tag represents the object type
*/
public static final String XML_OBJECTTYPE ="objectType";
/**
* A XML string tag represents the object name
*/
public static final String XML_NAME ="name";
/**
* A XML string tag represents the object description
*/
public static final String XML_DESC ="description";
/**an internal log utility*/
private JFLogger m_logger=JFLogManager.getLogger(this.getClass());
/**
* An object type used to identify the type of an object,
* especially you need to store such an object type into a DataOutputStream,
* so we can distinguish this object type from a DataInputStream, although
* we can easily use an instanceof or the other type casting ways
* to test an object type at runtime.
*/
private int m_objectType =0;
/**
* All AbstractObject should be stored as XML, so here we need a XML tag for each object.
*/
private String m_xmlTag="";
/**
* A value used to represents the object id.
* Ports should be attached to a shape,
* so each port should have an unique object id to identify them
*/
private int m_objectId =0;
/**
* a new integer id used for customization purpose
*/
private int m_intId =0;
/**
* a new string id used for customization purpose
*/
private String m_strId ="";
/**
* the object name
*/
private String m_name ="";
/**
* the object description
*/
private String m_desc ="";
/**
* Last error info within this object.
*/
protected String m_lastError="";
/** zoom scale.
* A zoom scale is internally used by almost all shapes.
* So we defiend zoom scale here for simplify class definitions.
*/
private double m_zoomScale =1.0;
/** get zoom scale
* @return the zoom scale
*/
public double getZoomScale(){
return m_zoomScale;
}
/** set zoom scale
* @param zoomScale A new zoom scale.
*/
public void setZoomScale(double zoomScale){
m_zoomScale =zoomScale;
}
/** if show current object's design info. e.g. ports, group's outline, etc.
*/
private boolean m_showDesign =true;
/** if current object is under show design state.
*/
public boolean isShowDesign(){
return m_showDesign;
}
/** set if show or hide current object's design info
*/
public void setShowDesign(boolean showDesign){
m_showDesign =showDesign;
}
/**
* An object type used to identify the type of an object,
* especially you need to store such an object type into a DataOutputStream,
* so we can distinguish this object type from a DataInputStream, although
* we can easily use an instanceof or the other type casting ways
* to test an object type at runtime.
* <p>
* GetObjectType used to get the type of current object
*
* @return The object Type.
*
*/
public int getObjectType(){
return m_objectType;
}
/**
* Set the type of current object
*
* @param objectType A new object type for current object.
*
*/
public void setObjectType(int objectType){
m_objectType =objectType;
}
/**
* a new integer id used for customization purpose,this integer id is used for
* customization purpose, you can manage your own objects by specify a meaningful
* integer id here.
*
* @return current customized integer id
*/
public int getIntId(){
return m_intId;
}
/**
* a new integer id used for customization purpose,this integer id is used for
* customization purpose, you can manage your own objects by specify a meaningful
* integer id here.
*
* @param intId A new customized integer id
*
*/
public void setIntId(int intId){
m_intId =intId;
}
/**
* a new string id used for customization purpose, this string id is used for
* customization purpose, you can manage your own objects by specify a meaningful
* string id here.
*
* @return Current customized string id.
*/
public String getStrId(){
return m_strId;
}
/**
* a new string id used for customization purpose, this string id is used for
* customization purpose, you can manage your own objects by specify a meaningful
* string id here.
*
* @param strId A new customized string id.
*/
public void setStrId(String strId){
if (strId==null)
strId ="";
m_strId =strId;
}
/**
* the object name
*/
public String getName(){
return m_name;
}
/**
* set the object name
*/
public void setName(String name){
if (name==null)
name ="";
m_name =name;
}
/**
* get the object description
*/
public String getDesc(){
return m_desc;
}
/**
* set the object description
*/
public void setDesc(String desc){
if (desc==null)
desc ="";
m_desc =desc;
}
/**
* All AbstractObject should be stored as XML, so here we need a XML tag for each object.
* <p>
* getXMLTag used to get current XML tag of this object.
*
* @return The object Type.
*
*/
public String getXMLTag(){
return m_xmlTag;
}
/**
* Set a xmlTag for this object.
*
* @param xmlTag XML tag for this object.
*
* @param objectType A new object type for current object.
*
*/
public void setXMLTag(String xmlTag){
m_xmlTag =xmlTag;
}
/**
* Get last error message within this object.
* @return The last error.
*
*/
public String getLastError(){
return m_lastError;
}
/**
* Set last error message within this object.
* @param lastError A new last error.
*
*/
public void setLastError(String lastError){
m_lastError =lastError;
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -