Back to Graal

Filter API Documentation

visualizer/Filters.md

1.0.05.9 KB
Original Source

Filter API Documentation

Here you can find documentation for Filter API of Ideal Graph Visualizer.
Custom filters are powerful tool which let you write your own code in JavaScript
to allow almost unbound manipulation and analysis of GraalVM graphs in Ideal Graph Visualizer.

Helpers

Our Filter API comes with various prepared helper functions to speedup writing of your own filters,
helpers are written against imported classes listed below.

  • classSimpleName(className: string): string;
    returns regexp for easier matching of "class" property to class name (matches all namespaces)<p> </p>
  • colorize(propertyName: string, valueRegexp: string, color: Color);
    colorizes nodes with matching property value to a color,
    there are already prepared colors in global variables:
    -- black, white, gray, darkGray, lightGray, red, green, blue, cyan, magenta, yellow, orange, pink
    or you can create your own (viz imported classes): var color = new Color(r, g, b);<p> </p>
  • colorizeGradient(propertyName: string, min: number, max: number);
    colorizes nodes with property in gradient manner on interval [min, max] (expects value to be a number)
    default coloring goes from blue through yellow to red in linear fassion.<p> </p>
  • colorizeGradientWithMode(propertyName: string, min: number, max: number, gradientMode: string);
    allows to set traversion between colors to either "LINEAR" or "LOGARITHMIC" mode.<p> </p>
  • colorizeGradientCustom(propertyName: string, min: number, max: number, gradientMode: string, colors: Color[], fractions: number[], shades: integer);
    allows to further specify:
    -- colors: used colors in order from minimal to maximal value
    -- fractions: positions of abovementioned colors on color gradient scale (first is 0, last 1)
    -- shades: number of used color shades<p> </p>
  • remove(propertyName: string, valueRegexp: string);
    removes nodes with matching property value<p> </p>
  • removeIncludingOrphans(propertyName: string, valueRegexp: string);
    removes nodes with matching property value and possible orphaned nodes<p> </p>
  • removeInputs(propertyName: string, valueRegexp: string, fromIndex: integer = 0, toIndex: integer = Integer.MAX_VALUE);
    removes input connections of nodes with matching property value
    -- fromIndex and toIndex denotes starting and ending index of inputs to remove<p> </p>
  • removeUnconectedSlots(removeInputs: boolean, removeOutputs: boolean);
    removes input/output slots that doesn't have a connection<p> </p>
  • split(propertyName: string, valueRegexp: string, nodeText: string);
    removes nodes with matching property value and turns them into names slots on predecessor and successor nodes -- node text allow to extract and use property values as name text by format: "[propertyName]"

<a name=global-variables></a>Defined global variables

<a name=global-colors></a>Colors

Variable nameContent
blackColor.static.black
blueColor.static.blue
cyanColor.static.cyan
darkGrayColor.static.darkGray
grayColor.static.gray
greenColor.static.green
lightGrayColor.static.lightGray
magentaColor.static.magenta
orangeColor.static.orange
pinkColor.static.pink
redColor.static.red
yellowColor.static.yellow
whiteColor.static.white

<a name=global-others></a>Others

Variable nameContentDescription
IOPrintStreamoutput stream
graphDiagramcurrent graph

<a name=imported-classes></a>Imported classes

Classes imported from Ideal Graph Visualizer Java codebase to allow their creation.

JS ClassJava Class
Colorjava.awt.Color
GraphDocumentorg.graalvm.visualizer.data.GraphDocument
InputGraphorg.graalvm.visualizer.data.InputGraph
Diagramorg.graalvm.visualizer.graph.Diagram
Blockorg.graalvm.visualizer.graph.Block
Figureorg.graalvm.visualizer.graph.Figure
FigureSourceorg.graalvm.visualizer.graph.FigureSource
InputSlotorg.graalvm.visualizer.graph.InputSlot
OutputSlotorg.graalvm.visualizer.graph.OutputSlot
Connectionorg.graalvm.visualizer.graph.Connection
MatcherSelectororg.graalvm.visualizer.graph.MatcherSelector
InvertSelectororg.graalvm.visualizer.graph.InvertSelector
AndSelectororg.graalvm.visualizer.graph.AndSelector
OrSelectororg.graalvm.visualizer.graph.OrSelector
PredecessorSelectororg.graalvm.visualizer.graph.PredecessorSelector
SuccessorSelectororg.graalvm.visualizer.graph.SuccessorSelector
Propertiesorg.graalvm.visualizer.data.Properties
Propertyorg.graalvm.visualizer.data.Property
PropertySelectororg.graalvm.visualizer.data.Properties$PropertySelector
RegexpPropertyMatcherorg.graalvm.visualizer.data.Properties$RegexpPropertyMatcher
EqualityPropertyMatcherorg.graalvm.visualizer.data.Properties$EqualityPropertyMatcher
InvertPropertyMatcherorg.graalvm.visualizer.data.Properties$InvertPropertyMatcher
ColorFilterorg.graalvm.visualizer.filter.ColorFilter
ColorRuleorg.graalvm.visualizer.filter.ColorFilter$ColorRule
CombineFilterorg.graalvm.visualizer.filter.CombineFilter
ConnectionFilterorg.graalvm.visualizer.filter.ConnectionFilter
CustomFilterorg.graalvm.visualizer.filter.CustomFilter
EdgeColorIndexFilterorg.graalvm.visualizer.filter.EdgeColorIndexFilter
GradientColorFilterorg.graalvm.visualizer.filter.GradientColorFilter
RemoveFilterorg.graalvm.visualizer.filter.RemoveFilter
RemoveRuleorg.graalvm.visualizer.filter.RemoveFilter$RemoveRule
RemoveInputsFilterorg.graalvm.visualizer.filter.RemoveInputsFilter
RemoveInputsRuleorg.graalvm.visualizer.filter.RemoveInputsFilter$RemoveInputsRule
RemoveSelfLoopsFilterorg.graalvm.visualizer.filter.RemoveSelfLoopsFilter
SplitFilterorg.graalvm.visualizer.filter.SplitFilter
UnconnectedSlotFilterorg.graalvm.visualizer.filter.UnconnectedSlotFilter