home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / plaf / basic / BasicTreeUI.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  31.5 KB  |  1,638 lines

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Dimension;
  6. import java.awt.Graphics;
  7. import java.awt.Insets;
  8. import java.awt.Point;
  9. import java.awt.Rectangle;
  10. import java.awt.event.ComponentListener;
  11. import java.awt.event.FocusListener;
  12. import java.awt.event.InputEvent;
  13. import java.awt.event.KeyListener;
  14. import java.awt.event.MouseEvent;
  15. import java.awt.event.MouseListener;
  16. import java.beans.PropertyChangeListener;
  17. import java.util.Enumeration;
  18. import java.util.Hashtable;
  19. import javax.swing.ActionMap;
  20. import javax.swing.CellRendererPane;
  21. import javax.swing.Icon;
  22. import javax.swing.InputMap;
  23. import javax.swing.JComponent;
  24. import javax.swing.JTree;
  25. import javax.swing.SwingUtilities;
  26. import javax.swing.UIManager;
  27. import javax.swing.event.CellEditorListener;
  28. import javax.swing.event.TreeExpansionListener;
  29. import javax.swing.event.TreeModelListener;
  30. import javax.swing.event.TreeSelectionListener;
  31. import javax.swing.plaf.ActionMapUIResource;
  32. import javax.swing.plaf.ComponentUI;
  33. import javax.swing.plaf.TreeUI;
  34. import javax.swing.plaf.UIResource;
  35. import javax.swing.tree.AbstractLayoutCache;
  36. import javax.swing.tree.DefaultTreeCellEditor;
  37. import javax.swing.tree.DefaultTreeCellRenderer;
  38. import javax.swing.tree.FixedHeightLayoutCache;
  39. import javax.swing.tree.TreeCellEditor;
  40. import javax.swing.tree.TreeCellRenderer;
  41. import javax.swing.tree.TreeModel;
  42. import javax.swing.tree.TreePath;
  43. import javax.swing.tree.TreeSelectionModel;
  44. import javax.swing.tree.VariableHeightLayoutCache;
  45.  
  46. public class BasicTreeUI extends TreeUI {
  47.    private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
  48.    protected transient Icon collapsedIcon;
  49.    protected transient Icon expandedIcon;
  50.    private Color hashColor;
  51.    protected int leftChildIndent;
  52.    protected int rightChildIndent;
  53.    protected int totalChildIndent;
  54.    protected Dimension preferredMinSize;
  55.    protected int lastSelectedRow;
  56.    protected JTree tree;
  57.    protected transient TreeCellRenderer currentCellRenderer;
  58.    protected boolean createdRenderer;
  59.    protected transient TreeCellEditor cellEditor;
  60.    protected boolean createdCellEditor;
  61.    protected boolean stopEditingInCompleteEditing;
  62.    protected CellRendererPane rendererPane;
  63.    protected Dimension preferredSize;
  64.    protected boolean validCachedPreferredSize;
  65.    protected AbstractLayoutCache treeState;
  66.    protected Hashtable drawingCache;
  67.    protected boolean largeModel;
  68.    protected AbstractLayoutCache.NodeDimensions nodeDimensions;
  69.    protected TreeModel treeModel;
  70.    protected TreeSelectionModel treeSelectionModel;
  71.    protected int depthOffset;
  72.    private int lastWidth;
  73.    protected Component editingComponent;
  74.    protected TreePath editingPath;
  75.    protected int editingRow;
  76.    protected boolean editorHasDifferentSize;
  77.    private int leadRow;
  78.    private boolean ignoreLAChange;
  79.    private boolean leftToRight;
  80.    private PropertyChangeListener propertyChangeListener;
  81.    private PropertyChangeListener selectionModelPropertyChangeListener;
  82.    private MouseListener mouseListener;
  83.    private FocusListener focusListener;
  84.    private KeyListener keyListener;
  85.    private ComponentListener componentListener;
  86.    private CellEditorListener cellEditorListener;
  87.    private TreeSelectionListener treeSelectionListener;
  88.    private TreeModelListener treeModelListener;
  89.    private TreeExpansionListener treeExpansionListener;
  90.  
  91.    public static ComponentUI createUI(JComponent var0) {
  92.       return new BasicTreeUI();
  93.    }
  94.  
  95.    protected Color getHashColor() {
  96.       return this.hashColor;
  97.    }
  98.  
  99.    protected void setHashColor(Color var1) {
  100.       this.hashColor = var1;
  101.    }
  102.  
  103.    public void setLeftChildIndent(int var1) {
  104.       this.leftChildIndent = var1;
  105.       this.totalChildIndent = this.leftChildIndent + this.rightChildIndent;
  106.       if (this.treeState != null) {
  107.          this.treeState.invalidateSizes();
  108.       }
  109.  
  110.       this.updateSize();
  111.    }
  112.  
  113.    public int getLeftChildIndent() {
  114.       return this.leftChildIndent;
  115.    }
  116.  
  117.    public void setRightChildIndent(int var1) {
  118.       this.rightChildIndent = var1;
  119.       this.totalChildIndent = this.leftChildIndent + this.rightChildIndent;
  120.       if (this.treeState != null) {
  121.          this.treeState.invalidateSizes();
  122.       }
  123.  
  124.       this.updateSize();
  125.    }
  126.  
  127.    public int getRightChildIndent() {
  128.       return this.rightChildIndent;
  129.    }
  130.  
  131.    public void setExpandedIcon(Icon var1) {
  132.       this.expandedIcon = var1;
  133.    }
  134.  
  135.    public Icon getExpandedIcon() {
  136.       return this.expandedIcon;
  137.    }
  138.  
  139.    public void setCollapsedIcon(Icon var1) {
  140.       this.collapsedIcon = var1;
  141.    }
  142.  
  143.    public Icon getCollapsedIcon() {
  144.       return this.collapsedIcon;
  145.    }
  146.  
  147.    protected void setLargeModel(boolean var1) {
  148.       if (this.getRowHeight() < 1) {
  149.          var1 = false;
  150.       }
  151.  
  152.       if (this.largeModel != var1) {
  153.          this.completeEditing();
  154.          this.largeModel = var1;
  155.          this.treeState = this.createLayoutCache();
  156.          this.configureLayoutCache();
  157.          this.updateLayoutCacheExpandedNodes();
  158.          this.updateSize();
  159.       }
  160.  
  161.    }
  162.  
  163.    protected boolean isLargeModel() {
  164.       return this.largeModel;
  165.    }
  166.  
  167.    protected void setRowHeight(int var1) {
  168.       this.completeEditing();
  169.       if (this.treeState != null) {
  170.          this.setLargeModel(this.tree.isLargeModel());
  171.          this.treeState.setRowHeight(var1);
  172.          this.updateSize();
  173.       }
  174.  
  175.    }
  176.  
  177.    protected int getRowHeight() {
  178.       return this.tree == null ? -1 : this.tree.getRowHeight();
  179.    }
  180.  
  181.    protected void setCellRenderer(TreeCellRenderer var1) {
  182.       this.completeEditing();
  183.       this.updateRenderer();
  184.       if (this.treeState != null) {
  185.          this.treeState.invalidateSizes();
  186.          this.updateSize();
  187.       }
  188.  
  189.    }
  190.  
  191.    protected TreeCellRenderer getCellRenderer() {
  192.       return this.currentCellRenderer;
  193.    }
  194.  
  195.    protected void setModel(TreeModel var1) {
  196.       this.completeEditing();
  197.       if (this.treeModel != null && this.treeModelListener != null) {
  198.          this.treeModel.removeTreeModelListener(this.treeModelListener);
  199.       }
  200.  
  201.       this.treeModel = var1;
  202.       if (this.treeModel != null && this.treeModelListener != null) {
  203.          this.treeModel.addTreeModelListener(this.treeModelListener);
  204.       }
  205.  
  206.       if (this.treeState != null) {
  207.          this.treeState.setModel(var1);
  208.          this.updateLayoutCacheExpandedNodes();
  209.          this.updateSize();
  210.       }
  211.  
  212.    }
  213.  
  214.    protected TreeModel getModel() {
  215.       return this.treeModel;
  216.    }
  217.  
  218.    protected void setRootVisible(boolean var1) {
  219.       this.completeEditing();
  220.       this.updateDepthOffset();
  221.       if (this.treeState != null) {
  222.          this.treeState.setRootVisible(var1);
  223.          this.treeState.invalidateSizes();
  224.          this.updateSize();
  225.       }
  226.  
  227.    }
  228.  
  229.    protected boolean isRootVisible() {
  230.       return this.tree != null ? this.tree.isRootVisible() : false;
  231.    }
  232.  
  233.    protected void setShowsRootHandles(boolean var1) {
  234.       this.completeEditing();
  235.       this.updateDepthOffset();
  236.       if (this.treeState != null) {
  237.          this.treeState.invalidateSizes();
  238.          this.updateSize();
  239.       }
  240.  
  241.    }
  242.  
  243.    protected boolean getShowsRootHandles() {
  244.       return this.tree != null ? this.tree.getShowsRootHandles() : false;
  245.    }
  246.  
  247.    protected void setCellEditor(TreeCellEditor var1) {
  248.       this.updateCellEditor();
  249.    }
  250.  
  251.    protected TreeCellEditor getCellEditor() {
  252.       return this.tree != null ? this.tree.getCellEditor() : null;
  253.    }
  254.  
  255.    protected void setEditable(boolean var1) {
  256.       this.updateCellEditor();
  257.    }
  258.  
  259.    protected boolean isEditable() {
  260.       return this.tree != null ? this.tree.isEditable() : false;
  261.    }
  262.  
  263.    protected void setSelectionModel(TreeSelectionModel var1) {
  264.       this.completeEditing();
  265.       if (this.selectionModelPropertyChangeListener != null && this.treeSelectionModel != null) {
  266.          this.treeSelectionModel.removePropertyChangeListener(this.selectionModelPropertyChangeListener);
  267.       }
  268.  
  269.       if (this.treeSelectionListener != null && this.treeSelectionModel != null) {
  270.          this.treeSelectionModel.removeTreeSelectionListener(this.treeSelectionListener);
  271.       }
  272.  
  273.       this.treeSelectionModel = var1;
  274.       if (this.treeSelectionModel != null) {
  275.          if (this.selectionModelPropertyChangeListener != null) {
  276.             this.treeSelectionModel.addPropertyChangeListener(this.selectionModelPropertyChangeListener);
  277.          }
  278.  
  279.          if (this.treeSelectionListener != null) {
  280.             this.treeSelectionModel.addTreeSelectionListener(this.treeSelectionListener);
  281.          }
  282.  
  283.          if (this.treeState != null) {
  284.             this.treeState.setSelectionModel(this.treeSelectionModel);
  285.          }
  286.       } else if (this.treeState != null) {
  287.          this.treeState.setSelectionModel((TreeSelectionModel)null);
  288.       }
  289.  
  290.       if (this.tree != null) {
  291.          this.tree.repaint();
  292.       }
  293.  
  294.    }
  295.  
  296.    protected TreeSelectionModel getSelectionModel() {
  297.       return this.treeSelectionModel;
  298.    }
  299.  
  300.    public Rectangle getPathBounds(JTree var1, TreePath var2) {
  301.       if (var1 != null && this.treeState != null) {
  302.          Insets var3 = ((JComponent)var1).getInsets();
  303.          Rectangle var4 = this.treeState.getBounds(var2, (Rectangle)null);
  304.          if (var4 != null && var3 != null) {
  305.             var4.x += var3.left;
  306.             var4.y += var3.top;
  307.          }
  308.  
  309.          return var4;
  310.       } else {
  311.          return null;
  312.       }
  313.    }
  314.  
  315.    public TreePath getPathForRow(JTree var1, int var2) {
  316.       return this.treeState != null ? this.treeState.getPathForRow(var2) : null;
  317.    }
  318.  
  319.    public int getRowForPath(JTree var1, TreePath var2) {
  320.       return this.treeState != null ? this.treeState.getRowForPath(var2) : -1;
  321.    }
  322.  
  323.    public int getRowCount(JTree var1) {
  324.       return this.treeState != null ? this.treeState.getRowCount() : 0;
  325.    }
  326.  
  327.    public TreePath getClosestPathForLocation(JTree var1, int var2, int var3) {
  328.       if (var1 != null && this.treeState != null) {
  329.          Insets var4 = ((JComponent)var1).getInsets();
  330.          if (var4 == null) {
  331.             var4 = EMPTY_INSETS;
  332.          }
  333.  
  334.          return this.treeState.getPathClosestTo(var2 - var4.left, var3 - var4.top);
  335.       } else {
  336.          return null;
  337.       }
  338.    }
  339.  
  340.    public boolean isEditing(JTree var1) {
  341.       return this.editingComponent != null;
  342.    }
  343.  
  344.    public boolean stopEditing(JTree var1) {
  345.       if (this.editingComponent != null && this.cellEditor.stopCellEditing()) {
  346.          this.completeEditing(false, false, true);
  347.          return true;
  348.       } else {
  349.          return false;
  350.       }
  351.    }
  352.  
  353.    public void cancelEditing(JTree var1) {
  354.       if (this.editingComponent != null) {
  355.          this.completeEditing(false, true, false);
  356.       }
  357.  
  358.    }
  359.  
  360.    public void startEditingAtPath(JTree var1, TreePath var2) {
  361.       var1.scrollPathToVisible(var2);
  362.       if (var2 != null && var1.isVisible(var2)) {
  363.          this.startEditing(var2, (MouseEvent)null);
  364.       }
  365.  
  366.    }
  367.  
  368.    public TreePath getEditingPath(JTree var1) {
  369.       return this.editingPath;
  370.    }
  371.  
  372.    public void installUI(JComponent var1) {
  373.       if (var1 == null) {
  374.          throw new NullPointerException("null component passed to BasicTreeUI.installUI()");
  375.       } else {
  376.          this.tree = (JTree)var1;
  377.          this.prepareForUIInstall();
  378.          this.installDefaults();
  379.          this.installListeners();
  380.          this.installKeyboardActions();
  381.          this.installComponents();
  382.          this.completeUIInstall();
  383.       }
  384.    }
  385.  
  386.    protected void prepareForUIInstall() {
  387.       this.drawingCache = new Hashtable(7);
  388.       this.leftToRight = BasicGraphicsUtils.isLeftToRight(this.tree);
  389.       this.lastWidth = this.tree.getWidth();
  390.       this.stopEditingInCompleteEditing = true;
  391.       this.lastSelectedRow = -1;
  392.       this.leadRow = -1;
  393.       this.preferredSize = new Dimension();
  394.       this.tree.setRowHeight(UIManager.getInt("Tree.rowHeight"));
  395.       Object var1 = UIManager.get("Tree.scrollsOnExpand");
  396.       if (var1 != null) {
  397.          this.tree.setScrollsOnExpand((Boolean)var1);
  398.       }
  399.  
  400.       this.largeModel = this.tree.isLargeModel();
  401.       if (this.getRowHeight() <= 0) {
  402.          this.largeModel = false;
  403.       }
  404.  
  405.       this.setModel(this.tree.getModel());
  406.    }
  407.  
  408.    protected void completeUIInstall() {
  409.       this.setShowsRootHandles(this.tree.getShowsRootHandles());
  410.       this.updateRenderer();
  411.       this.updateDepthOffset();
  412.       this.setSelectionModel(this.tree.getSelectionModel());
  413.       this.treeState = this.createLayoutCache();
  414.       this.configureLayoutCache();
  415.       this.updateSize();
  416.    }
  417.  
  418.    protected void installDefaults() {
  419.       if (this.tree.getBackground() == null || this.tree.getBackground() instanceof UIResource) {
  420.          this.tree.setBackground(UIManager.getColor("Tree.background"));
  421.       }
  422.  
  423.       if (this.getHashColor() == null || this.getHashColor() instanceof UIResource) {
  424.          this.setHashColor(UIManager.getColor("Tree.hash"));
  425.       }
  426.  
  427.       if (this.tree.getFont() == null || this.tree.getFont() instanceof UIResource) {
  428.          this.tree.setFont(UIManager.getFont("Tree.font"));
  429.       }
  430.  
  431.       this.setExpandedIcon((Icon)UIManager.get("Tree.expandedIcon"));
  432.       this.setCollapsedIcon((Icon)UIManager.get("Tree.collapsedIcon"));
  433.       this.setLeftChildIndent((Integer)UIManager.get("Tree.leftChildIndent"));
  434.       this.setRightChildIndent((Integer)UIManager.get("Tree.rightChildIndent"));
  435.    }
  436.  
  437.    protected void installListeners() {
  438.       if ((this.propertyChangeListener = this.createPropertyChangeListener()) != null) {
  439.          this.tree.addPropertyChangeListener(this.propertyChangeListener);
  440.       }
  441.  
  442.       if ((this.mouseListener = this.createMouseListener()) != null) {
  443.          this.tree.addMouseListener(this.mouseListener);
  444.       }
  445.  
  446.       if ((this.focusListener = this.createFocusListener()) != null) {
  447.          this.tree.addFocusListener(this.focusListener);
  448.       }
  449.  
  450.       if ((this.keyListener = this.createKeyListener()) != null) {
  451.          this.tree.addKeyListener(this.keyListener);
  452.       }
  453.  
  454.       if ((this.treeExpansionListener = this.createTreeExpansionListener()) != null) {
  455.          this.tree.addTreeExpansionListener(this.treeExpansionListener);
  456.       }
  457.  
  458.       if ((this.treeModelListener = this.createTreeModelListener()) != null && this.treeModel != null) {
  459.          this.treeModel.addTreeModelListener(this.treeModelListener);
  460.       }
  461.  
  462.       if ((this.selectionModelPropertyChangeListener = this.createSelectionModelPropertyChangeListener()) != null && this.treeSelectionModel != null) {
  463.          this.treeSelectionModel.addPropertyChangeListener(this.selectionModelPropertyChangeListener);
  464.       }
  465.  
  466.       if ((this.treeSelectionListener = this.createTreeSelectionListener()) != null && this.treeSelectionModel != null) {
  467.          this.treeSelectionModel.addTreeSelectionListener(this.treeSelectionListener);
  468.       }
  469.  
  470.    }
  471.  
  472.    protected void installKeyboardActions() {
  473.       InputMap var1 = this.getInputMap(1);
  474.       SwingUtilities.replaceUIInputMap(this.tree, 1, var1);
  475.       var1 = this.getInputMap(0);
  476.       SwingUtilities.replaceUIInputMap(this.tree, 0, var1);
  477.       ActionMap var2 = this.getActionMap();
  478.       SwingUtilities.replaceUIActionMap(this.tree, var2);
  479.    }
  480.  
  481.    InputMap getInputMap(int var1) {
  482.       if (var1 == 1) {
  483.          return (InputMap)UIManager.get("Tree.ancestorInputMap");
  484.       } else {
  485.          return var1 == 0 ? (InputMap)UIManager.get("Tree.focusInputMap") : null;
  486.       }
  487.    }
  488.  
  489.    ActionMap getActionMap() {
  490.       return this.createActionMap();
  491.    }
  492.  
  493.    ActionMap createActionMap() {
  494.       ActionMapUIResource var1 = new ActionMapUIResource();
  495.       ((ActionMap)var1).put("selectPrevious", new TreeIncrementAction(this, -1, "selectPrevious", false, true, (1)null));
  496.       ((ActionMap)var1).put("selectPreviousChangeLead", new TreeIncrementAction(this, -1, "selectPreviousLead", false, false, (1)null));
  497.       ((ActionMap)var1).put("selectPreviousExtendSelection", new TreeIncrementAction(this, -1, "selectPreviousExtendSelection", true, true, (1)null));
  498.       ((ActionMap)var1).put("selectNext", new TreeIncrementAction(this, 1, "selectNext", false, true, (1)null));
  499.       ((ActionMap)var1).put("selectNextChangeLead", new TreeIncrementAction(this, 1, "selectNextLead", false, false, (1)null));
  500.       ((ActionMap)var1).put("selectNextExtendSelection", new TreeIncrementAction(this, 1, "selectNextExtendSelection", true, true, (1)null));
  501.       ((ActionMap)var1).put("selectChild", new TreeTraverseAction(this, 1, "selectChild", true, (1)null));
  502.       ((ActionMap)var1).put("selectChildChangeLead", new TreeTraverseAction(this, 1, "selectChildLead", false, (1)null));
  503.       ((ActionMap)var1).put("selectParent", new TreeTraverseAction(this, -1, "selectParent", true, (1)null));
  504.       ((ActionMap)var1).put("selectParentChangeLead", new TreeTraverseAction(this, -1, "selectParentLead", false, (1)null));
  505.       ((ActionMap)var1).put("scrollUpChangeSelection", new TreePageAction(this, -1, "scrollUpChangeSelection", false, true, (1)null));
  506.       ((ActionMap)var1).put("scrollUpChangeLead", new TreePageAction(this, -1, "scrollUpChangeLead", false, false, (1)null));
  507.       ((ActionMap)var1).put("scrollUpExtendSelection", new TreePageAction(this, -1, "scrollUpExtendSelection", true, true, (1)null));
  508.       ((ActionMap)var1).put("scrollDownChangeSelection", new TreePageAction(this, 1, "scrollDownChangeSelection", false, true, (1)null));
  509.       ((ActionMap)var1).put("scrollDownExtendSelection", new TreePageAction(this, 1, "scrollDownExtendSelection", true, true, (1)null));
  510.       ((ActionMap)var1).put("scrollDownChangeLead", new TreePageAction(this, 1, "scrollDownChangeLead", false, false, (1)null));
  511.       ((ActionMap)var1).put("selectFirst", new TreeHomeAction(this, -1, "selectFirst", false, true, (1)null));
  512.       ((ActionMap)var1).put("selectFirstChangeLead", new TreeHomeAction(this, -1, "selectFirst", false, false, (1)null));
  513.       ((ActionMap)var1).put("selectFirstExtendSelection", new TreeHomeAction(this, -1, "selectFirstExtendSelection", true, true, (1)null));
  514.       ((ActionMap)var1).put("selectLast", new TreeHomeAction(this, 1, "selectLast", false, true, (1)null));
  515.       ((ActionMap)var1).put("selectLastChangeLead", new TreeHomeAction(this, 1, "selectLast", false, false, (1)null));
  516.       ((ActionMap)var1).put("selectLastExtendSelection", new TreeHomeAction(this, 1, "selectLastExtendSelection", true, true, (1)null));
  517.       ((ActionMap)var1).put("toggle", new TreeToggleAction(this, "toggle"));
  518.       ((ActionMap)var1).put("cancel", new TreeCancelEditingAction(this, "cancel"));
  519.       ((ActionMap)var1).put("startEditing", new TreeEditAction(this, "startEditing"));
  520.       ((ActionMap)var1).put("selectAll", new TreeSelectAllAction(this, "selectAll", true));
  521.       ((ActionMap)var1).put("clearSelection", new TreeSelectAllAction(this, "clearSelection", false));
  522.       ((ActionMap)var1).put("toggleSelectionPreserveAnchor", new TreeAddSelectionAction(this, "toggleSelectionPreserveAnchor", false));
  523.       ((ActionMap)var1).put("toggleSelection", new TreeAddSelectionAction(this, "toggleSelection", true));
  524.       ((ActionMap)var1).put("extendSelection", new TreeExtendSelectionAction(this, "extendSelection"));
  525.       ((ActionMap)var1).put("scrollLeft", new ScrollAction(this.tree, 0, -10));
  526.       ((ActionMap)var1).put("scrollLeftExtendSelection", new TreeScrollLRAction(this, -1, "scrollLeftExtendSelection", true, true));
  527.       ((ActionMap)var1).put("scrollRight", new ScrollAction(this.tree, 0, 10));
  528.       ((ActionMap)var1).put("scrollRightExtendSelection", new TreeScrollLRAction(this, 1, "scrollRightExtendSelection", true, true));
  529.       ((ActionMap)var1).put("scrollRightChangeLead", new TreeScrollLRAction(this, 1, "scrollRightChangeLead", false, false));
  530.       ((ActionMap)var1).put("scrollLeftChangeLead", new TreeScrollLRAction(this, -1, "scrollLeftChangeLead", false, false));
  531.       return var1;
  532.    }
  533.  
  534.    protected void installComponents() {
  535.       if ((this.rendererPane = this.createCellRendererPane()) != null) {
  536.          this.tree.add(this.rendererPane);
  537.       }
  538.  
  539.    }
  540.  
  541.    protected AbstractLayoutCache.NodeDimensions createNodeDimensions() {
  542.       return new NodeDimensionsHandler(this);
  543.    }
  544.  
  545.    protected PropertyChangeListener createPropertyChangeListener() {
  546.       return new PropertyChangeHandler(this);
  547.    }
  548.  
  549.    protected MouseListener createMouseListener() {
  550.       return new MouseHandler(this);
  551.    }
  552.  
  553.    protected FocusListener createFocusListener() {
  554.       return new FocusHandler(this);
  555.    }
  556.  
  557.    protected KeyListener createKeyListener() {
  558.       return new KeyHandler(this);
  559.    }
  560.  
  561.    protected PropertyChangeListener createSelectionModelPropertyChangeListener() {
  562.       return new SelectionModelPropertyChangeHandler(this);
  563.    }
  564.  
  565.    protected TreeSelectionListener createTreeSelectionListener() {
  566.       return new TreeSelectionHandler(this);
  567.    }
  568.  
  569.    protected CellEditorListener createCellEditorListener() {
  570.       return new CellEditorHandler(this);
  571.    }
  572.  
  573.    protected ComponentListener createComponentListener() {
  574.       return new ComponentHandler(this);
  575.    }
  576.  
  577.    protected TreeExpansionListener createTreeExpansionListener() {
  578.       return new TreeExpansionHandler(this);
  579.    }
  580.  
  581.    protected AbstractLayoutCache createLayoutCache() {
  582.       return (AbstractLayoutCache)(this.isLargeModel() && this.getRowHeight() > 0 ? new FixedHeightLayoutCache() : new VariableHeightLayoutCache());
  583.    }
  584.  
  585.    protected CellRendererPane createCellRendererPane() {
  586.       return new CellRendererPane();
  587.    }
  588.  
  589.    protected TreeCellEditor createDefaultCellEditor() {
  590.       if (this.currentCellRenderer != null && this.currentCellRenderer instanceof DefaultTreeCellRenderer) {
  591.          DefaultTreeCellEditor var1 = new DefaultTreeCellEditor(this.tree, (DefaultTreeCellRenderer)this.currentCellRenderer);
  592.          return var1;
  593.       } else {
  594.          return new DefaultTreeCellEditor(this.tree, (DefaultTreeCellRenderer)null);
  595.       }
  596.    }
  597.  
  598.    protected TreeCellRenderer createDefaultCellRenderer() {
  599.       return new DefaultTreeCellRenderer();
  600.    }
  601.  
  602.    protected TreeModelListener createTreeModelListener() {
  603.       return new TreeModelHandler(this);
  604.    }
  605.  
  606.    public void uninstallUI(JComponent var1) {
  607.       this.completeEditing();
  608.       this.prepareForUIUninstall();
  609.       this.uninstallDefaults();
  610.       this.uninstallListeners();
  611.       this.uninstallKeyboardActions();
  612.       this.uninstallComponents();
  613.       this.completeUIUninstall();
  614.    }
  615.  
  616.    protected void prepareForUIUninstall() {
  617.    }
  618.  
  619.    protected void completeUIUninstall() {
  620.       if (this.createdRenderer) {
  621.          this.tree.setCellRenderer((TreeCellRenderer)null);
  622.       }
  623.  
  624.       if (this.createdCellEditor) {
  625.          this.tree.setCellEditor((TreeCellEditor)null);
  626.       }
  627.  
  628.       this.cellEditor = null;
  629.       this.currentCellRenderer = null;
  630.       this.rendererPane = null;
  631.       this.componentListener = null;
  632.       this.propertyChangeListener = null;
  633.       this.mouseListener = null;
  634.       this.focusListener = null;
  635.       this.keyListener = null;
  636.       this.setSelectionModel((TreeSelectionModel)null);
  637.       this.treeState = null;
  638.       this.drawingCache = null;
  639.       this.selectionModelPropertyChangeListener = null;
  640.       this.tree = null;
  641.       this.treeModel = null;
  642.       this.treeSelectionModel = null;
  643.       this.treeSelectionListener = null;
  644.       this.treeExpansionListener = null;
  645.    }
  646.  
  647.    protected void uninstallDefaults() {
  648.    }
  649.  
  650.    protected void uninstallListeners() {
  651.       if (this.componentListener != null) {
  652.          this.tree.removeComponentListener(this.componentListener);
  653.       }
  654.  
  655.       if (this.propertyChangeListener != null) {
  656.          this.tree.removePropertyChangeListener(this.propertyChangeListener);
  657.       }
  658.  
  659.       if (this.mouseListener != null) {
  660.          this.tree.removeMouseListener(this.mouseListener);
  661.       }
  662.  
  663.       if (this.focusListener != null) {
  664.          this.tree.removeFocusListener(this.focusListener);
  665.       }
  666.  
  667.       if (this.keyListener != null) {
  668.          this.tree.removeKeyListener(this.keyListener);
  669.       }
  670.  
  671.       if (this.treeExpansionListener != null) {
  672.          this.tree.removeTreeExpansionListener(this.treeExpansionListener);
  673.       }
  674.  
  675.       if (this.treeModel != null && this.treeModelListener != null) {
  676.          this.treeModel.removeTreeModelListener(this.treeModelListener);
  677.       }
  678.  
  679.       if (this.selectionModelPropertyChangeListener != null && this.treeSelectionModel != null) {
  680.          this.treeSelectionModel.removePropertyChangeListener(this.selectionModelPropertyChangeListener);
  681.       }
  682.  
  683.       if (this.treeSelectionListener != null && this.treeSelectionModel != null) {
  684.          this.treeSelectionModel.removeTreeSelectionListener(this.treeSelectionListener);
  685.       }
  686.  
  687.    }
  688.  
  689.    protected void uninstallKeyboardActions() {
  690.       SwingUtilities.replaceUIActionMap(this.tree, (ActionMap)null);
  691.       SwingUtilities.replaceUIInputMap(this.tree, 1, (InputMap)null);
  692.       SwingUtilities.replaceUIInputMap(this.tree, 0, (InputMap)null);
  693.    }
  694.  
  695.    protected void uninstallComponents() {
  696.       if (this.rendererPane != null) {
  697.          this.tree.remove(this.rendererPane);
  698.       }
  699.  
  700.    }
  701.  
  702.    private void redoTheLayout() {
  703.       if (this.treeState != null) {
  704.          this.treeState.invalidateSizes();
  705.       }
  706.  
  707.    }
  708.  
  709.    public void paint(Graphics var1, JComponent var2) {
  710.       if (this.tree != var2) {
  711.          throw new InternalError("incorrect component");
  712.       } else if (this.treeState != null) {
  713.          int var3 = this.tree.getWidth();
  714.          if (var3 != this.lastWidth) {
  715.             this.lastWidth = var3;
  716.             if (!this.leftToRight) {
  717.                this.redoTheLayout();
  718.                this.updateSize();
  719.             }
  720.          }
  721.  
  722.          Rectangle var4 = var1.getClipBounds();
  723.          Insets var5 = this.tree.getInsets();
  724.          if (var5 == null) {
  725.             var5 = EMPTY_INSETS;
  726.          }
  727.  
  728.          TreePath var6 = this.getClosestPathForLocation(this.tree, 0, var4.y);
  729.          Enumeration var7 = this.treeState.getVisiblePathsFrom(var6);
  730.          int var8 = this.treeState.getRowForPath(var6);
  731.          int var9 = var4.y + var4.height;
  732.          this.drawingCache.clear();
  733.          if (var6 != null && var7 != null) {
  734.             for(TreePath var10 = var6.getParentPath(); var10 != null; var10 = var10.getParentPath()) {
  735.                this.paintVerticalPartOfLeg(var1, var4, var5, var10);
  736.                this.drawingCache.put(var10, Boolean.TRUE);
  737.             }
  738.  
  739.             boolean var11 = false;
  740.             Rectangle var15 = new Rectangle();
  741.  
  742.             for(boolean var18 = this.isRootVisible(); !var11 && var7.hasMoreElements(); ++var8) {
  743.                TreePath var17 = (TreePath)var7.nextElement();
  744.                if (var17 != null) {
  745.                   boolean var14 = this.treeModel.isLeaf(var17.getLastPathComponent());
  746.                   boolean var12;
  747.                   boolean var13;
  748.                   if (var14) {
  749.                      var13 = false;
  750.                      var12 = false;
  751.                   } else {
  752.                      var12 = this.treeState.getExpandedState(var17);
  753.                      var13 = this.tree.hasBeenExpanded(var17);
  754.                   }
  755.  
  756.                   Rectangle var16 = this.treeState.getBounds(var17, var15);
  757.                   if (var16 == null) {
  758.                      return;
  759.                   }
  760.  
  761.                   var16.x += var5.left;
  762.                   var16.y += var5.top;
  763.                   TreePath var19 = var17.getParentPath();
  764.                   if (var19 != null) {
  765.                      if (this.drawingCache.get(var19) == null) {
  766.                         this.paintVerticalPartOfLeg(var1, var4, var5, var19);
  767.                         this.drawingCache.put(var19, Boolean.TRUE);
  768.                      }
  769.  
  770.                      this.paintHorizontalPartOfLeg(var1, var4, var5, var16, var17, var8, var12, var13, var14);
  771.                   } else if (var18 && var8 == 0) {
  772.                      this.paintHorizontalPartOfLeg(var1, var4, var5, var16, var17, var8, var12, var13, var14);
  773.                   }
  774.  
  775.                   if (this.shouldPaintExpandControl(var17, var8, var12, var13, var14)) {
  776.                      this.paintExpandControl(var1, var4, var5, var16, var17, var8, var12, var13, var14);
  777.                   }
  778.  
  779.                   if (!this.leftToRight) {
  780.                      var16.x += 4;
  781.                   }
  782.  
  783.                   this.paintRow(var1, var4, var5, var16, var17, var8, var12, var13, var14);
  784.                   if (var16.y + var16.height >= var9) {
  785.                      var11 = true;
  786.                   }
  787.                } else {
  788.                   var11 = true;
  789.                }
  790.             }
  791.          }
  792.  
  793.          this.rendererPane.removeAll();
  794.       }
  795.    }
  796.  
  797.    protected void paintHorizontalPartOfLeg(Graphics var1, Rectangle var2, Insets var3, Rectangle var4, TreePath var5, int var6, boolean var7, boolean var8, boolean var9) {
  798.       int var10 = var2.x;
  799.       int var11 = var2.x + (var2.width - 1);
  800.       int var12 = var2.y;
  801.       int var13 = var2.y + (var2.height - 1);
  802.       int var14 = var4.y + var4.height / 2;
  803.       if (this.leftToRight) {
  804.          int var15 = var4.x - this.getRightChildIndent();
  805.          int var16 = var4.x - this.getHorizontalLegBuffer();
  806.          if (var14 > var12 && var14 < var13 && var16 > var10 && var15 < var11) {
  807.             var15 = Math.max(var15, var10);
  808.             var16 = Math.min(var16, var11);
  809.             var1.setColor(this.getHashColor());
  810.             this.paintHorizontalLine(var1, this.tree, var14, var15, var16);
  811.          }
  812.       } else {
  813.          int var18 = var4.x + var4.width + this.getRightChildIndent();
  814.          int var21 = var4.x + var4.width + this.getHorizontalLegBuffer() - 1;
  815.          if (var14 > var12 && var14 < var13 && var18 > var10 && var21 < var11) {
  816.             var18 = Math.min(var18, var11);
  817.             var21 = Math.max(var21, var10);
  818.             var1.setColor(this.getHashColor());
  819.             this.paintHorizontalLine(var1, this.tree, var14, var21, var18);
  820.          }
  821.       }
  822.  
  823.    }
  824.  
  825.    protected void paintVerticalPartOfLeg(Graphics var1, Rectangle var2, Insets var3, TreePath var4) {
  826.       int var5;
  827.       if (this.leftToRight) {
  828.          var5 = (var4.getPathCount() + this.depthOffset) * this.totalChildIndent - this.getRightChildIndent() + var3.left;
  829.       } else {
  830.          var5 = this.lastWidth - (var4.getPathCount() - 1 + this.depthOffset) * this.totalChildIndent - 9;
  831.       }
  832.  
  833.       int var6 = var2.x;
  834.       int var7 = var2.x + (var2.width - 1);
  835.       if (var5 > var6 && var5 < var7) {
  836.          int var8 = var2.y;
  837.          int var9 = var2.y + var2.height;
  838.          Rectangle var10 = this.getPathBounds(this.tree, var4);
  839.          Rectangle var11 = this.getPathBounds(this.tree, this.getLastChildPath(var4));
  840.          if (var11 == null) {
  841.             return;
  842.          }
  843.  
  844.          int var12;
  845.          if (var10 == null) {
  846.             var12 = Math.max(var3.top + this.getVerticalLegBuffer(), var8);
  847.          } else {
  848.             var12 = Math.max(var10.y + var10.height + this.getVerticalLegBuffer(), var8);
  849.          }
  850.  
  851.          if (var4.getPathCount() == 1 && !this.isRootVisible()) {
  852.             TreeModel var13 = this.getModel();
  853.             if (var13 != null) {
  854.                Object var14 = var13.getRoot();
  855.                if (var13.getChildCount(var14) > 0) {
  856.                   var10 = this.getPathBounds(this.tree, var4.pathByAddingChild(var13.getChild(var14, 0)));
  857.                   if (var10 != null) {
  858.                      var12 = Math.max(var3.top + this.getVerticalLegBuffer(), var10.y + var10.height / 2);
  859.                   }
  860.                }
  861.             }
  862.          }
  863.  
  864.          int var16 = Math.min(var11.y + var11.height / 2, var9);
  865.          var1.setColor(this.getHashColor());
  866.          this.paintVerticalLine(var1, this.tree, var5, var12, var16);
  867.       }
  868.  
  869.    }
  870.  
  871.    protected void paintExpandControl(Graphics var1, Rectangle var2, Insets var3, Rectangle var4, TreePath var5, int var6, boolean var7, boolean var8, boolean var9) {
  872.       Object var10 = var5.getLastPathComponent();
  873.       if (!var9 && (!var8 || this.treeModel.getChildCount(var10) > 0)) {
  874.          int var11;
  875.          if (this.leftToRight) {
  876.             var11 = var4.x - (this.getRightChildIndent() - 1);
  877.          } else {
  878.             var11 = var4.x + var4.width + this.getRightChildIndent();
  879.          }
  880.  
  881.          int var12 = var4.y + var4.height / 2;
  882.          if (var7) {
  883.             Icon var13 = this.getExpandedIcon();
  884.             if (var13 != null) {
  885.                this.drawCentered(this.tree, var1, var13, var11, var12);
  886.             }
  887.          } else {
  888.             Icon var14 = this.getCollapsedIcon();
  889.             if (var14 != null) {
  890.                this.drawCentered(this.tree, var1, var14, var11, var12);
  891.             }
  892.          }
  893.       }
  894.  
  895.    }
  896.  
  897.    protected void paintRow(Graphics var1, Rectangle var2, Insets var3, Rectangle var4, TreePath var5, int var6, boolean var7, boolean var8, boolean var9) {
  898.       if (this.editingComponent == null || this.editingRow != var6) {
  899.          int var10;
  900.          if (this.tree.hasFocus()) {
  901.             var10 = this.getLeadSelectionRow();
  902.          } else {
  903.             var10 = -1;
  904.          }
  905.  
  906.          Component var11 = this.currentCellRenderer.getTreeCellRendererComponent(this.tree, var5.getLastPathComponent(), this.tree.isRowSelected(var6), var7, var9, var6, var10 == var6);
  907.          this.rendererPane.paintComponent(var1, var11, this.tree, var4.x, var4.y, var4.width, var4.height, true);
  908.       }
  909.    }
  910.  
  911.    protected boolean shouldPaintExpandControl(TreePath var1, int var2, boolean var3, boolean var4, boolean var5) {
  912.       if (var5) {
  913.          return false;
  914.       } else {
  915.          int var6 = var1.getPathCount() - 1;
  916.          return var6 != 0 && (var6 != 1 || this.isRootVisible()) || this.getShowsRootHandles();
  917.       }
  918.    }
  919.  
  920.    protected void paintVerticalLine(Graphics var1, JComponent var2, int var3, int var4, int var5) {
  921.       var1.drawLine(var3, var4, var3, var5);
  922.    }
  923.  
  924.    protected void paintHorizontalLine(Graphics var1, JComponent var2, int var3, int var4, int var5) {
  925.       var1.drawLine(var4, var3, var5, var3);
  926.    }
  927.  
  928.    protected int getVerticalLegBuffer() {
  929.       return 0;
  930.    }
  931.  
  932.    protected int getHorizontalLegBuffer() {
  933.       return 0;
  934.    }
  935.  
  936.    protected void drawCentered(Component var1, Graphics var2, Icon var3, int var4, int var5) {
  937.       var3.paintIcon(var1, var2, var4 - var3.getIconWidth() / 2, var5 - var3.getIconHeight() / 2);
  938.    }
  939.  
  940.    protected void drawDashedHorizontalLine(Graphics var1, int var2, int var3, int var4) {
  941.       var3 += var3 % 2;
  942.  
  943.       for(int var5 = var3; var5 <= var4; var5 += 2) {
  944.          var1.drawLine(var5, var2, var5, var2);
  945.       }
  946.  
  947.    }
  948.  
  949.    protected void drawDashedVerticalLine(Graphics var1, int var2, int var3, int var4) {
  950.       var3 += var3 % 2;
  951.  
  952.       for(int var5 = var3; var5 <= var4; var5 += 2) {
  953.          var1.drawLine(var2, var5, var2, var5);
  954.       }
  955.  
  956.    }
  957.  
  958.    protected void updateLayoutCacheExpandedNodes() {
  959.       if (this.treeModel != null) {
  960.          this.updateExpandedDescendants(new TreePath(this.treeModel.getRoot()));
  961.       }
  962.  
  963.    }
  964.  
  965.    protected void updateExpandedDescendants(TreePath var1) {
  966.       this.completeEditing();
  967.       if (this.treeState != null) {
  968.          this.treeState.setExpandedState(var1, true);
  969.          Enumeration var2 = this.tree.getExpandedDescendants(var1);
  970.          if (var2 != null) {
  971.             while(var2.hasMoreElements()) {
  972.                var1 = (TreePath)var2.nextElement();
  973.                this.treeState.setExpandedState(var1, true);
  974.             }
  975.          }
  976.  
  977.          this.updateLeadRow();
  978.          this.updateSize();
  979.       }
  980.  
  981.    }
  982.  
  983.    protected TreePath getLastChildPath(TreePath var1) {
  984.       if (this.treeModel != null) {
  985.          int var2 = this.treeModel.getChildCount(var1.getLastPathComponent());
  986.          if (var2 > 0) {
  987.             return var1.pathByAddingChild(this.treeModel.getChild(var1.getLastPathComponent(), var2 - 1));
  988.          }
  989.       }
  990.  
  991.       return null;
  992.    }
  993.  
  994.    protected void updateDepthOffset() {
  995.       if (this.isRootVisible()) {
  996.          if (this.getShowsRootHandles()) {
  997.             this.depthOffset = 1;
  998.          } else {
  999.             this.depthOffset = 0;
  1000.          }
  1001.       } else if (!this.getShowsRootHandles()) {
  1002.          this.depthOffset = -1;
  1003.       } else {
  1004.          this.depthOffset = 0;
  1005.       }
  1006.  
  1007.    }
  1008.  
  1009.    protected void updateCellEditor() {
  1010.       this.completeEditing();
  1011.       TreeCellEditor var1;
  1012.       if (this.tree == null) {
  1013.          var1 = null;
  1014.       } else if (this.tree.isEditable()) {
  1015.          var1 = this.tree.getCellEditor();
  1016.          if (var1 == null) {
  1017.             var1 = this.createDefaultCellEditor();
  1018.             if (var1 != null) {
  1019.                this.tree.setCellEditor(var1);
  1020.                this.createdCellEditor = true;
  1021.             }
  1022.          }
  1023.       } else {
  1024.          var1 = null;
  1025.       }
  1026.  
  1027.       if (var1 != this.cellEditor) {
  1028.          if (this.cellEditor != null && this.cellEditorListener != null) {
  1029.             this.cellEditor.removeCellEditorListener(this.cellEditorListener);
  1030.          }
  1031.  
  1032.          this.cellEditor = var1;
  1033.          if (this.cellEditorListener == null) {
  1034.             this.cellEditorListener = this.createCellEditorListener();
  1035.          }
  1036.  
  1037.          if (var1 != null && this.cellEditorListener != null) {
  1038.             var1.addCellEditorListener(this.cellEditorListener);
  1039.          }
  1040.  
  1041.          this.createdCellEditor = false;
  1042.       }
  1043.  
  1044.    }
  1045.  
  1046.    protected void updateRenderer() {
  1047.       if (this.tree != null) {
  1048.          TreeCellRenderer var1 = this.tree.getCellRenderer();
  1049.          if (var1 == null) {
  1050.             this.tree.setCellRenderer(this.createDefaultCellRenderer());
  1051.             this.createdRenderer = true;
  1052.          } else {
  1053.             this.createdRenderer = false;
  1054.             this.currentCellRenderer = var1;
  1055.             if (this.createdCellEditor) {
  1056.                this.tree.setCellEditor((TreeCellEditor)null);
  1057.             }
  1058.          }
  1059.       } else {
  1060.          this.createdRenderer = false;
  1061.          this.currentCellRenderer = null;
  1062.       }
  1063.  
  1064.       this.updateCellEditor();
  1065.    }
  1066.  
  1067.    protected void configureLayoutCache() {
  1068.       if (this.treeState != null && this.tree != null) {
  1069.          if (this.nodeDimensions == null) {
  1070.             this.nodeDimensions = this.createNodeDimensions();
  1071.          }
  1072.  
  1073.          this.treeState.setNodeDimensions(this.nodeDimensions);
  1074.          this.treeState.setRootVisible(this.tree.isRootVisible());
  1075.          this.treeState.setRowHeight(this.tree.getRowHeight());
  1076.          this.treeState.setSelectionModel(this.getSelectionModel());
  1077.          if (this.treeState.getModel() != this.tree.getModel()) {
  1078.             this.treeState.setModel(this.tree.getModel());
  1079.          }
  1080.  
  1081.          this.updateLayoutCacheExpandedNodes();
  1082.          if (this.isLargeModel()) {
  1083.             if (this.componentListener == null) {
  1084.                this.componentListener = this.createComponentListener();
  1085.                if (this.componentListener != null) {
  1086.                   this.tree.addComponentListener(this.componentListener);
  1087.                }
  1088.             }
  1089.          } else if (this.componentListener != null) {
  1090.             this.tree.removeComponentListener(this.componentListener);
  1091.             this.componentListener = null;
  1092.          }
  1093.       } else if (this.componentListener != null) {
  1094.          this.tree.removeComponentListener(this.componentListener);
  1095.          this.componentListener = null;
  1096.       }
  1097.  
  1098.    }
  1099.  
  1100.    protected void updateSize() {
  1101.       this.validCachedPreferredSize = false;
  1102.       this.tree.treeDidChange();
  1103.    }
  1104.  
  1105.    protected void updateCachedPreferredSize() {
  1106.       if (this.treeState != null) {
  1107.          Insets var1 = this.tree.getInsets();
  1108.          if (this.isLargeModel()) {
  1109.             Rectangle var6 = this.tree.getVisibleRect();
  1110.             if (var1 != null) {
  1111.                var6.x -= var1.left;
  1112.                var6.y -= var1.top;
  1113.             }
  1114.  
  1115.             if (this.leftToRight) {
  1116.                this.preferredSize.width = this.treeState.getPreferredWidth(var6);
  1117.             } else if (this.getRowCount(this.tree) == 0) {
  1118.                this.preferredSize.width = 0;
  1119.             } else {
  1120.                this.preferredSize.width = this.lastWidth - this.getMinX(var6);
  1121.             }
  1122.          } else if (this.leftToRight) {
  1123.             this.preferredSize.width = this.treeState.getPreferredWidth((Rectangle)null);
  1124.          } else {
  1125.             Rectangle var2 = null;
  1126.             int var3 = this.tree.getRowCount();
  1127.             int var4 = 0;
  1128.  
  1129.             for(int var5 = 0; var5 < var3; ++var5) {
  1130.                var2 = this.treeState.getBounds(this.treeState.getPathForRow(var5), var2);
  1131.                if (var2 != null) {
  1132.                   var4 = Math.max(this.lastWidth - var2.x, var4);
  1133.                }
  1134.             }
  1135.  
  1136.             this.preferredSize.width = var4;
  1137.          }
  1138.  
  1139.          this.preferredSize.height = this.treeState.getPreferredHeight();
  1140.          if (var1 != null) {
  1141.             Dimension var10000 = this.preferredSize;
  1142.             var10000.width += var1.left + var1.right;
  1143.             var10000 = this.preferredSize;
  1144.             var10000.height += var1.top + var1.bottom;
  1145.          }
  1146.       }
  1147.  
  1148.       this.validCachedPreferredSize = true;
  1149.    }
  1150.  
  1151.    private int getMinX(Rectangle var1) {
  1152.       TreePath var2;
  1153.       int var3;
  1154.       if (var1 == null) {
  1155.          var2 = this.getPathForRow(this.tree, 0);
  1156.          var3 = Integer.MAX_VALUE;
  1157.       } else {
  1158.          var2 = this.treeState.getPathClosestTo(var1.x, var1.y);
  1159.          var3 = var1.height + var1.y;
  1160.       }
  1161.  
  1162.       Enumeration var4 = this.treeState.getVisiblePathsFrom(var2);
  1163.       int var5 = 0;
  1164.       if (var4 != null && var4.hasMoreElements()) {
  1165.          Rectangle var6 = this.treeState.getBounds((TreePath)var4.nextElement(), (Rectangle)null);
  1166.          if (var6 != null) {
  1167.             var5 = var6.x + var6.width;
  1168.             if (var6.y >= var3) {
  1169.                return var5;
  1170.             }
  1171.          }
  1172.  
  1173.          while(var6 != null && var4.hasMoreElements()) {
  1174.             var6 = this.treeState.getBounds((TreePath)var4.nextElement(), var6);
  1175.             if (var6 != null && var6.y < var3) {
  1176.                var5 = Math.min(var5, var6.x);
  1177.             } else {
  1178.                var6 = null;
  1179.             }
  1180.          }
  1181.  
  1182.          return var5;
  1183.       } else {
  1184.          return var5;
  1185.       }
  1186.    }
  1187.  
  1188.    protected void pathWasExpanded(TreePath var1) {
  1189.       if (this.tree != null) {
  1190.          this.tree.fireTreeExpanded(var1);
  1191.       }
  1192.  
  1193.    }
  1194.  
  1195.    protected void pathWasCollapsed(TreePath var1) {
  1196.       if (this.tree != null) {
  1197.          this.tree.fireTreeCollapsed(var1);
  1198.       }
  1199.  
  1200.    }
  1201.  
  1202.    protected void ensureRowsAreVisible(int var1, int var2) {
  1203.       if (this.tree != null && var1 >= 0 && var2 < this.getRowCount(this.tree)) {
  1204.          if (var1 == var2) {
  1205.             Rectangle var3 = this.getPathBounds(this.tree, this.getPathForRow(this.tree, var1));
  1206.             if (var3 != null) {
  1207.                this.tree.scrollRectToVisible(var3);
  1208.             }
  1209.          } else {
  1210.             Rectangle var9 = this.getPathBounds(this.tree, this.getPathForRow(this.tree, var1));
  1211.             Rectangle var4 = this.tree.getVisibleRect();
  1212.             Rectangle var5 = var9;
  1213.             int var6 = var9.y;
  1214.             int var7 = var6 + var4.height;
  1215.  
  1216.             for(int var8 = var1 + 1; var8 <= var2; ++var8) {
  1217.                var5 = this.getPathBounds(this.tree, this.getPathForRow(this.tree, var8));
  1218.                if (var5.y + var5.height > var7) {
  1219.                   var8 = var2;
  1220.                }
  1221.             }
  1222.  
  1223.             this.tree.scrollRectToVisible(new Rectangle(var4.x, var6, 1, var5.y + var5.height - var6));
  1224.          }
  1225.       }
  1226.  
  1227.    }
  1228.  
  1229.    public void setPreferredMinSize(Dimension var1) {
  1230.       this.preferredMinSize = var1;
  1231.    }
  1232.  
  1233.    public Dimension getPreferredMinSize() {
  1234.       return this.preferredMinSize == null ? null : new Dimension(this.preferredMinSize);
  1235.    }
  1236.  
  1237.    public Dimension getPreferredSize(JComponent var1) {
  1238.       return this.getPreferredSize(var1, true);
  1239.    }
  1240.  
  1241.    public Dimension getPreferredSize(JComponent var1, boolean var2) {
  1242.       Dimension var3 = this.getPreferredMinSize();
  1243.       if (!this.validCachedPreferredSize) {
  1244.          this.updateCachedPreferredSize();
  1245.       }
  1246.  
  1247.       if (this.tree != null) {
  1248.          return var3 != null ? new Dimension(Math.max(var3.width, this.preferredSize.width), Math.max(var3.height, this.preferredSize.height)) : new Dimension(this.preferredSize.width, this.preferredSize.height);
  1249.       } else {
  1250.          return var3 != null ? var3 : new Dimension(0, 0);
  1251.       }
  1252.    }
  1253.  
  1254.    public Dimension getMinimumSize(JComponent var1) {
  1255.       return this.getPreferredMinSize() != null ? this.getPreferredMinSize() : new Dimension(0, 0);
  1256.    }
  1257.  
  1258.    public Dimension getMaximumSize(JComponent var1) {
  1259.       if (this.tree != null) {
  1260.          return this.getPreferredSize(this.tree);
  1261.       } else {
  1262.          return this.getPreferredMinSize() != null ? this.getPreferredMinSize() : new Dimension(0, 0);
  1263.       }
  1264.    }
  1265.  
  1266.    protected void completeEditing() {
  1267.       if (this.tree.getInvokesStopCellEditing() && this.stopEditingInCompleteEditing && this.editingComponent != null) {
  1268.          this.cellEditor.stopCellEditing();
  1269.       }
  1270.  
  1271.       this.completeEditing(false, true, false);
  1272.    }
  1273.  
  1274.    protected void completeEditing(boolean var1, boolean var2, boolean var3) {
  1275.       if (this.stopEditingInCompleteEditing && this.editingComponent != null) {
  1276.          Component var4 = this.editingComponent;
  1277.          TreePath var5 = this.editingPath;
  1278.          TreeCellEditor var6 = this.cellEditor;
  1279.          Object var7 = var6.getCellEditorValue();
  1280.          Rectangle var8 = this.getPathBounds(this.tree, this.editingPath);
  1281.          boolean var9 = this.tree != null && (this.tree.hasFocus() || SwingUtilities.findFocusOwner(this.editingComponent) != null);
  1282.          this.editingComponent = null;
  1283.          this.editingPath = null;
  1284.          if (var1) {
  1285.             var6.stopCellEditing();
  1286.          } else if (var2) {
  1287.             var6.cancelCellEditing();
  1288.          }
  1289.  
  1290.          this.tree.remove(var4);
  1291.          if (this.editorHasDifferentSize) {
  1292.             this.treeState.invalidatePathBounds(var5);
  1293.             this.updateSize();
  1294.          } else {
  1295.             var8.x = 0;
  1296.             var8.width = this.tree.getSize().width;
  1297.             this.tree.repaint(var8);
  1298.          }
  1299.  
  1300.          if (var9) {
  1301.             this.tree.requestFocus();
  1302.          }
  1303.  
  1304.          if (var3) {
  1305.             this.treeModel.valueForPathChanged(var5, var7);
  1306.          }
  1307.       }
  1308.  
  1309.    }
  1310.  
  1311.    protected boolean startEditing(TreePath var1, MouseEvent var2) {
  1312.       this.completeEditing();
  1313.       if (this.cellEditor != null && this.tree.isPathEditable(var1)) {
  1314.          int var3 = this.getRowForPath(this.tree, var1);
  1315.          this.editingComponent = this.cellEditor.getTreeCellEditorComponent(this.tree, var1.getLastPathComponent(), this.tree.isPathSelected(var1), this.tree.isExpanded(var1), this.treeModel.isLeaf(var1.getLastPathComponent()), var3);
  1316.          if (this.cellEditor.isCellEditable(var2)) {
  1317.             Rectangle var4 = this.getPathBounds(this.tree, var1);
  1318.             this.editingRow = var3;
  1319.             Dimension var5 = this.editingComponent.getPreferredSize();
  1320.             if (var5.height != var4.height && this.getRowHeight() > 0) {
  1321.                var5.height = this.getRowHeight();
  1322.             }
  1323.  
  1324.             if (var5.width == var4.width && var5.height == var4.height) {
  1325.                this.editorHasDifferentSize = false;
  1326.             } else {
  1327.                this.editorHasDifferentSize = true;
  1328.                this.treeState.invalidatePathBounds(var1);
  1329.                this.updateSize();
  1330.             }
  1331.  
  1332.             this.tree.add(this.editingComponent);
  1333.             this.editingComponent.setBounds(var4.x, var4.y, var5.width, var5.height);
  1334.             this.editingPath = var1;
  1335.             this.editingComponent.validate();
  1336.             Rectangle var6 = this.tree.getVisibleRect();
  1337.             this.tree.paintImmediately(var4.x, var4.y, var6.width + var6.x - var4.x, var5.height);
  1338.             if (this.cellEditor.shouldSelectCell(var2)) {
  1339.                this.stopEditingInCompleteEditing = false;
  1340.  
  1341.                try {
  1342.                   this.tree.setSelectionRow(var3);
  1343.                } catch (Exception var9) {
  1344.                   System.err.println("Editing exception: " + var9);
  1345.                }
  1346.  
  1347.                this.stopEditingInCompleteEditing = true;
  1348.             }
  1349.  
  1350.             if (var2 != null && var2 instanceof MouseEvent) {
  1351.                Point var7 = SwingUtilities.convertPoint(this.tree, new Point(var2.getX(), var2.getY()), this.editingComponent);
  1352.                Component var8 = SwingUtilities.getDeepestComponentAt(this.editingComponent, var7.x, var7.y);
  1353.                if (var8 != null) {
  1354.                   new MouseInputHandler(this, this.tree, var8, var2);
  1355.                }
  1356.             }
  1357.  
  1358.             return true;
  1359.          }
  1360.  
  1361.          this.editingComponent = null;
  1362.       }
  1363.  
  1364.       return false;
  1365.    }
  1366.  
  1367.    protected void checkForClickInExpandControl(TreePath var1, int var2, int var3) {
  1368.       if (this.isLocationInExpandControl(var1, var2, var3)) {
  1369.          this.handleExpandControlClick(var1, var2, var3);
  1370.       }
  1371.  
  1372.    }
  1373.  
  1374.    protected boolean isLocationInExpandControl(TreePath var1, int var2, int var3) {
  1375.       if (var1 != null && !this.treeModel.isLeaf(var1.getLastPathComponent())) {
  1376.          Insets var5 = this.tree.getInsets();
  1377.          int var4;
  1378.          if (this.getExpandedIcon() != null) {
  1379.             var4 = this.getExpandedIcon().getIconWidth();
  1380.          } else {
  1381.             var4 = 8;
  1382.          }
  1383.  
  1384.          int var6 = var5 != null ? var5.left : 0;
  1385.          if (this.leftToRight) {
  1386.             var6 += (var1.getPathCount() + this.depthOffset - 2) * this.totalChildIndent + this.getLeftChildIndent() - var4 / 2;
  1387.          } else {
  1388.             var6 += this.lastWidth - 1 - (var1.getPathCount() - 2 + this.depthOffset) * this.totalChildIndent - this.getLeftChildIndent() - var4 / 2;
  1389.          }
  1390.  
  1391.          int var7 = var6 + var4;
  1392.          return var2 >= var6 && var2 <= var7;
  1393.       } else {
  1394.          return false;
  1395.       }
  1396.    }
  1397.  
  1398.    protected void handleExpandControlClick(TreePath var1, int var2, int var3) {
  1399.       this.toggleExpandState(var1);
  1400.    }
  1401.  
  1402.    protected void toggleExpandState(TreePath var1) {
  1403.       if (!this.tree.isExpanded(var1)) {
  1404.          int var2 = this.getRowForPath(this.tree, var1);
  1405.          this.tree.expandPath(var1);
  1406.          this.updateSize();
  1407.          if (var2 != -1) {
  1408.             if (this.tree.getScrollsOnExpand()) {
  1409.                this.ensureRowsAreVisible(var2, var2 + this.treeState.getVisibleChildCount(var1));
  1410.             } else {
  1411.                this.ensureRowsAreVisible(var2, var2);
  1412.             }
  1413.          }
  1414.       } else {
  1415.          this.tree.collapsePath(var1);
  1416.          this.updateSize();
  1417.       }
  1418.  
  1419.    }
  1420.  
  1421.    protected boolean isToggleSelectionEvent(MouseEvent var1) {
  1422.       return SwingUtilities.isLeftMouseButton(var1) && ((InputEvent)var1).isControlDown();
  1423.    }
  1424.  
  1425.    protected boolean isMultiSelectEvent(MouseEvent var1) {
  1426.       return SwingUtilities.isLeftMouseButton(var1) && ((InputEvent)var1).isShiftDown();
  1427.    }
  1428.  
  1429.    protected boolean isToggleEvent(MouseEvent var1) {
  1430.       if (!SwingUtilities.isLeftMouseButton(var1)) {
  1431.          return false;
  1432.       } else {
  1433.          int var2 = this.tree.getToggleClickCount();
  1434.          if (var2 <= 0) {
  1435.             return false;
  1436.          } else {
  1437.             return var1.getClickCount() == var2;
  1438.          }
  1439.       }
  1440.    }
  1441.  
  1442.    protected void selectPathForEvent(TreePath var1, MouseEvent var2) {
  1443.       if (this.isToggleSelectionEvent(var2)) {
  1444.          if (this.tree.isPathSelected(var1)) {
  1445.             this.tree.removeSelectionPath(var1);
  1446.          } else {
  1447.             this.tree.addSelectionPath(var1);
  1448.          }
  1449.  
  1450.          this.lastSelectedRow = this.getRowForPath(this.tree, var1);
  1451.          this.setAnchorSelectionPath(var1);
  1452.          this.setLeadSelectionPath(var1);
  1453.       } else if (this.isMultiSelectEvent(var2)) {
  1454.          TreePath var3 = this.getAnchorSelectionPath();
  1455.          int var4 = var3 == null ? -1 : this.getRowForPath(this.tree, var3);
  1456.          if (var4 == -1) {
  1457.             this.tree.setSelectionPath(var1);
  1458.          } else {
  1459.             int var5 = this.getRowForPath(this.tree, var1);
  1460.             if (var5 < var4) {
  1461.                this.tree.setSelectionInterval(var5, var4);
  1462.             } else {
  1463.                this.tree.setSelectionInterval(var4, var5);
  1464.             }
  1465.  
  1466.             this.lastSelectedRow = var5;
  1467.             this.setAnchorSelectionPath(var3);
  1468.             this.setLeadSelectionPath(var1);
  1469.          }
  1470.       } else if (SwingUtilities.isLeftMouseButton(var2)) {
  1471.          this.tree.setSelectionPath(var1);
  1472.          if (this.isToggleEvent(var2)) {
  1473.             this.toggleExpandState(var1);
  1474.          }
  1475.       }
  1476.  
  1477.    }
  1478.  
  1479.    protected boolean isLeaf(int var1) {
  1480.       TreePath var2 = this.getPathForRow(this.tree, var1);
  1481.       return var2 != null ? this.treeModel.isLeaf(var2.getLastPathComponent()) : true;
  1482.    }
  1483.  
  1484.    private void setAnchorSelectionPath(TreePath var1) {
  1485.       this.ignoreLAChange = true;
  1486.  
  1487.       try {
  1488.          this.tree.setAnchorSelectionPath(var1);
  1489.       } finally {
  1490.          this.ignoreLAChange = false;
  1491.       }
  1492.  
  1493.    }
  1494.  
  1495.    private TreePath getAnchorSelectionPath() {
  1496.       return this.tree.getAnchorSelectionPath();
  1497.    }
  1498.  
  1499.    private void setLeadSelectionPath(TreePath var1) {
  1500.       this.setLeadSelectionPath(var1, false);
  1501.    }
  1502.  
  1503.    private void setLeadSelectionPath(TreePath var1, boolean var2) {
  1504.       Rectangle var3 = var2 ? this.getPathBounds(this.tree, this.getLeadSelectionPath()) : null;
  1505.       this.ignoreLAChange = true;
  1506.  
  1507.       try {
  1508.          this.tree.setLeadSelectionPath(var1);
  1509.       } finally {
  1510.          this.ignoreLAChange = false;
  1511.       }
  1512.  
  1513.       this.leadRow = this.getRowForPath(this.tree, var1);
  1514.       if (var2) {
  1515.          if (var3 != null) {
  1516.             this.tree.repaint(var3);
  1517.          }
  1518.  
  1519.          var3 = this.getPathBounds(this.tree, var1);
  1520.          if (var3 != null) {
  1521.             this.tree.repaint(var3);
  1522.          }
  1523.       }
  1524.  
  1525.    }
  1526.  
  1527.    private TreePath getLeadSelectionPath() {
  1528.       return this.tree.getLeadSelectionPath();
  1529.    }
  1530.  
  1531.    private void updateLeadRow() {
  1532.       this.leadRow = this.getRowForPath(this.tree, this.getLeadSelectionPath());
  1533.    }
  1534.  
  1535.    private int getLeadSelectionRow() {
  1536.       return this.leadRow;
  1537.    }
  1538.  
  1539.    private void extendSelection(TreePath var1) {
  1540.       TreePath var2 = this.getAnchorSelectionPath();
  1541.       int var3 = var2 == null ? -1 : this.getRowForPath(this.tree, var2);
  1542.       int var4 = this.getRowForPath(this.tree, var1);
  1543.       if (var3 == -1) {
  1544.          this.tree.setSelectionRow(var4);
  1545.       } else {
  1546.          if (var3 < var4) {
  1547.             this.tree.setSelectionInterval(var3, var4);
  1548.          } else {
  1549.             this.tree.setSelectionInterval(var4, var3);
  1550.          }
  1551.  
  1552.          this.setAnchorSelectionPath(var2);
  1553.          this.setLeadSelectionPath(var1);
  1554.       }
  1555.  
  1556.    }
  1557.  
  1558.    private void repaintPath(TreePath var1) {
  1559.       if (var1 != null) {
  1560.          Rectangle var2 = this.getPathBounds(this.tree, var1);
  1561.          if (var2 != null) {
  1562.             this.tree.repaint(var2.x, var2.y, var2.width, var2.height);
  1563.          }
  1564.       }
  1565.  
  1566.    }
  1567.  
  1568.    // $FF: synthetic method
  1569.    static void access$400(BasicTreeUI var0) {
  1570.       var0.updateLeadRow();
  1571.    }
  1572.  
  1573.    // $FF: synthetic method
  1574.    static TreePath access$500(BasicTreeUI var0) {
  1575.       return var0.getLeadSelectionPath();
  1576.    }
  1577.  
  1578.    // $FF: synthetic method
  1579.    static void access$600(BasicTreeUI var0, TreePath var1) {
  1580.       var0.setAnchorSelectionPath(var1);
  1581.    }
  1582.  
  1583.    // $FF: synthetic method
  1584.    static void access$700(BasicTreeUI var0, TreePath var1) {
  1585.       var0.setLeadSelectionPath(var1);
  1586.    }
  1587.  
  1588.    // $FF: synthetic method
  1589.    static boolean access$800(BasicTreeUI var0) {
  1590.       return var0.leftToRight;
  1591.    }
  1592.  
  1593.    // $FF: synthetic method
  1594.    static int access$900(BasicTreeUI var0) {
  1595.       return var0.lastWidth;
  1596.    }
  1597.  
  1598.    // $FF: synthetic method
  1599.    static boolean access$1000(BasicTreeUI var0) {
  1600.       return var0.ignoreLAChange;
  1601.    }
  1602.  
  1603.    // $FF: synthetic method
  1604.    static void access$1100(BasicTreeUI var0, TreePath var1) {
  1605.       var0.repaintPath(var1);
  1606.    }
  1607.  
  1608.    // $FF: synthetic method
  1609.    static void access$1200(BasicTreeUI var0) {
  1610.       var0.redoTheLayout();
  1611.    }
  1612.  
  1613.    // $FF: synthetic method
  1614.    static boolean access$802(BasicTreeUI var0, boolean var1) {
  1615.       return var0.leftToRight = var1;
  1616.    }
  1617.  
  1618.    // $FF: synthetic method
  1619.    static int access$1300(BasicTreeUI var0) {
  1620.       return var0.getLeadSelectionRow();
  1621.    }
  1622.  
  1623.    // $FF: synthetic method
  1624.    static void access$1400(BasicTreeUI var0, TreePath var1, boolean var2) {
  1625.       var0.setLeadSelectionPath(var1, var2);
  1626.    }
  1627.  
  1628.    // $FF: synthetic method
  1629.    static void access$1500(BasicTreeUI var0, TreePath var1) {
  1630.       var0.extendSelection(var1);
  1631.    }
  1632.  
  1633.    // $FF: synthetic method
  1634.    static TreePath access$1600(BasicTreeUI var0) {
  1635.       return var0.getAnchorSelectionPath();
  1636.    }
  1637. }
  1638.