* "threshold" status.
* Also set each node's drawMe flag to FALSE.
*/
for (int i = 0; i < nodes.size(); i++)
{
PhyloNode n = nodes.get(i);
if (fforwardMe)
n.fforward();
updateNode(n);
n.drawMe = false;
n.labelWasDrawn = false;
n.isWithinScreen = isNodeWithinScreen(n);
// n.isWithinScreen = true;
n.zoomTextSize = 1;
}
fforwardMe = false;
list.sortFull();
/*
* SECOND LOOP: Flagging drawn nodes
* -- Now, we go through all nodes
* (remember this is a list sorted by significance, i.e. enclosed number
* of leaves). At each node, we decide whether or not to draw it based
* on whether it is within the screen area. We exit the loop once the
* threshold number of nodes has been drawn.
*/
int nodesDrawn = 0;
ArrayList<PhyloNode> nodesToDraw = new ArrayList<PhyloNode>(nodes.size());
for (int i = 0; i < nodes.size(); i++)
{
PhyloNode n = nodes.get(i);
// n.isWithinScreen = isNodeWithinScreen(n);
if (nodesDrawn >= PhyloWidget.ui.renderThreshold)
break;
if (!n.isWithinScreen)
continue;
/*
* Ok, let's flag this thing to be drawn.
*/
n.drawMe = true;
nodesDrawn++;
nodesToDraw.add(n);
}
/*
* THIRD LOOP: Drawing nodes
* - This loop actually does the drawing.
*/
for (int i = 0; i < nodesToDraw.size(); i++)
{
PhyloNode n = nodesToDraw.get(i);
if (!n.drawMe)
{
if (n.isWithinScreen)
{
if (isAnyParentDrawn(n))
continue;
} else
continue;
}
/*
* Ok, we've skipped all the non-drawn nodes,
* let's do the actual drawing.
*/
handleNode(n);
}
/*
* FOURTH LOOP: Drawing labels
* - This loop uses the crazy overlap logic.
*
*
*/
// System.out.println("Nodes:");
overlap.clear();
/*
* If we have a hovered node, always draw it.
*/
if (tree instanceof PhyloTree)
{
PhyloTree pt = (PhyloTree) tree;
PhyloNode h = pt.hoveredNode;
if (h != null)
{
Point point = new Point(getX(h), getY(h));
float dist = (float) point.distance(mousePt);
float bulgedSize = BulgeUtil.bulge(dist, .7f, 30);
if (textSize <= 12)
h.zoomTextSize = bulgedSize;
else
h.zoomTextSize = 1f;
updateNode(h);
drawLabel(h);
h.labelWasDrawn = true;
NodeRange r = nodesToRanges.get(h);
if (r != null)
overlap.insert(r.loY, r.hiY);
}
}
int asdf = 0;
for (int i = 0; i < sigLeaves.size(); i++)
{
PhyloNode n = sigLeaves.get(i);
if (!n.isWithinScreen)
continue;
NodeRange r = nodesToRanges.get(n);
if (!overlap.overlaps(r.loY, r.hiY))
{