/[classpath]/classpath/javax/swing/plaf/basic/BasicTreeUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicTreeUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.91 by langel, Wed Oct 12 17:17:59 2005 UTC revision 1.92 by langel, Thu Oct 13 14:17:48 2005 UTC
# Line 650  public class BasicTreeUI Line 650  public class BasicTreeUI
650     */     */
651    public TreePath getPathForRow(JTree tree, int row)    public TreePath getPathForRow(JTree tree, int row)
652    {    {
653      if (treeModel != null)      if (treeModel != null && currentVisiblePath != null)
654        {        {
655          Object[] nodes = currentVisiblePath.getPath();          Object[] nodes = currentVisiblePath.getPath();
656          if (row < nodes.length)          if (row < nodes.length)
# Line 676  public class BasicTreeUI Line 676  public class BasicTreeUI
676      int row = 0;      int row = 0;
677      Object dest = path.getLastPathComponent();      Object dest = path.getLastPathComponent();
678      int rowCount = getRowCount(tree);      int rowCount = getRowCount(tree);
679      Object[] nodes = currentVisiblePath.getPath();      if (currentVisiblePath != null)
     while (row < rowCount)  
680        {        {
681          if (dest.equals(nodes[row]))          Object[] nodes = currentVisiblePath.getPath();
682            return row;          while (row < rowCount)
683          row++;                      {
684                if (dest.equals(nodes[row]))
685                  return row;
686                row++;          
687              }
688        }        }
         
689      return -1;      return -1;
690    }    }
691    
# Line 696  public class BasicTreeUI Line 698  public class BasicTreeUI
698     */     */
699    public int getRowCount(JTree tree)    public int getRowCount(JTree tree)
700    {    {
701      return currentVisiblePath.getPathCount();      if (currentVisiblePath != null)
702          return currentVisiblePath.getPathCount();
703        return 0;
704    }    }
705    
706    /**    /**
# Line 1471  public class BasicTreeUI Line 1475  public class BasicTreeUI
1475    {    {
1476      // FIXME: checkConsistancy not implemented, c not used      // FIXME: checkConsistancy not implemented, c not used
1477      int maxWidth = 0;      int maxWidth = 0;
1478      Object[] path = currentVisiblePath.getPath();      if (currentVisiblePath != null)
1479      for (int i = 0; i < path.length; i++)        {
1480        maxWidth = Math.max(maxWidth,          Object[] path = currentVisiblePath.getPath();
1481                            (int) (getCellBounds(0, 0, path[i]).getWidth()));          for (int i = 0; i < path.length; i++)
1482      return new Dimension(maxWidth, (getRowHeight() * path.length));            {
1483                TreePath curr = new TreePath(getPathToRoot(path[i], 0));
1484                Rectangle bounds = getPathBounds(tree,
1485                            curr);
1486                maxWidth = Math.max(maxWidth, bounds.x + bounds.width
1487                                    + getCurrentControlIcon(curr).getIconWidth());
1488              }
1489            return new Dimension(maxWidth, (getRowHeight() * path.length));
1490          }
1491        return new Dimension(0, 0);
1492    }    }
1493    
1494    /**    /**
# Line 2969  public class BasicTreeUI Line 2982  public class BasicTreeUI
2982          String s = cell.toString();          String s = cell.toString();
2983          Font f = tree.getFont();          Font f = tree.getFont();
2984          FontMetrics fm = tree.getToolkit().getFontMetrics(f);          FontMetrics fm = tree.getToolkit().getFontMetrics(f);
2985            
2986          if (s != null)          if (s != null)
2987            return new Rectangle(x, y,            return new Rectangle(x, y,
2988                                 SwingUtilities.computeStringWidth(fm, s) + 4,                                 SwingUtilities.computeStringWidth(fm, s) + 4,
# Line 3056  public class BasicTreeUI Line 3069  public class BasicTreeUI
3069            
3070      if (isLeaf)      if (isLeaf)
3071        {        {
3072            bounds.width += bounds.x;
3073          paintRow(g, clip, null, bounds, path, row, true, false, true);          paintRow(g, clip, null, bounds, path, row, true, false, true);
3074          descent += getRowHeight();          descent += getRowHeight();
3075        }        }
3076      else      else
3077        {                {
3078            bounds.width += bounds.x + getCurrentControlIcon(path).getIconWidth();
3079          if (depth > 0 || isRootVisible)          if (depth > 0 || isRootVisible)
3080            {            {
3081              paintRow(g, clip, null, bounds, path, row, isExpanded, false, false);              paintRow(g, clip, null, bounds, path, row, isExpanded, false, false);
# Line 3253  public class BasicTreeUI Line 3268  public class BasicTreeUI
3268     */     */
3269    Object getPreviousVisibleNode(Object node)    Object getPreviousVisibleNode(Object node)
3270    {    {
3271      Object[] nodes = currentVisiblePath.getPath();      if (currentVisiblePath != null)
3272      int i = 0;        {
3273      while (i < nodes.length && !node.equals(nodes[i]))          Object[] nodes = currentVisiblePath.getPath();
3274        i++;          int i = 0;
3275      // return the next node          while (i < nodes.length && !node.equals(nodes[i]))
3276      if (i-1 > 0)            i++;
3277        return nodes[i-1];          // return the next node
3278            if (i-1 > 0)
3279              return nodes[i-1];
3280          }
3281      return null;      return null;
3282    }    }
3283    
# Line 3722  public class BasicTreeUI Line 3740  public class BasicTreeUI
3740     */     */
3741    Object getNextVisibleNode(Object node)    Object getNextVisibleNode(Object node)
3742    {    {
3743      Object[] nodes = currentVisiblePath.getPath();      if (currentVisiblePath != null)
3744      int i = 0;        {
3745      while (i < nodes.length && !node.equals(nodes[i]))          Object[] nodes = currentVisiblePath.getPath();
3746        i++;          int i = 0;
3747      // return the next node          while (i < nodes.length && !node.equals(nodes[i]))
3748      if (i+1 < nodes.length)            i++;
3749        return nodes[i+1];          // return the next node
3750            if (i+1 < nodes.length)
3751              return nodes[i+1];
3752          }
3753      return null;      return null;
3754    }    }
3755  } // BasicTreeUI  } // BasicTreeUI

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.92

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26