Source Code Cross Referenced for Scroller.java in  » Internationalization-Localization » icu4j » com » ibm » richtext » textpanel » 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 » Internationalization Localization » icu4j » com.ibm.richtext.textpanel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * (C) Copyright IBM Corp. 1998-2005.  All Rights Reserved.
003:         *
004:         * The program is provided "as is" without any warranty express or
005:         * implied, including the warranty of non-infringement and the implied
006:         * warranties of merchantibility and fitness for a particular purpose.
007:         * IBM will not be liable for any damages suffered by you as a result
008:         * of using the Program. In no event will IBM be liable for any
009:         * special, indirect or consequential damages or lost profits even if
010:         * IBM has been advised of the possibility of their occurrence. IBM
011:         * will not be liable for any third party claims against you.
012:         */
013:        package com.ibm.richtext.textpanel;
014:
015:        /*
016:         7/9/97 - changed some deprecated methods in Scrollbar
017:         Also setting Unit and Block increment values.  Maybe
018:         it matters...
019:         6/29/98 - reimplemented this class.  Now this class talks to
020:         any component which implements Scroller.Client.
021:         ScrollHolder is gone, too.
022:         2/4/99 - No longer a Panel.  Also, doesn't create Scrollbars,
023:         and in fact doesn't even use the Scrollbar class
024:         directly.
025:         */
026:
027:        import java.awt.Component;
028:        import java.awt.Rectangle;
029:
030:        import java.awt.event.AdjustmentListener;
031:        import java.awt.event.AdjustmentEvent;
032:        import java.awt.Adjustable;
033:
034:        /**
035:         * This class manages the interaction between a scrollable client
036:         * and vertical and horizontal scrollbars.  It calls the client's
037:         * scrollTo method in response to manipulation of the scroll bars.
038:         *
039:         * This class used to be a Panel containing the scrollbars and
040:         * the client panel.  As part of the migration away from direct
041:         * AWT dependencies, this class is no longer part of the view
042:         * hierarchy.  Instead it simply keeps a reference to its
043:         * client and scroll bars.  It is the responsibility of higher-
044:         * level classes to set up the view hierarchy.
045:         */
046:        final class Scroller implements  AdjustmentListener {
047:            static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
048:
049:            static interface Client {
050:                void scrollTo(int x, int y);
051:
052:                Rectangle getScrollSize();
053:
054:                Rectangle getBounds();
055:            }
056:
057:            private Adjustable fHorizScrollBar = null;
058:            private Adjustable fVertScrollBar = null;
059:            private Client fClient = null;
060:
061:            /**
062:             * These are used if the respective Scrollbar is not present.
063:             */
064:            private int fHorizValue, fVertValue;
065:
066:            private static final int DEFAULT_UNIT_INC = 10;
067:
068:            /**
069:             * Construct a new Scroller with the given Adjustables,
070:             * which really should be scrollbars of some ilk.
071:             * Also, the Adjustables are required to be AWT Components,
072:             * so the Scroller can enable and disable them.
073:             * However, a Scroller can work with either AWT Scrollbars
074:             * or JFC JScrollbars.
075:             * @param horizScrollBar the horizontal scrollbar.  null if
076:             * there is no horizontal scrollbar.
077:             * @param vertScrollBar the vertical scrollbar.  null if
078:             * there is no vertical scrollbar.
079:             */
080:            public Scroller(Adjustable horizScrollBar, Adjustable vertScrollBar) {
081:
082:                //setLayout(new ScrollBarLayout());
083:
084:                fHorizScrollBar = horizScrollBar;
085:                fVertScrollBar = vertScrollBar;
086:
087:                if (fVertScrollBar != null) {
088:                    fVertScrollBar.setUnitIncrement(DEFAULT_UNIT_INC);
089:                    fVertScrollBar.addAdjustmentListener(this );
090:                }
091:                if (fHorizScrollBar != null) {
092:                    fHorizScrollBar.setUnitIncrement(DEFAULT_UNIT_INC);
093:                    fHorizScrollBar.addAdjustmentListener(this );
094:                }
095:            }
096:
097:            public void setClient(Client client) {
098:
099:                fClient = client;
100:                clientScrollSizeChanged();
101:            }
102:
103:            public void adjustmentValueChanged(AdjustmentEvent event) {
104:
105:                // variable not used boolean horizontal;
106:                if (event.getAdjustable() == fHorizScrollBar) {
107:                    int vertVal = fVertScrollBar == null ? fVertValue
108:                            : fVertScrollBar.getValue();
109:                    scrollTo(event.getValue(), vertVal);
110:                } else {
111:                    int horizVal = fHorizScrollBar == null ? fHorizValue
112:                            : fHorizScrollBar.getValue();
113:                    scrollTo(horizVal, event.getValue());
114:                }
115:            }
116:
117:            private void setValues(Adjustable scrollbar, int visible,
118:                    int minimum, int height) {
119:
120:                int maximum = minimum + height;
121:
122:                if (scrollbar != null) {
123:
124:                    Component scrollbarToo = (Component) scrollbar;
125:
126:                    if (maximum <= visible) {
127:                        scrollbarToo.setEnabled(false);
128:                    } else {
129:                        scrollbarToo.setEnabled(true);
130:                    }
131:
132:                    scrollbar.setMinimum(minimum);
133:                    scrollbar.setMaximum(maximum);
134:                    scrollbar.setVisibleAmount(visible);
135:                    // workaround setBlockIncrement warnings for increments < 1
136:                    scrollbar.setBlockIncrement(Math.max(1, visible
137:                            - DEFAULT_UNIT_INC));
138:                }
139:            }
140:
141:            public void clientScrollSizeChanged() {
142:                Rectangle bounds = fClient.getBounds();
143:                Rectangle preferredSize = fClient.getScrollSize();
144:
145:                setValues(fHorizScrollBar, bounds.width, preferredSize.x,
146:                        preferredSize.width);
147:                setValues(fVertScrollBar, bounds.height, preferredSize.y,
148:                        preferredSize.height);
149:            }
150:
151:            public void setPosition(int x, int y) {
152:
153:                if (fHorizScrollBar != null) {
154:                    fHorizScrollBar.setValue(x);
155:                } else {
156:                    fHorizValue = x;
157:                }
158:                if (fVertScrollBar != null) {
159:                    fVertScrollBar.setValue(y);
160:                } else {
161:                    fVertValue = y;
162:                }
163:            }
164:
165:            private void scrollTo(int x, int y) {
166:                fClient.scrollTo(x, y);
167:            }
168:
169:            public void setHorizLineDistance(int newDistance) {
170:                if (fHorizScrollBar != null) {
171:                    fHorizScrollBar.setUnitIncrement(newDistance);
172:                }
173:            }
174:
175:            public void setHorizPageOverlap(int newOverlap) {
176:                if (fHorizScrollBar != null) {
177:                    fHorizScrollBar.setBlockIncrement( // workaround warnings for values < 1 on unix
178:                            Math.max(1, fHorizScrollBar.getVisibleAmount()
179:                                    - newOverlap));
180:                }
181:            }
182:
183:            public void setVertLineDistance(int newDistance) {
184:                if (fVertScrollBar != null) {
185:                    fVertScrollBar.setUnitIncrement(newDistance);
186:                }
187:            }
188:
189:            public void setVertPageOverlap(int newOverlap) {
190:                if (fVertScrollBar != null) {
191:                    fVertScrollBar.setBlockIncrement( // workaround warnings for values < 1 on unix
192:                            Math.max(1, fVertScrollBar.getVisibleAmount()
193:                                    - newOverlap));
194:                }
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.