Source Code Cross Referenced for JIconView.java in  » XML-UI » xmlgui » org » beryl » gui » swing » 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 » XML UI » xmlgui » org.beryl.gui.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Beryl - A web platform based on XML, XSLT and Java
003:         * This file is part of the Beryl XML GUI
004:         *
005:         * Copyright (C) 2004 Wenzel Jakob <wazlaf@tigris.org>
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-3107  USA
020:         */
021:
022:        package org.beryl.gui.swing;
023:
024:        import java.awt.Dimension;
025:        import java.awt.Font;
026:        import java.awt.Rectangle;
027:        import java.beans.PropertyChangeEvent;
028:        import java.beans.PropertyChangeListener;
029:        import java.util.HashSet;
030:        import java.util.Iterator;
031:
032:        import javax.swing.JComponent;
033:        import javax.swing.ListModel;
034:        import javax.swing.LookAndFeel;
035:        import javax.swing.Scrollable;
036:        import javax.swing.UIManager;
037:        import javax.swing.event.ListSelectionEvent;
038:        import javax.swing.event.ListSelectionListener;
039:
040:        import org.beryl.gui.swing.plaf.IconViewUI;
041:
042:        /**
043:         * JIconView - A simple Java icon view widget
044:         * @version 2.0
045:         * @author Wenzel Jakob
046:         */
047:
048:        public class JIconView extends JComponent implements  Scrollable {
049:            private static final String uiClassID = "IconViewUI";
050:            public static final String MODEL_PROPERTY = "model";
051:            public static final String XCELLSIZE_PROPERTY = "xCellSize";
052:            public static final String YCELLSIZE_PROPERTY = "yCellSize";
053:            public static final String ICONTEXTSPACING_PROPERTY = "iconTextSpacing";
054:            public static final String HANDCURSORENABLED_PROPERTY = "handCursorEnabled";
055:
056:            private ListModel model = null;
057:            private int xCellSize = 0;
058:            private int yCellSize = 0;
059:            private int iconTextSpacing = 0;
060:            private int selectedIndex = -1;
061:            private boolean handCursorEnabled = false;
062:            private HashSet listeners = null;
063:
064:            public JIconView() {
065:                this (null);
066:            }
067:
068:            public JIconView(ListModel model) {
069:                super ();
070:                setModel(model);
071:                setFont(new Font("SansSerif", Font.PLAIN, 10));
072:                xCellSize = yCellSize = 80;
073:                iconTextSpacing = 3;
074:                listeners = new HashSet();
075:                initialize();
076:                updateUI();
077:            }
078:
079:            /* ========== Initialisation ========== */
080:
081:            public static void initialize() {
082:                setLookAndFeelProperties(UIManager.getLookAndFeel());
083:                UIManager
084:                        .addPropertyChangeListener(new PropertyChangeListener() {
085:                            public void propertyChange(PropertyChangeEvent event) {
086:                                if ("lookAndFeel".equals(event
087:                                        .getPropertyName())) {
088:                                    setLookAndFeelProperties((LookAndFeel) event
089:                                            .getNewValue());
090:                                }
091:                            }
092:                        });
093:            }
094:
095:            private static void setLookAndFeelProperties(LookAndFeel lookAndFeel) {
096:                UIManager.put("IconViewUI",
097:                        "org.beryl.gui.swing.plaf.IconViewUI");
098:            }
099:
100:            /* ========== Model ========== */
101:
102:            public void setModel(ListModel model) {
103:                ListModel old = this .model;
104:                this .model = model;
105:                firePropertyChange(MODEL_PROPERTY, old, model);
106:            }
107:
108:            public ListModel getModel() {
109:                return model;
110:            }
111:
112:            /* ========== Spacing ========== */
113:
114:            public int getXCellSize() {
115:                return xCellSize;
116:            }
117:
118:            public int getYCellSize() {
119:                return yCellSize;
120:            }
121:
122:            public int getIconTextSpacing() {
123:                return iconTextSpacing;
124:            }
125:
126:            public void setXCellSize(int xCellSize) {
127:                int old = xCellSize;
128:                this .xCellSize = xCellSize;
129:                firePropertyChange(XCELLSIZE_PROPERTY, old, xCellSize);
130:            }
131:
132:            public void setYCellSize(int yCellSize) {
133:                int old = yCellSize;
134:                this .yCellSize = yCellSize;
135:                firePropertyChange(YCELLSIZE_PROPERTY, old, yCellSize);
136:            }
137:
138:            public void setIconTextSpacing(int iconTextSpacing) {
139:                int old = iconTextSpacing;
140:                this .iconTextSpacing = iconTextSpacing;
141:                firePropertyChange(ICONTEXTSPACING_PROPERTY, old,
142:                        iconTextSpacing);
143:            }
144:
145:            /* ========== Cursor ========== */
146:
147:            public boolean getHandCursorEnabled() {
148:                return handCursorEnabled;
149:            }
150:
151:            public void setHandCursorEnabled(boolean enabled) {
152:                boolean old = handCursorEnabled;
153:                handCursorEnabled = enabled;
154:                firePropertyChange(ICONTEXTSPACING_PROPERTY, old,
155:                        handCursorEnabled);
156:
157:            }
158:
159:            /* ========== Listeners ========== */
160:
161:            public void addListSelectionListener(ListSelectionListener listener) {
162:                listeners.add(listener);
163:            }
164:
165:            public void removeListSelectionListener(
166:                    ListSelectionListener listener) {
167:                listeners.remove(listener);
168:            }
169:
170:            /* ========== Selection ========== */
171:
172:            public int getSelectedIndex() {
173:                return selectedIndex;
174:            }
175:
176:            public void setSelectedIndex(int selectedIndex) {
177:                if (model != null) {
178:                    try {
179:                        if (selectedIndex < model.getSize()
180:                                && selectedIndex >= -1) {
181:                            this .selectedIndex = selectedIndex;
182:                            ListSelectionEvent event = new ListSelectionEvent(
183:                                    this , selectedIndex, selectedIndex, false);
184:                            for (Iterator i = listeners.iterator(); i.hasNext();) {
185:                                ((ListSelectionListener) i.next())
186:                                        .valueChanged(event);
187:                            }
188:
189:                        }
190:                    } catch (ArrayIndexOutOfBoundsException e) {
191:                    }
192:                }
193:            }
194:
195:            /* ========== Scrollable ========== */
196:
197:            public Dimension getPreferredScrollableViewportSize() {
198:                return getPreferredSize();
199:            }
200:
201:            public int getScrollableUnitIncrement(Rectangle visibleRect,
202:                    int orientation, int direction) {
203:                return 1;
204:            }
205:
206:            public int getScrollableBlockIncrement(Rectangle visibleRect,
207:                    int orientation, int direction) {
208:                return 1;
209:            }
210:
211:            public boolean getScrollableTracksViewportWidth() {
212:                return true;
213:            }
214:
215:            public boolean getScrollableTracksViewportHeight() {
216:                return false;
217:            }
218:
219:            /* ========== UI ========== */
220:
221:            public IconViewUI getUI() {
222:                return (IconViewUI) ui;
223:            }
224:
225:            public void setUI(IconViewUI ui) {
226:                super .setUI(ui);
227:            }
228:
229:            public void updateUI() {
230:                setUI((IconViewUI) UIManager.getUI(this ));
231:                invalidate();
232:            }
233:
234:            public String getUIClassID() {
235:                return uiClassID;
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.