You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.0 KiB
37 lines
1.0 KiB
package com.fr.design.debug.remote; |
|
|
|
import com.fine.theme.light.ui.FineTableHeaderUI; |
|
|
|
import java.awt.Color; |
|
|
|
import static com.fr.design.debug.remote.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()); |
|
} |
|
}
|
|
|