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 TypeClassDescriptionclassThe class for animating the 3D network structure.Nested classes/interfaces inherited from class GenericPopGraph
GenericPopGraph.PopGraphControllerNested classes/interfaces inherited from class AbstractGraph
AbstractGraph.Controller, AbstractGraph.GraphStyle, AbstractGraph.HasTrajectory, AbstractGraph.MyContext2d, AbstractGraph.Shifter, AbstractGraph.Shifting, AbstractGraph.ZoomCommand, AbstractGraph.Zoomer, AbstractGraph.ZoomingNested classes/interfaces inherited from class UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabledNested classes/interfaces inherited from interface HasWidgets
HasWidgets.ForIsWidget -
Field Summary
FieldsModifier and TypeFieldDescription(package private) AmbientLightThe ambient light source illuminating the scene.private EffectHelper variable for additional effects on the 3D view.(package private) CameraThe camera of the 3D graph.(package private) RenderingPanelThe panel for rendering the 3D graph.(package private) PopGraph3D.Pop3DSceneThe 3D scene of the graph.(package private) PointLightThe directed light source illuminating the scene.(package private) LineBasicMaterialThe line style for the links.(package private) LabelThe label for displaying messages.(package private) RaycasterHelper 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, noGraphFields 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, zoomResetMenuFields inherited from class UIObject
DEBUG_ID_PREFIXFields 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 TypeMethodDescriptionvoidactivate()Perform necessary preparations to show the graph in the GUI.voidcalcBounds(int width, int height) Calculate bounds of drawing area.voidClear the message.voidThe graph is removed from the GUI.booleandisplayMessage(String msg) Display messagemsgon the graph (no HTML formatting).protected voidDraws structures with static layout of lattices.protected voidDraws the network.protected voidAdds the nodes, links, lights and camera to the scene.voidExport the graphical contextctx.intfindNodeAt(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 indexnodeas a CSS color string.protected voidinitUniverse(Geometry unit) Initialize the universe of the 3D graph.booleanCheck if the graph is displayed as an anaglyph.booleanCheck if the camera uses an orthographic projection.booleanisVR()Check if the graph is displayed with stereo effect.voidvoidonMouseDown(MouseDownEvent event) voidonMouseUp(MouseUpEvent event) voidonResize()voidonTouchEnd(TouchEndEvent event) booleanpaint(boolean force) Draw the graph.voidsetAnaglyph(boolean anaglyph) Set the anaglyph effect for the 3D view.voidsetOrthographic(boolean orthographic) Set the projection of the camera.voidsetVR(boolean vr) Set the stereo effect for the 3D view.voidzoom(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, updateMethods 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, zoomMethods 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, setTabIndexMethods inherited from class SimplePanel
add, getContainerElement, getWidget, iterator, remove, setWidget, setWidgetMethods inherited from class Panel
add, adopt, clear, doAttachChildren, doDetachChildren, orphan, removeMethods 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, unsinkEventsMethods 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, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface AbstractGraph.Zoomer
zoomMethods inherited from interface AbstractGraph.Zooming
zoomMethods inherited from interface ContextMenu.Listener
getAbsoluteLeft, getAbsoluteTopMethods inherited from interface HasHandlers
fireEventMethods inherited from interface HasTouchCancelHandlers
addTouchCancelHandlerMethods inherited from interface HasTouchEndHandlers
addTouchEndHandlerMethods inherited from interface HasTouchMoveHandlers
addTouchMoveHandlerMethods inherited from interface HasTouchStartHandlers
addTouchStartHandlerMethods inherited from interface Iterable
forEach, spliteratorMethods 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:AbstractGraphPerform necessary preparations to show the graph in the GUI. Attaches mouse and touch handlers for graphs that implementAbstractGraph.ZoomingorAbstractGraph.Shiftinginterfaces.- Overrides:
activatein classGenericPopGraph<MeshLambertMaterial,Network3DGWT> - See Also:
-
deactivate
public void deactivate()Description copied from class:AbstractGraphThe graph is removed from the GUI. Opportunity for some clean up. Removes all mouse and touch handlers from graph.- Overrides:
deactivatein classAbstractGraph<MeshLambertMaterial[]>- See Also:
-
paint
public boolean paint(boolean force) Description copied from class:AbstractGraphDraw the graph. For re-drawing the graph, setforcetotrue.- Overrides:
paintin classGenericPopGraph<MeshLambertMaterial,Network3DGWT> - Parameters:
force-trueto force re-drawing of graph- Returns:
trueif painting skipped
-
drawLattice
protected void drawLattice()Description copied from class:GenericPopGraphDraws structures with static layout of lattices.- Specified by:
drawLatticein classGenericPopGraph<MeshLambertMaterial,Network3DGWT> - See Also:
-
drawNetwork
protected void drawNetwork()Description copied from class:GenericPopGraphDraws the network.- Specified by:
drawNetworkin 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:AbstractGraphCalculate bounds of drawing area.- Overrides:
calcBoundsin 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 indexnodeas a CSS color string.- Specified by:
getCSSColorAtin 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:GenericPopGraphFind the index of the node at the location with coordinates(x, y).- Specified by:
findNodeAtin 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:AbstractGraphAdjust zoom level by the factorzoom. Default implementation for graphs that implementZooming.- Specified by:
zoomin interfaceAbstractGraph.Zooming- Overrides:
zoomin classAbstractGraph<MeshLambertMaterial[]>- Parameters:
zoom- the new zoom level- See Also:
-
onMouseDown
Description copied from class:AbstractGraphIf 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
MouseMoveEvents.- Specified by:
onMouseDownin interfaceMouseDownHandler- Overrides:
onMouseDownin classAbstractGraph<MeshLambertMaterial[]>- See Also:
-
onMouseUp
Description copied from class:AbstractGraphCancel all interactions with the graph and reset node and mouse information.
CSS Style Rules
- .evoludo-cursorMoveView
- removed from graph element.
- Specified by:
onMouseUpin interfaceMouseUpHandler- Overrides:
onMouseUpin classAbstractGraph<MeshLambertMaterial[]>- See Also:
-
onTouchEnd
The number of touches on the graph changed.
The number of touches on the graph changed.
- Specified by:
onTouchEndin interfaceTouchEndHandler- Overrides:
onTouchEndin classAbstractGraph<MeshLambertMaterial[]>
-
setOrthographic
public void setOrthographic(boolean orthographic) Set the projection of the camera. IfsetOrtho == truethe 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:
truefor orthographic projections
-
setAnaglyph
public void setAnaglyph(boolean anaglyph) Set the anaglyph effect for the 3D view.- Parameters:
anaglyph-trueenable the anaglyph effect
-
isAnaglyph
public boolean isAnaglyph()Check if the graph is displayed as an anaglyph.- Returns:
trueif anaglyph shown
-
setVR
public void setVR(boolean vr) Set the stereo effect for the 3D view.- Parameters:
vr-trueto enable the stereo effect
-
isVR
public boolean isVR()Check if the graph is displayed with stereo effect.- Returns:
trueif stereo effect shown
-
export
Description copied from class:AbstractGraphExport the graphical contextctx.- Specified by:
exportin classAbstractGraph<MeshLambertMaterial[]>- Parameters:
ctx- the graphical context to export
-
onContextError
- Specified by:
onContextErrorin interfaceContext3dErrorHandler
-
onResize
public void onResize()- Specified by:
onResizein interfaceRequiresResize- Overrides:
onResizein classGenericPopGraph<MeshLambertMaterial,Network3DGWT>
-
displayMessage
Description copied from class:AbstractGraphDisplay messagemsgon 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:
displayMessagein classAbstractGraph<MeshLambertMaterial[]>- Parameters:
msg- the message to display- Returns:
trueif message displayed
-
clearMessage
public void clearMessage()Description copied from class:AbstractGraphClear the message.- Overrides:
clearMessagein classAbstractGraph<MeshLambertMaterial[]>
-