fr.inria.zvtm.engine
Class ViewPanel

java.lang.Object
  extended by fr.inria.zvtm.engine.ViewPanel
All Implemented Interfaces:
ComponentListener, MouseListener, MouseMotionListener, MouseWheelListener, EventListener
Direct Known Subclasses:
AgileViewPanel, GLViewPanel, OffscreenViewPanel, StdViewPanel

public abstract class ViewPanel
extends Object
implements MouseListener, MouseMotionListener, MouseWheelListener, ComponentListener

JPanel used to paint the content of a view (all camera layers).

Author:
Emmanuel Pietriga

Field Summary
 int activeLayer
          active layer in this view (corresponds to the index of a camera in cams[])
protected  Cursor awtCursor
          the AWT cursor
 Camera[] cams
          list of cameras used in this view
static short CIRCLE
          should a circle between point where we started dragging the mouse and current point
protected  int curDragx
          drag-segment/rectangle coords
protected  int curDragy
          drag-segment/rectangle coords
protected  boolean drawVTMcursor
          VTM cursor is drawn only when AWT cursor is set to CUSTOM_CURSOR
protected  Image FIRST_ORDER_PAN_WIDGET
           
protected  Lens lens
          Lens (fisheye, etc.)
static int NO_COORDS
          Value that specifies that there isn't any point for which no mouse move/drag event is sent.
static short NONE
          draw no oval between point where we started dragging the mouse and current point
protected  int oldX
          Previous coordinates of the mouse.
protected  int oldY
           
protected  int origDragx
          drag-segment/rectangle coords
protected  int origDragy
          drag-segment/rectangle coords
static short OVAL
          draw an oval between point where we started dragging the mouse and current point
 View parent
          view
protected  Graphics2D stableRefToBackBufferGraphics
           
 
Constructor Summary
ViewPanel()
           
 
Method Summary
protected  void afterLensHook()
           
protected  void backgroundHook()
           
 void componentHidden(ComponentEvent e)
           
 void componentMoved(ComponentEvent e)
           
 void componentResized(ComponentEvent e)
           
 void componentShown(ComponentEvent e)
           
protected  void drawPortals()
           
protected  void foregroundHook()
           
 boolean getAutoRequestFocusOnMouseEnter()
          Tells whether the viewpanel is automatically requesting focus when cursor enters it or not.
abstract  Component getComponent()
          Get the underlying Swing component.
 long getDelay()
          Get the actual instantaneous refresh rate.
 Glyph[] getGlyphsUnderCursorList()
          Get the list of glyphs currently under mouse (last entry is last glyph entered) This returns a copy of the actual array managed by VCursor at the time the method is called (in other words, the array returned by this method is not synchronized with the actual list over time)
abstract  BufferedImage getImage()
           
protected  Lens getLens()
          return Lens cyrrently used by this view (null if none)
 ViewListener[] getListeners()
           
 Point getNoEventCoordinates()
          Get the coordinates of a particular point in view panel coordinates for which mouse move/drag events are ignored, if any.
abstract  int getRefreshRate()
          Gets the maximum view refresh rate.
 VCursor getVCursor()
          Get VCursor instance associated with the parent view.
protected  int[] getVisibilityPadding()
          get the padding values customizing the region inside the view for which objects are actually visible
 void hideFirstOrderPanWidget()
          Hide the icon representing first-order-of-control panning.
 boolean isShowingFirstOrderPanWidget()
          Is the icon used to represent first-order-of-control panning currently being shown.
 Glyph lastGlyphEntered()
          last glyph the mouse entered in (for this view and current active layer)
 void mouseClicked(MouseEvent e)
          send event to application event handler
 void mouseDragged(MouseEvent e)
          send event to application event handler
 void mouseEntered(MouseEvent e)
          Mouse cursor entered this view.
 void mouseExited(MouseEvent e)
          Mouse cursor exited this view.
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
          send event to application event handler
 void mouseReleased(MouseEvent e)
          send event to application event handler
 void mouseWheelMoved(MouseWheelEvent e)
          send event to application event handler
protected  void portalsHook()
           
 void setAutoRequestFocusOnMouseEnter(boolean b)
          Should the viewpanel automatically request focus when cursor enters it or not.
protected  void setAWTCursor(Cursor c)
          Set the cursor.
protected  void setAWTCursor(int cursorType)
          Set the cursor.
 void setDrawCursor(boolean b)
           
 void setDrawDrag(boolean b)
          true will draw a segment between origin of drag and current cursor pos until drag is finished (still visible for backward compatibility reasons - should use setDrawSegment instead)
 void setDrawOval(short s)
          draw a circle between origin of drag and current cursor pos until drag is finished (drag segment represents the radius of the circle, not its diameter) - use OVAL for any oval, CIRCLE for circle, NONE to stop drawing it
 void setDrawRect(boolean b)
          true will draw a rectangle between origin of drag and current cursor pos until drag is finished
 void setDrawSegment(boolean b)
          true will draw a segment between origin of drag and current cursor pos until drag is finished
 void setFirstOrderPanWidget(Image icon)
          Set the icon used to represent first-order-of-control panning.
protected  Lens setLens(Lens l)
          set a lens for this view ; set to null to remove an existing lens
 void setNoEventCoordinates(int x, int y)
          Set a particular point in view panel coordinates for which mouse move/drag events should be ignored.
abstract  void setRefreshRate(int r)
          Sets the maximum view refresh rate.
protected  void setVisibilityPadding(int[] wnesPadding)
          set a padding for customizing the region inside the view for which objects are actually visible
 void showFirstOrderPanWidget(int jpx, int jpy)
          Show the icon representing first-order-of-control panning.
 Point spaceToViewCoords(Camera c, double vx, double vy)
          Converts between virtual space coordinates and view coordinates for a given camera.
 Point2D.Double viewToSpaceCoords(Camera c, int jpx, int jpy)
          Converts between view coordinates and virtual space coordinates for a given camera.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final short NONE
draw no oval between point where we started dragging the mouse and current point

See Also:
Constant Field Values

OVAL

public static final short OVAL
draw an oval between point where we started dragging the mouse and current point

See Also:
Constant Field Values

CIRCLE

public static final short CIRCLE
should a circle between point where we started dragging the mouse and current point

See Also:
Constant Field Values

stableRefToBackBufferGraphics

protected Graphics2D stableRefToBackBufferGraphics

cams

public Camera[] cams
list of cameras used in this view


activeLayer

public int activeLayer
active layer in this view (corresponds to the index of a camera in cams[])


parent

public View parent
view


oldX

protected int oldX
Previous coordinates of the mouse. Used to erase old cursor before repainting in XOR mode. Also used to resetMouseInsidePortals


oldY

protected int oldY

origDragx

protected int origDragx
drag-segment/rectangle coords


origDragy

protected int origDragy
drag-segment/rectangle coords


curDragx

protected int curDragx
drag-segment/rectangle coords


curDragy

protected int curDragy
drag-segment/rectangle coords


FIRST_ORDER_PAN_WIDGET

protected Image FIRST_ORDER_PAN_WIDGET

drawVTMcursor

protected boolean drawVTMcursor
VTM cursor is drawn only when AWT cursor is set to CUSTOM_CURSOR


awtCursor

protected Cursor awtCursor
the AWT cursor


lens

protected Lens lens
Lens (fisheye, etc.)


NO_COORDS

public static final int NO_COORDS
Value that specifies that there isn't any point for which no mouse move/drag event is sent.

See Also:
Constant Field Values
Constructor Detail

ViewPanel

public ViewPanel()
Method Detail

getListeners

public ViewListener[] getListeners()

getComponent

public abstract Component getComponent()
Get the underlying Swing component.


setAWTCursor

protected void setAWTCursor(int cursorType)
Set the cursor. Either the ZVTM cursor or one of the default AWT cursors.

Parameters:
cursorType - any of the cursor type values declared in java.awt.Cursor, such as DEFAULT_CURSOR, CROSSHAIR_CURSOR HAND_CURSOR, etc. To get the ZVTM cursor, use Cursor.CUSTOM_CURSOR.

setDrawCursor

public void setDrawCursor(boolean b)

setAWTCursor

protected void setAWTCursor(Cursor c)
Set the cursor. Replaces the ZVTM cursor by a bitmap cursor similar to the default AWT cursors.

Parameters:
c - an AWT cursor instantiated e.g. by calling java.awt.Toolkit.createCustomCursor(Image cursor, Point hotSpot, String name)

viewToSpaceCoords

public Point2D.Double viewToSpaceCoords(Camera c,
                                        int jpx,
                                        int jpy)
Converts between view coordinates and virtual space coordinates for a given camera.

Parameters:
c - camera
jpx - x coordinate in the panel system (JPanel coordinates)
jpy - y coordinate in the panel system (JPanel coordinates)
Returns:
(x,y) coordinates in virtual space
See Also:
spaceToViewCoords(Camera cam, double vx, double vy)

spaceToViewCoords

public Point spaceToViewCoords(Camera c,
                               double vx,
                               double vy)
Converts between virtual space coordinates and view coordinates for a given camera.

Parameters:
c - camera
vx - x coordinate in virtual space
vy - y coordinate in virtual space
Returns:
(x,y) coordinates in the view system (JPanel coordinates)
See Also:
viewToSpaceCoords(Camera cam, int jpx, int jpy)

setDrawDrag

public void setDrawDrag(boolean b)
true will draw a segment between origin of drag and current cursor pos until drag is finished (still visible for backward compatibility reasons - should use setDrawSegment instead)


setDrawSegment

public void setDrawSegment(boolean b)
true will draw a segment between origin of drag and current cursor pos until drag is finished


setDrawRect

public void setDrawRect(boolean b)
true will draw a rectangle between origin of drag and current cursor pos until drag is finished


setDrawOval

public void setDrawOval(short s)
draw a circle between origin of drag and current cursor pos until drag is finished (drag segment represents the radius of the circle, not its diameter) - use OVAL for any oval, CIRCLE for circle, NONE to stop drawing it


showFirstOrderPanWidget

public void showFirstOrderPanWidget(int jpx,
                                    int jpy)
Show the icon representing first-order-of-control panning.

Parameters:
jpx - x-coordinate of icon's center in JPanel coordinate system
jpy - y-coordinate of icon's center in JPanel coordinate system
See Also:
hideFirstOrderPanWidget(), setFirstOrderPanWidget(Image icon), isShowingFirstOrderPanWidget()

hideFirstOrderPanWidget

public void hideFirstOrderPanWidget()
Hide the icon representing first-order-of-control panning.

See Also:
showFirstOrderPanWidget(int jpx, int jpy), setFirstOrderPanWidget(Image icon), isShowingFirstOrderPanWidget()

setFirstOrderPanWidget

public void setFirstOrderPanWidget(Image icon)
Set the icon used to represent first-order-of-control panning.

See Also:
showFirstOrderPanWidget(int jpx, int jpy), hideFirstOrderPanWidget(), isShowingFirstOrderPanWidget()

isShowingFirstOrderPanWidget

public boolean isShowingFirstOrderPanWidget()
Is the icon used to represent first-order-of-control panning currently being shown.

See Also:
showFirstOrderPanWidget(int jpx, int jpy), hideFirstOrderPanWidget(), setFirstOrderPanWidget(Image icon)

mousePressed

public void mousePressed(MouseEvent e)
send event to application event handler

Specified by:
mousePressed in interface MouseListener

mouseClicked

public void mouseClicked(MouseEvent e)
send event to application event handler

Specified by:
mouseClicked in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
send event to application event handler

Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Mouse cursor entered this view.

Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Mouse cursor exited this view.

Specified by:
mouseExited in interface MouseListener

setAutoRequestFocusOnMouseEnter

public void setAutoRequestFocusOnMouseEnter(boolean b)
Should the viewpanel automatically request focus when cursor enters it or not. Default is false for external views (EView). Default is true for panel views (PView) as keyboard events don't get sent otherwise.


getAutoRequestFocusOnMouseEnter

public boolean getAutoRequestFocusOnMouseEnter()
Tells whether the viewpanel is automatically requesting focus when cursor enters it or not. Default is false for external views (EView). Default is true for panel views (PView) as keyboard events don't get sent otherwise.


setNoEventCoordinates

public void setNoEventCoordinates(int x,
                                  int y)
Set a particular point in view panel coordinates for which mouse move/drag events should be ignored. This is useful, e.g., to completely ignore mouse repositioning events triggered by an AWT Robot.

Parameters:
x - x-coordinate in the JPanel's system ; set to ViewPanel.NO_COORDS to cancel any previsouly set point.
y - y-coordinate in the JPanel's system ; set to ViewPanel.NO_COORDS to cancel any previsouly set point.

getNoEventCoordinates

public Point getNoEventCoordinates()
Get the coordinates of a particular point in view panel coordinates for which mouse move/drag events are ignored, if any. Such a point is useful, e.g., to completely ignore mouse repositioning events triggered by an AWT Robot.

Returns:
(x,y) coordinates of the point in the JPanel's system, null if no such point is set.

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener

mouseDragged

public void mouseDragged(MouseEvent e)
send event to application event handler

Specified by:
mouseDragged in interface MouseMotionListener

mouseWheelMoved

public void mouseWheelMoved(MouseWheelEvent e)
send event to application event handler

Specified by:
mouseWheelMoved in interface MouseWheelListener

getVCursor

public VCursor getVCursor()
Get VCursor instance associated with the parent view.


lastGlyphEntered

public Glyph lastGlyphEntered()
last glyph the mouse entered in (for this view and current active layer)


getGlyphsUnderCursorList

public Glyph[] getGlyphsUnderCursorList()
Get the list of glyphs currently under mouse (last entry is last glyph entered) This returns a copy of the actual array managed by VCursor at the time the method is called (in other words, the array returned by this method is not synchronized with the actual list over time)


getImage

public abstract BufferedImage getImage()

setRefreshRate

public abstract void setRefreshRate(int r)
Sets the maximum view refresh rate. Beyond which ZVTM won't go even if it can.

Parameters:
r - positive integer in milliseconds

getRefreshRate

public abstract int getRefreshRate()
Gets the maximum view refresh rate. Beyond which ZVTM won't go even if it can.

Returns:
positive integer in milliseconds

getDelay

public long getDelay()
Get the actual instantaneous refresh rate. As the delay (in milliseconds) between the last two full view repaint calls performed.


setLens

protected Lens setLens(Lens l)
set a lens for this view ; set to null to remove an existing lens


getLens

protected Lens getLens()
return Lens cyrrently used by this view (null if none)


setVisibilityPadding

protected void setVisibilityPadding(int[] wnesPadding)
set a padding for customizing the region inside the view for which objects are actually visible

Parameters:
wnesPadding - padding values in pixels for the west, north, east and south borders

getVisibilityPadding

protected int[] getVisibilityPadding()
get the padding values customizing the region inside the view for which objects are actually visible

Returns:
padding values in pixels for the west, north, east and south borders

componentResized

public void componentResized(ComponentEvent e)
Specified by:
componentResized in interface ComponentListener

componentMoved

public void componentMoved(ComponentEvent e)
Specified by:
componentMoved in interface ComponentListener

componentShown

public void componentShown(ComponentEvent e)
Specified by:
componentShown in interface ComponentListener

componentHidden

public void componentHidden(ComponentEvent e)
Specified by:
componentHidden in interface ComponentListener

drawPortals

protected final void drawPortals()

portalsHook

protected final void portalsHook()

backgroundHook

protected final void backgroundHook()

foregroundHook

protected final void foregroundHook()

afterLensHook

protected final void afterLensHook()


Copyright © 2000-2002 Xerox Corporation. All Rights Reserved
Copyright © 2003 World Wide Web Consortium. All Rights Reserved
Copyright © 2004-2011 INRIA. All Rights Reserved
Licensed under the GNU LGPL. For full terms see the file COPYING.