X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Futil%2FTableSorter.js;h=f211ef6ecf0029ce1207268e1ede6c76864df794;hp=9a7a6bdbc2c2fef4fd9ddc72b9be806c2875a7dd;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/jalview/util/TableSorter.js b/site/j2s/jalview/util/TableSorter.js index 9a7a6bd..f211ef6 100644 --- a/site/j2s/jalview/util/TableSorter.js +++ b/site/j2s/jalview/util/TableSorter.js @@ -1,387 +1,387 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (["java.awt.event.MouseAdapter", "javax.swing.Icon", "javax.swing.event.TableModelListener", "javax.swing.table.AbstractTableModel", "$.TableCellRenderer", "java.util.ArrayList", "$.HashMap"], "jalview.util.TableSorter", ["java.awt.Color", "java.util.Arrays", "javax.swing.JLabel", "javax.swing.event.TableModelEvent"], function () { -c$ = Clazz.decorateAsClass (function () { -this.tableModel = null; -this.viewToModel = null; -this.modelToView = null; -this.tableHeader = null; -this.mouseListener = null; -this.tableModelListener = null; -this.columnComparators = null; -this.sortingColumns = null; -if (!Clazz.isClassDefined ("jalview.util.TableSorter.Row")) { -jalview.util.TableSorter.$TableSorter$Row$ (); -} -if (!Clazz.isClassDefined ("jalview.util.TableSorter.TableModelHandler")) { -jalview.util.TableSorter.$TableSorter$TableModelHandler$ (); -} -if (!Clazz.isClassDefined ("jalview.util.TableSorter.MouseHandler")) { -jalview.util.TableSorter.$TableSorter$MouseHandler$ (); -} -if (!Clazz.isClassDefined ("jalview.util.TableSorter.SortableHeaderRenderer")) { -jalview.util.TableSorter.$TableSorter$SortableHeaderRenderer$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.util, "TableSorter", javax.swing.table.AbstractTableModel); -Clazz.prepareFields (c$, function () { -this.columnComparators = new java.util.HashMap (); -this.sortingColumns = new java.util.ArrayList (); -}); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.util.TableSorter, []); -this.mouseListener = Clazz.innerTypeInstance (jalview.util.TableSorter.MouseHandler, this, null); -this.tableModelListener = Clazz.innerTypeInstance (jalview.util.TableSorter.TableModelHandler, this, null); -}); -Clazz.makeConstructor (c$, -function (tableModel) { -this.construct (); -this.setTableModel (tableModel); -}, "javax.swing.table.TableModel"); -Clazz.makeConstructor (c$, -function (tableModel, tableHeader) { -this.construct (); -this.setTableHeader (tableHeader); -this.setTableModel (tableModel); -}, "javax.swing.table.TableModel,javax.swing.table.JTableHeader"); -Clazz.defineMethod (c$, "clearSortingState", - function () { -this.viewToModel = null; -this.modelToView = null; -}); -Clazz.defineMethod (c$, "getTableModel", -function () { -return this.tableModel; -}); -Clazz.defineMethod (c$, "setTableModel", -function (tableModel) { -if (this.tableModel != null) { -this.tableModel.removeTableModelListener (this.tableModelListener); -}this.tableModel = tableModel; -if (this.tableModel != null) { -this.tableModel.addTableModelListener (this.tableModelListener); -}this.clearSortingState (); -this.fireTableStructureChanged (); -}, "javax.swing.table.TableModel"); -Clazz.defineMethod (c$, "getTableHeader", -function () { -return this.tableHeader; -}); -Clazz.defineMethod (c$, "setTableHeader", -function (tableHeader) { -if (this.tableHeader != null) { -this.tableHeader.removeMouseListener (this.mouseListener); -var defaultRenderer = this.tableHeader.getDefaultRenderer (); -if (Clazz.instanceOf (defaultRenderer, jalview.util.TableSorter.SortableHeaderRenderer)) { -this.tableHeader.setDefaultRenderer ((defaultRenderer).tableCellRenderer); -}}this.tableHeader = tableHeader; -if (this.tableHeader != null) { -this.tableHeader.addMouseListener (this.mouseListener); -this.tableHeader.setDefaultRenderer (Clazz.innerTypeInstance (jalview.util.TableSorter.SortableHeaderRenderer, this, null, this.tableHeader.getDefaultRenderer ())); -}}, "javax.swing.table.JTableHeader"); -Clazz.defineMethod (c$, "isSorting", -function () { -return this.sortingColumns.size () != 0; -}); -Clazz.defineMethod (c$, "getDirective", - function (column) { -for (var i = 0; i < this.sortingColumns.size (); i++) { -var directive = this.sortingColumns.get (i); -if (directive.column == column) { -return directive; -}} -return jalview.util.TableSorter.EMPTY_DIRECTIVE; -}, "~N"); -Clazz.defineMethod (c$, "getSortingStatus", -function (column) { -return this.getDirective (column).direction; -}, "~N"); -Clazz.defineMethod (c$, "sortingStatusChanged", - function () { -this.clearSortingState (); -this.fireTableDataChanged (); -if (this.tableHeader != null) { -this.tableHeader.repaint (); -}}); -Clazz.defineMethod (c$, "setSortingStatus", -function (column, status) { -var directive = this.getDirective (column); -if (directive !== jalview.util.TableSorter.EMPTY_DIRECTIVE) { -this.sortingColumns.remove (directive); -}if (status != 0) { -this.sortingColumns.add ( new jalview.util.TableSorter.Directive (column, status)); -}this.sortingStatusChanged (); -}, "~N,~N"); -Clazz.defineMethod (c$, "getHeaderRendererIcon", -function (column, size) { -var directive = this.getDirective (column); -if (directive === jalview.util.TableSorter.EMPTY_DIRECTIVE) { -return null; -}return new jalview.util.TableSorter.Arrow (directive.direction == -1, size, this.sortingColumns.indexOf (directive)); -}, "~N,~N"); -Clazz.defineMethod (c$, "cancelSorting", - function () { -this.sortingColumns.clear (); -this.sortingStatusChanged (); -}); -Clazz.defineMethod (c$, "setColumnComparator", -function (type, comparator) { -if (comparator == null) { -this.columnComparators.remove (type); -} else { -this.columnComparators.put (type, comparator); -}}, "Class,java.util.Comparator"); -Clazz.defineMethod (c$, "getComparator", -function (column) { -var columnType = this.tableModel.getColumnClass (column); -var comparator = this.columnComparators.get (columnType); -if (comparator != null) { -return comparator; -}if (Comparable.isAssignableFrom (columnType)) { -return jalview.util.TableSorter.COMPARABLE_COMAPRATOR; -}return jalview.util.TableSorter.LEXICAL_COMPARATOR; -}, "~N"); -Clazz.defineMethod (c$, "getViewToModel", - function () { -if (this.viewToModel == null) { -var tableModelRowCount = this.tableModel.getRowCount (); -this.viewToModel = new Array (tableModelRowCount); -for (var row = 0; row < tableModelRowCount; row++) { -this.viewToModel[row] = Clazz.innerTypeInstance (jalview.util.TableSorter.Row, this, null, row); -} -if (this.isSorting ()) { -java.util.Arrays.sort (this.viewToModel); -}}return this.viewToModel; -}); -Clazz.defineMethod (c$, "modelIndex", -function (viewIndex) { -return this.getViewToModel ()[viewIndex].modelIndex; -}, "~N"); -Clazz.defineMethod (c$, "getModelToView", - function () { -if (this.modelToView == null) { -var n = this.getViewToModel ().length; -this.modelToView = Clazz.newIntArray (n, 0); -for (var i = 0; i < n; i++) { -this.modelToView[this.modelIndex (i)] = i; -} -}return this.modelToView; -}); -Clazz.defineMethod (c$, "getRowCount", -function () { -return (this.tableModel == null) ? 0 : this.tableModel.getRowCount (); -}); -Clazz.defineMethod (c$, "getColumnCount", -function () { -return (this.tableModel == null) ? 0 : this.tableModel.getColumnCount (); -}); -Clazz.overrideMethod (c$, "getColumnName", -function (column) { -return this.tableModel.getColumnName (column); -}, "~N"); -Clazz.overrideMethod (c$, "getColumnClass", -function (column) { -return this.tableModel.getColumnClass (column); -}, "~N"); -Clazz.overrideMethod (c$, "isCellEditable", -function (row, column) { -return this.tableModel.isCellEditable (this.modelIndex (row), column); -}, "~N,~N"); -Clazz.defineMethod (c$, "getValueAt", -function (row, column) { -return this.tableModel.getValueAt (this.modelIndex (row), column); -}, "~N,~N"); -Clazz.overrideMethod (c$, "setValueAt", -function (aValue, row, column) { -this.tableModel.setValueAt (aValue, this.modelIndex (row), column); -}, "~O,~N,~N"); -c$.$TableSorter$Row$ = function () { -Clazz.pu$h(self.c$); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.modelIndex = 0; -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "Row", null, Comparable); -Clazz.makeConstructor (c$, -function (a) { -this.modelIndex = a; -}, "~N"); -Clazz.overrideMethod (c$, "compareTo", -function (a) { -var b = this.modelIndex; -var c = (a).modelIndex; -for (var d = this.b$["jalview.util.TableSorter"].sortingColumns.iterator (); d.hasNext (); ) { -var e = d.next (); -var f = e.column; -var g = this.b$["jalview.util.TableSorter"].tableModel.getValueAt (b, f); -var h = this.b$["jalview.util.TableSorter"].tableModel.getValueAt (c, f); -var i = 0; -if (g == null && h == null) { -i = 0; -} else if (g == null) { -i = -1; -} else if (h == null) { -i = 1; -} else { -i = this.b$["jalview.util.TableSorter"].getComparator (f).compare (g, h); -}if (i != 0) { -return e.direction == -1 ? -i : i; -}} -return 0; -}, "~O"); -c$ = Clazz.p0p (); -}; -c$.$TableSorter$TableModelHandler$ = function () { -Clazz.pu$h(self.c$); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "TableModelHandler", null, javax.swing.event.TableModelListener); -Clazz.overrideMethod (c$, "tableChanged", -function (a) { -if (!this.b$["jalview.util.TableSorter"].isSorting ()) { -this.b$["jalview.util.TableSorter"].clearSortingState (); -this.b$["jalview.util.TableSorter"].fireTableChanged (a); -return; -}if (a.getFirstRow () == -1) { -this.b$["jalview.util.TableSorter"].cancelSorting (); -this.b$["jalview.util.TableSorter"].fireTableChanged (a); -return; -}var b = a.getColumn (); -if (a.getFirstRow () == a.getLastRow () && b != -1 && this.b$["jalview.util.TableSorter"].getSortingStatus (b) == 0 && this.b$["jalview.util.TableSorter"].modelToView != null) { -var c = this.b$["jalview.util.TableSorter"].getModelToView ()[a.getFirstRow ()]; -this.b$["jalview.util.TableSorter"].fireTableChanged ( new javax.swing.event.TableModelEvent (this.b$["jalview.util.TableSorter"], c, c, b, a.getType ())); -return; -}this.b$["jalview.util.TableSorter"].clearSortingState (); -this.b$["jalview.util.TableSorter"].fireTableDataChanged (); -return; -}, "javax.swing.event.TableModelEvent"); -c$ = Clazz.p0p (); -}; -c$.$TableSorter$MouseHandler$ = function () { -Clazz.pu$h(self.c$); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "MouseHandler", java.awt.event.MouseAdapter); -Clazz.overrideMethod (c$, "mouseClicked", -function (a) { -var b = a.getSource (); -var c = b.getColumnModel (); -var d = c.getColumnIndexAtX (a.getX ()); -var e = c.getColumn (d).getModelIndex (); -if (e != -1) { -var f = this.b$["jalview.util.TableSorter"].getSortingStatus (e); -if (!a.isControlDown ()) { -this.b$["jalview.util.TableSorter"].cancelSorting (); -}f = f + (a.isShiftDown () ? -1 : 1); -f = (f + 4) % 3 - 1; -this.b$["jalview.util.TableSorter"].setSortingStatus (e, f); -}}, "java.awt.event.MouseEvent"); -c$ = Clazz.p0p (); -}; -c$.$TableSorter$SortableHeaderRenderer$ = function () { -Clazz.pu$h(self.c$); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.tableCellRenderer = null; -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "SortableHeaderRenderer", null, javax.swing.table.TableCellRenderer); -Clazz.makeConstructor (c$, -function (a) { -this.tableCellRenderer = a; -}, "javax.swing.table.TableCellRenderer"); -Clazz.defineMethod (c$, "getTableCellRendererComponent", -function (a, b, c, d, e, f) { -var g = this.tableCellRenderer.getTableCellRendererComponent (a, b, c, d, e, f); -if (Clazz.instanceOf (g, javax.swing.JLabel)) { -var h = g; -h.setHorizontalTextPosition (2); -var i = a.convertColumnIndexToModel (f); -h.setIcon (this.b$["jalview.util.TableSorter"].getHeaderRendererIcon (i, h.getFont ().getSize ())); -}return g; -}, "javax.swing.JTable,~O,~B,~B,~N,~N"); -c$ = Clazz.p0p (); -}; -c$.$TableSorter$1$ = function () { -Clazz.pu$h(self.c$); -c$ = Clazz.declareAnonymous (jalview.util, "TableSorter$1", null, java.util.Comparator); -Clazz.defineMethod (c$, "compare", -function (o1, o2) { -return (o1).compareTo (o2); -}, "~O,~O"); -c$ = Clazz.p0p (); -}; -c$.$TableSorter$2$ = function () { -Clazz.pu$h(self.c$); -c$ = Clazz.declareAnonymous (jalview.util, "TableSorter$2", null, java.util.Comparator); -Clazz.defineMethod (c$, "compare", -function (o1, o2) { -return o1.toString ().compareTo (o2.toString ()); -}, "~O,~O"); -c$ = Clazz.p0p (); -}; -Clazz.pu$h(self.c$); -c$ = Clazz.decorateAsClass (function () { -this.descending = false; -this.size = 0; -this.priority = 0; -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "Arrow", null, javax.swing.Icon); -Clazz.makeConstructor (c$, -function (a, b, c) { -this.descending = a; -this.size = b; -this.priority = c; -}, "~B,~N,~N"); -Clazz.overrideMethod (c$, "paintIcon", -function (a, b, c, d) { -var e = a == null ? java.awt.Color.GRAY : a.getBackground (); -var f = Clazz.doubleToInt (Clazz.doubleToInt (this.size / 2) * Math.pow (0.8, this.priority)); -var g = this.descending ? f : -f; -d = d + Clazz.doubleToInt (5 * this.size / 6) + (this.descending ? -g : 0); -var h = this.descending ? 1 : -1; -b.translate (c, d); -b.setColor (e.darker ()); -b.drawLine (Clazz.doubleToInt (f / 2), g, 0, 0); -b.drawLine (Clazz.doubleToInt (f / 2), g + h, 0, h); -b.setColor (e.brighter ()); -b.drawLine (Clazz.doubleToInt (f / 2), g, f, 0); -b.drawLine (Clazz.doubleToInt (f / 2), g + h, f, h); -if (this.descending) { -b.setColor (e.darker ().darker ()); -} else { -b.setColor (e.brighter ().brighter ()); -}b.drawLine (f, 0, 0, 0); -b.setColor (e); -b.translate (-c, -d); -}, "java.awt.Component,java.awt.Graphics,~N,~N"); -Clazz.overrideMethod (c$, "getIconWidth", -function () { -return this.size; -}); -Clazz.overrideMethod (c$, "getIconHeight", -function () { -return this.size; -}); -c$ = Clazz.p0p (); -Clazz.pu$h(self.c$); -c$ = Clazz.decorateAsClass (function () { -this.column = 0; -this.direction = 0; -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "Directive"); -Clazz.makeConstructor (c$, -function (a, b) { -this.column = a; -this.direction = b; -}, "~N,~N"); -c$ = Clazz.p0p (); -Clazz.defineStatics (c$, -"DESCENDING", -1, -"NOT_SORTED", 0, -"ASCENDING", 1); -c$.EMPTY_DIRECTIVE = c$.prototype.EMPTY_DIRECTIVE = new jalview.util.TableSorter.Directive (-1, 0); -c$.COMPARABLE_COMAPRATOR = c$.prototype.COMPARABLE_COMAPRATOR = ((Clazz.isClassDefined ("jalview.util.TableSorter$1") ? 0 : jalview.util.TableSorter.$TableSorter$1$ ()), Clazz.innerTypeInstance (jalview.util.TableSorter$1, this, null)); -c$.LEXICAL_COMPARATOR = c$.prototype.LEXICAL_COMPARATOR = ((Clazz.isClassDefined ("jalview.util.TableSorter$2") ? 0 : jalview.util.TableSorter.$TableSorter$2$ ()), Clazz.innerTypeInstance (jalview.util.TableSorter$2, this, null)); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (["java.awt.event.MouseAdapter", "javax.swing.Icon", "javax.swing.event.TableModelListener", "javax.swing.table.AbstractTableModel", "$.TableCellRenderer", "java.util.ArrayList", "$.HashMap"], "jalview.util.TableSorter", ["java.awt.Color", "java.util.Arrays", "javax.swing.JLabel", "javax.swing.event.TableModelEvent"], function () { +c$ = Clazz.decorateAsClass (function () { +this.tableModel = null; +this.viewToModel = null; +this.modelToView = null; +this.tableHeader = null; +this.mouseListener = null; +this.tableModelListener = null; +this.columnComparators = null; +this.sortingColumns = null; +if (!Clazz.isClassDefined ("jalview.util.TableSorter.Row")) { +jalview.util.TableSorter.$TableSorter$Row$ (); +} +if (!Clazz.isClassDefined ("jalview.util.TableSorter.TableModelHandler")) { +jalview.util.TableSorter.$TableSorter$TableModelHandler$ (); +} +if (!Clazz.isClassDefined ("jalview.util.TableSorter.MouseHandler")) { +jalview.util.TableSorter.$TableSorter$MouseHandler$ (); +} +if (!Clazz.isClassDefined ("jalview.util.TableSorter.SortableHeaderRenderer")) { +jalview.util.TableSorter.$TableSorter$SortableHeaderRenderer$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.util, "TableSorter", javax.swing.table.AbstractTableModel); +Clazz.prepareFields (c$, function () { +this.columnComparators = new java.util.HashMap (); +this.sortingColumns = new java.util.ArrayList (); +}); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.util.TableSorter, []); +this.mouseListener = Clazz.innerTypeInstance (jalview.util.TableSorter.MouseHandler, this, null); +this.tableModelListener = Clazz.innerTypeInstance (jalview.util.TableSorter.TableModelHandler, this, null); +}); +Clazz.makeConstructor (c$, +function (tableModel) { +this.construct (); +this.setTableModel (tableModel); +}, "javax.swing.table.TableModel"); +Clazz.makeConstructor (c$, +function (tableModel, tableHeader) { +this.construct (); +this.setTableHeader (tableHeader); +this.setTableModel (tableModel); +}, "javax.swing.table.TableModel,javax.swing.table.JTableHeader"); +Clazz.defineMethod (c$, "clearSortingState", + function () { +this.viewToModel = null; +this.modelToView = null; +}); +Clazz.defineMethod (c$, "getTableModel", +function () { +return this.tableModel; +}); +Clazz.defineMethod (c$, "setTableModel", +function (tableModel) { +if (this.tableModel != null) { +this.tableModel.removeTableModelListener (this.tableModelListener); +}this.tableModel = tableModel; +if (this.tableModel != null) { +this.tableModel.addTableModelListener (this.tableModelListener); +}this.clearSortingState (); +this.fireTableStructureChanged (); +}, "javax.swing.table.TableModel"); +Clazz.defineMethod (c$, "getTableHeader", +function () { +return this.tableHeader; +}); +Clazz.defineMethod (c$, "setTableHeader", +function (tableHeader) { +if (this.tableHeader != null) { +this.tableHeader.removeMouseListener (this.mouseListener); +var defaultRenderer = this.tableHeader.getDefaultRenderer (); +if (Clazz.instanceOf (defaultRenderer, jalview.util.TableSorter.SortableHeaderRenderer)) { +this.tableHeader.setDefaultRenderer ((defaultRenderer).tableCellRenderer); +}}this.tableHeader = tableHeader; +if (this.tableHeader != null) { +this.tableHeader.addMouseListener (this.mouseListener); +this.tableHeader.setDefaultRenderer (Clazz.innerTypeInstance (jalview.util.TableSorter.SortableHeaderRenderer, this, null, this.tableHeader.getDefaultRenderer ())); +}}, "javax.swing.table.JTableHeader"); +Clazz.defineMethod (c$, "isSorting", +function () { +return this.sortingColumns.size () != 0; +}); +Clazz.defineMethod (c$, "getDirective", + function (column) { +for (var i = 0; i < this.sortingColumns.size (); i++) { +var directive = this.sortingColumns.get (i); +if (directive.column == column) { +return directive; +}} +return jalview.util.TableSorter.EMPTY_DIRECTIVE; +}, "~N"); +Clazz.defineMethod (c$, "getSortingStatus", +function (column) { +return this.getDirective (column).direction; +}, "~N"); +Clazz.defineMethod (c$, "sortingStatusChanged", + function () { +this.clearSortingState (); +this.fireTableDataChanged (); +if (this.tableHeader != null) { +this.tableHeader.repaint (); +}}); +Clazz.defineMethod (c$, "setSortingStatus", +function (column, status) { +var directive = this.getDirective (column); +if (directive !== jalview.util.TableSorter.EMPTY_DIRECTIVE) { +this.sortingColumns.remove (directive); +}if (status != 0) { +this.sortingColumns.add ( new jalview.util.TableSorter.Directive (column, status)); +}this.sortingStatusChanged (); +}, "~N,~N"); +Clazz.defineMethod (c$, "getHeaderRendererIcon", +function (column, size) { +var directive = this.getDirective (column); +if (directive === jalview.util.TableSorter.EMPTY_DIRECTIVE) { +return null; +}return new jalview.util.TableSorter.Arrow (directive.direction == -1, size, this.sortingColumns.indexOf (directive)); +}, "~N,~N"); +Clazz.defineMethod (c$, "cancelSorting", + function () { +this.sortingColumns.clear (); +this.sortingStatusChanged (); +}); +Clazz.defineMethod (c$, "setColumnComparator", +function (type, comparator) { +if (comparator == null) { +this.columnComparators.remove (type); +} else { +this.columnComparators.put (type, comparator); +}}, "Class,java.util.Comparator"); +Clazz.defineMethod (c$, "getComparator", +function (column) { +var columnType = this.tableModel.getColumnClass (column); +var comparator = this.columnComparators.get (columnType); +if (comparator != null) { +return comparator; +}if (Comparable.isAssignableFrom (columnType)) { +return jalview.util.TableSorter.COMPARABLE_COMAPRATOR; +}return jalview.util.TableSorter.LEXICAL_COMPARATOR; +}, "~N"); +Clazz.defineMethod (c$, "getViewToModel", + function () { +if (this.viewToModel == null) { +var tableModelRowCount = this.tableModel.getRowCount (); +this.viewToModel = new Array (tableModelRowCount); +for (var row = 0; row < tableModelRowCount; row++) { +this.viewToModel[row] = Clazz.innerTypeInstance (jalview.util.TableSorter.Row, this, null, row); +} +if (this.isSorting ()) { +java.util.Arrays.sort (this.viewToModel); +}}return this.viewToModel; +}); +Clazz.defineMethod (c$, "modelIndex", +function (viewIndex) { +return this.getViewToModel ()[viewIndex].modelIndex; +}, "~N"); +Clazz.defineMethod (c$, "getModelToView", + function () { +if (this.modelToView == null) { +var n = this.getViewToModel ().length; +this.modelToView = Clazz.newIntArray (n, 0); +for (var i = 0; i < n; i++) { +this.modelToView[this.modelIndex (i)] = i; +} +}return this.modelToView; +}); +Clazz.defineMethod (c$, "getRowCount", +function () { +return (this.tableModel == null) ? 0 : this.tableModel.getRowCount (); +}); +Clazz.defineMethod (c$, "getColumnCount", +function () { +return (this.tableModel == null) ? 0 : this.tableModel.getColumnCount (); +}); +Clazz.overrideMethod (c$, "getColumnName", +function (column) { +return this.tableModel.getColumnName (column); +}, "~N"); +Clazz.overrideMethod (c$, "getColumnClass", +function (column) { +return this.tableModel.getColumnClass (column); +}, "~N"); +Clazz.overrideMethod (c$, "isCellEditable", +function (row, column) { +return this.tableModel.isCellEditable (this.modelIndex (row), column); +}, "~N,~N"); +Clazz.defineMethod (c$, "getValueAt", +function (row, column) { +return this.tableModel.getValueAt (this.modelIndex (row), column); +}, "~N,~N"); +Clazz.overrideMethod (c$, "setValueAt", +function (aValue, row, column) { +this.tableModel.setValueAt (aValue, this.modelIndex (row), column); +}, "~O,~N,~N"); +c$.$TableSorter$Row$ = function () { +Clazz.pu$h(self.c$); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.modelIndex = 0; +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "Row", null, Comparable); +Clazz.makeConstructor (c$, +function (a) { +this.modelIndex = a; +}, "~N"); +Clazz.overrideMethod (c$, "compareTo", +function (a) { +var b = this.modelIndex; +var c = (a).modelIndex; +for (var d = this.b$["jalview.util.TableSorter"].sortingColumns.iterator (); d.hasNext (); ) { +var e = d.next (); +var f = e.column; +var g = this.b$["jalview.util.TableSorter"].tableModel.getValueAt (b, f); +var h = this.b$["jalview.util.TableSorter"].tableModel.getValueAt (c, f); +var i = 0; +if (g == null && h == null) { +i = 0; +} else if (g == null) { +i = -1; +} else if (h == null) { +i = 1; +} else { +i = this.b$["jalview.util.TableSorter"].getComparator (f).compare (g, h); +}if (i != 0) { +return e.direction == -1 ? -i : i; +}} +return 0; +}, "~O"); +c$ = Clazz.p0p (); +}; +c$.$TableSorter$TableModelHandler$ = function () { +Clazz.pu$h(self.c$); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "TableModelHandler", null, javax.swing.event.TableModelListener); +Clazz.overrideMethod (c$, "tableChanged", +function (a) { +if (!this.b$["jalview.util.TableSorter"].isSorting ()) { +this.b$["jalview.util.TableSorter"].clearSortingState (); +this.b$["jalview.util.TableSorter"].fireTableChanged (a); +return; +}if (a.getFirstRow () == -1) { +this.b$["jalview.util.TableSorter"].cancelSorting (); +this.b$["jalview.util.TableSorter"].fireTableChanged (a); +return; +}var b = a.getColumn (); +if (a.getFirstRow () == a.getLastRow () && b != -1 && this.b$["jalview.util.TableSorter"].getSortingStatus (b) == 0 && this.b$["jalview.util.TableSorter"].modelToView != null) { +var c = this.b$["jalview.util.TableSorter"].getModelToView ()[a.getFirstRow ()]; +this.b$["jalview.util.TableSorter"].fireTableChanged ( new javax.swing.event.TableModelEvent (this.b$["jalview.util.TableSorter"], c, c, b, a.getType ())); +return; +}this.b$["jalview.util.TableSorter"].clearSortingState (); +this.b$["jalview.util.TableSorter"].fireTableDataChanged (); +return; +}, "javax.swing.event.TableModelEvent"); +c$ = Clazz.p0p (); +}; +c$.$TableSorter$MouseHandler$ = function () { +Clazz.pu$h(self.c$); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "MouseHandler", java.awt.event.MouseAdapter); +Clazz.overrideMethod (c$, "mouseClicked", +function (a) { +var b = a.getSource (); +var c = b.getColumnModel (); +var d = c.getColumnIndexAtX (a.getX ()); +var e = c.getColumn (d).getModelIndex (); +if (e != -1) { +var f = this.b$["jalview.util.TableSorter"].getSortingStatus (e); +if (!a.isControlDown ()) { +this.b$["jalview.util.TableSorter"].cancelSorting (); +}f = f + (a.isShiftDown () ? -1 : 1); +f = (f + 4) % 3 - 1; +this.b$["jalview.util.TableSorter"].setSortingStatus (e, f); +}}, "java.awt.event.MouseEvent"); +c$ = Clazz.p0p (); +}; +c$.$TableSorter$SortableHeaderRenderer$ = function () { +Clazz.pu$h(self.c$); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.tableCellRenderer = null; +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "SortableHeaderRenderer", null, javax.swing.table.TableCellRenderer); +Clazz.makeConstructor (c$, +function (a) { +this.tableCellRenderer = a; +}, "javax.swing.table.TableCellRenderer"); +Clazz.defineMethod (c$, "getTableCellRendererComponent", +function (a, b, c, d, e, f) { +var g = this.tableCellRenderer.getTableCellRendererComponent (a, b, c, d, e, f); +if (Clazz.instanceOf (g, javax.swing.JLabel)) { +var h = g; +h.setHorizontalTextPosition (2); +var i = a.convertColumnIndexToModel (f); +h.setIcon (this.b$["jalview.util.TableSorter"].getHeaderRendererIcon (i, h.getFont ().getSize ())); +}return g; +}, "javax.swing.JTable,~O,~B,~B,~N,~N"); +c$ = Clazz.p0p (); +}; +c$.$TableSorter$1$ = function () { +Clazz.pu$h(self.c$); +c$ = Clazz.declareAnonymous (jalview.util, "TableSorter$1", null, java.util.Comparator); +Clazz.defineMethod (c$, "compare", +function (o1, o2) { +return (o1).compareTo (o2); +}, "~O,~O"); +c$ = Clazz.p0p (); +}; +c$.$TableSorter$2$ = function () { +Clazz.pu$h(self.c$); +c$ = Clazz.declareAnonymous (jalview.util, "TableSorter$2", null, java.util.Comparator); +Clazz.defineMethod (c$, "compare", +function (o1, o2) { +return o1.toString ().compareTo (o2.toString ()); +}, "~O,~O"); +c$ = Clazz.p0p (); +}; +Clazz.pu$h(self.c$); +c$ = Clazz.decorateAsClass (function () { +this.descending = false; +this.size = 0; +this.priority = 0; +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "Arrow", null, javax.swing.Icon); +Clazz.makeConstructor (c$, +function (a, b, c) { +this.descending = a; +this.size = b; +this.priority = c; +}, "~B,~N,~N"); +Clazz.overrideMethod (c$, "paintIcon", +function (a, b, c, d) { +var e = a == null ? java.awt.Color.GRAY : a.getBackground (); +var f = Clazz.doubleToInt (Clazz.doubleToInt (this.size / 2) * Math.pow (0.8, this.priority)); +var g = this.descending ? f : -f; +d = d + Clazz.doubleToInt (5 * this.size / 6) + (this.descending ? -g : 0); +var h = this.descending ? 1 : -1; +b.translate (c, d); +b.setColor (e.darker ()); +b.drawLine (Clazz.doubleToInt (f / 2), g, 0, 0); +b.drawLine (Clazz.doubleToInt (f / 2), g + h, 0, h); +b.setColor (e.brighter ()); +b.drawLine (Clazz.doubleToInt (f / 2), g, f, 0); +b.drawLine (Clazz.doubleToInt (f / 2), g + h, f, h); +if (this.descending) { +b.setColor (e.darker ().darker ()); +} else { +b.setColor (e.brighter ().brighter ()); +}b.drawLine (f, 0, 0, 0); +b.setColor (e); +b.translate (-c, -d); +}, "java.awt.Component,java.awt.Graphics,~N,~N"); +Clazz.overrideMethod (c$, "getIconWidth", +function () { +return this.size; +}); +Clazz.overrideMethod (c$, "getIconHeight", +function () { +return this.size; +}); +c$ = Clazz.p0p (); +Clazz.pu$h(self.c$); +c$ = Clazz.decorateAsClass (function () { +this.column = 0; +this.direction = 0; +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "Directive"); +Clazz.makeConstructor (c$, +function (a, b) { +this.column = a; +this.direction = b; +}, "~N,~N"); +c$ = Clazz.p0p (); +Clazz.defineStatics (c$, +"DESCENDING", -1, +"NOT_SORTED", 0, +"ASCENDING", 1); +c$.EMPTY_DIRECTIVE = c$.prototype.EMPTY_DIRECTIVE = new jalview.util.TableSorter.Directive (-1, 0); +c$.COMPARABLE_COMAPRATOR = c$.prototype.COMPARABLE_COMAPRATOR = ((Clazz.isClassDefined ("jalview.util.TableSorter$1") ? 0 : jalview.util.TableSorter.$TableSorter$1$ ()), Clazz.innerTypeInstance (jalview.util.TableSorter$1, this, null)); +c$.LEXICAL_COMPARATOR = c$.prototype.LEXICAL_COMPARATOR = ((Clazz.isClassDefined ("jalview.util.TableSorter$2") ? 0 : jalview.util.TableSorter.$TableSorter$2$ ()), Clazz.innerTypeInstance (jalview.util.TableSorter$2, this, null)); +});