Source Code Cross Referenced for JScrollPaneOperator.java in  » Testing » jemmy » org » netbeans » jemmy » operators » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » jemmy » org.netbeans.jemmy.operators 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s): Alexandre Iline.
025:         *
026:         * The Original Software is the Jemmy library.
027:         * The Initial Developer of the Original Software is Alexandre Iline.
028:         * All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         *
041:         *
042:         *
043:         * $Id: JScrollPaneOperator.java,v 1.10 2007/10/05 11:35:38 jskrivanek Exp $ $Revision: 1.10 $ $Date: 2007/10/05 11:35:38 $
044:         *
045:         */
046:
047:        package org.netbeans.jemmy.operators;
048:
049:        import org.netbeans.jemmy.ComponentSearcher;
050:        import org.netbeans.jemmy.ComponentChooser;
051:        import org.netbeans.jemmy.Outputable;
052:        import org.netbeans.jemmy.TestOut;
053:        import org.netbeans.jemmy.Timeoutable;
054:        import org.netbeans.jemmy.TimeoutExpiredException;
055:        import org.netbeans.jemmy.Timeouts;
056:
057:        import org.netbeans.jemmy.util.EmptyVisualizer;
058:
059:        import org.netbeans.jemmy.drivers.scrolling.ScrollAdjuster;
060:
061:        import java.awt.Component;
062:        import java.awt.Container;
063:        import java.awt.Point;
064:        import java.awt.Rectangle;
065:
066:        import javax.swing.JScrollPane;
067:        import javax.swing.JScrollBar;
068:        import javax.swing.JViewport;
069:        import javax.swing.SwingUtilities;
070:
071:        import javax.swing.border.Border;
072:
073:        import javax.swing.plaf.ScrollPaneUI;
074:
075:        /**
076:         * <BR><BR>Timeouts used: <BR>
077:         * JScrollBarOperator.OneScrollClickTimeout - time for one scroll click <BR>
078:         * JScrollBarOperator.WholeScrollTimeout - time for the whole scrolling <BR>
079:         * ComponentOperator.WaitComponentTimeout - time to wait component displayed <BR>.
080:         *
081:         * @see org.netbeans.jemmy.Timeouts
082:         *
083:         * @author Alexandre Iline (alexandre.iline@sun.com)
084:         *	
085:         */
086:
087:        public class JScrollPaneOperator extends JComponentOperator implements 
088:                Timeoutable, Outputable {
089:
090:            private static int X_POINT_RECT_SIZE = 6;
091:            private static int Y_POINT_RECT_SIZE = 4;
092:
093:            private Timeouts timeouts;
094:            private TestOut output;
095:            private JScrollBarOperator hScrollBarOper = null;
096:            private JScrollBarOperator vScrollBarOper = null;
097:
098:            /**
099:             * Constructor.
100:             * @param b JScrollPane component.
101:             */
102:            public JScrollPaneOperator(JScrollPane b) {
103:                super (b);
104:            }
105:
106:            /**
107:             * Constructs a JScrollPaneOperator object.
108:             * @param cont a container
109:             * @param chooser a component chooser specifying searching criteria.
110:             * @param index an index between appropriate ones.
111:             */
112:            public JScrollPaneOperator(ContainerOperator cont,
113:                    ComponentChooser chooser, int index) {
114:                this ((JScrollPane) cont.waitSubComponent(new JScrollPaneFinder(
115:                        chooser), index));
116:                copyEnvironment(cont);
117:            }
118:
119:            /**
120:             * Constructs a JScrollPaneOperator object.
121:             * @param cont a container
122:             * @param chooser a component chooser specifying searching criteria.
123:             */
124:            public JScrollPaneOperator(ContainerOperator cont,
125:                    ComponentChooser chooser) {
126:                this (cont, chooser, 0);
127:            }
128:
129:            /**
130:             * Constructor.
131:             * Waits component in container first.
132:             * Uses cont's timeout and output for waiting and to init operator.
133:             * @param cont Operator pointing a container to search component in.
134:             * @param index Ordinal component index.
135:             * @throws TimeoutExpiredException
136:             */
137:            public JScrollPaneOperator(ContainerOperator cont, int index) {
138:                this ((JScrollPane) waitComponent(cont, new JScrollPaneFinder(),
139:                        index));
140:                copyEnvironment(cont);
141:            }
142:
143:            /**
144:             * Constructor.
145:             * Waits component in container first.
146:             * Uses cont's timeout and output for waiting and to init operator.
147:             * @param cont Operator pointing a container to search component in.
148:             * @throws TimeoutExpiredException
149:             */
150:            public JScrollPaneOperator(ContainerOperator cont) {
151:                this (cont, 0);
152:            }
153:
154:            /**
155:             * Searches JScrollPane in container.
156:             * @param cont Container to search component in.
157:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
158:             * @param index Ordinal component index.
159:             * @return JScrollPane instance or null if component was not found.
160:             */
161:            public static JScrollPane findJScrollPane(Container cont,
162:                    ComponentChooser chooser, int index) {
163:                return ((JScrollPane) findComponent(cont,
164:                        new JScrollPaneFinder(chooser), index));
165:            }
166:
167:            /**
168:             * Searches 0'th JScrollPane in container.
169:             * @param cont Container to search component in.
170:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
171:             * @return JScrollPane instance or null if component was not found.
172:             */
173:            public static JScrollPane findJScrollPane(Container cont,
174:                    ComponentChooser chooser) {
175:                return (findJScrollPane(cont, chooser, 0));
176:            }
177:
178:            /**
179:             * Searches JScrollPane in container.
180:             * @param cont Container to search component in.
181:             * @param index Ordinal component index.
182:             * @return JScrollPane instance or null if component was not found.
183:             */
184:            public static JScrollPane findJScrollPane(Container cont, int index) {
185:                return (findJScrollPane(cont, ComponentSearcher
186:                        .getTrueChooser(Integer.toString(index)
187:                                + "'th JScrollPane instance"), index));
188:            }
189:
190:            /**
191:             * Searches 0'th JScrollPane in container.
192:             * @param cont Container to search component in.
193:             * @return JScrollPane instance or null if component was not found.
194:             */
195:            public static JScrollPane findJScrollPane(Container cont) {
196:                return (findJScrollPane(cont, 0));
197:            }
198:
199:            /**
200:             * Searches JScrollPane object which component lies on.
201:             * @param comp Component to find JScrollPane under.
202:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
203:             * @return JScrollPane instance or null if component was not found.
204:             */
205:            public static JScrollPane findJScrollPaneUnder(Component comp,
206:                    ComponentChooser chooser) {
207:                return ((JScrollPane) findContainerUnder(comp,
208:                        new JScrollPaneFinder(chooser)));
209:            }
210:
211:            /**
212:             * Searches JScrollPane object which component lies on.
213:             * @param comp Component to find JScrollPane under.
214:             * @return JScrollPane instance or null if component was not found.
215:             */
216:            public static JScrollPane findJScrollPaneUnder(Component comp) {
217:                return (findJScrollPaneUnder(comp, new JScrollPaneFinder()));
218:            }
219:
220:            /**
221:             * Waits JScrollPane in container.
222:             * @param cont Container to search component in.
223:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
224:             * @param index Ordinal component index.
225:             * @return JScrollPane instance or null if component was not displayed.
226:             * @throws TimeoutExpiredException
227:             */
228:            public static JScrollPane waitJScrollPane(Container cont,
229:                    ComponentChooser chooser, int index) {
230:                return ((JScrollPane) waitComponent(cont,
231:                        new JScrollPaneFinder(chooser), index));
232:            }
233:
234:            /**
235:             * Waits 0'th JScrollPane in container.
236:             * @param cont Container to search component in.
237:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
238:             * @return JScrollPane instance or null if component was not displayed.
239:             * @throws TimeoutExpiredException
240:             */
241:            public static JScrollPane waitJScrollPane(Container cont,
242:                    ComponentChooser chooser) {
243:                return (waitJScrollPane(cont, chooser, 0));
244:            }
245:
246:            /**
247:             * Waits JScrollPane in container.
248:             * @param cont Container to search component in.
249:             * @param index Ordinal component index.
250:             * @return JScrollPane instance or null if component was not displayed.
251:             * @throws TimeoutExpiredException
252:             */
253:            public static JScrollPane waitJScrollPane(Container cont, int index) {
254:                return (waitJScrollPane(cont, ComponentSearcher
255:                        .getTrueChooser(Integer.toString(index)
256:                                + "'th JScrollPane instance"), index));
257:            }
258:
259:            /**
260:             * Waits 0'th JScrollPane in container.
261:             * @param cont Container to search component in.
262:             * @return JScrollPane instance or null if component was not displayed.
263:             * @throws TimeoutExpiredException
264:             */
265:            public static JScrollPane waitJScrollPane(Container cont) {
266:                return (waitJScrollPane(cont, 0));
267:            }
268:
269:            /**
270:             * Sets values for both JScrollBars.
271:             * @param hValue a value for the horizontal scrollbar.
272:             * @param vValue a value for the vertical scrollbar.
273:             */
274:            public void setValues(int hValue, int vValue) {
275:                initOperators();
276:                hScrollBarOper.setValue(hValue);
277:                vScrollBarOper.setValue(vValue);
278:            }
279:
280:            public void setTimeouts(Timeouts timeouts) {
281:                super .setTimeouts(timeouts);
282:                this .timeouts = timeouts;
283:            }
284:
285:            public Timeouts getTimeouts() {
286:                return (timeouts);
287:            }
288:
289:            public void setOutput(TestOut out) {
290:                output = out;
291:                super .setOutput(output.createErrorOutput());
292:            }
293:
294:            public TestOut getOutput() {
295:                return (output);
296:            }
297:
298:            /**
299:             * Scrolls horizontal scroll bar.
300:             * @param value Value to scroll horizontal scroll bar to.
301:             * @throws TimeoutExpiredException
302:             */
303:            public void scrollToHorizontalValue(int value) {
304:                output.printTrace("Scroll JScrollPane to "
305:                        + Integer.toString(value) + " horizontal value \n"
306:                        + toStringSource());
307:                output.printGolden("Scroll JScrollPane to "
308:                        + Integer.toString(value) + " horizontal value");
309:                initOperators();
310:                makeComponentVisible();
311:                if (hScrollBarOper != null
312:                        && hScrollBarOper.getSource().isVisible()) {
313:                    hScrollBarOper.scrollToValue(value);
314:                }
315:            }
316:
317:            /**
318:             * Scrolls horizontal scroll bar.
319:             * @param proportionalValue Proportional value to scroll horizontal scroll bar to.
320:             * @throws TimeoutExpiredException
321:             */
322:            public void scrollToHorizontalValue(double proportionalValue) {
323:                output.printTrace("Scroll JScrollPane to "
324:                        + Double.toString(proportionalValue)
325:                        + " proportional horizontal value \n"
326:                        + toStringSource());
327:                output.printGolden("Scroll JScrollPane to "
328:                        + Double.toString(proportionalValue)
329:                        + " proportional horizontal value");
330:                initOperators();
331:                makeComponentVisible();
332:                if (hScrollBarOper != null
333:                        && hScrollBarOper.getSource().isVisible()) {
334:                    hScrollBarOper.scrollToValue(proportionalValue);
335:                }
336:            }
337:
338:            /**
339:             * Scrolls vertical scroll bar.
340:             * @param value Value to scroll vertical scroll bar to.
341:             * @throws TimeoutExpiredException
342:             */
343:            public void scrollToVerticalValue(int value) {
344:                output.printTrace("Scroll JScrollPane to "
345:                        + Integer.toString(value) + " vertical value \n"
346:                        + toStringSource());
347:                output.printGolden("Scroll JScrollPane to "
348:                        + Integer.toString(value) + " vertical value");
349:                initOperators();
350:                makeComponentVisible();
351:                if (vScrollBarOper != null
352:                        && vScrollBarOper.getSource().isVisible()) {
353:                    vScrollBarOper.scrollToValue(value);
354:                }
355:            }
356:
357:            /**
358:             * Scrolls vertical scroll bar.
359:             * @param proportionalValue Value to scroll vertical scroll bar to.
360:             * @throws TimeoutExpiredException
361:             */
362:            public void scrollToVerticalValue(double proportionalValue) {
363:                output.printTrace("Scroll JScrollPane to "
364:                        + Double.toString(proportionalValue)
365:                        + " proportional vertical value \n" + toStringSource());
366:                output.printGolden("Scroll JScrollPane to "
367:                        + Double.toString(proportionalValue)
368:                        + " proportional vertical value");
369:                initOperators();
370:                makeComponentVisible();
371:                if (vScrollBarOper != null
372:                        && vScrollBarOper.getSource().isVisible()) {
373:                    vScrollBarOper.scrollToValue(proportionalValue);
374:                }
375:            }
376:
377:            /**
378:             * Scrolls both scroll bars.
379:             * @param valueX Value to scroll horizontal scroll bar to.
380:             * @param valueY Value to scroll vertical scroll bar to.
381:             * @throws TimeoutExpiredException
382:             */
383:            public void scrollToValues(int valueX, int valueY) {
384:                scrollToVerticalValue(valueX);
385:                scrollToHorizontalValue(valueX);
386:            }
387:
388:            /**
389:             * Scrolls both scroll bars.
390:             * @param proportionalValueX Value to scroll horizontal scroll bar to.
391:             * @param proportionalValueY Value to scroll vertical scroll bar to.
392:             * @throws TimeoutExpiredException
393:             */
394:            public void scrollToValues(double proportionalValueX,
395:                    double proportionalValueY) {
396:                scrollToVerticalValue(proportionalValueX);
397:                scrollToHorizontalValue(proportionalValueY);
398:            }
399:
400:            /**
401:             * Scrolls pane to top.
402:             * @throws TimeoutExpiredException
403:             */
404:            public void scrollToTop() {
405:                output.printTrace("Scroll JScrollPane to top\n"
406:                        + toStringSource());
407:                output.printGolden("Scroll JScrollPane to top");
408:                initOperators();
409:                makeComponentVisible();
410:                if (vScrollBarOper != null
411:                        && vScrollBarOper.getSource().isVisible()) {
412:                    vScrollBarOper.scrollToMinimum();
413:                }
414:            }
415:
416:            /**
417:             * Scrolls pane to bottom.
418:             * @throws TimeoutExpiredException
419:             */
420:            public void scrollToBottom() {
421:                output.printTrace("Scroll JScrollPane to bottom\n"
422:                        + toStringSource());
423:                output.printGolden("Scroll JScrollPane to bottom");
424:                initOperators();
425:                makeComponentVisible();
426:                if (vScrollBarOper != null
427:                        && vScrollBarOper.getSource().isVisible()) {
428:                    vScrollBarOper.scrollToMaximum();
429:                }
430:            }
431:
432:            /**
433:             * Scrolls pane to left.
434:             * @throws TimeoutExpiredException
435:             */
436:            public void scrollToLeft() {
437:                output.printTrace("Scroll JScrollPane to left\n"
438:                        + toStringSource());
439:                output.printGolden("Scroll JScrollPane to left");
440:                initOperators();
441:                makeComponentVisible();
442:                if (hScrollBarOper != null
443:                        && hScrollBarOper.getSource().isVisible()) {
444:                    hScrollBarOper.scrollToMinimum();
445:                }
446:            }
447:
448:            /**
449:             * Scrolls pane to right.
450:             * @throws TimeoutExpiredException
451:             */
452:            public void scrollToRight() {
453:                output.printTrace("Scroll JScrollPane to right\n"
454:                        + toStringSource());
455:                output.printGolden("Scroll JScrollPane to right");
456:                initOperators();
457:                makeComponentVisible();
458:                if (hScrollBarOper != null
459:                        && hScrollBarOper.getSource().isVisible()) {
460:                    hScrollBarOper.scrollToMaximum();
461:                }
462:            }
463:
464:            /**
465:             * Scrolls pane to rectangle of a component.
466:             * @param comp a subcomponent defining coordinate system.
467:             * @param x coordinate
468:             * @param y coordinate
469:             * @param width rectangle width
470:             * @param height rectangle height
471:             * @throws TimeoutExpiredException
472:             */
473:            public void scrollToComponentRectangle(Component comp, int x,
474:                    int y, int width, int height) {
475:                initOperators();
476:                makeComponentVisible();
477:                if (hScrollBarOper != null
478:                        && hScrollBarOper.getSource().isVisible()) {
479:                    hScrollBarOper.scrollTo(new ComponentRectChecker(comp, x,
480:                            y, width, height, JScrollBar.HORIZONTAL));
481:                }
482:                if (vScrollBarOper != null
483:                        && vScrollBarOper.getSource().isVisible()) {
484:                    vScrollBarOper.scrollTo(new ComponentRectChecker(comp, x,
485:                            y, width, height, JScrollBar.VERTICAL));
486:                }
487:            }
488:
489:            /**
490:             * Scrolls pane to point.
491:             * @param comp a subcomponent defining coordinate system.
492:             * @param x coordinate
493:             * @param y coordinate
494:             * @throws TimeoutExpiredException
495:             */
496:            public void scrollToComponentPoint(Component comp, int x, int y) {
497:                scrollToComponentRectangle(comp, x - X_POINT_RECT_SIZE, y
498:                        - Y_POINT_RECT_SIZE, 2 * X_POINT_RECT_SIZE,
499:                        2 * Y_POINT_RECT_SIZE);
500:            }
501:
502:            /**
503:             * Scrolls pane to component on this pane.
504:             * Component should lay on the JScrollPane view.
505:             * @param comp Component to scroll to.
506:             * @throws TimeoutExpiredException
507:             */
508:            public void scrollToComponent(final Component comp) {
509:                String componentToString = (String) runMapping(new Operator.MapAction(
510:                        "comp.toString()") {
511:                    public Object map() {
512:                        return comp.toString();
513:                    }
514:                });
515:                output.printTrace("Scroll JScrollPane " + toStringSource()
516:                        + "\nto component " + componentToString);
517:                output.printGolden("Scroll JScrollPane to "
518:                        + comp.getClass().getName() + " component.");
519:                scrollToComponentRectangle(comp, 0, 0, comp.getWidth(), comp
520:                        .getHeight());
521:            }
522:
523:            /**
524:             * Returns operator used for horizontal scrollbar.
525:             * @return an operator for the horizontal scrollbar.
526:             */
527:            public JScrollBarOperator getHScrollBarOperator() {
528:                initOperators();
529:                return (hScrollBarOper);
530:            }
531:
532:            /**
533:             * Returns operator used for vertical scrollbar.
534:             * @return an operator for the vertical scrollbar.
535:             */
536:            public JScrollBarOperator getVScrollBarOperator() {
537:                initOperators();
538:                return (vScrollBarOper);
539:            }
540:
541:            /**
542:             * Checks if component's rectangle is inside view port (no scrolling necessary).
543:             * @param comp a subcomponent defining coordinate system.
544:             * @param x coordinate
545:             * @param y coordinate
546:             * @param width rectangle width
547:             * @param height rectangle height
548:             * @return true if pointed subcomponent rectangle is inside the scrolling area.
549:             */
550:            public boolean checkInside(Component comp, int x, int y, int width,
551:                    int height) {
552:                Component view = getViewport().getView();
553:                Point toPoint = SwingUtilities.convertPoint(comp, x, y,
554:                        getViewport().getView());
555:                initOperators();
556:                if (hScrollBarOper != null
557:                        && hScrollBarOper.getSource().isVisible()) {
558:                    if (toPoint.x < hScrollBarOper.getValue()) {
559:                        return (false);
560:                    }
561:                    if (comp.getWidth() > view.getWidth()) {
562:                        return (toPoint.x > 0);
563:                    } else {
564:                        return (toPoint.x + comp.getWidth() > hScrollBarOper
565:                                .getValue()
566:                                + view.getWidth());
567:                    }
568:                }
569:                if (vScrollBarOper != null
570:                        && vScrollBarOper.getSource().isVisible()) {
571:                    if (toPoint.y < vScrollBarOper.getValue()) {
572:                        return (false);
573:                    }
574:                    if (comp.getHeight() > view.getHeight()) {
575:                        return (toPoint.y > 0);
576:                    } else {
577:                        return (toPoint.y + comp.getHeight() > vScrollBarOper
578:                                .getValue()
579:                                + view.getHeight());
580:                    }
581:                }
582:                return (true);
583:            }
584:
585:            /**
586:             * Checks if component is inside view port (no scrolling necessary).
587:             * @param comp a subcomponent
588:             * @return true if pointed subcomponent is inside the scrolling area.
589:             */
590:            public boolean checkInside(Component comp) {
591:                return (checkInside(comp, 0, 0, comp.getWidth(), comp
592:                        .getHeight()));
593:            }
594:
595:            ////////////////////////////////////////////////////////
596:            //Mapping                                             //
597:
598:            /**Maps <code>JScrollPane.createHorizontalScrollBar()</code> through queue*/
599:            public JScrollBar createHorizontalScrollBar() {
600:                return ((JScrollBar) runMapping(new MapAction(
601:                        "createHorizontalScrollBar") {
602:                    public Object map() {
603:                        return (((JScrollPane) getSource())
604:                                .createHorizontalScrollBar());
605:                    }
606:                }));
607:            }
608:
609:            /**Maps <code>JScrollPane.createVerticalScrollBar()</code> through queue*/
610:            public JScrollBar createVerticalScrollBar() {
611:                return ((JScrollBar) runMapping(new MapAction(
612:                        "createVerticalScrollBar") {
613:                    public Object map() {
614:                        return (((JScrollPane) getSource())
615:                                .createVerticalScrollBar());
616:                    }
617:                }));
618:            }
619:
620:            /**Maps <code>JScrollPane.getColumnHeader()</code> through queue*/
621:            public JViewport getColumnHeader() {
622:                return ((JViewport) runMapping(new MapAction("getColumnHeader") {
623:                    public Object map() {
624:                        return (((JScrollPane) getSource()).getColumnHeader());
625:                    }
626:                }));
627:            }
628:
629:            /**Maps <code>JScrollPane.getCorner(String)</code> through queue*/
630:            public Component getCorner(final String string) {
631:                return ((Component) runMapping(new MapAction("getCorner") {
632:                    public Object map() {
633:                        return (((JScrollPane) getSource()).getCorner(string));
634:                    }
635:                }));
636:            }
637:
638:            /**Maps <code>JScrollPane.getHorizontalScrollBar()</code> through queue*/
639:            public JScrollBar getHorizontalScrollBar() {
640:                return ((JScrollBar) runMapping(new MapAction(
641:                        "getHorizontalScrollBar") {
642:                    public Object map() {
643:                        return (((JScrollPane) getSource())
644:                                .getHorizontalScrollBar());
645:                    }
646:                }));
647:            }
648:
649:            /**Maps <code>JScrollPane.getHorizontalScrollBarPolicy()</code> through queue*/
650:            public int getHorizontalScrollBarPolicy() {
651:                return (runMapping(new MapIntegerAction(
652:                        "getHorizontalScrollBarPolicy") {
653:                    public int map() {
654:                        return (((JScrollPane) getSource())
655:                                .getHorizontalScrollBarPolicy());
656:                    }
657:                }));
658:            }
659:
660:            /**Maps <code>JScrollPane.getRowHeader()</code> through queue*/
661:            public JViewport getRowHeader() {
662:                return ((JViewport) runMapping(new MapAction("getRowHeader") {
663:                    public Object map() {
664:                        return (((JScrollPane) getSource()).getRowHeader());
665:                    }
666:                }));
667:            }
668:
669:            /**Maps <code>JScrollPane.getUI()</code> through queue*/
670:            public ScrollPaneUI getUI() {
671:                return ((ScrollPaneUI) runMapping(new MapAction("getUI") {
672:                    public Object map() {
673:                        return (((JScrollPane) getSource()).getUI());
674:                    }
675:                }));
676:            }
677:
678:            /**Maps <code>JScrollPane.getVerticalScrollBar()</code> through queue*/
679:            public JScrollBar getVerticalScrollBar() {
680:                return ((JScrollBar) runMapping(new MapAction(
681:                        "getVerticalScrollBar") {
682:                    public Object map() {
683:                        return (((JScrollPane) getSource())
684:                                .getVerticalScrollBar());
685:                    }
686:                }));
687:            }
688:
689:            /**Maps <code>JScrollPane.getVerticalScrollBarPolicy()</code> through queue*/
690:            public int getVerticalScrollBarPolicy() {
691:                return (runMapping(new MapIntegerAction(
692:                        "getVerticalScrollBarPolicy") {
693:                    public int map() {
694:                        return (((JScrollPane) getSource())
695:                                .getVerticalScrollBarPolicy());
696:                    }
697:                }));
698:            }
699:
700:            /**Maps <code>JScrollPane.getViewport()</code> through queue*/
701:            public JViewport getViewport() {
702:                return ((JViewport) runMapping(new MapAction("getViewport") {
703:                    public Object map() {
704:                        return (((JScrollPane) getSource()).getViewport());
705:                    }
706:                }));
707:            }
708:
709:            /**Maps <code>JScrollPane.getViewportBorder()</code> through queue*/
710:            public Border getViewportBorder() {
711:                return ((Border) runMapping(new MapAction("getViewportBorder") {
712:                    public Object map() {
713:                        return (((JScrollPane) getSource()).getViewportBorder());
714:                    }
715:                }));
716:            }
717:
718:            /**Maps <code>JScrollPane.getViewportBorderBounds()</code> through queue*/
719:            public Rectangle getViewportBorderBounds() {
720:                return ((Rectangle) runMapping(new MapAction(
721:                        "getViewportBorderBounds") {
722:                    public Object map() {
723:                        return (((JScrollPane) getSource())
724:                                .getViewportBorderBounds());
725:                    }
726:                }));
727:            }
728:
729:            /**Maps <code>JScrollPane.setColumnHeader(JViewport)</code> through queue*/
730:            public void setColumnHeader(final JViewport jViewport) {
731:                runMapping(new MapVoidAction("setColumnHeader") {
732:                    public void map() {
733:                        ((JScrollPane) getSource()).setColumnHeader(jViewport);
734:                    }
735:                });
736:            }
737:
738:            /**Maps <code>JScrollPane.setColumnHeaderView(Component)</code> through queue*/
739:            public void setColumnHeaderView(final Component component) {
740:                runMapping(new MapVoidAction("setColumnHeaderView") {
741:                    public void map() {
742:                        ((JScrollPane) getSource())
743:                                .setColumnHeaderView(component);
744:                    }
745:                });
746:            }
747:
748:            /**Maps <code>JScrollPane.setCorner(String, Component)</code> through queue*/
749:            public void setCorner(final String string, final Component component) {
750:                runMapping(new MapVoidAction("setCorner") {
751:                    public void map() {
752:                        ((JScrollPane) getSource())
753:                                .setCorner(string, component);
754:                    }
755:                });
756:            }
757:
758:            /**Maps <code>JScrollPane.setHorizontalScrollBar(JScrollBar)</code> through queue*/
759:            public void setHorizontalScrollBar(final JScrollBar jScrollBar) {
760:                runMapping(new MapVoidAction("setHorizontalScrollBar") {
761:                    public void map() {
762:                        ((JScrollPane) getSource())
763:                                .setHorizontalScrollBar(jScrollBar);
764:                    }
765:                });
766:            }
767:
768:            /**Maps <code>JScrollPane.setHorizontalScrollBarPolicy(int)</code> through queue*/
769:            public void setHorizontalScrollBarPolicy(final int i) {
770:                runMapping(new MapVoidAction("setHorizontalScrollBarPolicy") {
771:                    public void map() {
772:                        ((JScrollPane) getSource())
773:                                .setHorizontalScrollBarPolicy(i);
774:                    }
775:                });
776:            }
777:
778:            /**Maps <code>JScrollPane.setRowHeader(JViewport)</code> through queue*/
779:            public void setRowHeader(final JViewport jViewport) {
780:                runMapping(new MapVoidAction("setRowHeader") {
781:                    public void map() {
782:                        ((JScrollPane) getSource()).setRowHeader(jViewport);
783:                    }
784:                });
785:            }
786:
787:            /**Maps <code>JScrollPane.setRowHeaderView(Component)</code> through queue*/
788:            public void setRowHeaderView(final Component component) {
789:                runMapping(new MapVoidAction("setRowHeaderView") {
790:                    public void map() {
791:                        ((JScrollPane) getSource()).setRowHeaderView(component);
792:                    }
793:                });
794:            }
795:
796:            /**Maps <code>JScrollPane.setUI(ScrollPaneUI)</code> through queue*/
797:            public void setUI(final ScrollPaneUI scrollPaneUI) {
798:                runMapping(new MapVoidAction("setUI") {
799:                    public void map() {
800:                        ((JScrollPane) getSource()).setUI(scrollPaneUI);
801:                    }
802:                });
803:            }
804:
805:            /**Maps <code>JScrollPane.setVerticalScrollBar(JScrollBar)</code> through queue*/
806:            public void setVerticalScrollBar(final JScrollBar jScrollBar) {
807:                runMapping(new MapVoidAction("setVerticalScrollBar") {
808:                    public void map() {
809:                        ((JScrollPane) getSource())
810:                                .setVerticalScrollBar(jScrollBar);
811:                    }
812:                });
813:            }
814:
815:            /**Maps <code>JScrollPane.setVerticalScrollBarPolicy(int)</code> through queue*/
816:            public void setVerticalScrollBarPolicy(final int i) {
817:                runMapping(new MapVoidAction("setVerticalScrollBarPolicy") {
818:                    public void map() {
819:                        ((JScrollPane) getSource())
820:                                .setVerticalScrollBarPolicy(i);
821:                    }
822:                });
823:            }
824:
825:            /**Maps <code>JScrollPane.setViewport(JViewport)</code> through queue*/
826:            public void setViewport(final JViewport jViewport) {
827:                runMapping(new MapVoidAction("setViewport") {
828:                    public void map() {
829:                        ((JScrollPane) getSource()).setViewport(jViewport);
830:                    }
831:                });
832:            }
833:
834:            /**Maps <code>JScrollPane.setViewportBorder(Border)</code> through queue*/
835:            public void setViewportBorder(final Border border) {
836:                runMapping(new MapVoidAction("setViewportBorder") {
837:                    public void map() {
838:                        ((JScrollPane) getSource()).setViewportBorder(border);
839:                    }
840:                });
841:            }
842:
843:            /**Maps <code>JScrollPane.setViewportView(Component)</code> through queue*/
844:            public void setViewportView(final Component component) {
845:                runMapping(new MapVoidAction("setViewportView") {
846:                    public void map() {
847:                        ((JScrollPane) getSource()).setViewportView(component);
848:                    }
849:                });
850:            }
851:
852:            //End of mapping                                      //
853:            ////////////////////////////////////////////////////////
854:
855:            private void initOperators() {
856:                if (hScrollBarOper == null && getHorizontalScrollBar() != null
857:                        && getHorizontalScrollBar().isVisible()) {
858:                    hScrollBarOper = new JScrollBarOperator(
859:                            getHorizontalScrollBar());
860:                    hScrollBarOper.copyEnvironment(this );
861:                    hScrollBarOper.setVisualizer(new EmptyVisualizer());
862:                }
863:                if (vScrollBarOper == null && getVerticalScrollBar() != null
864:                        && getVerticalScrollBar().isVisible()) {
865:                    vScrollBarOper = new JScrollBarOperator(
866:                            getVerticalScrollBar());
867:                    vScrollBarOper.copyEnvironment(this );
868:                    vScrollBarOper.setVisualizer(new EmptyVisualizer());
869:                }
870:            }
871:
872:            private class ComponentRectChecker implements 
873:                    JScrollBarOperator.ScrollChecker {
874:                Component comp;
875:                int x;
876:                int y;
877:                int width;
878:                int height;
879:                int orientation;
880:
881:                public ComponentRectChecker(Component comp, int x, int y,
882:                        int width, int height, int orientation) {
883:                    this .comp = comp;
884:                    this .x = x;
885:                    this .y = y;
886:                    this .width = width;
887:                    this .height = height;
888:                    this .orientation = orientation;
889:                }
890:
891:                public int getScrollDirection(JScrollBarOperator oper) {
892:                    Point toPoint = SwingUtilities.convertPoint(comp, x, y,
893:                            getViewport().getView());
894:                    int to = (orientation == JScrollBar.HORIZONTAL) ? toPoint.x
895:                            : toPoint.y;
896:                    int ln = (orientation == JScrollBar.HORIZONTAL) ? width
897:                            : height;
898:                    int lv = (orientation == JScrollBar.HORIZONTAL) ? getViewport()
899:                            .getWidth()
900:                            : getViewport().getHeight();
901:                    int vl = oper.getValue();
902:                    if (to < vl) {
903:                        return (ScrollAdjuster.DECREASE_SCROLL_DIRECTION);
904:                    } else if ((to + ln - 1) > (vl + lv) && to > vl) {
905:                        return (ScrollAdjuster.INCREASE_SCROLL_DIRECTION);
906:                    } else {
907:                        return (ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION);
908:                    }
909:                }
910:
911:                public String getDescription() {
912:                    return ("");
913:                }
914:            }
915:
916:            /**
917:             * Checks component type.
918:             */
919:            public static class JScrollPaneFinder extends Finder {
920:                /**
921:                 * Constructs JScrollPaneFinder.
922:                 * @param sf other searching criteria.
923:                 */
924:                public JScrollPaneFinder(ComponentChooser sf) {
925:                    super (JScrollPane.class, sf);
926:                }
927:
928:                /**
929:                 * Constructs JScrollPaneFinder.
930:                 */
931:                public JScrollPaneFinder() {
932:                    super (JScrollPane.class);
933:                }
934:            }
935:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.