Author: scooter
Date: 2012-09-04 17:37:45 -0700 (Tue, 04 Sep 2012)
New Revision: 30314

Added:
   core3/api/trunk/custom-graphics-api/
   core3/api/trunk/custom-graphics-api/pom.xml
   core3/api/trunk/custom-graphics-api/src/
   core3/api/trunk/custom-graphics-api/src/main/
   core3/api/trunk/custom-graphics-api/src/main/java/
   core3/api/trunk/custom-graphics-api/src/main/java/org/
   core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/
   core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/
   
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/
   
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/
   
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/AbstractPaintedShape.java
   
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphics.java
   
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsFactory.java
   
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsPaint.java
   
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsPaintedShapes.java
   
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/PaintedShape.java
   
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/package-info.java
Modified:
   core3/api/trunk/app-api/pom.xml
   core3/api/trunk/pom.xml
Log:
First commit of custom-graphics-api for review.


Modified: core3/api/trunk/app-api/pom.xml
===================================================================
--- core3/api/trunk/app-api/pom.xml     2012-09-04 22:00:21 UTC (rev 30313)
+++ core3/api/trunk/app-api/pom.xml     2012-09-05 00:37:45 UTC (rev 30314)
@@ -152,6 +152,11 @@
                </dependency>
                <dependency>
                        <groupId>org.cytoscape</groupId>
+                       <artifactId>custom-graphics-api</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
                        <artifactId>service-api</artifactId>
                        <version>${project.version}</version>
                </dependency>

Added: core3/api/trunk/custom-graphics-api/pom.xml
===================================================================
(Binary files differ)


Property changes on: core3/api/trunk/custom-graphics-api/pom.xml
___________________________________________________________________
Added: svn:mime-type
   + application/xml

Added: 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/AbstractPaintedShape.java
===================================================================
--- 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/AbstractPaintedShape.java
                          (rev 0)
+++ 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/AbstractPaintedShape.java
  2012-09-05 00:37:45 UTC (rev 30314)
@@ -0,0 +1,37 @@
+package org.cytoscape.view.presentation.customgraphics;
+
+import java.awt.Paint;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.Rectangle2D;
+
+public class AbstractPaintedShape implements PaintedShape {
+       protected Shape shape;
+       protected Paint fill;
+       protected Stroke stroke;
+       protected Paint strokePaint;
+
+       public AbstractPaintedShape(Shape shape, Paint fill,
+                                   Stroke stroke, Paint strokePaint) {
+               this.shape = shape;
+               this.fill = fill;
+               this.stroke = stroke;
+               this.strokePaint = strokePaint;
+       }
+
+       public Shape getShape(Rectangle2D bounds) {
+               return shape;
+       }
+
+       public Paint getFill(Rectangle2D bounds) {
+               return fill;
+       }
+
+       public Stroke getStroke() {
+               return stroke;
+       }
+
+       public Paint getStrokePaint() {
+               return strokePaint;
+       }
+}

Added: 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphics.java
===================================================================
--- 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphics.java
                                (rev 0)
+++ 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphics.java
        2012-09-05 00:37:45 UTC (rev 30314)
@@ -0,0 +1,38 @@
+package org.cytoscape.view.presentation.customgraphics;
+
+import java.awt.Image;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * This interface defines a custom graphics object that
+ * provides a simple {@link java.awt.Image} to be painted
+ * on a {@link org.cytoscape.model.CyNode} and is the only mandatory interface 
that
+ * must be implemented by all
+ * {@link org.cytoscape.view.presentation.RenderingEngine}s.
+ * It is assumed that
+ * any {@link org.cytoscape.view.presentation.RenderingEngine} will
+ * be able to display an {@link java.awt.Image}, and that all more complicated
+ * CustomGraphics implementations will be able to generate an image from
+ * their graphical data.
+ */
+public interface CustomGraphics {
+       /**
+        * This key is the threshold the provider wants to set for 
re-rendering.  If the
+        * zoom changes less than this value, none of the CustomGraphics 
methods will be
+        * called and the existing graphics will be reused.  If it exceeds this 
threshold
+        * the appropriate methods will be called to generate new custom 
graphics data.
+        */
+       public static String ZOOM_THRESHOLD = "zoomThreshold";
+
+       /**
+        * This method is called by the 
+        * {@link org.cytoscape.view.presentation.RenderingEngine} to get an 
image
+        * to paint onto a {@link org.cytoscape.model.CyNode}.  The size (in 
display
+        * coordinates) are given by the bounding rectangle.
+        *
+        * @param bounds the bounding rectangle of the displayed {@link 
org.cytoscape.model.CyNode}.
+        * @return an {@link java.awt.Image} that should be painted on the 
appropriate 
+        * {@link org.cytoscape.model.CyNode}.
+        */
+       public Image getRenderedImage(Rectangle2D bounds);
+}

Added: 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsFactory.java
===================================================================
--- 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsFactory.java
                         (rev 0)
+++ 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsFactory.java
 2012-09-05 00:37:45 UTC (rev 30314)
@@ -0,0 +1,45 @@
+package org.cytoscape.view.presentation.customgraphics;
+
+import java.util.List;
+
+import org.cytoscape.model.CyNode;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.View;
+
+/**
+ * This interface provides a factory for creating custom graphics
+ * providers for a particular node view in a particular network.
+ * All custom graphics providers are expected to implement the
+ * {@link org.cytoscape.view.presentation.customgraphics.CustomGraphics}
+ * interface.  Other interfaces may be implemented also.  The usual
+ * way to register a {@link CustomGraphicsFactory} is to provide an 
implementation
+ * of this interface and register it as part of the CyActivator for your App.
+ * {@link org.cytoscape.view.presentation.RenderingEngine}s will read the
+ * {@link java.util.Properties} object provided as part of the registration
+ * to determine default position, zoom action, etc.  See 
+ * {@link org.cytoscape.view.presentation.customgraphics.CustomGraphics} for
+ * the default keys.
+ */
+public interface CustomGraphicsFactory {
+       /**
+        * Create a new custom graphics.  A
+        * {@link org.cytoscape.view.presentation.RenderingEngine} will provide
+        * an ordered list of types that it supports in the "requestedTypes" 
list,
+        * with the first in the list being the highest quality rendering that 
this
+        * {@link org.cytoscape.view.presentation.RenderingEngine} can provide.
+        * The {@link org.cytoscape.view.presentation.RenderingEngine} will 
determine
+        * what this particular custom graphics class supports.
+        *
+        * @param netView the {@link org.cytoscape.view.model.CyNetworkView} 
this applies to.  
+        *                It can not be null.
+        * @param nodeView the {@link org.cytoscape.model.CyNode} {@link 
org.cytoscape.view.model.View}
+        *                 this applies to.
+        * @param requestedTypes the types of CustomGraphics this 
+        *                       {@link 
org.cytoscape.view.presentation.RenderingEngine} supports.
+        * @return a {@link org.cytoscape.view.presentation.CustomGraphics} 
object 
+        *         for this network and node view.
+        */
+       public CustomGraphics createCustomGraphics(CyNetworkView netView,
+                                                  View<CyNode> nodeView,
+                                                  List<Class<?>> 
requestedTypes);
+}

Added: 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsPaint.java
===================================================================
--- 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsPaint.java
                           (rev 0)
+++ 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsPaint.java
   2012-09-05 00:37:45 UTC (rev 30314)
@@ -0,0 +1,28 @@
+package org.cytoscape.view.presentation.customgraphics;
+
+import java.awt.Paint;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * This interface defines a custom graphics object that provides
+ * only a simple {@link java.awt.Paint} to a
+ * {@link org.cytoscape.view.presentation.RenderingEngine} that can
+ * be used to fill an arbitrary shape.  This might be used for something
+ * like creating a data-driven gradient to use on a {@link 
org.cytoscape.model.CyNode}
+ * visualization.  {@link org.cytoscape.view.presentation.RenderingEngine}s
+ * are not required to implement this, so any implementation of this interface
+ * must also implement {@link CustomGraphics}.
+ */
+public interface CustomGraphicsPaint {
+       /**
+        * Return the {@link java.awt.Paint} to use for the
+        * {@link org.cytoscape.model.CyNode} specified by the
+        * {@link 
org.cytoscape.view.presentation.customgraphics.CustomGraphicsFactory}.
+        *
+        * @param bounds the bounding box of the {@link 
org.cytoscape.model.CyNode}.  Not
+        *               usually required for {@link java.awt.Paint} but 
provided here for
+        *               completeness.
+        * @return the {@link java.awt.Paint} to for this {@link 
org.cytoscape.model.CyNode}.
+        */
+       public Paint getPaint(Rectangle2D bounds);
+}

Added: 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsPaintedShapes.java
===================================================================
--- 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsPaintedShapes.java
                           (rev 0)
+++ 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphicsPaintedShapes.java
   2012-09-05 00:37:45 UTC (rev 30314)
@@ -0,0 +1,30 @@
+package org.cytoscape.view.presentation.customgraphics;
+
+import java.awt.geom.Rectangle2D;
+import java.util.List;
+
+/**
+ * This interface defines a custom graphics object that provides
+ * a series of {@link java.awt.Shape}s with arbitrary fill
+ * {@link java.awt.Paint} and {@link java.awt.Stroke} to a
+ * {@link org.cytoscape.view.presentation.RenderingEngine}.
+ * This might be used for something
+ * like creating a data-driven pie chart to use on a {@link 
org.cytoscape.model.CyNode}
+ * visualization.  {@link org.cytoscape.view.presentation.RenderingEngine}s
+ * are not required to implement this, so any implementation of this interface
+ * must also implement {@link CustomGraphics}.
+ */
+public interface CustomGraphicsPaintedShapes {
+       /**
+        * Return a list of {@link PaintedShape}s to the
+        * {@link org.cytoscape.view.presentation.RenderingEngine} for
+        * painting onto the {@link org.cytoscape.model.CyNode} visualization.
+        *
+        * @param bounds the bounding box of the 
+        *               {@link org.cytoscape.model.CyNode} visualization.
+        * @return a {@link java.util.List} of {@link PaintedShape}s that will 
+        *         be drawn in list order.  This means that the first 
+        *         {@link PaintedShape}s may be under subsequent {@link 
PaintedShape}s.
+        */
+       public List<PaintedShape> getPaintedShapes(Rectangle2D bounds);
+}

Added: 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/PaintedShape.java
===================================================================
--- 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/PaintedShape.java
                          (rev 0)
+++ 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/PaintedShape.java
  2012-09-05 00:37:45 UTC (rev 30314)
@@ -0,0 +1,43 @@
+package org.cytoscape.view.presentation.customgraphics;
+
+import java.awt.Paint;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * This interface defines a the information required to
+ * construct a {@link java.awt.Shape} that has an arbitrary
+ * fill {@link java.awt.Paint} and {@link java.awt.Stroke}.
+ */
+public interface PaintedShape {
+       /**
+        * Return the {@link java.awt.Shape}
+        *
+        * @param bounds the bounding box of the {@link 
org.cytoscape.model.CyNode}.
+        * @return the {@link java.awt.Shape}
+        */
+       public Shape getShape(Rectangle2D bounds);
+       /**
+        * Return the {@link java.awt.Paint} to be used to
+        * fill the {@link java.awt.Shape}.
+        *
+        * @param bounds the bounding box of the {@link 
org.cytoscape.model.CyNode}.
+        * @return the fill {@link java.awt.Paint}
+        */
+       public Paint getFill(Rectangle2D bounds);
+       /**
+        * Return the {@link java.awt.Stroke} to use to outline the
+        * {@link java.awt.Shape} provided by the {@link #getShape} method 
above.
+        *
+        * @return the {@link java.awt.Stroke} to use.
+        */
+       public Stroke getStroke();
+       /**
+        * Return the {@link java.awt.Paint} to use to color the
+        * {@link java.awt.Stroke} returned by {@link #getStroke}.
+        *
+        * @return the stroke {@link java.awt.Paint}
+        */
+       public Paint getStrokePaint();
+}

Added: 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/package-info.java
===================================================================
--- 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/package-info.java
                          (rev 0)
+++ 
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/package-info.java
  2012-09-05 00:37:45 UTC (rev 30314)
@@ -0,0 +1,5 @@
+/**
+This package provides an API for augmenting a {@link 
org.cytoscape.view.presentation.RenderingEngine}s
+node rendering with custom graphics.
+*/
+package org.cytoscape.view.presentation.customgraphics;

Modified: core3/api/trunk/pom.xml
===================================================================
--- core3/api/trunk/pom.xml     2012-09-04 22:00:21 UTC (rev 30313)
+++ core3/api/trunk/pom.xml     2012-09-05 00:37:45 UTC (rev 30314)
@@ -25,6 +25,7 @@
                <module>app-api</module>
                <module>swing-app-api</module>
                <module>presentation-api</module>
+               <module>custom-graphics-api</module>
                <module>property-api</module>
                <module>session-api</module>
                <module>swing-application-api</module>

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to