Source Code Cross Referenced for SPageScroller.java in  » Swing-Library » wings3 » org » wings » 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 » Swing Library » wings3 » org.wings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2000,2005 wingS development team.
003:         *
004:         * This file is part of wingS (http://wingsframework.org).
005:         *
006:         * wingS is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU Lesser General Public License
008:         * as published by the Free Software Foundation; either version 2.1
009:         * of the License, or (at your option) any later version.
010:         *
011:         * Please see COPYING for the complete licence.
012:         */
013:        package org.wings;
014:
015:        /**
016:         * A scroller component offering several pages for selection.
017:         * <p/>
018:         * Apply i.e. to {@link SScrollPane} like <br/>
019:         * <code>
020:         *    scrollbar = new SPageScroller(Adjustable.VERTICAL);
021:         *    scrollPane.setHorizontalScrollBar(scrollbar, SScrollPaneLayout.NORTH);
022:         * </code>
023:         *
024:         * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
025:         */
026:        public class SPageScroller extends SAbstractAdjustable {
027:            private static final int DEFAULT_DIRECT_PAGES = 10;
028:
029:            private boolean marginVisible;
030:
031:            private boolean stepVisible;
032:
033:            /**
034:             * Actual amount of page clickables; depends on the number of elemnts in the
035:             * model and on the models extent.
036:             *
037:             * @see #setDirectPages
038:             */
039:            protected int directPages = DEFAULT_DIRECT_PAGES;
040:
041:            /*
042:             * how to layout the scroller, vertical or horizontal
043:             * @see #setLayoutMode
044:             */
045:            protected int layoutMode;
046:
047:            /**
048:             * contains the clickables forward, backward, first, last
049:             */
050:            protected SClickable[] clickables = new SClickable[4];
051:
052:            /**
053:             * contains the direct page clickables. Size of this array is extend
054:             */
055:            protected SClickable[] directPageClickables;
056:
057:            protected SLabel pageCountLabel = new SLabel();
058:
059:            /**
060:             * Creates a scrollbar with the specified orientation,
061:             * value, extent, mimimum, and maximum.
062:             * The "extent" is the size of the viewable area. It is also known
063:             * as the "visible amount".
064:             *
065:             * @throws IllegalArgumentException if orientation is not one of VERTICAL, HORIZONTAL
066:             * @see #setOrientation
067:             * @see #setValue
068:             * @see #setVisibleAmount
069:             * @see #setMinimum
070:             * @see #setMaximum
071:             */
072:            public SPageScroller(int orientation, int value, int extent,
073:                    int min, int max) {
074:                super (new SPagingBoundedRangeModel(value, extent, min, max));
075:                unitIncrement = extent;
076:                blockIncrement = extent;
077:
078:                for (int i = 0; i < clickables.length; i++) {
079:                    clickables[i] = new SClickable();
080:                    clickables[i].setEventTarget(this );
081:                }
082:
083:                setOrientation(orientation);
084:                setMarginVisible(false);
085:                setHorizontalAlignment(SConstants.CENTER);
086:                setVerticalAlignment(SConstants.CENTER);
087:                setEpochCheckEnabled(false);
088:            }
089:
090:            /**
091:             * Creates a scrollbar with the specified orientation
092:             * and the following initial values:
093:             * <pre>
094:             * minimum = 0
095:             * maximum = 100
096:             * value = 0
097:             * extent = 10
098:             * </pre>
099:             */
100:            public SPageScroller(int orientation) {
101:                this (orientation, 0, 1, 0, 100);
102:            }
103:
104:            /**
105:             * Creates a vertical scrollbar with the following initial values:
106:             * <pre>
107:             * minimum = 0
108:             * maximum = 100
109:             * value = 0
110:             * extent = 10
111:             * </pre>
112:             */
113:            public SPageScroller() {
114:                this (SConstants.VERTICAL);
115:            }
116:
117:            public SLabel getPageCountLabel() {
118:                return pageCountLabel;
119:            }
120:
121:            protected void setPageCountText(int pages) {
122:                pageCountLabel.setText("/" + pages);
123:            }
124:
125:            public int getLayoutMode() {
126:                return layoutMode;
127:            }
128:
129:            /**
130:             * set how to layout components
131:             * {@link #VERTICAL} or {@link #HORIZONTAL}
132:             */
133:            public void setLayoutMode(int orientation) {
134:                switch (orientation) {
135:                case SConstants.VERTICAL:
136:                case SConstants.HORIZONTAL:
137:                    layoutMode = orientation;
138:                    break;
139:                default:
140:                    throw new IllegalArgumentException(
141:                            "layout mode must be one of: VERTICAL, HORIZONTAL");
142:                }
143:            }
144:
145:            /**
146:             * Sets the amount of page clickables to <code>count</code>.
147:             */
148:            public final int getDirectPages() {
149:                return directPages;
150:            }
151:
152:            /**
153:             * Sets the amount of page clickables to <code>count</code>.
154:             *
155:             * @param count : New amount of page clickables.
156:             */
157:            public void setDirectPages(int count) {
158:                reloadIfChange(directPages, count);
159:                directPages = count;
160:            }
161:
162:            public final int getPageCount() {
163:                // avoid division by zero
164:                if (getExtent() == 0)
165:                    return 0;
166:                return ((getMaximum()) - getMinimum() + (getExtent() - 1))
167:                        / getExtent();
168:            }
169:
170:            /**
171:             * gets the current page number according to the Position we are
172:             * in.
173:             *
174:             * @return the current page number
175:             */
176:            public final int getCurrentPage() {
177:                // avoid division by zero
178:                if (getExtent() == 0)
179:                    return 0;
180:
181:                return (getValue() - getMinimum() + getExtent() - 1)
182:                        / getExtent();
183:            }
184:
185:            protected String formatDirectPageLabel(int page) {
186:                return Integer.toString(page + 1);
187:            }
188:
189:            public boolean isMarginVisible() {
190:                return marginVisible;
191:            }
192:
193:            public void setMarginVisible(boolean marginVisible) {
194:                this .marginVisible = marginVisible;
195:            }
196:
197:            public boolean isStepVisible() {
198:                return stepVisible;
199:            }
200:
201:            public void setStepVisible(boolean stepVisible) {
202:                this .stepVisible = stepVisible;
203:            }
204:
205:            /**
206:             * Set the visible amount of the scroller. This sets also the
207:             * unitincrement and the blockIncrement!
208:             *
209:             * @param value the new extent
210:             */
211:            public void setExtent(int value) {
212:                super .setExtent(value);
213:                unitIncrement = value;
214:                blockIncrement = value;
215:                // make sure we have a valid value!
216:                setValue(getValue());
217:            }
218:
219:            /**
220:             * Set the visible amount of the scroller. This sets also the
221:             * unitincrement and the blockIncrement!
222:             *
223:             * @param value the new extent
224:             */
225:            public void setVisibleAmount(int value) {
226:                super .setVisibleAmount(value);
227:                unitIncrement = value;
228:                blockIncrement = value;
229:                // make sure we have a valid value!
230:                setValue(getValue());
231:            }
232:
233:            protected void adjust() {
234:                reload();
235:            }
236:
237:            /**
238:             * Set the current value of the scroller. The value will be
239:             * adjusted to a multiple of the extent.
240:             *
241:             * @param value the new value
242:             */
243:            public void setValue(int value) {
244:                super.setValue(value);
245:            }
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.