public void setLocation(int x, int y) { m_x = x; m_y = y; m_node.setLocation(x, y); setLocated(true); }
protected void applyLayoutInternal( InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double boundsX, double boundsY, double boundsWidth, double boundsHeight) { List<InternalNode> entitiesList = asList(entitiesToLayout); List<InternalRelationship> relationshipsList = asList(relationshipsToConsider); // --- build the node matrix without laying out first ---// List<List<GXMoreThanNode>> rows = buildNodeMatrix(entitiesList, relationshipsList); // --- layout the nodes --- // // we're going to put them together bottom - up. Collections.reverse(rows); double[] maxHeights = new double[rows.size()]; // the vertical size of a node line // double maxHeight = -1; double maxWidth = -1; for (int i = 0; i < maxHeights.length; ++i) { double temp = -1; for (GXMoreThanNode item : rows.get(i)) { if ((temp = item.m_node.getHeightInLayout()) > maxHeights[i]) maxHeights[i] = temp; } } double temp = -1; for (InternalNode list : entitiesToLayout) { // if((temp=list.getLayoutEntity().getHeightInLayout()) > maxHeight){ // maxHeight = temp; // } if ((temp = list.getLayoutEntity().getWidthInLayout()) > maxWidth) { maxWidth = temp; } } // int verticalLineSize =(int) (maxHeights[] + // verSpacing);//(int)(entitiesToLayout[0].getLayoutEntity().getHeightInLayout() + verSpacing); // the vertical location we begin placing the nodes from int sum = 0; for (int i = 0; i < maxHeights.length; ++i) sum += (int) (maxHeights[i] + verSpacing); int heightSoFar = sum; // (int) (((rows.size()-1) * verticalLineSize) + verSpacing); // place bottom most row first - just center it. List<GXMoreThanNode> childRow = rows.get(0); int nodeSpacing = (int) (horSpacing + maxWidth); // (int) (horSpacing + // childRow.get(0).getNode().getLayoutEntity().getWidthInLayout()); int x = (int) ((boundsWidth / 2) - ((childRow.size() / 2) * nodeSpacing)); placeStrand(childRow, x, heightSoFar, nodeSpacing); // place parent rows List<GXMoreThanNode> parentRow; // run through all parent rows for (int i = 1; i < rows.size(); i++) { // initialize stuff we'll need parentRow = rows.get(i); heightSoFar -= (int) (maxHeights[i] + verSpacing); // verticalLineSize; placeRow(parentRow, heightSoFar); } }