Search this API

y.layout.transformer
Class GraphZoomer

java.lang.Object
  extended by y.layout.transformer.GraphZoomer
All Implemented Interfaces:
Layouter

public class GraphZoomer
extends java.lang.Object
implements Layouter

This layout algorithm applies zoom operations to (sub-)graphs.

Layout Style

The zoomed parts of the graph are more detailed.

A radial zoom in a regular grid

Features

The zoom operations are defined by GraphZoomer.Zoom. Custom implementations provide the modification of the initial graph coordinates.

There are two predefined zoom operations: radial (fish-eye) zoom and rectangular zoom. Both operations will just move the nodes and bends. However, they will not introduce new bends.

Zoom operations can be combined by adding several instances to a list that gets processed in doLayout(LayoutGraph).

See Also:
addRadialZoom(YPoint, double, double, double), addRectangularZoom(YPoint, double, double, double, double), GraphZoomer.Zoom
 

Nested Class Summary
static interface GraphZoomer.Zoom
          A GraphZoomer.Zoom modifies the position of the nodes in a specific area in the graph.
 
Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
GraphZoomer()
          Creates a new instance of GraphZoomer with an empty list of zoom operations.
 
Method Summary
 void addRadialZoom(YPoint center, double innerRadius, double outerRadius, double zoomFactor)
          Adds a radial zoom operation to the list of operations to be performed on the graph.
 void addRectangularZoom(YPoint center, double innerRadius, double outerRadius, double ratio, double zoomFactor)
          Adds a rectangular zoom operation to the list of operations performed on the graph.
 boolean canLayout(LayoutGraph graph)
          Accepts all general graphs.
 void doLayout(LayoutGraph graph)
          Applies previously defined zoom operations to the given graph.
static void zoom(LayoutGraph graph, GraphZoomer.Zoom zoom)
          Applies the given zoom operation to the given graph.
static void zoomRadial(LayoutGraph graph, double centerX, double centerY, double innerRadius, double outerRadius, double zoomFactor)
          Applies a radial zoom operation to the given graph.
static void zoomRectangular(LayoutGraph graph, double centerX, double centerY, double innerRadius, double outerRadius, double ratio, double zoomFactor)
          Applies a rectangular zoom operation to the given graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphZoomer

public GraphZoomer()
Creates a new instance of GraphZoomer with an empty list of zoom operations.

See Also:
addRadialZoom(YPoint, double, double, double), addRectangularZoom(YPoint, double, double, double, double), GraphZoomer.Zoom
Method Detail

addRadialZoom

public void addRadialZoom(YPoint center,
                          double innerRadius,
                          double outerRadius,
                          double zoomFactor)
Adds a radial zoom operation to the list of operations to be performed on the graph.

The zoom factor is applied to the subgraph located inside the inner radius. Inside the outer radius and outside the inner radius, the zoom factor will be reduced. The zoom factor outside the outer radius will be reduced again.

Parameters:
center - the center coordinates of the zooming area
innerRadius - the radius of the circle around the center inside which the zoom level is constantly set to the given zoom factor
outerRadius - the radius of the outer circle around the center inside which the zoom factor will be reduced; must be greater than the inner radius
zoomFactor - the zoom factor inside the inner circle
See Also:
GraphZoomer.Zoom

addRectangularZoom

public void addRectangularZoom(YPoint center,
                               double innerRadius,
                               double outerRadius,
                               double ratio,
                               double zoomFactor)
Adds a rectangular zoom operation to the list of operations performed on the graph.

The zoom factor is applied to the subgraph located inside the rectangle defined by the inner radius and the given ratio. Inside the rectangle defined by the outer radius and the ratio and outside the inner rectangle, the zoom factor will be reduced. The zoom factor outside the outer rectangle will be reduced again.

Parameters:
center - the center coordinates of the zooming area
innerRadius - the radius of the rectangular shape around the center inside which the zoom level is constantly set to the given zoom factor
outerRadius - the radius of the outer rectangular shape around the center inside which the zoom factor will be reduced; must be greater than the inner radius
ratio - the aspect ratio of the inner and outer rectangle
zoomFactor - the zoom factor inside the inner rectangle
See Also:
GraphZoomer.Zoom

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all general graphs.

Specified by:
canLayout in interface Layouter
Parameters:
graph - the input graph
Returns:
true for all graphs
See Also:
Layouter.doLayout(LayoutGraph)

doLayout

public void doLayout(LayoutGraph graph)
Applies previously defined zoom operations to the given graph.

Specified by:
doLayout in interface Layouter
Parameters:
graph - the input graph
See Also:
addRadialZoom(YPoint, double, double, double), addRectangularZoom(YPoint, double, double, double, double), GraphZoomer.Zoom

zoomRadial

public static final void zoomRadial(LayoutGraph graph,
                                    double centerX,
                                    double centerY,
                                    double innerRadius,
                                    double outerRadius,
                                    double zoomFactor)
Applies a radial zoom operation to the given graph.

The zoom factor is applied to the subgraph located inside the inner radius. Inside the outer radius and outside the inner radius, the zoom factor will be reduced. The zoom factor outside the outer radius will be reduced again.

Parameters:
graph - the input graph
centerX - the center x-coordinate of the zooming area
centerY - the center y-coordinate of the zooming area
innerRadius - the radius of the circle around the center inside which the zoom level is constantly set to the given zoom factor
outerRadius - the radius of the outer circle around the center inside which the zoom factor will be reduced; must be greater than the inner radius
zoomFactor - the zoom factor inside the inner circle
See Also:
GraphZoomer.Zoom, addRadialZoom(YPoint, double, double, double)

zoomRectangular

public static final void zoomRectangular(LayoutGraph graph,
                                         double centerX,
                                         double centerY,
                                         double innerRadius,
                                         double outerRadius,
                                         double ratio,
                                         double zoomFactor)
Applies a rectangular zoom operation to the given graph.

The zoom factor is applied to the subgraph located inside the rectangle defined by the inner radius and the given ratio. Inside the rectangle defined by the outer radius and the ratio and outside the inner rectangle, the zoom factor will be reduced. The zoom factor outside the outer rectangle will be reduced again.

Parameters:
graph - the input graph
centerX - the center x-coordinate of the zooming area
centerY - the center y-coordinate of the zooming area
innerRadius - the radius of the rectangular shape around the center inside which the zoom level is constantly set to the given zoom factor
outerRadius - the radius of the outer rectangular shape around the center inside which the zoom factor will be reduced; must be greater than the inner radius
ratio - the aspect ratio of the inner and outer rectangle
zoomFactor - the zoom factor inside the inner circle
See Also:
GraphZoomer.Zoom, addRectangularZoom(YPoint, double, double, double, double)

zoom

public static final void zoom(LayoutGraph graph,
                              GraphZoomer.Zoom zoom)
Applies the given zoom operation to the given graph.

Parameters:
graph - the input graph
zoom - the zoom operation

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.