Package org.evoludo.graphics
Class PopGraph3D
- All Implemented Interfaces:
DoubleClickHandler
,HasAllDragAndDropHandlers
,HasAllFocusHandlers
,HasAllGestureHandlers
,HasAllKeyHandlers
,HasAllMouseHandlers
,HasAllTouchHandlers
,HasBlurHandlers
,HasClickHandlers
,HasContextMenuHandlers
,HasDoubleClickHandlers
,HasDragEndHandlers
,HasDragEnterHandlers
,HasDragHandlers
,HasDragLeaveHandlers
,HasDragOverHandlers
,HasDragStartHandlers
,HasDropHandlers
,HasFocusHandlers
,HasGestureChangeHandlers
,HasGestureEndHandlers
,HasGestureStartHandlers
,HasKeyDownHandlers
,HasKeyPressHandlers
,HasKeyUpHandlers
,HasMouseDownHandlers
,HasMouseMoveHandlers
,HasMouseOutHandlers
,HasMouseOverHandlers
,HasMouseUpHandlers
,HasMouseWheelHandlers
,HasTouchCancelHandlers
,HasTouchEndHandlers
,HasTouchMoveHandlers
,HasTouchStartHandlers
,MouseDownHandler
,MouseMoveHandler
,MouseOutHandler
,MouseUpHandler
,MouseWheelHandler
,TouchEndHandler
,TouchMoveHandler
,TouchStartHandler
,HasAttachHandlers
,EventHandler
,HasHandlers
,EventListener
,AcceptsOneWidget
,Focusable
,HasFocus
,HasOneWidget
,HasVisibility
,HasWidgets
,HasWidgets.ForIsWidget
,IsWidget
,RequiresResize
,SourcesClickEvents
,SourcesFocusEvents
,SourcesKeyboardEvents
,SourcesMouseEvents
,SourcesMouseWheelEvents
,Iterable<Widget>
,AbstractGraph.Zoomer
,AbstractGraph.Zooming
,Network.LayoutListener
,ContextMenu.Listener
,ContextMenu.Provider
,Tooltip.Provider
,Context3dErrorHandler
public class PopGraph3D
extends GenericPopGraph<MeshLambertMaterial,Network3DGWT>
implements Context3dErrorHandler
The graphical representation of network structures in 3D. The 3D graph is
based on the Parallax 3D library.
The graph is displayed in a
RenderingPanel
which is a GWT widget
that wraps the Parallax 3D library.
The graph is interactive and allows the user to zoom and rotate the view. The user can change the state of nodes by by double-clicking on them. The graph can be exported in PNG or SVG graphics formats.
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
The class for animating the 3D network structure.Nested classes/interfaces inherited from class GenericPopGraph
GenericPopGraph.PopGraphController
Nested classes/interfaces inherited from class AbstractGraph
AbstractGraph.Controller, AbstractGraph.GraphStyle, AbstractGraph.HasTrajectory, AbstractGraph.MyContext2d, AbstractGraph.Shifter, AbstractGraph.Shifting, AbstractGraph.ZoomCommand, AbstractGraph.Zoomer, AbstractGraph.Zooming
Nested classes/interfaces inherited from class UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
Nested classes/interfaces inherited from interface HasWidgets
HasWidgets.ForIsWidget
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) AmbientLight
The ambient light source illuminating the scene.private Effect
Helper variable for additional effects on the 3D view.(package private) Camera
The camera of the 3D graph.(package private) RenderingPanel
The panel for rendering the 3D graph.(package private) PopGraph3D.Pop3DScene
The 3D scene of the graph.(package private) PointLight
The directed light source illuminating the scene.(package private) LineBasicMaterial
The line style for the links.(package private) Label
The label for displaying messages.(package private) Raycaster
Helper field for determining which node has been hit by mouse or tap.The colors of the nodes.Fields inherited from class GenericPopGraph
animate, colorMap, data, FINDNODEAT_OUT_OF_BOUNDS, FINDNODEAT_UNIMPLEMENTED, geometry, hitNode, invalidated, label, MAX_ANIMATE_LAYOUT_LINKS_DEFAULT, MAX_ANIMATE_LAYOUT_VERTICES_DEFAULT, network, noGraph
Fields inherited from class AbstractGraph
bounds, buffer, canvas, colors, contextMenu, controller, DEFAULT_BUFFER_SIZE, doubleClickHandler, element, g, hasMessage, hasZoom, isActive, leftMouseButton, logger, markerColors, markers, MIN_BUFFER_SIZE, MIN_MSEC_BETWEEN_UPDATES, module, mouseDownHandler, mouseMoveHandler, mouseOutHandler, mouseUpHandler, mouseWheelHandler, mouseX, mouseY, PIHALF, pinchDist, pinchX, pinchY, scale, shifter, style, tooltip, tooltipProvider, touchEndHandler, touchEndTime, touchMoveHandler, touchStartHandler, updatetime, viewCorner, wrapper, zoomer, zoomFactor, zoomInertiaTimer, zoomInMenu, zoomOutMenu, zoomResetMenu
Fields inherited from class UIObject
DEBUG_ID_PREFIX
Fields inherited from interface AbstractGraph.Zooming
ZOOM_INCR, ZOOM_MAX
-
Constructor Summary
ConstructorsConstructorDescriptionPopGraph3D
(GenericPopGraph.PopGraphController controller, Module module) Create a graph for graphically visualizing the structure of a network (or population). -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Perform necessary preparations to show the graph in the GUI.void
calcBounds
(int width, int height) Calculate bounds of drawing area.void
Clear the message.void
The graph is removed from the GUI.boolean
displayMessage
(String msg) Display messagemsg
on the graph (no HTML formatting).protected void
Draws structures with static layout of lattices.protected void
Draws the network.protected void
Adds the nodes, links, lights and camera to the scene.void
Export the graphical contextctx
.int
findNodeAt
(int x, int y) Find the index of the node at the location with coordinates(x, y)
.Get the canvas element.getCSSColorAt
(int node) Get the color of the node at indexnode
as a CSS color string.protected void
initUniverse
(Geometry unit) Initialize the universe of the 3D graph.boolean
Check if the graph is displayed as an anaglyph.boolean
Check if the camera uses an orthographic projection.boolean
isVR()
Check if the graph is displayed with stereo effect.void
void
onMouseDown
(MouseDownEvent event) void
onMouseUp
(MouseUpEvent event) void
onResize()
void
onTouchEnd
(TouchEndEvent event) boolean
paint
(boolean force) Draw the graph.void
setAnaglyph
(boolean anaglyph) Set the anaglyph effect for the 3D view.void
setOrthographic
(boolean orthographic) Set the projection of the camera.void
setVR
(boolean vr) Set the stereo effect for the 3D view.void
zoom
(double zoom) Adjust zoom level by the factorzoom
.Methods inherited from class GenericPopGraph
getColorMap, getData, getGeometry, getNetwork, getTooltipAt, hasAnimatedLayout, hasMessage, hasStaticLayout, invalidate, layoutComplete, layoutNetwork, layoutUpdate, onDoubleClick, onTouchStart, populateContextMenuAt, reset, setColorMap, setDebugEnabled, setGeometry, setGraphLabel, update
Methods inherited from class AbstractGraph
addContextMenuHandler, autoscale, calcBounds, clearCanvas, clearGraph, clearHistory, contains, convertToScaledCoordinates, convertToScaledCoordinates, doUpdate, drawFrame, drawFrame, fill, fillCircle, fillRect, fillTextVertical, getBuffer, getModule, getStyle, hasHistory, init, onMouseMove, onMouseOut, onMouseWheel, onTouchMove, paint, prependTime2Data, resetTransforms, setBufferCapacity, setColors, setFont, setMarkers, setMarkers, setStrokeStyleAt, setTooltipProvider, shift, stroke, strokeCircle, strokeLine, strokeRect, zoom, zoom, zoom
Methods inherited from class FocusPanel
addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getTabIndex, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener, setAccessKey, setFocus, setTabIndex
Methods inherited from class SimplePanel
add, getContainerElement, getWidget, iterator, remove, setWidget, setWidget
Methods inherited from class Panel
add, adopt, clear, doAttachChildren, doDetachChildren, orphan, remove
Methods inherited from class Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
Methods inherited from class UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface AbstractGraph.Zoomer
zoom
Methods inherited from interface AbstractGraph.Zooming
zoom
Methods inherited from interface ContextMenu.Listener
getAbsoluteLeft, getAbsoluteTop
Methods inherited from interface HasHandlers
fireEvent
Methods inherited from interface HasTouchCancelHandlers
addTouchCancelHandler
Methods inherited from interface HasTouchEndHandlers
addTouchEndHandler
Methods inherited from interface HasTouchMoveHandlers
addTouchMoveHandler
Methods inherited from interface HasTouchStartHandlers
addTouchStartHandler
Methods inherited from interface Iterable
forEach, spliterator
Methods inherited from interface MouseWheelHandler
onMouseWheel
-
Field Details
-
graph3DPanel
RenderingPanel graph3DPanelThe panel for rendering the 3D graph. -
graph3DScene
PopGraph3D.Pop3DScene graph3DSceneThe 3D scene of the graph. -
graph3DCamera
Camera graph3DCameraThe camera of the 3D graph. -
spheres
The colors of the nodes. -
linkstyle
LineBasicMaterial linkstyleThe line style for the links. -
light
PointLight lightThe directed light source illuminating the scene. -
ambient
AmbientLight ambientThe ambient light source illuminating the scene. -
msgLabel
Label msgLabelThe label for displaying messages. -
raycaster
Raycaster raycasterHelper field for determining which node has been hit by mouse or tap. -
effect
private Effect effectHelper variable for additional effects on the 3D view. This handles anaglyph and stereo projections.
-
-
Constructor Details
-
PopGraph3D
Create a graph for graphically visualizing the structure of a network (or population). Allocates the canvas and the label and retrieves the shared tooltip and context menu.CSS Style Rules
- .evoludo-PopGraph3D
- the graph element.
- .evoludo-Label3D
- the graph label element.
- .evoludo-Message3D
- the message element (3D text).
- Parameters:
controller
- the controller of this graphmodule
- the module backing the graph
-
-
Method Details
-
activate
public void activate()Description copied from class:AbstractGraph
Perform necessary preparations to show the graph in the GUI. Attaches mouse and touch handlers for graphs that implementAbstractGraph.Zooming
orAbstractGraph.Shifting
interfaces.- Overrides:
activate
in classGenericPopGraph<MeshLambertMaterial,
Network3DGWT> - See Also:
-
deactivate
public void deactivate()Description copied from class:AbstractGraph
The graph is removed from the GUI. Opportunity for some clean up. Removes all mouse and touch handlers from graph.- Overrides:
deactivate
in classAbstractGraph<MeshLambertMaterial[]>
- See Also:
-
paint
public boolean paint(boolean force) Description copied from class:AbstractGraph
Draw the graph. For re-drawing the graph, setforce
totrue
.- Overrides:
paint
in classGenericPopGraph<MeshLambertMaterial,
Network3DGWT> - Parameters:
force
-true
to force re-drawing of graph- Returns:
true
if painting skipped
-
drawLattice
protected void drawLattice()Description copied from class:GenericPopGraph
Draws structures with static layout of lattices.- Specified by:
drawLattice
in classGenericPopGraph<MeshLambertMaterial,
Network3DGWT> - See Also:
-
drawNetwork
protected void drawNetwork()Description copied from class:GenericPopGraph
Draws the network.- Specified by:
drawNetwork
in classGenericPopGraph<MeshLambertMaterial,
Network3DGWT>
-
drawUniverse
protected void drawUniverse()Adds the nodes, links, lights and camera to the scene. -
calcBounds
public void calcBounds(int width, int height) Description copied from class:AbstractGraph
Calculate bounds of drawing area.- Overrides:
calcBounds
in classAbstractGraph<MeshLambertMaterial[]>
- Parameters:
width
- the width of the drawing areaheight
- the height of the drawing area
-
getCanvasElement
Get the canvas element.Notes:
- Before exporting the canvas to image/png the scene needs to be rendered.
- For resizing just returning the canvas element is fine.
- Attempts to render the scene of an inactive view triggers lots of WebGL warnings.
- Returns:
- the canvas element
-
getCSSColorAt
Get the color of the node at indexnode
as a CSS color string.- Specified by:
getCSSColorAt
in classGenericPopGraph<MeshLambertMaterial,
Network3DGWT> - Parameters:
node
- the index of the node- Returns:
- the color of the node
-
findNodeAt
public int findNodeAt(int x, int y) Description copied from class:GenericPopGraph
Find the index of the node at the location with coordinates(x, y)
.- Specified by:
findNodeAt
in classGenericPopGraph<MeshLambertMaterial,
Network3DGWT> - Parameters:
x
- thex
-coordinate of the locationy
- they
-coordinate of the location- Returns:
- the index of the node
-
zoom
public void zoom(double zoom) Description copied from class:AbstractGraph
Adjust zoom level by the factorzoom
. Default implementation for graphs that implementZooming
.- Specified by:
zoom
in interfaceAbstractGraph.Zooming
- Overrides:
zoom
in classAbstractGraph<MeshLambertMaterial[]>
- Parameters:
zoom
- the new zoom level- See Also:
-
onMouseDown
Description copied from class:AbstractGraph
If a node has been hit by a left-click, remember the node's index and the current mouse coordinates. This information might be used by subsequent
MouseMoveEvent
s.- Specified by:
onMouseDown
in interfaceMouseDownHandler
- Overrides:
onMouseDown
in classAbstractGraph<MeshLambertMaterial[]>
- See Also:
-
onMouseUp
Description copied from class:AbstractGraph
Cancel all interactions with the graph and reset node and mouse information.
CSS Style Rules
- .evoludo-cursorMoveView
- removed from graph element.
- Specified by:
onMouseUp
in interfaceMouseUpHandler
- Overrides:
onMouseUp
in classAbstractGraph<MeshLambertMaterial[]>
- See Also:
-
onTouchEnd
The number of touches on the graph changed.
The number of touches on the graph changed.
- Specified by:
onTouchEnd
in interfaceTouchEndHandler
- Overrides:
onTouchEnd
in classAbstractGraph<MeshLambertMaterial[]>
-
setOrthographic
public void setOrthographic(boolean orthographic) Set the projection of the camera. IfsetOrtho == true
the camera uses an orthographic (parallel) projection and a perspective projection otherwise.- Parameters:
orthographic
- the flag to set an orthographic (parallel) projection for the camera
-
isOrthographic
public boolean isOrthographic()Check if the camera uses an orthographic projection.- Returns:
true
for orthographic projections
-
setAnaglyph
public void setAnaglyph(boolean anaglyph) Set the anaglyph effect for the 3D view.- Parameters:
anaglyph
-true
enable the anaglyph effect
-
isAnaglyph
public boolean isAnaglyph()Check if the graph is displayed as an anaglyph.- Returns:
true
if anaglyph shown
-
setVR
public void setVR(boolean vr) Set the stereo effect for the 3D view.- Parameters:
vr
-true
to enable the stereo effect
-
isVR
public boolean isVR()Check if the graph is displayed with stereo effect.- Returns:
true
if stereo effect shown
-
export
Description copied from class:AbstractGraph
Export the graphical contextctx
.- Specified by:
export
in classAbstractGraph<MeshLambertMaterial[]>
- Parameters:
ctx
- the graphical context to export
-
onContextError
- Specified by:
onContextError
in interfaceContext3dErrorHandler
-
onResize
public void onResize()- Specified by:
onResize
in interfaceRequiresResize
- Overrides:
onResize
in classGenericPopGraph<MeshLambertMaterial,
Network3DGWT>
-
displayMessage
Description copied from class:AbstractGraph
Display messagemsg
on the graph (no HTML formatting).Implementation note:
The message is centered and scaled such that it fills approximately two thirds of the width of the graph.- Overrides:
displayMessage
in classAbstractGraph<MeshLambertMaterial[]>
- Parameters:
msg
- the message to display- Returns:
true
if message displayed
-
clearMessage
public void clearMessage()Description copied from class:AbstractGraph
Clear the message.- Overrides:
clearMessage
in classAbstractGraph<MeshLambertMaterial[]>
-