use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle in project archi by archimatetool.
the class SpringLayoutAlgorithm method computeOneIteration.
@Override
protected void computeOneIteration(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double x, double y, double width, double height) {
if (bounds == null)
bounds = new DisplayIndependentRectangle(x, y, width, height);
checkPreferredLocation(entitiesToLayout, bounds);
computeForces(entitiesToLayout);
largestMovement = Double.MAX_VALUE;
computePositions(entitiesToLayout);
for (int i = 0; i < entitiesToLayout.length; i++) {
InternalNode layoutEntity = entitiesToLayout[i];
layoutEntity.setInternalLocation(tempLocationsX[i], tempLocationsY[i]);
}
defaultFitWithinBounds(entitiesToLayout, bounds);
iteration++;
}
use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle in project archi by archimatetool.
the class RadialLayoutAlgorithm method preLayoutAlgorithm.
@Override
protected void preLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double x, double y, double width, double height) {
// TODO Auto-generated method stub
layoutBounds = new DisplayIndependentRectangle(x, y, width, height);
super.preLayoutAlgorithm(entitiesToLayout, relationshipsToConsider, x, y, width, height);
}
use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle in project archi by archimatetool.
the class RadialLayoutAlgorithm method computeRadialPositions.
/**
* Take the tree and make it round. This is done by determining the location of each entity in terms
* of its percentage in the tree layout. Then apply that percentage to the radius and distance from
* the center.
*/
protected void computeRadialPositions(InternalNode[] entities, DisplayIndependentRectangle bounds2) {
// TODO TODO TODO
DisplayIndependentRectangle bounds = new DisplayIndependentRectangle(getLayoutBounds(entities, true));
bounds.height = bounds2.height;
bounds.y = bounds2.y;
for (int i = 0; i < entities.length; i++) {
InternalNode entity = entities[i];
double percentTheta = (entity.getInternalX() - bounds.x) / bounds.width;
double distance = (entity.getInternalY() - bounds.y) / bounds.height;
double theta = startDegree + Math.abs(endDegree - startDegree) * percentTheta;
double newX = distance * Math.cos(theta);
double newY = distance * Math.sin(theta);
entity.setInternalLocation(newX, newY);
}
}
use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle in project archi by archimatetool.
the class SpringLayoutAlgorithm method preLayoutAlgorithm.
@Override
protected void preLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double x, double y, double width, double height) {
// TODO: Filter out any non-wanted entities and relationships
// super.applyLayout(entitiesToLayout, relationshipsToConsider, x, y,
// width, height);
// InternalNode[] a_entitiesToLayout = (InternalNode[]) entitiesToLayout.toArray(new InternalNode[entitiesToLayout.size()]);
bounds = new DisplayIndependentRectangle(x, y, width, height);
tempLocationsX = new double[entitiesToLayout.length];
tempLocationsY = new double[entitiesToLayout.length];
forcesX = new double[entitiesToLayout.length];
forcesY = new double[entitiesToLayout.length];
anchors = new boolean[entitiesToLayout.length];
for (int i = 0; i < entitiesToLayout.length; i++) {
anchors[i] = DEFAULT_ANCHOR;
}
for (int i = 0; i < relationshipsToConsider.length; i++) {
InternalRelationship layoutRelationship = relationshipsToConsider[i];
addRelation(layoutRelationship);
}
// do the calculations
preCompute(entitiesToLayout);
startTime = date.getTime();
}
use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle in project archi by archimatetool.
the class SpringLayoutAlgorithm method checkPreferredLocation.
private void checkPreferredLocation(InternalNode[] entitiesToLayout, DisplayIndependentRectangle realBounds) {
// use 10% for the border - 5% on each side
double borderWidth = Math.min(realBounds.width, realBounds.height) / 10.0;
DisplayIndependentRectangle screenBounds = new DisplayIndependentRectangle(realBounds.x + borderWidth / 2.0, realBounds.y + borderWidth / 2.0, realBounds.width - borderWidth, realBounds.height - borderWidth);
DisplayIndependentRectangle layoutBounds = getLayoutBoundsTemp(entitiesToLayout, false);
for (int i = 0; i < entitiesToLayout.length; i++) {
InternalNode layoutEntity = entitiesToLayout[i];
if (layoutEntity.hasPreferredLocation()) {
convertNodePositionsBack(i, layoutEntity, layoutEntity.getPreferredX(), layoutEntity.getPreferredY(), screenBounds.width, screenBounds.height, layoutBounds);
}
}
}
Aggregations