public class AlgorithmHelper
extends java.lang.Object
AlgorithmHelper
class contains utility methods for the laying out
of entities within bounds.Modifier and Type | Field and Description |
---|---|
static int |
MIN_NODE_SIZE
The minimum size of a node.
|
static double |
PADDING_PERCENT
This percent of a node's maximum size is reserved for the node, the rest
is used as padding, i.e.
|
Constructor and Description |
---|
AlgorithmHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
fitWithinBounds(IEntityLayout[] entities,
Rectangle destinationBounds,
boolean resize)
Fits given entities within given bounds, preserving their relative
locations.
|
static Rectangle |
getLayoutBounds(IEntityLayout[] entities,
boolean includeNodeSize)
Find the bounds in which the nodes are located.
|
static Dimension |
getMinimumDistance(IEntityLayout[] entities)
minDistance is the closest that any two points are together.
|
static void |
maximizeSizes(IEntityLayout[] entities)
Resizes the nodes so that they have a maximal area without overlapping
each other, with additional empty space of 20% of node's width (or
height, if bigger).
|
public static int MIN_NODE_SIZE
public static double PADDING_PERCENT
node_size = max_size * PADDING_PERCENT
.public static void fitWithinBounds(IEntityLayout[] entities, Rectangle destinationBounds, boolean resize)
true
, then the entity will be scaled according to the bounds
change, i.e. scale_factor = dst_bounds / start_bounds
.entities
- The IEntityLayout
s to fit.destinationBounds
- The Rectangle
representing the layout bounds.resize
- true
to indicate that the entities can be
resized, otherwise false
.public static void maximizeSizes(IEntityLayout[] entities)
entities
- The IEntityLayout
s of which the sizes are maximized.public static Rectangle getLayoutBounds(IEntityLayout[] entities, boolean includeNodeSize)
entities
- The IEntityLayout
s for which the layout bounds are
computed.includeNodeSize
- true
to indicate that the entities' sizes should
be taken into consideration, otherwise false
.Rectangle
representing the layout bounds of the given
IEntityLayout
s.public static Dimension getMinimumDistance(IEntityLayout[] entities)
_______ | | | | | + | | |\ | |___|_\_|_____ | | \ | | | \ | +-|---+ | | | |_______|
entities
- The IEntityLayout
s for which the minimum distance is
computed.Dimension
representing the minimum distance (in x- and
y-direction).Copyright (c) 2014 itemis AG and others. All rights reserved.