| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
package org.fest.swing.core; |
| 16 |
|
|
| 17 |
|
import static javax.swing.SwingUtilities.convertRectangle; |
| 18 |
|
import static org.fest.swing.edt.GuiActionRunner.execute; |
| 19 |
|
|
| 20 |
|
import java.awt.Component; |
| 21 |
|
import java.awt.Container; |
| 22 |
|
import java.awt.Rectangle; |
| 23 |
|
|
| 24 |
|
import javax.swing.JComponent; |
| 25 |
|
import javax.swing.JInternalFrame; |
| 26 |
|
import javax.swing.JViewport; |
| 27 |
|
|
| 28 |
|
import org.fest.swing.edt.GuiTask; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
@author |
| 34 |
|
|
| 35 |
|
@since |
| 36 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 10 |
Complexity Density: 0.56 |
|
| 37 |
|
public final class Scrolling { |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
@link |
| 41 |
|
@param |
| 42 |
|
@param |
| 43 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 44 |
106
|
public static void scrollToVisible(Robot robot, JComponent c) {... |
| 45 |
106
|
JComponent root = findClosestValidatingRootAncestor(c); |
| 46 |
|
|
| 47 |
205
|
while (root != null) { |
| 48 |
99
|
scrollToVisible(robot, root, c); |
| 49 |
|
|
| 50 |
99
|
root = findClosestValidatingRootAncestor(root); |
| 51 |
|
} |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
@param |
| 57 |
|
@return |
| 58 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
| 59 |
205
|
private static JComponent findClosestValidatingRootAncestor(JComponent c) {... |
| 60 |
|
|
| 61 |
205
|
Container root = c; |
| 62 |
|
|
| 63 |
960
|
while (root != null) { |
| 64 |
854
|
Container parent = root.getParent(); |
| 65 |
|
|
| 66 |
854
|
root = parent; |
| 67 |
|
|
| 68 |
228
|
if (!(root instanceof JComponent)) continue; |
| 69 |
|
|
| 70 |
99
|
if (root instanceof JViewport || root instanceof JInternalFrame) return (JComponent) root; |
| 71 |
|
} |
| 72 |
106
|
return null; |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
@param |
| 78 |
|
@param |
| 79 |
|
@param |
| 80 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 81 |
99
|
private static void scrollToVisible(Robot robot, JComponent container, Component target) {... |
| 82 |
99
|
Rectangle r = convertRectangle(target.getParent(), target.getBounds(), container); |
| 83 |
99
|
scrollToVisible(robot, container, r); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
@param |
| 89 |
|
@param |
| 90 |
|
@param |
| 91 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 92 |
99
|
private static void scrollToVisible(Robot robot, final JComponent c, final Rectangle rectangle) {... |
| 93 |
99
|
execute(new GuiTask() { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 94 |
99
|
protected void executeInEDT() {... |
| 95 |
99
|
c.scrollRectToVisible(rectangle); |
| 96 |
|
} |
| 97 |
|
}); |
| 98 |
99
|
robot.waitForIdle(); |
| 99 |
|
} |
| 100 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 101 |
|
private Scrolling() {}... |
| 102 |
|
} |