Author: laylaoesper
Date: 2010-07-27 10:19:35 -0700 (Tue, 27 Jul 2010)
New Revision: 21032

Added:
   
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/AddDelimiterDialog.java
   
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/WordDelimiters.java
Modified:
   csplugins/trunk/soc/layla/SemanticSummary/jars/SemanticSummary.jar
   
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
   
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
   
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryParameters.java
   
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryPlugin.java
Log:
Adding the functionality to add/remove delimiters from use with the WordCloud.

Modified: csplugins/trunk/soc/layla/SemanticSummary/jars/SemanticSummary.jar
===================================================================
(Binary files differ)

Added: 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/AddDelimiterDialog.java
===================================================================
--- 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/AddDelimiterDialog.java
                           (rev 0)
+++ 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/AddDelimiterDialog.java
   2010-07-27 17:19:35 UTC (rev 21032)
@@ -0,0 +1,154 @@
+/*
+ File: EditCloudNameDialog.java
+
+ Copyright 2010 - The Cytoscape Consortium (www.cytoscape.org)
+ 
+ Code written by: Layla Oesper
+ Authors: Layla Oesper, Ruth Isserlin, Daniele Merico
+ 
+ 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 3 of the License, or
+ (at your option) 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.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU Lesser General Public License
+ along with this project.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package cytoscape.csplugins.semanticsummary;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.Insets;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+/**
+ * This class handles all the dialog box associated with defining your own 
delimiter.
+ * @author Layla Oesper
+ * @version 1.0
+ */
+
+public class AddDelimiterDialog extends JDialog implements ActionListener
+{
+       //VARIABLES
+       private String newName = "";
+
+       private JButton btnCancel;
+       private JButton btnOK;
+       private JLabel jLabel1;
+       private JPanel jPanel1;
+       private JTextField tfDelimiter;
+
+       
+       //CONSTRUCTOR
+       /**
+        * Creates a new AddDelimiterDialog object
+        * @param parent - parent component to display this in
+        * @param modal - whether this is a modal display
+        */
+       public AddDelimiterDialog(Component parent, boolean modal)
+       {
+               super((JFrame) parent, modal);
+               initComponents();
+               
+               setSize(new java.awt.Dimension(300, 170));
+       }
+       
+       //METHODS
+       /**
+        * Initializes all components for this dialog.
+        */
+       private void initComponents() {
+               GridBagConstraints gridBagConstraints;
+
+               jLabel1 = new JLabel();
+               tfDelimiter = new JTextField();
+               jPanel1 = new JPanel();
+               btnOK = new JButton();
+               btnCancel = new JButton();
+
+               btnOK.addActionListener(this);
+               btnCancel.addActionListener(this);
+
+               getContentPane().setLayout(new GridBagLayout());
+
+               
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+               setTitle("Add Word Tokenization Delimiter");
+               jLabel1.setText("Please enter the new delimiter:");
+               gridBagConstraints = new GridBagConstraints();
+               gridBagConstraints.anchor = GridBagConstraints.WEST;
+               gridBagConstraints.insets = new Insets(15, 10, 0, 0);
+               getContentPane().add(jLabel1, gridBagConstraints);
+
+               gridBagConstraints = new GridBagConstraints();
+               gridBagConstraints.gridy = 1;
+               gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+               gridBagConstraints.weightx = 1.0;
+               gridBagConstraints.insets = new Insets(10, 10, 10, 10);
+               getContentPane().add(tfDelimiter, gridBagConstraints);
+
+               btnOK.setText("OK");
+               btnOK.setPreferredSize(new Dimension(65, 23));
+               btnCancel.setPreferredSize(new Dimension(65, 23));
+
+               jPanel1.add(btnOK);
+
+               btnCancel.setText("Cancel");
+               jPanel1.add(btnCancel);
+
+               gridBagConstraints = new GridBagConstraints();
+               gridBagConstraints.gridy = 2;
+               gridBagConstraints.insets = new Insets(10, 0, 10, 0);
+               getContentPane().add(jPanel1, gridBagConstraints);
+
+               pack();
+       }
+       
+       /**
+        * Called when an action is performed on this dialog.
+        * @param ActionEvent
+        */
+       public void actionPerformed(ActionEvent e)
+       {
+               Object _actionObject = e.getSource();
+               
+               // handle button events
+               if(_actionObject instanceof JButton)
+               {
+                       JButton _btn = (JButton) _actionObject;
+                       
+                       if (_btn == btnOK)
+                       {
+                               newName = tfDelimiter.getText();
+                               this.dispose();
+                       } else if (_btn == btnCancel)
+                       {
+                               this.dispose();
+                       }
+               }
+       }
+       
+       /**
+        * Returns the new Cloud Name.
+        */
+       public String getNewDelimiter()
+       {
+               return newName;
+       }
+}
+

Modified: 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
===================================================================
--- 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
      2010-07-26 23:39:22 UTC (rev 21031)
+++ 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/CloudParameters.java
      2010-07-27 17:19:35 UTC (rev 21032)
@@ -88,7 +88,9 @@
        //String Delimeters
        private static final String NODEDELIMITER = "CloudParamNodeDelimiter";
        private static final String WORDDELIMITER = "CloudParamWordDelimiter";
+       private static final char controlChar = '\u001F';
        
+       
        //Default Values for User Input
        private Double defaultNetWeight = 0.5;
        private String defaultAttName = "nodeID";
@@ -894,12 +896,23 @@
                nodeValue = nodeValue.toLowerCase();
                
                //replace all punctuation with white spaces except ' and -
-               nodeValue = nodeValue.replaceAll("[[\\p{Punct}] && [^'-]]", " 
");
+               //nodeValue = nodeValue.replaceAll("[[\\p{Punct}] && [^'-]]", " 
");
+               String controlString = Character.toString(controlChar);
+               
+               //Remove all standard delimiters and replace with controlChar
+               WordDelimiters delims = this.getNetworkParams().getDelimiter();
+               nodeValue = 
nodeValue.replaceAll(delims.getRegex(),controlString);
         
+               //Remove all user stated delimiters and replace with controlChar
+               for (Iterator<String> iter = delims.getUserDelims().iterator(); 
iter.hasNext();)
+               {
+                       String userDelim = iter.next();
+                       nodeValue = nodeValue.replaceAll(userDelim, 
controlString);
+               }
+               
         //Separate into non repeating set of words
                List<String> wordSet = new ArrayList<String>();
-               //Set<String> wordSet = new HashSet<String>();
-        StringTokenizer token = new StringTokenizer(nodeValue);
+               StringTokenizer token = new StringTokenizer(nodeValue, 
controlString);
         while (token.hasMoreTokens())
         {
                String a = token.nextToken();

Modified: 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
===================================================================
--- 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
    2010-07-26 23:39:22 UTC (rev 21031)
+++ 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryInputPanel.java
    2010-07-27 17:19:35 UTC (rev 21032)
@@ -23,6 +23,7 @@
 package cytoscape.csplugins.semanticsummary;
 
 import java.awt.BorderLayout;
+import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.GridBagConstraints;
@@ -92,6 +93,8 @@
        private JComboBox cmbAttributes;
        private JComboBox cmbRemoval;
        private JComboBox cmbStyle;
+       private JComboBox cmbDelimiterRemoval;
+       private JComboBox cmbDelimiterAddition;
        
        //JLabels
        private JLabel networkLabel;
@@ -104,6 +107,8 @@
        //Buttons
        private JButton removeWordButton;
        private JButton addWordButton;
+       private JButton addDelimiterButton;
+       private JButton removeDelimiterButton;
        
        //Checkbox
        private JCheckBox numExclusion;
@@ -113,6 +118,11 @@
        private static final String flaggedSeparator = "--Flagged Words--";
        private static final String stopSeparator = "--Stop Words--";
        
+       //String COnstants for Separators in delimiter combo boxes
+       private static final String commonDelimiters = "--Common Delimiters--";
+       private static final String userAddDelimiters = "--User Defined--";
+       private static final String selectMe = "Select to add your own";
+       
        private static final int DEF_ROW_HEIGHT = 20;
 
        
@@ -242,6 +252,12 @@
                
                networkPanel.add(exclusionList);
                
+               //Delimiter/Tokenization Panel
+               CollapsiblePanel tokenizationPanel = createTokenizationPanel();
+               tokenizationPanel.setCollapsed(true);
+               
+               networkPanel.add(tokenizationPanel);
+               
                //Add to collapsible panel
                collapsiblePanel2.getContentPane().add(networkPanel, 
BorderLayout.NORTH);
                
@@ -519,6 +535,121 @@
        }
        
        /**
+        * Creates a CollapsiblePanel that holds the word tokenization 
information.
+        * @return CollapsiblePanel - word tokenization panel interface.
+        */
+       private CollapsiblePanel createTokenizationPanel()
+       {
+               CollapsiblePanel collapsiblePanel = new CollapsiblePanel("Word 
Tokenization");
+               
+               JPanel panel = new JPanel();
+               panel.setLayout(new GridLayout(0,1));
+               
+               //Add Delimiter
+               JLabel addDelimiterLabel = new JLabel("Add Delimiter");
+
+               //Delimiter Addition Combo Box
+               WidestStringComboBoxModel wscbm = new 
WidestStringComboBoxModel();
+               cmbDelimiterAddition = new JComboBox(wscbm);
+               cmbDelimiterAddition.addPopupMenuListener(new 
WidestStringComboBoxPopupMenuListener());
+               cmbDelimiterAddition.setEditable(false);
+           Dimension d = cmbDelimiterAddition.getPreferredSize();
+           cmbDelimiterAddition.setPreferredSize(new Dimension(15, d.height));
+           cmbDelimiterAddition.addItemListener(this);
+           
+           StringBuffer buf = new StringBuffer();
+               buf.append("<html>" + "Allows for specification of an 
additional delimiter to be used when tokenizing nodes" + "<br>");
+               buf.append("<b>Acceptable Values:</b> Values entered must have 
proper escape character if necessary" + "</html>");
+               cmbDelimiterAddition.setToolTipText(buf.toString());
+               
+               addDelimiterButton = new JButton();
+               addDelimiterButton.setText("Add");
+               addDelimiterButton.setEnabled(false);
+               addDelimiterButton.addActionListener(this);
+               
+               //Word panel
+               JPanel wordPanel = new JPanel();
+               wordPanel.setLayout(new GridBagLayout());
+               
+               GridBagConstraints gridBagConstraints = new 
GridBagConstraints();
+               gridBagConstraints.gridx = 0;
+               gridBagConstraints.gridy = 0;
+               gridBagConstraints.anchor = GridBagConstraints.WEST;
+               gridBagConstraints.insets = new Insets(5,0,0,0);
+               wordPanel.add(addDelimiterLabel, gridBagConstraints);
+               
+               gridBagConstraints = new GridBagConstraints();
+               gridBagConstraints.gridx = 1;
+               gridBagConstraints.gridy = 0;
+               gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+               gridBagConstraints.weightx = 1.0;
+               gridBagConstraints.insets = new Insets(5,10,0,10);
+               wordPanel.add(cmbDelimiterAddition, gridBagConstraints);
+               
+               //Button stuff
+               gridBagConstraints = new GridBagConstraints();
+               gridBagConstraints.gridx = 2;
+               gridBagConstraints.gridy = 0;
+               gridBagConstraints.anchor = GridBagConstraints.EAST;
+               gridBagConstraints.insets = new Insets(5,0,0,0);
+               wordPanel.add(addDelimiterButton, gridBagConstraints);
+               
+               
+               // Word Removal Label
+               JLabel removeDelimiterLabel = new JLabel("Remove Delimiter");
+               
+               //Word Removal Combo Box
+               wscbm = new WidestStringComboBoxModel();
+               cmbDelimiterRemoval = new JComboBox(wscbm);
+               cmbDelimiterRemoval.addPopupMenuListener(new 
WidestStringComboBoxPopupMenuListener());
+               cmbDelimiterRemoval.setEditable(false);
+           d = cmbDelimiterRemoval.getPreferredSize();
+           cmbDelimiterRemoval.setPreferredSize(new Dimension(15, d.height));
+           cmbDelimiterRemoval.addItemListener(this);
+           cmbDelimiterRemoval.setToolTipText("Allows for selection of a 
delimiter to remove from the list used when tokenizing");
+
+           //Word Removal Button
+           removeDelimiterButton = new JButton();
+           removeDelimiterButton.setText("Remove");
+           removeDelimiterButton.setEnabled(false);
+           removeDelimiterButton.addActionListener(this);
+               
+               gridBagConstraints = new GridBagConstraints();
+               gridBagConstraints.gridx = 0;
+               gridBagConstraints.gridy = 1;
+               gridBagConstraints.anchor = GridBagConstraints.WEST;
+               gridBagConstraints.insets = new Insets(5,0,0,0);
+               wordPanel.add(removeDelimiterLabel, gridBagConstraints);
+               
+               gridBagConstraints = new GridBagConstraints();
+               gridBagConstraints.gridx = 1;
+               gridBagConstraints.gridy = 1;
+               gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+               gridBagConstraints.weightx = 1.0;
+               gridBagConstraints.insets = new Insets(5, 10, 0, 10);
+               wordPanel.add(cmbDelimiterRemoval, gridBagConstraints);
+               
+               //Button stuff
+               gridBagConstraints = new GridBagConstraints();
+               gridBagConstraints.gridx = 2;
+               gridBagConstraints.gridy = 1;
+               gridBagConstraints.anchor = GridBagConstraints.EAST;
+               gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
+               wordPanel.add(removeDelimiterButton, gridBagConstraints);
+
+               updateDelimiterCMBs();
+               
+               //Add components to main panel
+               panel.add(wordPanel);
+               
+               //Add to collapsible panel
+               collapsiblePanel.getContentPane().add(panel, 
BorderLayout.NORTH);
+               
+               return collapsiblePanel;
+       }
+       
+       
+       /**
         * Creates a CollapsiblePanel that holds the Cloud Layout information.
         * @return CollapsiblePanel - cloud Layout panel interface.
         */
@@ -668,7 +799,6 @@
                }
                
                SemanticSummaryManager.getInstance().setCurCloud(params);
-               //this.refreshRemovalCMB();
                this.refreshNetworkSettings();
        }
        
@@ -713,6 +843,80 @@
        }
        
        /**
+        * Update the delimiter combo boxes.
+        */
+       private void updateDelimiterCMBs()
+       {
+               // Add Box
+               DefaultComboBoxModel cmb;
+               cmb = ((DefaultComboBoxModel)cmbDelimiterAddition.getModel());
+               cmb.removeAllElements();
+               
+               SemanticSummaryParameters networkParams = 
SemanticSummaryManager.getInstance().getCurNetwork();
+               WordDelimiters curDelimiters = networkParams.getDelimiter();
+               
+               //Check if we are dealing with the Null 
SemanticSummaryParameters
+               Boolean isNull = false;
+               if 
(networkParams.equals(SemanticSummaryManager.getInstance().getNullSemanticSummary()))
+                               isNull = true;
+               
+               //Common Delimiters
+               cmb.addElement(commonDelimiters);
+               
+               if (!isNull)
+               {       
+                       //Add alphabetically order list of delimiters
+                       for(Iterator<String> iter = 
curDelimiters.getDelimsToAdd().iterator(); iter.hasNext();)
+                       {
+                               String curDelim = iter.next();
+                               cmb.addElement(curDelim);
+                       }
+               }
+               
+               //User to add
+               cmb.addElement(userAddDelimiters);
+               
+               if (!isNull)
+               {
+                       cmb.addElement(selectMe);
+               }
+               
+               cmbDelimiterAddition.repaint();
+               
+               //Remove Box
+               cmb = ((DefaultComboBoxModel)cmbDelimiterRemoval.getModel());
+               cmb.removeAllElements();
+               
+               //Common Delimiters
+               cmb.addElement(commonDelimiters);
+               
+               if (!isNull)
+               {       
+                       //Add alphabetically order list of delimiters
+                       for(Iterator<String> iter = 
curDelimiters.getDelimsInUse().iterator(); iter.hasNext();)
+                       {
+                               String curDelim = iter.next();
+                               cmb.addElement(curDelim);
+                       }
+               }
+               
+               //User to add
+               cmb.addElement(userAddDelimiters);
+               
+               if (!isNull)
+               {
+                       //Add alphabetically order list of delimiters
+                       for(Iterator<String> iter = 
curDelimiters.getUserDelims().iterator(); iter.hasNext();)
+                       {
+                               String curDelim = iter.next();
+                               cmb.addElement(curDelim);
+                       }
+               }
+               
+               cmbDelimiterRemoval.repaint();
+       }
+       
+       /**
         * Update the remove word list in the remove combobox.
         */
        private void updateCMBRemoval()
@@ -818,6 +1022,7 @@
        {
                this.refreshRemovalCMB();
                this.updateNumExclusionBox();
+               this.updateDelimiterCMBs();
        }
        
        
@@ -957,6 +1162,35 @@
                                                        
removeWordButton.setEnabled(true);
                                }//end if not null
                        }//end if cmbRemoval
+                       
+                       if (cmb == cmbDelimiterRemoval)
+                       {
+                               Object selectObject = 
cmbDelimiterRemoval.getSelectedItem();
+                               if (selectObject != null)
+                               {
+                                       String selectItem = 
selectObject.toString();
+                                       if 
(selectItem.equalsIgnoreCase(commonDelimiters) || 
+                                                       
selectItem.equalsIgnoreCase(userAddDelimiters))
+                                               
removeDelimiterButton.setEnabled(false);
+                                               else
+                                                       
removeDelimiterButton.setEnabled(true);
+                               }//end if not null
+                       }//end if cmbDelimiterRemoval
+                       
+                       if (cmb == cmbDelimiterAddition)
+                       {
+                               Object selectObject = 
cmbDelimiterAddition.getSelectedItem();
+                               if (selectObject != null)
+                               {
+                                       String selectItem = 
selectObject.toString();
+                                       if 
(selectItem.equalsIgnoreCase(commonDelimiters) || 
+                                                       
selectItem.equalsIgnoreCase(userAddDelimiters))
+                                               
addDelimiterButton.setEnabled(false);
+                                               else
+                                                       
addDelimiterButton.setEnabled(true);
+                               }//end if not null
+                       }//end if cmbDelimiterRemoval
+                       
                }//end if combo box
        }
        
@@ -1030,7 +1264,72 @@
                                        
JOptionPane.showMessageDialog(Cytoscape.getDesktop(), message, "Parameter out 
of bounds", JOptionPane.WARNING_MESSAGE);
                                }
                        }
+                       
+                       if (_btn == removeDelimiterButton)
+                       {
+                               //Get Selected word
+                               Object selectObject = 
cmbDelimiterRemoval.getSelectedItem();
+                               if (selectObject != null)
+                               {
+                                       String selectItem = 
selectObject.toString();
+                                       if 
(!selectItem.equalsIgnoreCase(commonDelimiters) || 
+                                                       
!selectItem.equalsIgnoreCase(userAddDelimiters))
+                                       {
+                                               SemanticSummaryParameters 
networkParams = SemanticSummaryManager.getInstance().getCurNetwork();
+                                               WordDelimiters curDelimiters = 
networkParams.getDelimiter();
+                                               
+                                               //Remove from delimiters
+                                               
curDelimiters.removeDelimiter(selectItem);
+                                               
+                                               //Reset flags
+                                               networkParams.networkChanged();
+                                               
+                                               //Refresh word removal list
+                                               this.updateDelimiterCMBs();
+                                       }//end if appropriate selection
+                               }//end if not null selected
+                       }//end remove delimiter button
+                       
+                       if (_btn == addDelimiterButton)
+                       {
+                               //Get Selected word
+                               Object selectObject = 
cmbDelimiterAddition.getSelectedItem();
+                               if (selectObject != null)
+                               {
+                                       String selectItem = 
selectObject.toString();
+                                       if 
(!selectItem.equalsIgnoreCase(commonDelimiters) || 
+                                                       
!selectItem.equalsIgnoreCase(userAddDelimiters))
+                                       {
+                                               //Dialog if user add
+                                               if (selectItem.equals(selectMe))
+                                               {
+                                                       Component parent = 
Cytoscape.getDesktop();
+                                                       AddDelimiterDialog 
dialog = new AddDelimiterDialog(parent, true);
+                                                       
dialog.setLocationRelativeTo(parent);
+                                                       dialog.setVisible(true);
+                                                       
+                                                       selectItem = 
dialog.getNewDelimiter();
+                                               }
+                                               
+                                               if (!selectItem.equals(""))
+                                               {
+                                                       
SemanticSummaryParameters networkParams = 
SemanticSummaryManager.getInstance().getCurNetwork();
+                                                       WordDelimiters 
curDelimiters = networkParams.getDelimiter();
+                                               
+                                                       //Add to delimiters
+                                                       
curDelimiters.addDelimToUse(selectItem);
+                                               
+                                                       //Reset flags
+                                                       
networkParams.networkChanged();
+                                               
+                                                       //Refresh word removal 
list
+                                                       
this.updateDelimiterCMBs();
+                                               }
+                                       }//end if appropriate selection
+                               }//end if not null selected
+                       }//end remove delimiter button
                }//end button   
+               
                else if (_actionObject instanceof JCheckBox)
                {
                        JCheckBox _box = (JCheckBox)_actionObject;
@@ -1123,7 +1422,27 @@
                numExclusion = box;
        }
        
+       public JComboBox getCMBDelimiterRemoval()
+       {
+               return cmbDelimiterRemoval;
+       }
        
+       public JComboBox getCMBDelimiterAddition()
+       {
+               return cmbDelimiterAddition;
+       }
+       
+       public JButton getAddDelimiterButton()
+       {
+               return addDelimiterButton;
+       }
+       
+       public JButton getRemoveDelimiterButton()
+       {
+               return removeDelimiterButton;
+       }
+       
+       
        /**
         * Private Class to ensure that text fields are being set properly
         */

Modified: 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryParameters.java
===================================================================
--- 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryParameters.java
    2010-07-26 23:39:22 UTC (rev 21031)
+++ 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryParameters.java
    2010-07-27 17:19:35 UTC (rev 21032)
@@ -63,6 +63,7 @@
        
        //Filter stuff
        private WordFilter filter;
+       private WordDelimiters delimiters;
        
        //CONSTRUCTORS
        
@@ -74,6 +75,7 @@
                this.clouds = new HashMap<String,CloudParameters>();
                this.nodeList = new ArrayList<String>();
                this.filter = new WordFilter();
+               this.delimiters = new WordDelimiters();
        }
        
        /**
@@ -378,4 +380,14 @@
                filter = aFilter;
        }
        
+       public WordDelimiters getDelimiter()
+       {
+               return delimiters;
+       }
+       
+       public void setDelimiter(WordDelimiters aDelimiter)
+       {
+               delimiters = aDelimiter;
+       }
+       
 }

Modified: 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryPlugin.java
===================================================================
--- 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryPlugin.java
        2010-07-26 23:39:22 UTC (rev 21031)
+++ 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/SemanticSummaryPlugin.java
        2010-07-27 17:19:35 UTC (rev 21032)
@@ -163,6 +163,12 @@
                                filterWriter.close();
                                pFileList.add(current_filter);
                                
+                               File current_delimiter = new File(tmpDir, 
netNameSep + networkName + netNameSep + ".DELIMITER.txt");
+                               BufferedWriter delimiterWriter = new 
BufferedWriter(new FileWriter(current_delimiter));
+                               
delimiterWriter.write(params.getDelimiter().toString());
+                               delimiterWriter.close();
+                               pFileList.add(current_delimiter);
+                               
                                //Loop on Clouds
                                if (!params.getClouds().isEmpty())
                                {
@@ -345,6 +351,25 @@
                                        WordFilter curFilter = new 
WordFilter(fullText);
                                        networkParams.setFilter(curFilter);
                                }
+                               
+                               if 
(prop_file.getName().contains(".DELIMITER.txt"))
+                               {
+                                       TextFileReader reader = new 
TextFileReader(prop_file.getAbsolutePath());
+                                       reader.read();
+                                       String fullText = reader.getText();
+                                       
+                                       //Get the networkID from the props file
+                                       String[] fullname = 
prop_file.getName().split(netNameSep);
+                                       String net_name = fullname[1];
+                                       
+                                       //Get the Network Parameters
+                                       SemanticSummaryParameters networkParams 
= 
+                                               
SemanticSummaryManager.getInstance().getCyNetworkList().get(net_name);
+                                       
+                                       //Recreate the Delimiter and set 
pointer in cloud
+                                       WordDelimiters curDelimiter = new 
WordDelimiters(fullText);
+                                       
networkParams.setDelimiter(curDelimiter);
+                               }
                        }//end loop through all props files
                        
                        
@@ -355,7 +380,8 @@
                                
                                if (prop_file.getName().contains(".CLOUDS.txt") 
||
                                                
prop_file.getName().contains(".props") || 
-                                               
prop_file.getName().contains(".FILTER.txt"))
+                                               
prop_file.getName().contains(".FILTER.txt") ||
+                                               
prop_file.getName().contains(".DELIMITER.txt"))
                                        continue;
                                
                                TextFileReader reader = new 
TextFileReader(prop_file.getAbsolutePath());

Added: 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/WordDelimiters.java
===================================================================
--- 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/WordDelimiters.java
                               (rev 0)
+++ 
csplugins/trunk/soc/layla/SemanticSummary/src/cytoscape/csplugins/semanticsummary/WordDelimiters.java
       2010-07-27 17:19:35 UTC (rev 21032)
@@ -0,0 +1,350 @@
+/*
+ File: WordDelimiters.java
+
+ Copyright 2010 - The Cytoscape Consortium (www.cytoscape.org)
+ 
+ Code written by: Layla Oesper
+ Authors: Layla Oesper, Ruth Isserlin, Daniele Merico
+ 
+ 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 3 of the License, or
+ (at your option) 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.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU Lesser General Public License
+ along with this project.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package cytoscape.csplugins.semanticsummary;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.TreeSet;
+
+/**
+ * This class defines the WordDelimiters class.  This class is used to 
determine
+ * if a delimiter in question should be used to tokenize text.
+ * 
+ * @author Layla Oesper
+ * @version 1.0
+ */
+
+public class WordDelimiters 
+{
+       
+       //VARIABLES
+       
+       private TreeSet<String> delimsInUse= new TreeSet<String>();
+       private TreeSet<String> delimsToAdd= new TreeSet<String>();
+       private TreeSet<String> userDelims= new TreeSet<String>();
+       
+       private HashMap<String, String> regexTranslation = new HashMap<String, 
String>();
+       
+       //String Delimeters
+       private static final String DELIMITER = "SAVEDELIMITER";
+       private static final String FIRSTDELIMITER = "NewLineEquivalent";
+       private static final String SECONDDELIMITER = "TabbedEquivalent";
+       
+       //CONSTRUCTORS
+       
+       /**
+        * Creates the default WordDelimiters object.
+        */
+       public WordDelimiters()
+       {
+               delimsInUse.add("tab");
+               delimsInUse.add("space");
+               delimsInUse.add("newline");
+               delimsInUse.add("carriage return");
+               delimsInUse.add("form feed");
+               delimsInUse.add("!");
+               delimsInUse.add("\"");
+               delimsInUse.add("#");
+               delimsInUse.add("$");
+               delimsInUse.add("%");
+               delimsInUse.add("&");
+               delimsInUse.add("(");
+               delimsInUse.add(")");
+               delimsInUse.add("*");
+               delimsInUse.add("+");
+               delimsInUse.add(",");
+               delimsInUse.add(".");
+               delimsInUse.add("/");
+               delimsInUse.add(":");
+               delimsInUse.add(";");
+               delimsInUse.add("<");
+               delimsInUse.add("=");
+               delimsInUse.add(">");
+               delimsInUse.add("?");
+               delimsInUse.add("@");
+               delimsInUse.add("[");
+               delimsInUse.add("\\");
+               delimsInUse.add("]");
+               delimsInUse.add("^");
+               delimsInUse.add("_");
+               delimsInUse.add("`");
+               delimsInUse.add("{");
+               delimsInUse.add("|");
+               delimsInUse.add("}");
+               delimsInUse.add("~");
+               
+               delimsToAdd.add("-");
+               delimsToAdd.add("'");
+               
+               regexTranslation.put("tab", "\\t");
+               regexTranslation.put("space", " ");
+               regexTranslation.put("newline", "\\n");
+               regexTranslation.put("carriage return", "\\r");
+               regexTranslation.put("form feed", "\\f");
+               regexTranslation.put("!","!");
+               regexTranslation.put("\"", "\" ");
+               regexTranslation.put("#", "#");
+               regexTranslation.put("$", "$");
+               regexTranslation.put("%", "%");
+               regexTranslation.put("&", "&");
+               regexTranslation.put("(", "(");
+               regexTranslation.put(")", ")");
+               regexTranslation.put("*", "*");
+               regexTranslation.put("+", "+");
+               regexTranslation.put(",", ",");
+               regexTranslation.put(".", ".");
+               regexTranslation.put("/", "/");
+               regexTranslation.put(":", ":");
+               regexTranslation.put(";", ";");
+               regexTranslation.put("<", "<");
+               regexTranslation.put("=", "=");
+               regexTranslation.put(">", ">");
+               regexTranslation.put("?", "?");
+               regexTranslation.put("@", "@");
+               regexTranslation.put("[", "\\[");
+               regexTranslation.put("\\", "\\\\");
+               regexTranslation.put("]", "\\]");
+               regexTranslation.put("^", "\\^");
+               regexTranslation.put("_", "_");
+               regexTranslation.put("`", "`");
+               regexTranslation.put("{", "{");
+               regexTranslation.put("|", "|");
+               regexTranslation.put("}", "}");
+               regexTranslation.put("~", "~");
+               regexTranslation.put("-", "\\-");
+               regexTranslation.put("'", "'");
+       }
+       
+       
+       /**
+        * Constructor to create WordDelimiters from a cytoscape property file
+        * while restoring a session.  Property file is created when the 
session is saved.
+        * @param propFile - the contents of the property file as a String
+        */
+       public WordDelimiters(String propFile)
+       {
+               //Initialize to be backwards compatible
+               this();
+               
+               //Create a hashmap to contain all the values in the rpt file
+               HashMap<String, String> props = new HashMap<String,String>();
+               
+               String[] lines = propFile.split(FIRSTDELIMITER);
+               
+               for (int i = 0; i < lines.length; i++)
+               {
+                       String line = lines[i];
+                       String[] tokens = line.split(SECONDDELIMITER);
+                       //there should be two values in each line
+                       if(tokens.length == 2)
+                               props.put(tokens[0],tokens[1]);
+               }
+               
+               //Check if this is new version, clear out initialization
+               if ((props.get("DelimsInUse") != null) || 
(props.get("DelimsToAdd") != null))
+               {
+                       delimsInUse = new TreeSet<String>();
+                       delimsToAdd = new TreeSet<String>();
+               }
+               
+               //Rebuild inUse List
+               String value = props.get("DelimsInUse");
+               if (value != null)
+               {
+                       String[] delims = value.split(DELIMITER);
+                       for (int i = 0; i < delims.length; i++)
+                       {
+                               String curDelim = delims[i];
+                               delimsInUse.add(curDelim);
+                       }
+               }
+               
+               //Rebuild toAdd List
+               value = props.get("DelimsToAdd");
+               if (value != null)
+               {
+                       String[] delims = value.split(DELIMITER);
+                       for (int i = 0; i < delims.length; i++)
+                       {
+                               String curDelim = delims[i];
+                               delimsToAdd.add(curDelim);
+                       }
+               }
+               
+               
+               //Rebuild added List
+               value = props.get("AddedDelims");
+               if (value != null)
+               {
+                       String[] delims = value.split(DELIMITER);
+                       for (int i = 0; i < delims.length; i++)
+                       {
+                               String curDelim = delims[i];
+                               userDelims.add(curDelim);
+                       }
+               }
+       }
+       
+       
+       /**
+        * Creates a String representation of all words currently in this 
+        * WordDelimiters used for saving sessions.
+        * 
+        * @return String - list of words in this WordDelimiter used for 
restoring.
+        */
+       
+       public String toString()
+       {
+               StringBuffer delimVariables = new StringBuffer();
+               
+               //List of inUse words as a delimited list
+               StringBuffer output = new StringBuffer();
+               if (delimsInUse.size()> 0)
+               {
+                       for (Iterator<String> iter = delimsInUse.iterator(); 
iter.hasNext();)
+                       {
+                               String curDelim = iter.next();
+                               output.append(curDelim + DELIMITER);
+                       }
+                       delimVariables.append("DelimsInUse" + SECONDDELIMITER + 
output.toString() + FIRSTDELIMITER);
+               }
+               
+               //List of toAdd words as a delimeted list
+               output = new StringBuffer();
+               if (delimsToAdd.size()> 0)
+               {
+                       for (Iterator<String> iter = delimsToAdd.iterator(); 
iter.hasNext();)
+                       {
+                               String curWord = iter.next();
+                               output.append(curWord + DELIMITER);
+                       }
+                       delimVariables.append("DelimsToAdd" + SECONDDELIMITER + 
output.toString() + FIRSTDELIMITER);
+               }
+               
+               //List of added delimiters as a delimeted list
+               output = new StringBuffer();
+               if (userDelims.size()>0)
+               {
+                       for (Iterator<String> iter = userDelims.iterator(); 
iter.hasNext();)
+                       {
+                               String curWord = iter.next();
+                               output.append(curWord + DELIMITER);
+                       }
+                       delimVariables.append("AddedDelims" + SECONDDELIMITER + 
output.toString() + FIRSTDELIMITER);
+               }
+               
+               return delimVariables.toString();
+       }
+       
+       /**
+        * Returns a String regular expression for all the delimiters currently 
in use.
+        * @return String regex of all delimiters
+        */
+       public String getRegex()
+       {
+               String reg = "";
+               
+               for (Iterator<String> iter = delimsInUse.iterator(); 
iter.hasNext();)
+               {
+                       String curDelim = iter.next();
+                       String addDelim = this.translateToRegex(curDelim);
+                       
+                       reg = reg + addDelim;
+               }//end for loop
+               
+               String regEx = "[" + reg + "]";
+               
+               return regEx;
+       }
+       
+       /**
+        * Adds the specified delimiter into use if it is not currently in use.
+        */
+       public void addDelimToUse(String delim)
+       {
+               //If it is one of the defined delims
+               if (delimsToAdd.contains(delim))
+               {
+                       delimsToAdd.remove(delim);
+                       delimsInUse.add(delim);
+               }
+               //Add to user list
+               else
+               {
+                       if (!userDelims.contains(delim))
+                               userDelims.add(delim);
+               }
+       }
+       
+       /**
+        * Removes the specified delimiter from use if it is currently in use.
+        */
+       public void removeDelimiter(String delim)
+       {
+               //First check user delims
+               if (userDelims.contains(delim))
+               {
+                       userDelims.remove(delim);
+               }
+               else  if (delimsInUse.contains(delim))
+               {
+                       delimsInUse.remove(delim);
+                       delimsToAdd.add(delim);
+               }
+       }
+       
+       /**
+        * Retrieves the regex translation of the given string or null if the 
string is bad
+        */
+       public String translateToRegex(String val)
+       {
+               if (regexTranslation.containsKey(val))
+                       return regexTranslation.get(val);
+               else
+                       return null;
+       }
+       
+       
+       //Getters and Setters
+       
+       public TreeSet<String> getDelimsInUse()
+       {
+               return delimsInUse;
+       }
+       
+       public TreeSet<String> getDelimsToAdd()
+       {
+               return delimsToAdd;
+       }
+       
+       public TreeSet<String> getUserDelims()
+       {
+               return userDelims;
+       }
+       
+       public HashMap<String,String> getRegExTranslation()
+       {
+               return regexTranslation;
+       }
+       
+}

-- 
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