Search in sources :

Example 6 with DisplayIndependentRectangle

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

the class DynamicScreen method getScreenLocation.

public DisplayIndependentPoint getScreenLocation(InternalNode node) {
    DisplayIndependentRectangle layoutBounds = calculateBounds();
    double x = (layoutBounds.width == 0) ? 0 : (node.getInternalX() - layoutBounds.x) / layoutBounds.width;
    double y = (layoutBounds.height == 0) ? 0 : (node.getInternalY() - layoutBounds.y) / layoutBounds.height;
    x = screenBounds.x + x * screenBounds.width;
    y = screenBounds.y + y * screenBounds.height;
    return new DisplayIndependentPoint(x, y);
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle) DisplayIndependentPoint(org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint)

Example 7 with DisplayIndependentRectangle

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

the class DynamicScreen method calculateBounds.

private DisplayIndependentRectangle calculateBounds() {
    InternalNode n1 = (InternalNode) XCoords.first();
    InternalNode n2 = (InternalNode) XCoords.last();
    InternalNode n3 = (InternalNode) YCoords.first();
    InternalNode n4 = (InternalNode) YCoords.last();
    double x = n1.getInternalX();
    double width = n2.getInternalX();
    double y = n3.getInternalY();
    double height = n4.getInternalY();
    return new DisplayIndependentRectangle(x, y, width - x, height - y);
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle) InternalNode(org.eclipse.zest.layouts.dataStructures.InternalNode)

Example 8 with DisplayIndependentRectangle

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

the class AbstractLayoutAlgorithm method getLocalLocation.

/**
 * Gets the location in the layout bounds for this node
 * @param x
 * @param y
 * @return
 */
protected DisplayIndependentPoint getLocalLocation(InternalNode[] entitiesToLayout, double x, double y, DisplayIndependentRectangle realBounds) {
    double screenWidth = realBounds.width;
    double screenHeight = realBounds.height;
    DisplayIndependentRectangle layoutBounds = getLayoutBounds(entitiesToLayout, false);
    double localX = (x / screenWidth) * layoutBounds.width + layoutBounds.x;
    double localY = (y / screenHeight) * layoutBounds.height + layoutBounds.y;
    return new DisplayIndependentPoint(localX, localY);
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle) DisplayIndependentPoint(org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint)

Example 9 with DisplayIndependentRectangle

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

the class AbstractLayoutAlgorithm method defaultFitWithinBounds.

/**
 * Find an appropriate size for the given nodes, then fit them into the given bounds.
 * The relative locations of the nodes to each other must be preserved.
 * Child classes should set flag reresizeEntitiesAfterLayout to false if they
 * want to preserve node sizes.
 */
protected void defaultFitWithinBounds(InternalNode[] entitiesToLayout, InternalRelationship[] relationships, DisplayIndependentRectangle realBounds) {
    DisplayIndependentRectangle layoutBounds;
    if (resizeEntitiesAfterLayout) {
        layoutBounds = getLayoutBounds(entitiesToLayout, false);
        // Convert node x,y to be in percent rather than absolute coords
        convertPositionsToPercentage(entitiesToLayout, relationships, layoutBounds, false);
        // Resize and shift nodes
        resizeAndShiftNodes(entitiesToLayout);
    }
    // Recalculate layout, allowing for the node width, which we now know
    layoutBounds = getLayoutBounds(entitiesToLayout, true);
    // adjust node positions again, to the new coordinate system (still as a percentage)
    convertPositionsToPercentage(entitiesToLayout, relationships, layoutBounds, true);
    DisplayIndependentRectangle screenBounds = calcScreenBounds(realBounds, layoutBounds);
    // Now convert to real screen coordinates
    convertPositionsToCoords(entitiesToLayout, relationships, screenBounds);
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle)

Example 10 with DisplayIndependentRectangle

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

the class TreeLayoutAlgorithm method preLayoutAlgorithm.

/**
 * Executes this TreeLayoutAlgorithm layout algorithm by referencing the
 * data stored in the repository system. Once done, the result
 * will be saved to the data repository.
 *
 * @param entitiesToLayout Apply the algorithm to these entities
 * @param relationshipsToConsider Only consider these relationships when applying the algorithm.
 * @param boundsX The left side of the bounds in which the layout can place the entities.
 * @param boundsY The top side of the bounds in which the layout can place the entities.
 * @param boundsWidth The width of the bounds in which the layout can place the entities.
 * @param boundsHeight The height of the bounds in which the layout can place the entities.
 * @throws RuntimeException Thrown if entitiesToLayout doesn't contain all of the endpoints for each relationship in relationshipsToConsider
 */
@Override
protected void preLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double x, double y, double width, double height) {
    // Filter unwanted entities and relationships
    // super.applyLayout (entitiesToLayout, relationshipsToConsider, boundsX, boundsY, boundsWidth, boundsHeight);
    parentLists = new List[entitiesToLayout.length];
    childrenLists = new List[entitiesToLayout.length];
    weights = new double[entitiesToLayout.length];
    markedArr = new boolean[entitiesToLayout.length];
    for (int i = 0; i < entitiesToLayout.length; i++) {
        parentLists[i] = new ArrayList();
        childrenLists[i] = new ArrayList();
        weights[i] = DEFAULT_WEIGHT;
        markedArr[i] = DEFAULT_MARKED;
    }
    this.boundsHeight = height;
    this.boundsWidth = width;
    this.boundsX = x;
    this.boundsY = y;
    layoutBounds = new DisplayIndependentRectangle(boundsX, boundsY, boundsWidth, boundsHeight);
}
Also used : DisplayIndependentRectangle(org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle) ArrayList(java.util.ArrayList)

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