|
From: Frederick W. <fre...@us...> - 2012-01-21 18:15:33
|
rails/ui/swing/GridPanel.java | 38 ++++++++++++++++++++------------------
rails/ui/swing/ORPanel.java | 16 +++++++++++-----
2 files changed, 31 insertions(+), 23 deletions(-)
New commits:
commit a6d8c72b5d2cebe6ef49788daa5e197427af2524
Author: Frederick Weld <fre...@gm...>
Date: Sat Jan 21 19:12:00 2012 +0100
Enhanced OR panel highlighting (highlights for multi-cell & spinner)
Now all relevant cells of a company's turn are highlighted (eg. all
token related cells during the lay token turn).
The revenue spinner cell's highlighting is now aligned with the one
of standard cells.
Re-adjusted highlighting scope (eg., revenue is not highlighted
any more during the decision turn).
diff --git a/rails/ui/swing/GridPanel.java b/rails/ui/swing/GridPanel.java
index 4941867..a64f955 100644
--- a/rails/ui/swing/GridPanel.java
+++ b/rails/ui/swing/GridPanel.java
@@ -62,7 +62,7 @@ implements ActionListener, KeyListener {
protected static Logger log =
Logger.getLogger(GridPanel.class.getPackage().getName());
- private JComponent highlightedComp = null;
+ private List<JComponent> highlightedComps = new ArrayList<JComponent>();
protected Color tableBorderColor;
protected Color cellOutlineColor;
protected Color highlightedBorderColor;
@@ -142,31 +142,33 @@ implements ActionListener, KeyListener {
/**
* highlights given component by altering its border's attributes
- * If another component had been highlighted before, it's highlighting is first
- * undone before highlighting the new given component.
*/
protected void setHighlight(JComponent comp,boolean isToBeHighlighted) {
//quit if nothing is to be done
- if (isToBeHighlighted && comp == highlightedComp) return;
- removeHighlight();
- if (isToBeHighlighted) {
- if (comp.getBorder() instanceof FieldBorder) {
- FieldBorder fb = (FieldBorder)comp.getBorder();
- fb.setHighlight(isToBeHighlighted);
- comp.repaint();
+ if (isToBeHighlighted && highlightedComps.contains(comp)) return;
+ if (!isToBeHighlighted && !highlightedComps.contains(comp)) return;
+
+ if (comp.getBorder() instanceof FieldBorder) {
+ FieldBorder fb = (FieldBorder)comp.getBorder();
+ fb.setHighlight(isToBeHighlighted);
+ comp.repaint();
+ if (isToBeHighlighted) {
+ highlightedComps.add(comp);
+ } else {
+ highlightedComps.remove(comp);
}
- highlightedComp = comp;
}
}
- protected void removeHighlight() {
- if (highlightedComp == null) return;
- if (highlightedComp.getBorder() instanceof FieldBorder) {
- FieldBorder fb = (FieldBorder)highlightedComp.getBorder();
- fb.setHighlight(false);
- highlightedComp.repaint();
+ protected void removeAllHighlights() {
+ for (JComponent c : highlightedComps) {
+ if (c.getBorder() instanceof FieldBorder) {
+ FieldBorder fb = (FieldBorder)c.getBorder();
+ fb.setHighlight(false);
+ c.repaint();
+ }
}
- highlightedComp = null;
+ highlightedComps.clear();
}
public void keyPressed(KeyEvent e) {
diff --git a/rails/ui/swing/ORPanel.java b/rails/ui/swing/ORPanel.java
index ffeabf8..f3b8b18 100644
--- a/rails/ui/swing/ORPanel.java
+++ b/rails/ui/swing/ORPanel.java
@@ -396,7 +396,7 @@ implements ActionListener, KeyListener, RevenueListener {
loansXOffset = currentXOffset += lastXWidth;
loansYOffset = leftCompNameYOffset;
addField (loansCaption = new Caption(LocalText.getText("LOANS")),
- loansXOffset, 0, lastXWidth = 1, 2, WIDE_RIGHT);
+ loansXOffset, 0, lastXWidth = 1, 2, WIDE_BOTTOM + WIDE_RIGHT);
}
if (hasRights) {
@@ -541,7 +541,8 @@ implements ActionListener, KeyListener, RevenueListener {
addField(f, revXOffset, revYOffset + i, 1, 1, 0, visible);
f = revenueSelect[i] = new Spinner(0, 0, 0, 10);
//zero-border so that size matches revenue field (thus, averting or panel resize)
- f.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
+ f.setPreferredSize(revenue[i].getPreferredSize());
+ //f.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
addField(f, revXOffset, revYOffset + i, 1, 1, 0, false);
// deactived below, as this caused problems by gridpanel rowvisibility function -- sfy
// revenue[i].addDependent(revenueSelect[i]);
@@ -916,7 +917,7 @@ implements ActionListener, KeyListener, RevenueListener {
}
undoButton.setEnabled(false);
- removeHighlight();
+ removeAllHighlights();
}
@@ -1005,7 +1006,7 @@ implements ActionListener, KeyListener, RevenueListener {
this.orCompIndex = orCompIndex;
president[orCompIndex].setHighlight(true);
- removeHighlight();
+ removeAllHighlights();
buttonOC.clearPossibleActions();
button1.clearPossibleActions();
@@ -1025,6 +1026,7 @@ implements ActionListener, KeyListener, RevenueListener {
tileCaption.setHighlight(true);
setHighlight(tiles[orCompIndex],true);
+ setHighlight(tileCost[orCompIndex],true);
button1.setVisible(false);
}
@@ -1033,6 +1035,9 @@ implements ActionListener, KeyListener, RevenueListener {
tokenCaption.setHighlight(true);
setHighlight(tokens[orCompIndex],true);
+ setHighlight(tokenCost[orCompIndex],true);
+ setHighlight(tokensLeft[orCompIndex],true);
+ setHighlight(tokenBonus[orCompIndex],true);
button1.setEnabled(false);
button1.setVisible(false);
button3.setEnabled(false);
@@ -1081,7 +1086,7 @@ implements ActionListener, KeyListener, RevenueListener {
public void initPayoutStep(int orCompIndex, SetDividend action,
boolean withhold, boolean split, boolean payout) {
- setHighlight(revenue[orCompIndex],true);
+ setHighlight(decision[orCompIndex],true);
SetDividend clonedAction;
@@ -1130,6 +1135,7 @@ implements ActionListener, KeyListener, RevenueListener {
trainCaption.setHighlight(true);
setHighlight(trains[orCompIndex],true);
+ setHighlight(newTrainCost[orCompIndex],true);
button1.setText(LocalText.getText("BUY_TRAIN"));
button1.setActionCommand(BUY_TRAIN_CMD);
|