|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.AbstractLayoutStage y.layout.CurveFittingLayoutStage
public class CurveFittingLayoutStage
CurveFittingLayoutStage
fits a piecewise cubic bezier curve to given arbitrary edge paths.
The path
of an edge, i.e., its start and end point as well as the
intermediate control points, are interpreted as the set of input points. A cubic bezier curve is
then fitted to these points.
After the fitting, the points of the processed edges can be interpreted as cubic bezier control points. Each four consecutive points form a bezier curve, where the first and last of the four points represent the start and end of the curve and the second and third point are the control points defining how the curve looks. The second and third point do not necessarily lie on the actual curve.
There are two exceptions to the stated rules:
The maximum allowed error
for the fitting process can be selected to control
how high the precision should be. A high allowed error means that the approximation process has a lot
of freedom. Curves are only loosely bound to the original edge path. If this is not desired, e.g., because
no new intersection with other graph elements should be introduced, then a rather low error value should be
specified. The lower the error value, the larger the number of bend points of an approximated edge will be.
It is possible to define the set of edges that should be processed by this layout stage. Therefore, only
paths of a sub-set of edges can be changed. Use a DataProvider
registered with the specified
selection key
to mark edges which should be part of the
considered sub-set.
CurveFittingLayoutStage
is useful if curved edge paths were
modeled using a large number of bends which are then connected by straight lines - as, for example,
produced by RadialLayouter
. Applying this stage can drastically
reduce the number of necessary bends in such cases.Field Summary | |
---|---|
static java.lang.Object |
FITTING_SELECTION_DPKEY
A DataProvider key for selecting edges for curve fitting
|
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
CurveFittingLayoutStage()
Creates a new CurveFittingLayoutStage with default settings. |
|
CurveFittingLayoutStage(Layouter core)
Creates a new CurveFittingLayoutStage with the given algorithm as core layout algorithm . |
Method Summary | |
---|---|
boolean |
canLayout(LayoutGraph graph)
Accepts all graphs that can be handled by the core layout algorithm . |
void |
doLayout(LayoutGraph graph)
Changes the edge paths of selected edges of the given graph such that they represent piecewise cubic bezier curves which approximate the original points of the path. |
double |
getMaximumError()
Returns the maximum allowed error for the fitting process. |
java.lang.Object |
getSelectedEdgesDpKey()
Returns the DataProvider key to look up the selection state of the edges that defines whether
or not an edge's path should be approximated by a bezier curve. |
double |
getStraightControlPointRatio()
Returns the ratio that defines the distance between the intermediate control points and the end points of a cubic segment which actually represents a straight line, i.e., in case the four points are collinear. |
void |
setMaximumError(double maximumError)
Specifies the maximum allowed error for the fitting process. |
void |
setSelectedEdgesDpKey(java.lang.Object selectedEdgesDpKey)
Specifies the DataProvider key to look up the selection state of the edges that defines whether
or not an edge's path should be approximated by a bezier curve. |
void |
setStraightControlPointRatio(double straightControlPointRatio)
Specifies the ratio that defines the distance between the intermediate control points and the end points of a cubic segment which actually represents a straight line, i.e., in case the four points are collinear. |
Methods inherited from class y.layout.AbstractLayoutStage |
---|
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Object FITTING_SELECTION_DPKEY
DataProvider
key for selecting edges for curve fitting
DataProvider
registered with this key, a curve is fitted to all edges.Constructor Detail |
---|
public CurveFittingLayoutStage()
CurveFittingLayoutStage
with default settings.
public CurveFittingLayoutStage(Layouter core)
CurveFittingLayoutStage
with the given algorithm as core layout algorithm
.
core
- the core layout algorithmMethod Detail |
---|
public double getMaximumError()
The error is defined as the minimum distance between an original input control point (i.e. bend) of and edge and the fitted bezier curve.
The maximum error must be greater than or equal to zero.
setMaximumError(double)
public void setMaximumError(double maximumError)
The error is defined as the minimum distance between an original input control point (i.e. bend) of and edge and the fitted bezier curve.
The maximum error must be greater than or equal to zero.
maximumError
- the maximum allowed error for the fitting process
java.lang.IllegalArgumentException
- if the specified maximum error is negativepublic double getStraightControlPointRatio()
0.33
- the second and third control point are equally distributed between
te first and fourth point.
0.0
- the first and second control point as well as the
third and fourth point are equal.
0.5
- the second and third control point are equal and exactly the mid-point
between the first and fourth point.
The control point ratio is defined to be within the interval [0.0, 0.5]
.
setStraightControlPointRatio(double)
public void setStraightControlPointRatio(double straightControlPointRatio)
0.33
- the second and third control point are equally distributed between
te first and fourth point.
0.0
- the first and second control point as well as the
third and fourth point are equal.
0.5
- the second and third control point are equal and exactly the mid-point
between the first and fourth point.
The control point ratio is defined to be within the interval [0.0, 0.5]
.
straightControlPointRatio
- the control point ratio for straight-line path segments
java.lang.IllegalArgumentException
- if the specified ratio is outside the interval [0.0, 0.5]
public java.lang.Object getSelectedEdgesDpKey()
DataProvider
key to look up the selection state of the edges that defines whether
or not an edge's path should be approximated by a bezier curve.
If there is a DataProvider
registered with the input graph with this key, then only marked edges are
processed by this layout stage. Otherwise, all edges are processed.
DataProvider
key for edge selectionsetSelectedEdgesDpKey(Object)
public void setSelectedEdgesDpKey(java.lang.Object selectedEdgesDpKey)
DataProvider
key to look up the selection state of the edges that defines whether
or not an edge's path should be approximated by a bezier curve.
If there is a DataProvider
registered with the input graph with this key, then only marked edges are
processed by this layout stage. Otherwise, all edges are processed.
FITTING_SELECTION_DPKEY
selectedEdgesDpKey
- the DataProvider
key for edge selection
java.lang.IllegalArgumentException
- if the specified DataProvider
key is null
public boolean canLayout(LayoutGraph graph)
core layout algorithm
.
If there is no core layout algorithm
, all graphs are accepted.
graph
- the input graph
true
if there is no core layout algorithm or the core layout algorithm accepts the graph,
false
otherwiseLayouter.doLayout(LayoutGraph)
public void doLayout(LayoutGraph graph)
graph
- the input graphLayouter.canLayout(LayoutGraph)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |