You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2011/01/10 00:19:29 UTC

svn commit: r1057053 [6/12] - in /pivot/branches/3.x: ./ core/ core/src/ core/src/org/ core/src/org/apache/ core/src/org/apache/pivot/ core/src/org/apache/pivot/beans/ core/src/org/apache/pivot/bxml/ core/src/org/apache/pivot/csv/ core/src/org/apache/p...

Added: pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean1.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean1.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean1.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean1.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.json.test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+public class SampleBean1 {
+    private int a = 0;
+    private String b = null;
+    private boolean c = false;
+    private ArrayList<String> d = null;
+    private HashMap<String, Integer> e = null;
+    private SampleBean1 i = null;
+    private ArrayList<SampleBean2> k = null;
+
+    public int getA() {
+        return a;
+    }
+
+    public void setA(int a) {
+        this.a = a;
+    }
+
+    public String getB() {
+        return b;
+    }
+
+    public void setB(String b) {
+        this.b = b;
+    }
+
+    public boolean getC() {
+        return c;
+    }
+
+    public void setC(boolean c) {
+        this.c = c;
+    }
+
+    public ArrayList<String> getD() {
+        return d;
+    }
+
+    public void setD(ArrayList<String> d) {
+        this.d = d;
+    }
+
+    public HashMap<String, Integer> getE() {
+        return e;
+    }
+
+    public void setE(HashMap<String, Integer> e) {
+        this.e = e;
+    }
+
+    public SampleBean1 getI() {
+        return i;
+    }
+
+    public void setI(SampleBean1 i) {
+        this.i = i;
+    }
+
+    public ArrayList<SampleBean2> getK() {
+        return k;
+    }
+
+    public void setK(ArrayList<SampleBean2> k) {
+        this.k = k;
+    }
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.json.test;
+
+public class SampleBean2 {
+    private int a = 0;
+    private int b = 0;
+    private String c = null;
+
+    public int getA() {
+        return a;
+    }
+
+    public void setA(int a) {
+        this.a = a;
+    }
+
+    public int getB() {
+        return b;
+    }
+
+    public void setB(int b) {
+        this.b = b;
+    }
+
+    public String getC() {
+        return c;
+    }
+
+    public void setC(String c) {
+        this.c = c;
+    }
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2List.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2List.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2List.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2List.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.json.test;
+
+import java.util.ArrayList;
+
+public class SampleBean2List extends ArrayList<SampleBean2> {
+    private static final long serialVersionUID = 0;
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2ListSubclass.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2ListSubclass.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2ListSubclass.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2ListSubclass.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.json.test;
+
+public class SampleBean2ListSubclass extends SampleBean2List {
+    private static final long serialVersionUID = 0;
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2Map.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2Map.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2Map.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2Map.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.json.test;
+
+import java.util.HashMap;
+
+public class SampleBean2Map extends HashMap<String, SampleBean2> {
+    private static final long serialVersionUID = 0;
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2MapSubclass.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2MapSubclass.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2MapSubclass.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/json/test/SampleBean2MapSubclass.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.json.test;
+
+public class SampleBean2MapSubclass extends SampleBean2Map {
+    private static final long serialVersionUID = 0;
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/json/test/list.json
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/json/test/list.json?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/json/test/list.json (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/json/test/list.json Sun Jan  9 23:19:19 2011
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+[   {a:1, b:2, c:"3"},
+    {a:10, b:20, c:"30"},
+    {a:100, b:200, c:"300"}
+]
\ No newline at end of file

Added: pivot/branches/3.x/core/test/org/apache/pivot/json/test/map.json
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/json/test/map.json?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/json/test/map.json (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/json/test/map.json Sun Jan  9 23:19:19 2011
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+{   a: 100,
+    b: "Hello",
+    c: false,
+    d: ["1", "2", "3"],
+    e: {f: 4, g: 5, h: 6},
+    "i": { a: 200, b: "Goodbye", c: true},
+    j: 200,
+    k:  [
+        {a:1, b:2, c:"3"},
+        {a:10, b:20, c:"30"},
+        {a:100, b:200, c:"300"}
+    ]
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/util/concurrent/test/TaskTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/util/concurrent/test/TaskTest.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/util/concurrent/test/TaskTest.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/util/concurrent/test/TaskTest.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.util.concurrent.test;
+
+import org.apache.pivot.util.concurrent.ParallelTaskGroup;
+import org.apache.pivot.util.concurrent.SerialTaskGroup;
+import org.apache.pivot.util.concurrent.Task;
+import org.apache.pivot.util.concurrent.TaskListener;
+import org.junit.Test;
+
+public class TaskTest {
+    public static class SleepTask extends Task<Void> {
+        private long timeout = 0;
+
+        public SleepTask(long timeout) {
+            this.timeout = timeout;
+        }
+
+        @Override
+        public Void execute() {
+            System.out.println("Starting task " + this + "...");
+
+            try {
+                Thread.sleep(timeout);
+            } catch (InterruptedException exception) {
+                System.out.println(exception);
+            }
+
+            System.out.println("...done");
+
+            return null;
+        }
+
+        @Override
+        public String toString() {
+            return Long.toString(timeout);
+        }
+    }
+
+    @Test
+    public void testTaskSequence() {
+        TaskListener<Void> taskListener = new TaskListener<Void>() {
+            @Override
+            public synchronized void taskExecuted(Task<Void> task) {
+                Throwable fault = task.getFault();
+
+                if (fault == null) {
+                    System.out.println("EXECUTED");
+                } else {
+                    System.out.println("FAILED: " + fault);
+                }
+
+                notify();
+            }
+        };
+
+        SerialTaskGroup taskGroup = new SerialTaskGroup();
+
+        SleepTask task1 = new SleepTask(500);
+        taskGroup.getTasks().add(task1);
+
+        SleepTask task2 = new SleepTask(1000);
+        taskGroup.getTasks().add(task2);
+
+        SleepTask task3 = new SleepTask(2000);
+        taskGroup.getTasks().add(task3);
+
+        synchronized (taskListener) {
+            taskGroup.execute(taskListener);
+
+            try {
+                taskListener.wait();
+            } catch (InterruptedException exception) {
+            }
+        }
+    }
+
+    @Test
+    public void testTaskGroup() {
+        TaskListener<Void> taskListener = new TaskListener<Void>() {
+            @Override
+            public synchronized void taskExecuted(Task<Void> task) {
+                Throwable fault = task.getFault();
+
+                if (fault == null) {
+                    System.out.println("EXECUTED");
+                } else {
+                    System.out.println("FAILED: " + fault);
+                }
+
+                notify();
+            }
+        };
+
+        ParallelTaskGroup taskGroup = new ParallelTaskGroup();
+
+        SleepTask task1 = new SleepTask(500);
+        taskGroup.getTasks().add(task1);
+
+        SleepTask task2 = new SleepTask(1000);
+        taskGroup.getTasks().add(task2);
+
+        SleepTask task3 = new SleepTask(2000);
+        taskGroup.getTasks().add(task3);
+
+        synchronized (taskListener) {
+            taskGroup.execute(taskListener);
+
+            try {
+                taskListener.wait();
+            } catch (InterruptedException exception) {
+            }
+        }
+    }
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableListAdapterTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableListAdapterTest.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableListAdapterTest.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableListAdapterTest.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.util.test;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.pivot.util.ObservableListAdapter;
+import org.junit.Test;
+
+public class ObservableListAdapterTest {
+    @Test
+    public void basicTest() {
+        List<String> list = new ObservableListAdapter<String>(new ArrayList<String>());
+        list.add(0, "B");
+        list.add(1, "C");
+        list.add(2, "D");
+        list.add(0, "A");
+
+        Object[] array = list.toArray();
+        assertEquals(array[0], "A");
+
+        list.remove(0);
+        assertEquals(list.get(0), "B");
+        assertEquals(list.size(), 3);
+        assertEquals(list.indexOf("C"), 1);
+
+        String removed = list.remove(1);
+        assertNotNull(removed);
+        assertTrue(removed.equals("C"));
+
+        list.add(1, "E");
+        assertEquals(list.size(), 3);
+        assertNotNull(list.get(1));
+        assertTrue(list.get(1).equals("E"));
+
+        assertTrue(list.equals(Arrays.asList("B", "E", "D")));
+        assertFalse(list.equals(Arrays.asList("B", "E", "D", "C")));
+        assertFalse(list.equals(Arrays.asList("E", "C", "D")));
+
+        List<String> copy = Arrays.asList("B", "E", "D");
+        int i = 0;
+        for (String item : list) {
+            assertEquals(item, copy.get(i++));
+        }
+
+        int j = 0;
+        ListIterator<String> iterator = list.listIterator();
+        while (j < list.size()) {
+            iterator.next();
+            j++;
+        }
+
+        while (iterator.hasPrevious()) {
+            String s = iterator.previous();
+            assertEquals(s, copy.get(--j));
+        }
+
+        iterator = list.listIterator();
+        assertEquals(iterator.next(), "B");
+        assertEquals(iterator.next(), "E");
+        assertEquals(iterator.previous(), "E");
+        assertEquals(iterator.previous(), "B");
+        assertEquals(iterator.next(), "B");
+
+        iterator = list.listIterator();
+        iterator.add("M");
+
+        assertEquals(list, Arrays.asList("M", "B", "E", "D"));
+
+        assertEquals(iterator.next(), "B");
+        iterator.add("N");
+        assertEquals(list, Arrays.asList("M", "B", "N", "E", "D"));
+    }
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableMapAdapterTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableMapAdapterTest.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableMapAdapterTest.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableMapAdapterTest.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.util.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ConcurrentModificationException;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.pivot.util.ObservableMapAdapter;
+import org.junit.Test;
+
+public class ObservableMapAdapterTest {
+    @Test
+    public void basicTest() {
+        ObservableMapAdapter<String, Integer> map =
+            new ObservableMapAdapter<String, Integer>(new HashMap<String, Integer>());
+
+        assertTrue(map.isEmpty());
+        assertEquals(0, map.size());
+        assertFalse(map.containsKey("a"));
+        assertNotNull(map.getObservableMapListeners());
+        assertNotNull(map.toString());
+
+        assertNull(map.put("a", Integer.valueOf(1)));
+
+        assertEquals(1, (int) map.put("a", 2));
+
+        assertEquals(2, (int) map.get("a"));
+
+        assertEquals(1, map.size());
+
+        assertEquals(2, (int) map.remove("a"));
+
+        assertEquals(0, map.size());
+
+        map.put("a", 1);
+        assertEquals(1, map.size());
+        map.put("b", 2);
+        assertEquals(2, map.size());
+        map.put("c", 3);
+        assertEquals(3, map.size());
+
+        assertEquals(1, (int) map.get("a"));
+        assertEquals(2, (int) map.get("b"));
+        assertEquals(3, (int) map.get("c"));
+
+        Iterator<String> iter = map.keySet().iterator();
+        int count = 0;
+        while (iter.hasNext()) {
+            String s = iter.next();
+            if (!map.containsKey(s)) {
+                fail("Unknown element in map " + s);
+            }
+
+            count++;
+        }
+        assertEquals(3, count);
+
+        iter = map.keySet().iterator();
+        while (iter.hasNext()) {
+            iter.next();
+            iter.remove();
+        }
+        assertEquals(0, map.size());
+
+        map.put("a", 1);
+        map.put("b", 2);
+        map.put("c", 3);
+        map.clear();
+
+        assertEquals(0, map.size());
+
+        assertEquals(null, map.get("a"));
+        assertEquals(null, map.get("b"));
+        assertEquals(null, map.get("c"));
+    }
+
+    @Test
+    public void iteratorConcurrentModificationTest() {
+        ObservableMapAdapter<Integer, Integer> map =
+            new ObservableMapAdapter<Integer, Integer>(new HashMap<Integer, Integer>());
+
+        map.put(1, 1);
+        map.put(2, 2);
+        Iterator<Integer> iter = map.keySet().iterator();
+        iter.next();
+        map.put(3, 3);
+        try {
+            iter.next();
+            fail("Expecting " + ConcurrentModificationException.class);
+        } catch (ConcurrentModificationException ex) {
+            // expecting this
+        }
+    }
+
+    @Test
+    public void iteratorTest() {
+        ObservableMapAdapter<String, Object> map =
+            new ObservableMapAdapter<String, Object>(new HashMap<String, Object>());
+        map.put("font", "Verdana 11");
+        map.put("colors", "#ff0000");
+
+        Iterator<String> iterator = map.keySet().iterator();
+        while (iterator.hasNext()) {
+            String key = iterator.next();
+            System.out.println(key);
+        }
+    }
+
+    @Test
+    public void equalsTest() {
+        ObservableMapAdapter<String, String> map1 =
+            new ObservableMapAdapter<String, String>(new HashMap<String, String>());
+        map1.put("a", "one");
+        map1.put("b", "two");
+        map1.put("c", "three");
+
+        ObservableMapAdapter<String, String> map2 =
+            new ObservableMapAdapter<String, String>(new HashMap<String, String>());
+        map2.put("a", "one");
+        map2.put("b", "two");
+        map2.put("c", "three");
+
+        // Same
+        assertTrue(map1.equals(map2));
+
+        // Different values
+        map2.put("c", "four");
+        assertFalse(map1.equals(map2));
+
+        map1.put("c", null);
+        assertFalse(map1.equals(map2));
+
+        // Null comparison
+        map2.put("c", null);
+        assertTrue(map1.equals(map2));
+
+        // Different lengths
+        map2.put("d", "four");
+        assertFalse(map1.equals(map2));
+    }
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableSetAdapterTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableSetAdapterTest.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableSetAdapterTest.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/util/test/ObservableSetAdapterTest.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.util.test;
+
+import static org.junit.Assert.*;
+
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.apache.pivot.util.ObservableSetAdapter;
+import org.junit.Test;
+
+public class ObservableSetAdapterTest {
+    @Test
+    public void basicTest() {
+        ObservableSetAdapter<String> set = new ObservableSetAdapter<String>(new HashSet<String>());
+
+        set.add("A");
+        assertTrue(set.contains("A"));
+
+        set.add("B");
+        assertTrue(set.contains("A"));
+        assertTrue(set.contains("B"));
+
+        assertEquals(set.size(), 2);
+
+        int i = 0;
+        for (String element : set) {
+            assertTrue(element.equals("A")
+                || element.equals("B"));
+            i++;
+        }
+
+        assertEquals(i, 2);
+
+        set.remove("B");
+        assertFalse(set.contains("B"));
+
+        set.remove("A");
+        assertFalse(set.contains("A"));
+
+        assertTrue(set.isEmpty());
+
+        set.add("A");
+        set.add("B");
+        set.add("C");
+
+        Iterator<String> iter = set.iterator();
+        int count = 0;
+        while (iter.hasNext()) {
+            String s = iter.next();
+            if (!set.contains(s)) {
+                fail("Unknown element in set " + s);
+            }
+            count++;
+        }
+        assertEquals(3, count);
+
+        iter = set.iterator();
+        while (iter.hasNext()) {
+            iter.next();
+            iter.remove();
+        }
+        assertEquals(0, set.size());
+    }
+
+    @Test
+    public void equalsTest() {
+        ObservableSetAdapter<String> set1 = new ObservableSetAdapter<String>(new HashSet<String>());
+        set1.add("one");
+        set1.add("two");
+        set1.add("three");
+
+        ObservableSetAdapter<String> set2 = new ObservableSetAdapter<String>(new HashSet<String>());
+        set2.add("one");
+        set2.add("two");
+        set2.add("three");
+
+        // Same
+        assertTrue(set1.equals(set2));
+
+        // Different values
+        set2.remove("three");
+        set2.add("four");
+        assertFalse(set1.equals(set2));
+
+        // Different lengths
+        set2.add("three");
+        assertFalse(set1.equals(set2));
+    }
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/util/test/ReferenceCountedMapTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/util/test/ReferenceCountedMapTest.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/util/test/ReferenceCountedMapTest.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/util/test/ReferenceCountedMapTest.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.util.test;
+
+import static junit.framework.Assert.*;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.pivot.util.ReferenceCountedMap;
+import org.junit.Test;
+
+public class ReferenceCountedMapTest {
+    public static final String A_KEY = "A";
+    public static final Integer A_VALUE = 100;
+
+    public static final String B_KEY = "B";
+    public static final Integer B_VALUE = 200;
+
+    public static final Integer C_VALUE = 300;
+
+    @Test
+    public void getRemoveTest() {
+        ReferenceCountedMap<String, Integer> map = new ReferenceCountedMap<String, Integer>();
+
+        map.put(A_KEY, A_VALUE);
+
+        assertEquals(map.countOf(A_KEY), 0);
+
+        Integer a1 = map.get(A_KEY);
+        assertEquals(a1, A_VALUE);
+        assertEquals(map.countOf(A_KEY), 1);
+
+        Integer a2 = map.get(A_KEY);
+        assertEquals(a1, a2);
+        assertEquals(map.countOf(A_KEY), 2);
+
+        Integer removed1 = map.remove(A_KEY);
+        assertEquals(removed1, null);
+        assertEquals(map.countOf(A_KEY), 1);
+        assertTrue(map.containsKey(A_KEY));
+
+        Integer removed2 = map.remove(A_KEY);
+        assertEquals(removed2, null);
+        assertEquals(map.countOf(A_KEY), 0);
+        assertTrue(map.containsKey(A_KEY));
+
+        Integer removed3 = map.remove(A_KEY);
+        assertEquals(removed3, A_VALUE);
+        assertEquals(map.countOf(A_KEY), 0);
+        assertFalse(map.containsKey(A_KEY));
+    }
+
+    @Test
+    public void entrySetTest() {
+        ReferenceCountedMap<String, Integer> map = new ReferenceCountedMap<String, Integer>();
+
+        map.put(A_KEY, A_VALUE);
+        map.put(B_KEY, B_VALUE);
+
+        Iterator<Map.Entry<String, Integer>> iterator;
+
+        // Iterate over entries but don't get values
+        iterator = map.entrySet().iterator();
+        while (iterator.hasNext()) {
+            iterator.next();
+        }
+
+        for (String key : map.keySet()) {
+            assertEquals(map.countOf(key), 0);
+        }
+
+        // Iterate over entries and get values
+        iterator = map.entrySet().iterator();
+        while (iterator.hasNext()) {
+            Map.Entry<String, Integer> entry = iterator.next();
+            entry.getValue();
+        }
+
+        for (String key : map.keySet()) {
+            assertEquals(map.countOf(key), 1);
+        }
+
+        // Iterate over entries and update values
+        iterator = map.entrySet().iterator();
+        while (iterator.hasNext()) {
+            Map.Entry<String, Integer> entry = iterator.next();
+            entry.setValue(C_VALUE);
+        }
+
+        for (String key : map.keySet()) {
+            // Verify that the value has been updated
+            assertEquals(map.get(key), C_VALUE);
+
+            // The count should be 1, since the set should have cleared it
+            // and the get should have incremented it
+            assertEquals(map.countOf(key), 1);
+        }
+
+        // Iterate over entries and remove values
+        iterator = map.entrySet().iterator();
+        while (iterator.hasNext()) {
+            iterator.next();
+            iterator.remove();
+        }
+
+        for (String key : map.keySet()) {
+            assertFalse(map.containsKey(key));
+        }
+    }
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/util/test/ResourcesTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/util/test/ResourcesTest.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/util/test/ResourcesTest.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/util/test/ResourcesTest.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.util.test;
+
+import java.io.IOException;
+
+import org.apache.pivot.util.Resources;
+import org.junit.Test;
+
+
+import static org.junit.Assert.*;
+
+public class ResourcesTest {
+    @Test
+    public void basicTest() throws IOException {
+        Resources resources = new Resources(ResourcesTest.class.getName());
+        assertEquals(resources.get("foo"), "123");
+    }
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/util/test/ResourcesTest.properties
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/util/test/ResourcesTest.properties?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/util/test/ResourcesTest.properties (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/util/test/ResourcesTest.properties Sun Jan  9 23:19:19 2011
@@ -0,0 +1,2 @@
+foo = 123
+bar = 456

Added: pivot/branches/3.x/core/test/org/apache/pivot/util/test/TimeTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/util/test/TimeTest.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/util/test/TimeTest.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/util/test/TimeTest.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.util.test;
+
+import org.apache.pivot.util.Time;
+import org.junit.Test;
+
+public class TimeTest {
+    @Test
+    public void basicTest() {
+        Time time = new Time();
+        System.out.println(time);
+
+        time = new Time(time.toMilliseconds());
+        System.out.println(time);
+
+        time = Time.decode(time.toString());
+        System.out.println(time);
+
+        time = new Time(0, 0, 0);
+        System.out.println(time.subtract(new Time(0, 0, 1)));
+        System.out.println(time.subtract(new Time(23, 59, 59, 999)));
+
+        time = new Time(0, 0, 0);
+        System.out.println(time.add(1));
+        System.out.println(time.add(Time.MILLISECONDS_PER_DAY + 1));
+        System.out.println(time.add(-1));
+        System.out.println(time.add(-Time.MILLISECONDS_PER_DAY - 1));
+        System.out.println(time.add(1000));
+        System.out.println(time.add(-1000));
+
+        time = Time.decode("00:00:00");
+        System.out.println(time);
+
+        time = Time.decode("00:00:00.000");
+        System.out.println(time);
+
+        try {
+            time = Time.decode("00:00");
+        } catch (IllegalArgumentException exception) {
+            System.out.println(exception);
+        }
+
+        try {
+            time = Time.decode("00:00:00.00");
+        } catch (IllegalArgumentException exception) {
+            System.out.println(exception);
+        }
+    }
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/xml/test/XMLSerializerTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/xml/test/XMLSerializerTest.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/xml/test/XMLSerializerTest.java (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/xml/test/XMLSerializerTest.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,109 @@
+/*
+ * Contains code originally developed for Apache Pivot under the Apache
+ * License, Version 2.0:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+package org.apache.pivot.xml.test;
+
+import java.io.IOException;
+import java.util.List;
+
+
+import org.apache.pivot.io.SerializationException;
+import org.apache.pivot.xml.Element;
+import org.apache.pivot.xml.TextNode;
+import org.apache.pivot.xml.XMLSerializer;
+import org.apache.pivot.xml.XMLSerializerListener;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class XMLSerializerTest {
+    @Test
+    public void basicTest() throws IOException, SerializationException {
+        XMLSerializer xmlSerializer = new XMLSerializer();
+
+        Element root = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
+
+        assertEquals(root.getName(), "root");
+
+        Element a = root.getElement("a");
+        assertEquals(a.getName(), "a");
+        assertEquals(a.getAttributeValue("id"), "x");
+
+        Element b = root.getElement("a/b");
+        assertEquals(b.getName(), "b");
+        assertEquals(b.getAttributeValue("id"), "y");
+
+        b = a.getElement("b");
+        assertEquals(b.getName(), "b");
+        assertEquals(b.getAttributeValue("id"), "y");
+
+        List<Element> cs = root.getElements("a/b", "c");
+        assertEquals(cs.size(), 1);
+
+        List<Element> fs = root.getElements("d/e", "f");
+        assertEquals(fs.size(), 4);
+
+        Element e = root.getElement("d/e");
+        Element f = e.getElement("f");
+        assertEquals(f.getName(), "f");
+
+        Element g = e.getElement("g");
+        assertEquals(g.getName(), "g");
+
+        String ft = root.getText("d/e/f");
+        assertEquals(ft, "1");
+
+        String gt = root.getText("d/e/g");
+        assertEquals(gt, "4");
+
+        assertNull(root.getElement("a/b/n"));
+        assertNull(root.getText("a/b/n"));
+
+        assertEquals(root.getElements("a/b", "n").size(), 0);
+
+        assertEquals(root.getText("d/foo:h"), "Hello");
+
+        List<Element> is = e.getElements("is", "i");
+        assertEquals(is.size(), 3);
+
+        assertEquals(root.getText("d[0]/e[0]/f[2]"), "3");
+        assertEquals(root.getText("d[0]/e[1]"), null);
+    }
+
+    @Test
+    public void equalsTest() throws IOException, SerializationException {
+        XMLSerializer xmlSerializer = new XMLSerializer();
+        XMLSerializerListener xmlSerializerListener = new XMLSerializerListener() {
+            @Override
+            public void beginElement(XMLSerializer xmlSerializer, Element element) {
+                System.out.println("Begin element: " + element);
+            }
+
+            @Override
+            public void endElement(XMLSerializer xmlSerializer) {
+                System.out.println("End element");
+            }
+
+            @Override
+            public void readTextNode(XMLSerializer xmlSerializer, TextNode textNode) {
+                System.out.println("Read text node: " + textNode);
+            }
+        };
+
+        xmlSerializer.getXMLSerializerListeners().add(xmlSerializerListener);
+        Element root1 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
+
+        xmlSerializer.getXMLSerializerListeners().remove(xmlSerializerListener);
+        Element root2 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
+
+        assertTrue(root1.equals(root2));
+
+        Element a = root2.getElement("a");
+        a.getAttributes().remove(0);
+
+        assertFalse(root1.equals(root2));
+    }
+}

Added: pivot/branches/3.x/core/test/org/apache/pivot/xml/test/sample.xml
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/core/test/org/apache/pivot/xml/test/sample.xml?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/core/test/org/apache/pivot/xml/test/sample.xml (added)
+++ pivot/branches/3.x/core/test/org/apache/pivot/xml/test/sample.xml Sun Jan  9 23:19:19 2011
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<root xmlns:foo="bar">
+    <a id="x">
+        <b id="y">
+            <c>ABC</c>
+        </b>
+    </a>
+
+    <d>
+        <e>
+            <f>1</f>
+            <f>2</f>
+            <f>3</f>
+            <g>4</g>
+            <f>5</f>
+            <is>
+                <i id="1"/>
+                <i id="2"/>
+                <i id="3"/>
+            </is>
+        </e>
+        <foo:h>Hello</foo:h>
+    </d>
+    <abc_123/>
+</root>

Added: pivot/branches/3.x/platform-awt/.classpath
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/platform-awt/.classpath?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/platform-awt/.classpath (added)
+++ pivot/branches/3.x/platform-awt/.classpath Sun Jan  9 23:19:19 2011
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/core"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/scene"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/ui"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: pivot/branches/3.x/platform-awt/.project
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/platform-awt/.project?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/platform-awt/.project (added)
+++ pivot/branches/3.x/platform-awt/.project Sun Jan  9 23:19:19 2011
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>platform-awt</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: pivot/branches/3.x/platform-awt/src/META-INF/services/org.apache.pivot.scene.Platform
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/platform-awt/src/META-INF/services/org.apache.pivot.scene.Platform?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/platform-awt/src/META-INF/services/org.apache.pivot.scene.Platform (added)
+++ pivot/branches/3.x/platform-awt/src/META-INF/services/org.apache.pivot.scene.Platform Sun Jan  9 23:19:19 2011
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License,
+# Version 2.0 (the "License"); you may not use this file except in
+# compliance with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Service provider for AWT platform 
+org.apache.pivot.scene.AWTPlatform

Added: pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTGraphics.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTGraphics.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTGraphics.java (added)
+++ pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTGraphics.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,397 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.scene;
+
+import java.awt.AlphaComposite;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Path2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+
+import org.apache.pivot.scene.Bounds;
+import org.apache.pivot.scene.Color;
+import org.apache.pivot.scene.Font;
+import org.apache.pivot.scene.Graphics;
+import org.apache.pivot.scene.Paint;
+import org.apache.pivot.scene.PathGeometry;
+import org.apache.pivot.scene.Platform;
+import org.apache.pivot.scene.SolidColorPaint;
+import org.apache.pivot.scene.Stroke;
+import org.apache.pivot.scene.Transform;
+import org.apache.pivot.scene.media.Raster;
+
+/**
+ * AWT graphics implementation.
+ */
+public class AWTGraphics extends Graphics {
+    private Graphics2D graphics2D;
+
+    private float alpha;
+    private CompositeOperation compositeOperation;
+    private boolean antiAliased;
+    private Stroke stroke;
+    private Paint paint;
+    private Font font;
+
+    private Line2D.Float line2D = new Line2D.Float();
+    private Rectangle2D.Float rectangle2D = new Rectangle2D.Float();
+    private RoundRectangle2D.Float roundRectangle2D = new RoundRectangle2D.Float();
+    private Arc2D.Float arc2D = new Arc2D.Float();
+    private Ellipse2D.Float ellipse2D = new Ellipse2D.Float();
+
+    public AWTGraphics(Graphics2D graphics2D) {
+        if (graphics2D == null) {
+            throw new IllegalArgumentException();
+        }
+
+        this.graphics2D = graphics2D;
+
+        setAlpha(1.0f);
+        setCompositeOperation(CompositeOperation.SOURCE_OVER);
+        setAntiAliased(false);
+        setStroke(new Stroke());
+        setPaint(new SolidColorPaint(Color.BLACK));
+        setFont(Platform.getPlatform().getDefaultFont());
+    }
+
+    // Clipping
+    @Override
+    public void clip(int x, int y, int width, int height) {
+        graphics2D.clipRect(x, y, width, height);
+    }
+
+    @Override
+    public Bounds getClipBounds() {
+        Rectangle clipBounds = graphics2D.getClipBounds();
+        return new Bounds(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height);
+    }
+
+    // Compositing
+    @Override
+    public float getAlpha() {
+        return alpha;
+    }
+
+    @Override
+    public void setAlpha(float alpha) {
+        if (alpha < 0
+            || alpha > 1) {
+            throw new IllegalArgumentException("Alpha must be between 0 and 1.");
+        }
+
+        this.alpha = alpha;
+
+        AlphaComposite alphaComposite = (AlphaComposite)graphics2D.getComposite();
+        graphics2D.setComposite(alphaComposite.derive(alpha));
+    }
+
+    @Override
+    public CompositeOperation getCompositeOperation() {
+        return compositeOperation;
+    }
+
+    @Override
+    public void setCompositeOperation(CompositeOperation compositeOperation) {
+        int rule = -1;
+        switch (compositeOperation) {
+            case SOURCE_ATOP: {
+                rule = AlphaComposite.SRC_ATOP;
+                break;
+            }
+
+            case SOURCE_IN: {
+                rule = AlphaComposite.SRC_IN;
+                break;
+            }
+
+            case SOURCE_OUT: {
+                rule = AlphaComposite.SRC_OUT;
+                break;
+            }
+
+            case SOURCE_OVER: {
+                rule = AlphaComposite.SRC_OVER;
+                break;
+            }
+
+            case DESTINATION_ATOP: {
+                rule = AlphaComposite.DST_ATOP;
+                break;
+            }
+
+            case DESTINATION_IN: {
+                rule = AlphaComposite.DST_IN;
+                break;
+            }
+
+            case DESTINATION_OUT: {
+                rule = AlphaComposite.DST_OUT;
+                break;
+            }
+
+            case DESTINATION_OVER: {
+                rule = AlphaComposite.DST_OVER;
+                break;
+            }
+
+            case CLEAR: {
+                rule = AlphaComposite.CLEAR;
+                break;
+            }
+
+            case XOR: {
+                rule = AlphaComposite.XOR;
+                break;
+            }
+        }
+
+        graphics2D.setComposite(AlphaComposite.getInstance(rule, alpha));
+    }
+
+    // Anti-aliasing
+    @Override
+    public boolean isAntiAliased() {
+        return antiAliased;
+    }
+
+    @Override
+    public void setAntiAliased(boolean antiAliased) {
+        this.antiAliased = antiAliased;
+
+        graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAliased ?
+            RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
+    }
+
+    // Primitive drawing/filling
+    @Override
+    public Stroke getStroke() {
+        return stroke;
+    }
+
+    @Override
+    public void setStroke(Stroke stroke) {
+        if (stroke == null) {
+            throw new IllegalArgumentException("stroke is null.");
+        }
+
+        graphics2D.setStroke((java.awt.Stroke)stroke.getNativeStroke());
+    }
+
+    @Override
+    public Paint getPaint() {
+        return paint;
+    }
+
+    @Override
+    public void setPaint(Paint paint) {
+        if (paint == null) {
+            throw new IllegalArgumentException("paint is null.");
+        }
+
+        this.paint = paint;
+
+        graphics2D.setPaint((java.awt.Paint)paint.getNativePaint());
+    }
+
+    @Override
+    public void drawLine(float x1, float y1, float x2, float y2) {
+        // TODO Optimize to use drawLine() when appropriate
+
+        line2D.x1 = x1;
+        line2D.y1 = y1;
+        line2D.x2 = x2;
+        line2D.y2 = y2;
+
+        graphics2D.draw(line2D);
+    }
+
+    @Override
+    public void drawRectangle(float x, float y, float width, float height, float cornerRadius) {
+        // TODO Optimize to use drawRect() or drawRoundRect() when appropriate
+
+        if (cornerRadius == 0) {
+            rectangle2D.x = x;
+            rectangle2D.y = y;
+            rectangle2D.width = width;
+            rectangle2D.height = height;
+
+            graphics2D.draw(rectangle2D);
+        } else {
+            roundRectangle2D.x = x;
+            roundRectangle2D.y = y;
+            roundRectangle2D.width = width;
+            roundRectangle2D.height = height;
+            roundRectangle2D.archeight = cornerRadius;
+            roundRectangle2D.arcwidth = cornerRadius;
+
+            graphics2D.draw(roundRectangle2D);
+        }
+    }
+
+    @Override
+    public void drawArc(float x, float y, float width, float height, float start, float extent) {
+        // TODO Optimize to use drawArc() when appropriate
+
+        arc2D.x = x;
+        arc2D.y = y;
+        arc2D.width = width;
+        arc2D.height = height;
+        arc2D.start = start;
+        arc2D.extent = extent;
+
+        graphics2D.draw(arc2D);
+    }
+
+    @Override
+    public void drawEllipse(float x, float y, float width, float height) {
+        // TODO Optimize to use drawOval() when appropriate
+
+        ellipse2D.x = x;
+        ellipse2D.y = y;
+        ellipse2D.width = width;
+        ellipse2D.height = height;
+
+        graphics2D.draw(ellipse2D);
+    }
+
+    @Override
+    public void drawPath(PathGeometry pathGeometry) {
+        graphics2D.draw((Path2D.Float)pathGeometry.getNativePathGeometry());
+    }
+
+    @Override
+    public void fillRectangle(float x, float y, float width, float height, float cornerRadius) {
+        // TODO Optimize to use fillRect() or fillRoundRect() when appropriate
+
+        if (cornerRadius == 0) {
+            rectangle2D.x = x;
+            rectangle2D.y = y;
+            rectangle2D.width = width;
+            rectangle2D.height = height;
+
+            graphics2D.fill(rectangle2D);
+        } else {
+            roundRectangle2D.x = x;
+            roundRectangle2D.y = y;
+            roundRectangle2D.width = width;
+            roundRectangle2D.height = height;
+            roundRectangle2D.archeight = cornerRadius;
+            roundRectangle2D.arcwidth = cornerRadius;
+
+            graphics2D.fill(roundRectangle2D);
+        }
+    }
+
+    @Override
+    public void fillArc(float x, float y, float width, float height, float start, float extent) {
+        // TODO Optimize to use fillArc() when appropriate
+
+        arc2D.x = x;
+        arc2D.y = y;
+        arc2D.width = width;
+        arc2D.height = height;
+        arc2D.start = start;
+        arc2D.extent = extent;
+
+        graphics2D.fill(arc2D);
+    }
+
+    @Override
+    public void fillEllipse(float x, float y, float width, float height) {
+        // TODO Optimize to use drawOval() when appropriate
+
+        ellipse2D.x = x;
+        ellipse2D.y = y;
+        ellipse2D.width = width;
+        ellipse2D.height = height;
+
+        graphics2D.draw(ellipse2D);
+    }
+
+    @Override
+    public void fillPath(PathGeometry pathGeometry) {
+        graphics2D.fill((Path2D.Float)pathGeometry.getNativePathGeometry());
+    }
+
+    @Override
+    public void drawRaster(Raster raster, int x, int y, int width, int height) {
+        graphics2D.drawImage((BufferedImage)raster.getNativeRaster(), x, y, null);
+    }
+
+    // Blitting
+    @Override
+    public void copyArea(int x, int y, int width, int height, int dx, int dy) {
+        graphics2D.copyArea(x, y, width, height, dx, dy);
+    }
+
+    // Text
+    @Override
+    public Font getFont() {
+        return font;
+    }
+
+    @Override
+    public void setFont(Font font) {
+        graphics2D.setFont((java.awt.Font)font.getNativeFont());
+    }
+
+    @Override
+    public void drawText(CharSequence text, int start, int length, float x, float y) {
+        java.awt.Font nativeFont = (java.awt.Font)font.getNativeFont();
+        FontRenderContext fontRenderContext = AWTPlatform.getFontRenderContext();
+        GlyphVector glyphVector = nativeFont.createGlyphVector(fontRenderContext,
+            new CharSequenceCharacterIterator(text, start, start + length));
+
+        graphics2D.drawGlyphVector(glyphVector, x, y);
+    }
+
+    // Transformations
+    @Override
+    public void transform(float m11, float m12, float m21, float m22, float dx, float dy) {
+        // TODO
+    }
+
+    @Override
+    public Transform getCurrentTransform() {
+        // TODO
+        return null;
+    }
+
+    // Creation/disposal
+    @Override
+    public Graphics create() {
+        return new AWTGraphics((Graphics2D)graphics2D.create());
+    }
+
+    @Override
+    public void dispose() {
+        graphics2D.dispose();
+    }
+
+    @Override
+    public Object getNativeGraphics() {
+        return graphics2D;
+    }
+}

Added: pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTPlatform.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTPlatform.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTPlatform.java (added)
+++ pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTPlatform.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.scene;
+
+import java.awt.BasicStroke;
+import java.awt.RenderingHints;
+import java.awt.Toolkit;
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
+import java.awt.geom.Path2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+
+import org.apache.pivot.scene.Font;
+import org.apache.pivot.scene.LinearGradientPaint;
+import org.apache.pivot.scene.MultiStopGradientPaint;
+import org.apache.pivot.scene.PathGeometry;
+import org.apache.pivot.scene.Platform;
+import org.apache.pivot.scene.RadialGradientPaint;
+import org.apache.pivot.scene.SolidColorPaint;
+import org.apache.pivot.scene.Stroke;
+import org.apache.pivot.scene.media.Raster;
+
+/**
+ * AWT platform implementation.
+ */
+public class AWTPlatform extends Platform {
+    private static FontRenderContext fontRenderContext;
+
+    static {
+        // Initialize the font render context
+        initializeFontRenderContext();
+
+        // Listen for changes to the font desktop hints property
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        toolkit.addPropertyChangeListener("awt.font.desktophints", new PropertyChangeListener() {
+            @Override
+            public void propertyChange(PropertyChangeEvent event) {
+                initializeFontRenderContext();
+            }
+        });
+    }
+
+    @Override
+    public Font.Metrics getFontMetrics(Font font) {
+        java.awt.Font nativeFont = getNativeFont(font);
+        LineMetrics lm = nativeFont.getLineMetrics("", fontRenderContext);
+
+        return new Font.Metrics(lm.getAscent(), lm.getDescent(), lm.getLeading());
+    }
+
+    @Override
+    public float measureText(Font font, CharSequence text, int start, int length) {
+        java.awt.Font nativeFont = getNativeFont(font);
+        Rectangle2D stringBounds = nativeFont.getStringBounds(new CharSequenceCharacterIterator(text),
+            0, text.length(), fontRenderContext);
+
+        return (int)Math.ceil(stringBounds.getWidth());
+    }
+
+    @Override
+    public Raster readRaster(InputStream inputStream) throws IOException {
+        return new AWTRaster(ImageIO.read(inputStream));
+    }
+
+    @Override
+    public void writeRaster(Raster raster, String mimeType,  OutputStream outputStream)
+        throws IOException {
+        ImageIO.write((BufferedImage)raster.getNativeRaster(), mimeType, outputStream);
+    }
+
+    @Override
+    protected java.awt.Font getNativeFont(Font font) {
+        int style = 0;
+
+        if (font.bold) {
+            style |= java.awt.Font.BOLD;
+        }
+
+        if (font.italic) {
+            style |= java.awt.Font.ITALIC;
+        }
+
+        return new java.awt.Font(font.name, font.size, style);
+    }
+
+    @Override
+    protected java.awt.Color getNativePaint(SolidColorPaint solidColorPaint) {
+        return new java.awt.Color(solidColorPaint.color.red,
+            solidColorPaint.color.green,
+            solidColorPaint.color.blue,
+            solidColorPaint.color.alpha);
+    }
+
+    @Override
+    protected java.awt.LinearGradientPaint getNativePaint(LinearGradientPaint linearGradientPaint) {
+        int n = linearGradientPaint.stops.size();
+        float[] fractions = new float[n];
+        java.awt.Color[] colors = new java.awt.Color[n];
+
+        for (int i = 0; i < n; i++) {
+            MultiStopGradientPaint.Stop stop = linearGradientPaint.stops.get(i);
+            fractions[i] = stop.offset;
+            colors[i] = new java.awt.Color(stop.color.red,
+                stop.color.green,
+                stop.color.blue,
+                stop.color.alpha);
+        }
+
+        return new java.awt.LinearGradientPaint(linearGradientPaint.start.x,
+            linearGradientPaint.start.y,
+            linearGradientPaint.end.x,
+            linearGradientPaint.end.y,
+            fractions, colors);
+    }
+
+    @Override
+    protected java.awt.RadialGradientPaint getNativePaint(RadialGradientPaint radialGradientPaint) {
+        int n = radialGradientPaint.stops.size();
+        float[] fractions = new float[n];
+        java.awt.Color[] colors = new java.awt.Color[n];
+
+        for (int i = 0; i < n; i++) {
+            MultiStopGradientPaint.Stop stop = radialGradientPaint.stops.get(i);
+            fractions[i] = stop.offset;
+            colors[i] = new java.awt.Color(stop.color.red,
+                stop.color.green,
+                stop.color.blue,
+                stop.color.alpha);
+        }
+
+        return new java.awt.RadialGradientPaint(radialGradientPaint.center.x,
+            radialGradientPaint.center.y,
+            radialGradientPaint.radius, fractions, colors);
+    }
+
+    @Override
+    protected BasicStroke getNativeStroke(Stroke stroke) {
+        int cap = -1;
+        switch (stroke.lineCap) {
+            case BUTT: {
+                cap = BasicStroke.CAP_BUTT;
+                break;
+            }
+
+            case ROUND: {
+                cap = BasicStroke.CAP_ROUND;
+                break;
+            }
+
+            case SQUARE: {
+                cap = BasicStroke.CAP_SQUARE;
+                break;
+            }
+        }
+
+        int join = -1;
+        switch (stroke.lineJoin) {
+            case ROUND: {
+                join = BasicStroke.JOIN_ROUND;
+                break;
+            }
+
+            case BEVEL: {
+                join = BasicStroke.JOIN_BEVEL;
+                break;
+            }
+
+            case MITER: {
+                join = BasicStroke.JOIN_MITER;
+                break;
+            }
+        }
+
+        float[] dash = null;
+        float dashPhase = 0f;
+        switch (stroke.lineStyle) {
+            case DASHED: {
+                // TODO
+                break;
+            }
+
+            case DOTTED: {
+                // TODO
+                break;
+            }
+        }
+
+        return new BasicStroke(stroke.lineWidth, cap, join, stroke.miterLimit, dash, dashPhase);
+    }
+
+    @Override
+    protected Path2D.Float getNativePathGeometry(PathGeometry pathGeometry) {
+        // TODO
+        return null;
+    }
+
+    public static FontRenderContext getFontRenderContext() {
+        return fontRenderContext;
+    }
+
+    private static void initializeFontRenderContext() {
+        Object aaHint = null;
+        Object fmHint = null;
+
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        java.util.Map<?, ?> fontDesktopHints =
+            (java.util.Map<?, ?>)toolkit.getDesktopProperty("awt.font.desktophints");
+        if (fontDesktopHints != null) {
+            aaHint = fontDesktopHints.get(RenderingHints.KEY_TEXT_ANTIALIASING);
+            fmHint = fontDesktopHints.get(RenderingHints.KEY_FRACTIONALMETRICS);
+        }
+
+        if (aaHint == null) {
+            aaHint = RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
+        }
+
+        if (fmHint == null) {
+            fmHint = RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT;
+        }
+
+        fontRenderContext = new FontRenderContext(null, aaHint, fmHint);
+    }
+}

Added: pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTRaster.java
URL: http://svn.apache.org/viewvc/pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTRaster.java?rev=1057053&view=auto
==============================================================================
--- pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTRaster.java (added)
+++ pivot/branches/3.x/platform-awt/src/org/apache/pivot/scene/AWTRaster.java Sun Jan  9 23:19:19 2011
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.scene;
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+
+import org.apache.pivot.scene.Color;
+import org.apache.pivot.scene.Graphics;
+import org.apache.pivot.scene.media.Raster;
+
+/**
+ * AWT raster implementation.
+ */
+public class AWTRaster extends Raster {
+    private BufferedImage bufferedImage;
+
+    public AWTRaster(BufferedImage bufferedImage) {
+        if (bufferedImage == null) {
+            throw new IllegalArgumentException();
+        }
+
+        this.bufferedImage = bufferedImage;
+    }
+
+    @Override
+    public int getWidth() {
+        return bufferedImage.getWidth();
+    }
+
+    @Override
+    public int getHeight() {
+        return bufferedImage.getHeight();
+    }
+
+    @Override
+    public Color getPixel(int x, int y) {
+        return new Color(bufferedImage.getRGB(x, y));
+    }
+
+    @Override
+    public void setPixel(int x, int y, Color color) {
+        bufferedImage.setRGB(x, y, color.toInt());
+    }
+
+    @Override
+    public Graphics getGraphics() {
+        Graphics2D graphics2D = (Graphics2D)bufferedImage.getGraphics();
+        graphics2D.clipRect(0, 0, getWidth(), getHeight());
+
+        return new AWTGraphics(graphics2D);
+    }
+
+    @Override
+    public BufferedImage getNativeRaster() {
+        return bufferedImage;
+    }
+}