|
JavaView® v2.12 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--jv.object.PsObject
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.
| 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_MATERIAL_PANEL
Tag object as having a material panel. |
static int |
HAS_TEXTURE_PANEL
Tag object as having a texture 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. |
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 type,
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 base instance variables and prepend "copy_" resp. |
PsUpdateIf |
getFather()
Get unique parent of an object. |
PsPanel |
getInfoPanel()
Deprecated. use assurePanel(String, String) |
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. |
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, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int NUM_TAGS
setTag(int)public static final int IS_USED
setTag(int)public static final int IS_SELECTED
setTag(int)public static final int IS_DELETED
setTag(int)public static final int IS_FIXED
setTag(int)public static final int HAS_INFO_PANEL
setTag(int)public static final int HAS_MATERIAL_PANEL
setTag(int)public static final int HAS_TEXTURE_PANEL
setTag(int)public static final int HAS_CONFIG_PANEL
setTag(int)public static final java.lang.String INSPECTOR_INFO_EXT
public static final java.lang.String INSPECTOR_INFO
| Constructor Detail |
public PsObject()
| Method Detail |
public void init()
public java.lang.String toString()
PsDebug.message(object.toString()) to print information
to console. This method is usually extended by subclasses with further information.toString in class java.lang.Objectpublic static PsObject[][] clone(PsObject[][] src)
null.#copy(PgGeometry)public static PsObject[] clone(PsObject[] src)
null.#copy(PgGeometry)public java.lang.Object clone()
null.
Tags of this object are not copied but maybe copied of subclasses.copy(PsObject)public static int getNumObjects()
public void copy(PsObject object)
clone()public boolean update(java.lang.Object event)
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.
update in interface PsUpdateIfsetParent(PsUpdateIf),
getFather(),
addUpdateListener(PsUpdateIf)public boolean updatePanels(java.lang.Object event)
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.
update(Object),
addInspector(String, PsPanel)public boolean addUpdateListener(PsUpdateIf listener)
Listener - to registerfalse if listener already registered.hasUpdateListener(PsUpdateIf),
removeUpdateListener(PsUpdateIf)public boolean hasUpdateListener(PsUpdateIf listener)
true if registered listener found.addUpdateListener(PsUpdateIf),
removeUpdateListener(PsUpdateIf)public boolean removeUpdateListener(PsUpdateIf listener)
Registered - listenerfalse if listener is not registered.addUpdateListener(PsUpdateIf),
hasUpdateListener(PsUpdateIf)public PsUpdateIf getFather()
getParent() to its classes.getFather in interface PsUpdateIfPsUpdateIf,
update(Object),
setParent(PsUpdateIf)public void setParent(PsUpdateIf aParent)
setParent in interface PsUpdateIfPsUpdateIf,
update(Object),
getFather()public void setName(java.lang.String aName)
public java.lang.String getName()
getName in interface PsUpdateIfpublic void clearTag(int aBit)
PsObject.public boolean hasTag(int aBit)
PsObject.public void setTag(int aBit)
PsObject.public final boolean instanceOf(java.lang.String className)
false.
This method is different from Java operator instanceof which
is true even if current instance is subclass of class 'className'.className - name of class without package identifiersinstanceOf(Object, Class)
public static boolean instanceOf(java.lang.Object obj,
java.lang.Class cl)
obj - object to testcl - class or interfaceinstanceOf(String)
public boolean addInspector(java.lang.String name,
PsPanel panel)
false if same name already exists.getInspector(String),
hasInspector(String),
removeInspector(String)public PsPanel getInspector(java.lang.String name)
null if not found.public boolean hasInspector(java.lang.String name)
true if registered inspector found.addInspector(String, PsPanel),
getInspector(String)public boolean removeInspector(java.lang.String name)
Name - of inspectorfalse if inspector does not exists.addInspector(String, PsPanel)
public PsPanel assureInspector(java.lang.String type,
java.lang.String ext)
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.
type - type of panel, e.g. PsObject.INSPECTOR_INFOext - file name extension, e.g. PsObject.INSPECTOR_INFO_EXTpublic PsPanel getInfoPanel()
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.12 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||