Author: kono
Date: 2010-10-27 10:58:43 -0700 (Wed, 27 Oct 2010)
New Revision: 22501
Added:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedListener.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedListener.java
core3/presentation-api/trunk/src/main/resources/META-INF/spring/
core3/presentation-api/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
core3/presentation-api/trunk/src/main/resources/META-INF/spring/bundle-context.xml
Removed:
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/PresentationDestroyedEventListener.java
Modified:
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
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/PresentationDestroyedEvent.java
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/property/DefaultVisualizableVisualProperty.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/NullVisualProperty.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/ThreeDVisualLexicon.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/TwoDVisualLexicon.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/VisualPropertyUtil.java
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/PresentationEventsTest.java
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/RenderingEngineManagerTest.java
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/TwoDVisualLexiconTest.java
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/VisualPropertyUtilTest.java
core3/vizmap-api/trunk/src/test/java/org/cytoscape/view/vizmap/AbstractVisualStyleTest.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/DefaultVisualStyleBuilder.java
Log:
Presentation API is refactored and it's in alpha 1 status.
Modified:
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
===================================================================
---
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -2744,7 +2744,7 @@
enableEdgeSelection();
else
disableEdgeSelection();
- } else if (vp == TwoDVisualLexicon.NETWORK_BACKGROUND_COLOR) {
+ } else if (vp == TwoDVisualLexicon.NETWORK_BACKGROUND_PAINT) {
setBackgroundPaint((Paint) o);
} else if (vp == TwoDVisualLexicon.NETWORK_CENTER_X_LOCATION) {
setCenter(((Double) o).doubleValue(),
m_networkCanvas.m_yCenter);
Modified:
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/PresentationCreatedEvent.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedEvent.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -2,21 +2,38 @@
import org.cytoscape.event.AbstractCyEvent;
import org.cytoscape.view.presentation.RenderingEngine;
+import org.cytoscape.view.presentation.RenderingEngineFactory;
/**
* When {...@linkplain RenderingEngineFactory} creates a new presentation (
* {...@linkplain RenderingEngine}), this event should be fired.
*
*/
-public final class PresentationCreatedEvent extends
AbstractCyEvent<RenderingEngine<?>> {
+public final class PresentationCreatedEvent extends
+ AbstractCyEvent<RenderingEngineFactory<?>> {
+ private final RenderingEngine<?> engine;
+
/**
- * Create a new event for the new RenderingEngine object.
+ * Create an event for newly created presentation.
*
- * @param engine newly created RenderingEngine object.
+ * @param source factory taht creates the new engine.
+ * @param engine New {...@linkplain RenderingEngine} just created.
*/
- public PresentationCreatedEvent(RenderingEngine<?> engine) {
- super(engine, PresentationCreatedEventListener.class);
+ public PresentationCreatedEvent(final RenderingEngineFactory<?> source,
+ final RenderingEngine<?> engine) {
+ super(source, PresentationCreatedListener.class);
+ this.engine = engine;
+
}
+ /**
+ * Get new rendering engine.
+ *
+ * @return new rendering engine.
+ */
+ public RenderingEngine<?> getRenderingEngine() {
+ return this.engine;
+ }
+
}
Deleted:
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/PresentationCreatedEventListener.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedEventListener.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -1,21 +0,0 @@
-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);
-}
Copied:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedListener.java
(from rev 22416,
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/PresentationCreatedListener.java
(rev 0)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationCreatedListener.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -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 PresentationCreatedListener 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);
+}
Modified:
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
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedEvent.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -4,18 +4,31 @@
import org.cytoscape.view.presentation.RenderingEngine;
/**
- * When presentation (rendered graphics) is destroyed, this event should be
fired.
- *
+ * When presentation (rendered graphics) is destroyed, this event should be
+ * fired.
+ *
*/
-public final class PresentationDestroyedEvent extends
AbstractCyEvent<RenderingEngine<?>> {
+public final class PresentationDestroyedEvent extends AbstractCyEvent<Object> {
+ private final RenderingEngine<?> engine;
+
/**
* Construct an event for destroyed {...@linkplain RenderingEngine}.
*
- * @param source RenderingEngine for the deleted presentation.
+ * @param source
+ * source of event. In theory, this can be anything, but in
most
+ * cases, it will be an GUI components.
+ * @param engine
+ * {...@linkplain RenderingEngine} associated with the
deleted
+ * presentation.
*/
- public PresentationDestroyedEvent(final RenderingEngine<?> source) {
- super(source, PresentationDestroyedEventListener.class);
+ public PresentationDestroyedEvent(final Object source, final
RenderingEngine<?> engine) {
+ super(source, PresentationDestroyedListener.class);
+ this.engine = engine;
}
+ public RenderingEngine<?> getRenderingEngine() {
+ return this.engine;
+ }
+
}
Deleted:
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
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedEventListener.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -1,16 +0,0 @@
-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);
-
-}
Copied:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedListener.java
(from rev 22416,
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/PresentationDestroyedListener.java
(rev 0)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/events/PresentationDestroyedListener.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -0,0 +1,16 @@
+package org.cytoscape.view.presentation.events;
+
+/**
+ * Listener for destroyed presentations.
+ *
+ */
+public interface PresentationDestroyedListener {
+
+ /**
+ * Perform post-deletion tasks in this method.
+ *
+ * @param evt event containing deleted presentation's RenderingEngine.
+ */
+ void handleEvent(final PresentationDestroyedEvent evt);
+
+}
Modified:
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
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/internal/RenderingEngineManagerImpl.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -10,12 +10,12 @@
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.PresentationCreatedListener;
import org.cytoscape.view.presentation.events.PresentationDestroyedEvent;
-import
org.cytoscape.view.presentation.events.PresentationDestroyedEventListener;
+import org.cytoscape.view.presentation.events.PresentationDestroyedListener;
public class RenderingEngineManagerImpl implements RenderingEngineManager,
- PresentationCreatedEventListener,
PresentationDestroyedEventListener {
+ PresentationCreatedListener, PresentationDestroyedListener {
private final Map<View<?>, Set<RenderingEngine<?>>> renderingEngineMap;
@@ -42,7 +42,7 @@
@Override
public void handleEvent(PresentationCreatedEvent e) {
// This cannot be null.
- final RenderingEngine<?> renderingEngine = e.getSource();
+ final RenderingEngine<?> renderingEngine =
e.getRenderingEngine();
final View<?> viewModel = renderingEngine.getViewModel();
Set<RenderingEngine<?>> engines = renderingEngineMap
@@ -57,7 +57,7 @@
@Override
public void handleEvent(PresentationDestroyedEvent e) {
// This cannot be null.
- final RenderingEngine<?> renderingEngine = e.getSource();
+ final RenderingEngine<?> renderingEngine =
e.getRenderingEngine();
final View<?> viewModel = renderingEngine.getViewModel();
final Set<RenderingEngine<?>> engineSet =
renderingEngineMap.get(viewModel);
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/DefaultVisualizableVisualProperty.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/DefaultVisualizableVisualProperty.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/DefaultVisualizableVisualProperty.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -4,21 +4,26 @@
import org.cytoscape.view.model.Visualizable;
import org.cytoscape.view.presentation.internal.property.VisualizableImpl;
-public class DefaultVisualizableVisualProperty extends
AbstractVisualProperty<Visualizable> {
-
+/**
+ * Visual Property to represent abstract concept such as Node or Edge. If
+ * rendering engine have this visual property in the lexicon tree and if it's a
+ * leaf, it should render it with default settings.
+ *
+ */
+public class DefaultVisualizableVisualProperty extends
+ AbstractVisualProperty<Visualizable> {
+
private static final Visualizable visualizable = new VisualizableImpl();
public DefaultVisualizableVisualProperty(final String id, final String
name) {
super(visualizable, Visualizable.class, id, name);
}
-
@Override
public String toSerializableString(final Visualizable value) {
return value.toString();
}
-
@Override
public Visualizable parseSerializableString(final String text) {
return visualizable;
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/NullVisualProperty.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/NullVisualProperty.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/NullVisualProperty.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -4,10 +4,15 @@
import org.cytoscape.view.model.NullDataType;
import org.cytoscape.view.presentation.internal.property.NullDataTypeImpl;
+/**
+ * Visual Property for root. This will not be used in actual visualization.
Just
+ * a marker node in the tree.
+ *
+ */
public class NullVisualProperty extends AbstractVisualProperty<NullDataType> {
private static final NullDataType dummyObject = new NullDataTypeImpl();
-
+
public NullVisualProperty(final String id, final String name) {
super(dummyObject, NullDataType.class, id, name);
}
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/ThreeDVisualLexicon.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/ThreeDVisualLexicon.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/ThreeDVisualLexicon.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -3,6 +3,10 @@
import org.cytoscape.view.model.NullDataType;
import org.cytoscape.view.model.VisualProperty;
+/**
+ * Minimal set of Visual Properties for 3D rendering engines.
+ *
+ */
public class ThreeDVisualLexicon extends TwoDVisualLexicon {
public static final VisualProperty<Double> NODE_Z_LOCATION = new
DoubleVisualProperty(
@@ -17,6 +21,12 @@
public static final VisualProperty<Double> NETWORK_DEPTH = new
DoubleVisualProperty(
0.0, "NETWORK_DEPTH", "Network Depth");
+ /**
+ * Construct a {...@linkplain VisalLexicon} for 3D rendering engine.
+ *
+ * @param root Root node in the lexicon tree.
+ *
+ */
public ThreeDVisualLexicon(final VisualProperty<NullDataType> root) {
super(root);
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/TwoDVisualLexicon.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/TwoDVisualLexicon.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/TwoDVisualLexicon.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -47,28 +47,27 @@
* all {...@linkplain RenderingEngine}s. All of Visual Properties are
singletons
* and accessible as static object.
*
- * @author kono
- *
*/
public class TwoDVisualLexicon extends AbstractVisualLexicon {
// Top level nodes has null as parent, and will be pointed by parent
node.
// This is because all VPs are static objects.
+ ////// Top level objects ///////
public static final VisualProperty<Visualizable> NETWORK = new
DefaultVisualizableVisualProperty(
"NETWORK", "Network Visual Property");
-
public static final VisualProperty<Visualizable> NODE = new
DefaultVisualizableVisualProperty(
"NODE", "Node Visual Property");
public static final VisualProperty<Visualizable> EDGE = new
DefaultVisualizableVisualProperty(
"EDGE", "Edge Visual Property");
+
+ ////// Node VP /////////
public static final VisualProperty<Paint> NODE_PAINT = new
PaintVisualProperty(
Color.gray, "NODE_PAINT", "Node Paint");
public static final VisualProperty<Paint> NODE_COLOR = new
PaintVisualProperty(
Color.RED, "NODE_COLOR", "Node Color");
- public static final VisualProperty<Paint> NODE_SELECTED_COLOR = new
PaintVisualProperty(
- Color.YELLOW, "NODE_SELECTED_COLOR", "Node Selected
Color");
+
public static final VisualProperty<Paint> NODE_LABEL_COLOR = new
PaintVisualProperty(
Color.BLACK, "NODE_LABEL_COLOR", "Node Label Color");
@@ -97,6 +96,8 @@
public static final VisualProperty<Boolean> NODE_SELECTED = new
BooleanVisualProperty(
false, "NODE_SELECTED", "Node Selected");
+
+ /////// Edge VP ///////
public static final VisualProperty<Paint> EDGE_PAINT = new
PaintVisualProperty(
Color.gray, "EDGE_PAINT", "Edge Paint");
public static final VisualProperty<Paint> EDGE_COLOR = new
PaintVisualProperty(
@@ -118,6 +119,8 @@
public static final VisualProperty<Boolean> EDGE_SELECTED = new
BooleanVisualProperty(
false, "EDGE_SELECTED", "Edge Selected");
+
+ //////// Network VP ////////
public static final VisualProperty<Double> NETWORK_SCALE_FACTOR = new
DoubleVisualProperty(
1.0, "NETWORK_SCALE_FACTOR", "Network Scale Factor");
@@ -138,17 +141,21 @@
public static final VisualProperty<String> NETWORK_TITLE = new
StringVisualProperty(
"", "NETWORK_TITLE", "Network Title");
- public static final VisualProperty<Paint> NETWORK_PAINT = new
PaintVisualProperty(
- Color.WHITE, "NETWORK_PAINT", "Network Paint");
- public static final VisualProperty<Paint> NETWORK_BACKGROUND_COLOR =
new PaintVisualProperty(
- Color.WHITE, "NETWORK_BACKGROUND_COLOR", "Network
Background Color");
+ public static final VisualProperty<Paint> NETWORK_BACKGROUND_PAINT =
new PaintVisualProperty(
+ Color.WHITE, "NETWORK_BACKGROUND_PAINT", "Network
Background Paint");
+
+ public static final VisualProperty<Paint> NETWORK_NODE_SELECTED_COLOR =
new PaintVisualProperty(
+ Color.YELLOW, "NETWORK_NODE_SELECTED_COLOR", "Node
Selected Color");
+
+ public static final VisualProperty<Paint> NETWORK_EDGE_SELECTED_COLOR =
new PaintVisualProperty(
+ Color.YELLOW, "NETWORK_EDGE_SELECTED_COLOR", "Edge
Selected Color");
/**
* Build tree-structure for the set of Visual Properties defined in this
* class.
*
- * @param root
- * @param nodeFactory
+ * @param root root node in the lexicon tree. It is just an entry
point for this tree.
+ *
*/
public TwoDVisualLexicon(final VisualProperty<NullDataType> root) {
super(root);
@@ -158,11 +165,13 @@
addVisualProperty(NODE, NETWORK);
addVisualProperty(EDGE, NETWORK);
- addVisualProperty(NETWORK_PAINT, NETWORK);
addVisualProperty(NETWORK_SIZE, NETWORK);
addVisualProperty(NETWORK_CENTER_LOCATION, NETWORK);
addVisualProperty(NETWORK_SCALE_FACTOR, NETWORK);
+ addVisualProperty(NETWORK_NODE_SELECTED_COLOR, NETWORK);
+ addVisualProperty(NETWORK_EDGE_SELECTED_COLOR, NETWORK);
+
addVisualProperty(NODE_LOCATION, NODE);
addVisualProperty(NODE_PAINT, NODE);
addVisualProperty(NODE_SIZE, NODE);
@@ -176,7 +185,7 @@
addVisualProperty(EDGE_SELECTED, EDGE);
addVisualProperty(NETWORK_TITLE, NETWORK);
- addVisualProperty(NETWORK_BACKGROUND_COLOR, NETWORK_PAINT);
+ addVisualProperty(NETWORK_BACKGROUND_PAINT, NETWORK);
addVisualProperty(NETWORK_WIDTH, NETWORK_SIZE);
addVisualProperty(NETWORK_HEIGHT, NETWORK_SIZE);
addVisualProperty(NETWORK_CENTER_X_LOCATION,
NETWORK_CENTER_LOCATION);
@@ -186,7 +195,6 @@
addVisualProperty(NODE_Y_LOCATION, NODE_LOCATION);
addVisualProperty(NODE_COLOR, NODE_PAINT);
addVisualProperty(NODE_LABEL_COLOR, NODE_PAINT);
- addVisualProperty(NODE_SELECTED_COLOR, NODE_PAINT);
addVisualProperty(NODE_X_SIZE, NODE_SIZE);
addVisualProperty(NODE_Y_SIZE, NODE_SIZE);
addVisualProperty(NODE_LABEL, NODE_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-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/VisualPropertyUtil.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -5,8 +5,22 @@
import org.cytoscape.view.model.VisualLexiconNode;
import org.cytoscape.view.model.VisualProperty;
+/**
+ * Utility functions for traversing visual lexicon tree.
+ *
+ */
public class VisualPropertyUtil {
+ /**
+ * Check whether the given {...@linkplain VisualProperty} is a child of
parent vp or not.
+ *
+ * @param parent parent visual property
+ * @param vp visual property to be tested
+ * @param lexicon lexicon tree
+ *
+ * @return true if it's a child of the parent or parent itself.
Otherwise, return false.
+ *
+ */
public static boolean isChildOf(final VisualProperty<?> parent, final
VisualProperty<?> vp,
final VisualLexicon lexicon) {
@@ -39,6 +53,14 @@
return false;
}
+
+ /**
+ * TODO: How can we avoid this?
+ *
+ * @param vp
+ * @param lexicon
+ * @return
+ */
public static String getGraphObjectType(final VisualProperty<?> vp,
final VisualLexicon lexicon) {
if(isChildOf(TwoDVisualLexicon.NODE, vp, lexicon))
return CyTableEntry.NODE;
Added:
core3/presentation-api/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
---
core3/presentation-api/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
(rev 0)
+++
core3/presentation-api/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2010-10-27 17:58:43 UTC (rev 22501)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd"
+ default-lazy-init="false">
+
+
+ <!-- Export Rendering Engine Manager Bean as a Service -->
+ <osgi:service id="renderingEngineManagerService"
ref="renderingEngineManager"
+
interface="org.cytoscape.view.presentation.RenderingEngineManager">
+ <osgi:service-properties>
+ <entry key="service.type" value="manager" />
+ </osgi:service-properties>
+ </osgi:service>
+
+</beans>
Added:
core3/presentation-api/trunk/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
---
core3/presentation-api/trunk/src/main/resources/META-INF/spring/bundle-context.xml
(rev 0)
+++
core3/presentation-api/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2010-10-27 17:58:43 UTC (rev 22501)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-2.5.xsd">
+
+ <context:annotation-config />
+
+ <!-- Rendering Engine Manager service bean -->
+ <bean id="renderingEngineManager"
+
class="org.cytoscape.view.presentation.internal.RenderingEngineManagerImpl">
+ </bean>
+
+</beans>
Modified:
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/PresentationEventsTest.java
===================================================================
---
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/PresentationEventsTest.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/PresentationEventsTest.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -4,6 +4,9 @@
import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+
import org.cytoscape.model.CyNetwork;
import org.cytoscape.view.presentation.events.PresentationCreatedEvent;
import org.cytoscape.view.presentation.events.PresentationDestroyedEvent;
@@ -24,12 +27,16 @@
@Test
public void testEvents() {
+ final RenderingEngineFactory<CyNetwork> factory =
createMock(RenderingEngineFactory.class);
final RenderingEngine<CyNetwork> engine =
createMock(RenderingEngine.class);
- final PresentationCreatedEvent createdEvent = new
PresentationCreatedEvent(engine);
- assertEquals(engine, createdEvent.getSource());
+ final PresentationCreatedEvent createdEvent = new
PresentationCreatedEvent(factory, engine);
+ assertEquals(factory, createdEvent.getSource());
+ assertEquals(engine, createdEvent.getRenderingEngine());
- final PresentationDestroyedEvent destroyedEvent = new
PresentationDestroyedEvent(engine);
- assertEquals(engine, destroyedEvent.getSource());
+ final JComponent deletePanel = new JPanel();
+ final PresentationDestroyedEvent destroyedEvent = new
PresentationDestroyedEvent(deletePanel, engine);
+ assertEquals(deletePanel, destroyedEvent.getSource());
+ assertEquals(engine, destroyedEvent.getRenderingEngine());
}
}
Modified:
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/RenderingEngineManagerTest.java
===================================================================
---
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/RenderingEngineManagerTest.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/RenderingEngineManagerTest.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -9,9 +9,9 @@
import org.cytoscape.model.CyNetwork;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.presentation.events.PresentationCreatedEvent;
-import org.cytoscape.view.presentation.events.PresentationCreatedEventListener;
+import org.cytoscape.view.presentation.events.PresentationCreatedListener;
import org.cytoscape.view.presentation.events.PresentationDestroyedEvent;
-import
org.cytoscape.view.presentation.events.PresentationDestroyedEventListener;
+import org.cytoscape.view.presentation.events.PresentationDestroyedListener;
import org.cytoscape.view.presentation.internal.RenderingEngineManagerImpl;
import org.junit.After;
import org.junit.Before;
@@ -43,6 +43,8 @@
final CyNetworkView networkView1 =
createMock(CyNetworkView.class);
final CyNetworkView networkView2 =
createMock(CyNetworkView.class);
+ final RenderingEngineFactory<CyNetwork> factory =
createMock(RenderingEngineFactory.class);
+
final RenderingEngine<CyNetwork> engine1 =
createMock(RenderingEngine.class);
final RenderingEngine<CyNetwork> engine2 =
createMock(RenderingEngine.class);
@@ -56,29 +58,29 @@
assertNotNull(engineSet);
assertEquals(0, engineSet.size());
- final PresentationCreatedEvent createdEvent1 = new
PresentationCreatedEvent(engine1);
+ final PresentationCreatedEvent createdEvent1 = new
PresentationCreatedEvent(factory, engine1);
expect(engine1.getViewModel()).andReturn(networkView1).anyTimes();
replay(engine1);
-
((PresentationCreatedEventListener)manager).handleEvent(createdEvent1);
+
((PresentationCreatedListener)manager).handleEvent(createdEvent1);
assertEquals(1,
manager.getRendringEngines(networkView1).size());
assertEquals(engine1,
manager.getRendringEngines(networkView1).iterator().next());
// Remove from manager
- final PresentationDestroyedEvent destroyEvent = new
PresentationDestroyedEvent(engine1);
-
((PresentationDestroyedEventListener)manager).handleEvent(destroyEvent);
+ final PresentationDestroyedEvent destroyEvent = new
PresentationDestroyedEvent(factory, engine1);
+
((PresentationDestroyedListener)manager).handleEvent(destroyEvent);
assertEquals(0,
manager.getRendringEngines(networkView1).size());
assertTrue(manager.getRendringEngines(networkView1) instanceof
Set);
// Add multiple engines
- final PresentationCreatedEvent createdEvent2 = new
PresentationCreatedEvent(engine2);
- final PresentationCreatedEvent createdEvent3 = new
PresentationCreatedEvent(engine3);
-
((PresentationCreatedEventListener)manager).handleEvent(createdEvent2);
-
((PresentationCreatedEventListener)manager).handleEvent(createdEvent1);
-
((PresentationCreatedEventListener)manager).handleEvent(createdEvent3);
+ final PresentationCreatedEvent createdEvent2 = new
PresentationCreatedEvent(factory, engine2);
+ final PresentationCreatedEvent createdEvent3 = new
PresentationCreatedEvent(factory, engine3);
+
((PresentationCreatedListener)manager).handleEvent(createdEvent2);
+
((PresentationCreatedListener)manager).handleEvent(createdEvent1);
+
((PresentationCreatedListener)manager).handleEvent(createdEvent3);
assertEquals(2,
manager.getRendringEngines(networkView1).size());
assertEquals(1,
manager.getRendringEngines(networkView2).size());
Modified:
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/TwoDVisualLexiconTest.java
===================================================================
---
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/TwoDVisualLexiconTest.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/TwoDVisualLexiconTest.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -56,11 +56,11 @@
assertEquals(1, nodeTextChild.size());
Collection<VisualLexiconNode> nodePaintChild =
twoDLex.getVisualLexiconNode(TwoDVisualLexicon.NODE_PAINT).getChildren();
- assertEquals(3, nodePaintChild.size());
+ assertEquals(2, nodePaintChild.size());
assertEquals(twoDLex.getAllDescendants(TwoDVisualLexicon.NODE_PAINT).size(),
nodePaintChild.size());
Collection<VisualProperty<?>> nodeChildren =
twoDLex.getAllDescendants(TwoDVisualLexicon.NODE);
- assertEquals(14, nodeChildren.size());
+ assertEquals(13, nodeChildren.size());
Collection<VisualProperty<?>> edgeChildren =
twoDLex.getAllDescendants(TwoDVisualLexicon.EDGE);
assertEquals(8, edgeChildren.size());
Modified:
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/VisualPropertyUtilTest.java
===================================================================
---
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/VisualPropertyUtilTest.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/VisualPropertyUtilTest.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -83,7 +83,7 @@
@Test
public void testGetGraphObjectType3() {
- final String type =
VisualPropertyUtil.getGraphObjectType(TwoDVisualLexicon.NETWORK_PAINT, lexicon);
+ final String type =
VisualPropertyUtil.getGraphObjectType(TwoDVisualLexicon.NETWORK_BACKGROUND_PAINT,
lexicon);
assertEquals("NETWORK", type);
}
Modified:
core3/vizmap-api/trunk/src/test/java/org/cytoscape/view/vizmap/AbstractVisualStyleTest.java
===================================================================
---
core3/vizmap-api/trunk/src/test/java/org/cytoscape/view/vizmap/AbstractVisualStyleTest.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/vizmap-api/trunk/src/test/java/org/cytoscape/view/vizmap/AbstractVisualStyleTest.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -46,9 +46,9 @@
assertEquals(lexicon, style.getVisualLexicon());
// Test default values.
- assertEquals(Color.white,
style.getDefaultValue(TwoDVisualLexicon.NETWORK_BACKGROUND_COLOR));
-
style.setDefaultValue(TwoDVisualLexicon.NETWORK_BACKGROUND_COLOR, Color.BLACK);
- assertEquals(Color.BLACK,
style.getDefaultValue(TwoDVisualLexicon.NETWORK_BACKGROUND_COLOR));
+ assertEquals(Color.white,
style.getDefaultValue(TwoDVisualLexicon.NETWORK_BACKGROUND_PAINT));
+
style.setDefaultValue(TwoDVisualLexicon.NETWORK_BACKGROUND_PAINT, Color.BLACK);
+ assertEquals(Color.BLACK,
style.getDefaultValue(TwoDVisualLexicon.NETWORK_BACKGROUND_PAINT));
assertEquals(Color.GRAY,
style.getDefaultValue(TwoDVisualLexicon.NODE_PAINT));
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/DefaultVisualStyleBuilder.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/DefaultVisualStyleBuilder.java
2010-10-27 17:56:50 UTC (rev 22500)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/DefaultVisualStyleBuilder.java
2010-10-27 17:58:43 UTC (rev 22501)
@@ -3,7 +3,7 @@
import static
org.cytoscape.view.presentation.property.TwoDVisualLexicon.EDGE_COLOR;
import static
org.cytoscape.view.presentation.property.TwoDVisualLexicon.EDGE_LABEL;
import static
org.cytoscape.view.presentation.property.TwoDVisualLexicon.EDGE_LABEL_COLOR;
-import static
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NETWORK_BACKGROUND_COLOR;
+import static
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NETWORK_BACKGROUND_PAINT;
import static
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_COLOR;
import static
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_LABEL;
import static
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_LABEL_COLOR;
@@ -101,7 +101,7 @@
newStyle.setDefaultValue(EDGE_LABEL_COLOR,
DEFAULT_EDGE_LABEL_COLOR );
// Set network appearance
- newStyle.setDefaultValue(NETWORK_BACKGROUND_COLOR,
DEFAULT_BACKGROUND_COLOR );
+ newStyle.setDefaultValue(NETWORK_BACKGROUND_PAINT,
DEFAULT_BACKGROUND_COLOR );
// Create label mappings
final PassthroughMapping<String, String> labelMapping = new
PassthroughMapping<String, String>(NAME, String.class, NODE_LABEL);
--
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.