Author: kono
Date: 2009-08-12 15:09:34 -0700 (Wed, 12 Aug 2009)
New Revision: 17799

Added:
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/DefaultVisualStyleBuilder.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ui/ProcessingPropertyPanel.java
Modified:
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/pom.xml
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NetworkRenderer.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/resources/META-INF/spring/bundle-context.xml
Log:
Default visual style builder had been added.

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/pom.xml
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/pom.xml
    2009-08-12 21:17:40 UTC (rev 17798)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/pom.xml
    2009-08-12 22:09:34 UTC (rev 17799)
@@ -59,12 +59,12 @@
                        <artifactId>physics</artifactId>
                        <version>0004-SNAPSHOT</version>
                </dependency>
-               
+
                <dependency>
                        <groupId>org.cytoscape.wrappers</groupId>
                        <artifactId>gestalt.gestalt-osgi</artifactId>
                        <version>0.0.1</version>
-                       
+
                </dependency>
 
                <!-- Cytoscape Dependency -->
@@ -93,6 +93,12 @@
                </dependency>
 
                <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>default-mappings</artifactId>
+                       <version>1.0-SNAPSHOT</version>
+               </dependency>
+
+               <dependency>
                        <groupId>cytoscape</groupId>
                        <artifactId>application</artifactId>
                        <version>1.0-SNAPSHOT</version>

Added: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/DefaultVisualStyleBuilder.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/DefaultVisualStyleBuilder.java
                           (rev 0)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/DefaultVisualStyleBuilder.java
   2009-08-12 22:09:34 UTC (rev 17799)
@@ -0,0 +1,69 @@
+package org.cytoscape.view.presentation.processing.internal;
+
+import static org.cytoscape.view.presentation.property.TwoDVisualLexicon.*;
+import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_LABEL;
+import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_OPACITY;
+
+import java.awt.Color;
+
+import org.cytoscape.view.vizmap.VisualMappingManager;
+import org.cytoscape.view.vizmap.VisualStyle;
+import org.cytoscape.view.vizmap.mappings.PassthroughMapping;
+
+/**
+ * Create default Visual Style for Processing Renderer
+ * 
+ * @author kono
+ * 
+ */
+public class DefaultVisualStyleBuilder {
+
+       // TODO: this attr name should be managed in model!!!
+       private static final String NAME = "name";
+
+       private static final String STYLE_TITLE = "Processing Default Style";
+
+       private static final Color DEF_NODE_COLOR = new Color(0, 30, 250);
+       private static final double DEF_NODE_OPACITY = 100d;
+
+       private static final Color DEF_EDGE_COLOR = new Color(0, 30, 250);
+       private static final double DEF_EDGE_OPACITY = 150d;
+
+       private static final Color DEF_BACKGROUND_COLOR = new Color(255, 255, 
255);
+
+       private VisualStyle style;
+
+       private final VisualMappingManager vmm;
+
+       public DefaultVisualStyleBuilder(VisualMappingManager vmm) {
+               this.vmm = vmm;
+               buildStyle();
+       }
+
+       private void buildStyle() {
+               style = vmm.createVisualStyle(STYLE_TITLE);
+
+               final PassthroughMapping<String, String> labelMapping = new 
PassthroughMapping<String, String>(
+                               NAME, String.class, NODE_LABEL);
+
+               final PassthroughMapping<String, String> edgeLabelMapping = new 
PassthroughMapping<String, String>(
+                               NAME, String.class, EDGE_LABEL);
+
+               style.addVisualMappingFunction(labelMapping);
+               style.addVisualMappingFunction(edgeLabelMapping);
+
+               style.setDefaultValue(NODE_COLOR, DEF_NODE_COLOR);
+               style.setDefaultValue(NODE_OPACITY, DEF_NODE_OPACITY);
+
+               style.setDefaultValue(EDGE_COLOR, DEF_EDGE_COLOR);
+               style.setDefaultValue(EDGE_OPACITY, DEF_EDGE_OPACITY);
+
+               style.setDefaultValue(NETWORK_BACKGROUND_COLOR, 
DEF_BACKGROUND_COLOR);
+
+       }
+
+       public VisualStyle getDefaultStyle() {
+               return style;
+       }
+
+}

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NetworkRenderer.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NetworkRenderer.java
   2009-08-12 21:17:40 UTC (rev 17798)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NetworkRenderer.java
   2009-08-12 22:09:34 UTC (rev 17799)
@@ -1,40 +1,30 @@
 package org.cytoscape.view.presentation.processing.internal;
 
-import static 
org.cytoscape.view.presentation.processing.visualproperty.ProcessingVisualLexicon.NODE_STYLE;
+import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NETWORK_BACKGROUND_COLOR;
 
 import org.cytoscape.view.model.CyNetworkView;
 import org.cytoscape.view.model.VisualLexicon;
-import org.cytoscape.view.presentation.processing.CyDrawable;
-import org.cytoscape.view.presentation.processing.internal.shape.Cube;
+import org.cytoscape.view.presentation.VisualItemRenderer;
+import org.cytoscape.view.presentation.property.BasicVisualLexicon;
 
 import processing.core.PApplet;
 
-public class P5NetworkRenderer extends AbstractRenderer<CyNetworkView> {
+public class P5NetworkRenderer implements VisualItemRenderer<CyNetworkView> {
 
        public P5NetworkRenderer(PApplet p) {
-               super(p);
+               
                // TODO Auto-generated constructor stub
        }
 
-       @Override
-       protected VisualLexicon buildLexicon() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-       
-       public CyDrawable render(CyNetworkView view) {
-               // If Style property is available, use it.
-               CyDrawable style = view.getVisualProperty(NODE_STYLE);
-               
 
-               // If not available, use the default CyDrawable, which is a 
cube.
-               if (style == null)
-                       style = new Cube(p, lexicon);
 
-               style.setContext(view);
-
-               return style;
+       public VisualLexicon getVisualLexicon() {
+               final VisualLexicon networkLexicon = new BasicVisualLexicon();
+               networkLexicon.addVisualProperty(NETWORK_BACKGROUND_COLOR);
+               
+               return networkLexicon;
        }
+       
+       
 
-
 }

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
   2009-08-12 21:17:40 UTC (rev 17798)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
   2009-08-12 22:09:34 UTC (rev 17799)
@@ -1,7 +1,9 @@
 package org.cytoscape.view.presentation.processing.internal;
 
+import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Image;
+import java.awt.Paint;
 import java.awt.event.MouseWheelEvent;
 import java.awt.event.MouseWheelListener;
 import java.awt.print.Printable;
@@ -37,6 +39,9 @@
 
 import com.sun.opengl.util.FPSAnimator;
 
+import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NETWORK_BACKGROUND_COLOR;
+
+
 public class ProcessingNetworkRenderer extends PApplet implements
                RenderingEngine {
 
@@ -71,6 +76,9 @@
        
        // Control
        private boolean isOverlay = false;
+       
+       // Network Visuals
+       private Color bgColor;
 
        /**
         * Constructor. Create a PApplet component based on the size given as
@@ -184,6 +192,8 @@
                edges = new CyDrawable[edgeViews.size()];
                for (int i = 0; i < edges.length; i++)
                        edges[i] = edgeRenderer.render(edgeViews.get(i));
+               
+               renderNetworkVisualProperties();
 
                numP = nodes.length;
                particleManager = new ParticleManager(numP, this, physics);
@@ -193,10 +203,17 @@
                System.out.println("%%%%%%%%%%%%% Setup DONE for P5");
        }
 
+       private void renderNetworkVisualProperties() {
+               bgColor = (Color) 
view.getVisualProperty(NETWORK_BACKGROUND_COLOR);
+               if(bgColor == null)
+                       bgColor = Color.green;
+                       
+       }
+       
        private int numP;
 
        public void draw() {
-               background(200);
+               background(bgColor.getRed(), bgColor.getGreen(), 
bgColor.getGreen());
                physics.update();
                lights();
 

Added: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ui/ProcessingPropertyPanel.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ui/ProcessingPropertyPanel.java
                          (rev 0)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ui/ProcessingPropertyPanel.java
  2009-08-12 22:09:34 UTC (rev 17799)
@@ -0,0 +1,132 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * ProcessingControlPanel.java
+ *
+ * Created on 2009/08/11, 14:54:04
+ */
+
+package org.cytoscape.view.presentation.processing.internal.ui;
+
+/**
+ *
+ * @author kono
+ */
+public class ProcessingPropertyPanel extends javax.swing.JPanel {
+
+    /** Creates new form ProcessingControlPanel */
+    public ProcessingPropertyPanel() {
+        initComponents();
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">
+    private void initComponents() {
+
+        mainPanel = new javax.swing.JPanel();
+        mainSplitPane = new javax.swing.JSplitPane();
+        treeScrollPane = new javax.swing.JScrollPane();
+        propTree = new javax.swing.JTree();
+        ButtonPanel = new javax.swing.JPanel();
+        okButton = new javax.swing.JButton();
+        cancelButton = new javax.swing.JButton();
+
+        mainSplitPane.setDividerLocation(200);
+        mainSplitPane.setDividerSize(4);
+
+        treeScrollPane.setViewportView(propTree);
+
+        mainSplitPane.setLeftComponent(treeScrollPane);
+
+        javax.swing.GroupLayout mainPanelLayout = new 
javax.swing.GroupLayout(mainPanel);
+        mainPanel.setLayout(mainPanelLayout);
+        mainPanelLayout.setHorizontalGroup(
+            
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addComponent(mainSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 
462, Short.MAX_VALUE)
+        );
+        mainPanelLayout.setVerticalGroup(
+            
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addComponent(mainSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 
553, Short.MAX_VALUE)
+        );
+
+        ButtonPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new 
java.awt.Color(0, 0, 0)));
+
+        okButton.setText("OK");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        cancelButton.setText("Cancel");
+        cancelButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                cancelButtonActionPerformed(evt);
+            }
+        });
+
+        javax.swing.GroupLayout ButtonPanelLayout = new 
javax.swing.GroupLayout(ButtonPanel);
+        ButtonPanel.setLayout(ButtonPanelLayout);
+        ButtonPanelLayout.setHorizontalGroup(
+            
ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
ButtonPanelLayout.createSequentialGroup()
+                .addContainerGap(325, Short.MAX_VALUE)
+                .addComponent(okButton)
+                
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(cancelButton)
+                .addGap(12, 12, 12))
+        );
+        ButtonPanelLayout.setVerticalGroup(
+            
ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
ButtonPanelLayout.createSequentialGroup()
+                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE)
+                
.addGroup(ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(cancelButton)
+                    .addComponent(okButton))
+                .addContainerGap())
+        );
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addComponent(ButtonPanel, 
javax.swing.GroupLayout.Alignment.TRAILING, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE)
+            .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
layout.createSequentialGroup()
+                .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(ButtonPanel, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE))
+        );
+    }// </editor-fold>
+
+    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
+        // TODO add your handling code here:
+    }
+
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
+        // TODO add your handling code here:
+    }
+
+
+    // Variables declaration - do not modify
+    private javax.swing.JPanel ButtonPanel;
+    private javax.swing.JButton cancelButton;
+    private javax.swing.JPanel mainPanel;
+    private javax.swing.JSplitPane mainSplitPane;
+    private javax.swing.JButton okButton;
+    private javax.swing.JTree propTree;
+    private javax.swing.JScrollPane treeScrollPane;
+    // End of variables declaration
+
+}

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/resources/META-INF/spring/bundle-context-osgi.xml
 2009-08-12 21:17:40 UTC (rev 17798)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/resources/META-INF/spring/bundle-context-osgi.xml
 2009-08-12 22:09:34 UTC (rev 17799)
@@ -8,6 +8,9 @@
        <osgi:reference id="cyNetworkManagerServiceRef"
                interface="org.cytoscape.session.CyNetworkManager" />
 
+       <osgi:reference id="visualMappingManagerServiceRef"
+               interface="org.cytoscape.view.vizmap.VisualMappingManager" />
+
        <osgi:service id="createPresentationTaskFactoryService"
                ref="createPresentationTaskFactory" 
interface="org.cytoscape.work.TaskFactory">
                <osgi:service-properties>
@@ -18,10 +21,13 @@
 
 
        <!-- Export Processing Rendering Engine -->
-       <osgi:service id="processingPresentationFactoryService" 
ref="processingPresentationFactory">
+       <osgi:service id="processingPresentationFactoryService"
+               ref="processingPresentationFactory">
                <osgi:interfaces>
-                       
<value>org.cytoscape.view.presentation.PresentationFactory</value>
-                       
<value>org.cytoscape.view.model.events.NetworkViewChangedListener</value>
+                       
<value>org.cytoscape.view.presentation.PresentationFactory
+                       </value>
+                       
<value>org.cytoscape.view.model.events.NetworkViewChangedListener
+                       </value>
                </osgi:interfaces>
                <osgi:service-properties>
                        <entry key="serviceType" value="presentationFactory" />

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/resources/META-INF/spring/bundle-context.xml
      2009-08-12 21:17:40 UTC (rev 17798)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/resources/META-INF/spring/bundle-context.xml
      2009-08-12 22:09:34 UTC (rev 17799)
@@ -30,5 +30,10 @@
        <bean id="processingPresentationFactory"
                
class="org.cytoscape.view.presentation.processing.internal.ProcessingPresentationFactory">
        </bean>
+       
+       <bean id="visualStyleBuilder"
+               
class="org.cytoscape.view.presentation.processing.internal.DefaultVisualStyleBuilder">
+               <constructor-arg ref="visualMappingManagerServiceRef" />
+       </bean>
 
 </beans>


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

Reply via email to