/[svn]/jsampler/trunk/src/org/jsampler/view/std/StdUtils.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/std/StdUtils.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1785 by iliev, Thu Dec 6 19:37:41 2007 UTC revision 1786 by iliev, Wed Oct 8 22:38:15 2008 UTC
# Line 22  Line 22 
22  package org.jsampler.view.std;  package org.jsampler.view.std;
23    
24  import java.awt.Desktop;  import java.awt.Desktop;
25    import java.awt.Rectangle;
26    
27  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
28  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
# Line 36  import java.net.URI; Line 37  import java.net.URI;
37  import java.text.NumberFormat;  import java.text.NumberFormat;
38    
39  import java.util.Vector;  import java.util.Vector;
40    import java.util.logging.Level;
41    
42  import javax.swing.JComboBox;  import javax.swing.JComboBox;
43  import javax.swing.JSlider;  import javax.swing.JSlider;
# Line 132  public class StdUtils { Line 134  public class StdUtils {
134                  catch(Exception x) { x.printStackTrace(); }                  catch(Exception x) { x.printStackTrace(); }
135          }          }
136                    
137            /**
138             * Gets the windows bounds from the preferences for the specified window.
139             * @return The windows bounds saved in the preferences for the specified window
140             * or <code>null</code>.
141             */
142            public static Rectangle
143            getWindowBounds(String windowName) {
144                    String s = windowName + ".windowSizeAndLocation";
145                    s = CC.preferences().getStringProperty(s, null);
146                    if(s == null) return null;
147                    
148                    try {
149                            int i = s.indexOf(',');
150                            int x = Integer.parseInt(s.substring(0, i));
151                            
152                            s = s.substring(i + 1);
153                            i = s.indexOf(',');
154                            int y = Integer.parseInt(s.substring(0, i));
155                            
156                            s = s.substring(i + 1);
157                            i = s.indexOf(',');
158                            int width = Integer.parseInt(s.substring(0, i));
159                            
160                            s = s.substring(i + 1);
161                            int height = Integer.parseInt(s);
162                            
163                            return new Rectangle(x, y, width, height);
164                    } catch(Exception x) {
165                            String msg = windowName;
166                            msg += ": Parsing of window size and location string failed";
167                            CC.getLogger().log(Level.INFO, msg, x);
168                            return null;
169                    }
170            }
171            
172            /**
173             * Saves the windows bounds in the preferences for the specified window.
174             */
175            public static void
176            saveWindowBounds(String windowName, Rectangle r) {
177                    StringBuffer sb = new StringBuffer();
178                    sb.append(r.x).append(',').append(r.y).append(',');
179                    sb.append(r.width).append(',').append(r.height);
180                    String s = windowName + ".windowSizeAndLocation";
181                    CC.preferences().setStringProperty(s, sb.toString());
182            }
183            
184          public static JSlider          public static JSlider
185          createVolumeSlider() {          createVolumeSlider() {
186                  return new VolumeSlider();                  return new VolumeSlider();

Legend:
Removed from v.1785  
changed lines
  Added in v.1786

  ViewVC Help
Powered by ViewVC