GraphView
GraphView is a pannable, zoomable canvas for displaying node graphs or any arbitrary 2D content. Children are placed on a contentRoot element that can be translated and scaled. The view renders a repeating grid background and supports:
- Pan — click and drag (left-button on the view background, or middle-button anywhere).
- Zoom — mouse wheel, clamped to
[min-scale, max-scale]. - Fit — helpers to centre and scale the view to fit all children or a given bounding box.
Everything documented on UIElement (layout, styles, events, data bindings, etc.) applies here too.
Usage
Internal Structure
| Field | CSS class | Description |
|---|---|---|
contentRoot |
.__graph-view_content-root__ |
Absolutely-positioned element that holds all user-added children and receives the pan/zoom transform. |
GraphView Style
allow-zoom
Whether scrolling the mouse wheel changes the zoom level.
Default: true
allow-pan
Whether clicking and dragging pans the view.
Default: true
min-scale / max-scale
Zoom level bounds.
Defaults: 0.1 / 10
grid-background
Texture tiled across the background. The default is a built-in grid sprite with REPEAT wrap mode.
Default: ldlib2:textures/gui/grid_bg.png (repeat)
grid-size
Size (in world-space units) of each grid cell.
Default: 64
Fields
| Name | Type | Access | Description |
|---|---|---|---|
contentRoot |
UIElement |
public final |
The transformed canvas holding all content. |
graphViewStyle |
GraphViewStyle |
private (getter) |
Current style. |
offsetX |
float |
getter/setter |
Current horizontal world-space offset. |
offsetY |
float |
getter/setter |
Current vertical world-space offset. |
scale |
float |
private (getter) |
Current zoom level. |
Methods
| Method | Returns | Description |
|---|---|---|
addContentChild(UIElement) |
GraphView |
Adds a child to contentRoot. |
removeContentChild(UIElement) |
GraphView |
Removes a child from contentRoot. |
clearAllContentChildren() |
GraphView |
Removes all children from contentRoot. |
graphViewStyle(Consumer<GraphViewStyle>) |
GraphView |
Configures style fluently. |
contentRoot(Consumer<UIElement>) |
UIElement |
Configures contentRoot. |
fitToChildren(float padding, float minScaleBound) |
void |
Adjusts offset and scale to fit all visible children, with the given padding and minimum scale. |
fit(float minX, float minY, float maxX, float maxY, float minScaleBound) |
void |
Adjusts offset and scale to fit the given bounding box. |