From 77a150f8d20f56aff7a4b4d394ea4b4857b6918c Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 17 May 2008 14:58:43 +0000 Subject: Time package new. --- sources/core/time/VSVectorTime.java | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 sources/core/time/VSVectorTime.java (limited to 'sources/core/time/VSVectorTime.java') 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 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(); + } +} -- cgit v1.2.3