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

public class PopGraph1D extends PopGraph2D
Specialized population graph for linear geometries with history.

Content is shifted/zoomed, while the frame and axis decorations remain fixed.

  • Field Details

    • DEFAULT_BUFFER_CAPACITY

      private static final int DEFAULT_BUFFER_CAPACITY
      Default buffer capacity for linear-history graphs.
      See Also:
    • EMPTY_MASS_ROW

      private static final double[] EMPTY_MASS_ROW
      Empty decoded row sentinel.
    • EMPTY_COLOR_ROW

      private static final String[] EMPTY_COLOR_ROW
      Empty encoded row sentinel.
  • Constructor Details

    • PopGraph1D

      public PopGraph1D(AbstractView<?> view, Module<?> module)
      Create a graph for linear population rendering.
      Parameters:
      view - the owning view
      module - the module backing the graph
  • Method Details

    • ensureData

      protected void ensureData()
      Description copied from class: PopGraph2D
      Ensure 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:
      ensureData in class PopGraph2D
    • update

      public void update(boolean isNext)
      Description copied from class: GenericPopGraph
      Update the graph.
      Overrides:
      update in class GenericPopGraph<String, Network2D>
      Parameters:
      isNext - true if the state has changed
    • getTooltipAt

      public String getTooltipAt(int x, int y)
      Description copied from interface: Tooltip.Provider
      Get the tooltip information for the location with coordinates (x, y). The returned string may include HTML elements for formatting.
      Specified by:
      getTooltipAt in interface Tooltip.Provider
      Overrides:
      getTooltipAt in class PopGraph2D
      Parameters:
      x - the x-coordinate for the tooltip
      y - the y-coordinate for the tooltip
      Returns:
      the (formatted) string with the tooltip info
    • decodeBin

      public double decodeBin(String[] colors, int idx, int nEntries)
      Decode the probability mass for a bin from a color-encoded histogram row.
      Parameters:
      colors - color-encoded histogram row
      idx - bin index
      nEntries - number of histogram entries to decode
      Returns:
      decoded bin mass, or -1.0 if unavailable
    • decodeColorIndex

      public int decodeColorIndex(String color)
      Decode the discrete index represented by color.
      Parameters:
      color - the encoded color
      Returns:
      decoded index, or -1 if unavailable
    • decodeColorValue

      public double decodeColorValue(String color)
      Decode the gradient value represented by color.
      Parameters:
      color - the encoded color
      Returns:
      decoded value, or Double.NaN if unavailable
    • isVacantColor

      public boolean isVacantColor(String color)
      Check whether color denotes a vacant site in gradient-based maps.
      Parameters:
      color - the encoded color
      Returns:
      true if the color encodes a vacant site
    • getHistoryColorAt

      public String getHistoryColorAt(int row, int node)
      Retrieve the encoded color at the given history row and node.
      Parameters:
      row - the history row, with 0 the most recent one
      node - the node index in the row
      Returns:
      the encoded color, or null if unavailable
    • rebinGraphData

      public void rebinGraphData(int oldBins, int newBins)
      Description copied from class: PopGraph2D
      Rebin graph data when the number of bins changes.

      Default implementation does nothing. Subclasses can override to preserve rendered state/history across bin changes.

      Overrides:
      rebinGraphData in class PopGraph2D
      Parameters:
      oldBins - previous number of bins per axis
      newBins - new number of bins per axis
    • decodeRow

      private static double[] decodeRow(String[] source, ColorMap.Gradient1D<String> cMap, int bins)
      Decode a 1D histogram row from colors into normalized probability masses.
      Parameters:
      source - source colors
      cMap - color map used for encoding
      bins - 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:
      value if finite and non-negative, 0.0 otherwise
    • encodeRow

      private static String[] encodeRow(double[] masses, ColorMap.Gradient1D<String> cMap)
      Encode histogram masses into colors using the graph color map.
      Parameters:
      masses - histogram masses
      cMap - 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 masses
      oldBins - old bins
      newBins - new bins
      Returns:
      rebinned masses
    • drawLattice

      protected void drawLattice()
      Description copied from class: GenericPopGraph
      Draws structures with static layout of lattices.
      Overrides:
      drawLattice in class PopGraph2D
      See Also:
    • prepContentCanvas

      private boolean prepContentCanvas()
      Prepare canvas so only content participates in pan/zoom transforms.
      Returns:
      true if 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 minimum
      baseXMax - baseline x maximum
      baseYMin - baseline y minimum
      baseYMax - baseline y maximum
    • populateGraphContextMenu

      protected void populateGraphContextMenu(ContextMenu menu, int x, int y)
      Description copied from class: GenericPopGraph
      Opportunity for subclasses to contribute menu items after graph-local entries such as clear/debug and before the generic zoom/view items.
      Overrides:
      populateGraphContextMenu in class GenericPopGraph<String, Network2D>
      Parameters:
      menu - the context menu to populate
      x - the x-coordinate where the menu was invoked
      y - the y-coordinate where the menu was invoked
    • populateLocalAxesMenu

      public void populateLocalAxesMenu(ContextMenu axesMenu)
      Description copied from class: AbstractGraph
      Opportunity for graph subclasses to contribute graph-local entries to the shared axes submenu assembled by the owning view.
      Overrides:
      populateLocalAxesMenu in class AbstractGraph<String[]>
      Parameters:
      axesMenu - the axes submenu to populate
    • calcBounds

      public void calcBounds(int width, int height)
      Description copied from class: AbstractGraph
      Calculate bounds of drawing area.
      Overrides:
      calcBounds in class PopGraph2D
      Parameters:
      width - the width of the drawing area
      height - the height of the drawing area
    • findNodeAt

      public int findNodeAt(int x, int y)
      Description copied from class: PopGraph2D
      Find the index of the node at the location with coordinates (x, y).
      Overrides:
      findNodeAt in class PopGraph2D
      Parameters:
      x - the x-coordinate of the location
      y - the y-coordinate of the location
      Returns:
      the index of the node
    • shift

      public void shift(int dx, int dy)
      Description copied from class: AbstractGraph
      Shift the (zoomed) graph within the view port by (dx, dy). Default implementation for graphs that implement Shifting.
      Specified by:
      shift in interface AbstractGraph.Shifter
      Overrides:
      shift in class AbstractGraph<String[]>
      Parameters:
      dx - the horizontal shift of the graph
      dy - the vertical shift of the graph
      See Also:
    • zoom

      protected void zoom(double zoom, double fx, double fy)
      Description copied from class: AbstractGraph
      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.
      Overrides:
      zoom in class AbstractGraph<String[]>
      Parameters:
      zoom - the new zoom level
      fx - the scaled x-coordinate of the zoom center
      fy - the scaled y-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.