JavaView© v3.95.000

jv.object
Class PsObject

java.lang.Object
  extended byjv.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, PgVertexStar, PjProject, PjWorkshop, PnEnergyMinimizer, PnExplodePolytope, PnFunction, PnGeodesicRK, PnOde, PnSparseMatrix, PsAnimation, PsAuthorInfo, PsGeometryInfo, PsJavaView, PsKey, PsLicense, PuDouble, PuFunction, PuInteger, PuPriorityQueue, PvCamera, PvScene, PvViewer, PwCurvature, PwRivaraBisection

public 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.

See Also:
Serialized Form

Field Summary
static int HAS_CONFIG_PANEL
          Tag object as having a control panel.
static int HAS_INFO_PANEL
          Tag object as having an inspector panel.
static int HAS_LABEL_PANEL
          Tag object as having a font panel.
static int HAS_MATERIAL_PANEL
          Tag object as having a material panel.
static int HAS_TEXTURE_PANEL
          Tag object as having a texture panel.
static int HAS_VECTOR_PANEL
          Tag object as having a vector field panel.
static java.lang.String INSPECTOR_INFO
          Deprecated. use PsPanel.INFO instead
static java.lang.String INSPECTOR_INFO_EXT
          Deprecated. use PsPanel.INFO_EXT instead
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_FOCUSSED
          Tag object as being within the focus of a device, and further action might pick or select this object.
static int IS_PICKED
          Tag object as being temporarily picked in a device and interactively modified.
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.
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.
 PsPanel assureInspector(java.lang.String name, java.lang.String ext)
          Get a certain panel - if it does not exist then try to allocate it.
 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 the content of data instance variables from argument object to this object.
 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.
static int getNumObjects()
          Get number of allocated instances of PsObject and its subclasses.
 java.lang.String getSymbol()
          Get symbol, i.e. shortcut name, which identifies this object in equations.
 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
 PsPanel newInspector(java.lang.String ext)
          Create and register a new inspector panel of this class, and set current object as parent of inspector panel.
 PsPanel newInspector(java.lang.String name, java.lang.String ext)
          Create and register a new inspector panel of this class, and set current object as parent of inspector panel.
 boolean removeInspector(PsPanel panel)
          Remove a registered inspector panel from list of registered inspectors.
 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 name)
          Set name identifying the object.
 void setParent(PsUpdateIf aParent)
          Set parent to receive update methods.
 void setSymbol(java.lang.String symbol)
          Set symbol, i.e. shortcut name, which identifies this object in equations.
 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, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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), Constant Field Values

IS_USED

public static final int IS_USED
Tag object as been used, applications may use this tag.

See Also:
setTag(int), Constant Field Values

IS_SELECTED

public static final int IS_SELECTED
Tag object as been selected, applications may use this tag.

See Also:
setTag(int), Constant Field Values

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), Constant Field Values

IS_FIXED

public static final int IS_FIXED
Tag object as been fixed, applications should not modify its data.

Since:
JavaView 1.95
See Also:
setTag(int), Constant Field Values

IS_PICKED

public static final int IS_PICKED
Tag object as being temporarily picked in a device and interactively modified.

Since:
JavaView 2.99.012
See Also:
setTag(int), Constant Field Values

IS_FOCUSSED

public static final int IS_FOCUSSED
Tag object as being within the focus of a device, and further action might pick or select this object.

Since:
JavaView 2.99.012
See Also:
setTag(int), Constant Field Values

HAS_INFO_PANEL

public static final int HAS_INFO_PANEL
Tag object as having an inspector panel. Usually tag is set in the constructor.

Since:
JavaView 1.95
See Also:
setTag(int), Constant Field Values

HAS_MATERIAL_PANEL

public static final int HAS_MATERIAL_PANEL
Tag object as having a material panel. Usually tag is set in the constructor.

Since:
JavaView 1.95
See Also:
setTag(int), Constant Field Values

HAS_TEXTURE_PANEL

public static final int HAS_TEXTURE_PANEL
Tag object as having a texture panel. Usually tag is set in the constructor.

Since:
JavaView 2.03
See Also:
setTag(int), Constant Field Values

HAS_VECTOR_PANEL

public static final int HAS_VECTOR_PANEL
Tag object as having a vector field panel. Usually tag is set in the constructor.

Since:
JavaView 2.28
See Also:
setTag(int), Constant Field Values

HAS_LABEL_PANEL

public static final int HAS_LABEL_PANEL
Tag object as having a font panel. Usually tag is set in the constructor.

Since:
JavaView 3.52.001
See Also:
setTag(int), Constant Field Values

HAS_CONFIG_PANEL

public static final int HAS_CONFIG_PANEL
Tag object as having a control panel. Usually tag is set in the constructor.

Since:
JavaView 1.95
See Also:
setTag(int), Constant Field Values

INSPECTOR_INFO_EXT

public static final java.lang.String INSPECTOR_INFO_EXT
Deprecated. use PsPanel.INFO_EXT instead

Identifier of class extension characterizing info panels.

See Also:
Constant Field Values

INSPECTOR_INFO

public static final java.lang.String INSPECTOR_INFO
Deprecated. use PsPanel.INFO instead

Name of default info panel under which panel is registered in panel list.

See Also:
Constant Field Values
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.


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(PsObject)

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(PsObject)

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.

See Also:
copy(PsObject)

getNumObjects

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


copy

public void copy(PsObject object)
Copy the content of data instance variables from argument object to this object. Instance variables are copied recursively.

Instance variables like parent and listeners are not copied.

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
Parameters:
event - carries a lot of information
Returns:
true if event has been handled, otherwise false
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).

Parameters:
event - Either this object or a registered panel.
Returns:
false, if no event or event is unknown.
See Also:
update(Object), addInspector(String, PsPanel)

addUpdateListener

public boolean addUpdateListener(PsUpdateIf listener)
Register a new update listener. Update listener must be different from this base class and parent of this base since those are always updated.

Parameters:
listener - 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.

Parameters:
listener - Listener to be checked
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:
listener - 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
Parameters:
aParent - will receive events which this does not handle
See Also:
PsUpdateIf, update(Object), getFather()

getName

public java.lang.String getName()
Get name identifying the object.

Specified by:
getName in interface PsUpdateIf

setName

public void setName(java.lang.String name)
Set name identifying the object. Should be chosen unique. The given name may not be Null or the empty string.


getSymbol

public java.lang.String getSymbol()
Get symbol, i.e. shortcut name, which identifies this object in equations.

Since:
JavaView 3.50.002

setSymbol

public void setSymbol(java.lang.String symbol)
Set symbol, i.e. shortcut name, which identifies this object in equations. The given name may be null but not the empty string.

Since:
JavaView 3.50.002

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. Any name of an inspector panels is possible except the string PsPanel.INFO, PsPanel.MATERIAL which are reserved for JavaView internal panels.

This method invokes the two methods PsPanel.setParent(PsUpdateIf) and PsPanel.update(Object) to register this class as parent of the panel:

 setParent(this)
 update(this)
 

Parameters:
name - any name except one of the reserved inspector names
panel - panel to be registered
Returns:
false if same name already exists.
See Also:
getInspector(String), hasInspector(String), newInspector(String), removeInspector(PsPanel), removeInspector(String)

newInspector

public PsPanel newInspector(java.lang.String name,
                            java.lang.String ext)
Create and register a new inspector panel of this class, and set current object as parent of inspector panel.

The parameter name specifies the string under which the inspector is registered in the list of inspectors of this class. Any name of an inspector panels is possible except the string PsPanel.INFO, PsPanel.MATERIAL which are reserved for JavaView internal panels.

The extension string allows this method to reconstruct the file name of the inspector panel from the name of this class. For example, if the name of this class is 'jvx.geom.Torus' then the name of the inspector panel must be 'jvx.geom.Torus_myExt' if the parameter extension is 'myExt'.

This method calls addInspector(String, PsPanel).

Parameters:
name - any name except one of the reserved inspector names
ext - suffix to name of base class
Returns:
new panel
See Also:
addInspector(String, PsPanel), getInspector(String), hasInspector(String), newInspector(String), removeInspector(PsPanel), removeInspector(String)

newInspector

public PsPanel newInspector(java.lang.String ext)
Create and register a new inspector panel of this class, and set current object as parent of inspector panel.

The extension string allows this method to reconstruct the file name of the inspector panel from the name of this class. For example, if the name of this class is 'jvx.geom.Torus' then the name of the inspector panel must be 'jvx.geom.Torus_myExt' if the parameter extension is 'myExt'.

The name, under which this panel is registered as inspector of this object, is unique and automatically choosen. Currently, this name is unavailable to the outside. Use newInspector(String, String) if the name is important.

This method calls newInspector(String, String).

Parameters:
ext - suffix to name of base class
Returns:
new panel
See Also:
addInspector(String, PsPanel), getInspector(String), hasInspector(String), newInspector(String, String), removeInspector(PsPanel), removeInspector(String)

getInspector

public PsPanel getInspector(java.lang.String name)
Get a registered inspector panel. Any name of an inspector panels is possible except the string PsPanel.INFO, PsPanel.MATERIAL which are reserved for JavaView internal panels.

Parameters:
name - Name of inspector to be received
Returns:
PsPanel a registered inspector, null if not found.
See Also:
addInspector(String, PsPanel), hasInspector(String), newInspector(String), newInspector(String, String), removeInspector(String)

hasInspector

public boolean hasInspector(java.lang.String name)
Check for a registered inspector panel by name. Any name of an inspector panels is possible except the string PsPanel.INFO, PsPanel.MATERIAL which are reserved for JavaView internal panels.

Parameters:
name - Name of inspector to be checked
Returns:
true if registered inspector found.
See Also:
addInspector(String, PsPanel), getInspector(String), newInspector(String), newInspector(String, String), removeInspector(String), removeInspector(PsPanel)

removeInspector

public boolean removeInspector(java.lang.String name)
Remove a registered inspector panel from list of registered inspectors. Any name of an inspector panels is possible except the string PsPanel.INFO, PsPanel.MATERIAL which are reserved for JavaView internal panels.

Parameters:
name - Name of inspector to be removed
Returns:
false if inspector does not exists.
See Also:
addInspector(String, PsPanel), getInspector(String), hasInspector(String), newInspector(String), newInspector(String, String), removeInspector(PsPanel)

removeInspector

public boolean removeInspector(PsPanel panel)
Remove a registered inspector panel from list of registered inspectors. Any name of an inspector panels is possible except the string PsPanel.INFO, PsPanel.MATERIAL which are reserved for JavaView internal panels.

Parameters:
panel - Panel to be removed
Returns:
false if inspector does not exists.
See Also:
addInspector(String, PsPanel), getInspector(String), hasInspector(String), newInspector(String), newInspector(String, String), removeInspector(String)

assureInspector

public PsPanel assureInspector(java.lang.String name,
                               java.lang.String ext)
Get a certain panel - if it does not exist then try to allocate it. This method is a shortcut to avoid checking, creating, and adding the panel to the inspector list.

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.

Parameters:
name - name of panel
ext - suffix to name of base class
Returns:
existing or new inspector panel
See Also:
addInspector(String, PsPanel), getInspector(String), hasInspector(String), newInspector(String), newInspector(String, String), removeInspector(PsPanel), removeInspector(String)

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. But note, obtaining an inspector with this method provides always the same panel instance, that is, this panel should only be used within a single other container, for example. If more panels are needed the create panels with different names using assureInspector(String, String).

Returns:
existing or new inspector panel
See Also:
addInspector(String, PsPanel), getInspector(String), hasInspector(String), newInspector(String), newInspector(String, String), removeInspector(String)

JavaView© v3.95.000

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