diff --git a/java/src/com/melloware/jintellitype/Main.java b/java/src/com/melloware/jintellitype/Main.java
index b579745..32c93c0 100644
--- a/java/src/com/melloware/jintellitype/Main.java
+++ b/java/src/com/melloware/jintellitype/Main.java
@@ -24,7 +24,7 @@ package com.melloware.jintellitype;
import java.util.Properties;
/**
- * Simple executable class that is used as the Main-Class in the JIntellitype
+ * Simple executable class that is used as the NetworkClient-Class in the JIntellitype
* jar. Outputs version information and other information about the environment
* on which the jar is being executed.
*
@@ -44,7 +44,7 @@ public final class Main {
// private constructor to make singleton.
}
- /** Main method that does what the class level javadoc states. */
+ /** NetworkClient method that does what the class level javadoc states. */
public static void main(String[] argv) {
System.out.println("JIntellitype version \"" + getProjectVersion() + "\"");
System.out.println(" ");
diff --git a/java/src/javazoom/jlgui/basicplayer/BasicPlayer.java b/java/src/javazoom/jlgui/basicplayer/BasicPlayer.java
index 24bb85e..e71407d 100644
--- a/java/src/javazoom/jlgui/basicplayer/BasicPlayer.java
+++ b/java/src/javazoom/jlgui/basicplayer/BasicPlayer.java
@@ -588,7 +588,7 @@ public class BasicPlayer implements BasicController, Runnable
}
/**
- * Main loop.
+ * NetworkClient loop.
*
* Player Status == STOPPED || SEEKING => End of Thread + Freeing Audio Ressources.
* Player Status == PLAYING => Audio stream data sent to Audio line.
@@ -602,7 +602,7 @@ public class BasicPlayer implements BasicController, Runnable
// Lock stream while playing.
synchronized (m_audioInputStream)
{
- // Main play/pause loop.
+ // NetworkClient play/pause loop.
while ((nBytesRead != -1) && (m_status != STOPPED) && (m_status != SEEKING) && (m_status != UNKNOWN))
{
if (m_status == PLAYING)
diff --git a/java/src/org/apache/log4j/chainsaw/Main.java b/java/src/org/apache/log4j/chainsaw/Main.java
index c0c9aad..5a69351 100644
--- a/java/src/org/apache/log4j/chainsaw/Main.java
+++ b/java/src/org/apache/log4j/chainsaw/Main.java
@@ -55,7 +55,7 @@ public class Main
/**
- * Creates a new Main instance.
+ * Creates a new NetworkClient instance.
*/
private Main() {
super("CHAINSAW - Log4J Log Viewer");
diff --git a/java/src/org/apache/log4j/lf5/StartLogFactor5.java b/java/src/org/apache/log4j/lf5/StartLogFactor5.java
index 1ea28c3..914b02f 100644
--- a/java/src/org/apache/log4j/lf5/StartLogFactor5.java
+++ b/java/src/org/apache/log4j/lf5/StartLogFactor5.java
@@ -49,7 +49,7 @@ public class StartLogFactor5 {
//--------------------------------------------------------------------------
/**
- * Main - starts a an instance of the LogFactor5 console and configures
+ * NetworkClient - starts a an instance of the LogFactor5 console and configures
* the console settings.
*/
public final static void main(String[] args) {
diff --git a/java/src/pm/Application.java b/java/src/pm/Application.java
index 34e0985..e50c57b 100644
--- a/java/src/pm/Application.java
+++ b/java/src/pm/Application.java
@@ -1,15 +1,10 @@
package pm;
import pm.event.EventListener;
-import pm.event.EventManager;
import pm.exception.application.ApplicationExitException;
import pm.exception.application.ApplicationInitialiseException;
public abstract class Application extends EventListener {
- public Application() {
- super();
- }
-
public void initialise() throws ApplicationInitialiseException {}
public void exit() throws ApplicationExitException {
diff --git a/java/src/pm/Device.java b/java/src/pm/Device.java
index dda4777..55b6111 100644
--- a/java/src/pm/Device.java
+++ b/java/src/pm/Device.java
@@ -6,8 +6,6 @@ import pm.event.task.Continuous;
import pm.event.task.Stopper;
import pm.exception.device.DeviceExitException;
import pm.exception.device.DeviceInitialiseException;
-import pm.interrupt.InterruptListener;
-import pm.interrupt.Interruptible;
import pm.macro.Sequence;
import pm.macro.SequenceListener;
import pm.macro.State;
@@ -17,12 +15,10 @@ import pm.macro.state.Release;
public abstract class Device extends EventListener {
protected SequenceListener sequenceListener;
- //protected InterruptListener interruptListener;
public Device() {
super();
sequenceListener = new SequenceListener(this);
- //interruptListener = new InterruptListener(this);
}
/* Register macro's */
@@ -71,11 +67,6 @@ public abstract class Device extends EventListener {
Button button = hold.getButton();
add(new Press(button), new Release(button), continuous);
}
-
- /* Register interruptibles *
- protected void add(Interruptible interruptible) {
- interruptListener.add(interruptible);
- }*/
/* Recognize events */
protected void add(State state) {
diff --git a/java/src/pm/Main.java b/java/src/pm/Main.java
index b9ec37a..9436ed3 100644
--- a/java/src/pm/Main.java
+++ b/java/src/pm/Main.java
@@ -38,18 +38,15 @@ public class Main extends EventListener {
//protected String[] deviceClassArray;
protected ArrayCycle applicationCycle;
protected ArrayList deviceList;
+
+ protected EventManager eventManager;
public Main() {
super();
- /*deviceClassArray = new String[] {
- "pm.device.jintellitype.JIntellitypeDevice",
- "pm.device.javainput.rumblepad.RumblepadDevice",
- "pm.device.javainput.extreme3d.Extreme3DDevice",
- "pm.device.wiimote.WiimoteDevice"};*/
applicationCycle = new ArrayCycle();
deviceList = new ArrayList();
- EventManager.initialise(applicationCycle);
- EventManager.add(this);
+ eventManager = new EventManager(applicationCycle);
+ EventListener.initialise(eventManager);
}
public void initialise() throws DeviceInitialiseException {
@@ -59,10 +56,10 @@ public class Main extends EventListener {
//add(new WiimoteDevice());
//add(new GUIDevice());
//add(new TextDevice());
- //add(new PanelDevice());
+ add(new PanelDevice());
//add(new LanTextDevice());
//add(new Extreme3DDevice());
- add(new NetworkServer());
+ //add(new NetworkServer());
startDevices();
//add(new ExampleApplication());
@@ -164,22 +161,22 @@ public class Main extends EventListener {
/* Add / remove methods */
protected void add(Application application) {
- EventManager.add(application);
+ //EventManager.add(application);
applicationCycle.add(application);
}
protected void remove(Application application) {
- EventManager.remove(application);
+ //EventManager.remove(application);
applicationCycle.remove(application);
}
protected void add(Device device) {
- EventManager.add(device);
+ //EventManager.add(device);
deviceList.add(device);
}
protected void remove(Device device) {
- EventManager.remove(device);
+ //EventManager.remove(device);
deviceList.remove(device);
}
diff --git a/java/src/pm/device/gui/GUIDevice.java b/java/src/pm/device/gui/GUIDevice.java
deleted file mode 100644
index 3814b77..0000000
--- a/java/src/pm/device/gui/GUIDevice.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package pm.device.gui;
-
-import pm.Device;
-
-public class GUIDevice extends Device {
- protected GUIDeviceUI gui;
-
- public GUIDevice() {
- gui = new GUIDeviceUI();
- }
-}
diff --git a/java/src/pm/device/gui/GUIDeviceUI.java b/java/src/pm/device/gui/GUIDeviceUI.java
deleted file mode 100644
index 733f79d..0000000
--- a/java/src/pm/device/gui/GUIDeviceUI.java
+++ /dev/null
@@ -1,199 +0,0 @@
-package pm.device.gui;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-
-import pm.event.Task;
-import pm.event.EventManager;
-import pm.value.Action;
-import pm.value.Target;
-
-import layout.TableLayout;
-import layout.TableLayoutConstraints;
-
-public class GUIDeviceUI extends JFrame {
-
- protected static final long serialVersionUID = 1L;
-
- protected JButton play;
- protected JButton pause;
- protected JButton resume;
- protected JButton next;
- protected JButton previous;
- protected JButton forward;
- protected JButton rewind;
- protected JButton mute;
- protected JButton volumeUp;
- protected JButton volumeDown;
-
- //TaskGatherer.add
- public GUIDeviceUI() {
- initComponents();
- setSize(30, 300);
- setVisible(true);
- }
-
- public void initComponents() {
- play = new JButton();
- pause = new JButton();
- resume = new JButton();
- next = new JButton();
- previous = new JButton();
- forward = new JButton();
- rewind = new JButton();
- mute = new JButton();
- volumeUp = new JButton();
- volumeDown = new JButton();
-
-
- setLayout(
- new TableLayout(new double[][] {
- {TableLayout.PREFERRED},
- {TableLayout.PREFERRED,
- TableLayout.PREFERRED,
- TableLayout.PREFERRED,
- TableLayout.PREFERRED,
- TableLayout.PREFERRED,
- TableLayout.PREFERRED,
- TableLayout.PREFERRED,
- TableLayout.PREFERRED,
- TableLayout.PREFERRED,
- TableLayout.PREFERRED,
- TableLayout.PREFERRED}
- })
- );
-
- //---- play ----
- play.setText("play");
- play.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- playAction(e);
- }
- });
- add(play, new TableLayoutConstraints(0, 0, 0, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
-
- //---- pause ----
- pause.setText("pause");
- pause.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- pauseAction(e);
- }
- });
- add(pause, new TableLayoutConstraints(0, 1, 0, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
-
- //---- resume ----
- resume.setText("resume");
- resume.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- resumeAction(e);
- }
- });
- add(resume, new TableLayoutConstraints(0, 2, 0, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
-
- //---- next ----
- next.setText("next");
- next.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- nextAction(e);
- }
- });
- add(next, new TableLayoutConstraints(0, 3, 0, 3, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
-
- //---- previous ----
- previous.setText("previous");
- previous.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- previousAction(e);
- }
- });
- add(previous, new TableLayoutConstraints(0, 4, 0, 4, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
-
- //---- forward ----
- forward.setText("forward");
- forward.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- forwardAction(e);
- }
- });
- add(forward, new TableLayoutConstraints(0, 5, 0, 5, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
-
- //---- rewind ----
- rewind.setText("rewind");
- rewind.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- rewindAction(e);
- }
- });
- add(rewind, new TableLayoutConstraints(0, 6, 0, 6, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
-
- //---- mute ----
- mute.setText("mute");
- mute.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- muteAction(e);
- }
- });
- add(mute, new TableLayoutConstraints(0, 7, 0, 7, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
-
- //---- volumeUp ----
- volumeUp.setText("volume up");
- volumeUp.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- volumeUpAction(e);
- }
- });
- add(volumeUp, new TableLayoutConstraints(0, 8, 0, 8, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
-
- //---- volumeDown ----
- volumeDown.setText("volume down");
- volumeDown.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- volumeDownAction(e);
- }
- });
- add(volumeDown, new TableLayoutConstraints(0, 9, 0, 9, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
- }
-
- protected void playAction(ActionEvent e) {
- EventManager.add(new Task(Action.PLAY, Target.APPLICATION));
- }
-
- protected void pauseAction(ActionEvent e) {
- EventManager.add(new Task(Action.PAUSE, Target.APPLICATION));
- }
-
- protected void resumeAction(ActionEvent e) {
- EventManager.add(new Task(Action.RESUME, Target.APPLICATION));
- }
-
- protected void nextAction(ActionEvent e) {
- EventManager.add(new Task(Action.NEXT, Target.APPLICATION));
- }
-
- protected void previousAction(ActionEvent e) {
- EventManager.add(new Task(Action.PREVIOUS, Target.APPLICATION));
- }
-
- protected void forwardAction(ActionEvent e) {
- EventManager.add(new Task(Action.FORWARD, Target.APPLICATION));
- }
-
- protected void rewindAction(ActionEvent e) {
- EventManager.add(new Task(Action.REWIND, Target.APPLICATION));
- }
-
- protected void muteAction(ActionEvent e) {
- EventManager.add(new Task(Action.MUTE, Target.APPLICATION));
- }
-
- protected void volumeUpAction(ActionEvent e) {
- EventManager.add(new Task(Action.VOLUME_UP, Target.APPLICATION));
- }
-
- protected void volumeDownAction(ActionEvent e) {
- EventManager.add(new Task(Action.VOLUME_DOWN, Target.APPLICATION));
- }
-}
diff --git a/java/src/pm/device/javainput/extreme3d/Extreme3DDevice.java b/java/src/pm/device/javainput/extreme3d/Extreme3DDevice.java
index bf43e62..904a5e6 100644
--- a/java/src/pm/device/javainput/extreme3d/Extreme3DDevice.java
+++ b/java/src/pm/device/javainput/extreme3d/Extreme3DDevice.java
@@ -34,12 +34,6 @@ public class Extreme3DDevice extends JavaInputDevice {
new Press(Extreme3DButton.ELEVEN),
new Release(Extreme3DButton.ONE)),
new Task(Action.EXIT, Target.MAIN));
- add(
- new Interruptible(
- new Press(Extreme3DButton.NINE),
- new Task(Action.FORWARD),
- new Press(Extreme3DButton.TEN),
- new Task(Action.PLAY)));
} catch (MacroException e) {
e.printStackTrace();
}
diff --git a/java/src/pm/event/EventListener.java b/java/src/pm/event/EventListener.java
index 94db51c..5647b48 100644
--- a/java/src/pm/event/EventListener.java
+++ b/java/src/pm/event/EventListener.java
@@ -1,34 +1,23 @@
package pm.event;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
import pm.Event;
import pm.Listener;
import pm.event.task.Continuous;
import pm.value.Action;
public abstract class EventListener extends Listener implements Runnable {
- protected Queue eventQueue;
+ protected static EventManager eventManager;
- public EventListener() {
- eventQueue = new ConcurrentLinkedQueue();
+ public static void initialise(EventManager eventManager) {
+ EventListener.eventManager = eventManager;
}
-
+
public final void run() {
while (run) {
- if (eventQueue.isEmpty()) {
- sleep();
- } else {
- event(eventQueue.poll());
- }
+ event(eventManager.get());
}
}
- public void add(Event event) {
- eventQueue.add(event);
- }
-
protected void event(Event event) {
if (event instanceof Feedback) {
event((Feedback) event);
diff --git a/java/src/pm/event/EventManager.java b/java/src/pm/event/EventManager.java
index f474867..8f440ef 100644
--- a/java/src/pm/event/EventManager.java
+++ b/java/src/pm/event/EventManager.java
@@ -1,34 +1,78 @@
package pm.event;
-import java.util.ArrayList;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import pm.Application;
-import pm.Device;
-import pm.Main;
-import pm.event.task.Stopper;
+import pm.Event;
import pm.util.ArrayCycle;
import pm.value.Target;
public class EventManager {
- protected static ArrayList eventListenerList;
- protected static ArrayCycle applicationCycle;
+ protected Queue eventQueue;
+ protected Lock lock;
+ protected Condition available;
- public static void initialise(ArrayCycle applicationCycle) {
- eventListenerList = new ArrayList();
- EventManager.applicationCycle = applicationCycle;
+ public EventManager(ArrayCycle applicationCycle) {
+ eventQueue = new ConcurrentLinkedQueue();
+ lock = new ReentrantLock();
+ available = lock.newCondition();
}
- public static void add(EventListener eventListener) {
- eventListenerList.add(eventListener);
- }
-
- public static void add(Feedback feedback) {
- for (EventListener eventListener : eventListenerList) {
- eventListener.add(feedback);
+ public void add(Event event) {
+ eventQueue.add(event);
+ synchronized (available) {
+ lock.notifyAll();
}
}
- public static void add(EventListener self, Task task) {
+ public Event get(Target target) {
+ while (eventQueue.isEmpty()) {
+ synchronized (available) {
+ try {
+ available.await();
+ } catch (InterruptedException e) {}
+ }
+ }
+ Event event = eventQueue.peek();
+ if (event instanceof Task) {
+ Task task = (Task) event;
+ if (task.getTarget() == target) {
+ return eventQueue.poll();
+ } else {
+ return null;
+ }
+ } else {
+ return eventQueue.poll();
+ }
+ }
+
+ public Event gett(Target target) {
+ while (true) {
+ Event event = eventQueue.peek();
+ if (event instanceof Task) {
+ Task task = (Task) event;
+ if (task.getTarget() == target) {
+ return get();
+ }
+ }
+ }
+ }
+
+ public Event get() {
+ return get(Target.ALL);
+ }
+
+ /*public static void add(Feedback feedback) {
+ for (EventListener eventListener : eventListenerList) {
+ eventListener.add(feedback);
+ }
+ }*/
+
+ /*public static void add(EventListener self, Task task) {
if (task instanceof Stopper) {
((Stopper) task).stop();
} else {
@@ -68,19 +112,5 @@ public class EventManager {
}
}
}
- }
-
-/* public static void add(Task task) {
- add(null, task);
- }
-
- private static void add(Task task) {
- if (!task.getTarget().equals(Target.SELF)) {
- add(null, task);
- }
- }
-*/
- public static void remove(EventListener eventListener) {
- eventListenerList.remove(eventListener);
- }
+ }*/
}
\ No newline at end of file
diff --git a/java/src/pm/interrupt/InterruptListener.java b/java/src/pm/interrupt/InterruptListener.java
deleted file mode 100644
index 1beb7dc..0000000
--- a/java/src/pm/interrupt/InterruptListener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package pm.interrupt;
-
-import java.util.ArrayList;
-
-import pm.event.EventListener;
-import pm.event.EventManager;
-import pm.macro.State;
-
-public class InterruptListener {
- protected EventListener eventListener;
- protected ArrayList interruptibleList;
-
- public InterruptListener(EventListener eventListener) {
- this.eventListener = eventListener;
- interruptibleList = new ArrayList();
- }
-
- public void add(Interruptible interruptible) {
- interruptibleList.add(interruptible);
- }
-
- public void add(State state) {
- for (Interruptible interruptible : interruptibleList) {
- if(interruptible.triggerPress.equals(state)) {
- EventManager.add(interruptible.triggerTask);
- interruptible.triggered = true;
- } else if(interruptible.interruptPress.equals(state) && interruptible.triggered) {
- EventManager.add(interruptible.interruptTask);
- interruptible.interrupted = true;
- interruptibleList.remove(interruptible);
- }
- }
- }
-}
diff --git a/java/src/pm/interrupt/Interruptible.java b/java/src/pm/interrupt/Interruptible.java
deleted file mode 100644
index fb83f30..0000000
--- a/java/src/pm/interrupt/Interruptible.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package pm.interrupt;
-
-import pm.event.Task;
-import pm.macro.state.Press;
-
-public class Interruptible extends Task {
- protected static final int SLEEP = 0;
-
- protected boolean triggered;
- protected boolean interrupted;
- protected Press triggerPress;
- protected Task triggerTask;
- protected Press interruptPress;
- protected Task interruptTask;
-
-
- public Interruptible(Press triggerPress, Task triggerTask, Press interruptPress, Task interruptTask) {
- super(null, null);
- triggered = false;
- interrupted = false;
- this.triggerPress = triggerPress;
- this.triggerTask = triggerTask;
- this.interruptPress = interruptPress;
- this.interruptTask = interruptTask;
- }
-}
\ No newline at end of file
diff --git a/java/src/pm/macro/SequenceListener.java b/java/src/pm/macro/SequenceListener.java
index 38aaafc..daafad1 100644
--- a/java/src/pm/macro/SequenceListener.java
+++ b/java/src/pm/macro/SequenceListener.java
@@ -6,12 +6,15 @@ import java.util.HashMap;
import pm.event.Task;
import pm.event.EventListener;
import pm.event.EventManager;
+import pm.value.Target;
public class SequenceListener {
protected EventListener eventListener;
protected ArrayList sequenceList;
protected HashMap taskMap;
protected ArrayList activeList;
+
+ protected static EventManager eventManager;
public SequenceListener(EventListener eventListener) {
this.eventListener = eventListener;
@@ -20,6 +23,10 @@ public class SequenceListener {
activeList = new ArrayList();
}
+ public static void initialise(EventManager eventManager) {
+ SequenceListener.eventManager = eventManager;
+ }
+
public int add(Sequence sequence, Task task) {
int id = sequenceList.size();
sequenceList.add(sequence);
@@ -36,7 +43,12 @@ public class SequenceListener {
if (active.next(state)) {
if (active.last()) {
Task task = taskMap.get(active.getSequence());
- EventManager.add(eventListener, task);
+ if (task.getTarget().equals(Target.SELF)) {
+ //eventListener.event() protected in event listener
+ //.add(eventListener, task);
+ } else {
+ eventManager.add(task);
+ }
removeList.add(active);
}
} else {
diff --git a/java/src/wiiusej/test/Main.java b/java/src/wiiusej/test/Main.java
index 67ef279..1f5a414 100644
--- a/java/src/wiiusej/test/Main.java
+++ b/java/src/wiiusej/test/Main.java
@@ -20,7 +20,7 @@ import wiiusej.WiiUseApiManager;
import wiiusej.Wiimote;
/**
- * Main Class to launch WiiuseJ GUI Test.
+ * NetworkClient Class to launch WiiuseJ GUI Test.
*
* @author guiguito
*/