Package org.phylowidget.ui

Examples of org.phylowidget.ui.PhyloNode


  void setStateRecursive(RootedTree tree, PhyloNode base, int state)
  {
    BreadthFirstIterator bfi = new BreadthFirstIterator(tree, base);
    while (bfi.hasNext())
    {
      PhyloNode n = (PhyloNode) bfi.next();
      n.setState(state);
    }
  }
View Full Code Here


      // Y coordinate should be the average of its children's heights
      List children = tree.getChildrenOf(n);
      float sum = 0;
      for (int i = 0; i < children.size(); i++)
      {
        PhyloNode child = (PhyloNode) children.get(i);
        sum += branchPositions(child);
      }
      float yPos = (float) sum / (float) children.size();
      float xPos = 0;
      xPos = nodeXPosition(n);
View Full Code Here

     * "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))
      {
View Full Code Here

  {
    ArrayList ffMe = new ArrayList();
    tree.getAll(tree.getRoot(), null, ffMe);
    for (int i = 0; i < ffMe.size(); i++)
    {
      PhyloNode n = (PhyloNode) ffMe.get(i);
      n.fforward();
    }
  }
View Full Code Here

      drawNodeMarker(n);
      drawLine((PhyloNode) n.getParent(), n);
      List l = tree.getChildrenOf(n);
      for (int i = 0; i < l.size(); i++)
      {
        PhyloNode child = (PhyloNode) l.get(i);
        NodeRange r = nodesToRanges.get(child);
        /*
         * If this child is thresholded out, then draw a placemark line to its
         * earliest or latest leaf node.
         */
        if (!child.drawMe && child.isWithinScreen)
        {
          PhyloNode leaf = null;
          if (i == 0)
            leaf = (PhyloNode) tree.getFirstLeaf(child);
          else if (i == l.size() - 1)
            leaf = (PhyloNode) tree.getLastLeaf(child);
          else
            /*
             * If this child is a "middle child", just do nothing.
             */
            continue;
          drawLine(n, leaf);
          // drawLabel(leaf);
        }
      }
      /*
       * Now, we want to draw this inner node's label if it's significant
       * and we are set to show clade labels.
       */
      if (UniqueLabeler.isLabelSignificant(n.getLabel())
          && PhyloWidget.ui.showCladeLabels)
      {
        drawLabel(n);
      }
    }
    /*
     * If we've got a PhyloTree on our hands,
     * let's take care of the hovered node.
     */
    if (tree instanceof PhyloTree)
    {
      PhyloTree pt = (PhyloTree) tree;
      PhyloNode h = pt.hoveredNode;
      if (h != null && h.getParent() != null)
      {
        canvas.stroke(style.hoverColor.getRGB());
        float weight = baseStroke * style.hoverStroke;
        weight *= PhyloWidget.ui.traverser.glowTween.getPosition();
        canvas.strokeWeight(weight);
        canvas.fill(style.hoverColor.getRGB());
        drawLineImpl((PhyloNode) h.getParent(), h);
        canvas.noStroke();
        canvas.fill(style.hoverColor.getRGB());
        drawNodeMarkerImpl(h);
      }
    }
View Full Code Here

    canvas.noSmooth();
  }

  boolean isAnyParentDrawn(PhyloNode n)
  {
    PhyloNode cur = (PhyloNode) n.getParent();
    while (cur != null)
    {
      if (cur.drawMe)
        return true;
      cur = (PhyloNode) cur.getParent();
    }
    return false;
  }
View Full Code Here

    rect1.setFrameFromDiagonal(r.loX, r.loY, r.hiX, r.hiY);

    /*
     * Try to get the parental noderange and set it.
     */
    PhyloNode p = (PhyloNode) tree.getParentOf(n);
    NodeRange r2 = nodesToRanges.get(p);
    if (p == null || r2 == null)
    {
      /*
       * If we're the root node, just do our intersection.
View Full Code Here

    {
      list.clear();
      nodesToRanges.clear();
      for (int i = 0; i < nodes.size(); i++)
      {
        PhyloNode n = (PhyloNode) nodes.get(i);
        NodeRange r = new NodeRange();
        r.node = n;
        r.render = this;
        nodesToRanges.put(n, r);
        list.insert(r, false);
      }
      list.sortFull();
    }

    /*
     * ASSUMPTION: the leaves ArrayList contains a "sorted" view of the
     * tree's leaves, i.e. in the correct ordering from top to bottom.
     */
    biggestStringWidth = 0;
    biggestString = "";
    if (UIUtils.isJava2D(canvas))
      fm = UIUtils.getMetrics(canvas, font.font, 100);
    /*
     * Set the leaf positions.
     */
    for (int i = 0; i < leaves.size(); i++)
    {
      PhyloNode n = (PhyloNode) leaves.get(i);
      /*
       * Set the leaf position of this node.
       */
      leafPosition(n, i);
    }

    for (int i = 0; i < nodes.size(); i++)
    {
      PhyloNode n = (PhyloNode) nodes.get(i);
      /**
       * Find the width of this node's label.
       */
      float width = 0;// spaceWidth;
      if (UIUtils.isJava2D(canvas))
      {
        // width = fm.stringWidth(n.getName());
        Graphics2D g2 = ((PGraphicsJava2D) canvas).g2;
        width = (float) fm.getStringBounds(n.getLabel(), g2).getWidth() / 100f;
      } else
      {
        char[] chars = n.getLabel().toCharArray();

        for (int j = 0; j < chars.length; j++)
        {
          width += font.width(chars[j]);
        }
      }
      n.unitTextWidth = width;
      if (width > biggestStringWidth)
      {
        biggestStringWidth = width;
        biggestString = n.getLabel();
      }
    }
    /*
     * Special case: if biggestString is 0 length, we'll fudge it.
     */
 
View Full Code Here

      // theta should be the average of its children's thetas.
      List children = tree.getChildrenOf(n);
      float sum = 0;
      for (int i = 0; i < children.size(); i++)
      {
        PhyloNode child = (PhyloNode) children.get(i);
        sum += branchPositions(child);
      }
      float theta = (float) sum / (float) children.size();
      float r = 0;
      r = nodeXPosition(n);
View Full Code Here

      {
//        list.clear();
//        nodesToRanges.clear();
        for (int i = 0; i < nodes.size(); i++)
        {
          PhyloNode n = (PhyloNode) nodes.get(i);
          NodeRange r = new NodeRange();
          r.node = n;
          r.render = this;
          float oldTheta = getTheta(n);
          setTheta(n,1);
View Full Code Here

TOP

Related Classes of org.phylowidget.ui.PhyloNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.