JavaView® v2.12

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:

  1. 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.
  2. 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.
  3. 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, HAS_TEXTURE_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, NUM_TAGS
 
Constructor Summary
PjModel()
           
 
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, assureInspector, 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, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jv.anim.PsTimeListenerIf
getName
 
Methods inherited from interface jv.project.PvPickListenerIf
getName
 
Methods inherited from interface jv.object.PsUpdateIf
getFather, getName, setParent
 

Constructor Detail

PjModel

public PjModel()
Method Detail

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

JavaView® v2.12

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