|
|
@ -90,7 +90,6 @@ public class GUISimulatorUpdatesTable extends JTable implements ListSelectionLis |
|
|
updateTableRenderer = new UpdateTableRenderer(); |
|
|
updateTableRenderer = new UpdateTableRenderer(); |
|
|
setDefaultRenderer(Object.class, updateTableRenderer); |
|
|
setDefaultRenderer(Object.class, updateTableRenderer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); |
|
|
setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); |
|
|
|
|
|
|
|
|
InputMap inputMap = new ComponentInputMap(this); |
|
|
InputMap inputMap = new ComponentInputMap(this); |
|
|
@ -105,8 +104,7 @@ public class GUISimulatorUpdatesTable extends JTable implements ListSelectionLis |
|
|
public void actionPerformed(ActionEvent e) |
|
|
public void actionPerformed(ActionEvent e) |
|
|
{ |
|
|
{ |
|
|
int selectedRow = GUISimulatorUpdatesTable.this.getSelectedRow(); |
|
|
int selectedRow = GUISimulatorUpdatesTable.this.getSelectedRow(); |
|
|
if (selectedRow != -1) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
if (selectedRow != -1) { |
|
|
if (selectedRow < GUISimulatorUpdatesTable.this.getRowCount() - 1) |
|
|
if (selectedRow < GUISimulatorUpdatesTable.this.getRowCount() - 1) |
|
|
GUISimulatorUpdatesTable.this.getSelectionModel().setSelectionInterval(selectedRow + 1, selectedRow + 1); |
|
|
GUISimulatorUpdatesTable.this.getSelectionModel().setSelectionInterval(selectedRow + 1, selectedRow + 1); |
|
|
else |
|
|
else |
|
|
@ -120,12 +118,12 @@ public class GUISimulatorUpdatesTable extends JTable implements ListSelectionLis |
|
|
public void actionPerformed(ActionEvent e) |
|
|
public void actionPerformed(ActionEvent e) |
|
|
{ |
|
|
{ |
|
|
int selectedRow = GUISimulatorUpdatesTable.this.getSelectedRow(); |
|
|
int selectedRow = GUISimulatorUpdatesTable.this.getSelectedRow(); |
|
|
if (selectedRow != -1) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
if (selectedRow != -1) { |
|
|
if (selectedRow >= 1) |
|
|
if (selectedRow >= 1) |
|
|
GUISimulatorUpdatesTable.this.getSelectionModel().setSelectionInterval(selectedRow - 1, selectedRow - 1); |
|
|
GUISimulatorUpdatesTable.this.getSelectionModel().setSelectionInterval(selectedRow - 1, selectedRow - 1); |
|
|
else |
|
|
else |
|
|
GUISimulatorUpdatesTable.this.getSelectionModel().setSelectionInterval(GUISimulatorUpdatesTable.this.getRowCount()-1, GUISimulatorUpdatesTable.this.getRowCount()-1); |
|
|
|
|
|
|
|
|
GUISimulatorUpdatesTable.this.getSelectionModel().setSelectionInterval(GUISimulatorUpdatesTable.this.getRowCount() - 1, |
|
|
|
|
|
GUISimulatorUpdatesTable.this.getRowCount() - 1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
@ -133,16 +131,17 @@ public class GUISimulatorUpdatesTable extends JTable implements ListSelectionLis |
|
|
this.setInputMap(JComponent.WHEN_FOCUSED, inputMap); |
|
|
this.setInputMap(JComponent.WHEN_FOCUSED, inputMap); |
|
|
this.setActionMap(actionMap); |
|
|
this.setActionMap(actionMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** Override set font to pass changes onto renderer(s) and set row height */ |
|
|
/** Override set font to pass changes onto renderer(s) and set row height */ |
|
|
public void setFont(Font font) |
|
|
public void setFont(Font font) |
|
|
{ |
|
|
{ |
|
|
super.setFont(font); |
|
|
super.setFont(font); |
|
|
if (updateTableRenderer != null) updateTableRenderer.setFont(font); |
|
|
|
|
|
|
|
|
if (updateTableRenderer != null) |
|
|
|
|
|
updateTableRenderer.setFont(font); |
|
|
setRowHeight(getFontMetrics(font).getHeight() + 4); |
|
|
setRowHeight(getFontMetrics(font).getHeight() + 4); |
|
|
if (header != null) header.setFixedCellHeight(getRowHeight()); |
|
|
|
|
|
|
|
|
if (header != null) |
|
|
|
|
|
header.setFixedCellHeight(getRowHeight()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void valueChanged(ListSelectionEvent e) |
|
|
public void valueChanged(ListSelectionEvent e) |
|
|
@ -172,34 +171,27 @@ public class GUISimulatorUpdatesTable extends JTable implements ListSelectionLis |
|
|
|
|
|
|
|
|
int dist; |
|
|
int dist; |
|
|
|
|
|
|
|
|
if(sim.getModulesFile().getModelType() == ModelType.CTMC) |
|
|
|
|
|
|
|
|
// Select default background colour |
|
|
|
|
|
// (depends on choice, for nondeterministic models) |
|
|
|
|
|
if (sim.getModulesFile().getModelType().nondeterministic()) |
|
|
|
|
|
dist = utm.getChoiceIndexOf(row); |
|
|
|
|
|
else |
|
|
dist = 0; |
|
|
dist = 0; |
|
|
else dist = utm.getProbabilityDistributionOf(row); |
|
|
|
|
|
|
|
|
|
|
|
Color c = DISTRIBUTION_COLOURS[dist % 2]; |
|
|
Color c = DISTRIBUTION_COLOURS[dist % 2]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isSelected) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
if (isSelected) { |
|
|
Color newCol = new Color(c.getRed() - 20, c.getGreen() - 20, c.getBlue()); |
|
|
Color newCol = new Color(c.getRed() - 20, c.getGreen() - 20, c.getBlue()); |
|
|
if(utm.oldUpdate) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
if (utm.oldUpdate) { |
|
|
newCol = new Color(newCol.getRed() - 7, newCol.getGreen() - 7, newCol.getBlue() - 7); |
|
|
newCol = new Color(newCol.getRed() - 7, newCol.getGreen() - 7, newCol.getBlue() - 7); |
|
|
renderer.setBackground(newCol); |
|
|
renderer.setBackground(newCol); |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
} else { |
|
|
renderer.setBackground(newCol); |
|
|
renderer.setBackground(newCol); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
if(utm.oldUpdate) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
if (utm.oldUpdate) { |
|
|
Color newCol = new Color(c.getRed() - 7, c.getGreen() - 7, c.getBlue() - 7); |
|
|
Color newCol = new Color(c.getRed() - 7, c.getGreen() - 7, c.getBlue() - 7); |
|
|
renderer.setBackground(newCol); |
|
|
renderer.setBackground(newCol); |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
|
|
|
} else |
|
|
renderer.setBackground(c); |
|
|
renderer.setBackground(c); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -213,9 +205,6 @@ public class GUISimulatorUpdatesTable extends JTable implements ListSelectionLis |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UpdateHeaderRenderer extends JButton implements ListCellRenderer |
|
|
class UpdateHeaderRenderer extends JButton implements ListCellRenderer |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
@ -236,26 +225,21 @@ public class GUISimulatorUpdatesTable extends JTable implements ListSelectionLis |
|
|
selectedIcon = GUIPrism.getIconFromImage("smallItemSelected.png"); |
|
|
selectedIcon = GUIPrism.getIconFromImage("smallItemSelected.png"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public Component getListCellRendererComponent( JList list, |
|
|
|
|
|
Object value, int index, boolean isSelected, boolean cellHasFocus) |
|
|
|
|
|
|
|
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
setBorder(null); |
|
|
setBorder(null); |
|
|
selected = getSelectedRow() == index; |
|
|
selected = getSelectedRow() == index; |
|
|
|
|
|
|
|
|
if(selected) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
if (selected) { |
|
|
setIcon(selectedIcon); |
|
|
setIcon(selectedIcon); |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
} else { |
|
|
setIcon(null); |
|
|
setIcon(null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return this; |
|
|
return this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class UpdateHeaderListModel extends AbstractListModel |
|
|
class UpdateHeaderListModel extends AbstractListModel |
|
|
|