Author: kono
Date: 2010-10-21 14:15:08 -0700 (Thu, 21 Oct 2010)
New Revision: 22336
Added:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedEvent.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedEventListener.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedEvent.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedEventListener.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/internal/RenderingEngineManagerImpl.java
Removed:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/RenderingEngineCreatedEvent.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/RenderingEngineCreatedEventListener.java
Modified:
core3/presentation-api/trunk/osgi.bnd
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngine.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngineFactory.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngineManager.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/package-info.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/PaintVisualProperty.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/VisualPropertyUtil.java
Log:
New events had been added.
Modified: core3/presentation-api/trunk/osgi.bnd
===================================================================
--- core3/presentation-api/trunk/osgi.bnd 2010-10-21 21:12:24 UTC (rev
22335)
+++ core3/presentation-api/trunk/osgi.bnd 2010-10-21 21:15:08 UTC (rev
22336)
@@ -3,5 +3,5 @@
#-----------------------------------------------------------------
Import-Package: *
-Export-Package: org.cytoscape.view.presentation,
org.cytoscape.view.presentation.property
+Export-Package: org.cytoscape.view.presentation,
org.cytoscape.view.presentation.property, org.cytoscape.view.presentation.events
Private-Package: org.cytoscape.view.presentation.internal.*
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngine.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngine.java
2010-10-21 21:12:24 UTC (rev 22335)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngine.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -11,12 +11,9 @@
import org.cytoscape.view.model.VisualProperty;
/**
- * RenderingEngine is an interface for all visualizers. For a given view-model
+ * RenderingEngine is an interface for all visualizers which renders. For a
given view-model
* it renders actual view on display, documents, etc.
*
- * @author kono
- * @since Cytoscape 3.0
- *
* @param <T>
* source data object to be visualized. For now we have only one
* implementation for CyNetwork, but it can be anything, including
@@ -39,7 +36,6 @@
*/
public VisualLexicon getVisualLexicon();
-
/**
* Get property values for the rendering engine, like LOD.
@@ -63,6 +59,9 @@
/**
* Render an {...@linkplain Image} object from current visualization.
*
+ * @param width width of the image
+ * @param height height of the image
+ *
* @return Image object created from current window.
*/
public Image createImage(final int width, final int height);
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngineFactory.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngineFactory.java
2010-10-21 21:12:24 UTC (rev 22335)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngineFactory.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -6,11 +6,9 @@
* A factory class to create visualization for a given view model. One
* visualization (presentation) have one rendering engine
*
- * @author kono
- *
* @param <T>
* Compatible data model for this factory. For example, if this
- * parameter is set to CyNetwork, the factory creates rendering
+ * parameter is set to {...@linkplain CyNetwork}, the factory
creates rendering
* engine for CyNetwork objects.
*/
public interface RenderingEngineFactory<T> {
@@ -29,7 +27,7 @@
*
* @return Rendering Engine for visualization on the
visualizationContainer.
*/
- public RenderingEngine<T> render(final Object visualizationContainer,
+ RenderingEngine<T> render(final Object visualizationContainer,
final View<T> viewModel);
}
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngineManager.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngineManager.java
2010-10-21 21:12:24 UTC (rev 22335)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/RenderingEngineManager.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -10,27 +10,19 @@
* manager.
* <P>
* Register/unregister engines are handled through
- * {...@linkplain RenderingEngineCreatedEvent}s.
+ * {...@linkplain PresentationCreatedEvent}s.
*
- *
- * @author kono
- *
*/
public interface RenderingEngineManager {
/**
* Get all rendering engines for the given view model.
- *
- * @param <T>
- * Data model type. Usually they are {...@linkplain CyNode},
- * {...@linkplain CyEdge}, {...@linkplain CyNetwork}, or
- * {...@linkplain CyDataTable}.
+ *
* @param viewModel
* View model for the presentation.
*
* @return collection of rendering engines (presentations) for the given
* view model.
*/
- <T> Collection<RenderingEngine<T>> getRendringEngines(
- final View<T> viewModel);
+ Collection<RenderingEngine<?>> getRendringEngines(final View<?>
viewModel);
}
Copied:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedEvent.java
(from rev 22301,
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/RenderingEngineCreatedEvent.java)
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedEvent.java
(rev 0)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedEvent.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -0,0 +1,22 @@
+package org.cytoscape.view.presentation.events;
+
+import org.cytoscape.event.AbstractCyEvent;
+import org.cytoscape.view.presentation.RenderingEngine;
+
+/**
+ * When {...@linkplain RenderingEngineFactory} creates a new presentation (
+ * {...@linkplain RenderingEngine}), this event should be fired.
+ *
+ */
+public final class PresentationCreatedEvent extends
AbstractCyEvent<RenderingEngine<?>> {
+
+ /**
+ * Create a new event for the new RenderingEngine object.
+ *
+ * @param engine newly created RenderingEngine object.
+ */
+ public PresentationCreatedEvent(RenderingEngine<?> engine) {
+ super(engine, PresentationCreatedEventListener.class);
+ }
+
+}
Copied:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedEventListener.java
(from rev 22301,
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/RenderingEngineCreatedEventListener.java)
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedEventListener.java
(rev 0)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedEventListener.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -0,0 +1,21 @@
+package org.cytoscape.view.presentation.events;
+
+import org.cytoscape.event.CyListener;
+
+/**
+ * Listener for {...@linkplain PresentationCreatedEvent}.
+ * {...@linkplain RenderingEngineManager} implementation should implement this
+ * interface, too.
+ *
+ */
+public interface PresentationCreatedEventListener extends CyListener {
+
+ /**
+ * Listener can extract source RenderingEngine object in this method.
This
+ * is mainly for {...@linkplain RenderingEngineManager}.
+ *
+ * @param e
+ * an event object which contains source RenderingEngine.
+ */
+ void handleEvent(final PresentationCreatedEvent e);
+}
Added:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedEvent.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedEvent.java
(rev 0)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedEvent.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -0,0 +1,21 @@
+package org.cytoscape.view.presentation.events;
+
+import org.cytoscape.event.AbstractCyEvent;
+import org.cytoscape.view.presentation.RenderingEngine;
+
+/**
+ * When presentation (rendered graphics) is destroyed, this event should be
fired.
+ *
+ */
+public class PresentationDestroyedEvent extends
AbstractCyEvent<RenderingEngine<?>> {
+
+ /**
+ * Construct an event for restroyed {...@linkplain RenderingEngine}.
+ *
+ * @param source RenderingEngine for the deleted presentation.
+ */
+ public PresentationDestroyedEvent(final RenderingEngine<?> source) {
+ super(source, PresentationDestroyedEventListener.class);
+ }
+
+}
Added:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedEventListener.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedEventListener.java
(rev 0)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedEventListener.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -0,0 +1,16 @@
+package org.cytoscape.view.presentation.events;
+
+/**
+ * Listener for destroyed presentations.
+ *
+ */
+public interface PresentationDestroyedEventListener {
+
+ /**
+ * Perform post-deletion tasks in this method.
+ *
+ * @param evt event containing deleted presentation's RenderingEngine.
+ */
+ void handleEvent(final PresentationDestroyedEvent evt);
+
+}
Deleted:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/RenderingEngineCreatedEvent.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/RenderingEngineCreatedEvent.java
2010-10-21 21:12:24 UTC (rev 22335)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/RenderingEngineCreatedEvent.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -1,24 +0,0 @@
-package org.cytoscape.view.presentation.events;
-
-import org.cytoscape.event.AbstractCyEvent;
-import org.cytoscape.view.presentation.RenderingEngine;
-
-/**
- * When {...@linkplain RenderingEngineFactory} creates a new presentation (
- * {...@linkplain RenderingEngine}), this event should be fired.
- *
- * @author kono
- *
- */
-public class RenderingEngineCreatedEvent extends
AbstractCyEvent<RenderingEngine<?>> {
-
- /**
- * Create a new event for the new RenderingEngine object.
- *
- * @param engine newly created RenderingEngine object.
- */
- public RenderingEngineCreatedEvent(RenderingEngine<?> engine) {
- super(engine, RenderingEngineCreatedEventListener.class);
- }
-
-}
Deleted:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/RenderingEngineCreatedEventListener.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/RenderingEngineCreatedEventListener.java
2010-10-21 21:12:24 UTC (rev 22335)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/RenderingEngineCreatedEventListener.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -1,23 +0,0 @@
-package org.cytoscape.view.presentation.events;
-
-import org.cytoscape.event.CyListener;
-
-/**
- * Listener for {...@linkplain RenderingEngineCreatedEvent}.
- * {...@linkplain RenderingEngineManager} implementation should implement this
- * interface, too.
- *
- * @author kono
- *
- */
-public interface RenderingEngineCreatedEventListener extends CyListener {
-
- /**
- * Listener can extract source RenderingEngine object in this method.
This
- * is mainly for {...@linkplain RenderingEngineManager}.
- *
- * @param e
- * an event object which contains source RenderingEngine.
- */
- void handleEvent(final RenderingEngineCreatedEvent e);
-}
Added:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/internal/RenderingEngineManagerImpl.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/internal/RenderingEngineManagerImpl.java
(rev 0)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/internal/RenderingEngineManagerImpl.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -0,0 +1,62 @@
+package org.cytoscape.view.presentation.internal;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.presentation.RenderingEngine;
+import org.cytoscape.view.presentation.RenderingEngineManager;
+import org.cytoscape.view.presentation.events.PresentationCreatedEvent;
+import org.cytoscape.view.presentation.events.PresentationCreatedEventListener;
+import org.cytoscape.view.presentation.events.PresentationDestroyedEvent;
+import
org.cytoscape.view.presentation.events.PresentationDestroyedEventListener;
+
+public class RenderingEngineManagerImpl implements RenderingEngineManager,
+ PresentationCreatedEventListener,
PresentationDestroyedEventListener {
+
+ private final Map<View<?>, Set<RenderingEngine<?>>> renderingEngineMap;
+
+ /**
+ * Create an instance of rendering engine manager. This implementation
+ * listens to Presentation events and update its map based on them.
+ */
+ public RenderingEngineManagerImpl() {
+ this.renderingEngineMap = new HashMap<View<?>,
Set<RenderingEngine<?>>>();
+ }
+
+ @Override
+ public Collection<RenderingEngine<?>> getRendringEngines(
+ final View<?> viewModel) {
+ return renderingEngineMap.get(viewModel);
+ }
+
+ @Override
+ public void handleEvent(PresentationCreatedEvent e) {
+ final RenderingEngine<?> renderingEngine = e.getSource();
+ if (renderingEngine == null)
+ return;
+
+ Set<RenderingEngine<?>> engines = renderingEngineMap
+ .get(renderingEngine.getViewModel());
+ if (engines == null)
+ engines = new HashSet<RenderingEngine<?>>();
+
+ engines.add(renderingEngine);
+ this.renderingEngineMap.put(renderingEngine.getViewModel(),
engines);
+
+ }
+
+ @Override
+ public void handleEvent(PresentationDestroyedEvent e) {
+ final RenderingEngine<?> renderingEngine = e.getSource();
+ if (renderingEngine == null)
+ return;
+
+ this.renderingEngineMap.remove(renderingEngine.getViewModel());
+
+ }
+
+}
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/package-info.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/package-info.java
2010-10-21 21:12:24 UTC (rev 22335)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/package-info.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -1,5 +1,6 @@
/**
- * API set for all rendering engines (visualizers).
+ * API set for rendering engines (visualizers).
+ * Developers who wants to implement their own rendering engines, they should
implement these interfaces.
*/
package org.cytoscape.view.presentation;
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/PaintVisualProperty.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/PaintVisualProperty.java
2010-10-21 21:12:24 UTC (rev 22335)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/PaintVisualProperty.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -52,11 +52,11 @@
throw new IllegalArgumentException("This method
supports Color object only. Override this method for more implementations.");
}
- Integer red = new Integer(((Color) color).getRed());
- Integer green = new Integer(((Color) color).getGreen());
- Integer blue = new Integer(((Color) color).getBlue());
+ final Integer red = Integer.valueOf(((Color) color).getRed());
+ final Integer green = Integer.valueOf(((Color)
color).getGreen());
+ final Integer blue = Integer.valueOf(((Color) color).getBlue());
- return new String(red.toString() + "," + green.toString() + ","
+ blue.toString());
+ return red.toString() + "," + green.toString() + "," +
blue.toString();
}
public T parseSerializableString(final String text) {
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/VisualPropertyUtil.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/VisualPropertyUtil.java
2010-10-21 21:12:24 UTC (rev 22335)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/VisualPropertyUtil.java
2010-10-21 21:15:08 UTC (rev 22336)
@@ -10,7 +10,7 @@
public static boolean isChildOf(final VisualProperty<?> parent, final
VisualProperty<?> vp,
final VisualLexicon lexicon) {
- if (vp == parent ||
lexicon.getVisualLexiconNode(vp).getParent() == parent)
+ if (vp == parent ||
lexicon.getVisualLexiconNode(vp).getParent().getVisualProperty() == parent)
return true;
VisualLexiconNode node = lexicon.getVisualLexiconNode(vp);
--
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.