Author: scooter
Date: 2012-09-10 11:46:55 -0700 (Mon, 10 Sep 2012)
New Revision: 30340
Added:
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphic.java
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/ImageCustomGraphic.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/bitmap/ImageCustomGraphicImpl.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/PaintCustomGraphic.java
Removed:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/CustomGraphic.java
Modified:
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/PaintedShape.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/AbstractDCustomGraphics.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/CustomGraphicsRange.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/NullCustomGraphics.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/bitmap/URLImageCustomGraphics.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/paint/TexturePaintFactory.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientLayerCustomGraphics.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientOvalLayer.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientRoundRectangleLayer.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphicsmgr/internal/RestoreImageTask.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeDetails.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeView.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/customgraphics/CustomGraphicsPositionCalculator.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/visualproperty/CustomGraphicsVisualProperty.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/immed/GraphGraphics.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/GraphRenderer.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/NodeDetails.java
Log:
CustomGraphics refactor. This represents the first step.
The next step is to make ding listen to registrations of CyCustomGraphics
services...
Added:
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphic.java
===================================================================
---
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphic.java
(rev 0)
+++
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/CustomGraphic.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -0,0 +1,48 @@
+package org.cytoscape.view.presentation.customgraphics;
+
+import java.awt.Paint;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * This interface defines a the mimimum interface to
+ * add a custom graphics to a {@link org.cytoscape.model.CyNode}.
+ */
+public interface CustomGraphic {
+ /**
+ * Return the bounds of the area covered by this
+ * CustomGraphic as a {@link java.awt.Rectangle}
+ *
+ * @return the {@link java.awt.Rectangle}
+ */
+ public Rectangle getBounds();
+
+ /**
+ * Return the bounds of the area covered by this
+ * CustomGraphic as a {@link java.awt.Rectangle2D}
+ *
+ * @return the {@link java.awt.Rectangle2D}
+ */
+ public Rectangle2D getBounds2D();
+
+ /**
+ * 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 getPaint(Rectangle2D bounds);
+
+ /**
+ * Return a new NodeCustomGraphics that has been transformed by the
+ * provided {@link java.awt.geom.AffineTransform}.
+ *
+ * @param xform transform to perform on the shape
+ * @return the transformed NodeCustomGraphic
+ */
+ public CustomGraphic transform(AffineTransform xform);
+}
Added:
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/ImageCustomGraphic.java
===================================================================
---
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/ImageCustomGraphic.java
(rev 0)
+++
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/ImageCustomGraphic.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -0,0 +1,20 @@
+package org.cytoscape.view.presentation.customgraphics;
+
+import java.awt.TexturePaint;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * This interface defines a the mimimum interface to
+ * add a custom graphics to a {@link org.cytoscape.model.CyNode}.
+ */
+public interface ImageCustomGraphic extends CustomGraphic {
+ /**
+ * Return the {@link java.awt.TexturePaint} to be used as
+ * an image to fill a node
+ *
+ * @param bounds the bounding box of the {@link
org.cytoscape.model.CyNode}.
+ * @return the fill {@link java.awt.TexturePaint}
+ */
+ @Override
+ public TexturePaint getPaint(Rectangle2D bounds);
+}
Modified:
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
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/api/trunk/custom-graphics-api/src/main/java/org/cytoscape/view/presentation/customgraphics/PaintedShape.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -10,22 +10,23 @@
* construct a {@link java.awt.Shape} that has an arbitrary
* fill {@link java.awt.Paint} and {@link java.awt.Stroke}.
*/
-public interface PaintedShape {
+public interface PaintedShape extends CustomGraphic {
/**
* 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);
+ public Shape getShape();
+
/**
- * Return the {@link java.awt.Paint} to be used to
- * fill the {@link java.awt.Shape}.
+ * Return the {@link java.awt.Paint} to fill the shape with. This
+ * is a convenience method that is essentially the same as calling
+ * getPaint(getShape().getBounds());
*
- * @param bounds the bounding box of the {@link
org.cytoscape.model.CyNode}.
- * @return the fill {@link java.awt.Paint}
+ * @return the {@link java.awt.Paint}
*/
- public Paint getFill(Rectangle2D bounds);
+ public Paint getPaint();
+
/**
* Return the {@link java.awt.Stroke} to use to outline the
* {@link java.awt.Shape} provided by the {@link #getShape} method
above.
@@ -33,6 +34,7 @@
* @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}.
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/AbstractDCustomGraphics.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/AbstractDCustomGraphics.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/AbstractDCustomGraphics.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -8,10 +8,10 @@
import java.util.TreeSet;
import org.cytoscape.view.presentation.customgraphics.CyCustomGraphics;
-import org.cytoscape.graph.render.stateful.CustomGraphic;
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
-public abstract class AbstractDCustomGraphics implements
- CyCustomGraphics<CustomGraphic>, Taggable {
+public abstract class AbstractDCustomGraphics<T extends CustomGraphic>
implements
+ CyCustomGraphics<T>, Taggable {
protected static final String DELIMITER = ",";
public static final String LIST_DELIMITER = "|";
@@ -22,7 +22,7 @@
protected final Long id;
// Layers of Ding Custom Graphic objects.
- protected List<CustomGraphic> layers;
+ protected List<T> layers;
// Human readable name
protected String displayName;
@@ -48,7 +48,7 @@
public AbstractDCustomGraphics(final Long id, final String displayName)
{
this.id = id;
- this.layers = new ArrayList<CustomGraphic>();
+ this.layers = new ArrayList<T>();
this.displayName = displayName;
this.tags = new TreeSet<String>();
@@ -77,7 +77,7 @@
}
- public List<CustomGraphic> getLayers() {
+ public List<T> getLayers() {
return layers;
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/CustomGraphicsRange.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/CustomGraphicsRange.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/CustomGraphicsRange.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -3,7 +3,6 @@
import java.util.HashSet;
import java.util.Set;
-import org.cytoscape.graph.render.stateful.CustomGraphic;
import org.cytoscape.view.model.DiscreteRange;
import org.cytoscape.view.presentation.customgraphics.CyCustomGraphics;
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/NullCustomGraphics.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/NullCustomGraphics.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/NullCustomGraphics.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -7,16 +7,16 @@
import javax.imageio.ImageIO;
import org.cytoscape.ding.customgraphics.bitmap.URLImageCustomGraphics;
-import org.cytoscape.graph.render.stateful.CustomGraphic;
import org.cytoscape.view.presentation.customgraphics.CyCustomGraphics;
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
/**
* Null object for Custom Graphics. This is used to reset custom graphics on
* node views.
*
*/
-public class NullCustomGraphics extends AbstractDCustomGraphics {
+public class NullCustomGraphics extends AbstractDCustomGraphics<CustomGraphic>
{
private static final String DEF_IMAGE_FILE = "images/no_image.png";
public static BufferedImage DEF_IMAGE;
Added:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/bitmap/ImageCustomGraphicImpl.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/bitmap/ImageCustomGraphicImpl.java
(rev 0)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/bitmap/ImageCustomGraphicImpl.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -0,0 +1,38 @@
+package org.cytoscape.ding.customgraphics.bitmap;
+
+import java.awt.Paint;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.TexturePaint;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
+import org.cytoscape.view.presentation.customgraphics.ImageCustomGraphic;
+import org.cytoscape.ding.customgraphics.paint.TexturePaintFactory;
+
+public class ImageCustomGraphicImpl implements ImageCustomGraphic {
+ private Rectangle2D bounds;
+ private TexturePaintFactory pf;
+
+ public ImageCustomGraphicImpl(Rectangle2D bounds, TexturePaintFactory
factory) {
+ this.bounds = bounds;
+ this.pf = factory;
+ }
+
+ public Rectangle getBounds() { return bounds.getBounds(); }
+ public Rectangle2D getBounds2D() { return bounds; }
+
+ // TODO: at some point, we should just bring all of the
TexturePaintFactory
+ // stuff into here....
+ @Override
+ public TexturePaint getPaint(Rectangle2D bounds) {
+ return pf.getPaint(bounds);
+ }
+
+ public CustomGraphic transform(AffineTransform xform) {
+ Shape s = xform.createTransformedShape(bounds);
+ return new ImageCustomGraphicImpl(s.getBounds2D(), pf);
+ }
+
+}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/bitmap/URLImageCustomGraphics.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/bitmap/URLImageCustomGraphics.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/bitmap/URLImageCustomGraphics.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -1,6 +1,7 @@
package org.cytoscape.ding.customgraphics.bitmap;
import java.awt.Image;
+import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
@@ -11,11 +12,13 @@
import org.cytoscape.ding.customgraphics.AbstractDCustomGraphics;
import org.cytoscape.ding.customgraphics.ImageUtil;
+import org.cytoscape.ding.customgraphics.bitmap.ImageCustomGraphicImpl;
import org.cytoscape.ding.customgraphics.paint.TexturePaintFactory;
-import org.cytoscape.graph.render.stateful.CustomGraphic;
import org.cytoscape.graph.render.stateful.PaintFactory;
+import org.cytoscape.view.presentation.customgraphics.ImageCustomGraphic;
-public class URLImageCustomGraphics extends AbstractDCustomGraphics {
+public class URLImageCustomGraphics <ImageCustomGraphic>
+ extends AbstractDCustomGraphics {
private static final String DEF_IMAGE_FILE = "images/no_image.png";
private static BufferedImage DEF_IMAGE;
@@ -31,7 +34,7 @@
private static final String DEF_TAG = "bitmap image";
- private CustomGraphic cg;
+ private ImageCustomGraphic icg;
private BufferedImage originalImage;
private BufferedImage scaledImage;
@@ -70,9 +73,9 @@
height = targetImg.getHeight();
bound = new Rectangle2D.Double(-width / 2, -height / 2, width,
height);
- final PaintFactory paintFactory = new
TexturePaintFactory(targetImg);
+ final TexturePaintFactory paintFactory = new
TexturePaintFactory(targetImg);
- cg = new CustomGraphic(bound, paintFactory);
+ ImageCustomGraphicImpl cg = new ImageCustomGraphicImpl(bound,
paintFactory);
layers.add(cg);
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/paint/TexturePaintFactory.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/paint/TexturePaintFactory.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/paint/TexturePaintFactory.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -16,7 +16,7 @@
}
- public Paint getPaint(Rectangle2D bound) {
+ public TexturePaint getPaint(Rectangle2D bound) {
return new TexturePaint(img, bound);
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientLayerCustomGraphics.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientLayerCustomGraphics.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientLayerCustomGraphics.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -6,6 +6,7 @@
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.Shape;
+import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
@@ -23,8 +24,8 @@
// Paint fot this graphics
protected PaintFactory paintFactory;
- // Bound of this graphics
- protected Shape bound;
+ // Shape of this paint
+ protected Shape shape;
private static final float FIT = 0.9f;
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientOvalLayer.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientOvalLayer.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientOvalLayer.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -5,7 +5,7 @@
import java.awt.geom.Ellipse2D;
import org.cytoscape.ding.customgraphics.paint.GradientPaintFactory;
-import org.cytoscape.graph.render.stateful.CustomGraphic;
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
public class GradientOvalLayer extends GradientLayerCustomGraphics {
@@ -23,7 +23,7 @@
final Graphics2D g2d = (Graphics2D) graphics;
// Render
update();
- g2d.setPaint(paintFactory.getPaint(bound.getBounds2D()));
+ g2d.setPaint(paintFactory.getPaint(shape.getBounds2D()));
g2d.fillOval(rendered.getMinX(), rendered.getMinY(),
width, height);
}
@@ -31,9 +31,9 @@
public void update() {
// First, remove all layers.
layers.clear();
- bound = new Ellipse2D.Double(-width / 2, -height / 2, width,
height);
+ shape = new Ellipse2D.Double(-width / 2, -height / 2, width,
height);
paintFactory = new GradientPaintFactory(c1.getValue(),
c2.getValue());
- final CustomGraphic cg = new CustomGraphic(bound, paintFactory);
+ final CustomGraphic cg = new PaintCustomGraphic(shape,
paintFactory);
layers.add(cg);
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientRoundRectangleLayer.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientRoundRectangleLayer.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/GradientRoundRectangleLayer.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -5,7 +5,7 @@
import java.awt.geom.RoundRectangle2D;
import org.cytoscape.ding.customgraphics.paint.GradientPaintFactory;
-import org.cytoscape.graph.render.stateful.CustomGraphic;
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
public class GradientRoundRectangleLayer extends GradientLayerCustomGraphics {
@@ -24,7 +24,7 @@
final Graphics2D g2d = (Graphics2D) graphics;
// Render
update();
- g2d.setPaint(paintFactory.getPaint(bound.getBounds2D()));
+ g2d.setPaint(paintFactory.getPaint(shape.getBounds2D()));
g2d.fillRoundRect(rendered.getMinX(), rendered.getMinY(),
rendered.getWidth(), rendered.getHeight(), r,
r);
}
@@ -35,10 +35,10 @@
layers.clear();
r = (int)(Math.min(width, height)/4f);
- bound = new RoundRectangle2D.Double(-width / 2, -height / 2,
+ shape = new RoundRectangle2D.Double(-width / 2, -height / 2,
width, height, r, r);
paintFactory = new GradientPaintFactory(c1.getValue(),
c2.getValue());
- final CustomGraphic cg = new CustomGraphic(bound, paintFactory);
+ final PaintCustomGraphic cg = new PaintCustomGraphic(shape,
paintFactory);
layers.add(cg);
}
Added:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/PaintCustomGraphic.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/PaintCustomGraphic.java
(rev 0)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphics/vector/PaintCustomGraphic.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -0,0 +1,45 @@
+package org.cytoscape.ding.customgraphics.vector;
+
+import java.awt.Paint;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
+import org.cytoscape.view.presentation.customgraphics.PaintedShape;
+import org.cytoscape.graph.render.stateful.PaintFactory;
+
+public class PaintCustomGraphic implements PaintedShape {
+ private Shape shape;
+ private PaintFactory pf;
+
+ public PaintCustomGraphic(Shape shape, PaintFactory factory) {
+ this.shape = shape;
+ this.pf = factory;
+ }
+
+ public Rectangle getBounds() { return shape.getBounds(); }
+
+ public Rectangle2D getBounds2D() { return shape.getBounds2D(); }
+
+ public Paint getPaint(Rectangle2D bounds) {
+ return pf.getPaint(bounds);
+ }
+
+ public Paint getPaint() {
+ return pf.getPaint(shape.getBounds2D());
+ }
+
+ public Shape getShape() { return shape; }
+
+ public Stroke getStroke() { return null; }
+ public Paint getStrokePaint() { return null; }
+
+ public CustomGraphic transform(AffineTransform xform) {
+ Shape s = xform.createTransformedShape(shape);
+ return new PaintCustomGraphic(s, pf);
+ }
+
+}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphicsmgr/internal/RestoreImageTask.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphicsmgr/internal/RestoreImageTask.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/customgraphicsmgr/internal/RestoreImageTask.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -37,7 +37,6 @@
import
org.cytoscape.ding.customgraphicsmgr.internal.event.CustomGraphicsLibraryUpdatedEvent;
import org.cytoscape.ding.impl.DNodeView;
import org.cytoscape.event.CyEventHelper;
-import org.cytoscape.graph.render.stateful.CustomGraphic;
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskMonitor;
import org.slf4j.Logger;
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeDetails.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeDetails.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeDetails.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -46,11 +46,11 @@
import org.cytoscape.ding.Label;
import org.cytoscape.ding.ObjectPosition;
import org.cytoscape.ding.Position;
-import org.cytoscape.graph.render.stateful.CustomGraphic;
import org.cytoscape.graph.render.stateful.NodeDetails;
import org.cytoscape.model.CyNode;
import org.cytoscape.view.model.View;
import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
import org.cytoscape.view.presentation.property.values.LineType;
import org.cytoscape.view.presentation.property.values.NodeShape;
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeView.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeView.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeView.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -60,13 +60,13 @@
import org.cytoscape.ding.NodeView;
import org.cytoscape.ding.ObjectPosition;
import org.cytoscape.view.presentation.customgraphics.CyCustomGraphics;
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
import org.cytoscape.ding.customgraphics.NullCustomGraphics;
import org.cytoscape.ding.customgraphics.vector.VectorCustomGraphics;
import org.cytoscape.ding.impl.customgraphics.CustomGraphicsPositionCalculator;
import org.cytoscape.ding.impl.visualproperty.CustomGraphicsVisualProperty;
import org.cytoscape.ding.impl.visualproperty.ObjectPositionVisualProperty;
import org.cytoscape.graph.render.immed.GraphGraphics;
-import org.cytoscape.graph.render.stateful.CustomGraphic;
import org.cytoscape.model.CyNode;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.CyNetworkViewManager;
@@ -1223,8 +1223,7 @@
// final double nodeW = this.getWidth();
// final double nodeH = this.getHeight();
- final Shape originalShape = cg.getShape();
- final Rectangle2D originalBounds = originalShape.getBounds2D();
+ final Rectangle2D originalBounds = cg.getBounds2D();
final double cgW = originalBounds.getWidth();
final double cgH = originalBounds.getHeight();
@@ -1247,7 +1246,7 @@
}
}
- return new
CustomGraphic(scale.createTransformedShape(originalShape),
cg.getPaintFactory());
+ return cg.transform(scale);
}
@Override
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/customgraphics/CustomGraphicsPositionCalculator.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/customgraphics/CustomGraphicsPositionCalculator.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/customgraphics/CustomGraphicsPositionCalculator.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -8,7 +8,7 @@
import org.cytoscape.ding.ObjectPosition;
import org.cytoscape.ding.Position;
import org.cytoscape.ding.impl.DNodeView;
-import org.cytoscape.graph.render.stateful.CustomGraphic;
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
import org.cytoscape.graph.render.stateful.PaintFactory;
public class CustomGraphicsPositionCalculator {
@@ -51,8 +51,8 @@
final double nodeW = nv.getWidth();
final double nodeH = nv.getHeight();
- final double cgW = cg.getShape().getBounds().getWidth();
- final double cgH = cg.getShape().getBounds().getHeight();
+ final double cgW = cg.getBounds().getWidth();
+ final double cgH = cg.getBounds().getHeight();
final Float[] disp1 = DISPLACEMENT_MAP.get(anc);
final Float[] disp2 = DISPLACEMENT_MAP.get(ancN);
@@ -69,11 +69,7 @@
double totalDispY = dispY + dispNY + p.getOffsetY();
final AffineTransform tf =
AffineTransform.getTranslateInstance(totalDispX, totalDispY);
- final Shape newShape = tf.createTransformedShape(cg.getShape());
-
- final PaintFactory newFactory = cg.getPaintFactory();
-
- return new CustomGraphic(newShape, newFactory);
-
+
+ return cg.transform(tf);
}
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/visualproperty/CustomGraphicsVisualProperty.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/visualproperty/CustomGraphicsVisualProperty.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/visualproperty/CustomGraphicsVisualProperty.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -3,8 +3,8 @@
import org.cytoscape.ding.DummyCustomGraphics;
import org.cytoscape.ding.customgraphics.CustomGraphicsRange;
import org.cytoscape.view.presentation.customgraphics.CyCustomGraphics;
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
import org.cytoscape.ding.customgraphics.NullCustomGraphics;
-import org.cytoscape.graph.render.stateful.CustomGraphic;
import org.cytoscape.model.CyIdentifiable;
import org.cytoscape.view.model.AbstractVisualProperty;
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/immed/GraphGraphics.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/immed/GraphGraphics.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/immed/GraphGraphics.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -44,6 +44,7 @@
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Paint;
+import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.Stroke;
@@ -60,6 +61,10 @@
import java.util.HashMap;
import java.util.Map;
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
+import org.cytoscape.view.presentation.customgraphics.ImageCustomGraphic;
+import org.cytoscape.view.presentation.customgraphics.PaintedShape;
+
import org.cytoscape.graph.render.immed.arrow.Arrow;
import org.cytoscape.graph.render.immed.arrow.ArrowheadArrow;
import org.cytoscape.graph.render.immed.arrow.DeltaArrow;
@@ -1999,12 +2004,74 @@
return m_fontRenderContextFull;
}
+ public final void drawCustomGraphicImage(final Shape shape,
+ final float xOffset, final float yOffset, final
TexturePaint paint) {
+ if (m_debug) {
+ checkDispatchThread();
+ checkCleared();
+ }
+
+ m_g2d.translate(xOffset, yOffset);
+ if(paint instanceof TexturePaint) {
+ final BufferedImage bImg = ((TexturePaint)
paint).getImage();
+ m_g2d.drawImage(bImg,
+ shape.getBounds().x,
shape.getBounds().y,
+ shape.getBounds().width,
shape.getBounds().height, null);
+ }
+ m_g2d.setTransform(m_currNativeXform);
+ }
+
/**
* Fills an arbitrary graphical shape with high detail.
* <p>
* This method will not work unless clear() has been called at least
once
* previously.
*
+ * @param cg
+ * the CustomGraphic
+ * @param xOffset
+ * in node coordinates, a value to add to the X coordinates
of
+ * the shape's definition.
+ * @param yOffset
+ * in node coordinates, a value to add to the Y coordinates
of
+ * the shape's definition.
+ */
+ public final void drawCustomGraphicFull(final CustomGraphic cg,
+ final float xOffset, final
float yOffset) {
+ if (m_debug) {
+ checkDispatchThread();
+ checkCleared();
+ }
+
+ m_g2d.translate(xOffset, yOffset);
+ if (cg instanceof PaintedShape) {
+ PaintedShape ps = (PaintedShape)cg;
+ Shape shape = ps.getShape();
+
+ if (ps.getStroke() != null) {
+ Paint strokePaint = ps.getStrokePaint();
+ if (strokePaint == null) strokePaint =
Color.BLACK;
+ m_g2d.setPaint(strokePaint);
+ m_g2d.setStroke(ps.getStroke());
+ m_g2d.draw(shape);
+ }
+ m_g2d.setPaint(ps.getPaint());
+ m_g2d.fill(shape);
+ } else if(cg instanceof ImageCustomGraphic) {
+ Rectangle bounds = cg.getBounds();
+ final BufferedImage bImg =
((ImageCustomGraphic)cg).getPaint(bounds).getImage();
+ m_g2d.drawImage(bImg, bounds.x, bounds.y, bounds.width,
bounds.height, null);
+ }
+
+ m_g2d.setTransform(m_currNativeXform);
+ }
+
+ /**
+ * Fills an arbitrary graphical shape with high detail.
+ * <p>
+ * This method will not work unless clear() has been called at least
once
+ * previously.
+ *
* @param shape
* the shape to fill; the shape is specified in node
coordinates.
* @param xOffset
Deleted:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/CustomGraphic.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/CustomGraphic.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/CustomGraphic.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -1,134 +0,0 @@
-/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications. In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage. See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-/**
- * Immutable representation of extra graphics associated with a
- * NodeView or EdgeView that are defined by apps and are
- * independent of visual styles.
- */
-
-package org.cytoscape.graph.render.stateful;
-
-import java.awt.Paint;
-import java.awt.Shape;
-import java.awt.geom.Rectangle2D;
-
-/**
- * Represents all the information needed to define a custom graphic for a given
- * NodeView. <H3>Deprecation Note</H3> The use of CustomGraphic replaces the
- * entire old index-based custom graphic API. This includes all the NodeDetails
- * methods (and their overridden implementations) that refer to custom graphics
- * using indices:
- *
- * <PRE>
- * public int graphicCount(int node)
- * public Shape graphicShape(int node, int graphicInx)
- * public Paint graphicPaint(int node, int graphicInx)
- * public int graphicNodeAnchor(int node, int graphicInx)
- * </PRE>
- *
- * <B>To keep things completetly backwards compatible and to avoid introducing
- * bugs, the new API methods are completely independent from the the old API
- * methods. Thus, a custom graphic added using the new API will not be
- * accessible from the old API and visa versa.</B>
- * <P>
- * The reason for the deprecation is:
- * <OL>
- * <LI>Complexity in managing the indices.
- * <P>
- * In order for multiple apps to use the old API, each must monitor deletions
- * to custom graphics and update their saved indices, since the indices will
- * shift down as graphics are deleted. This management isn't even possible with
- * the old API because there's no event mechanism to inform apps when the
- * indices change. Also, each app must keep a list of all indices for all
- * graphics added, since the indices may not be contiguous.
- * <LI>There is no way to ensure that an index you want to use will not be used
- * by another app by the time you attempt to assign it (thread safety).
- * <P>
- * Using indices forces the need for a locking mechanism to ensure you are
- * guaranteed a unique and correct index independent of any other apps.
- * </OL>
- * For more information, see <A
- * HREF="http://cbio.mskcc.org/cytoscape/bugs/view.php?id=1500">Mantis Bug
- * 1500</A>.
- *
- * @author Michael L. Creech
- */
-
-public class CustomGraphic {
-
- private final Shape shape;
- private PaintFactory pf;
- private Paint paint;
-
- /**
- * Constructor
- *
- * @param shape
- * @param factory
- */
- public CustomGraphic(final Shape shape, final PaintFactory factory) {
- if (shape == null)
- throw new IllegalArgumentException("The shape given was
null.");
- this.shape = shape;
- this.pf = factory;
- }
-
- /**
- * Return the Shape that makes up this CustomGraphic.
- */
- public Shape getShape() {
- return shape;
- }
-
- /**
- * Return the Paint that makes up this CustomGraphic.
- */
- public Paint getPaint() {
- if (paint != null)
- return paint;
- else
- return getPaint(shape.getBounds2D());
- }
-
- public Paint getPaint(Rectangle2D bound) {
- paint = pf.getPaint(bound);
- return paint;
- }
-
- public PaintFactory getPaintFactory() {
- return this.pf;
- }
-}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/GraphRenderer.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/GraphRenderer.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/GraphRenderer.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -44,6 +44,7 @@
import org.cytoscape.spacial.SpacialEntry2DEnumerator;
import org.cytoscape.spacial.SpacialIndex2D;
import org.cytoscape.util.intr.LongHash;
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
/**
@@ -1079,7 +1080,7 @@
doubleBuff1[2] = floatBuff1[2];
doubleBuff1[3] = floatBuff1[3];
lemma_computeAnchor(NodeDetails.ANCHOR_CENTER,
doubleBuff1, doubleBuff2);
-
grafx.drawCustomGraphicFull(nestedNetworkPaint.getAnchorRect(),
(float)doubleBuff2[0], (float)doubleBuff2[1], nestedNetworkPaint);
+
grafx.drawCustomGraphicImage(nestedNetworkPaint.getAnchorRect(),
(float)doubleBuff2[0], (float)doubleBuff2[1], nestedNetworkPaint);
}
// draw custom graphics on top of nested networks
@@ -1100,8 +1101,10 @@
doubleBuff1[2] = floatBuff1[2];
doubleBuff1[3] = floatBuff1[3];
lemma_computeAnchor(NodeDetails.ANCHOR_CENTER, doubleBuff1, doubleBuff2);
-
grafx.drawCustomGraphicFull(cg.getShape(), (float) (doubleBuff2[0] +
offsetVectorX), (float) (doubleBuff2[1] + offsetVectorY),
-
cg.getPaint());
+
//grafx.drawCustomGraphicFull(cg.getShape(), (float) (doubleBuff2[0] +
offsetVectorX), (float) (doubleBuff2[1] + offsetVectorY),
+ //
cg.getPaint());
+ grafx.drawCustomGraphicFull(cg, (float)
(doubleBuff2[0] + offsetVectorX),
+ (float)
(doubleBuff2[1] + offsetVectorY));
graphicInx++;
}
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/NodeDetails.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/NodeDetails.java
2012-09-07 22:44:46 UTC (rev 30339)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/graph/render/stateful/NodeDetails.java
2012-09-10 18:46:55 UTC (rev 30340)
@@ -29,6 +29,7 @@
import org.cytoscape.graph.render.immed.GraphGraphics;
import org.cytoscape.model.CyNode;
+import org.cytoscape.view.presentation.customgraphics.CustomGraphic;
import java.awt.BasicStroke;
import java.awt.Color;
@@ -41,6 +42,7 @@
import java.util.Iterator;
import java.util.Map;
+
/**
* Defines visual properties of a node modulo the node size and location Even
* though this class is not declared abstract, in most situations it makes
sense
--
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.