Revision: 478 http://skycastle.svn.sourceforge.net/skycastle/?rev=478&view=rev Author: zzorn Date: 2008-04-26 07:17:02 -0700 (Sat, 26 Apr 2008) Log Message: ----------- Started on data model for a sketch application Added Paths: ----------- trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/Sketch.java trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/SketchImpl.java trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/Stroke.java trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokePoint.java trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokePointImpl.java trunk/skycastle/modules/ui/src/test/java/org/ trunk/skycastle/modules/ui/src/test/java/org/skycastle/ trunk/skycastle/modules/ui/src/test/java/org/skycastle/sketch/ trunk/skycastle/modules/ui/src/test/java/org/skycastle/sketch/TestSketchModel.java Added: trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/Sketch.java =================================================================== --- trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/Sketch.java (rev 0) +++ trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/Sketch.java 2008-04-26 14:17:02 UTC (rev 478) @@ -0,0 +1,22 @@ +package org.skycastle.sketch; + +/** + * Holds the data of a drawing. + * <p/> + * Strokes can be added and removed. + * <p/> + * Strokes can be grouped into Layers. + * + * @author Hans Häggström + */ +public interface Sketch +{ + + /** + * Creates a new {@link Stroke} and adds it to the sketch. + * + * @return the created stroke. + */ + Stroke createStroke(); + +} Added: trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/SketchImpl.java =================================================================== --- trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/SketchImpl.java (rev 0) +++ trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/SketchImpl.java 2008-04-26 14:17:02 UTC (rev 478) @@ -0,0 +1,23 @@ +package org.skycastle.sketch; + +/** + * @author Hans Häggström + */ +public class SketchImpl + implements Sketch +{ + + /** + * Creates a new {@link org.skycastle.sketch.SketchImpl}. + */ + public SketchImpl() + { + throw new UnsupportedOperationException( "Constructor not yet implemented." ); // IMPLEMENT + } + + public Stroke createStroke() + { + throw new UnsupportedOperationException( "This method has not yet been implemented." ); // IMPLEMENT + + } +} Added: trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/Stroke.java =================================================================== --- trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/Stroke.java (rev 0) +++ trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/Stroke.java 2008-04-26 14:17:02 UTC (rev 478) @@ -0,0 +1,16 @@ +package org.skycastle.sketch; + +/** + * @author Hans Häggström + * <p/> + * Immutable, except points can be added (and removed?), and the changes listened to. + */ +public interface Stroke +{ + /** + * @param strokePoint a new point to be added to the stroke. + */ + void addPoint( StrokePoint strokePoint ); + + +} Added: trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokePoint.java =================================================================== --- trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokePoint.java (rev 0) +++ trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokePoint.java 2008-04-26 14:17:02 UTC (rev 478) @@ -0,0 +1,35 @@ +package org.skycastle.sketch; + +/** + * A point on a {@link Stroke} + * <p/> + * Immutable. + * + * @author Hans Häggström + */ +public interface StrokePoint +{ + /** + * @return x coordinate of the point. + */ + float getX(); + + /** + * @return y coordinate of the point. + */ + float getY(); + + /** + * @param property the property to get + * + * @return the specified property of the stroke. + */ + float getValue( String property, float defaultValue ); + + /** + * @param property the property to get + * + * @return the specified property of the stroke. + */ + <T> T getObjectValue( String property, T defaultValue ); +} Added: trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokePointImpl.java =================================================================== --- trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokePointImpl.java (rev 0) +++ trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokePointImpl.java 2008-04-26 14:17:02 UTC (rev 478) @@ -0,0 +1,43 @@ +package org.skycastle.sketch; + +/** + * @author Hans Häggström + */ +public class StrokePointImpl + implements StrokePoint +{ + + private float myX = + + /** + * Creates a new {@link org.skycastle.sketch.StrokePointImpl}. + */ + public StrokePointImpl() + { + throw new UnsupportedOperationException( "Constructor not yet implemented." ); // IMPLEMENT + } + + public float getX() + { + throw new UnsupportedOperationException( "This method has not yet been implemented." ); // IMPLEMENT + + } + + public float getY() + { + throw new UnsupportedOperationException( "This method has not yet been implemented." ); // IMPLEMENT + + } + + public float getValue( final String property, final float defaultValue ) + { + throw new UnsupportedOperationException( "This method has not yet been implemented." ); // IMPLEMENT + + } + + public <T> T getObjectValue( final String property, final T defaultValue ) + { + throw new UnsupportedOperationException( "This method has not yet been implemented." ); // IMPLEMENT + + } +} Added: trunk/skycastle/modules/ui/src/test/java/org/skycastle/sketch/TestSketchModel.java =================================================================== --- trunk/skycastle/modules/ui/src/test/java/org/skycastle/sketch/TestSketchModel.java (rev 0) +++ trunk/skycastle/modules/ui/src/test/java/org/skycastle/sketch/TestSketchModel.java 2008-04-26 14:17:02 UTC (rev 478) @@ -0,0 +1,32 @@ +package org.skycastle.sketch; + +import junit.framework.TestCase; + +/** + * @author Hans Häggström + */ +public class TestSketchModel + extends TestCase +{ + + public void testCreateStroke() throws Exception + { + + Sketch sketch = new SketchImpl(); + + final Stroke stroke = sketch.createStroke(); + + stroke.addPoint( new StrokePointImpl() ); + + } + + + /** + * Creates a new {@link org.skycastle.sketch.TestSketchModel}. + */ + public TestSketchModel() + { + throw new UnsupportedOperationException( "Constructor not yet implemented." ); // IMPLEMENT + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.