Author: kono
Date: 2010-08-04 11:23:02 -0700 (Wed, 04 Aug 2010)
New Revision: 21191

Added:
   
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoStatusBarImpl.java
Removed:
   
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoStatusBarImpl.java
Modified:
   
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoscapeDesktop.java
Log:
Comments are added to the classes.  These two are the cause of cyclic 
dependency.  We need to move this to log-swing module.

Deleted: 
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoStatusBarImpl.java
===================================================================
--- 
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoStatusBarImpl.java
   2010-08-04 18:21:56 UTC (rev 21190)
+++ 
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoStatusBarImpl.java
   2010-08-04 18:23:02 UTC (rev 21191)
@@ -1,175 +0,0 @@
-package cytoscape.internal.view;
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.border.*;
-
-import org.cytoscape.log.statusbar.CytoStatusBar;
-
-/**
- * @author Pasteur
- */
-class CytoStatusBarImpl implements CytoStatusBar
-{
-       JPanel          panel;
-       JButton         statusMessage;
-       JProgressBar    memoryAvailable;
-       JButton         performGC;
-       Timer           updateUITimer;
-
-       long            timeSinceLastMessage = 0;
-       String          lastMessage = null;
-
-       public CytoStatusBarImpl(int uiUpdateDelay, String trashIconPath)
-       {
-               statusMessage = new JButton();
-               statusMessage.setCursor(new Cursor(Cursor.HAND_CURSOR));
-               setFontSize(statusMessage, 9);
-               statusMessage.setToolTipText("Open Console");
-               statusMessage.setBorderPainted(false);
-               statusMessage.setContentAreaFilled(false);
-               statusMessage.setHorizontalTextPosition(SwingConstants.RIGHT);
-               statusMessage.setHorizontalAlignment(SwingConstants.LEFT);
-
-               memoryAvailable = new JProgressBar();
-               memoryAvailable.setToolTipText("Amount of memory available to 
Cytoscape");
-               memoryAvailable.setStringPainted(true);
-               setFontSize(memoryAvailable, 8);
-               updateMemoryAvailable();
-
-               performGC = new JButton(new 
ImageIcon(getClass().getResource(trashIconPath)));
-               performGC.setToolTipText("Try to get more memory by performing 
garbage collection");
-               performGC.setBorderPainted(false);
-               performGC.setContentAreaFilled(false);
-               performGC.addActionListener(new PerformGCAction());
-
-               updateUITimer = new Timer(uiUpdateDelay, new UpdateUIAction());
-               updateUITimer.start();
-
-               panel = new JPanel(new GridBagLayout());
-               JPanel panel1 = new JPanel(new GridBagLayout());
-               panel1.setBorder(new EtchedBorder());
-               panel1.add(statusMessage, new GridBagConstraints(0, 0, 1, 1, 
1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 
0, 0), 0, 0));
-               panel.add(panel1, new GridBagConstraints(0, 0, 1, 1, 1, 1, 
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 3, 2, 1), 0, 
0));
-               JPanel panel2 = new JPanel(new GridBagLayout());
-               panel2.setBorder(new EtchedBorder());
-               JPanel panel3 = new JPanel(new GridBagLayout());
-               panel3.add(memoryAvailable, new GridBagConstraints(0, 0, 1, 1, 
0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 
0), 0, 0));
-               panel3.add(performGC, new GridBagConstraints(1, 0, 1, 1, 0, 0, 
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 
0));
-               panel2.add(panel3, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, 
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 
0));
-               panel.add(panel2, new GridBagConstraints(1, 0, 1, 1, 0, 1, 
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 1, 2, 2), 0, 
0));
-       }
-
-       public JPanel getPanel()
-       {
-               return panel;
-       }
-
-       static void setFontSize(Component component, int size)
-       {
-               Font font = component.getFont();
-               component.setFont(new Font(font.getFontName(), font.getStyle(), 
size));
-       }
-
-       public void setMessage(String message, Icon icon)
-       {
-               statusMessage.setIcon(icon);
-               lastMessage = message;
-               timeSinceLastMessage = System.currentTimeMillis();
-               updateStatusMessage();
-       }
-
-       public void addActionListener(ActionListener actionListener)
-       {
-               statusMessage.addActionListener(actionListener);
-       }
-
-       class PerformGCAction implements ActionListener
-       {
-               public void actionPerformed(ActionEvent e)
-               {
-                       performGC.setEnabled(false);
-                       for (int i = 0; i < 5; i++)
-                       {
-                               System.runFinalization();
-                               System.gc();
-                       }
-                       performGC.setEnabled(true);
-               }
-       }
-
-       static final String[] MEMORY_SUFFIXES = { "b", "kb", "Mb", "Gb" };
-       static final double MEMORY_UNIT = 1024.0;
-       static String formatMemory(long freeMemory, long totalMemory)
-       {
-               double free = (double) freeMemory;
-               double total = (double) totalMemory;
-               int suffix = 0;
-               while ((total >= MEMORY_UNIT) && (suffix < 
MEMORY_SUFFIXES.length - 1))
-               {
-                       free /= MEMORY_UNIT;
-                       total /= MEMORY_UNIT;
-                       suffix++;
-               }
-               return String.format("%.2f of %.2f %s", free, total, 
MEMORY_SUFFIXES[suffix]);
-       }
-
-       static String formatTime(long totalMilliseconds)
-       {
-               long totalSeconds = totalMilliseconds / 1000;
-               if (totalSeconds < 60)
-                       return formatTimeUnit(totalSeconds, "second");
-
-               long totalMinutes = totalSeconds / 60;
-               if (totalMinutes < 60)
-                       return formatTimeUnit(totalMinutes, "minute");
-
-               long hours = totalMinutes / 60;
-               long minutes = totalMinutes % 60;
-
-               if (minutes == 0)
-                       return formatTimeUnit(hours, "hour");
-               else
-                       return formatTimeUnit(hours, "hour") + ", " + 
formatTimeUnit(minutes, "minute");
-       }
-
-       static String formatTimeUnit(long time, String unit)
-       {
-               if (time == 1)
-                       return String.format("%d %s", time, unit);
-               else
-                       return String.format("%d %ss", time, unit);
-       }
-
-       void updateStatusMessage()
-       {
-               if (lastMessage == null)
-               {
-                       statusMessage.setText("");
-               }
-               else
-               {
-                       long delta = System.currentTimeMillis() - 
timeSinceLastMessage;
-                       statusMessage.setText(String.format("%s (%s ago)", 
lastMessage, formatTime(delta))); 
-               }
-       }
-
-       void updateMemoryAvailable()
-       {
-               long free = Runtime.getRuntime().freeMemory();
-               long total = Runtime.getRuntime().totalMemory();
-
-               memoryAvailable.setValue((int) (free * 100 / total));
-               memoryAvailable.setString(formatMemory(free, total));
-       }
-
-       class UpdateUIAction implements ActionListener
-       {
-               public void actionPerformed(ActionEvent e)
-               {
-                       updateStatusMessage();
-                       updateMemoryAvailable();
-               }
-       }
-}

Copied: 
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoStatusBarImpl.java
 (from rev 21185, 
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoStatusBarImpl.java)
===================================================================
--- 
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoStatusBarImpl.java
                           (rev 0)
+++ 
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoStatusBarImpl.java
   2010-08-04 18:23:02 UTC (rev 21191)
@@ -0,0 +1,177 @@
+package cytoscape.internal.view;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.border.*;
+
+import org.cytoscape.log.statusbar.CytoStatusBar;
+
+/**
+ * FIXME: Move this class to log-swing module.  This is a cause of  
dependency. 
+ * 
+ * @author Pasteur
+ */
+class CytoStatusBarImpl implements CytoStatusBar
+{
+       JPanel          panel;
+       JButton         statusMessage;
+       JProgressBar    memoryAvailable;
+       JButton         performGC;
+       Timer           updateUITimer;
+
+       long            timeSinceLastMessage = 0;
+       String          lastMessage = null;
+
+       public CytoStatusBarImpl(int uiUpdateDelay, String trashIconPath)
+       {
+               statusMessage = new JButton();
+               statusMessage.setCursor(new Cursor(Cursor.HAND_CURSOR));
+               setFontSize(statusMessage, 9);
+               statusMessage.setToolTipText("Open Console");
+               statusMessage.setBorderPainted(false);
+               statusMessage.setContentAreaFilled(false);
+               statusMessage.setHorizontalTextPosition(SwingConstants.RIGHT);
+               statusMessage.setHorizontalAlignment(SwingConstants.LEFT);
+
+               memoryAvailable = new JProgressBar();
+               memoryAvailable.setToolTipText("Amount of memory available to 
Cytoscape");
+               memoryAvailable.setStringPainted(true);
+               setFontSize(memoryAvailable, 8);
+               updateMemoryAvailable();
+
+               performGC = new JButton(new 
ImageIcon(getClass().getResource(trashIconPath)));
+               performGC.setToolTipText("Try to get more memory by performing 
garbage collection");
+               performGC.setBorderPainted(false);
+               performGC.setContentAreaFilled(false);
+               performGC.addActionListener(new PerformGCAction());
+
+               updateUITimer = new Timer(uiUpdateDelay, new UpdateUIAction());
+               updateUITimer.start();
+
+               panel = new JPanel(new GridBagLayout());
+               JPanel panel1 = new JPanel(new GridBagLayout());
+               panel1.setBorder(new EtchedBorder());
+               panel1.add(statusMessage, new GridBagConstraints(0, 0, 1, 1, 
1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 
0, 0), 0, 0));
+               panel.add(panel1, new GridBagConstraints(0, 0, 1, 1, 1, 1, 
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 3, 2, 1), 0, 
0));
+               JPanel panel2 = new JPanel(new GridBagLayout());
+               panel2.setBorder(new EtchedBorder());
+               JPanel panel3 = new JPanel(new GridBagLayout());
+               panel3.add(memoryAvailable, new GridBagConstraints(0, 0, 1, 1, 
0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 
0), 0, 0));
+               panel3.add(performGC, new GridBagConstraints(1, 0, 1, 1, 0, 0, 
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 
0));
+               panel2.add(panel3, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, 
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 
0));
+               panel.add(panel2, new GridBagConstraints(1, 0, 1, 1, 0, 1, 
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 1, 2, 2), 0, 
0));
+       }
+
+       public JPanel getPanel()
+       {
+               return panel;
+       }
+
+       static void setFontSize(Component component, int size)
+       {
+               Font font = component.getFont();
+               component.setFont(new Font(font.getFontName(), font.getStyle(), 
size));
+       }
+
+       public void setMessage(String message, Icon icon)
+       {
+               statusMessage.setIcon(icon);
+               lastMessage = message;
+               timeSinceLastMessage = System.currentTimeMillis();
+               updateStatusMessage();
+       }
+
+       public void addActionListener(ActionListener actionListener)
+       {
+               statusMessage.addActionListener(actionListener);
+       }
+
+       class PerformGCAction implements ActionListener
+       {
+               public void actionPerformed(ActionEvent e)
+               {
+                       performGC.setEnabled(false);
+                       for (int i = 0; i < 5; i++)
+                       {
+                               System.runFinalization();
+                               System.gc();
+                       }
+                       performGC.setEnabled(true);
+               }
+       }
+
+       static final String[] MEMORY_SUFFIXES = { "b", "kb", "Mb", "Gb" };
+       static final double MEMORY_UNIT = 1024.0;
+       static String formatMemory(long freeMemory, long totalMemory)
+       {
+               double free = (double) freeMemory;
+               double total = (double) totalMemory;
+               int suffix = 0;
+               while ((total >= MEMORY_UNIT) && (suffix < 
MEMORY_SUFFIXES.length - 1))
+               {
+                       free /= MEMORY_UNIT;
+                       total /= MEMORY_UNIT;
+                       suffix++;
+               }
+               return String.format("%.2f of %.2f %s", free, total, 
MEMORY_SUFFIXES[suffix]);
+       }
+
+       static String formatTime(long totalMilliseconds)
+       {
+               long totalSeconds = totalMilliseconds / 1000;
+               if (totalSeconds < 60)
+                       return formatTimeUnit(totalSeconds, "second");
+
+               long totalMinutes = totalSeconds / 60;
+               if (totalMinutes < 60)
+                       return formatTimeUnit(totalMinutes, "minute");
+
+               long hours = totalMinutes / 60;
+               long minutes = totalMinutes % 60;
+
+               if (minutes == 0)
+                       return formatTimeUnit(hours, "hour");
+               else
+                       return formatTimeUnit(hours, "hour") + ", " + 
formatTimeUnit(minutes, "minute");
+       }
+
+       static String formatTimeUnit(long time, String unit)
+       {
+               if (time == 1)
+                       return String.format("%d %s", time, unit);
+               else
+                       return String.format("%d %ss", time, unit);
+       }
+
+       void updateStatusMessage()
+       {
+               if (lastMessage == null)
+               {
+                       statusMessage.setText("");
+               }
+               else
+               {
+                       long delta = System.currentTimeMillis() - 
timeSinceLastMessage;
+                       statusMessage.setText(String.format("%s (%s ago)", 
lastMessage, formatTime(delta))); 
+               }
+       }
+
+       void updateMemoryAvailable()
+       {
+               long free = Runtime.getRuntime().freeMemory();
+               long total = Runtime.getRuntime().totalMemory();
+
+               memoryAvailable.setValue((int) (free * 100 / total));
+               memoryAvailable.setString(formatMemory(free, total));
+       }
+
+       class UpdateUIAction implements ActionListener
+       {
+               public void actionPerformed(ActionEvent e)
+               {
+                       updateStatusMessage();
+                       updateMemoryAvailable();
+               }
+       }
+}

Modified: 
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoscapeDesktop.java
===================================================================
--- 
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoscapeDesktop.java
    2010-08-04 18:21:56 UTC (rev 21190)
+++ 
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoscapeDesktop.java
    2010-08-04 18:23:02 UTC (rev 21191)
@@ -37,7 +37,6 @@
 package cytoscape.internal.view;
 
 import java.awt.BorderLayout;
-import java.awt.Color;
 import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.Toolkit;
@@ -46,22 +45,17 @@
 
 import javax.swing.ImageIcon;
 import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JSplitPane;
 import javax.swing.JTabbedPane;
 import javax.swing.SwingConstants;
 import javax.swing.WindowConstants;
-import javax.swing.border.EmptyBorder;
 
 import cytoscape.CytoscapeShutdown;
-import org.cytoscape.session.CyNetworkManager;
-
+import cytoscape.view.CyMenus;
+import cytoscape.view.CySwingApplication;
 import cytoscape.view.CytoPanel;
 import cytoscape.view.CytoPanelState;
-import cytoscape.view.CySwingApplication;
-import cytoscape.view.CyMenus;
 
 
 
@@ -107,7 +101,7 @@
        protected CytoPanelImp cytoPanelSouth;
        protected CytoPanelImp cytoPanelSouthWest; 
 
-       // Status Bar
+       // Status Bar TODO: Move this to log-swing to avoid cyclic dependency.
        protected CytoStatusBarImpl statusBar;
        protected JPanel main_panel;
        private final CytoscapeShutdown shutdown; 

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