summaryrefslogtreecommitdiff
path: root/sources/core/time/VSVectorTime.java
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-17 14:58:43 +0000
committerPaul Buetow <paul@buetow.org>2008-05-17 14:58:43 +0000
commit77a150f8d20f56aff7a4b4d394ea4b4857b6918c (patch)
treeed5c99fedc8aba6d0745cd6a45767b8d97e4cec9 /sources/core/time/VSVectorTime.java
parentd46b1369ce9361bb0ee43e7e29669940aecbdee4 (diff)
Time package new.
Diffstat (limited to 'sources/core/time/VSVectorTime.java')
-rw-r--r--sources/core/time/VSVectorTime.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/sources/core/time/VSVectorTime.java b/sources/core/time/VSVectorTime.java
new file mode 100644
index 0000000..70a62a2
--- /dev/null
+++ b/sources/core/time/VSVectorTime.java
@@ -0,0 +1,52 @@
+package core;
+
+import java.util.ArrayList;
+
+public class VSVectorTime extends ArrayList<Long> implements VSTime {
+ /* Only needed for painting in the painting panel */
+ private long globalTime;
+
+ public VSVectorTime(long globalTime) {
+ this.globalTime = globalTime;
+ }
+
+ public long[] toLongArray() {
+ final int size = super.size();
+ final long[] arr = new long[size];
+
+ for (int i = 0; i < size; ++i)
+ arr[i] = super.get(i).longValue();
+
+ return arr;
+ }
+
+ public void setGlobalTime(long globalTime) {
+ this.globalTime = globalTime;
+ }
+
+ public long getGlobalTime() {
+ return globalTime;
+ }
+
+ public VSVectorTime getCopy() {
+ final VSVectorTime vectorTime = new VSVectorTime(globalTime);
+ final int size = super.size();
+
+ for (int i = 0; i < size; ++i)
+ vectorTime.add(super.get(i));
+
+ return vectorTime;
+ }
+
+ public String toString() {
+ final int size = super.size();
+ final StringBuffer buffer = new StringBuffer();
+ buffer.append("(");
+
+ for (int i = 0; i < size-1; ++i)
+ buffer.append(super.get(i)+",");
+ buffer.append(super.get(size-1)+")");
+
+ return buffer.toString();
+ }
+}