Destiny.Lin
1 month ago
12 changed files with 151 additions and 9 deletions
@ -0,0 +1,52 @@
|
||||
package com.fr.design.remote.ui.debug; |
||||
|
||||
import com.fine.theme.icon.LazyIcon; |
||||
import com.fine.theme.light.ui.FineTableHeaderUI; |
||||
|
||||
import javax.swing.Icon; |
||||
import javax.swing.JTable; |
||||
import javax.swing.RowSorter; |
||||
import javax.swing.SortOrder; |
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* 远程调试界面表头 |
||||
* |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2024/10/17 |
||||
*/ |
||||
public class HeaderRenderer extends FineTableHeaderUI.TableHeaderRenderer { |
||||
private final Icon ascendingIcon = new LazyIcon("sort_asc"); |
||||
private final Icon descendingIcon = new LazyIcon("sort_desc"); |
||||
private final Icon nosortIcon = new LazyIcon("nosort"); |
||||
|
||||
|
||||
@Override |
||||
public Component getTableCellRendererComponent(JTable table, Object value, |
||||
boolean isSelected, boolean hasFocus, |
||||
int row, int col) { |
||||
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); |
||||
|
||||
int modelColumn = table.convertColumnIndexToModel(col); |
||||
setIcon(null); |
||||
RemoteDesignNetWorkTableRowSorter sorter = (RemoteDesignNetWorkTableRowSorter) table.getRowSorter(); |
||||
|
||||
if (!sorter.isSortable(modelColumn)) { |
||||
return this; |
||||
} |
||||
SortOrder sortOrder = sorter.getSortKeys().stream() |
||||
.filter(key -> key.getColumn() == modelColumn) |
||||
.map(RowSorter.SortKey::getSortOrder) |
||||
.findFirst() |
||||
.orElse(null); |
||||
if (sortOrder == SortOrder.ASCENDING) { |
||||
setIcon(ascendingIcon); |
||||
} else if (sortOrder == SortOrder.DESCENDING) { |
||||
setIcon(descendingIcon); |
||||
} else { |
||||
setIcon(nosortIcon); |
||||
} |
||||
return this; |
||||
} |
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.fr.design.remote.ui.debug; |
||||
|
||||
import com.fine.theme.light.ui.FineTableHeaderUI; |
||||
|
||||
import java.awt.Color; |
||||
|
||||
import static com.fr.design.remote.ui.debug.RemoteDesignNetWorkHelper.DEFAULT_COLOR; |
||||
|
||||
/** |
||||
* 大小多颜色渲染 |
||||
* |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2024/10/16 |
||||
*/ |
||||
public class SizeColorCellRenderer extends FineTableHeaderUI.TableRenderer { |
||||
private static final int UNIT_BYTES = 1024; |
||||
private static final int SIZE_MIDDLE = UNIT_BYTES * 100; |
||||
private static final int SIZE_LARGE = UNIT_BYTES * 200; |
||||
|
||||
|
||||
@Override |
||||
protected void setValue(Object value) { |
||||
|
||||
if (value instanceof String) { |
||||
long parsed = RemoteDesignNetWorkHelper.parseSizeToBytes((String) value); |
||||
if (parsed > SIZE_LARGE) { |
||||
setForeground(Color.RED); |
||||
} else if (parsed > SIZE_MIDDLE) { |
||||
setForeground(Color.ORANGE); |
||||
} else { |
||||
setForeground(DEFAULT_COLOR); |
||||
} |
||||
} |
||||
setText((value == null) ? "" : value.toString()); |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.design.remote.ui.debug; |
||||
|
||||
import com.fine.theme.light.ui.FineTableHeaderUI; |
||||
|
||||
import java.awt.Color; |
||||
|
||||
import static com.fr.design.remote.ui.debug.RemoteDesignNetWorkHelper.DEFAULT_COLOR; |
||||
|
||||
/** |
||||
* 时间多颜色渲染 |
||||
* |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2024/10/16 |
||||
*/ |
||||
public class TimeColorCellRenderer extends FineTableHeaderUI.TableRenderer { |
||||
|
||||
private static final int SIZE_MIDDLE = 1000; |
||||
private static final int SIZE_LARGE = 5000; |
||||
|
||||
|
||||
|
||||
@Override |
||||
protected void setValue(Object value) { |
||||
|
||||
if (value instanceof String) { |
||||
long parsed = RemoteDesignNetWorkHelper.parseCostToMS((String) value); |
||||
if (parsed > SIZE_LARGE) { |
||||
setForeground(Color.RED); |
||||
} else if (parsed > SIZE_MIDDLE) { |
||||
setForeground(Color.ORANGE); |
||||
} else { |
||||
setForeground(DEFAULT_COLOR); |
||||
} |
||||
} |
||||
setText((value == null) ? "" : value.toString()); |
||||
} |
||||
} |
Loading…
Reference in new issue