use of org.eclipse.zest.layouts.dataStructures.InternalNode in project linuxtools by eclipse.
the class AggregateLayoutAlgorithm method postLayoutAlgorithm.
/**
* Called at the end of the layout algorithm -- change the size and colour
* of each node according to times called/total time
*/
@Override
protected void postLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider) {
final int minimumSize = 40;
double xcursor = 0.0;
double ycursor = 0.0;
for (InternalNode sn : entitiesToLayout) {
Long time = list.remove(0);
double percent = (double) time / (double) totalTime;
double snWidth = (sn.getInternalWidth() * percent) + minimumSize;
double snHeight = (sn.getInternalHeight() * percent) + minimumSize;
sn.setSize(snWidth, snHeight);
if (xcursor + snWidth > graphWidth) {
// reaching the end of row, move to lower column
ycursor += snHeight;
xcursor = 0;
sn.setLocation(xcursor, ycursor);
} else {
sn.setLocation(xcursor, ycursor);
xcursor += snWidth;
}
}
}
use of org.eclipse.zest.layouts.dataStructures.InternalNode 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++;
}
use of org.eclipse.zest.layouts.dataStructures.InternalNode in project archi by archimatetool.
the class TreeLayoutAlgorithm method buildForestRecursively.
/**
* Builds the forest recursively. All entities
* will be placed somewhere in the forest.
*/
private void buildForestRecursively(List roots, List unplacedEntities, InternalNode[] entities, InternalRelationship[] relationships) {
if (unplacedEntities.size() == 0) {
// no more entities to place
return;
}
// get the first entity in the list of unplaced entities, find its root, and build this root's tree
InternalNode layoutEntity = (InternalNode) unplacedEntities.get(0);
InternalNode rootEntity = findRootObjectRecursive(layoutEntity, new HashSet(), relationships);
int rootEntityIndex = indexOfInternalNode(entities, rootEntity);
buildTreeRecursively(rootEntity, rootEntityIndex, 0, entities, relationships);
roots.add(rootEntity);
// now see which nodes are left to be placed in a tree somewhere
List unmarkedCopy = new ArrayList(unplacedEntities);
for (Iterator iter = unmarkedCopy.iterator(); iter.hasNext(); ) {
InternalNode tmpEntity = (InternalNode) iter.next();
int tmpEntityIndex = indexOfInternalNode(entities, tmpEntity);
boolean isMarked = markedArr[tmpEntityIndex];
if (isMarked) {
unplacedEntities.remove(tmpEntity);
}
}
buildForestRecursively(roots, unplacedEntities, entities, relationships);
}
use of org.eclipse.zest.layouts.dataStructures.InternalNode in project archi by archimatetool.
the class TreeLayoutAlgorithm method getNumberOfLeavesRecursive.
private int getNumberOfLeavesRecursive(InternalNode layoutEntity, int i, Set seen, InternalNode[] entities) {
int numLeaves = 0;
List children = childrenLists[i];
if (children.size() == 0) {
numLeaves = 1;
} else {
// TODO: SLOW!
for (Iterator iter = children.iterator(); iter.hasNext(); ) {
InternalNode childEntity = (InternalNode) iter.next();
if (!seen.contains(childEntity)) {
seen.add(childEntity);
int childEntityIndex = indexOfInternalNode(entities, childEntity);
numLeaves += getNumberOfLeavesRecursive(childEntity, childEntityIndex, seen, entities);
} else {
numLeaves = 1;
}
}
}
return numLeaves;
}
use of org.eclipse.zest.layouts.dataStructures.InternalNode in project archi by archimatetool.
the class GridLayoutAlgorithm method applyLayoutInternal.
/**
* Use this algorithm to layout the given entities, using the given relationships and bounds.
* The entities will be placed in the same order as they are passed in, unless a comparator
* is supplied.
*
* @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 synchronized void applyLayoutInternal(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double boundsX, double boundsY, double boundsWidth, double boundsHeight) {
int index = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if ((i * cols + j) < numChildren) {
// find new position for child
double xmove = boundsX + j * colWidth + offsetX;
double ymove = boundsY + i * rowHeight + offsetY;
InternalNode sn = entitiesToLayout[index++];
sn.setInternalLocation(xmove, ymove);
sn.setInternalSize(Math.max(w, MIN_ENTITY_SIZE), Math.max(h, MIN_ENTITY_SIZE));
}
}
fireProgressEvent(2 + i, totalProgress);
}
updateLayoutLocations(entitiesToLayout);
fireProgressEvent(totalProgress, totalProgress);
}
Aggregations