summaryrefslogtreecommitdiff
path: root/sources/simulator/VSLogging.java
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-15 23:08:33 +0000
committerPaul Buetow <paul@buetow.org>2008-05-15 23:08:33 +0000
commitd4c1ddcc90c1e2e8660598fc36b3772d2bff6816 (patch)
tree28a0afc255e42f92adbca0d102e785301bc43a58 /sources/simulator/VSLogging.java
parent61599471a5978c1521b9c89c044ac2ce9a88c398 (diff)
1 Moved the stuff to trunk!
Diffstat (limited to 'sources/simulator/VSLogging.java')
-rw-r--r--sources/simulator/VSLogging.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/sources/simulator/VSLogging.java b/sources/simulator/VSLogging.java
new file mode 100644
index 0000000..c65198b
--- /dev/null
+++ b/sources/simulator/VSLogging.java
@@ -0,0 +1,57 @@
+package simulator;
+
+import javax.swing.*;
+import java.util.*;
+
+import utils.*;
+
+public class VSLogging {
+ private JTextArea loggingArea;
+ private VSSimulationPanel simulationPanel;
+ private volatile boolean isPaused;
+ private StringBuffer pauseBuffer;
+
+ public VSLogging() {
+ loggingArea = new JTextArea(0, 0);
+ loggingArea.setEditable(false);
+ pauseBuffer = new StringBuffer();
+ }
+
+ public void setSimulationPanel(VSSimulationPanel simulationPanel) {
+ this.simulationPanel = simulationPanel;
+ }
+
+ public JTextArea getLoggingArea() {
+ return loggingArea;
+ }
+
+ public void logg(String message) {
+ if (simulationPanel == null)
+ logg(message, 0);
+ else
+ logg(message, simulationPanel.getTime());
+ }
+
+ public void logg(String message, long time) {
+ if (isPaused) {
+ pauseBuffer.append(VSTools.getTimeString(time));
+ pauseBuffer.append(": ");
+ pauseBuffer.append(message);
+ pauseBuffer.append("\n");
+
+ } else {
+ loggingArea.append(VSTools.getTimeString(time) + ": " + message + "\n");
+ loggingArea.setCaretPosition(loggingArea.getDocument().getLength());
+ }
+ }
+
+ public void isPaused(boolean isPaused) {
+ this.isPaused = isPaused;
+
+ if (!isPaused) {
+ loggingArea.append(pauseBuffer.toString());
+ loggingArea.setCaretPosition(loggingArea.getDocument().getLength());
+ pauseBuffer.delete(0, pauseBuffer.length());
+ }
+ }
+}