Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / javax / swing / tree / AbstractLayoutCache.js
1 Clazz.declarePackage ("javax.swing.tree");
2 Clazz.load (["javax.swing.tree.RowMapper"], "javax.swing.tree.AbstractLayoutCache", null, function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.nodeDimensions = null;
5 this.treeModel = null;
6 this.treeSelectionModel = null;
7 this.rootVisible = false;
8 this.rowHeight = 0;
9 Clazz.instantialize (this, arguments);
10 }, javax.swing.tree, "AbstractLayoutCache", null, javax.swing.tree.RowMapper);
11 Clazz.defineMethod (c$, "setNodeDimensions", 
12 function (nd) {
13 this.nodeDimensions = nd;
14 }, "javax.swing.tree.AbstractLayoutCache.NodeDimensions");
15 Clazz.defineMethod (c$, "getNodeDimensions", 
16 function () {
17 return this.nodeDimensions;
18 });
19 Clazz.defineMethod (c$, "setModel", 
20 function (newModel) {
21 this.treeModel = newModel;
22 }, "javax.swing.tree.TreeModel");
23 Clazz.defineMethod (c$, "getModel", 
24 function () {
25 return this.treeModel;
26 });
27 Clazz.defineMethod (c$, "setRootVisible", 
28 function (rootVisible) {
29 this.rootVisible = rootVisible;
30 }, "~B");
31 Clazz.defineMethod (c$, "isRootVisible", 
32 function () {
33 return this.rootVisible;
34 });
35 Clazz.defineMethod (c$, "setRowHeight", 
36 function (rowHeight) {
37 this.rowHeight = rowHeight;
38 }, "~N");
39 Clazz.defineMethod (c$, "getRowHeight", 
40 function () {
41 return this.rowHeight;
42 });
43 Clazz.defineMethod (c$, "setSelectionModel", 
44 function (newLSM) {
45 if (this.treeSelectionModel != null) this.treeSelectionModel.setRowMapper (null);
46 this.treeSelectionModel = newLSM;
47 if (this.treeSelectionModel != null) this.treeSelectionModel.setRowMapper (this);
48 }, "javax.swing.tree.TreeSelectionModel");
49 Clazz.defineMethod (c$, "getSelectionModel", 
50 function () {
51 return this.treeSelectionModel;
52 });
53 Clazz.defineMethod (c$, "getPreferredHeight", 
54 function () {
55 var rowCount = this.getRowCount ();
56 if (rowCount > 0) {
57 var bounds = this.getBounds (this.getPathForRow (rowCount - 1), null);
58 if (bounds != null) return bounds.y + bounds.height;
59 }return 0;
60 });
61 Clazz.defineMethod (c$, "getPreferredWidth", 
62 function (bounds) {
63 var rowCount = this.getRowCount ();
64 if (rowCount > 0) {
65 var firstPath;
66 var endY;
67 if (bounds == null) {
68 firstPath = this.getPathForRow (0);
69 endY = 2147483647;
70 } else {
71 firstPath = this.getPathClosestTo (bounds.x, bounds.y);
72 endY = bounds.height + bounds.y;
73 }var paths = this.getVisiblePathsFrom (firstPath);
74 if (paths != null && paths.hasMoreElements ()) {
75 var pBounds = this.getBounds (paths.nextElement (), null);
76 var width;
77 if (pBounds != null) {
78 width = pBounds.x + pBounds.width;
79 if (pBounds.y >= endY) {
80 return width;
81 }} else width = 0;
82 while (pBounds != null && paths.hasMoreElements ()) {
83 pBounds = this.getBounds (paths.nextElement (), pBounds);
84 if (pBounds != null && pBounds.y < endY) {
85 width = Math.max (width, pBounds.x + pBounds.width);
86 } else {
87 pBounds = null;
88 }}
89 return width;
90 }}return 0;
91 }, "java.awt.Rectangle");
92 Clazz.overrideMethod (c$, "getRowsForPaths", 
93 function (paths) {
94 if (paths == null) return null;
95 var numPaths = paths.length;
96 var rows =  Clazz.newIntArray (numPaths, 0);
97 for (var counter = 0; counter < numPaths; counter++) rows[counter] = this.getRowForPath (paths[counter]);
98
99 return rows;
100 }, "~A");
101 Clazz.defineMethod (c$, "getNodeDimensions", 
102 function (value, row, depth, expanded, placeIn) {
103 var nd = this.getNodeDimensions ();
104 if (nd != null) {
105 return nd.getNodeDimensions (value, row, depth, expanded, placeIn);
106 }return null;
107 }, "~O,~N,~N,~B,java.awt.Rectangle");
108 Clazz.defineMethod (c$, "isFixedRowHeight", 
109 function () {
110 return (this.rowHeight > 0);
111 });
112 Clazz.pu$h(self.c$);
113 c$ = Clazz.declareType (javax.swing.tree.AbstractLayoutCache, "NodeDimensions");
114 c$ = Clazz.p0p ();
115 });