JavaView® v2.00.008

jv.viewer
Class PvDisplay

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--jv.viewer.PvDisplay
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, PsUpdateIf, PvDisplayIf, java.lang.Runnable, java.io.Serializable

public final class PvDisplay
extends java.awt.Canvas
implements PvDisplayIf, java.lang.Runnable, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ActionListener, java.io.Serializable

Display of JavaView for viewing and interaction with 3d geometries. The display is subclass of an AWT canvas and fulfills the interface PvDisplayIf. It may be included inside any Java containter with any layout manager.

A display may be obtained by three different ways:

  1. Simple applets may directly create a display, add a geometry, and call the instance methods of the display to configure it.
  2. A slightly advanced applet should obtain the default display from the central PvViewer instance using PvViewer#getDisplay(). This mechanism avoids any need to connect the geometry of the current project or viewer to the display.
  3. In some cases an applet or project may need additional displays.
Simple applets may directly create a display and call its instance methods.

Each class fulfilling the interface PvDisplayIf can serve as a display in JavaView, e.g. the VRML export filter is an implementation of this interface.

Version:
16.11.00, 4.10 revised (kp) Reflection of geometries added.
29.09.00, 4.00 revised (kp) Many set/get methods renamed to show/isShowing.
10.08.00, 3.40 revised (kp) Two methods for get/setting filename of background image removed.
18.07.00, 3.30 revised (kp) Mode MODE_DISPLAY_PICK now returns display pick events and no geometries.
10.07.00, 3.20 revised (kp) Flag determining backface drawing moved to element set.
06.05.00, 3.15 revised (kp) Number of methods to access PvPickListener reduced.
01.05.00, 3.10 revised (sk) Internationalization added.
27.04.00, 2.60 revised (kp) Default applet size is take on first call of resizeImage().
27.03.00, 2.50 revised (ep) Return type of getCamera() changed to PvCameraIf.
01.01.00, 2.40 revised (kp) Selecting geometries by picking somewhere, not just at vertices.
27.12.99, 2.30 revised (kp) Local transformation matrices incorporated in picking.
30.11.99, 2.20 revised (kp) Size if display modifiable.
20.11.99, 2.10 revised (kp) Aura along edges.
08.07.99, 2.04 revised (kp) Synchronization added again by synchronizing m_scene in all four methods
since there happend some flickering when auto-rotate and animation panel was enabled.
07.07.99, 2.03 revised (kp) Synchronization removed from update(Object), paintGeom(g), paint(g) and update(g).
since there was still a problem with deadlocks on a 2-processor linux machine.
01.07.99, 2.03 revised (kp) Only one camera added during construction, other added on request.
21.06.99, 2.02 revised (kp) Clipping activated.
18.04.99, 2.01 revised (kp) Automatic animation disabled as default because stopping the thread does not work on Mac.
00.00.97, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
Serialized Form

Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected static java.lang.String GEOM_AXES
          Key identifying the special geometry axes.
protected static java.lang.String GEOM_AXES_0
          Key identifying the special geometry axes.
protected static java.lang.String GEOM_AXES_1
          Key identifying the special geometry axes.
protected static java.lang.String GEOM_AXES_2
          Key identifying the special geometry axes.
protected static java.lang.String GEOM_BNDBOX
          Key identifying the special geometry bounding box.
protected static java.lang.String GEOM_FRAME
          Key identifying the special geometry coordinate frame.
protected static java.lang.String GEOM_XY_GRID
          Key identifying the special geometry xy-grid.
static int KEY_0
           
static int KEY_1
           
static int KEY_2
           
static int KEY_3
           
static int KEY_4
           
static int KEY_5
           
static int KEY_6
           
static int KEY_7
           
static int KEY_8
           
static int KEY_9
           
static int KEY_A
           
static int KEY_B
           
static int KEY_C
           
static int KEY_D
           
static int KEY_E
           
static int KEY_F
           
static int KEY_G
           
static int KEY_H
           
static int KEY_I
           
static int KEY_J
           
static int KEY_K
           
static int KEY_L
           
static int KEY_M
           
static int KEY_N
           
static int KEY_O
           
static int KEY_P
           
static int KEY_Q
           
static int KEY_R
           
static int KEY_S
           
static int KEY_T
           
static int KEY_U
           
static int KEY_V
           
static int KEY_W
           
static int KEY_X
           
static int KEY_Y
           
static int KEY_Z
           
protected  int m_ambientProj
          Projection from ambient space to R3 used in transformations of model.
protected  int m_ambientSpace
          Ambient space used in transformations of model.
protected  PdColor m_backgroundColor
          Background color of display canvas.
 java.lang.String m_backgroundImage
          Background image for display.
protected  java.awt.Image m_backImage
          Background image behind geometry.
protected  boolean m_bCentered
           
protected  boolean m_bDrawing
          Internal flag whether a thread is currently painting to display.
protected  boolean m_bEnableAnimation
          Flag to enable auto-rotation.
protected  boolean m_bEnableSorting
          Flag to enable depth sorting of elements for drawing.
protected  boolean m_bEnableTag
          Flag to enable modification of tagged vertices and elements.
protected  boolean m_bEnableZBuffer
          Flag to enable z-buffered drawing.
protected  boolean m_bFpsEnabled
          true if measuring frames per second.
protected  boolean m_bIsEnabledUpdate
          Flag determines whether update mechanism is enabled.
protected  boolean m_bMouseDown
          Flag whether mouse has picked in the display.
protected  boolean m_bMouseInside
          Flag whether mouse is currently inside the display.
protected  boolean m_bShowBackface
          Flag to globally disable drawing faces whose normal points away from observer.
protected  boolean m_bShowBackImage
          Flag to enable showing of a background image in display.
protected  boolean m_bShowDepthcue
          Flag to enable drawing of items less intense if they are farther away from observer.
protected  boolean m_bShowEdgeAura
          Flag to enable drawing of an aura around edges in background color.
protected  boolean m_bShowEdgesOnce
          Flag to enable drawing of common face edges only once, requires neighbour information.
protected  boolean m_bShowGrid
          Flag to enable showing of grid in xy-coordinate plane.
protected  boolean m_bTransformModel
          Flag whether transformation of current model or camera is active.
protected  java.util.Hashtable m_camera
          List of registered cameras.
protected  java.util.Vector m_cameraListener
          List of camera listeners who will be notified when a camera event occurred.
protected  PsPanel m_cameraPanel
          Info panel of camera, shared by different cameras.
protected  PvCamera m_currentCamera
          Currently used camera in display.
protected  jv.viewer.PvGeometry m_currentGeom
          Currently selected geometry container.
protected  java.awt.Dimension m_currLoc
          Instance variables are 'int'
protected  double[] m_currNormLoc
          Instance variables are 'double'
 java.lang.String m_defBackgroundImage
          Default background image for display.
protected  int m_defModeMajor
          Default major control mode, i.e. scale, shift, rot...
protected static java.awt.Dimension m_defSize
          Default height and width of display window, size of offscreen image.
protected  PdColor m_foregroundColor
          Foreground color of overlay items such as coordinate axis.
protected  java.awt.Frame m_frame
          Reference to container frame of display, e.g. to allow display to hide/show frame.
protected  PgGeometryIf m_geomIf
          Associated geometry of currently selected geometry 'm_currentGeom'.
protected  PuInteger m_height
          Height of display window, height of offscreen image.
protected  int m_imageFitMode
          Mode determines how a background image is scaled w.r.t. display canvas.
protected  PsPanel m_infoPanel
          Info panel of display.
protected static java.lang.String[] m_majorModeMessage
          Status message of modes available through PvDisplayIf.
protected  PiVector m_markBox
          Selected rectangle in screen coordinates during mark-mode.
protected  java.awt.MenuItem[] m_menuItem
          Array with popup menu items.
protected static java.lang.String[] m_minorModeMessage
          Status message of modes not available through PvDisplayIf.
protected  int m_mode
          Control mode, i.e. scale, shift, rot...
static int M_MODE_ADD
           
protected static int M_MODE_ADD_ELEMENT
          Minor mode in display to add new elements to selected geometry.
protected static int M_MODE_CENTER
           
static int M_MODE_DELETE
           
static int M_MODE_DISPLAY_PICK
           
static int M_MODE_DUPLICATE
           
protected static int M_MODE_FOCUS
           
static int M_MODE_HIGHLIGHT
           
static int M_MODE_INITIAL_PICK
           
static int M_MODE_MARK
           
static int M_MODE_MARK_ELEMENTS
           
static int M_MODE_ORBIT
           
static int M_MODE_PICK
           
protected static int M_MODE_RESET
           
static int M_MODE_SCALE
           
static int M_MODE_SCALE_RECT
           
protected static int M_MODE_START
           
protected static int M_MODE_STOP
           
static int M_MODE_TRANS
           
static int M_MODE_TRANS_Z
           
static int M_MODE_UNMARK
           
protected  jv.viewer.PvModelCamera m_modelCamera
          Camera used for modeling transformations of geometry.
protected  int m_modeMajor
          Major control mode, i.e. scale, shift, rot...
protected  java.lang.String m_name
           
protected  int m_nHeight
          Height of display window, height of offscreen image.
protected  int m_nWidth
          Width of display window, width of offscreen image.
protected  PsUpdateIf m_parent
           
protected  PdVector m_pick
          Pick coordinates of picking in screen coordinates (x,y): m_pick.set(x, y, 0., 1.).
protected  int m_pickedVertex
          Index of picked vertex in global vertex array of current geometry.
protected  PvPickListenerIf m_pickFocus
          Listener who has requested the pick focus to be the only receiver of pick events.
protected  java.util.Vector m_pickListener
          List of pick listeners who will be notified when a pick event occurred.
protected  java.awt.PopupMenu m_popup
          Popup menu to select mouse interaction mode like orbit, scale, translate etc.
protected  PvScene m_scene
          Scene of display containing all geometries.
protected  int m_sceneFlags
          Flags determining what is painted.
protected  PuInteger m_sleep
          Sleeping period of auto-animation thread between two repaint().
protected  java.util.Hashtable m_specialGeom
          Hashtable contains all active special geometries such as bounding box, grid, or coordinate frame.
protected static boolean M_SWITCH_DCUE
           
protected static boolean M_SWITCH_GRID
           
protected static boolean M_SWITCH_HIDD
           
protected  java.lang.Thread m_thread
          Thread created in auto-rotate mode.
protected  PvViewerIf m_viewer
           
protected  PuInteger m_width
          Width of display window, width of offscreen image.
protected  PdVector m_worldPick
          4D world coordinates of hit during picking obtained from current hit point in screen coordinates by applying inverse of transformation matrix.
protected static float PS_ZOOM
          Zoom factor of each pixel quantity if PostScript printing is enabled.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface jv.project.PvDisplayIf
CAMERA_MODEL, CAMERA_ORTHO_XY, CAMERA_ORTHO_XZ, CAMERA_ORTHO_YZ, CAMERA_PERSPECTIVE, IMAGE_CENTER, IMAGE_RESIZE, IMAGE_TESSELATE, MATRIX_INV_MODEL, MATRIX_INV_PROJECT, MATRIX_INV_PROJVIEW, MATRIX_INV_TRANS, MATRIX_INV_VIEW, MATRIX_MODEL, MATRIX_PROJECT, MATRIX_PROJVIEW, MATRIX_TRANS, MATRIX_VIEW, MODE_ADD, MODE_DELETE, MODE_DISPLAY_PICK, MODE_DUPLICATE, MODE_HIGHLIGHT, MODE_INITIAL_PICK, MODE_MARK, MODE_MARK_ELEMENTS, MODE_ORBIT, MODE_PICK, MODE_SCALE, MODE_SCALE_RECT, MODE_TRANS, MODE_TRANS_Z, MODE_UNMARK, PAINT_ALL, PAINT_ANTIALIAS, PAINT_AXES, PAINT_BACKGROUND, PAINT_BACKIMAGE, PAINT_BNDBOX, PAINT_BORDER, PAINT_CLEAR_SCREEN, PAINT_CROSS, PAINT_FRAME, PAINT_INFO, PAINT_MAGNET, PAINT_SINGLE, PAINT_ZOOM
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PvDisplay()
          Constructor of display without viewer as parent.
PvDisplay(java.applet.Applet applet, java.awt.Frame frame)
          Constructor of display inside applet, or inside frame if applet is null.
PvDisplay(PvViewerIf viewer)
          Constructor of display with given argument viewer as parent.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
           
 int addCamera(java.lang.String aName, PvCamera aCamera)
          Add new camera and make it accessible under the given name.
 void addCameraListener(PvCameraListenerIf listener)
          Add camera listener to receive camera events PvCameraEvent.
 boolean addGeometry(PgGeometryIf aGeom)
          Add geometry to display.
 void addPickListener(PvPickListenerIf listener)
          Add pick listener to receive pick events PvPickEvent.
 void center()
          Center geometry in window, do no scaling
 boolean containsGeometry(PgGeometryIf aGeom)
          Check whether geometry is registered in display.
 void enableClip(boolean aFlag)
          Deprecated. use #setEnabledClip
protected  void enableTransformModel(boolean aFlag)
          Enable transformation of modeling matrix M of single geometry rather than transforming the whole scene by modifying project P and view V matrices.
 void fit()
          Center and scale camera such that geometry fits exactly into window.
protected  PgGeometryIf[] getAllGeometries()
          Get array with all geometries including registered and special geometries.
protected  jv.viewer.PvGeometry[] getAllGeometryContainers()
          Get array with all geometry containers including registered and special geometries.
 int getAmbientProjection()
          Get projection mode of ambient space used in model transformations.
 int getAmbientSpace()
          Get ambient space used in model transformations.
 java.awt.Color getBackgroundColor()
          Get color of background of display.
 java.awt.Image getBackgroundImage()
          Make image of display available to outside world.
 java.lang.String getBackgroundImageFile()
          Get filename of background image of display canvas.
 PvCameraIf getCamera()
          Get current camera object.
 PvCamera getCamera(int type)
          Get a camera object by type.
 PsPanel getCameraPanel()
          Get info panel of current camera.
protected  int getCurrentCameraType()
          Get type of current camera, for example, perspective, xy-projection etc.
 double getFarClip()
          Get far clip distance of current camera.
 PsUpdateIf getFather()
          Get father of display.
 java.awt.Color getForegroundColor()
          Get foreground color.
 java.awt.Frame getFrame()
          Get reference to container frame of display, e.g. to allow display to hide/show frame.
 PgGeometryIf[] getGeometries()
          Get array with registered geometries.
protected  jv.viewer.PvGeometry[] getGeometryContainers()
          Get array with registered geometry containers.
 java.awt.Image getImage()
          Make image of display available to outside world.
 int getImageFitMode()
          Get the mode determining how a background image is scaled w.r.t. the display canvas.
 PsPanel getInfoPanel()
          Get info panel of display.
 int getMajorMode()
          Get current interaction mode.
 java.awt.Dimension getMinimumSize()
          Assure correct horizontal size of all project panels.
 java.lang.String getName()
          Get name of this display.
 double getNearClip()
          Get near clip distance of current camera.
 PvPickEvent getPickEvent(int x, int y)
          Find intersection of ray through pick locus on registered geometries.
 java.awt.Point getPosition(int xPos, int yPos)
          Get upper left corner of frame.
 java.awt.Dimension getPreferredSize()
          Assure correct horizontal size of all project panels.
 PgGeometryIf getSelectedGeometry()
          Get currently selected geometry.
 java.awt.Dimension getSize()
          Get height of drawing canvas.
 PdMatrix getTransMatrix(int type)
          Get 4*4 transformation matrix or components from current camera and display.
protected  int[][] getZBuffer()
          Get z-buffer array with depth information of each pixel.
 boolean hasCameraListener(PvCameraListenerIf listener)
          Check for a registered listener.
 boolean hasPaintTag(int flags)
          Check whether either if the bits in parameter has been set.
protected  java.awt.Frame hasParentFrame()
          Check whether display is embedded in a browser or a separate frame.
 boolean hasPickListener(PvPickListenerIf listener)
          Check for a registered listener.
 boolean incrementAutoRotation()
          Do a single increment of auto-rotation animaton.
 void init()
          Initialize and reset dispay.
 boolean isClip()
          Deprecated. use #isEnabledClip
 boolean isEnabledAnimation()
          Check whether auto-rotation is enabled.
 boolean isEnabledClearScreen()
          Check whether screen is cleared after each repaint.
 boolean isEnabledClip()
          Check whether clipping with front and back plane is enabled.
 boolean isEnabledPainters()
          Check whether painter's algorithm during drawing is enabled.
 boolean isEnabledTags()
          Determine whether tag mode is enabled to move marked elements.
 boolean isEnabledUpdate()
          Determine whether update mechanism is enabled.
 boolean isEnabledZBuffer()
          Check whether z-buffered drawing is enabled.
 boolean isShowingAxes()
          Check whether axes of active geometry is currently showing.
 boolean isShowingBackImage()
          Check drawing of background image of display window.
 boolean isShowingBndBox()
          Check whether bounding box of active geometry is currently showing.
 boolean isShowingDepthcue()
          True if depthcue is enabled.
 boolean isShowingEdgeAura()
          Check flag of drawing of edges by one or both elements adjacent to an edge.
 boolean isShowingEdgesOnce()
          Check flag of drawing of edges by one or both elements adjacent to an edge.
 boolean isShowingFrame()
          Check whether coordinate frame is currently showing.
 boolean isShowingGrid()
          Check whether grid is currently showing.
 boolean isShowingMagnet()
          Check whether cursor attached to vertices if nearby.
protected  boolean isTransformModel()
          Check whether transformation of current model is active, i.e. of model matrix.
 void keyPressed(java.awt.event.KeyEvent event)
           
 void keyReleased(java.awt.event.KeyEvent event)
           
 void keyTyped(java.awt.event.KeyEvent event)
           
 void mouseClicked(java.awt.event.MouseEvent event)
           
 void mouseDragged(java.awt.event.MouseEvent event)
           
 void mouseEntered(java.awt.event.MouseEvent event)
           
 void mouseExited(java.awt.event.MouseEvent event)
           
 void mouseMoved(java.awt.event.MouseEvent event)
           
 void mousePressed(java.awt.event.MouseEvent event)
          Do not react on popup events or other than left mouse clicks.
 void mouseReleased(java.awt.event.MouseEvent event)
           
protected static void normalizedCoordsFromViewport(double[] norm, int x, int y, int width, int height)
          Convert mouse position (x,y) within the viewport = [0,width-1]x[0,height-1] to normalized coordinates such that left lower corner of window is (0,0) in pixel coordinates and it becomes the origin in normalized coordinates.
 void paint(java.awt.Graphics g)
          Override Canvas.paint(g) to initiate redrawing of geometries.
protected  void paintGeom(java.awt.Graphics g)
          Redraw geometries in the backscreen image buffer.
 void processMouseEvent(java.awt.event.MouseEvent event)
           
 void releasePickFocus()
          Release pick focus, i.e. to be the unique listener who receives pick events.
 boolean removeCamera(int type)
          Remove camera from list of registered cameras.
 boolean removeCameraListener(PvCameraListenerIf listener)
          Remove a registered listener from list of registered listeners.
 void removeGeometries()
          Remove all geometries from list of registered geometries.
 boolean removeGeometry(PgGeometryIf aGeom)
          Remove geometry from list of registered geometries.
 boolean removePickListener(PvPickListenerIf listener)
          Remove a registered listener from list of registered listeners.
 void requestPickFocus(PvPickListenerIf listener)
          Request pick focus, i.e. to be the unique listener who receives pick events.
 void resetTransformModel()
          Reset model matrix of current model and modelCamera.
protected  void resetZBuffer()
          Reset z-buffer to lowest integer height.
 void run()
          Do the animation by incrementing the transformation matrix with the last action.
 boolean selectCamera(int type)
          Select current camera used in dispay by id.
 boolean selectGeometry(PgGeometryIf aGeom)
          Select geometry to be active and receive pick events.
 void setAmbientProjection(int mode)
          Set projection mode of ambient space used in model transformations.
 void setAmbientSpace(int mode)
          Set ambient space used in model transformations.
 void setAutoRotation(PdVector axis, double angle)
          Set axis and angle for auto-rotation.
 void setBackgroundColor(java.awt.Color aColor)
          Set color of background of display.
 void setBackgroundImage(java.awt.Image anImage)
          Set background image of display canvas.
 void setBackgroundImage(java.lang.String fileName)
          Set filename of background image of display canvas.
protected  void setCurrentMajorMode(int mode)
           
static void setDefaultSize(java.awt.Dimension size)
          Set default dimension of drawing canvas from outside.
 void setDrawingOrder(int order, PgGeometryIf aGeom)
          Choose z-order of geometry when drawn in display.
 void setEnabledAnimation(boolean aFlag)
          Enable and disable auto-rotation of scene.
 void setEnabledClearScreen(boolean aFlag)
          Enable clearing of screen after each repaint.
 void setEnabledClip(boolean aFlag)
          Enable and disable clipping with front and back plane.
 void setEnabledPainters(boolean aFlag)
          Enable and disable painter's algorithm during drawing, i.e. a z-sort of drawing items.
 void setEnabledTags(boolean aFlag)
          Enable and disable tag mode to move marked elements.
 void setEnabledUpdate(boolean flag)
          Set flag which determines whether update mechanism is enabled.
 void setEnabledZBuffer(boolean aFlag)
          Enable and disable z-buffered drawing of scene.
 void setFarClip(double dist)
          Set far clip distance of current camera, works even if clipping is disabled.
 void setForegroundColor(java.awt.Color aColor)
          Set foreground color.
 void setFrame(java.awt.Frame frame)
          Set reference to container frame of display, e.g. to allow display to hide/show frame.
 void setImageFitMode(int mode)
          Set the mode determining how a background image is scaled w.r.t. the display canvas.
 void setMajorMode(int mode)
          Switch between interaction modes like rotating or scaling, usually done interactively.
 void setName(java.lang.String aName)
          Set name of this display.
 void setNearClip(double dist)
          Set near clip distance of current camera, works even if clipping is disabled.
 void setPaintTag(int flags, boolean val)
          Set all bits which are set in parameter.
 void setParent(PsUpdateIf father)
          Set father of display which receives update events when current class has changed.
 void setPosition(int xPos, int yPos)
          Set position of upper left corner of frame from outside.
 void setSizeWithinFrame(int width, int height)
          Set dimension of display which is included in a parent frame.
 void setTransMatrix(int type, PdMatrix mat)
          Set transformation matrices PV, P, V and their inverses in current camera and display.
 void showAxes(boolean aFlag)
          Set visibility of axes active geometry, and create axes if not available.
 void showBackImage(boolean aFlag)
          Enable and disable drawing of background image of display window.
 void showBndBox(boolean aFlag)
          Set visibility of bounding box active geometry, and create bounding box if not available.
 void showDepthcue(boolean aFlag)
          Enable and disable depthcue drawing.
 void showEdgeAura(boolean aFlag)
          Enable and disable drawing of edges by one or both elements adjacent to an edge.
 void showEdgesOnce(boolean aFlag)
          Enable and disable drawing of edges by one or both elements adjacent to an edge.
 void showFrame(boolean aFlag)
          Set visibility of coordinate frame is shown, and create frame if not available.
 void showGrid(boolean aFlag)
          Set visibility of grid, and create grid if not available.
 void showMagnet(boolean aFlag)
          Attach cursor to vertices if nearby.
 void start()
          Start animation by creating a new thread
 void stop()
          Stop animation by stopping the thread.
 void update(java.awt.Graphics g)
          Override Component.update(g) to initiate redrawing of geometries.
 boolean update(java.lang.Object event)
          Handle update events sent to display by JavaView.
protected  void updateCameraListener(int state)
           
protected  boolean updatePosition(int x, int y)
          Check whether current mouse position has changed and store new position.
 
Methods inherited from class java.awt.Canvas
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getParent, getPeer, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jv.project.PvDisplayIf
addKeyListener, getGraphics, removeKeyListener
 

Field Detail

KEY_0

public static final int KEY_0

KEY_1

public static final int KEY_1

KEY_2

public static final int KEY_2

KEY_3

public static final int KEY_3

KEY_4

public static final int KEY_4

KEY_5

public static final int KEY_5

KEY_6

public static final int KEY_6

KEY_7

public static final int KEY_7

KEY_8

public static final int KEY_8

KEY_9

public static final int KEY_9

KEY_A

public static final int KEY_A

KEY_B

public static final int KEY_B

KEY_C

public static final int KEY_C

KEY_D

public static final int KEY_D

KEY_E

public static final int KEY_E

KEY_F

public static final int KEY_F

KEY_G

public static final int KEY_G

KEY_H

public static final int KEY_H

KEY_I

public static final int KEY_I

KEY_J

public static final int KEY_J

KEY_K

public static final int KEY_K

KEY_L

public static final int KEY_L

KEY_M

public static final int KEY_M

KEY_N

public static final int KEY_N

KEY_O

public static final int KEY_O

KEY_P

public static final int KEY_P

KEY_Q

public static final int KEY_Q

KEY_R

public static final int KEY_R

KEY_S

public static final int KEY_S

KEY_T

public static final int KEY_T

KEY_U

public static final int KEY_U

KEY_V

public static final int KEY_V

KEY_W

public static final int KEY_W

KEY_X

public static final int KEY_X

KEY_Y

public static final int KEY_Y

KEY_Z

public static final int KEY_Z

M_MODE_ORBIT

public static final int M_MODE_ORBIT

M_MODE_SCALE

public static final int M_MODE_SCALE

M_MODE_SCALE_RECT

public static final int M_MODE_SCALE_RECT

M_MODE_TRANS

public static final int M_MODE_TRANS

M_MODE_TRANS_Z

public static final int M_MODE_TRANS_Z

M_MODE_PICK

public static final int M_MODE_PICK

M_MODE_INITIAL_PICK

public static final int M_MODE_INITIAL_PICK

M_MODE_HIGHLIGHT

public static final int M_MODE_HIGHLIGHT

M_MODE_DISPLAY_PICK

public static final int M_MODE_DISPLAY_PICK

M_MODE_MARK

public static final int M_MODE_MARK

M_MODE_MARK_ELEMENTS

public static final int M_MODE_MARK_ELEMENTS

M_MODE_UNMARK

public static final int M_MODE_UNMARK

M_MODE_ADD

public static final int M_MODE_ADD

M_MODE_DELETE

public static final int M_MODE_DELETE

M_MODE_DUPLICATE

public static final int M_MODE_DUPLICATE

M_MODE_ADD_ELEMENT

protected static final int M_MODE_ADD_ELEMENT
Minor mode in display to add new elements to selected geometry.

m_defBackgroundImage

public java.lang.String m_defBackgroundImage
Default background image for display.

m_backgroundImage

public java.lang.String m_backgroundImage
Background image for display.

m_majorModeMessage

protected static final java.lang.String[] m_majorModeMessage
Status message of modes available through PvDisplayIf. Ordering must follow exactly the values of static variables in PvDisplayIf.

M_MODE_RESET

protected static final int M_MODE_RESET

M_MODE_CENTER

protected static final int M_MODE_CENTER

M_MODE_FOCUS

protected static final int M_MODE_FOCUS

M_MODE_START

protected static final int M_MODE_START

M_MODE_STOP

protected static final int M_MODE_STOP

m_minorModeMessage

protected static final java.lang.String[] m_minorModeMessage
Status message of modes not available through PvDisplayIf.

M_SWITCH_GRID

protected static final boolean M_SWITCH_GRID

M_SWITCH_DCUE

protected static final boolean M_SWITCH_DCUE

M_SWITCH_HIDD

protected static final boolean M_SWITCH_HIDD

m_bMouseInside

protected boolean m_bMouseInside
Flag whether mouse is currently inside the display.

m_bMouseDown

protected boolean m_bMouseDown
Flag whether mouse has picked in the display.

m_name

protected java.lang.String m_name

m_bIsEnabledUpdate

protected boolean m_bIsEnabledUpdate
Flag determines whether update mechanism is enabled.

m_frame

protected transient java.awt.Frame m_frame
Reference to container frame of display, e.g. to allow display to hide/show frame.

m_parent

protected transient PsUpdateIf m_parent

m_viewer

protected transient PvViewerIf m_viewer

m_camera

protected java.util.Hashtable m_camera
List of registered cameras.

m_currentCamera

protected PvCamera m_currentCamera
Currently used camera in display.

m_cameraPanel

protected PsPanel m_cameraPanel
Info panel of camera, shared by different cameras.

m_infoPanel

protected PsPanel m_infoPanel
Info panel of display.

m_scene

protected PvScene m_scene
Scene of display containing all geometries.

m_currentGeom

protected jv.viewer.PvGeometry m_currentGeom
Currently selected geometry container. Its associated geometry is m_geomIf.

m_geomIf

protected PgGeometryIf m_geomIf
Associated geometry of currently selected geometry 'm_currentGeom'.

m_bCentered

protected boolean m_bCentered

GEOM_AXES

protected static final java.lang.String GEOM_AXES
Key identifying the special geometry axes.

GEOM_AXES_0

protected static final java.lang.String GEOM_AXES_0
Key identifying the special geometry axes.

GEOM_AXES_1

protected static final java.lang.String GEOM_AXES_1
Key identifying the special geometry axes.

GEOM_AXES_2

protected static final java.lang.String GEOM_AXES_2
Key identifying the special geometry axes.

GEOM_BNDBOX

protected static final java.lang.String GEOM_BNDBOX
Key identifying the special geometry bounding box.

GEOM_FRAME

protected static final java.lang.String GEOM_FRAME
Key identifying the special geometry coordinate frame.

GEOM_XY_GRID

protected static final java.lang.String GEOM_XY_GRID
Key identifying the special geometry xy-grid.

m_specialGeom

protected java.util.Hashtable m_specialGeom
Hashtable contains all active special geometries such as bounding box, grid, or coordinate frame. The keys are strings identifying the geometry.

m_mode

protected int m_mode
Control mode, i.e. scale, shift, rot...

m_modeMajor

protected int m_modeMajor
Major control mode, i.e. scale, shift, rot...

m_defModeMajor

protected int m_defModeMajor
Default major control mode, i.e. scale, shift, rot...

m_modelCamera

protected jv.viewer.PvModelCamera m_modelCamera
Camera used for modeling transformations of geometry.

m_bTransformModel

protected boolean m_bTransformModel
Flag whether transformation of current model or camera is active.

m_ambientSpace

protected int m_ambientSpace
Ambient space used in transformations of model.

m_ambientProj

protected int m_ambientProj
Projection from ambient space to R3 used in transformations of model.

m_cameraListener

protected transient java.util.Vector m_cameraListener
List of camera listeners who will be notified when a camera event occurred.

m_pickListener

protected transient java.util.Vector m_pickListener
List of pick listeners who will be notified when a pick event occurred.

m_pickFocus

protected transient PvPickListenerIf m_pickFocus
Listener who has requested the pick focus to be the only receiver of pick events.

m_pickedVertex

protected int m_pickedVertex
Index of picked vertex in global vertex array of current geometry.

m_pick

protected PdVector m_pick
Pick coordinates of picking in screen coordinates (x,y): m_pick.set(x, y, 0., 1.). Applying inverse of transformation matrix leads to world coordinates, i.e. first three coordinates are world coordinates.

m_markBox

protected PiVector m_markBox
Selected rectangle in screen coordinates during mark-mode.

m_worldPick

protected PdVector m_worldPick
4D world coordinates of hit during picking obtained from current hit point in screen coordinates by applying inverse of transformation matrix. First three coordinates are world coordinates.

m_currLoc

protected java.awt.Dimension m_currLoc
Instance variables are 'int'

m_currNormLoc

protected double[] m_currNormLoc
Instance variables are 'double'

m_imageFitMode

protected int m_imageFitMode
Mode determines how a background image is scaled w.r.t. display canvas.

m_backImage

protected transient java.awt.Image m_backImage
Background image behind geometry. Image is scaled to fill display.

m_nHeight

protected int m_nHeight
Height of display window, height of offscreen image.

m_nWidth

protected int m_nWidth
Width of display window, width of offscreen image.

m_defSize

protected static java.awt.Dimension m_defSize
Default height and width of display window, size of offscreen image.

m_height

protected PuInteger m_height
Height of display window, height of offscreen image.

m_width

protected PuInteger m_width
Width of display window, width of offscreen image.

m_sceneFlags

protected int m_sceneFlags
Flags determining what is painted.

PS_ZOOM

protected static float PS_ZOOM
Zoom factor of each pixel quantity if PostScript printing is enabled. Only used of m_bZoom is enabled.

m_foregroundColor

protected PdColor m_foregroundColor
Foreground color of overlay items such as coordinate axis.

m_backgroundColor

protected PdColor m_backgroundColor
Background color of display canvas.

m_bShowBackface

protected boolean m_bShowBackface
Flag to globally disable drawing faces whose normal points away from observer.

m_bShowBackImage

protected boolean m_bShowBackImage
Flag to enable showing of a background image in display.

m_bShowDepthcue

protected boolean m_bShowDepthcue
Flag to enable drawing of items less intense if they are farther away from observer.

m_bShowEdgesOnce

protected boolean m_bShowEdgesOnce
Flag to enable drawing of common face edges only once, requires neighbour information.

m_bShowEdgeAura

protected boolean m_bShowEdgeAura
Flag to enable drawing of an aura around edges in background color.

m_bShowGrid

protected boolean m_bShowGrid
Flag to enable showing of grid in xy-coordinate plane.

m_bEnableSorting

protected boolean m_bEnableSorting
Flag to enable depth sorting of elements for drawing.

m_bEnableTag

protected boolean m_bEnableTag
Flag to enable modification of tagged vertices and elements.

m_bEnableZBuffer

protected boolean m_bEnableZBuffer
Flag to enable z-buffered drawing.

m_thread

protected transient java.lang.Thread m_thread
Thread created in auto-rotate mode.

m_bEnableAnimation

protected boolean m_bEnableAnimation
Flag to enable auto-rotation.

m_bDrawing

protected boolean m_bDrawing
Internal flag whether a thread is currently painting to display.

m_sleep

protected PuInteger m_sleep
Sleeping period of auto-animation thread between two repaint().

m_bFpsEnabled

protected boolean m_bFpsEnabled
true if measuring frames per second.

m_popup

protected transient java.awt.PopupMenu m_popup
Popup menu to select mouse interaction mode like orbit, scale, translate etc.

m_menuItem

protected transient java.awt.MenuItem[] m_menuItem
Array with popup menu items.
Constructor Detail

PvDisplay

public PvDisplay()
Constructor of display without viewer as parent. Allows display to act as bean.

PvDisplay

public PvDisplay(PvViewerIf viewer)
Constructor of display with given argument viewer as parent.
Parameters:
viewer - parent of display to handle certain events like export.

PvDisplay

public PvDisplay(java.applet.Applet applet,
                 java.awt.Frame frame)
Constructor of display inside applet, or inside frame if applet is null. Frame is used to allow modification of size of display if no viewer available.
Parameters:
applet - which is container of display
frame - which contains applet, or is container of display
Method Detail

init

public void init()
Description copied from interface: PvDisplayIf
Initialize and reset dispay.
Specified by:
init in interface PvDisplayIf

getName

public java.lang.String getName()
Get name of this display.
Specified by:
getName in interface PvDisplayIf
Overrides:
getName in class java.awt.Component

setName

public void setName(java.lang.String aName)
Set name of this display.
Specified by:
setName in interface PvDisplayIf
Overrides:
setName in class java.awt.Component

getFrame

public java.awt.Frame getFrame()
Get reference to container frame of display, e.g. to allow display to hide/show frame.
Specified by:
getFrame in interface PvDisplayIf

setFrame

public void setFrame(java.awt.Frame frame)
Set reference to container frame of display, e.g. to allow display to hide/show frame.
Specified by:
setFrame in interface PvDisplayIf

addPickListener

public void addPickListener(PvPickListenerIf listener)
Add pick listener to receive pick events PvPickEvent.
Specified by:
addPickListener in interface PvDisplayIf
Parameters:
PickListenerIf -  
See Also:
hasPickListener(PvPickListenerIf), removePickListener(PvPickListenerIf)

hasPickListener

public boolean hasPickListener(PvPickListenerIf listener)
Check for a registered listener.
Specified by:
hasPickListener in interface PvDisplayIf
Parameters:
PickListenerIf -  
Returns:
true if registered listener found.
See Also:
addPickListener(PvPickListenerIf), removePickListener(PvPickListenerIf)

removePickListener

public boolean removePickListener(PvPickListenerIf listener)
Remove a registered listener from list of registered listeners.
Specified by:
removePickListener in interface PvDisplayIf
Parameters:
PickListenerIf -  
Returns:
false if listener does not exists.
See Also:
addPickListener(PvPickListenerIf), hasPickListener(PvPickListenerIf)

addCameraListener

public void addCameraListener(PvCameraListenerIf listener)
Add camera listener to receive camera events PvCameraEvent.
Specified by:
addCameraListener in interface PvDisplayIf
Parameters:
CameraListenerIf -  
Returns:
false if same instance already registered.
See Also:
hasCameraListener(PvCameraListenerIf), removeCameraListener(PvCameraListenerIf)

hasCameraListener

public boolean hasCameraListener(PvCameraListenerIf listener)
Check for a registered listener.
Specified by:
hasCameraListener in interface PvDisplayIf
Parameters:
CameraListenerIf -  
Returns:
true if registered listener found.
See Also:
addCameraListener(PvCameraListenerIf), removeCameraListener(PvCameraListenerIf)

removeCameraListener

public boolean removeCameraListener(PvCameraListenerIf listener)
Remove a registered listener from list of registered listeners.
Specified by:
removeCameraListener in interface PvDisplayIf
Parameters:
CameraListenerIf -  
Returns:
false if listener does not exists.
See Also:
addCameraListener(PvCameraListenerIf), hasCameraListener(PvCameraListenerIf)

requestPickFocus

public void requestPickFocus(PvPickListenerIf listener)
Request pick focus, i.e. to be the unique listener who receives pick events. The focus should only be requested temporarily, and must be released after use.
Specified by:
requestPickFocus in interface PvDisplayIf
Parameters:
PickListenerIf -  
See Also:
releasePickFocus()

releasePickFocus

public void releasePickFocus()
Release pick focus, i.e. to be the unique listener who receives pick events. The focus should only be requested temporarily, and must be released after use.
Specified by:
releasePickFocus in interface PvDisplayIf
Parameters:
PickListenerIf -  
See Also:
requestPickFocus(PvPickListenerIf)

addGeometry

public boolean addGeometry(PgGeometryIf aGeom)
Add geometry to display. Display may show several geometries among one of them is the currently active geometry. The active geometry is the target for picking.

After the first geometry is added, the display performs a fit() operation to center and scale the camera such that the geometry is completely visible in the display.

The first geometry added to a display automatically becomes the active geometry. After having added several geometries the active geometry may be selected with selectGeometry().

Note, default drawing order is PvGeometryIf#DRAW_ORDER_STANDARD which means, that z-depth of geometry elements are orderer in comparison with all other geometries. Except, if drawing order is PvGeometryIf#DRAW_ORDER_FRONT or PvGeometryIf.DRAW_ORDER_BACK then no comparison is done during display. Use method #setDrawingOrder(int, jv.project.PgGeometryIf) to modify the drawing order of a geometry after it has been added to the display.

Specified by:
addGeometry in interface PvDisplayIf

removeGeometries

public void removeGeometries()
Remove all geometries from list of registered geometries. The current geometry is null after this call.
Specified by:
removeGeometries in interface PvDisplayIf

removeGeometry

public boolean removeGeometry(PgGeometryIf aGeom)
Remove geometry from list of registered geometries. The current geometry changes if it was the removed geometry.

If the currently active geometry is removed, then the first geometry becomes active.

Specified by:
removeGeometry in interface PvDisplayIf

selectGeometry

public boolean selectGeometry(PgGeometryIf aGeom)
Select geometry to be active and receive pick events.
Specified by:
selectGeometry in interface PvDisplayIf

containsGeometry

public boolean containsGeometry(PgGeometryIf aGeom)
Check whether geometry is registered in display.
Specified by:
containsGeometry in interface PvDisplayIf

getAllGeometryContainers

protected jv.viewer.PvGeometry[] getAllGeometryContainers()
Get array with all geometry containers including registered and special geometries. Method is used internally by this class.

getGeometryContainers

protected jv.viewer.PvGeometry[] getGeometryContainers()
Get array with registered geometry containers. Method does not return any special geometries like bounding box.

getAllGeometries

protected PgGeometryIf[] getAllGeometries()
Get array with all geometries including registered and special geometries. Method is used internally by this class.

getGeometries

public PgGeometryIf[] getGeometries()
Get array with registered geometries. Method does not return any special geometries like bounding box.
Specified by:
getGeometries in interface PvDisplayIf

getSelectedGeometry

public PgGeometryIf getSelectedGeometry()
Get currently selected geometry.
Specified by:
getSelectedGeometry in interface PvDisplayIf

center

public void center()
Center geometry in window, do no scaling

fit

public void fit()
Center and scale camera such that geometry fits exactly into window.
Specified by:
fit in interface PvDisplayIf

getBackgroundColor

public java.awt.Color getBackgroundColor()
Get color of background of display. If background image is set, then color has no influence.
Specified by:
getBackgroundColor in interface PvDisplayIf

setBackgroundColor

public void setBackgroundColor(java.awt.Color aColor)
Set color of background of display. If background image is set, then color has no influence.
Specified by:
setBackgroundColor in interface PvDisplayIf

getForegroundColor

public java.awt.Color getForegroundColor()
Get foreground color. Currently neither defined nor used.
Specified by:
getForegroundColor in interface PvDisplayIf

setForegroundColor

public void setForegroundColor(java.awt.Color aColor)
Set foreground color. Currently neither defined nor used.
Specified by:
setForegroundColor in interface PvDisplayIf

isEnabledAnimation

public boolean isEnabledAnimation()
Check whether auto-rotation is enabled.
Specified by:
isEnabledAnimation in interface PvDisplayIf

setEnabledAnimation

public void setEnabledAnimation(boolean aFlag)
Enable and disable auto-rotation of scene.
Specified by:
setEnabledAnimation in interface PvDisplayIf

getAmbientSpace

public int getAmbientSpace()
Get ambient space used in model transformations.

setAmbientSpace

public void setAmbientSpace(int mode)
Set ambient space used in model transformations.

getAmbientProjection

public int getAmbientProjection()
Get projection mode of ambient space used in model transformations.

setAmbientProjection

public void setAmbientProjection(int mode)
Set projection mode of ambient space used in model transformations.

isTransformModel

protected boolean isTransformModel()
Check whether transformation of current model is active, i.e. of model matrix. Otherwise, whole scene is transformed, i.e. project and view matrix. Method is protected to allow JAX to eliminate method and class PvModelCamera.

enableTransformModel

protected void enableTransformModel(boolean aFlag)
Enable transformation of modeling matrix M of single geometry rather than transforming the whole scene by modifying project P and view V matrices. Method is protected to allow JAX to eliminate method and class PvModelCamera.

resetTransformModel

public void resetTransformModel()
Reset model matrix of current model and modelCamera.

getImageFitMode

public int getImageFitMode()
Get the mode determining how a background image is scaled w.r.t. the display canvas.
Specified by:
getImageFitMode in interface PvDisplayIf

setImageFitMode

public void setImageFitMode(int mode)
Set the mode determining how a background image is scaled w.r.t. the display canvas.
Specified by:
setImageFitMode in interface PvDisplayIf

isShowingBackImage

public boolean isShowingBackImage()
Check drawing of background image of display window.
Specified by:
isShowingBackImage in interface PvDisplayIf

showBackImage

public void showBackImage(boolean aFlag)
Enable and disable drawing of background image of display window.
Specified by:
showBackImage in interface PvDisplayIf

isShowingDepthcue

public boolean isShowingDepthcue()
True if depthcue is enabled. No depthcue for non-perspective projections. Depthcue is always switched off for non-perspective projections since they usually show planar geometries where depthcue makes not too much sense.
Specified by:
isShowingDepthcue in interface PvDisplayIf

showDepthcue

public void showDepthcue(boolean aFlag)
Enable and disable depthcue drawing.
Specified by:
showDepthcue in interface PvDisplayIf

isShowingEdgesOnce

public boolean isShowingEdgesOnce()
Check flag of drawing of edges by one or both elements adjacent to an edge.
Specified by:
isShowingEdgesOnce in interface PvDisplayIf

showEdgesOnce

public void showEdgesOnce(boolean aFlag)
Enable and disable drawing of edges by one or both elements adjacent to an edge.
Specified by:
showEdgesOnce in interface PvDisplayIf

isShowingEdgeAura

public boolean isShowingEdgeAura()
Check flag of drawing of edges by one or both elements adjacent to an edge.
Specified by:
isShowingEdgeAura in interface PvDisplayIf

showEdgeAura

public void showEdgeAura(boolean aFlag)
Enable and disable drawing of edges by one or both elements adjacent to an edge.
Specified by:
showEdgeAura in interface PvDisplayIf

setDrawingOrder

public void setDrawingOrder(int order,
                            PgGeometryIf aGeom)
Choose z-order of geometry when drawn in display. For possible values see e.g. PvGeometryIf#DRAW_ORDER_STANDARD.
Specified by:
setDrawingOrder in interface PvDisplayIf
See Also:
PvGeometryIf

isShowingGrid

public boolean isShowingGrid()
Check whether grid is currently showing.
Specified by:
isShowingGrid in interface PvDisplayIf

showGrid

public void showGrid(boolean aFlag)
Set visibility of grid, and create grid if not available.
Specified by:
showGrid in interface PvDisplayIf

isShowingFrame

public boolean isShowingFrame()
Check whether coordinate frame is currently showing.
Specified by:
isShowingFrame in interface PvDisplayIf

showFrame

public void showFrame(boolean aFlag)
Set visibility of coordinate frame is shown, and create frame if not available.
Specified by:
showFrame in interface PvDisplayIf

isShowingBndBox

public boolean isShowingBndBox()
Check whether bounding box of active geometry is currently showing.
Specified by:
isShowingBndBox in interface PvDisplayIf

showBndBox

public void showBndBox(boolean aFlag)
Set visibility of bounding box active geometry, and create bounding box if not available.
Specified by:
showBndBox in interface PvDisplayIf

isEnabledClearScreen

public boolean isEnabledClearScreen()
Check whether screen is cleared after each repaint.

setEnabledClearScreen

public void setEnabledClearScreen(boolean aFlag)
Enable clearing of screen after each repaint.

isShowingAxes

public boolean isShowingAxes()
Check whether axes of active geometry is currently showing.
Specified by:
isShowingAxes in interface PvDisplayIf

showAxes

public void showAxes(boolean aFlag)
Set visibility of axes active geometry, and create axes if not available.
Specified by:
showAxes in interface PvDisplayIf

isShowingMagnet

public boolean isShowingMagnet()
Check whether cursor attached to vertices if nearby.
Specified by:
isShowingMagnet in interface PvDisplayIf

showMagnet

public void showMagnet(boolean aFlag)
Attach cursor to vertices if nearby.
Specified by:
showMagnet in interface PvDisplayIf

getZBuffer

protected int[][] getZBuffer()
Get z-buffer array with depth information of each pixel. Array is available only if z-buffered drawing is enabled.

resetZBuffer

protected void resetZBuffer()
Reset z-buffer to lowest integer height. Method requires that z-buffered drawing is enabled.

isEnabledZBuffer

public boolean isEnabledZBuffer()
Check whether z-buffered drawing is enabled.
Specified by:
isEnabledZBuffer in interface PvDisplayIf

setEnabledZBuffer

public void setEnabledZBuffer(boolean aFlag)
Enable and disable z-buffered drawing of scene.
Specified by:
setEnabledZBuffer in interface PvDisplayIf

isEnabledTags

public boolean isEnabledTags()
Determine whether tag mode is enabled to move marked elements.

setEnabledTags

public void setEnabledTags(boolean aFlag)
Enable and disable tag mode to move marked elements.

isEnabledPainters

public boolean isEnabledPainters()
Check whether painter's algorithm during drawing is enabled.
Specified by:
isEnabledPainters in interface PvDisplayIf

setEnabledPainters

public void setEnabledPainters(boolean aFlag)
Enable and disable painter's algorithm during drawing, i.e. a z-sort of drawing items.
Specified by:
setEnabledPainters in interface PvDisplayIf

isEnabledClip

public boolean isEnabledClip()
Check whether clipping with front and back plane is enabled.
Specified by:
isEnabledClip in interface PvDisplayIf

setEnabledClip

public void setEnabledClip(boolean aFlag)
Enable and disable clipping with front and back plane.
Specified by:
setEnabledClip in interface PvDisplayIf

isClip

public boolean isClip()
Deprecated. use #isEnabledClip

Check whether clipping with front and back plane is enabled.
Specified by:
isClip in interface PvDisplayIf

enableClip

public void enableClip(boolean aFlag)
Deprecated. use #setEnabledClip

Enable and disable clipping with front and back plane.
Specified by:
enableClip in interface PvDisplayIf

getNearClip

public double getNearClip()
Get near clip distance of current camera. Returns a value even if clipping is disabled.
Specified by:
getNearClip in interface PvDisplayIf

setNearClip

public void setNearClip(double dist)
Set near clip distance of current camera, works even if clipping is disabled.
Specified by:
setNearClip in interface PvDisplayIf

getFarClip

public double getFarClip()
Get far clip distance of current camera. Returns a value even if clipping is disabled.
Specified by:
getFarClip in interface PvDisplayIf

setFarClip

public void setFarClip(double dist)
Set far clip distance of current camera, works even if clipping is disabled.
Specified by:
setFarClip in interface PvDisplayIf

getTransMatrix

public PdMatrix getTransMatrix(int type)
Get 4*4 transformation matrix or components from current camera and display. Allows to transform world coordinates into screen coordinates [0,0]*[width-1,height-1] of display.
Specified by:
getTransMatrix in interface PvDisplayIf
Following copied from interface: jv.project.PvDisplayIf
Parameters:
type - Any matrix type jv.project.PvDisplayIf#MATRIX_...

setTransMatrix

public void setTransMatrix(int type,
                           PdMatrix mat)
Set transformation matrices PV, P, V and their inverses in current camera and display. Allows to transform world coordinates into screen coordinates [0,0]*[width-1,height-1] of display.

Modeling matrix should be set in original geometry model.

Specified by:
setTransMatrix in interface PvDisplayIf
Following copied from interface: jv.project.PvDisplayIf
Parameters:
type - Any matrix type jv.project.PvDisplayIf#MATRIX_...

addCamera

public int addCamera(java.lang.String aName,
                     PvCamera aCamera)
Add new camera and make it accessible under the given name. Most applications use the built-in cameras. TODO: Method currently does not allow to add user defined cameras.
Returns:
unique key of camera which allows to select camera, or -1 if error.

getCamera

public PvCameraIf getCamera()
Get current camera object.
Specified by:
getCamera in interface PvDisplayIf
Returns:
current camera object

getCurrentCameraType

protected int getCurrentCameraType()
Get type of current camera, for example, perspective, xy-projection etc. Type is among PvDisplayIf#CAMERA_PERSPECTIVE, PvDisplayIf#CAMERA_ORTHO_XY, PvDisplayIf#CAMERA_ORTHO_XZ, PvDisplayIf#CAMERA_ORTHO_YZ, For a list of possible type see PvDisplayIf.
Returns:
type type of current camera

getCamera

public PvCamera getCamera(int type)
Get a camera object by type. Type is among PvDisplayIf#CAMERA_PERSPECTIVE, PvDisplayIf#CAMERA_ORTHO_XY, PvDisplayIf#CAMERA_ORTHO_XZ, PvDisplayIf#CAMERA_ORTHO_YZ, For a list of possible type see PvDisplayIf.
Parameters:
type - of camera
Returns:
null if argument out of bounds or camera not found.

selectCamera

public boolean selectCamera(int type)
Select current camera used in dispay by id. If a requested system cameratio has not been instantiated yet, then it is created now. Type is among PvDisplayIf#CAMERA_PERSPECTIVE, PvDisplayIf#CAMERA_ORTHO_XY, PvDisplayIf#CAMERA_ORTHO_XZ, PvDisplayIf#CAMERA_ORTHO_YZ, For a list of possible type see PvDisplayIf.
Specified by:
selectCamera in interface PvDisplayIf
Parameters:
type - of camera
Returns:
false if type is outOfBounds.

removeCamera

public boolean removeCamera(int type)
Remove camera from list of registered cameras. Type is among PvDisplayIf#CAMERA_PERSPECTIVE, PvDisplayIf#CAMERA_ORTHO_XY, PvDisplayIf#CAMERA_ORTHO_XZ, PvDisplayIf#CAMERA_ORTHO_YZ, For a list of possible type see PvDisplayIf.
Parameters:
type - of camera
Returns:
true if camera was found and successfully removed.

getPosition

public java.awt.Point getPosition(int xPos,
                                  int yPos)
Get upper left corner of frame.

setPosition

public void setPosition(int xPos,
                        int yPos)
Set position of upper left corner of frame from outside.

getSize

public java.awt.Dimension getSize()
Get height of drawing canvas.
Specified by:
getSize in interface PvDisplayIf
Overrides:
getSize in class java.awt.Component

setSizeWithinFrame

public void setSizeWithinFrame(int width,
                               int height)
Set dimension of display which is included in a parent frame. This call should be used instead of a direct call of #setSize(Dimension) resp. #setSize(int, int). Size of parent frame is the size of the display plus the its border margins.
Specified by:
setSizeWithinFrame in interface PvDisplayIf
Parameters:
width - width of display area, not of parent frame
height - height of display area, not of parent frame

setDefaultSize

public static void setDefaultSize(java.awt.Dimension size)
Set default dimension of drawing canvas from outside.

hasParentFrame

protected java.awt.Frame hasParentFrame()
Check whether display is embedded in a browser or a separate frame. The only way to distinguish these two cases is to check whether display has a PsMainFrame as parent. We cannot check for parent being an applet since applets are also embedded in a PsMainFrame.

getFather

public PsUpdateIf getFather()
Get father of display. Method must be defined since PvDisplay does not derive from PsObject.
Specified by:
getFather in interface PsUpdateIf
Following copied from interface: jv.object.PsUpdateIf
See Also:
PsUpdateIf.setParent(PsUpdateIf), PsUpdateIf.update(Object)

setParent

public void setParent(PsUpdateIf father)
Set father of display which receives update events when current class has changed. Method must be defined since PvDisplay does not derive from PsObject.
Specified by:
setParent in interface PsUpdateIf
Following copied from interface: jv.object.PsUpdateIf
Parameters:
aParent - will receive events which this does not handle
See Also:
PsUpdateIf.getFather(), PsUpdateIf.update(Object)

isEnabledUpdate

public boolean isEnabledUpdate()
Determine whether update mechanism is enabled.
Specified by:
isEnabledUpdate in interface PvDisplayIf

setEnabledUpdate

public void setEnabledUpdate(boolean flag)
Set flag which determines whether update mechanism is enabled.
Specified by:
setEnabledUpdate in interface PvDisplayIf

update

public boolean update(java.lang.Object event)
Handle update events sent to display by JavaView. Notice, Java itself sends update(Graphics) calls to display too.
Specified by:
update in interface PvDisplayIf
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)

hasPaintTag

public boolean hasPaintTag(int flags)
Check whether either if the bits in parameter has been set.
Specified by:
hasPaintTag in interface PvDisplayIf
See Also:
setPaintTag(int, boolean)

setPaintTag

public void setPaintTag(int flags,
                        boolean val)
Set all bits which are set in parameter. See jv.project.PvDisplayIf for a list of possible flags.

Special flag for internal purpose is PAINT_ZOOM: Scale transformation matrix to simulate floating point accuracy in pixel integers. Required for PostScript printing to increase pixel accurracy.

HACK: This PostScript Driver temporarily scales all integer valued quantities during display by a factor of 1000 to increase accuracy. The variable PvThickGraphics.ZOOM is set to allow to adjust all 'thickness' sizes as well. The thickness sizes are not scaled by PostScript, so we must do it in PvThickGraphics by hand. This procedure is very error proneous.

Setting flag PvDisplayIf#PAINT_ALL invokes a repaint() of the display, just for convience.

Specified by:
setPaintTag in interface PvDisplayIf
See Also:
hasPaintTag(int)

paintGeom

protected void paintGeom(java.awt.Graphics g)
Redraw geometries in the backscreen image buffer. External applications may call this method with different graphics objects, e.g. JavaView PostScript printing calls methods with jv.loader.PSGr.

paint

public void paint(java.awt.Graphics g)
Override Canvas.paint(g) to initiate redrawing of geometries.
Overrides:
paint in class java.awt.Canvas

update

public void update(java.awt.Graphics g)
Override Component.update(g) to initiate redrawing of geometries.
Overrides:
update in class java.awt.Component

getImage

public java.awt.Image getImage()
Make image of display available to outside world.
Specified by:
getImage in interface PvDisplayIf

getBackgroundImage

public java.awt.Image getBackgroundImage()
Make image of display available to outside world.
Specified by:
getBackgroundImage in interface PvDisplayIf

setBackgroundImage

public void setBackgroundImage(java.awt.Image anImage)
Set background image of display canvas.
Specified by:
setBackgroundImage in interface PvDisplayIf

getBackgroundImageFile

public java.lang.String getBackgroundImageFile()
Get filename of background image of display canvas.
Returns:
relative file name of image.

setBackgroundImage

public void setBackgroundImage(java.lang.String fileName)
Set filename of background image of display canvas. Method tries to load file immediately.
Specified by:
setBackgroundImage in interface PvDisplayIf
Parameters:
fileName - relative file name of image.

normalizedCoordsFromViewport

protected static void normalizedCoordsFromViewport(double[] norm,
                                                   int x,
                                                   int y,
                                                   int width,
                                                   int height)
Convert mouse position (x,y) within the viewport = [0,width-1]x[0,height-1] to normalized coordinates such that left lower corner of window is (0,0) in pixel coordinates and it becomes the origin in normalized coordinates. Normalized coordinates of a square window are in the range [-1,+1]*[-1,+1]. Since the aspect ratio is kept, the normalized coordinates of the minimal window edge is mapped to [-1,+1], and the larger edge is mapped to a larger interval.

Usage:

	public boolean mouseDrag(Event event, int x, int y) {
		normalizedCoordsFromViewport(normPosition, x, y, width, height);
 

updatePosition

protected boolean updatePosition(int x,
                                 int y)
Check whether current mouse position has changed and store new position.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

processMouseEvent

public void processMouseEvent(java.awt.event.MouseEvent event)
Overrides:
processMouseEvent in class java.awt.Component

mousePressed

public void mousePressed(java.awt.event.MouseEvent event)
Do not react on popup events or other than left mouse clicks.
Specified by:
mousePressed in interface java.awt.event.MouseListener

updateCameraListener

protected void updateCameraListener(int state)
Parameters:
state - current state of mouse using MOUSE_PICKED, MOUSE_DRAGGED

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent event)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent event)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

getPickEvent

public PvPickEvent getPickEvent(int x,
                                int y)
Find intersection of ray through pick locus on registered geometries. First, intersection of ray with active geometry is tested, then intersection with all other visible geometries in the order they appear in the display panel. Non visible geometries are ignored.

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent event)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent event)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent event)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent event)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

getMajorMode

public int getMajorMode()
Description copied from interface: PvDisplayIf
Get current interaction mode.
Specified by:
getMajorMode in interface PvDisplayIf

setMajorMode

public void setMajorMode(int mode)
Description copied from interface: PvDisplayIf
Switch between interaction modes like rotating or scaling, usually done interactively.
Specified by:
setMajorMode in interface PvDisplayIf

setCurrentMajorMode

protected void setCurrentMajorMode(int mode)

keyTyped

public void keyTyped(java.awt.event.KeyEvent event)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent event)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent event)
Specified by:
keyPressed in interface java.awt.event.KeyListener

getInfoPanel

public PsPanel getInfoPanel()
Get info panel of display. Display allocates panel if it does not exist.
Specified by:
getInfoPanel in interface PvDisplayIf

getCameraPanel

public PsPanel getCameraPanel()
Get info panel of current camera. Camera allocates panel if it does not exist.
Specified by:
getCameraPanel in interface PvDisplayIf

getMinimumSize

public java.awt.Dimension getMinimumSize()
Assure correct horizontal size of all project panels. TODO: locate preferred horizontal size in PsConfig. This method was necessary since especially PaParmSurface_IP tends to shrink.
Overrides:
getMinimumSize in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Assure correct horizontal size of all project panels. TODO: locate preferred horizontal size in PsConfig. This method was necessary since especially PaParmSurface_IP tends to shrink.
Overrides:
getPreferredSize in class java.awt.Component

start

public void start()
Start animation by creating a new thread
Specified by:
start in interface PvDisplayIf

stop

public void stop()
Stop animation by stopping the thread. Netscape does not like to suspend a thread.
Specified by:
stop in interface PvDisplayIf

setAutoRotation

public void setAutoRotation(PdVector axis,
                            double angle)
Set axis and angle for auto-rotation.
Specified by:
setAutoRotation in interface PvDisplayIf

incrementAutoRotation

public boolean incrementAutoRotation()
Do a single increment of auto-rotation animaton. Method is invoked from PvViewer to generate Gif animations.
Specified by:
incrementAutoRotation in interface PvDisplayIf

run

public void run()
Do the animation by incrementing the transformation matrix with the last action.
Specified by:
run in interface java.lang.Runnable

JavaView® v2.00.008

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