use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint in project archi by archimatetool.
the class RadialLayoutAlgorithm method determineCenterPoint.
/**
* Find the center point between the roots
*/
private DisplayIndependentPoint determineCenterPoint(List roots) {
double totalX = 0, totalY = 0;
for (Iterator iterator = roots.iterator(); iterator.hasNext(); ) {
InternalNode entity = (InternalNode) iterator.next();
totalX += entity.getInternalX();
totalY += entity.getInternalY();
}
return new DisplayIndependentPoint(totalX / roots.size(), totalY / roots.size());
}
use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint 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);
}
use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint in project archi by archimatetool.
the class AbstractLayoutAlgorithm method convertPositionsToCoords.
/**
* Convert the positions from a percentage of bounds area to fixed
* coordinates. NOTE: ALL OF THE POSITIONS OF NODES UNTIL NOW WERE FOR THE
* CENTER OF THE NODE - Convert it to the left top corner.
*
* @param entitiesToLayout
* @param relationships
* @param realBounds
*/
private void convertPositionsToCoords(InternalNode[] entitiesToLayout, InternalRelationship[] relationships, DisplayIndependentRectangle screenBounds) {
// Adjust node positions and sizes
for (int i = 0; i < entitiesToLayout.length; i++) {
InternalNode node = entitiesToLayout[i];
double width = node.getInternalWidth() * screenBounds.width;
double height = node.getInternalHeight() * screenBounds.height;
DisplayIndependentPoint location = node.getInternalLocation().convertFromPercent(screenBounds);
node.setInternalLocation(location.x - width / 2, location.y - height / 2);
if (resizeEntitiesAfterLayout) {
adjustNodeSizeAndPos(node, height, width);
} else {
node.setInternalSize(width, height);
}
}
// Adjust bendpoint positions and shift based on source node size
for (int i = 0; i < relationships.length; i++) {
InternalRelationship rel = relationships[i];
for (int j = 0; j < rel.getBendPoints().size(); j++) {
BendPoint bp = (BendPoint) rel.getBendPoints().get(j);
DisplayIndependentPoint fromPercent = bp.convertFromPercent(screenBounds);
bp.setX(fromPercent.x);
bp.setY(fromPercent.y);
}
}
}
use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint in project archi by archimatetool.
the class AbstractLayoutAlgorithm method convertPositionsToPercentage.
/**
* Convert all node positions into a percentage of the screen. If includeNodeSize
* is true then this also updates the node's internal size.
* @param entitiesToLayout
*/
private void convertPositionsToPercentage(InternalNode[] entitiesToLayout, InternalRelationship[] relationships, DisplayIndependentRectangle layoutBounds, boolean includeNodeSize) {
// Adjust node positions and sizes
for (int i = 0; i < entitiesToLayout.length; i++) {
InternalNode node = entitiesToLayout[i];
DisplayIndependentPoint location = node.getInternalLocation().convertToPercent(layoutBounds);
node.setInternalLocation(location.x, location.y);
if (includeNodeSize) {
// adjust node sizes
double width = node.getInternalWidth() / layoutBounds.width;
double height = node.getInternalHeight() / layoutBounds.height;
node.setInternalSize(width, height);
}
}
// Adjust bendpoint positions
for (int i = 0; i < relationships.length; i++) {
InternalRelationship rel = relationships[i];
for (int j = 0; j < rel.getBendPoints().size(); j++) {
BendPoint bp = (BendPoint) rel.getBendPoints().get(j);
DisplayIndependentPoint toPercent = bp.convertToPercent(layoutBounds);
bp.setX(toPercent.x);
bp.setY(toPercent.y);
}
}
}
use of org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint 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);
}
Aggregations