Search in sources :

Example 11 with DisplayIndependentRectangle

use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle in project archi by archimatetool.

the class ContinuousLayoutAlgorithm method applyLayoutInternal.

/**
 * Calculates and applies the positions of the given entities based on a
 * spring layout using the given relationships.
 */
@Override
protected void applyLayoutInternal(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double x, double y, double width, double height) {
    this.setBounds(x, y, width, height);
    while (continueRunning()) {
        // check for entities and relationships to add or remove
        entitiesToLayout = updateEntities(entitiesToLayout);
        relationshipsToConsider = updateRelationships(relationshipsToConsider);
        DisplayIndependentRectangle bounds = this.getBounds();
        double localX = bounds.x;
        double localY = bounds.y;
        double localWidth = bounds.width;
        double localHeight = bounds.height;
        computeOneIteration(entitiesToLayout, relationshipsToConsider, localX, localY, localWidth, localHeight);
        updateLayoutLocations(entitiesToLayout);
        if (this.internalContinuous) {
            fireProgressEvent(1, 1);
        } else {
            fireProgressEvent(getCurrentLayoutStep(), getTotalNumberOfLayoutSteps());
        }
    }
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle)

Example 12 with DisplayIndependentRectangle

use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle in project archi by archimatetool.

the class RadialLayoutAlgorithm method getLayoutBounds.

/**
 * Find the bounds in which the nodes are located.  Using the bounds against the real bounds
 * of the screen, the nodes can proportionally be placed within the real bounds.
 * The bounds can be determined either including the size of the nodes or not.  If the size
 * is not included, the bounds will only be guaranteed to include the center of each node.
 */
@Override
protected DisplayIndependentRectangle getLayoutBounds(InternalNode[] entitiesToLayout, boolean includeNodeSize) {
    DisplayIndependentRectangle layoutBounds = super.getLayoutBounds(entitiesToLayout, includeNodeSize);
    DisplayIndependentPoint centerPoint = (roots != null) ? determineCenterPoint(roots) : new DisplayIndependentPoint(layoutBounds.x + layoutBounds.width / 2, layoutBounds.y + layoutBounds.height / 2);
    // The center entity is determined in applyLayout
    double maxDistanceX = Math.max(Math.abs(layoutBounds.x + layoutBounds.width - centerPoint.x), Math.abs(centerPoint.x - layoutBounds.x));
    double maxDistanceY = Math.max(Math.abs(layoutBounds.y + layoutBounds.height - centerPoint.y), Math.abs(centerPoint.y - layoutBounds.y));
    layoutBounds = new DisplayIndependentRectangle(centerPoint.x - maxDistanceX, centerPoint.y - maxDistanceY, maxDistanceX * 2, maxDistanceY * 2);
    return layoutBounds;
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle) DisplayIndependentPoint(org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint)

Example 13 with DisplayIndependentRectangle

use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle in project archi by archimatetool.

the class AbstractLayoutAlgorithm method getLayoutBounds.

/**
 * Find the bounds in which the nodes are located.  Using the bounds against the real bounds
 * of the screen, the nodes can proportionally be placed within the real bounds.
 * The bounds can be determined either including the size of the nodes or not.  If the size
 * is not included, the bounds will only be guaranteed to include the center of each node.
 */
protected DisplayIndependentRectangle getLayoutBounds(InternalNode[] entitiesToLayout, boolean includeNodeSize) {
    double rightSide = Double.MIN_VALUE;
    double bottomSide = Double.MIN_VALUE;
    double leftSide = Double.MAX_VALUE;
    double topSide = Double.MAX_VALUE;
    for (int i = 0; i < entitiesToLayout.length; i++) {
        InternalNode entity = entitiesToLayout[i];
        if (entity.hasPreferredLocation()) {
            continue;
        }
        if (includeNodeSize) {
            leftSide = Math.min(entity.getInternalX() - entity.getInternalWidth() / 2, leftSide);
            topSide = Math.min(entity.getInternalY() - entity.getInternalHeight() / 2, topSide);
            rightSide = Math.max(entity.getInternalX() + entity.getInternalWidth() / 2, rightSide);
            bottomSide = Math.max(entity.getInternalY() + entity.getInternalHeight() / 2, bottomSide);
        } else {
            leftSide = Math.min(entity.getInternalX(), leftSide);
            topSide = Math.min(entity.getInternalY(), topSide);
            rightSide = Math.max(entity.getInternalX(), rightSide);
            bottomSide = Math.max(entity.getInternalY(), bottomSide);
        }
    }
    return new DisplayIndependentRectangle(leftSide, topSide, rightSide - leftSide, bottomSide - topSide);
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle) InternalNode(org.eclipse.zest.layouts.dataStructures.InternalNode) BasicEntityConstraint(org.eclipse.zest.layouts.constraints.BasicEntityConstraint) BendPoint(org.eclipse.zest.layouts.dataStructures.BendPoint) DisplayIndependentPoint(org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint)

Example 14 with DisplayIndependentRectangle

use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle in project archi by archimatetool.

the class DynamicScreen method getVirtualLocation.

public DisplayIndependentPoint getVirtualLocation(DisplayIndependentPoint point) {
    DisplayIndependentRectangle layoutBounds = calculateBounds();
    double x = (point.x / screenBounds.width) * layoutBounds.width + layoutBounds.x;
    double y = (point.y / screenBounds.height) * layoutBounds.height + layoutBounds.y;
    return new DisplayIndependentPoint(x, y);
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle) DisplayIndependentPoint(org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint)

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