summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-03 17:33:48 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-03 17:33:48 +0200
commit6161c4b1d4d9b5a47775d32dfa198003ddb5afb5 (patch)
tree895332fecb75ae2832b0c4cf3247facebf748190
parentbcc3f95847eafa1b61bb32dac047101c7adc0e64 (diff)
downloadJRummikub-6161c4b1d4d9b5a47775d32dfa198003ddb5afb5.tar
JRummikub-6161c4b1d4d9b5a47775d32dfa198003ddb5afb5.zip
Rename event and listener methods
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@81 72836036-5685-4462-b002-a69064685172
-rw-r--r--src/jrummikub/JRummikub.java28
-rw-r--r--src/jrummikub/util/Event.java30
-rw-r--r--src/jrummikub/util/Event1.java4
-rw-r--r--src/jrummikub/util/Event2.java4
-rw-r--r--src/jrummikub/util/IListener.java4
-rw-r--r--src/jrummikub/util/IListener1.java2
-rw-r--r--src/jrummikub/util/IListener2.java2
-rw-r--r--src/jrummikub/view/impl/AbstractStonePanel.java4
-rw-r--r--src/jrummikub/view/impl/PlayerPanel.java6
-rw-r--r--test/jrummikub/util/Event1Test.java18
-rw-r--r--test/jrummikub/util/Event2Test.java18
-rw-r--r--test/jrummikub/util/EventTest.java18
12 files changed, 69 insertions, 69 deletions
diff --git a/src/jrummikub/JRummikub.java b/src/jrummikub/JRummikub.java
index 54566d5..571e679 100644
--- a/src/jrummikub/JRummikub.java
+++ b/src/jrummikub/JRummikub.java
@@ -40,19 +40,19 @@ public class JRummikub {
view.getPlayerPanel().getSortByNumberEvent().add(new IListener() {
@Override
- public void fire() {
+ public void handle() {
System.out.println("'Sort by number' fired");
}
});
view.getPlayerPanel().getSortByColorEvent().add(new IListener() {
@Override
- public void fire() {
+ public void handle() {
System.out.println("'Sort by color' fired");
}
});
view.getPlayerPanel().getEndTurnEvent().add(new IListener() {
@Override
- public void fire() {
+ public void handle() {
System.out.println("'End turn' fired");
}
});
@@ -73,14 +73,14 @@ public class JRummikub {
view.getPlayerPanel().getHandPanel().getClickEvent()
.add(new IListener1<Position>() {
@Override
- public void fire(Position p) {
+ public void handle(Position p) {
System.out.println("Hand clicked at " + p);
}
});
view.getPlayerPanel().getHandPanel().getStoneClickEvent()
.add(new IListener2<Stone, Boolean>() {
@Override
- public void fire(Stone s, Boolean collect) {
+ public void handle(Stone s, Boolean collect) {
System.out.println("Hand clicked on " + s
+ (collect ? ", collect" : ""));
@@ -89,7 +89,7 @@ public class JRummikub {
view.getPlayerPanel().getHandPanel().getRangeClickEvent()
.add(new IListener2<Stone, Boolean>() {
@Override
- public void fire(Stone s, Boolean collect) {
+ public void handle(Stone s, Boolean collect) {
System.out.println("Hand range-clicked on " + s
+ (collect ? ", collect" : ""));
@@ -98,7 +98,7 @@ public class JRummikub {
view.getPlayerPanel().getHandPanel().getSetClickEvent()
.add(new IListener2<Stone, Boolean>() {
@Override
- public void fire(Stone s, Boolean collect) {
+ public void handle(Stone s, Boolean collect) {
System.out.println("Hand set-clicked at " + s
+ (collect ? ", collect" : ""));
@@ -108,14 +108,14 @@ public class JRummikub {
view.getTablePanel().getClickEvent()
.add(new IListener1<Position>() {
@Override
- public void fire(Position p) {
+ public void handle(Position p) {
System.out.println("Table clicked at " + p);
}
});
view.getTablePanel().getStoneClickEvent()
.add(new IListener2<Stone, Boolean>() {
@Override
- public void fire(Stone s, Boolean collect) {
+ public void handle(Stone s, Boolean collect) {
System.out.println("Table clicked on " + s
+ (collect ? ", collect" : ""));
@@ -124,7 +124,7 @@ public class JRummikub {
view.getTablePanel().getRangeClickEvent()
.add(new IListener2<Stone, Boolean>() {
@Override
- public void fire(Stone s, Boolean collect) {
+ public void handle(Stone s, Boolean collect) {
System.out.println("Table range-clicked on " + s
+ (collect ? ", collect" : ""));
@@ -133,7 +133,7 @@ public class JRummikub {
view.getTablePanel().getSetClickEvent()
.add(new IListener2<Stone, Boolean>() {
@Override
- public void fire(Stone s, Boolean collect) {
+ public void handle(Stone s, Boolean collect) {
System.out.println("Table set-clicked at " + s
+ (collect ? ", collect" : ""));
@@ -143,7 +143,7 @@ public class JRummikub {
view.getTablePanel().getStoneCollectionPanel().getStoneClickEvent()
.add(new IListener2<Stone, Boolean>() {
@Override
- public void fire(Stone s, Boolean collect) {
+ public void handle(Stone s, Boolean collect) {
System.out.println("Collection clicked on " + s
+ (collect ? ", collect" : ""));
@@ -152,7 +152,7 @@ public class JRummikub {
view.getTablePanel().getStoneCollectionPanel().getRangeClickEvent()
.add(new IListener2<Stone, Boolean>() {
@Override
- public void fire(Stone s, Boolean collect) {
+ public void handle(Stone s, Boolean collect) {
System.out.println("Collection range-clicked on " + s
+ (collect ? ", collect" : ""));
@@ -161,7 +161,7 @@ public class JRummikub {
view.getTablePanel().getStoneCollectionPanel().getSetClickEvent()
.add(new IListener2<Stone, Boolean>() {
@Override
- public void fire(Stone s, Boolean collect) {
+ public void handle(Stone s, Boolean collect) {
System.out.println("Collection set-clicked at " + s
+ (collect ? ", collect" : ""));
diff --git a/src/jrummikub/util/Event.java b/src/jrummikub/util/Event.java
index 698e0ed..64a70b3 100644
--- a/src/jrummikub/util/Event.java
+++ b/src/jrummikub/util/Event.java
@@ -4,22 +4,22 @@ import java.util.HashSet;
/** Simple parameterless event generator */
public class Event implements IEvent {
- private HashSet<IListener> listeners = new HashSet<IListener>();
+ private HashSet<IListener> listeners = new HashSet<IListener>();
- @Override
- public void add(IListener listener) {
- listeners.add(listener);
- }
+ @Override
+ public void add(IListener listener) {
+ listeners.add(listener);
+ }
- @Override
- public void remove(IListener listener) {
- listeners.remove(listener);
- }
+ @Override
+ public void remove(IListener listener) {
+ listeners.remove(listener);
+ }
- /** Generate a single event */
- public void fire() {
- for (IListener listener : listeners) {
- listener.fire();
- }
- }
+ /** Generate a single event */
+ public void emit() {
+ for (IListener listener : listeners) {
+ listener.handle();
+ }
+ }
}
diff --git a/src/jrummikub/util/Event1.java b/src/jrummikub/util/Event1.java
index 8ddf2a5..3f5056d 100644
--- a/src/jrummikub/util/Event1.java
+++ b/src/jrummikub/util/Event1.java
@@ -27,9 +27,9 @@ public class Event1<T> implements IEvent1<T> {
* @param value
* the event parameter
*/
- public void fire(T value) {
+ public void emit(T value) {
for (IListener1<T> listener : listeners) {
- listener.fire(value);
+ listener.handle(value);
}
}
}
diff --git a/src/jrummikub/util/Event2.java b/src/jrummikub/util/Event2.java
index f89446e..764004f 100644
--- a/src/jrummikub/util/Event2.java
+++ b/src/jrummikub/util/Event2.java
@@ -31,9 +31,9 @@ public class Event2<T1, T2> implements IEvent2<T1, T2> {
* @param value2
* the second event parameter
*/
- public void fire(T1 value1, T2 value2) {
+ public void emit(T1 value1, T2 value2) {
for (IListener2<T1, T2> listener : listeners) {
- listener.fire(value1, value2);
+ listener.handle(value1, value2);
}
}
}
diff --git a/src/jrummikub/util/IListener.java b/src/jrummikub/util/IListener.java
index 9030f71..f805452 100644
--- a/src/jrummikub/util/IListener.java
+++ b/src/jrummikub/util/IListener.java
@@ -4,6 +4,6 @@ package jrummikub.util;
* Interface for classes that can receive parameterless events
*/
public interface IListener {
- /** This method is called whenever a class we're listening to emits an event */
- public void fire();
+ /** This method is called whenever a class we're listening to emits an event */
+ public void handle();
}
diff --git a/src/jrummikub/util/IListener1.java b/src/jrummikub/util/IListener1.java
index c5e7253..5a01569 100644
--- a/src/jrummikub/util/IListener1.java
+++ b/src/jrummikub/util/IListener1.java
@@ -14,5 +14,5 @@ public interface IListener1<T> {
* @param value
* the event parameter
*/
- public void fire(T value);
+ public void handle(T value);
}
diff --git a/src/jrummikub/util/IListener2.java b/src/jrummikub/util/IListener2.java
index 1733208..dd571a3 100644
--- a/src/jrummikub/util/IListener2.java
+++ b/src/jrummikub/util/IListener2.java
@@ -18,5 +18,5 @@ public interface IListener2<T1, T2> {
* @param value2
* the second event parameter
*/
- public void fire(T1 value1, T2 value2);
+ public void handle(T1 value1, T2 value2);
}
diff --git a/src/jrummikub/view/impl/AbstractStonePanel.java b/src/jrummikub/view/impl/AbstractStonePanel.java
index 19e5891..a19ea1f 100644
--- a/src/jrummikub/view/impl/AbstractStonePanel.java
+++ b/src/jrummikub/view/impl/AbstractStonePanel.java
@@ -65,7 +65,7 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel,
Stone stone = getStoneAt(pos);
if (stone == null) {
- clickEvent.fire(pos);
+ clickEvent.emit(pos);
return;
}
@@ -76,7 +76,7 @@ abstract class AbstractStonePanel extends JPanel implements IStonePanel,
else if (e.getClickCount() >= 2)
event = setClickEvent;
- event.fire(stone, e.isControlDown());
+ event.emit(stone, e.isControlDown());
}
});
}
diff --git a/src/jrummikub/view/impl/PlayerPanel.java b/src/jrummikub/view/impl/PlayerPanel.java
index 0a7e64a..385356b 100644
--- a/src/jrummikub/view/impl/PlayerPanel.java
+++ b/src/jrummikub/view/impl/PlayerPanel.java
@@ -96,7 +96,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
sortByNumberButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
- sortByNumberEvent.fire();
+ sortByNumberEvent.emit();
}
});
leftPanel.add(sortByNumberButton);
@@ -107,7 +107,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
sortByColorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
- sortByColorEvent.fire();
+ sortByColorEvent.emit();
}
});
leftPanel.add(sortByColorButton);
@@ -131,7 +131,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
endTurnButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
- endTurnEvent.fire();
+ endTurnEvent.emit();
}
});
diff --git a/test/jrummikub/util/Event1Test.java b/test/jrummikub/util/Event1Test.java
index f414bf5..3f8839d 100644
--- a/test/jrummikub/util/Event1Test.java
+++ b/test/jrummikub/util/Event1Test.java
@@ -15,15 +15,15 @@ public class Event1Test {
testEvent.add(new IListener1<Integer>() {
@Override
- public void fire(Integer n) {
+ public void handle(Integer n) {
fired += n;
}
});
assertEquals(fired, 0);
- testEvent.fire(10);
+ testEvent.emit(10);
assertEquals(fired, 10);
- testEvent.fire(20);
+ testEvent.emit(20);
assertEquals(fired, 30);
}
@@ -35,7 +35,7 @@ public class Event1Test {
testEvent.add(new IListener1<Integer>() {
@Override
- public void fire(Integer n) {
+ public void handle(Integer n) {
fired += n;
}
@@ -43,14 +43,14 @@ public class Event1Test {
testEvent.add(new IListener1<Integer>() {
@Override
- public void fire(Integer n) {
+ public void handle(Integer n) {
fired2 -= n;
}
});
assertEquals(fired, 0);
assertEquals(fired2, 0);
- testEvent.fire(5);
+ testEvent.emit(5);
assertEquals(fired, 5);
assertEquals(fired2, -5);
@@ -63,7 +63,7 @@ public class Event1Test {
testEvent.add(new IListener1<Integer>() {
@Override
- public void fire(Integer n) {
+ public void handle(Integer n) {
fired += n;
}
@@ -71,13 +71,13 @@ public class Event1Test {
IListener1<Integer> rem = new IListener1<Integer>() {
@Override
- public void fire(Integer n) {
+ public void handle(Integer n) {
fail();
}
};
testEvent.add(rem);
testEvent.remove(rem);
- testEvent.fire(10);
+ testEvent.emit(10);
assertEquals(fired, 10);
}
}
diff --git a/test/jrummikub/util/Event2Test.java b/test/jrummikub/util/Event2Test.java
index c3d9c2a..6d1958e 100644
--- a/test/jrummikub/util/Event2Test.java
+++ b/test/jrummikub/util/Event2Test.java
@@ -16,17 +16,17 @@ public class Event2Test {
testEvent.add(new IListener2<Integer, Integer>() {
@Override
- public void fire(Integer n, Integer m) {
+ public void handle(Integer n, Integer m) {
fired += n;
fired2 += m;
}
});
assertEquals(fired, 0);
assertEquals(fired2, 0);
- testEvent.fire(10, 5);
+ testEvent.emit(10, 5);
assertEquals(fired, 10);
assertEquals(fired2, 5);
- testEvent.fire(20, 45);
+ testEvent.emit(20, 45);
assertEquals(fired, 30);
assertEquals(fired2, 50);
}
@@ -41,7 +41,7 @@ public class Event2Test {
testEvent.add(new IListener2<Integer, Integer>() {
@Override
- public void fire(Integer n, Integer m) {
+ public void handle(Integer n, Integer m) {
fired += n;
fired2 += m;
}
@@ -49,7 +49,7 @@ public class Event2Test {
testEvent.add(new IListener2<Integer, Integer>() {
@Override
- public void fire(Integer n, Integer m) {
+ public void handle(Integer n, Integer m) {
fired3 -= n;
fired4 -= m;
}
@@ -58,7 +58,7 @@ public class Event2Test {
assertEquals(fired2, 0);
assertEquals(fired3, 0);
assertEquals(fired4, 0);
- testEvent.fire(5, 10);
+ testEvent.emit(5, 10);
assertEquals(fired, 5);
assertEquals(fired2, 10);
assertEquals(fired3, -5);
@@ -73,7 +73,7 @@ public class Event2Test {
testEvent.add(new IListener2<Integer, Integer>() {
@Override
- public void fire(Integer n, Integer m) {
+ public void handle(Integer n, Integer m) {
fired += n;
fired2 += m;
}
@@ -81,7 +81,7 @@ public class Event2Test {
IListener2<Integer, Integer> rem = new IListener2<Integer, Integer>() {
@Override
- public void fire(Integer n, Integer m) {
+ public void handle(Integer n, Integer m) {
fail();
}
};
@@ -89,7 +89,7 @@ public class Event2Test {
assertEquals(fired2, 0);
testEvent.add(rem);
testEvent.remove(rem);
- testEvent.fire(10, 20);
+ testEvent.emit(10, 20);
assertEquals(fired, 10);
assertEquals(fired2, 20);
}
diff --git a/test/jrummikub/util/EventTest.java b/test/jrummikub/util/EventTest.java
index a4fb94f..15bd632 100644
--- a/test/jrummikub/util/EventTest.java
+++ b/test/jrummikub/util/EventTest.java
@@ -13,16 +13,16 @@ public class EventTest {
testEvent.add(new IListener() {
@Override
- public void fire() {
+ public void handle() {
fired = true;
}
});
assertFalse(fired);
- testEvent.fire();
+ testEvent.emit();
assertTrue(fired);
fired = false;
- testEvent.fire();
+ testEvent.emit();
assertTrue(fired);
}
@@ -34,7 +34,7 @@ public class EventTest {
testEvent.add(new IListener() {
@Override
- public void fire() {
+ public void handle() {
fired = true;
}
@@ -42,14 +42,14 @@ public class EventTest {
testEvent.add(new IListener() {
@Override
- public void fire() {
+ public void handle() {
fired2 = true;
}
});
assertFalse(fired);
assertFalse(fired2);
- testEvent.fire();
+ testEvent.emit();
assertTrue(fired);
assertTrue(fired2);
@@ -62,7 +62,7 @@ public class EventTest {
testEvent.add(new IListener() {
@Override
- public void fire() {
+ public void handle() {
fired = true;
}
@@ -70,13 +70,13 @@ public class EventTest {
IListener rem = new IListener() {
@Override
- public void fire() {
+ public void handle() {
fail();
}
};
testEvent.add(rem);
testEvent.remove(rem);
- testEvent.fire();
+ testEvent.emit();
assertTrue(fired);
}