com.jzy3d.surfedit.controllers
Class AWTMouseController

java.lang.Object
  extended by org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector
      extended by com.jzy3d.surfedit.controllers.AWTMouseController
All Implemented Interfaces:
MouseListener, MouseMotionListener, MouseWheelListener, EventListener

public class AWTMouseController
extends org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector
implements MouseWheelListener

Updates the highlighted status of each surface cell, and query a chart repaint when the selection changes. The implementation of the AWTMouseController tool relies on View.toScreen() which project all the surface data to 2d. The projection is updated after a call to prepareProjection(), so:

Author:
Martin Pernollet

Field Summary
protected  List<org.jzy3d.events.ControllerEventListener> controllerListeners
           
protected  boolean createSelection
           
protected  boolean currentCellSelectionChanged
           
protected  SelectionRectangle currentRectangleSelection
           
protected  org.jzy3d.maths.Coord2d currMouse
           
protected  boolean dragZ
           
protected  Map<org.jzy3d.maths.PolygonArray,Polygon> hullMap
           
protected  List<CellSelectedEventListener> listeners
           
protected  org.jzy3d.events.IDrawableListener morphologyListener
           
protected  org.jzy3d.maths.Coord2d prevMouse
           
protected  boolean rotateStarted
           
protected  SelectionMode selectionMode
           
protected  Set<Cell> selections
           
protected  boolean startDragAndSelect
           
protected  IInteractiveSurface surface
           
protected  boolean tooltipOn
           
protected  boolean useShiftToMakeRectangle
           
protected  boolean wasLeftDown
           
protected  boolean wheelOn
           
 
Fields inherited from class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector
chart, dragging, in, last, out, selectionRenderer
 
Constructor Summary
AWTMouseController(IInteractiveSurface surface)
           
 
Method Summary
 boolean addCellSelectedEventListener(CellSelectedEventListener listener)
           
 void addControllerEventListener(org.jzy3d.events.ControllerEventListener listener)
           
protected  boolean applyAndBroadcastMaximalSelection(com.jzy3d.surfedit.controllers.CellReference selection)
           
protected  boolean applyAndBroadcastSelection(com.jzy3d.surfedit.controllers.CellReference selection)
           
protected  void applyAndBroadcastSingleSelection(com.jzy3d.surfedit.controllers.CellReference selection)
           
protected  org.jzy3d.plot3d.primitives.AbstractWireframeable asWireframeable(IInteractiveSurface surface)
           
protected  InteractiveChart castChart()
           
 void clearLastSelection()
           
protected  void clearTooltip()
           
protected  boolean contains(org.jzy3d.maths.PolygonArray projection, int x, int y)
           
protected  Polygon convert(org.jzy3d.maths.PolygonArray cell)
          Returns the polygon as AWT.
protected  void dragSelection(MouseEvent e)
           
protected  void dragZ(MouseEvent e)
           
protected  void drawSelection(Graphics2D g2d, int width, int height)
           
protected  void editZValues()
           
protected  void fireCellSelectedEvent(CellSelectedEvent e)
           
protected  void fireCellsSelectedEvent(CellsSelectedEvent e)
           
protected  void fireCellsUnselectedEvent()
           
protected  void fireControllerEvent(org.jzy3d.chart.controllers.ControllerType type, Object value)
           
 List<CellSelectedEventListener> getCellSelectedEventListeners()
           
 com.jzy3d.surfedit.controllers.CellReference getCellUnderMouse()
           
protected  com.jzy3d.surfedit.controllers.CellReference getCellUnderMouse(int x, int y)
          Set highlighted cells according to mouse position.
protected  com.jzy3d.surfedit.controllers.CellReference getCellUnderMouse(MouseEvent e)
           
protected  com.jzy3d.surfedit.controllers.CellReference getCellUnderMouseAndAppendToSelection(MouseEvent e)
          Multi-cell selection
protected  com.jzy3d.surfedit.controllers.CellReference getCellUnderMouseAndSetSingleSelection(MouseEvent e)
          Single-cell selection.
 SelectionMode getSelectionMode()
           
protected  org.jzy3d.maths.Rectangle getViewport()
           
protected  Polygon hull(org.jzy3d.maths.PolygonArray cell)
          Computes the convex hull of a list of points and returns it as an AWT polygon.
protected  org.jzy3d.plot3d.rendering.view.Renderer2d initRenderer2d(org.jzy3d.plot3d.rendering.canvas.ICanvas c)
          OVERLAY
protected  boolean isCellAlreadyHighlighted(com.jzy3d.surfedit.controllers.CellReference selection)
           
 boolean isTooltipOn()
           
 boolean isUseShiftToMakeRectangle()
           
 boolean isWheelOn()
          If wheel is on, then the wheel can be used to scale the graph.
 void mouseDragged(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void mouseWheelMoved(MouseWheelEvent e)
           
protected  boolean onViewport(MouseEvent e)
          Returns true if the mouse stands on the Chart's viewport.
protected  void processSelection(org.jzy3d.plot3d.rendering.scene.Scene scene, org.jzy3d.plot3d.rendering.view.View view, int width, int height)
           
protected  void releaseSelection(MouseEvent e)
           
 boolean removeCellSelectedEventListener(CellSelectedEventListener listener)
           
 void removeControllerEventListener(org.jzy3d.events.ControllerEventListener listener)
           
 void reset()
           
protected  void rollOver(MouseEvent e)
          Highlight surface cells standing under the mouse pointer, and update display.
 void setCellSelectedEventListeners(List<CellSelectedEventListener> listeners)
           
 void setSelectionMode(SelectionMode mode)
           
 void setTooltipOn(boolean tooltipOn)
           
 void setUseShiftToMakeRectangle(boolean useShiftToMakeRectangle)
          If true, uses the following commands: mouse only allows cell by cell selection mouse + shift allows rectangular selection If false, uses the following commands: mouse only allows rectangular selection mouse + control selection allows cell by cell selection All selections are additive until one presses the ESC key.
 void setWheelOn(boolean wheelOn)
           
protected  void startDragZ(MouseEvent e)
           
protected  void startDragZ(MouseEvent e, boolean updatePrevMouse)
           
protected  void startSelection(MouseEvent e)
           
protected  void stopDragZ(MouseEvent e)
           
protected  void updateTooltip(com.jzy3d.surfedit.controllers.CellReference selection)
           
 
Methods inherited from class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector
dispose, drawRectangle, matchRectangleSelection, matchRectangleSelection, mouseClicked, mouseEntered, mouseExited, mouseWheelMoved, register, unregister, updateLast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

surface

protected IInteractiveSurface surface

hullMap

protected Map<org.jzy3d.maths.PolygonArray,Polygon> hullMap

selections

protected Set<Cell> selections

currMouse

protected org.jzy3d.maths.Coord2d currMouse

prevMouse

protected org.jzy3d.maths.Coord2d prevMouse

rotateStarted

protected boolean rotateStarted

wasLeftDown

protected boolean wasLeftDown

tooltipOn

protected boolean tooltipOn

currentCellSelectionChanged

protected boolean currentCellSelectionChanged

selectionMode

protected SelectionMode selectionMode

currentRectangleSelection

protected SelectionRectangle currentRectangleSelection

listeners

protected List<CellSelectedEventListener> listeners

controllerListeners

protected List<org.jzy3d.events.ControllerEventListener> controllerListeners

morphologyListener

protected org.jzy3d.events.IDrawableListener morphologyListener

wheelOn

protected boolean wheelOn

useShiftToMakeRectangle

protected boolean useShiftToMakeRectangle

startDragAndSelect

protected boolean startDragAndSelect

dragZ

protected boolean dragZ

createSelection

protected boolean createSelection
Constructor Detail

AWTMouseController

public AWTMouseController(IInteractiveSurface surface)
Method Detail

isTooltipOn

public boolean isTooltipOn()

setTooltipOn

public void setTooltipOn(boolean tooltipOn)

getCellUnderMouse

public com.jzy3d.surfedit.controllers.CellReference getCellUnderMouse()

setSelectionMode

public void setSelectionMode(SelectionMode mode)

getSelectionMode

public SelectionMode getSelectionMode()

setUseShiftToMakeRectangle

public void setUseShiftToMakeRectangle(boolean useShiftToMakeRectangle)
If true, uses the following commands: If false, uses the following commands: All selections are additive until one presses the ESC key.


isUseShiftToMakeRectangle

public boolean isUseShiftToMakeRectangle()

isWheelOn

public boolean isWheelOn()
If wheel is on, then the wheel can be used to scale the graph.


setWheelOn

public void setWheelOn(boolean wheelOn)

clearLastSelection

public void clearLastSelection()
Specified by:
clearLastSelection in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

reset

public void reset()

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener
Overrides:
mouseMoved in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

startSelection

protected void startSelection(MouseEvent e)
Overrides:
startSelection in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

dragSelection

protected void dragSelection(MouseEvent e)
Overrides:
dragSelection in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

releaseSelection

protected void releaseSelection(MouseEvent e)
Overrides:
releaseSelection in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

rollOver

protected void rollOver(MouseEvent e)
Highlight surface cells standing under the mouse pointer, and update display.

Overrides:
rollOver in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

startDragZ

protected void startDragZ(MouseEvent e)

startDragZ

protected void startDragZ(MouseEvent e,
                          boolean updatePrevMouse)

dragZ

protected void dragZ(MouseEvent e)

stopDragZ

protected void stopDragZ(MouseEvent e)

mouseWheelMoved

public void mouseWheelMoved(MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface MouseWheelListener

editZValues

protected void editZValues()

getCellUnderMouseAndAppendToSelection

protected com.jzy3d.surfedit.controllers.CellReference getCellUnderMouseAndAppendToSelection(MouseEvent e)
Multi-cell selection


applyAndBroadcastSelection

protected boolean applyAndBroadcastSelection(com.jzy3d.surfedit.controllers.CellReference selection)
Returns:
true if selection status of the referenced cell changed.

applyAndBroadcastMaximalSelection

protected boolean applyAndBroadcastMaximalSelection(com.jzy3d.surfedit.controllers.CellReference selection)

getCellUnderMouseAndSetSingleSelection

protected com.jzy3d.surfedit.controllers.CellReference getCellUnderMouseAndSetSingleSelection(MouseEvent e)
Single-cell selection. Resets previously existing selection.


applyAndBroadcastSingleSelection

protected void applyAndBroadcastSingleSelection(com.jzy3d.surfedit.controllers.CellReference selection)

getCellUnderMouse

protected com.jzy3d.surfedit.controllers.CellReference getCellUnderMouse(MouseEvent e)

isCellAlreadyHighlighted

protected boolean isCellAlreadyHighlighted(com.jzy3d.surfedit.controllers.CellReference selection)

onViewport

protected boolean onViewport(MouseEvent e)
Returns true if the mouse stands on the Chart's viewport.


getViewport

protected org.jzy3d.maths.Rectangle getViewport()

getCellUnderMouse

protected com.jzy3d.surfedit.controllers.CellReference getCellUnderMouse(int x,
                                                                         int y)
Set highlighted cells according to mouse position. Projection is made in the CANVAS frame, not in the VIEWPORT frame.


contains

protected boolean contains(org.jzy3d.maths.PolygonArray projection,
                           int x,
                           int y)
See Also:
for definition of insideness.

hull

protected Polygon hull(org.jzy3d.maths.PolygonArray cell)
Computes the convex hull of a list of points and returns it as an AWT polygon.


convert

protected Polygon convert(org.jzy3d.maths.PolygonArray cell)
Returns the polygon as AWT.


addCellSelectedEventListener

public boolean addCellSelectedEventListener(CellSelectedEventListener listener)

removeCellSelectedEventListener

public boolean removeCellSelectedEventListener(CellSelectedEventListener listener)

getCellSelectedEventListeners

public List<CellSelectedEventListener> getCellSelectedEventListeners()

setCellSelectedEventListeners

public void setCellSelectedEventListeners(List<CellSelectedEventListener> listeners)

addControllerEventListener

public void addControllerEventListener(org.jzy3d.events.ControllerEventListener listener)

removeControllerEventListener

public void removeControllerEventListener(org.jzy3d.events.ControllerEventListener listener)

fireControllerEvent

protected void fireControllerEvent(org.jzy3d.chart.controllers.ControllerType type,
                                   Object value)

fireCellSelectedEvent

protected void fireCellSelectedEvent(CellSelectedEvent e)

fireCellsSelectedEvent

protected void fireCellsSelectedEvent(CellsSelectedEvent e)

fireCellsUnselectedEvent

protected void fireCellsUnselectedEvent()

initRenderer2d

protected org.jzy3d.plot3d.rendering.view.Renderer2d initRenderer2d(org.jzy3d.plot3d.rendering.canvas.ICanvas c)
OVERLAY

Overrides:
initRenderer2d in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

updateTooltip

protected void updateTooltip(com.jzy3d.surfedit.controllers.CellReference selection)

clearTooltip

protected void clearTooltip()

processSelection

protected void processSelection(org.jzy3d.plot3d.rendering.scene.Scene scene,
                                org.jzy3d.plot3d.rendering.view.View view,
                                int width,
                                int height)
Specified by:
processSelection in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

drawSelection

protected void drawSelection(Graphics2D g2d,
                             int width,
                             int height)
Specified by:
drawSelection in class org.jzy3d.chart.controllers.mouse.selection.AWTAbstractMouseSelector

castChart

protected InteractiveChart castChart()

asWireframeable

protected org.jzy3d.plot3d.primitives.AbstractWireframeable asWireframeable(IInteractiveSurface surface)


Copyright © 2014. All rights reserved.