Commits

Michael Ludwig committed 712cb81

Update vector math properties to use entreri-1.5.2 and add useful default annotations.

  • Participants
  • Parent commits 2b93b78

Comments (0)

Files changed (8)

File ferox-math/pom.xml

         <dependency>
             <groupId>com.lhkbob.entreri</groupId>
             <artifactId>entreri</artifactId>
-            <version>1.5.1</version>
-            <scope>compile</scope>
+            <version>1.5.2</version>
             <optional>true</optional>
         </dependency>
     </dependencies>

File ferox-math/src/main/java/com/ferox/math/entreri/AxisAlignedBoxProperty.java

 package com.ferox.math.entreri;
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
 import com.ferox.math.Const;
 import com.ferox.math.bounds.AxisAlignedBox;
+import com.lhkbob.entreri.Attribute;
+import com.lhkbob.entreri.Attributes;
+import com.lhkbob.entreri.Factory;
+import com.lhkbob.entreri.IndexedDataStore;
+import com.lhkbob.entreri.Property;
 import com.lhkbob.entreri.property.AbstractPropertyFactory;
 import com.lhkbob.entreri.property.DoubleProperty;
-import com.lhkbob.entreri.property.IndexedDataStore;
-import com.lhkbob.entreri.property.Property;
-import com.lhkbob.entreri.property.PropertyFactory;
 
 /**
  * AxisAlignedBoxProperty is a property that wraps a {@link DoubleProperty} as a
  * 
  * @author Michael Ludwig
  */
+@Factory(AxisAlignedBoxProperty.Factory.class)
 public class AxisAlignedBoxProperty implements Property {
     private static final int REQUIRED_ELEMENTS = 6;
     
     }
     
     /**
-     * @return PropertyFactory that creates AxisAlignedBoxProperties
-     */
-    public static PropertyFactory<AxisAlignedBoxProperty> factory() {
-        return new AbstractPropertyFactory<AxisAlignedBoxProperty>() {
-            @Override
-            public AxisAlignedBoxProperty create() {
-                return new AxisAlignedBoxProperty();
-            }
-
-            @Override
-            public void setDefaultValue(AxisAlignedBoxProperty property, int index) {
-                for (int i = 0; i < REQUIRED_ELEMENTS; i++) {
-                    property.data.set(0f, index, i);
-                }
-            }
-        };
-    }
-
-    /**
      * Get the axis aligned box of this property, for the component at the given
      * index, and store it into <tt>result</tt>. If result is null, a new
      * AxisAlignedBox is created and returned.
     public void setDataStore(IndexedDataStore store) {
         data.setDataStore(store);
     }
+    
+    /**
+     * Attribute annotation to apply to AxisAlignedBoxProperty declarations,
+     * to specify the minimum coordinate of the box.
+     * 
+     * @author Michael Ludwig
+     */
+    @Attribute
+    @Target(ElementType.FIELD)
+    @Retention(RetentionPolicy.RUNTIME)
+    public static @interface DefaultMin {
+        /**
+         * @return Default x coordinate
+         */
+        double x();
+        /**
+         * @return Default y coordinate
+         */
+        double y();
+        /**
+         * @return Default z coordinate
+         */
+        double z();
+    }
+    
+    /**
+     * Attribute annotation to apply to AxisAlignedBoxProperty declarations,
+     * to specify the maximum coordinate of the box.
+     * 
+     * @author Michael Ludwig
+     */
+    @Attribute
+    @Target(ElementType.FIELD)
+    @Retention(RetentionPolicy.RUNTIME)
+    public static @interface DefaultMax {
+        /**
+         * @return Default x coordinate
+         */
+        double x();
+        /**
+         * @return Default y coordinate
+         */
+        double y();
+        /**
+         * @return Default z coordinate
+         */
+        double z();
+    }
+    
+    /**
+     * Default factory implementation for AxisAlignedBoxProperties, supports the
+     * {@link DefaultMin} and {@link DefaultMax} annotations to specify the
+     * default bounding box.
+     * 
+     * @author Michael Ludwig
+     */
+    public static class Factory extends AbstractPropertyFactory<AxisAlignedBoxProperty> {
+        private final AxisAlignedBox dflt;
+        
+        public Factory(Attributes attrs) {
+            super(attrs);
+            dflt = new AxisAlignedBox();
+            
+            if (attrs.hasAttribute(DefaultMin.class)) {
+                DefaultMin min = attrs.getAttribute(DefaultMin.class);
+                dflt.min.set(min.x(), min.y(), min.z());
+            }
+            
+            if (attrs.hasAttribute(DefaultMax.class)) {
+                DefaultMax max = attrs.getAttribute(DefaultMax.class);
+                dflt.min.set(max.x(), max.y(), max.z());
+            }
+        }
+        
+        public Factory(@Const AxisAlignedBox v) {
+            super(null);
+            dflt = new AxisAlignedBox(v);
+        }
+
+        @Override
+        public AxisAlignedBoxProperty create() {
+            return new AxisAlignedBoxProperty();
+        }
+
+        @Override
+        public void setDefaultValue(AxisAlignedBoxProperty property, int index) {
+            property.set(dflt, index);
+        }
+    }
 }

File ferox-math/src/main/java/com/ferox/math/entreri/ColorRGBProperty.java

 package com.ferox.math.entreri;
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
 import com.ferox.math.ColorRGB;
 import com.ferox.math.Const;
+import com.lhkbob.entreri.Attribute;
+import com.lhkbob.entreri.Attributes;
+import com.lhkbob.entreri.Factory;
+import com.lhkbob.entreri.IndexedDataStore;
+import com.lhkbob.entreri.Property;
 import com.lhkbob.entreri.property.AbstractPropertyFactory;
 import com.lhkbob.entreri.property.DoubleProperty;
-import com.lhkbob.entreri.property.IndexedDataStore;
-import com.lhkbob.entreri.property.Property;
-import com.lhkbob.entreri.property.PropertyFactory;
 
 /**
  * ColorRGBProperty is a caching property that wraps a DoubleProperty as a
  * 
  * @author Michael Ludwig
  */
+@Factory(ColorRGBProperty.Factory.class)
 public class ColorRGBProperty implements Property {
     private static final int REQUIRED_ELEMENTS = 3;
 
     public ColorRGBProperty() {
         data = new DoubleProperty(REQUIRED_ELEMENTS);
     }
-    
-    /**
-     * @return PropertyFactory that creates ColorRGBProperties
-     */
-    public static PropertyFactory<ColorRGBProperty> factory() {
-        return new AbstractPropertyFactory<ColorRGBProperty>() {
-            @Override
-            public ColorRGBProperty create() {
-                return new ColorRGBProperty();
-            }
-
-            @Override
-            public void setDefaultValue(ColorRGBProperty property, int index) {
-                for (int i = 0; i < REQUIRED_ELEMENTS; i++) {
-                    property.data.set(0f, index, i);
-                }
-            }
-        };
-    }
 
     /**
      * Get the color of this property, for the component at the given
     public void setDataStore(IndexedDataStore store) {
         data.setDataStore(store);
     }
+    
+    /**
+     * Attribute annotation to apply to ColorRGBProperty declarations.
+     * 
+     * @author Michael Ludwig
+     */
+    @Attribute
+    @Target(ElementType.FIELD)
+    @Retention(RetentionPolicy.RUNTIME)
+    public static @interface DefaultColor {
+        /**
+         * @return Default red value in HDR
+         */
+        double red();
+        /**
+         * @return Default green value in HDR
+         */
+        double green();
+        /**
+         * @return Default blue value in HDR
+         */
+        double blue();
+    }
+    
+    /**
+     * Default factory implementation for ColorRGBProperties, supports the
+     * {@link DefaultColor} annotation to specify the default color.
+     * 
+     * @author Michael Ludwig
+     */
+    public static class Factory extends AbstractPropertyFactory<ColorRGBProperty> {
+        private final ColorRGB dflt;
+        
+        public Factory(Attributes attrs) {
+            super(attrs);
+            if (attrs.hasAttribute(DefaultColor.class)) {
+                DefaultColor v = attrs.getAttribute(DefaultColor.class);
+                dflt = new ColorRGB(v.red(), v.green(), v.blue());
+            } else {
+                dflt = new ColorRGB();
+            }
+        }
+        
+        public Factory(@Const ColorRGB v) {
+            super(null);
+            dflt = new ColorRGB(v);
+        }
+
+        @Override
+        public ColorRGBProperty create() {
+            return new ColorRGBProperty();
+        }
+
+        @Override
+        public void setDefaultValue(ColorRGBProperty property, int index) {
+            property.set(dflt, index);
+        }
+    }
 }

File ferox-math/src/main/java/com/ferox/math/entreri/Matrix3Property.java

 package com.ferox.math.entreri;
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.ferox.math.Const;
 import com.ferox.math.Matrix3;
+import com.lhkbob.entreri.Attribute;
+import com.lhkbob.entreri.Attributes;
+import com.lhkbob.entreri.Factory;
+import com.lhkbob.entreri.IndexedDataStore;
+import com.lhkbob.entreri.Property;
 import com.lhkbob.entreri.property.AbstractPropertyFactory;
 import com.lhkbob.entreri.property.DoubleProperty;
-import com.lhkbob.entreri.property.IndexedDataStore;
-import com.lhkbob.entreri.property.Property;
-import com.lhkbob.entreri.property.PropertyFactory;
 
 /**
  * Matrix3Property is a caching property that wraps a DoubleProperty as a
  * 
  * @author Michael Ludwig
  */
+@Factory(Matrix3Property.Factory.class)
 public class Matrix3Property implements Property {
     private static final int REQUIRED_ELEMENTS = 9;
 
     }
     
     /**
-     * @return PropertyFactory that creates Matrix3Properties
-     */
-    public static PropertyFactory<Matrix3Property> factory() {
-        return new AbstractPropertyFactory<Matrix3Property>() {
-            @Override
-            public Matrix3Property create() {
-                return new Matrix3Property();
-            }
-
-            @Override
-            public void setDefaultValue(Matrix3Property property, int index) {
-                for (int i = 0; i < REQUIRED_ELEMENTS; i++) {
-                    property.data.set(0f, index, i);
-                }
-            }
-        };
-    }
-
-    /**
      * Get the matrix of this property, for the component at the given
      * index, and store it into <tt>result</tt>. If result is null, a new
      * Matrix3 is created and returned.
     public void setDataStore(IndexedDataStore store) {
         data.setDataStore(store);
     }
+    
+    /**
+     * Attribute annotation to apply to Matrix3Property declarations.
+     * 
+     * @author Michael Ludwig
+     */
+    @Attribute
+    @Target(ElementType.FIELD)
+    @Retention(RetentionPolicy.RUNTIME)
+    public static @interface DefaultMatrix3 {
+        /**
+         * @return Default m00 value
+         */
+        double m00();
+        /**
+         * @return Default m01 value
+         */
+        double m01();
+        /**
+         * @return Default m02 value
+         */
+        double m02();
+        /**
+         * @return Default m10 value
+         */
+        double m10();
+        /**
+         * @return Default m11 value
+         */
+        double m11();
+        /**
+         * @return Default m12 value
+         */
+        double m12();
+        /**
+         * @return Default m20 value
+         */
+        double m20();
+        /**
+         * @return Default m21 value
+         */
+        double m21();
+        /**
+         * @return Default m22 value
+         */
+        double m22();
+    }
+    
+    /**
+     * Default factory implementation for Matrix3Properties, supports the
+     * {@link DefaultMatrix3} annotation to specify the default matrix
+     * coordinates.
+     * 
+     * @author Michael Ludwig
+     */
+    public static class Factory extends AbstractPropertyFactory<Matrix3Property> {
+        private final Matrix3 dflt;
+        
+        public Factory(Attributes attrs) {
+            super(attrs);
+            if (attrs.hasAttribute(DefaultMatrix3.class)) {
+                DefaultMatrix3 v = attrs.getAttribute(DefaultMatrix3.class);
+                dflt = new Matrix3(v.m00(), v.m01(), v.m02(),
+                                   v.m10(), v.m11(), v.m12(),
+                                   v.m20(), v.m21(), v.m22());
+            } else {
+                dflt = new Matrix3();
+            }
+        }
+        
+        public Factory(@Const Matrix3 v) {
+            super(null);
+            dflt = new Matrix3(v);
+        }
+
+        @Override
+        public Matrix3Property create() {
+            return new Matrix3Property();
+        }
+
+        @Override
+        public void setDefaultValue(Matrix3Property property, int index) {
+            property.set(dflt, index);
+        }
+    }
 }

File ferox-math/src/main/java/com/ferox/math/entreri/Matrix4Property.java

 package com.ferox.math.entreri;
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
 import com.ferox.math.Const;
 import com.ferox.math.Matrix4;
+import com.lhkbob.entreri.Attribute;
+import com.lhkbob.entreri.Attributes;
+import com.lhkbob.entreri.Factory;
+import com.lhkbob.entreri.IndexedDataStore;
+import com.lhkbob.entreri.Property;
 import com.lhkbob.entreri.property.AbstractPropertyFactory;
 import com.lhkbob.entreri.property.DoubleProperty;
-import com.lhkbob.entreri.property.IndexedDataStore;
-import com.lhkbob.entreri.property.Property;
-import com.lhkbob.entreri.property.PropertyFactory;
 
 /**
  * Matrix4Property is a caching property that wraps a DoubleProperty as a
  * 
  * @author Michael Ludwig
  */
+@Factory(Matrix4Property.Factory.class)
 public class Matrix4Property implements Property {
     private static final int REQUIRED_ELEMENTS = 16;
 
     }
     
     /**
-     * @return PropertyFactory that creates Matrix4Properties
-     */
-    public static PropertyFactory<Matrix4Property> factory() {
-        return new AbstractPropertyFactory<Matrix4Property>() {
-            @Override
-            public Matrix4Property create() {
-                return new Matrix4Property();
-            }
-
-            @Override
-            public void setDefaultValue(Matrix4Property property, int index) {
-                for (int i = 0; i < REQUIRED_ELEMENTS; i++) {
-                    property.data.set(0f, index, i);
-                }
-            }
-        };
-    }
-    
-    /**
      * Get the matrix of this property, for the component at the given
      * index, and store it into <tt>result</tt>. If result is null, a new
      * Matrix4 is created and returned.
     public void setDataStore(IndexedDataStore store) {
         data.setDataStore(store);
     }
+    
+    /**
+     * Attribute annotation to apply to Matrix4Property declarations.
+     * 
+     * @author Michael Ludwig
+     */
+    @Attribute
+    @Target(ElementType.FIELD)
+    @Retention(RetentionPolicy.RUNTIME)
+    public static @interface DefaultMatrix4 {
+        /**
+         * @return Default m00 value
+         */
+        double m00();
+        /**
+         * @return Default m01 value
+         */
+        double m01();
+        /**
+         * @return Default m02 value
+         */
+        double m02();
+        /**
+         * @return Default m03 value
+         */
+        double m03();
+        /**
+         * @return Default m10 value
+         */
+        double m10();
+        /**
+         * @return Default m11 value
+         */
+        double m11();
+        /**
+         * @return Default m12 value
+         */
+        double m12();
+        /**
+         * @return Default m13 value
+         */
+        double m13();
+        /**
+         * @return Default m20 value
+         */
+        double m20();
+        /**
+         * @return Default m21 value
+         */
+        double m21();
+        /**
+         * @return Default m22 value
+         */
+        double m22();
+        /**
+         * @return Default m23 value
+         */
+        double m23();
+        /**
+         * @return Default m30 value
+         */
+        double m30();
+        /**
+         * @return Default m31 value
+         */
+        double m31();
+        /**
+         * @return Default m32 value
+         */
+        double m32();
+        /**
+         * @return Default m33 value
+         */
+        double m33();
+    }
+    
+    /**
+     * Default factory implementation for Matrix4Properties, supports the
+     * {@link DefaultMatrix4} annotation to specify the default matrix
+     * coordinates.
+     * 
+     * @author Michael Ludwig
+     */
+    public static class Factory extends AbstractPropertyFactory<Matrix4Property> {
+        private final Matrix4 dflt;
+        
+        public Factory(Attributes attrs) {
+            super(attrs);
+            if (attrs.hasAttribute(DefaultMatrix4.class)) {
+                DefaultMatrix4 v = attrs.getAttribute(DefaultMatrix4.class);
+                dflt = new Matrix4(v.m00(), v.m01(), v.m02(), v.m03(),
+                                   v.m10(), v.m11(), v.m12(), v.m13(),
+                                   v.m20(), v.m21(), v.m22(), v.m23(),
+                                   v.m30(), v.m31(), v.m32(), v.m33());
+            } else {
+                dflt = new Matrix4();
+            }
+        }
+        
+        public Factory(@Const Matrix4 v) {
+            super(null);
+            dflt = new Matrix4(v);
+        }
+
+        @Override
+        public Matrix4Property create() {
+            return new Matrix4Property();
+        }
+
+        @Override
+        public void setDefaultValue(Matrix4Property property, int index) {
+            property.set(dflt, index);
+        }
+    }
 }

File ferox-math/src/main/java/com/ferox/math/entreri/Quat4Property.java

 package com.ferox.math.entreri;
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
 import com.ferox.math.Const;
 import com.ferox.math.Quat4;
+import com.lhkbob.entreri.Attribute;
+import com.lhkbob.entreri.Attributes;
+import com.lhkbob.entreri.Factory;
+import com.lhkbob.entreri.IndexedDataStore;
+import com.lhkbob.entreri.Property;
 import com.lhkbob.entreri.property.AbstractPropertyFactory;
 import com.lhkbob.entreri.property.DoubleProperty;
-import com.lhkbob.entreri.property.IndexedDataStore;
-import com.lhkbob.entreri.property.Property;
-import com.lhkbob.entreri.property.PropertyFactory;
 
 /**
  * Quat4Property is a caching property that wraps a DoubleProperty as a
  * 
  * @author Michael Ludwig
  */
+@Factory(Quat4Property.Factory.class)
 public class Quat4Property implements Property {
     private static final int REQUIRED_ELEMENTS = 4;
 
     }
     
     /**
-     * @return PropertyFactory that creates Quat4Properties
-     */
-    public static PropertyFactory<Quat4Property> factory() {
-        return new AbstractPropertyFactory<Quat4Property>() {
-            @Override
-            public Quat4Property create() {
-                return new Quat4Property();
-            }
-
-            @Override
-            public void setDefaultValue(Quat4Property property, int index) {
-                for (int i = 0; i < REQUIRED_ELEMENTS; i++) {
-                    property.data.set(0, index, i);
-                }
-            }
-        };
-    }
-    
-    /**
      * Get the quaternion of this property, for the component at the given
      * index, and store it into <tt>result</tt>. If result is null, a new
      * Quat4 is created and returned.
     public void setDataStore(IndexedDataStore store) {
         data.setDataStore(store);
     }
+    
+    /**
+     * Attribute annotation to apply to Quat4Property declarations.
+     * 
+     * @author Michael Ludwig
+     */
+    @Attribute
+    @Target(ElementType.FIELD)
+    @Retention(RetentionPolicy.RUNTIME)
+    public static @interface DefaultQuat4 {
+        /**
+         * @return Default x coordinate
+         */
+        double x();
+        /**
+         * @return Default y coordinate
+         */
+        double y();
+        /**
+         * @return Default z coordinate
+         */
+        double z();
+        /**
+         * @return Default w coordinate
+         */
+        double w();
+    }
+    
+    /**
+     * Default factory implementation for Quat4Properties, supports the
+     * {@link DefaultQuat4} annotation to specify the default quaternion
+     * coordinates.
+     * 
+     * @author Michael Ludwig
+     */
+    public static class Factory extends AbstractPropertyFactory<Quat4Property> {
+        private final Quat4 dflt;
+        
+        public Factory(Attributes attrs) {
+            super(attrs);
+            if (attrs.hasAttribute(DefaultQuat4.class)) {
+                DefaultQuat4 v = attrs.getAttribute(DefaultQuat4.class);
+                dflt = new Quat4(v.x(), v.y(), v.z(), v.w());
+            } else {
+                dflt = new Quat4();
+            }
+        }
+        
+        public Factory(@Const Quat4 v) {
+            super(null);
+            dflt = new Quat4(v);
+        }
+
+        @Override
+        public Quat4Property create() {
+            return new Quat4Property();
+        }
+
+        @Override
+        public void setDefaultValue(Quat4Property property, int index) {
+            property.set(dflt, index);
+        }
+    }
 }

File ferox-math/src/main/java/com/ferox/math/entreri/Vector3Property.java

 package com.ferox.math.entreri;
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
 import com.ferox.math.Const;
 import com.ferox.math.Vector3;
+import com.lhkbob.entreri.Attribute;
+import com.lhkbob.entreri.Attributes;
+import com.lhkbob.entreri.Factory;
+import com.lhkbob.entreri.IndexedDataStore;
+import com.lhkbob.entreri.Property;
 import com.lhkbob.entreri.property.AbstractPropertyFactory;
 import com.lhkbob.entreri.property.DoubleProperty;
-import com.lhkbob.entreri.property.IndexedDataStore;
-import com.lhkbob.entreri.property.Property;
-import com.lhkbob.entreri.property.PropertyFactory;
 
 /**
  * Vector3Property is a caching property that wraps a DoubleProperty as a
  * 
  * @author Michael Ludwig
  */
+@Factory(Vector3Property.Factory.class)
 public class Vector3Property implements Property {
     private static final int REQUIRED_ELEMENTS = 3;
 
     }
     
     /**
-     * @return PropertyFactory that creates Vector3Properties
-     */
-    public static PropertyFactory<Vector3Property> factory() {
-        return new AbstractPropertyFactory<Vector3Property>() {
-            @Override
-            public Vector3Property create() {
-                return new Vector3Property();
-            }
-
-            @Override
-            public void setDefaultValue(Vector3Property property, int index) {
-                for (int i = 0; i < REQUIRED_ELEMENTS; i++) {
-                    property.data.set(0f, index, i);
-                }
-            }
-        };
-    }
-
-    /**
      * Get the vector of this property, for the component at the given index,
      * and store it into <tt>result</tt>. If result is null, a new Vector3 is
      * created and returned.
     public void setDataStore(IndexedDataStore store) {
         data.setDataStore(store);
     }
+    
+    /**
+     * Attribute annotation to apply to Vector3Property declarations.
+     * 
+     * @author Michael Ludwig
+     */
+    @Attribute
+    @Target(ElementType.FIELD)
+    @Retention(RetentionPolicy.RUNTIME)
+    public static @interface DefaultVector3 {
+        /**
+         * @return Default x coordinate
+         */
+        double x();
+        /**
+         * @return Default y coordinate
+         */
+        double y();
+        /**
+         * @return Default z coordinate
+         */
+        double z();
+    }
+    
+    /**
+     * Default factory implementation for Vector3Properties, supports the
+     * {@link DefaultVector3} annotation to specify the default vector
+     * coordinates.
+     * 
+     * @author Michael Ludwig
+     */
+    public static class Factory extends AbstractPropertyFactory<Vector3Property> {
+        private final Vector3 dflt;
+        
+        public Factory(Attributes attrs) {
+            super(attrs);
+            if (attrs.hasAttribute(DefaultVector3.class)) {
+                DefaultVector3 v = attrs.getAttribute(DefaultVector3.class);
+                dflt = new Vector3(v.x(), v.y(), v.z());
+            } else {
+                dflt = new Vector3();
+            }
+        }
+        
+        public Factory(@Const Vector3 v) {
+            super(null);
+            dflt = new Vector3(v);
+        }
+
+        @Override
+        public Vector3Property create() {
+            return new Vector3Property();
+        }
+
+        @Override
+        public void setDefaultValue(Vector3Property property, int index) {
+            property.set(dflt, index);
+        }
+    }
 }

File ferox-math/src/main/java/com/ferox/math/entreri/Vector4Property.java

 package com.ferox.math.entreri;
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
 import com.ferox.math.Const;
 import com.ferox.math.Vector4;
+import com.lhkbob.entreri.Attribute;
+import com.lhkbob.entreri.Attributes;
+import com.lhkbob.entreri.Factory;
+import com.lhkbob.entreri.IndexedDataStore;
+import com.lhkbob.entreri.Property;
 import com.lhkbob.entreri.property.AbstractPropertyFactory;
 import com.lhkbob.entreri.property.DoubleProperty;
-import com.lhkbob.entreri.property.IndexedDataStore;
-import com.lhkbob.entreri.property.Property;
-import com.lhkbob.entreri.property.PropertyFactory;
 
 /**
  * Vector4Property is a caching property that wraps a DoubleProperty as a
  * 
  * @author Michael Ludwig
  */
+@Factory(Vector4Property.Factory.class)
 public class Vector4Property implements Property {
     private static final int REQUIRED_ELEMENTS = 4;
 
     }
     
     /**
-     * @return PropertyFactory that creates Vector4Properties
-     */
-    public static PropertyFactory<Vector4Property> factory() {
-        return new AbstractPropertyFactory<Vector4Property>() {
-            @Override
-            public Vector4Property create() {
-                return new Vector4Property();
-            }
-
-            @Override
-            public void setDefaultValue(Vector4Property property, int index) {
-                for (int i = 0; i < REQUIRED_ELEMENTS; i++) {
-                    property.data.set(0f, index, i);
-                }
-            }
-        };
-    }
-
-    /**
      * Get the vector of this property, for the component at the given index,
      * and store it into <tt>result</tt>. If result is null, a new Vector3 is
      * created and returned.
     public void setDataStore(IndexedDataStore store) {
         data.setDataStore(store);
     }
+    
+    /**
+     * Attribute annotation to apply to Vector4Property declarations.
+     * 
+     * @author Michael Ludwig
+     */
+    @Attribute
+    @Target(ElementType.FIELD)
+    @Retention(RetentionPolicy.RUNTIME)
+    public static @interface DefaultVector4 {
+        /**
+         * @return Default x coordinate
+         */
+        double x();
+        /**
+         * @return Default y coordinate
+         */
+        double y();
+        /**
+         * @return Default z coordinate
+         */
+        double z();
+        /**
+         * @return Default w coordinate
+         */
+        double w();
+    }
+    
+    /**
+     * Default factory implementation for Vector4Properties, supports the
+     * {@link DefaultVector4} annotation to specify the default vector
+     * coordinates.
+     * 
+     * @author Michael Ludwig
+     */
+    public static class Factory extends AbstractPropertyFactory<Vector4Property> {
+        private final Vector4 dflt;
+        
+        public Factory(Attributes attrs) {
+            super(attrs);
+            if (attrs.hasAttribute(DefaultVector4.class)) {
+                DefaultVector4 v = attrs.getAttribute(DefaultVector4.class);
+                dflt = new Vector4(v.x(), v.y(), v.z(), v.w());
+            } else {
+                dflt = new Vector4();
+            }
+        }
+        
+        public Factory(@Const Vector4 v) {
+            super(null);
+            dflt = new Vector4(v);
+        }
+
+        @Override
+        public Vector4Property create() {
+            return new Vector4Property();
+        }
+
+        @Override
+        public void setDefaultValue(Vector4Property property, int index) {
+            property.set(dflt, index);
+        }
+    }
 }