Search in sources :

Example 1 with DisplayIndependentRectangle

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++;
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle) InternalNode(org.eclipse.zest.layouts.dataStructures.InternalNode)

Example 2 with DisplayIndependentRectangle

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);
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle)

Example 3 with DisplayIndependentRectangle

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);
    }
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle) InternalNode(org.eclipse.zest.layouts.dataStructures.InternalNode) DisplayIndependentPoint(org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint)

Example 4 with DisplayIndependentRectangle

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();
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle) InternalRelationship(org.eclipse.zest.layouts.dataStructures.InternalRelationship)

Example 5 with DisplayIndependentRectangle

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);
        }
    }
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle) InternalNode(org.eclipse.zest.layouts.dataStructures.InternalNode)

Aggregations

DisplayIndependentRectangle (org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle)14 DisplayIndependentPoint (org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint)6 InternalNode (org.eclipse.zest.layouts.dataStructures.InternalNode)5 ArrayList (java.util.ArrayList)1 BasicEntityConstraint (org.eclipse.zest.layouts.constraints.BasicEntityConstraint)1 BendPoint (org.eclipse.zest.layouts.dataStructures.BendPoint)1 InternalRelationship (org.eclipse.zest.layouts.dataStructures.InternalRelationship)1