vgp.tutor.model
Class PjModel
java.lang.Object
|
+--jv.object.PsObject
|
+--jv.project.PjProject
|
+--vgp.tutor.model.PjModel
- All Implemented Interfaces:
- java.lang.Cloneable, PsTimeListenerIf, PsUpdateIf, PvPickListenerIf, java.io.Serializable
- public class PjModel
- extends PjProject
Tutorial on usage of importing models from file.
Three methods to load a geometry from file are presented:
- The first loading takes place inside the start method of the project
where a geometry from a given file is loaded, without any user
interaction. Of course, the code may be inserted into any other
method than the start() method. This is a batch version.
- The second loading may be invoked by opening the control panel of
JavaView and import a model from the menu
File -> Import -> ...
.
This adds the loaded geometry to this project, and this project overwrites
the methods addGeometry() and selectGeometry() to show how the project
might react on newly loaded geometries. Here just a message is printed.
- The third loading may be invoked by including a separate panel of the
project PjImportModel into the info panel of this project. In this case
the import project should exist as instance, and this project should be
its parent to be able to receive update events invoked by the import project
when its info panel has received user interaction.
- Version:
- 15.01.00, 1.00 revised (kp)
15.01.00, 1.00 created (kp)
- Author:
- Konrad Polthier
- See Also:
PvViewer, Serialized Form
| Fields inherited from class jv.object.PsObject |
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, m_infoPanel, m_name, m_panelList, m_parent, m_tag, m_updateList, NUM_TAGS |
|
Method Summary |
boolean |
addGeometry(PgGeometryIf geom)
Overwrite method of superclass to be able to react when new geometry
is loaded from file by menu import.
|
void |
init()
Initialize and reset project, stops the running animation if any.
|
void |
removeGeometry(PgGeometryIf geom)
Overwrite method of superclass to be able to react when new geometry
is loaded from file by menu import.
|
void |
selectGeometry(PgGeometryIf geom)
Overwrite method of superclass to be able to react when new geometry
is loaded from file by menu import.
|
void |
start()
Start method is invoke when project is selected in the viewer. |
boolean |
update(java.lang.Object event)
TODO: Method does not correctly restore the previous geometry after pressing
cancel once the user has pressed ok the first time. |
| Methods inherited from class jv.project.PjProject |
addDisplay, addGeometry, dispose, dragDisplay, dragInitial, dragVertex, fitDisplays, getAnimation, getDisplay, getDisplays, getGeometry, getGeometry, getNumGeometries, getParameter, getViewer, hasAnimation, hasDisplay, isEnabledAutoFit, markVertices, pickDisplay, pickInitial, pickVertex, removeDisplay, removeGeometries, selectDisplay, setAnimation, setDisplay, setEnabledAutoFit, setParameter, setTime, setViewer, stop, unmarkVertices |
| Methods inherited from class jv.object.PsObject |
addInspector, addUpdateListener, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, removeInspector, removeUpdateListener, setName, setParent, setTag, toString, updatePanels |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
m_geom
protected PgGeometry m_geom
m_import
protected PjImportModel m_import
- Import project to load geometries from file via info panel.
It is an instance variable to allow display of its info panel
inside the info panel of this project.
m_defModelName
protected java.lang.String m_defModelName
- Default name of geometry for usage in start() method.
PjModel
public PjModel()
init
public void init()
- Description copied from class:
PjProject
- Initialize and reset project, stops the running animation if any.
Does not reset any registered display nor geometry. They must
be reset individually in each subclass.
- Overrides:
init in class PjProject
start
public void start()
- Start method is invoke when project is selected in the viewer. Here
the loading of geometry from file is demonstrated as a batch version
using another instance of PjImportModel.
- Overrides:
start in class PjProject
- Following copied from class:
jv.project.PjProject
- See Also:
PvViewerIf.start(),
#isEnabledAutoFit(boolean)
update
public boolean update(java.lang.Object event)
- TODO: Method does not correctly restore the previous geometry after pressing
cancel once the user has pressed ok the first time. When pressing ok m_geom
becomes a reference to the geometry of the import project, and then cannot be
used as a back any more. Solution: geometry must be duplicated when assigning
to m_geom: e.g. m_geom = PgGeometry.duplicate(m_import.getGeometry()).
I did not solve this here since this is a demo project, and the error only
occurs after certain usage, and is not so relevant.
- Overrides:
update in class PsObject
- Following copied from interface:
jv.object.PsUpdateIf
- Parameters:
event - carries a lot of information- Returns:
- true if event has been handled, otherwise false
- See Also:
PsObject,
PsUpdateIf.getFather(),
PsUpdateIf.setParent(PsUpdateIf)
addGeometry
public boolean addGeometry(PgGeometryIf geom)
- Overwrite method of superclass to be able to react when new geometry
is loaded from file by menu import.
This method is invoked when the import menu is pressed.
- Overrides:
addGeometry in class PjProject
- Following copied from class:
jv.project.PjProject
- Parameters:
aGeometry - geometry to be added to this project and the current display.- Returns:
false if geometry was null or already registered in project.
selectGeometry
public void selectGeometry(PgGeometryIf geom)
- Overwrite method of superclass to be able to react when new geometry
is loaded from file by menu import.
This method is invoked when the imported geometry is accepted.
- Overrides:
selectGeometry in class PjProject
removeGeometry
public void removeGeometry(PgGeometryIf geom)
- Overwrite method of superclass to be able to react when new geometry
is loaded from file by menu import.
This method is invoked when the imported geometry is cancelled.
- Overrides:
removeGeometry in class PjProject
The software JavaView® is copyright protected. All Rights Reserved.