Class TriangleSubgraph
java.lang.Object
org.eclipse.zest.core.widgets.DefaultSubgraph
org.eclipse.zest.core.widgets.FigureSubgraph
org.eclipse.zest.core.widgets.custom.TriangleSubgraph
- All Implemented Interfaces:
EntityLayout,SubgraphLayout
A subgraph that is visualized in a graph as a triangle. It assumes that nodes
in context that uses them are arranged in a tree structure and the nodes
added to the subgraph are a subtree (except for the subtree's root, which
should not be added).
The triangle has three features that show the properties of a subtree
contained within it:
- Height of the triangle is proportional to the height of the
subtree. If the subtree contains the whole tree, the triangle's height will
be equal to value provided with
TriangleSubgraph.TriangleParameters.referenceHeight(default is 50). - Length of the triangle's base depends on the number of leaves in
the subtree. More precisely, it is proportional to the logarithm of the
percent that the subtree's leaves make of the whole context's leaves. The
proportion factor is adjusted so that for a subtree containing all the leaves
the base has length provided with
TriangleSubgraphTriangleSubgraph.TriangleParameters.referenceBase(default is 50) and for a subtree containing only one leaf the base has length 1. - Background color of the triangle depends on average number of children for nodes in the subtree. The less is this value, the more bright is the color (up to white for a subtree with average number of children equal to 1). The average value is calculated only for nodes that have at least one child. The root of the subtree (which is not directly added to this subgraph) is also accounted.
TreeLayoutObserver is created for the context. It must keep track of
changes in the graph structure, so events related to it should not be
intercepted by other listeners before they reach the subgraph's observer.- Since:
- 1.14
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.eclipse.zest.core.widgets.FigureSubgraph
FigureSubgraph.SubgraphFigrueListenerNested classes/interfaces inherited from class org.eclipse.zest.core.widgets.DefaultSubgraph
DefaultSubgraph.DefaultSubgraphFactory, DefaultSubgraph.LabelSubgraphFactory, DefaultSubgraph.PrunedSuccessorsSubgraphFactory, DefaultSubgraph.TriangleSubgraphFactory -
Field Summary
Fields inherited from class org.eclipse.zest.core.widgets.FigureSubgraph
figureFields inherited from class org.eclipse.zest.core.widgets.DefaultSubgraph
context, disposed, nodesFields inherited from interface org.eclipse.zest.layouts.interfaces.SubgraphLayout
BOTTOM_UP, LEFT_RIGHT, RIGHT_LEFT, TOP_DOWN -
Constructor Summary
ConstructorsConstructorDescriptionTriangleSubgraph(NodeLayout[] nodes, LayoutContext context, TriangleSubgraph.TriangleParameters triangleParameters) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCreates a figure for this subgraph and stores it inFigureSubgraph.figure.booleanvoidChanges the color of the triangle visualizing this subgraph.voidsetDirection(int direction) Sets the direction of this subgraph (does nothing in case of subgraphs that don't depend on direction)protected voidUpdates the figure stored inFigureSubgraph.figuredepending on current nodes contained in this subgraph.Methods inherited from class org.eclipse.zest.core.widgets.FigureSubgraph
addNodes, applyLayoutChanges, dispose, getFigure, getLocation, getPredecessingEntities, getSize, getSuccessingEntities, isGraphEntity, isMovable, refreshLocation, removeNodes, setLocationMethods inherited from class org.eclipse.zest.core.widgets.DefaultSubgraph
countNodes, getItems, getNodes, getPreferredAspectRatio, isResizable, refreshConnectionsVisibility, refreshSize, removeDisposedNodes, setSize
-
Constructor Details
-
TriangleSubgraph
public TriangleSubgraph(NodeLayout[] nodes, LayoutContext context, TriangleSubgraph.TriangleParameters triangleParameters)
-
-
Method Details
-
createFigure
protected void createFigure()Description copied from class:FigureSubgraphCreates a figure for this subgraph and stores it inFigureSubgraph.figure. This method may not be called right after creation of the subgraph but later when the figure is actually needed (lazy initialization).- Specified by:
createFigurein classFigureSubgraph
-
updateFigure
protected void updateFigure()Description copied from class:FigureSubgraphUpdates the figure stored inFigureSubgraph.figuredepending on current nodes contained in this subgraph. If this method creates a new instance of IFigure, it should remember to add aFigureSubgraph.SubgraphFigrueListenerto it.- Specified by:
updateFigurein classFigureSubgraph
-
isDirectionDependant
public boolean isDirectionDependant()- Specified by:
isDirectionDependantin interfaceSubgraphLayout- Overrides:
isDirectionDependantin classDefaultSubgraph- Returns:
- true if this subgraph is visualized differently depending on direction
-
setDirection
public void setDirection(int direction) Description copied from interface:SubgraphLayoutSets the direction of this subgraph (does nothing in case of subgraphs that don't depend on direction)- Specified by:
setDirectionin interfaceSubgraphLayout- Overrides:
setDirectionin classDefaultSubgraph- Parameters:
direction- one of constants:SubgraphLayout.TOP_DOWN,SubgraphLayout.BOTTOM_UP,SubgraphLayout.LEFT_RIGHT,SubgraphLayout.RIGHT_LEFT
-
setColor
Changes the color of the triangle visualizing this subgraph.- Parameters:
color- color to use
-