本文整理汇总了Java中javax.swing.RowSorter.SortKey.getSortOrder方法的典型用法代码示例。如果您正苦于以下问题:Java SortKey.getSortOrder方法的具体用法?Java SortKey.getSortOrder怎么用?Java SortKey.getSortOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.RowSorter.SortKey
的用法示例。
在下文中一共展示了SortKey.getSortOrder方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIcon
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
/**
* Overloaded to return an icon suitable to the primary sorted column, or
* null if the column is not the primary sort key.
*
* @param table the <code>JTable</code>.
* @param column the column index.
* @return the sort icon, or null if the column is unsorted.
*/
protected Icon getIcon(JTable table, int column) {
SortKey sortKey = getSortKey(table, column);
if (sortKey != null && table.convertColumnIndexToView(sortKey.getColumn()) == column) {
switch (sortKey.getSortOrder()) {
case ASCENDING:
return UIManager.getIcon("Table.ascendingSortIcon");
case DESCENDING:
return UIManager.getIcon("Table.descendingSortIcon");
default:
// Just to remove unmatched case warning
}
}
return null;
}
示例2: sorterChanged
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
@Override
public void sorterChanged(RowSorterEvent e) {
if (e.getType() == Type.SORT_ORDER_CHANGED) {
@SuppressWarnings("unchecked")
List<? extends SortKey> sortKeys = e.getSource().getSortKeys();
Object[] keys = new Object[sortKeys.size()];
boolean[] directions = new boolean[sortKeys.size()];
int index = 0;
for (SortKey s : sortKeys) {
keys[index] = SwingTable.this.keys[s.getColumn()];
directions[index] = s.getSortOrder() == SortOrder.ASCENDING;
index++;
}
if (list instanceof Sortable) {
((Sortable) list).sort(keys, directions);
}
setOffset(0);
}
}
示例3: compareRows
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
public int compareRows(int row1, int row2) {
int order = 0;
for (int i = 0; i < criteria.size(); i++) {
SortKey key = criteria.get(i);
if (key.getSortOrder() != SortOrder.UNSORTED) {
Object o1 = model.getValueAt(row1, key.getColumn());
Object o2 = model.getValueAt(row2, key.getColumn());
if (o1 instanceof Comparable<?> && o2 instanceof Comparable<?>) {
Comparable<Object> c1 = (Comparable<Object>) o1;
Comparable<Object> c2 = (Comparable<Object>) o2;
order = c1.compareTo(c2);
} else if (o1 == null && o2 != null) {
order = 1;
} else if (o1 != null && o2 == null) {
order = -1;
}
order = key.getSortOrder() == SortOrder.DESCENDING ? -order : order;
if (order != 0) {
break;
}
}
}
return order;
}
示例4: isSameSorter
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
private boolean isSameSorter(List<? extends SortKey> sortKeys1,
List<? extends SortKey> sortKeys2) {
int size1 = (sortKeys1 == null) ? 0 : sortKeys1.size();
int size2 = (sortKeys2 == null) ? 0 : sortKeys2.size();
if ((size1 == 0) && (size2 == 0)) {
return true;
}
if ((sortKeys1 == null) && (sortKeys2 == null))
return true;
if ((sortKeys1 == null) || (sortKeys2 == null))
return false;
if (size1 != size2)
return false;
for (int i = 0; i < size1; i++) {
SortKey sortKey1 = sortKeys1.get(i);
SortKey sortKey2 = sortKeys2.get(i);
if ((sortKey1.getColumn() != sortKey2.getColumn())
|| (sortKey1.getSortOrder() != sortKey2.getSortOrder())) {
return false;
}
}
return true;
}
示例5: valueChanged
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void valueChanged(final ListSelectionEvent e) {
// fix for issue 478 - no animations when sorter has changed
List<? extends SortKey> sortKeys = (table.getRowSorter() == null) ? null
: table.getRowSorter().getSortKeys();
boolean isDifferentSorter = !isSameSorter(sortKeys, oldSortKeys);
if (e.getValueIsAdjusting() && isDifferentSorter)
return;
if (sortKeys == null) {
oldSortKeys = null;
} else {
oldSortKeys = new ArrayList<SortKey>();
for (SortKey sortKey : sortKeys) {
SortKey copy = new SortKey(sortKey.getColumn(),
sortKey.getSortOrder());
oldSortKeys.add(copy);
}
}
syncSelection(isDifferentSorter);
}
示例6: getIcon
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
@Override
public Icon getIcon() {
int modelCol = header.getTable().convertColumnIndexToModel(curCol);
TableModel model = header.getTable().getModel();
if (model instanceof ExtendedJTableSorterModel) {
ExtendedJTableSorterModel sortModel = (ExtendedJTableSorterModel) model;
switch (sortModel.getSortingStatus(modelCol)) {
case ExtendedJTableSorterModel.ASCENDING:
return UIManager.getIcon("Table.ascendingSortIcon");
case ExtendedJTableSorterModel.DESCENDING:
return UIManager.getIcon("Table.descendingSortIcon");
case ExtendedJTableSorterModel.NOT_SORTED:
default:
return null;
}
} else {
SortKey sortKey = getSortKey(header.getTable().getRowSorter(), modelCol);
SortOrder sortOrder = sortKey != null ? sortKey.getSortOrder() : SortOrder.UNSORTED;
switch (sortOrder) {
case ASCENDING:
return UIManager.getIcon("Table.ascendingSortIcon");
case DESCENDING:
return UIManager.getIcon("Table.descendingSortIcon");
case UNSORTED:
default:
return null;
}
}
}
示例7: rowSorterChanged
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
private void
rowSorterChanged() {
List<? extends SortKey> list = getRowSorter().getSortKeys();
if(list.isEmpty()) return;
SortKey k = list.get(0);
int i = k.getColumn() + 1;
if(k.getSortOrder() == SortOrder.UNSORTED) return;
if(k.getSortOrder() == SortOrder.DESCENDING) i *= -1;
preferences().setIntProperty(tablePrefix + "sortOrder", i);
}
示例8: getIcon
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
/**
* Overloaded to return an icon suitable to the primary sorted column, or null if
* the column is not the primary sort key.
*
* @param table the <code>JTable</code>.
* @param column the column index.
* @return the sort icon, or null if the column is unsorted.
*/
protected Icon getIcon(JTable table, int column) {
SortKey sortKey = getSortKey(table, column);
if (sortKey != null && table.convertColumnIndexToView(sortKey.getColumn()) == column) {
switch (sortKey.getSortOrder()) {
case ASCENDING:
return UIManager.getIcon("Table.ascendingSortIcon");
case DESCENDING:
return UIManager.getIcon("Table.descendingSortIcon");
}
}
return null;
}
示例9: getIcon
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
/**
* Overloaded to return an icon suitable to the primary sorted column, or
* null if the column is not the primary sort key.
*
* @param table the <code>JTable</code>.
* @param column the column index.
* @return the sort icon, or null if the column is unsorted.
*/
protected Icon getIcon(JTable table, int column) {
SortKey sortKey = getSortKey(table, column);
if (sortKey != null && table.convertColumnIndexToView(sortKey.getColumn()) == column) {
switch (sortKey.getSortOrder()) {
case ASCENDING:
return UIManager.getIcon("Table.ascendingSortIcon");
case DESCENDING:
return UIManager.getIcon("Table.descendingSortIcon");
}
}
return null;
}
示例10: getTableCellRendererComponent
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel comp = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
comp.setBackground(myBgColor);
comp.setHorizontalAlignment(JLabel.CENTER);
if (tooltip == null) {
comp.setToolTipText(GuiMessages.getString(value.toString()));
}
else {
comp.setToolTipText("<HTML>"+tooltip+"</HTML>");
}
comp.setIcon(null);
/*
if (dbTable != null) {
Vector<Integer> v = dbTable.getSortColumns();
if (v != null && v.size() > 0 && v.get(0) == column + 1) {
comp.setIcon(dbTable.isSortAscending() ? ascIcon : descIcon);
comp.repaint();
}
}
*/
if (table != null && table.getRowSorter() != null) { // && myBgColor != dbTable.getTable().getTableHeader().getBackground()
if (table.getRowSorter().getSortKeys().size() > 0) {
SortKey sk = table.getRowSorter().getSortKeys().get(0);
int sortCol = sk.getColumn();
//System.out.println(comp + "\tgetSortColumns\t" + sortCol);
if (column + 1 == sortCol) {
sk.getSortOrder();
comp.setIcon(sk.getSortOrder() == SortOrder.ASCENDING ? ascIcon : descIcon);
}
}
}
//comp.setText("W");
comp.setText(GuiMessages.getString(comp.getText()));
return comp;
}
示例11: hasSortOrder
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
private boolean hasSortOrder() {
@SuppressWarnings("unchecked")
TableRowSorter<ClipTableModel> sorter = ((TableRowSorter<ClipTableModel>) table.getRowSorter());
for (SortKey skey : sorter.getSortKeys()) {
if (skey.getSortOrder() != SortOrder.UNSORTED) return true;
}
return false;
}
示例12: nodeSorted
import javax.swing.RowSorter.SortKey; //导入方法依赖的package包/类
private void nodeSorted(TreePath path) {
if (!ignoreSortedChange) {
RowSorter<?> sorter = rowSorter.getRowSorter(path.getLastPathComponent());
SortKey key = sorter.getSortKeys().get(0);
if (key.getSortOrder() == SortOrder.UNSORTED) {
sortedPaths.remove(path);
} else {
sortedPaths.put(path, key);
}
updatePath(path, expandedDescendants(path));
if (getExpandsSortedNodes() && !isExpanded(path))
expandPath(path);
}
}