Class PopGraph1D
- 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.Shifter, AbstractGraph.Shifting, AbstractGraph.Zoomer, AbstractGraph.Zooming, Network.LayoutListener, ContextMenu.Listener, ContextMenu.Provider, Tooltip.Provider
Specialized population graph for linear geometries with history.
Content is shifted/zoomed, while the frame and axis decorations remain fixed.
-
Nested Class Summary
Nested classes/interfaces inherited from class GenericPopGraph
GenericPopGraph.HasDebugMenuNested classes/interfaces inherited from class AbstractGraph
AbstractGraph.HasLogScaleY, 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 TypeFieldDescriptionprivate static final intDefault buffer capacity for linear-history graphs.private static final String[]Empty encoded row sentinel.private static final double[]Empty decoded row sentinel.Fields inherited from class PopGraph2D
dh, dh3, dR, dw, dw2, HIERARCHY_GAP, hitDragged, hLevels, hPeriods, isHierarchy, legend, MIN_DH, MIN_DR, MIN_DW, sideFields inherited from class GenericPopGraph
animate, colorMap, data, EVOLUDO_CURSOR_NODE, 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, CSS_CURSOR_MOVE_VIEW, CURSOR_GRAB_NODE_CLASS, CURSOR_MOVE_NODE_CLASS, CURSOR_ZOOM_IN_CLASS, CURSOR_ZOOM_OUT_CLASS, DEFAULT_BUFFER_SIZE, doubleClickHandler, element, g, hasMessage, hasZoom, leftMouseButton, logger, markerColors, markers, message, MIN_BUFFER_SIZE, MIN_CURVATURE_STEP_SQ, MIN_NORM_DELTA, MIN_NORM_DIST_SQ, module, mouseDownHandler, mouseMoveHandler, mouseOutHandler, mouseUpHandler, mouseWheelHandler, mouseX, mouseY, msgFontSize, msgLabel, msgLineHeight, PIHALF, pinchDist, pinchX, pinchY, scale, shifter, style, tooltip, tooltipProvider, touchEndHandler, touchEndTime, touchMoveHandler, touchStartHandler, TURN_COS_THRESHOLD, view, viewCorner, wrapper, yAxisLabelTickSkip, zoomer, zoomFactor, zoomInertiaTimerFields inherited from class UIObject
DEBUG_ID_PREFIXFields inherited from interface AbstractGraph.Zooming
ZOOM_INCR, ZOOM_MAX -
Constructor Summary
ConstructorsConstructorDescriptionPopGraph1D(AbstractView<?> view, Module<?> module) Create a graph for linear population rendering. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidapplyViewportRanges(double baseXMin, double baseXMax, double baseYMin, double baseYMax) Map current pan/zoom state to visible axis ranges for frame labels/ticks.voidcalcBounds(int width, int height) Calculate bounds of drawing area.doubleDecode the probability mass for a bin from a color-encoded histogram row.intdecodeColorIndex(String color) Decode the discrete index represented bycolor.doubledecodeColorValue(String color) Decode the gradient value represented bycolor.private static double[]decodeRow(String[] source, ColorMap.Gradient1D<String> cMap, int bins) Decode a 1D histogram row from colors into normalized probability masses.private voidDraw frame and axis decorations without pan/zoom transforms.protected voidDraws structures with static layout of lattices.private voidDraw linear lattice content without frame.private static String[]encodeRow(double[] masses, ColorMap.Gradient1D<String> cMap) Encode histogram masses into colors using the graph color map.protected voidEnsure that the data array is properly initialized based on the current geometry.intfindNodeAt(int x, int y) Find the index of the node at the location with coordinates(x, y).private doubleReturn content height in graph coordinates, taking buffered history into account.getHistoryColorAt(int row, int node) Retrieve the encoded color at the given history row and node.getTooltipAt(int x, int y) Get the tooltip information for the location with coordinates(x, y).booleanisVacantColor(String color) Check whethercolordenotes a vacant site in gradient-based maps.private static doublenonNegativeFinite(double value) Convert non-finite or negative values to zero.protected voidpopulateGraphContextMenu(ContextMenu menu, int x, int y) Opportunity for subclasses to contribute menu items after graph-local entries such as clear/debug and before the generic zoom/view items.voidpopulateLocalAxesMenu(ContextMenu axesMenu) Opportunity for graph subclasses to contribute graph-local entries to the shared axes submenu assembled by the owning view.private booleanPrepare canvas so only content participates in pan/zoom transforms.voidrebinGraphData(int oldBins, int newBins) Rebin graph data when the number of bins changes.private static double[]rebinRow(double[] source, int oldBins, int newBins) Rebin 1D histogram masses by exact overlap.voidshift(int dx, int dy) Shift the (zoomed) graph within the view port by(dx, dy).voidupdate(boolean isNext) Update the graph.private voidUpdate the y-axis tick label offset to the current model time.protected voidzoom(double zoom, double fx, double fy) Helper method to adjust zoom level with the zoom center at the scaled coordinates(fx, fy), specified as a fraction of the view port in horizontal and vertical directions, respectively.Methods inherited from class PopGraph2D
activate, addZoomMenu, adjustBoundsForLegend, drawFrameOverlay, drawNetwork, export, getCSSColorAt, getMaxViewCornerX, getMaxViewCornerY, inside, onLoad, onMouseDown, onMouseMove, onMouseUp, onResize, onTouchEnd, onTouchMove, onUnload, paint, setGeometry, setLegendSpecs, shiftNodeBy, supportsNodeDraggingMethods inherited from class GenericPopGraph
getColorMap, getData, getGeometry, getNetwork, hasAnimatedLayout, hasMessage, hasStaticLayout, invalidate, layoutComplete, layoutNetwork, layoutUpdate, onDoubleClick, onTouchStart, populateContextMenuAt, reset, setColorMap, setGraphLabelMethods inherited from class AbstractGraph
addClearMenu, addContextMenuHandler, addLogScaleMenu, autoscale, calcBounds, clearCanvas, clearGraph, clearHistory, clearMessage, contains, convertToScaledCoordinates, convertToScaledCoordinates, deactivate, displayMessage, displayMessage, drawFrame, drawFrame, fill, fillCircle, fillCircle, fillCircle, fillRect, fillTextVertical, getBuffer, getModule, getStyle, getYAxisLabelTickSkip, hasHistory, hasSignificantTurn, init, keepSample, maxDelta, normDelta, normDeltaSq, onMessageCleared, onMessageDisplayed, onMouseOut, onMouseWheel, paint, parse, populateZoomMenu, prependTime2Data, resetTransforms, setColors, setFont, setLogY, setMarkers, setMarkers, setStrokeStyleAt, setTooltipProvider, stroke, strokeCircle, strokeCircle, strokeCircle, strokeLine, 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, 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
zoom, 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 MouseOutHandler
onMouseOutMethods inherited from interface MouseWheelHandler
onMouseWheelMethods inherited from interface TouchStartHandler
onTouchStart
-
Field Details
-
DEFAULT_BUFFER_CAPACITY
private static final int DEFAULT_BUFFER_CAPACITYDefault buffer capacity for linear-history graphs.- See Also:
-
EMPTY_MASS_ROW
private static final double[] EMPTY_MASS_ROWEmpty decoded row sentinel. -
EMPTY_COLOR_ROW
Empty encoded row sentinel.
-
-
Constructor Details
-
PopGraph1D
Create a graph for linear population rendering.- Parameters:
view- the owning viewmodule- the module backing the graph
-
-
Method Details
-
ensureData
protected void ensureData()Description copied from class:PopGraph2DEnsure that the data array is properly initialized based on the current geometry. Temporary display constraints do not discard the backing colour data so the graph can immediately redraw when more space becomes available.- Overrides:
ensureDatain classPopGraph2D
-
update
public void update(boolean isNext) Description copied from class:GenericPopGraphUpdate the graph.- Overrides:
updatein classGenericPopGraph<String, Network2D>- Parameters:
isNext-trueif the state has changed
-
getTooltipAt
Description copied from interface:Tooltip.ProviderGet the tooltip information for the location with coordinates(x, y). The returned string may include HTML elements for formatting.- Specified by:
getTooltipAtin interfaceTooltip.Provider- Overrides:
getTooltipAtin classPopGraph2D- Parameters:
x- thex-coordinate for the tooltipy- they-coordinate for the tooltip- Returns:
- the (formatted) string with the tooltip info
-
decodeBin
Decode the probability mass for a bin from a color-encoded histogram row.- Parameters:
colors- color-encoded histogram rowidx- bin indexnEntries- number of histogram entries to decode- Returns:
- decoded bin mass, or
-1.0if unavailable
-
decodeColorIndex
Decode the discrete index represented bycolor.- Parameters:
color- the encoded color- Returns:
- decoded index, or
-1if unavailable
-
decodeColorValue
Decode the gradient value represented bycolor.- Parameters:
color- the encoded color- Returns:
- decoded value, or
Double.NaNif unavailable
-
isVacantColor
Check whethercolordenotes a vacant site in gradient-based maps.- Parameters:
color- the encoded color- Returns:
trueif the color encodes a vacant site
-
getHistoryColorAt
Retrieve the encoded color at the given history row and node.- Parameters:
row- the history row, with0the most recent onenode- the node index in the row- Returns:
- the encoded color, or
nullif unavailable
-
rebinGraphData
public void rebinGraphData(int oldBins, int newBins) Description copied from class:PopGraph2DRebin graph data when the number of bins changes.Default implementation does nothing. Subclasses can override to preserve rendered state/history across bin changes.
- Overrides:
rebinGraphDatain classPopGraph2D- Parameters:
oldBins- previous number of bins per axisnewBins- new number of bins per axis
-
decodeRow
Decode a 1D histogram row from colors into normalized probability masses.- Parameters:
source- source colorscMap- color map used for encodingbins- number of bins- Returns:
- decoded masses or an empty array if decoding is not possible
-
nonNegativeFinite
private static double nonNegativeFinite(double value) Convert non-finite or negative values to zero.- Parameters:
value- the value to sanitize- Returns:
valueif finite and non-negative,0.0otherwise
-
encodeRow
Encode histogram masses into colors using the graph color map.- Parameters:
masses- histogram massescMap- color map used for encoding- Returns:
- encoded colors or an empty array if encoding is not possible
-
rebinRow
private static double[] rebinRow(double[] source, int oldBins, int newBins) Rebin 1D histogram masses by exact overlap.- Parameters:
source- source massesoldBins- old binsnewBins- new bins- Returns:
- rebinned masses
-
drawLattice
protected void drawLattice()Description copied from class:GenericPopGraphDraws structures with static layout of lattices.- Overrides:
drawLatticein classPopGraph2D- See Also:
-
prepContentCanvas
private boolean prepContentCanvas()Prepare canvas so only content participates in pan/zoom transforms.- Returns:
trueif canvas is ready for drawing
-
drawLinearContent
private void drawLinearContent()Draw linear lattice content without frame. -
drawFrameOverlay
private void drawFrameOverlay()Draw frame and axis decorations without pan/zoom transforms. -
applyViewportRanges
private void applyViewportRanges(double baseXMin, double baseXMax, double baseYMin, double baseYMax) Map current pan/zoom state to visible axis ranges for frame labels/ticks.- Parameters:
baseXMin- baseline x minimumbaseXMax- baseline x maximumbaseYMin- baseline y minimumbaseYMax- baseline y maximum
-
populateGraphContextMenu
Description copied from class:GenericPopGraphOpportunity for subclasses to contribute menu items after graph-local entries such as clear/debug and before the generic zoom/view items.- Overrides:
populateGraphContextMenuin classGenericPopGraph<String, Network2D>- Parameters:
menu- the context menu to populatex- the x-coordinate where the menu was invokedy- the y-coordinate where the menu was invoked
-
populateLocalAxesMenu
Description copied from class:AbstractGraphOpportunity for graph subclasses to contribute graph-local entries to the shared axes submenu assembled by the owning view.- Overrides:
populateLocalAxesMenuin classAbstractGraph<String[]>- Parameters:
axesMenu- the axes submenu to populate
-
calcBounds
public void calcBounds(int width, int height) Description copied from class:AbstractGraphCalculate bounds of drawing area.- Overrides:
calcBoundsin classPopGraph2D- Parameters:
width- the width of the drawing areaheight- the height of the drawing area
-
findNodeAt
public int findNodeAt(int x, int y) Description copied from class:PopGraph2DFind the index of the node at the location with coordinates(x, y).- Overrides:
findNodeAtin classPopGraph2D- Parameters:
x- thex-coordinate of the locationy- they-coordinate of the location- Returns:
- the index of the node
-
shift
public void shift(int dx, int dy) Description copied from class:AbstractGraphShift the (zoomed) graph within the view port by(dx, dy). Default implementation for graphs that implementShifting.- Specified by:
shiftin interfaceAbstractGraph.Shifter- Overrides:
shiftin classAbstractGraph<String[]>- Parameters:
dx- the horizontal shift of the graphdy- the vertical shift of the graph- See Also:
-
zoom
protected void zoom(double zoom, double fx, double fy) Description copied from class:AbstractGraphHelper method to adjust zoom level with the zoom center at the scaled coordinates(fx, fy), specified as a fraction of the view port in horizontal and vertical directions, respectively.- Overrides:
zoomin classAbstractGraph<String[]>- Parameters:
zoom- the new zoom levelfx- the scaledx-coordinate of the zoom centerfy- the scaledy-coordinate of the zoom center- See Also:
-
getContentHeight
private double getContentHeight()Return content height in graph coordinates, taking buffered history into account.- Returns:
- content height in pixels
-
updateYTickOffset
private void updateYTickOffset()Update the y-axis tick label offset to the current model time.
-