Search in sources :

Example 6 with DisplayIndependentPoint

use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint 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 7 with DisplayIndependentPoint

use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint 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

DisplayIndependentPoint (org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint)7 DisplayIndependentRectangle (org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle)4 InternalNode (org.eclipse.zest.layouts.dataStructures.InternalNode)3 BasicEntityConstraint (org.eclipse.zest.layouts.constraints.BasicEntityConstraint)2 BendPoint (org.eclipse.zest.layouts.dataStructures.BendPoint)2 InternalRelationship (org.eclipse.zest.layouts.dataStructures.InternalRelationship)2 Iterator (java.util.Iterator)1