Fix row selection color for drag table
This commit is contained in:
parent
7a51055315
commit
9caaf4be59
@ -764,11 +764,12 @@ public class ComponentAnalysisGeneralPanel extends JPanel implements StateChange
|
|||||||
private class DragCellRenderer extends CustomCellRenderer {
|
private class DragCellRenderer extends CustomCellRenderer {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final StripedLabelUI stripedUI;
|
private final StripedLabelUI stripedUI;
|
||||||
private final LabelUI defaultUI = new BasicLabelUI();
|
private final LabelUI defaultUI;
|
||||||
|
|
||||||
public DragCellRenderer() {
|
public DragCellRenderer() {
|
||||||
super(dragData, 3);
|
super(dragData, 3);
|
||||||
this.stripedUI = new StripedLabelUI(1, 12);
|
this.stripedUI = new StripedLabelUI(1, 12);
|
||||||
|
this.defaultUI = new BasicLabelUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -779,36 +780,48 @@ public class ComponentAnalysisGeneralPanel extends JPanel implements StateChange
|
|||||||
// Reset to default UI
|
// Reset to default UI
|
||||||
label.setUI(defaultUI);
|
label.setUI(defaultUI);
|
||||||
|
|
||||||
if (!isSelected && (value instanceof Double)) {
|
// Handle selection coloring
|
||||||
double cd = (Double) value;
|
if (isSelected) {
|
||||||
float r = (float) (cd / 1.5);
|
label.setBackground(table.getSelectionBackground());
|
||||||
|
label.setForeground(table.getSelectionForeground());
|
||||||
|
label.setOpaque(true);
|
||||||
|
} else {
|
||||||
|
// Non-selected styling
|
||||||
|
if (value instanceof Double) {
|
||||||
|
double cd = (Double) value;
|
||||||
|
float r = (float) (cd / 1.5);
|
||||||
|
|
||||||
float hue = MathUtil.clamp(0.3333f * (1 - 2.0f * r), 0, 0.3333f);
|
float hue = MathUtil.clamp(0.3333f * (1 - 2.0f * r), 0, 0.3333f);
|
||||||
float sat = MathUtil.clamp(0.8f * r + 0.1f * (1 - r), 0, 1);
|
float sat = MathUtil.clamp(0.8f * r + 0.1f * (1 - r), 0, 1);
|
||||||
float val = 1.0f;
|
float val = 1.0f;
|
||||||
|
|
||||||
label.setBackground(Color.getHSBColor(hue, sat, val));
|
label.setBackground(Color.getHSBColor(hue, sat, val));
|
||||||
label.setForeground(Color.BLACK);
|
label.setForeground(Color.BLACK);
|
||||||
|
} else {
|
||||||
|
label.setBackground(table.getBackground());
|
||||||
|
label.setForeground(table.getForeground());
|
||||||
|
}
|
||||||
|
label.setOpaque(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the per instance CD, we want to use a different formatting, because the relative percentages
|
// Special handling for column 4
|
||||||
// don't matter, and the total instance CD for the rocket makes no sense.
|
|
||||||
if (column == 4) {
|
if (column == 4) {
|
||||||
if (row == 0) {
|
if (row == 0) {
|
||||||
label.setText("");
|
label.setText("");
|
||||||
label.setOpaque(true);
|
|
||||||
label.setBackground(backgroundColor);
|
|
||||||
label.setForeground(foregroundColor);
|
|
||||||
label.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
|
|
||||||
label.setUI(stripedUI);
|
label.setUI(stripedUI);
|
||||||
|
if (!isSelected) {
|
||||||
|
label.setBackground(table.getBackground());
|
||||||
|
label.setForeground(table.getForeground());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
label.setText(decimalFormat(dragData.get(row).getCD()));
|
label.setText(decimalFormat(dragData.get(row).getCD()));
|
||||||
}
|
}
|
||||||
return label;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((row < 0) || (row >= dragData.size()))
|
// Set font
|
||||||
|
if ((row < 0) || (row >= dragData.size())) {
|
||||||
return label;
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
if ((dragData.get(row).getComponent() instanceof Rocket) || (column == 5)) {
|
if ((dragData.get(row).getComponent() instanceof Rocket) || (column == 5)) {
|
||||||
label.setFont(boldFont);
|
label.setFont(boldFont);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user