JavaView® v2.00.008

jv.project
Class PjProject

java.lang.Object
  |
  +--jv.object.PsObject
        |
        +--jv.project.PjProject
All Implemented Interfaces:
java.lang.Cloneable, PsTimeListenerIf, PsUpdateIf, PvPickListenerIf, java.io.Serializable
Direct Known Subclasses:
MyProject, PjAxes, PjCatenoid, PjConformal, PjConjugate, PjConnecting, PjCurve, PjCycloid, PjElasticCurve, PjEventCamera, PjEvolve, PjExprOde, PjFractalImage, PjHarmonic, PjHeight, PjHodge, PjImportModel, PjKeyframe, PjLIC, PjLife, PjLinear, PjMinesweeper, PjModel, PjParmSurface, PjPickEvent, PjPlatonic, PjPolygonSet, PjRivara, PjRootFinder, PjRuler, PjSubdivision, PjSurface, PjTextureCube, PjTexturedSurface, PjTorusKnot, PjTransform, PjVectorField, PjWeierstrass, PnCellOperator, slider_project

public class PjProject
extends PsObject
implements PsTimeListenerIf, PvPickListenerIf, PsUpdateIf

Central control class whose subclasses are application specific user projects. Projects might compute surfaces, load geometries from file, or solve differential equations. They are specialized classes making use of all the functionality available in JavaView. Projects can be used as building blocks in other projects.

The advantage of wrapping an application inside a project rather than an applet is the fact, that projects are considered as building blocks respectively modules in JavaView, which can be used by other projects to perform specific tasks. Although applets usually wrap an application but they contain too many presentation specific functionality to serve as reusable modules. An alternative to JavaView projects is the use of Java beans.

Subclasses are usually instantiated at following occasions:

  1. Inside an applet and passed to the PvViewer as current project. This mainly determines the initial functionality of the applet.
  2. Inside other projects to enhance their functionality. In such a case the project has usually no connection to the viewer and display.
  3. Interactively through the control menu. This is similar to step 1.
  4. If projects are registered in PvViewer, then PvViewer registers itself as parent of the project. This happens e.g. in cases 1. and 3. above, In case 2. the container project may, for example, register itself as parent. When the project is selected in PvViewer by selectProject(String), then that method in turn registers a default display and invokes the start() method of this project.

    A project has a main geometry, although it may have more geometries and even a network of geometries. It may have associated displays (might not be true in future), it may have an associated animation to receive update(time) events, and it may receive pick events from an associated PvDisplay.

    A project may have an animation object which handles the projects animations. If a project has an animation object, then the animation panel is shown when the project's start() method is invoked during loading of the project. Only one animation object may be set in a project, but a user might register the project in other animation objects. Use setAnimation(PsAnimation) to register an animation.

    To be able to access the global viewer the project must either be registered in PvViewer using addProject() or the viewer should be set directly using setViewer().

    Version:
    02.02.01, 3.10 revised (kp) Flag and methods to steer auto fit added.
    29.09.00, 3.00 revised (kp) Renamed to PjProject from PgProject.
    03.03.00, 2.20 revised (kp) New instance variable m_viewer with access methods added.
    02.01.00, 2.13 revised (kp) Method added in v2.12 removed, maybe added by subclasses.
    04.10.99, 2.12 revised (ur) Four dummy methods getTimeOfFirst/Previous/Next/LastKey added.
    06.06.99, 2.11 revised (kp) Bug in removeGeometry removed: set m_geometry==null if no further registered geometries.
    17.05.99, 2.10 revised (kp) Method getAnimationPanel() added.
    16.09.98, 2.00 revised (kp)
    00.00.97, 1.00 created (kp)
    Author:
    Konrad Polthier
    See Also:
    PsTimeListenerIf, PsAnimation, PvDisplay, PvViewer, Serialized Form

    Field Summary
    protected  PsAnimation m_anim
              Supervising animation control, empty if not used.
    protected  boolean m_bAutoFit
              Flag determines whether scenery is scaled to fit display when start() is called.
    protected  PvDisplayIf m_display
              Default display of project.
    protected  java.util.Vector m_displayList
              List of registered displays of project.
    protected  PgGeometryIf m_geometry
              Main geometry of project.
    protected  java.lang.String[][] m_parm
              Applet parameter.
    protected  java.util.Vector m_rootGeometry
              List of geometries of project.
     
    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
     
    Constructor Summary
    PjProject(java.lang.String aName)
              Constructor with unique name.
     
    Method Summary
     boolean addDisplay(PvDisplayIf display)
              Register a new display, e.g. to be deleted when project is removed.
     boolean addGeometry(PgGeometryIf aGeometry)
              Register new geometry in project and the selected display.
     boolean addGeometry(PgGeometryIf aGeometry, boolean bUpdateDisplay)
              Register new geometry in project and the selected display, but do not update the display if not requested.
     void dispose()
              Disconnect all links to other classes and prepare for deletion.
     void dragDisplay(PvPickEvent pos)
              Drag a location in the display with 2d display and 3d world coordinates.
     void dragInitial(PvPickEvent pos)
              Drag an arbitrary point along a geometry, point may lie inside an element.
     void dragVertex(PgGeometryIf geom, int vertexIndex, PdVector vertex)
              Drag a picked vertex of a geometry.
     void fitDisplays()
              Scale the current camera in all displays such that geometry fills the display.
     PsAnimation getAnimation()
              Get the animation object of the project which handles the projects animations.
     PvDisplayIf getDisplay()
              Get currently selected display.
     java.util.Enumeration getDisplays()
              Get all registered displays as enumeration.
     PgGeometryIf getGeometry()
              Get currently selected geometry of project.
     PgGeometryIf getGeometry(int anInd)
              Get a registered geometry with given index.
     int getNumGeometries()
              Get number of registered geometries of project.
     java.lang.String getParameter(java.lang.String parmLabel)
              Get project parameter.
     PvViewerIf getViewer()
              Get viewer.
     boolean hasAnimation()
              Check whether this project is registered as listener of an animation object.
     boolean hasDisplay(PvDisplayIf display)
              Check for a registered display.
     void init()
              Initialize and reset project, stops the running animation if any.
     boolean isEnabledAutoFit()
              Determine flag which determines whether scenery is scaled to fit display when start() is called.
     void markVertices(PvPickEvent markBox)
              Mark a set of vertices of a geometry within a given bounding box.
     void pickDisplay(PvPickEvent pos)
              Get a location in the display with 2d display and 3d world coordinates.
     void pickInitial(PvPickEvent pos)
              Pick an arbitrary point on a geometry, point may lie inside an element.
     void pickVertex(PgGeometryIf geom, int vertexIndex, PdVector vertex)
              Get a picked vertex of a geometry.
     boolean removeDisplay(PvDisplayIf display)
              Remove a registered display from list of registered displays.
     void removeGeometries()
              Remove all registered geometries from project and registered displays.
     void removeGeometry(PgGeometryIf aGeometry)
              Remove previously registered geometry from project and the selected display.
     boolean selectDisplay(PvDisplayIf disp)
              Select a display to become the default display to which geometries are added.
     void selectGeometry(PgGeometryIf aGeometry)
              Select registered geometry in the project and in the selected display.
     void setAnimation(PsAnimation anAnimation)
              Assign the animation object where this listener is registered.
     void setDisplay(PvDisplayIf disp)
              Register display, and add all geometries of project to display.
     void setEnabledAutoFit(boolean flag)
              Set flag which determines whether scenery is scaled to fit display when start() is called.
     void setParameter(java.lang.String[][] parm)
              Set project parameter.
     boolean setTime(PsTimeEvent time)
              Empty method, must be overwritten by subclasses to update dynamic object.
     void setViewer(PvViewerIf viewer)
              Set viewer for direct access to central dialogs, windows, and projects of JavaView.
     void start()
              Method is invoked during loading of a project in JavaView.
     void stop()
              Stop all animations and auto-rotation in display.
     void unmarkVertices(PvPickEvent markBox)
              Unmark a set of vertices of a geometry within a given bounding box.
     
    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, update, updatePanels
     
    Methods inherited from class java.lang.Object
    equals, finalize, 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, update
     

    Field Detail

    m_display

    protected PvDisplayIf m_display
    Default display of project.

    m_displayList

    protected java.util.Vector m_displayList
    List of registered displays of project. Project must add and remove geometries from these displays itself.

    m_rootGeometry

    protected java.util.Vector m_rootGeometry
    List of geometries of project. Each geometry was added with setGeometry().

    m_geometry

    protected PgGeometryIf m_geometry
    Main geometry of project. Geometry will be registered in display, install its info and material panels in the control window, and install its menu in the menu bar of the control window.

    m_anim

    protected PsAnimation m_anim
    Supervising animation control, empty if not used.

    m_parm

    protected java.lang.String[][] m_parm
    Applet parameter.

    m_bAutoFit

    protected boolean m_bAutoFit
    Flag determines whether scenery is scaled to fit display when start() is called. On default, auto fit is enabled.
    See Also:
    setEnabledAutoFit(boolean)
    Constructor Detail

    PjProject

    public PjProject(java.lang.String aName)
    Constructor with unique name.
    Method Detail

    init

    public void init()
    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 PsObject

    dispose

    public void dispose()
    Disconnect all links to other classes and prepare for deletion. After this call the object cannot be reinvoked using init().

    start

    public void start()
    Method is invoked during loading of a project in JavaView.

    If a project has an animation object, then the animation panel is shown when the project's this start() method is invoked during loading of the project. Use setAnimation(PsAnimation) to register an animation.

    If auto fit is enabled then scenery is scaled to fit in each display.

    See Also:
    PvViewerIf.start(), #isEnabledAutoFit(boolean)

    stop

    public void stop()
    Stop all animations and auto-rotation in display. Hide animation panel, remove itself as pick listener from displays. The object can be reinvoked using init() and start().
    See Also:
    PvViewerIf.stop()

    isEnabledAutoFit

    public boolean isEnabledAutoFit()
    Determine flag which determines whether scenery is scaled to fit display when start() is called. On default, auto fit is enabled.
    See Also:
    setEnabledAutoFit(boolean)

    setEnabledAutoFit

    public void setEnabledAutoFit(boolean flag)
    Set flag which determines whether scenery is scaled to fit display when start() is called. On default, auto fit is enabled.
    See Also:
    #isEnabledAutoFit(boolean)

    getViewer

    public PvViewerIf getViewer()
    Get viewer. Viewer manages the 3d-displays, control window, and list of projects. It is the central class in JavaView, and usually created at the beginning of an applet or application. This instance variable gives access to PvViewer, e.g. to show/hide dialogs and panels.
    See Also:
    PsViewerIf, PvViewer.PvViewer(Applet, Frame)

    setViewer

    public void setViewer(PvViewerIf viewer)
    Set viewer for direct access to central dialogs, windows, and projects of JavaView. Viewer manages the 3d-displays, control window, and list of projects. It is the central class in JavaView, and usually created at the beginning of an applet or application. This instance variable gives access to PvViewer, e.g. to show/hide dialogs and panels.
    See Also:
    getViewer(), PvViewerIf, PvViewer.PvViewer(Applet, Frame)

    getParameter

    public java.lang.String getParameter(java.lang.String parmLabel)
    Get project parameter.

    setParameter

    public void setParameter(java.lang.String[][] parm)
    Set project parameter.

    pickDisplay

    public void pickDisplay(PvPickEvent pos)
    Get a location in the display with 2d display and 3d world coordinates. Point may be independent of any geometry. This method does nothing and must be overwritten.
    Specified by:
    pickDisplay in interface PvPickListenerIf
    Parameters:
    pos - Pick event issued by the display
    See Also:
    PvPickListenerIf

    dragDisplay

    public void dragDisplay(PvPickEvent pos)
    Drag a location in the display with 2d display and 3d world coordinates. Point may be independent of any geometry. This method invokes pickDisplay() and should be overwritten.
    Specified by:
    dragDisplay in interface PvPickListenerIf
    Parameters:
    pos - Pick event issued by the display
    See Also:
    PvPickListenerIf

    pickInitial

    public void pickInitial(PvPickEvent pos)
    Pick an arbitrary point on a geometry, point may lie inside an element. This method does nothing and must be overwritten.
    Specified by:
    pickInitial in interface PvPickListenerIf
    Parameters:
    pos - Pick event issued by the display
    See Also:
    PvPickListenerIf

    dragInitial

    public void dragInitial(PvPickEvent pos)
    Drag an arbitrary point along a geometry, point may lie inside an element. This method invokes pickInitial() and should be overwritten.
    Specified by:
    dragInitial in interface PvPickListenerIf
    Parameters:
    pos - Pick event issued by the display
    See Also:
    PvPickListenerIf

    pickVertex

    public void pickVertex(PgGeometryIf geom,
                           int vertexIndex,
                           PdVector vertex)
    Get a picked vertex of a geometry. This method does nothing and must be overwritten.
    Specified by:
    pickVertex in interface PvPickListenerIf
    Parameters:
    geom - Picked geometry on which vertex lies
    index - Index of vertex in vertex array of geometry
    vertex - 3d coordinates of vertex position
    See Also:
    PvPickListenerIf

    dragVertex

    public void dragVertex(PgGeometryIf geom,
                           int vertexIndex,
                           PdVector vertex)
    Drag a picked vertex of a geometry. This method invokes pickVertex() and should be overwritten.
    Specified by:
    dragVertex in interface PvPickListenerIf
    Parameters:
    geom - Picked geometry on which vertex lies
    index - Index of vertex in vertex array of geometry
    vertex - 3d coordinates of vertex position
    See Also:
    PvPickListenerIf

    markVertices

    public void markVertices(PvPickEvent markBox)
    Mark a set of vertices of a geometry within a given bounding box.
    Specified by:
    markVertices in interface PvPickListenerIf
    Parameters:
    markBox - contains four coplanar points on the bounding prism, and direction of prism.

    unmarkVertices

    public void unmarkVertices(PvPickEvent markBox)
    Unmark a set of vertices of a geometry within a given bounding box.
    Specified by:
    unmarkVertices in interface PvPickListenerIf
    Parameters:
    markBox - contains four coplanar points on the bounding prism, and direction of prism.

    addGeometry

    public boolean addGeometry(PgGeometryIf aGeometry)
    Register new geometry in project and the selected display. The display is updated after this call. This method simply calls addGeometry(aGeometry, true).
    Parameters:
    aGeometry - geometry to be added to this project and the current display.
    Returns:
    false if geometry was null or already registered in project.

    addGeometry

    public boolean addGeometry(PgGeometryIf aGeometry,
                               boolean bUpdateDisplay)
    Register new geometry in project and the selected display, but do not update the display if not requested. If this method is used then a call like m_display.update(m_display) must be issued sometime when all geometries have been registered.
    Parameters:
    aGeometry - geometry to be added to this project and the current display.
    bUpdateDisplay - flag whether display shall be updated when geometry is added.
    Returns:
    false if geometry was null or already registered in project.

    removeGeometry

    public void removeGeometry(PgGeometryIf aGeometry)
    Remove previously registered geometry from project and the selected display.

    selectGeometry

    public void selectGeometry(PgGeometryIf aGeometry)
    Select registered geometry in the project and in the selected display.
    Specified by:
    selectGeometry in interface PvPickListenerIf

    removeGeometries

    public void removeGeometries()
    Remove all registered geometries from project and registered displays.

    getNumGeometries

    public int getNumGeometries()
    Get number of registered geometries of project.
    See Also:
    addGeometry(PgGeometryIf)

    getGeometry

    public PgGeometryIf getGeometry(int anInd)
    Get a registered geometry with given index. Geometries are ordered like a vector, i.e. geometries added later have larger index. Index may change if geometries are removed.
    See Also:
    addGeometry(PgGeometryIf)

    getGeometry

    public PgGeometryIf getGeometry()
    Get currently selected geometry of project. Subclasses should return the major geometry offered to other module projects.
    See Also:
    selectGeometry(PgGeometryIf)

    getAnimation

    public PsAnimation getAnimation()
    Get the animation object of the project which handles the projects animations. This listener may only have a single animation object which is assigned by the animation object when this listener is registered using setAnimation(PsAnimation).
    Specified by:
    getAnimation in interface PsTimeListenerIf
    See Also:
    hasAnimation(), setAnimation(PsAnimation)

    hasAnimation

    public boolean hasAnimation()
    Check whether this project is registered as listener of an animation object.
    Specified by:
    hasAnimation in interface PsTimeListenerIf
    See Also:
    getAnimation(), setAnimation(PsAnimation)

    setAnimation

    public void setAnimation(PsAnimation anAnimation)
    Assign the animation object where this listener is registered. This method is invoked by the animation object during registration of this listener, and usually is not required to be called by a user. If this listener has an assigned animation object, then its animation panel may be shown to change the current time of this listener.

    If this project has an animation object assigned in its constructor or init() method, then the animation panel is shown when the project's start() method is invoked during loading of the project.

    Only one animation object may be assigned to this listener. Subsequent assignments will replace the previous assignment.

    Specified by:
    setAnimation in interface PsTimeListenerIf
    See Also:
    getAnimation(), hasAnimation()

    setTime

    public boolean setTime(PsTimeEvent time)
    Empty method, must be overwritten by subclasses to update dynamic object.
    Specified by:
    setTime in interface PsTimeListenerIf

    fitDisplays

    public void fitDisplays()
    Scale the current camera in all displays such that geometry fills the display.

    setDisplay

    public void setDisplay(PvDisplayIf disp)
    Register display, and add all geometries of project to display. Currently selected geometry of project is selected display.

    Project registers itself as pick listener of the display.

    For example, method is called from PvViewer when display exists and project is selected, or when default display is requested from PvViewer from somewhere else.

    See Also:
    addDisplay(PvDisplayIf)

    getDisplay

    public PvDisplayIf getDisplay()
    Get currently selected display. Geometries, which are added to a project, are automatically added to the currently selected display.
    See Also:
    selectDisplay(PvDisplayIf)

    selectDisplay

    public boolean selectDisplay(PvDisplayIf disp)
    Select a display to become the default display to which geometries are added. The selected display should be the main display of a project, and usually does not change during a program run. The selected display of a project does not change when the window focus is changed interactively - these are two different concepts.

    For example, method is called from PvViewer when display exists and project is selected, or when default display is requested from PvViewer from somewhere else.

    See Also:
    setDisplay(PvDisplayIf)

    addDisplay

    public boolean addDisplay(PvDisplayIf display)
    Register a new display, e.g. to be deleted when project is removed.

    Note: project is not registered as pick listener in display neither are any geometries automatically registered in display. This should all be done by hand.

    Returns:
    false if instance already registered.
    See Also:
    getDisplays()

    getDisplays

    public java.util.Enumeration getDisplays()
    Get all registered displays as enumeration.
    Returns:
    Enumeration of registered displays, null if no displays found.
    See Also:
    addDisplay(PvDisplayIf)

    hasDisplay

    public boolean hasDisplay(PvDisplayIf display)
    Check for a registered display.
    Returns:
    true if registered display found.
    See Also:
    addDisplay(PvDisplayIf), getDisplays()

    removeDisplay

    public boolean removeDisplay(PvDisplayIf display)
    Remove a registered display from list of registered displays. For example, method is called from PvDisplay when removing the geometry from the display.
    Parameters:
    Display -  
    Returns:
    false if display does not exists.
    See Also:
    addDisplay(PvDisplayIf)

    JavaView® v2.00.008

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