org.eclipse.gef4.zest.core.widgets.custom

## Class TriangleSubgraph

- java.lang.Object
- - org.eclipse.gef4.zest.core.widgets.DefaultSubgraph
  - - org.eclipse.gef4.zest.core.widgets.FigureSubgraph
    - - org.eclipse.gef4.zest.core.widgets.custom.TriangleSubgraph

All Implemented Interfaces:
  org.eclipse.gef4.layout.interfaces.EntityLayout, org.eclipse.gef4.layout.interfaces.SubgraphLayout, org.eclipse.gef4.layout.IPropertyStore

    public class TriangleSubgraph
    extends FigureSubgraph

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#setReferenceHeight(double)` (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 `TriangleSubgraph` `#setReferenceBase(double)` (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.

When the first subgraph of this class is created for a layout context, a `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:
  2.0

### Nested Class Summary

Nested Classes
`static class` `TriangleSubgraph.TriangleParameters`

### Nested classes/interfaces inherited from class org.eclipse.gef4.zest.core.widgets.FigureSubgraph

`FigureSubgraph.SubgraphFigrueListener`

### Nested classes/interfaces inherited from class org.eclipse.gef4.zest.core.widgets.DefaultSubgraph

`DefaultSubgraph.DefaultSubgraphFactory, DefaultSubgraph.LabelSubgraphFactory, DefaultSubgraph.PrunedSuccessorsSubgraphFactory, DefaultSubgraph.TriangleSubgraphFactory`

### Field Summary

### Fields inherited from class org.eclipse.gef4.zest.core.widgets.FigureSubgraph

`figure`

### Fields inherited from class org.eclipse.gef4.zest.core.widgets.DefaultSubgraph

`context, disposed, nodes`

### Fields inherited from interface org.eclipse.gef4.layout.interfaces.SubgraphLayout

`BOTTOM_UP, LEFT_RIGHT, RIGHT_LEFT, TOP_DOWN`

### Fields inherited from interface org.eclipse.gef4.layout.interfaces.EntityLayout

`LOCATION_PROPERTY, MOVABLE_PROPERTY, SIZE_PROPERTY`

### Constructor Summary

Constructors
Constructor and Description
`TriangleSubgraph(org.eclipse.gef4.layout.interfaces.NodeLayout[] nodes, org.eclipse.gef4.layout.interfaces.LayoutContext context, TriangleSubgraph.TriangleParameters triangleParameters)`

### Method Summary

Methods
`protected void` `createFigure()` Creates a figure for this subgraph and stores it in `FigureSubgraph.figure`.
`boolean` `isDirectionDependant()`
`void` `setColor(Color color)` Changes the color of the triangle visualizing this subgraph.
`void` `setDirection(int direction)`
`protected void` `updateFigure()` Updates the figure stored in `FigureSubgraph.figure` depending on current nodes contained in this subgraph.

### Methods inherited from class org.eclipse.gef4.zest.core.widgets.FigureSubgraph

`addNodes, applyLayoutChanges, dispose, getFigure, getLocation, getPredecessingEntities, getSize, getSuccessingEntities, isGraphEntity, isMovable, refreshLocation, removeNodes, setLocation`

### Methods inherited from class org.eclipse.gef4.zest.core.widgets.DefaultSubgraph

`countNodes, getItems, getNodes, getPreferredAspectRatio, getProperty, isResizable, refreshConnectionsVisibility, refreshSize, setProperty, setSize`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### TriangleSubgraph

    public TriangleSubgraph(org.eclipse.gef4.layout.interfaces.NodeLayout[] nodes,
                    org.eclipse.gef4.layout.interfaces.LayoutContext context,
                    TriangleSubgraph.TriangleParameters triangleParameters)

### Method Detail

#### createFigure

    protected void createFigure()

Description copied from class: `FigureSubgraph`
Creates a figure for this subgraph and stores it in `FigureSubgraph.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:
  `createFigure` in class `FigureSubgraph`

#### updateFigure

    protected void updateFigure()

Description copied from class: `FigureSubgraph`
Updates the figure stored in `FigureSubgraph.figure` depending on current nodes contained in this subgraph. If this method creates a new instance of IFigure, it should remember to add a `FigureSubgraph.SubgraphFigrueListener` to it.

Specified by:
  `updateFigure` in class `FigureSubgraph`

#### isDirectionDependant

    public boolean isDirectionDependant()

Specified by:
  `isDirectionDependant` in interface `org.eclipse.gef4.layout.interfaces.SubgraphLayout`
Overrides:
  `isDirectionDependant` in class `DefaultSubgraph`

#### setDirection

    public void setDirection(int direction)

Specified by:
  `setDirection` in interface `org.eclipse.gef4.layout.interfaces.SubgraphLayout`
Overrides:
  `setDirection` in class `DefaultSubgraph`

#### setColor

    public void setColor(Color color)

Changes the color of the triangle visualizing this subgraph.

Parameters:
  `color` - color to use