|
|
@ -43,26 +43,26 @@ import userinterface.GUIPrism; |
|
|
*/ |
|
|
*/ |
|
|
public class GUISimulatorUpdatesTable extends JTable implements ListSelectionListener |
|
|
public class GUISimulatorUpdatesTable extends JTable implements ListSelectionListener |
|
|
{ |
|
|
{ |
|
|
public static Color [] DISTRIBUTION_COLOURS = { new Color(255,255,255), //white |
|
|
|
|
|
new Color(253,255,201) }; //yellow |
|
|
|
|
|
/*new Color(224,255,224), //green |
|
|
|
|
|
new Color(255,227,255), //pink |
|
|
|
|
|
new Color(255,234,199), //orange |
|
|
|
|
|
new Color(209,217,255), //blue |
|
|
|
|
|
new Color(226,199,255), //purple |
|
|
|
|
|
new Color(212,255,255)} ;*/ //cyan |
|
|
|
|
|
private GUISimulator.UpdateTableModel utm; |
|
|
|
|
|
|
|
|
|
|
|
private UpdateHeaderListModel headerModel; |
|
|
|
|
|
private JList header; |
|
|
|
|
|
private UpdateHeaderRenderer updateHeaderRenderer; |
|
|
|
|
|
private UpdateTableRenderer updateTableRenderer; |
|
|
|
|
|
|
|
|
|
|
|
private GUISimulator sim; |
|
|
|
|
|
|
|
|
|
|
|
/** Creates a new instance of GUISimulatorUpdatesTable */ |
|
|
|
|
|
public GUISimulatorUpdatesTable(GUISimulator.UpdateTableModel utm, GUISimulator sim) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
public static Color[] DISTRIBUTION_COLOURS = { new Color(255, 255, 255), //white |
|
|
|
|
|
new Color(253, 255, 201) }; //yellow |
|
|
|
|
|
/*new Color(224,255,224), //green |
|
|
|
|
|
new Color(255,227,255), //pink |
|
|
|
|
|
new Color(255,234,199), //orange |
|
|
|
|
|
new Color(209,217,255), //blue |
|
|
|
|
|
new Color(226,199,255), //purple |
|
|
|
|
|
new Color(212,255,255)} ;*///cyan |
|
|
|
|
|
private GUISimulator.UpdateTableModel utm; |
|
|
|
|
|
|
|
|
|
|
|
private UpdateHeaderListModel headerModel; |
|
|
|
|
|
private JList header; |
|
|
|
|
|
private UpdateHeaderRenderer updateHeaderRenderer; |
|
|
|
|
|
private UpdateTableRenderer updateTableRenderer; |
|
|
|
|
|
|
|
|
|
|
|
private GUISimulator sim; |
|
|
|
|
|
|
|
|
|
|
|
/** Creates a new instance of GUISimulatorUpdatesTable */ |
|
|
|
|
|
public GUISimulatorUpdatesTable(GUISimulator.UpdateTableModel utm, GUISimulator sim) |
|
|
|
|
|
{ |
|
|
super(utm); |
|
|
super(utm); |
|
|
this.sim = sim; |
|
|
this.sim = sim; |
|
|
this.utm = utm; |
|
|
this.utm = utm; |
|
|
@ -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,88 +131,79 @@ 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 */ |
|
|
|
|
|
public void setFont(Font font) |
|
|
|
|
|
{ |
|
|
|
|
|
super.setFont(font); |
|
|
|
|
|
if (updateTableRenderer != null) updateTableRenderer.setFont(font); |
|
|
|
|
|
setRowHeight(getFontMetrics(font).getHeight() + 4); |
|
|
|
|
|
if (header != null) header.setFixedCellHeight(getRowHeight()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** Override set font to pass changes onto renderer(s) and set row height */ |
|
|
|
|
|
public void setFont(Font font) |
|
|
|
|
|
{ |
|
|
|
|
|
super.setFont(font); |
|
|
|
|
|
if (updateTableRenderer != null) |
|
|
|
|
|
updateTableRenderer.setFont(font); |
|
|
|
|
|
setRowHeight(getFontMetrics(font).getHeight() + 4); |
|
|
|
|
|
if (header != null) |
|
|
|
|
|
header.setFixedCellHeight(getRowHeight()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void valueChanged(ListSelectionEvent e) |
|
|
|
|
|
{ |
|
|
|
|
|
if(headerModel != null) |
|
|
|
|
|
headerModel.updateHeader(); |
|
|
|
|
|
repaint(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void valueChanged(ListSelectionEvent e) |
|
|
|
|
|
{ |
|
|
|
|
|
if (headerModel != null) |
|
|
|
|
|
headerModel.updateHeader(); |
|
|
|
|
|
repaint(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public JList getUpdateRowHeader() |
|
|
|
|
|
{ |
|
|
|
|
|
return header; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public JList getUpdateRowHeader() |
|
|
|
|
|
{ |
|
|
|
|
|
return header; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
class UpdateTableRenderer implements TableCellRenderer |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
class UpdateTableRenderer implements TableCellRenderer |
|
|
|
|
|
{ |
|
|
JTextField renderer; |
|
|
JTextField renderer; |
|
|
|
|
|
|
|
|
public UpdateTableRenderer() |
|
|
public UpdateTableRenderer() |
|
|
{ |
|
|
{ |
|
|
renderer = new JTextField(""); |
|
|
|
|
|
|
|
|
renderer = new JTextField(""); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) |
|
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) |
|
|
{ |
|
|
{ |
|
|
renderer.setText(value.toString()); |
|
|
|
|
|
|
|
|
|
|
|
int dist; |
|
|
|
|
|
|
|
|
renderer.setText(value.toString()); |
|
|
|
|
|
|
|
|
if(sim.getModulesFile().getModelType() == ModelType.CTMC) |
|
|
|
|
|
dist = 0; |
|
|
|
|
|
else dist = utm.getProbabilityDistributionOf(row); |
|
|
|
|
|
|
|
|
int dist; |
|
|
|
|
|
|
|
|
Color c = DISTRIBUTION_COLOURS[dist%2]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isSelected) |
|
|
|
|
|
{ |
|
|
|
|
|
Color newCol = new Color(c.getRed()-20, c.getGreen()-20, c.getBlue()); |
|
|
|
|
|
if(utm.oldUpdate) |
|
|
|
|
|
{ |
|
|
|
|
|
newCol = new Color(newCol.getRed()-7, newCol.getGreen()-7, newCol.getBlue()-7); |
|
|
|
|
|
renderer.setBackground(newCol); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Select default background colour |
|
|
|
|
|
// (depends on choice, for nondeterministic models) |
|
|
|
|
|
if (sim.getModulesFile().getModelType().nondeterministic()) |
|
|
|
|
|
dist = utm.getChoiceIndexOf(row); |
|
|
else |
|
|
else |
|
|
{ |
|
|
|
|
|
renderer.setBackground(newCol); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
if(utm.oldUpdate) |
|
|
|
|
|
{ |
|
|
|
|
|
Color newCol = new Color(c.getRed()-7, c.getGreen()-7, c.getBlue()-7); |
|
|
|
|
|
renderer.setBackground(newCol); |
|
|
|
|
|
|
|
|
dist = 0; |
|
|
|
|
|
Color c = DISTRIBUTION_COLOURS[dist % 2]; |
|
|
|
|
|
|
|
|
|
|
|
if (isSelected) { |
|
|
|
|
|
Color newCol = new Color(c.getRed() - 20, c.getGreen() - 20, c.getBlue()); |
|
|
|
|
|
if (utm.oldUpdate) { |
|
|
|
|
|
newCol = new Color(newCol.getRed() - 7, newCol.getGreen() - 7, newCol.getBlue() - 7); |
|
|
|
|
|
renderer.setBackground(newCol); |
|
|
|
|
|
} else { |
|
|
|
|
|
renderer.setBackground(newCol); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if (utm.oldUpdate) { |
|
|
|
|
|
Color newCol = new Color(c.getRed() - 7, c.getGreen() - 7, c.getBlue() - 7); |
|
|
|
|
|
renderer.setBackground(newCol); |
|
|
|
|
|
} else |
|
|
|
|
|
renderer.setBackground(c); |
|
|
} |
|
|
} |
|
|
else |
|
|
|
|
|
renderer.setBackground(c); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
renderer.setBorder(new EmptyBorder(1, 1, 1, 1)); |
|
|
|
|
|
return renderer; |
|
|
|
|
|
|
|
|
renderer.setBorder(new EmptyBorder(1, 1, 1, 1)); |
|
|
|
|
|
return renderer; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void setFont(Font font) |
|
|
public void setFont(Font font) |
|
|
{ |
|
|
{ |
|
|
renderer.setFont(font); |
|
|
renderer.setFont(font); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
class UpdateHeaderRenderer extends JButton implements ListCellRenderer |
|
|
class UpdateHeaderRenderer extends JButton implements ListCellRenderer |
|
|
{ |
|
|
{ |
|
|
@ -224,7 +213,7 @@ public class GUISimulatorUpdatesTable extends JTable implements ListSelectionLis |
|
|
|
|
|
|
|
|
UpdateHeaderRenderer(JTable table) |
|
|
UpdateHeaderRenderer(JTable table) |
|
|
{ |
|
|
{ |
|
|
selected = false; |
|
|
|
|
|
|
|
|
selected = false; |
|
|
/*JTableHeader header = table.getTableHeader(); |
|
|
/*JTableHeader header = table.getTableHeader(); |
|
|
setOpaque(true); |
|
|
setOpaque(true); |
|
|
setBorder(UIManager.getBorder("TableHeader.cellBorder")); |
|
|
setBorder(UIManager.getBorder("TableHeader.cellBorder")); |
|
|
@ -232,30 +221,25 @@ public class GUISimulatorUpdatesTable extends JTable implements ListSelectionLis |
|
|
setForeground(header.getForeground()); |
|
|
setForeground(header.getForeground()); |
|
|
setBackground(header.getBackground()); |
|
|
setBackground(header.getBackground()); |
|
|
setFont(header.getFont());*/ |
|
|
setFont(header.getFont());*/ |
|
|
setBorder(null); |
|
|
|
|
|
selectedIcon = GUIPrism.getIconFromImage("smallItemSelected.png"); |
|
|
|
|
|
|
|
|
setBorder(null); |
|
|
|
|
|
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) |
|
|
|
|
|
{ |
|
|
|
|
|
setIcon(selectedIcon); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
setIcon(null); |
|
|
|
|
|
|
|
|
if (selected) { |
|
|
|
|
|
setIcon(selectedIcon); |
|
|
|
|
|
} else { |
|
|
|
|
|
setIcon(null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return this; |
|
|
return this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class UpdateHeaderListModel extends AbstractListModel |
|
|
class UpdateHeaderListModel extends AbstractListModel |
|
|
@ -263,7 +247,7 @@ public class GUISimulatorUpdatesTable extends JTable implements ListSelectionLis |
|
|
|
|
|
|
|
|
public Object getElementAt(int index) |
|
|
public Object getElementAt(int index) |
|
|
{ |
|
|
{ |
|
|
return ""+index; |
|
|
|
|
|
|
|
|
return "" + index; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public int getSize() |
|
|
public int getSize() |
|
|
|