Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart8.png 93% of files have more coverage
16   90   7   5.33
8   32   0.44   3
3     2.33  
1    
3.6% of code in this file is excluded from these metrics.
 
  WindowLikeContainerLocations       Line # 29 16 3.6% 7 6 77.8% 0.7777778
 
No Tests
 
1    /*
2    * Created on Nov 8, 2008
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10    * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11    * or implied. See the License for the specific language governing permissions and limitations under
12    * the License.
13    *
14    * Copyright @2008-2010 the original author or authors.
15    */
16    package org.fest.swing.driver;
17   
18    import static org.fest.swing.util.Platform.*;
19   
20    import java.awt.*;
21   
22    import org.fest.swing.annotation.RunsInCurrentThread;
23   
24    /**
25    * Understands locations of the control buttons in a window-like container.
26    *
27    * @author Alex Ruiz
28    */
 
29    final class WindowLikeContainerLocations {
30   
31    private static final int MAXIMIZE_BUTTON_OFFSET = isOSX() ? 25 : isWindows() ? -20 : 0;
32   
33    /**
34    * Identifies the coordinates of the 'close' button.
35    * <p>
36    * <b>Note:</b> This method is <b>not</b> executed in the event dispatch thread (EDT.) Clients are responsible for
37    * invoking this method in the EDT.
38    * </p>
39    * @param c the target window-like <code>Container</code>.
40    * @return the coordinates of the 'close' button.
41    */
 
42  2 toggle @RunsInCurrentThread
43    static Point closeLocationOf(Container c) {
44  2 Insets insets = c.getInsets();
45  2 if (isOSX()) return new Point(insets.left + 15, insets.top / 2);
46  2 return new Point(c.getWidth() - insets.right - 10, insets.top / 2);
47    }
48   
49    /**
50    * Identifies the coordinates of the 'maximize' button.
51    * <p>
52    * <b>Note:</b> This method is <b>not</b> executed in the event dispatch thread (EDT.) Clients are responsible for
53    * invoking this method in the EDT.
54    * </p>
55    * @param c the target window-like <code>Container</code>.
56    * @return the coordinates of the 'maximize' button.
57    */
 
58  6 toggle @RunsInCurrentThread
59    static Point maximizeLocationOf(Container c) {
60  6 Point p = iconifyLocationOf(c);
61  6 p.x += MAXIMIZE_BUTTON_OFFSET;
62  6 return p;
63    }
64   
65    /**
66    * Identifies the coordinates of the 'iconify' button, returning (0, 0) if not found.
67    * <p>
68    * <b>Note:</b> This method is <b>not</b> executed in the event dispatch thread (EDT.) Clients are responsible for
69    * invoking this method in the EDT.
70    * </p>
71    * @param c the target window-like <code>Container</code>.
72    * @return the coordinates of the 'iconify' button, returning (0, 0) if not found.
73    */
 
74  11 toggle @RunsInCurrentThread
75    static Point iconifyLocationOf(Container c) {
76  11 Insets insets = c.getInsets();
77    // From Abbot: We know the exact layout of the window manager frames for w32 and OSX. Currently no way of detecting
78    // the WM under X11. Maybe we could send a WM message (WM_ICONIFY)?
79  11 Point p = new Point();
80  11 p.y = insets.top / 2;
81  11 if (isOSX()) p.x = 35;
82  11 if (isWindows()) {
83  11 int offset = isWindowsXP() ? 64 : 45;
84  11 p.x = c.getWidth() - insets.right - offset;
85    }
86  11 return p;
87    }
88   
 
89    toggle private WindowLikeContainerLocations() {}
90    }