JavaView® v2.00.008

jv.object
Class PsObject

java.lang.Object
  |
  +--jv.object.PsObject
All Implemented Interfaces:
java.lang.Cloneable, PsUpdateIf, java.io.Serializable
Direct Known Subclasses:
MyClass, PdColor, PgBndConstraint, PgDomainDescr, PgFem, PgFrame, PgGeometry, PgMacroPatch, PgPolygonOnElementSet, PgTexture, PgUtil, PgVertexStar, PjProject, PnEnergyMinimizer, PnExplodePolytope, PnFunction, PnGeodesicRK, PnOde, PnStiffMatrix, PsAnimation, PsAuthorInfo, PsGeometryInfo, PsJavaView, PsKey, PsModelInfo, PuComplexP, PuDouble, PuFunction, PuInteger, PvCamera, PvScene, PvViewer, PwCleanMesh, PwClip, PwCurvature, PwGeodesic, PwHodge, PwLIC, PwModel, PwPlatonic, PwRivaraBisection, PwSimplify, PwVectorField

public abstract class PsObject
extends java.lang.Object
implements PsUpdateIf, java.lang.Cloneable, java.io.Serializable

Super class in JavaView which implements the update interface and has an info panel. Every class which implements the update interface PsUpdateIf may have PsObject as super class unless it is a panel, dialog etc. which are derived from PsPanel and PsDialog.

Subclasses must call the init() method in each constructor, and each init() method must call super.init() at first. The following layout may be used:

	public class myClass extends mySuperClass
		public myClass() {
			...	// create all instance variables
			if (getClass() == myClass.class)
				init();
		}
		public void init() {
			super.init();
			...	// initialization of instance variables, allows to use init() as reset()
		}
 
This ensures that the init() method of superclasses is called. Otherwise even the init() methods of the superclasses will not be called. The init() method should be written such that it can be used to reset the current instance. Therefore, all creation of instance variables should be placed in the constructor, as far as possible.

Each instance of PsObject may have an associated info panel as interactive inspector. Most information in the panel is interactively modifiable. The class name of an info panel may follow a special naming convention: "name of main class"+"_IP". This convention allows the method getInfoPanel() of PsObject to find this class automatically if it is in the same java package as the main class. For example, jv.geom.PgPointSet.java and jv.geom.PgPointSet_IP.java are a pair of base class and info panel.

If a class does not have an own inspector class then the inspector of its superclass is used. Each object may have several other inspectors with different filename extensions which are accessible via the menu of the control window.

Each instance of PsObject has a unique default name of the form 'object_NUMBER' where NUMBER is a unique integer number counting the number of created instances. The name should be changed using method setName(String) since it is used e.g. as header of the inspector panel, and in debug output as a unique reference to the object.

The tag variable may be used locally in methods or projects. They have no global influence, and a user cannot rely on the value once a method is left.

Since JavaView 1.74, we get the Class object that describes any Java type using the new class literal syntax. A class literal is simply the name of a type (a class name or a primitive type name) followed by a period and the class keyword. For example:

 Class o = PsObject.class;
 Class i = int.class;
 Class v = java.util.Vector.class;
 
Prior to JavaView 1.74 we used the Java 1.0 style, where we got the Class object from the name of a data type using the forName() class method of Class.

Version:
22.06.00, 1.70 revised (kp) Additional flag FIXED added which allows to freeze an object.
20.03.00, 1.60 revised (kp) Constructor used .class literal to decide calling init().
19.08.99, 1.50 revised (kp) Inspector panels in hashtable, update listeners added.
23.01.99, 1.20 revised (kp) Initialization of parent with setParent instead of update.
16.11.98, 1.10 revised (kp) method newInstance(,,) added
00.00.97, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
Serialized Form

Field Summary
static int HAS_CONFIG_PANEL
          Tag object as having an inspector panel.
static int HAS_INFO_PANEL
          Tag object as having an inspector panel.
static int HAS_MATERIAL_PANEL
          Tag object as having an inspector panel.
static java.lang.String INSPECTOR_INFO
          Name of default info panel under which panel is registered in panel list.
static java.lang.String INSPECTOR_INFO_EXT
          Identifier of class extension characterizing info panels.
static int IS_DELETED
          Tag object as been deleted, applications should not continue to access its data.
static int IS_FIXED
          Tag object as been fixed, applications should not modify its data.
static int IS_SELECTED
          Tag object as been selected, applications may use this tag.
static int IS_USED
          Tag object as been used, applications may use this tag.
protected  PsPanel m_infoPanel
          Standard info panel of object.
protected  java.lang.String m_name
          Name of current object, need not be unique.
protected  java.util.Hashtable m_panelList
          Hashtable of inspector panels and dialogs of object.
protected  PsUpdateIf m_parent
          Major parent and owner of instance, receives update events from this instance.
protected  java.util.BitSet m_tag
          Identifies different states of the geometry, created on first need.
protected  java.util.Vector m_updateList
          Hashtable of update listeners.
static int NUM_TAGS
          Number of available tags to describe state of object.
 
Constructor Summary
PsObject()
          Constructor.
 
Method Summary
 boolean addInspector(java.lang.String name, PsPanel panel)
          Register a new inspector, and set current object as parent of panel.
 boolean addUpdateListener(PsUpdateIf listener)
          Register a new update listener
 void clearTag(int aBit)
          Unset tag of object.
 java.lang.Object clone()
          Duplicate geometry by recursively cloning all instance variables except inspector panels and lists of registered listeners.
static PsObject[] clone(PsObject[] src)
          Duplicate array and all entries by recursively cloning all instance variables except inspector panels and lists of registered listeners.
static PsObject[][] clone(PsObject[][] src)
          Duplicate array and all entries by recursively cloning all instance variables except inspector panels and lists of registered listeners.
 void copy(PsObject object)
          Copy base instance variables and prepend "Copy of" to name if identical to original object name.
 PsUpdateIf getFather()
          Get unique parent of an object.
 PsPanel getInfoPanel()
          Get info panel, or if panel does not exist then try to allocate it.
 PsPanel getInspector(java.lang.String name)
          Get a registered inspector panel.
 java.lang.String getName()
          Get name identifying the object.
 int getNumObjects()
          Get number of allocated instances of PsObject and its subclasses.
 boolean hasInspector(java.lang.String name)
          Check for a registered inspector panel by name.
 boolean hasTag(int aBit)
          Check whether tag of object is set.
 boolean hasUpdateListener(PsUpdateIf listener)
          Check whether an instance is a registered listener.
 void init()
          If instance has missing name then assign default name 'object_NUMBER' where number is the total number of already created instances.
static boolean instanceOf(java.lang.Object obj, java.lang.Class cl)
          Method checks if an object extends a given class or one of its superclasses.
 boolean instanceOf(java.lang.String className)
          Deprecated. use "if (getClass() == PsObject.class)" instead
 boolean removeInspector(java.lang.String name)
          Remove a registered inspector panel from list of registered inspectors.
 boolean removeUpdateListener(PsUpdateIf listener)
          Remove a registered listener from list of registered listeners.
 void setName(java.lang.String aName)
          Set name identifying the object.
 void setParent(PsUpdateIf aParent)
          Set parent to receive update methods.
 void setTag(int aBit)
          Set tag of object.
 java.lang.String toString()
          Create a multi-line string representation with detailed information about all instance variables.
 boolean update(java.lang.Object event)
          Update all inspector panels, send update to all registered update listeners and finally update parent.
 boolean updatePanels(java.lang.Object event)
          Partial update method to synchrnonize all registered inspector panels.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_name

protected java.lang.String m_name
Name of current object, need not be unique. Used in header of info panel and in debug output.
See Also:
getName(), setName(java.lang.String)

m_parent

protected transient PsUpdateIf m_parent
Major parent and owner of instance, receives update events from this instance.
See Also:
update(Object), PsPanel.update(Object)

m_updateList

protected transient java.util.Vector m_updateList
Hashtable of update listeners. Each call of the PgGeometry.update() method of this geometry will initate an udpate of all registered update listeners.

m_panelList

protected transient java.util.Hashtable m_panelList
Hashtable of inspector panels and dialogs of object. Registered panels and dialogs receive an update event if they are visible.

m_infoPanel

protected transient PsPanel m_infoPanel
Standard info panel of object. Variable is kept for easy use, panel is also stored inside panelList.

m_tag

protected java.util.BitSet m_tag
Identifies different states of the geometry, created on first need. The tag variable may be used locally in methods or projects. They have no global influence, and each user should care about usage.
See Also:
clearTag(int), hasTag(int), setTag(int)

NUM_TAGS

public static final int NUM_TAGS
Number of available tags to describe state of object. Applications usually add additional tags for own purposes.
See Also:
setTag(int)

IS_USED

public static final int IS_USED
Tag object as been used, applications may use this tag.
See Also:
setTag(int)

IS_SELECTED

public static final int IS_SELECTED
Tag object as been selected, applications may use this tag.
See Also:
setTag(int)

IS_DELETED

public static final int IS_DELETED
Tag object as been deleted, applications should not continue to access its data.
See Also:
setTag(int)

IS_FIXED

public static final int IS_FIXED
Tag object as been fixed, applications should not modify its data.
See Also:
setTag(int)
Since:
JavaView 1.95

HAS_INFO_PANEL

public static final int HAS_INFO_PANEL
Tag object as having an inspector panel. Usually tag is set in the constructor.
See Also:
setTag(int)
Since:
JavaView 1.95

HAS_MATERIAL_PANEL

public static final int HAS_MATERIAL_PANEL
Tag object as having an inspector panel. Usually tag is set in the constructor.
See Also:
setTag(int)
Since:
JavaView 1.95

HAS_CONFIG_PANEL

public static final int HAS_CONFIG_PANEL
Tag object as having an inspector panel. Usually tag is set in the constructor.
See Also:
setTag(int)
Since:
JavaView 1.95

INSPECTOR_INFO_EXT

public static final java.lang.String INSPECTOR_INFO_EXT
Identifier of class extension characterizing info panels.

INSPECTOR_INFO

public static final java.lang.String INSPECTOR_INFO
Name of default info panel under which panel is registered in panel list.
Constructor Detail

PsObject

public PsObject()
Constructor. Increase total number of created instances.
Method Detail

init

public void init()
If instance has missing name then assign default name 'object_NUMBER' where number is the total number of already created instances.

toString

public java.lang.String toString()
Create a multi-line string representation with detailed information about all instance variables. E.g. use PsDebug.message(object.toString()) to print information to console. This method is usually extended by subclasses with further information.
Overrides:
toString in class java.lang.Object

clone

public static PsObject[][] clone(PsObject[][] src)
Duplicate array and all entries by recursively cloning all instance variables except inspector panels and lists of registered listeners. The parent relationship is maintained only within this class but not to external classes. In general, all links of the clone to external objects are set to null.
See Also:
#copy(PgGeometry)

clone

public static PsObject[] clone(PsObject[] src)
Duplicate array and all entries by recursively cloning all instance variables except inspector panels and lists of registered listeners. The parent relationship is maintained only within this class but not to external classes. In general, all links of the clone to external objects are set to null.
See Also:
#copy(PgGeometry)

clone

public java.lang.Object clone()
Duplicate geometry by recursively cloning all instance variables except inspector panels and lists of registered listeners. The parent relationship is maintained only within this class but not to an external parent. In general, all links of the clone to external objects are set to null. Tags of this object are not copied but maybe copied of subclasses.
Overrides:
clone in class java.lang.Object
See Also:
copy(PsObject)

getNumObjects

public int getNumObjects()
Get number of allocated instances of PsObject and its subclasses.

copy

public void copy(PsObject object)
Copy base instance variables and prepend "Copy of" to name if identical to original object name. In general, only geometry data is copied, no material properties and no external links.
See Also:
clone()

update

public boolean update(java.lang.Object event)
Update all inspector panels, send update to all registered update listeners and finally update parent. Each of those updates has this object as event independent of the argument of this method.

Central update method of this object. Must be overwritten if this class receives unknown events, say, from new children. Any subclass must class invoke super.update(event) on all events it does handle itself.

Specified by:
update in interface PsUpdateIf
See Also:
setParent(PsUpdateIf), getFather(), addUpdateListener(PsUpdateIf)

updatePanels

public boolean updatePanels(java.lang.Object event)
Partial update method to synchrnonize all registered inspector panels. This method is a convenience for certain classes like PuDouble which automatically and instantaneously synchronize their panels whenever, say, their value has changed. This is in contrast to heavier classes b which only synchronize their panels on a call b.update(panel of b) or b.update(b).

Method does nothing if list of panels does not exist. Method issues a warning if event is a panel but the panel is not registered as inspector.

Usually, application classes do not call this method but use update(Object.

See Also:
update(Object), addInspector(String, PsPanel)

addUpdateListener

public boolean addUpdateListener(PsUpdateIf listener)
Register a new update listener
Parameters:
Listener - to register
Returns:
false if listener already registered.
See Also:
hasUpdateListener(PsUpdateIf), removeUpdateListener(PsUpdateIf)

hasUpdateListener

public boolean hasUpdateListener(PsUpdateIf listener)
Check whether an instance is a registered listener.
Returns:
true if registered listener found.
See Also:
addUpdateListener(PsUpdateIf), removeUpdateListener(PsUpdateIf)

removeUpdateListener

public boolean removeUpdateListener(PsUpdateIf listener)
Remove a registered listener from list of registered listeners.
Parameters:
Registered - listener
Returns:
false if listener is not registered.
See Also:
addUpdateListener(PsUpdateIf), hasUpdateListener(PsUpdateIf)

getFather

public PsUpdateIf getFather()
Get unique parent of an object. It was necessary to rename the method since Java 1.1. added a method getParent() to its classes.
Specified by:
getFather in interface PsUpdateIf
See Also:
PsUpdateIf, update(Object), setParent(PsUpdateIf)

setParent

public void setParent(PsUpdateIf aParent)
Set parent to receive update methods.
Specified by:
setParent in interface PsUpdateIf
See Also:
PsUpdateIf, update(Object), getFather()

setName

public void setName(java.lang.String aName)
Set name identifying the object. Should be chosen unique.

getName

public java.lang.String getName()
Get name identifying the object.
Specified by:
getName in interface PsUpdateIf

clearTag

public void clearTag(int aBit)
Unset tag of object. For possible tags see PsObject.

hasTag

public boolean hasTag(int aBit)
Check whether tag of object is set. For possible tags see PsObject.

setTag

public void setTag(int aBit)
Set tag of object. For possible tags see PsObject.

instanceOf

public final boolean instanceOf(java.lang.String className)
Deprecated. use "if (getClass() == PsObject.class)" instead

Method checks if this object is exactly instance of a class given by its class name. Package names of class may be optionally given. Even if string denotes a super class method returns false. This method is different from Java operator instanceof which is true even if current instance is subclass of class 'className'.
Parameters:
className - name of class without package identifiers
Returns:
true if current object is exact instance of class
See Also:
instanceOf(Object, Class)

instanceOf

public static boolean instanceOf(java.lang.Object obj,
                                 java.lang.Class cl)
Method checks if an object extends a given class or one of its superclasses. An instanceof that works on Class objects at runtime, instead of type descriptors at compile time.
Parameters:
obj - object to test
cl - class or interface
Returns:
true, if object is instance of class or its superclasses
See Also:
instanceOf(String)

addInspector

public boolean addInspector(java.lang.String name,
                            PsPanel panel)
Register a new inspector, and set current object as parent of panel. Possible names of inspector panels are INSPECTOR_INFO, _MATERIAL, etc. depending on the current class.
Returns:
false if same name already exists.
See Also:
getInspector(String), hasInspector(String), removeInspector(String)

getInspector

public PsPanel getInspector(java.lang.String name)
Get a registered inspector panel. Possible names of inspector panels are INSPECTOR_INFO, _MATERIAL, etc. depending on the current class.
Returns:
PsPanel a registered inspector, null if not found.

hasInspector

public boolean hasInspector(java.lang.String name)
Check for a registered inspector panel by name. Possible names of inspector panels are INSPECTOR_INFO, _MATERIAL, etc. depending on the current class.
Returns:
true if registered inspector found.
See Also:
addInspector(String, PsPanel), getInspector(String)

removeInspector

public boolean removeInspector(java.lang.String name)
Remove a registered inspector panel from list of registered inspectors. Possible names of inspector panels are INSPECTOR_INFO, _MATERIAL, etc. depending on the current class.
Parameters:
Name - of inspector
Returns:
false if inspector does not exists.
See Also:
addInspector(String, PsPanel)

getInfoPanel

public PsPanel getInfoPanel()
Get info panel, or if panel does not exist then try to allocate it. Standard panel for inspecting standard internal data such as vertex arrays etc. of geometry.

Class name of info panel must consist of the name of the class to be inspected and '_IP' as suffix. In this case the panel is automatically found.

Method is a shortcut to avoid checking, creating, and adding the panel to the inspector list.


JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.