Source Code Cross Referenced for Catalog.java in  » XML-UI » xui32 » com » xoetrope » svgcomponentswizard » 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 » xui32 » com.xoetrope.svgcomponentswizard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Catalog.java
003:         *
004:         * Created on 20 March 2007, 11:32
005:         *
006:         * To change this template, choose Tools | Template Manager
007:         * and open the template in the editor.
008:         */
009:
010:        package com.xoetrope.svgcomponentswizard;
011:
012:        import com.xoetrope.event.XClickListener;
013:        import com.xoetrope.swing.XCaptionedImage;
014:        import com.xoetrope.tools.TitlePanel;
015:        import com.xoetrope.tools.XGraphicListCellRenderer;
016:        import java.awt.BorderLayout;
017:        import java.awt.Component;
018:        import java.awt.Cursor;
019:        import java.awt.Font;
020:        import java.awt.event.MouseEvent;
021:        import java.awt.event.MouseListener;
022:        import java.awt.event.MouseMotionListener;
023:        import java.beans.PropertyChangeEvent;
024:        import java.beans.PropertyChangeListener;
025:        import java.util.HashMap;
026:        import javax.swing.DefaultListModel;
027:        import javax.swing.JButton;
028:        import javax.swing.JComponent;
029:        import javax.swing.JFrame;
030:        import javax.swing.JLabel;
031:        import javax.swing.JList;
032:        import javax.swing.JPanel;
033:        import javax.swing.ListModel;
034:        import javax.swing.ListSelectionModel;
035:        import javax.swing.event.ListDataEvent;
036:        import javax.swing.event.ListDataListener;
037:        import net.xoetrope.swing.XApplet;
038:        import net.xoetrope.swing.XImage;
039:        import net.xoetrope.swing.XList;
040:        import net.xoetrope.swing.XPanel;
041:        import net.xoetrope.swing.XScrollPane;
042:        import net.xoetrope.swing.XTextArea;
043:        import net.xoetrope.swing.dnd.XDragInfo;
044:        import net.xoetrope.swing.dnd.XDragManager;
045:        import net.xoetrope.swing.dnd.XTransferHandlerFactory;
046:        import net.xoetrope.xui.XPage;
047:        import net.xoetrope.xui.XPageManager;
048:        import net.xoetrope.xui.XProject;
049:        import net.xoetrope.xui.XProjectManager;
050:        import net.xoetrope.xui.style.XStyle;
051:        import net.xoetrope.xui.style.XStyleManager;
052:
053:        /**
054:         *
055:         * @author kingsley.elmes
056:         */
057:        public class Catalog extends XPage implements  XDragManager,
058:                MouseListener {
059:            protected XPanel productsPanel, detailsPanel, mainPanel, cartPanel;
060:            protected XList cartList;
061:            protected DefaultListModel model;
062:            protected XGraphicListCellRenderer renderer;
063:            protected JLabel totalPrice;
064:            protected XTextArea descriptionArea;
065:            protected HashMap infoMap;
066:            protected Component[] products;
067:            protected Object[][] values;
068:            private int previousSize;
069:
070:            /** Creates a new instance of Catalog */
071:            public Catalog() {
072:                setupDragInfo();
073:            }
074:
075:            /** 
076:             * Set-up and add graphic list cell renderer to the cart list, add mouse listener to each 
077:             * captioned image and add property change listener to the cart list.
078:             */
079:            public void pageCreated() {
080:                mainPanel = (XPanel) findComponent("mainPanel");
081:                productsPanel = (XPanel) findComponent("productsPanel");
082:                descriptionArea = (XTextArea) findComponent("descriptionArea");
083:                cartList = (XList) findComponent("cartList");
084:                totalPrice = (JLabel) findComponent("totalPrice");
085:                cartPanel = (XPanel) findComponent("cartPanel");
086:
087:                descriptionArea.setFont(new Font("Arial", Font.PLAIN, 12));
088:
089:                XStyleManager styleManager = project.getStyleManager();
090:                XStyle comboStyle = styleManager.getStyle("base/edit");
091:                descriptionArea.setForeground(comboStyle
092:                        .getStyleAsColor(comboStyle.COLOR_FORE));
093:
094:                renderer = new XGraphicListCellRenderer(totalPrice);
095:                cartList.setCellRenderer(renderer);
096:                cartList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
097:                cartList.setFixedCellHeight(30);
098:                cartList.setFocusable(false);
099:                cartList.setDragEnabled(true);
100:
101:                productsPanel.addMouseListener(this );
102:
103:                products = productsPanel.getComponents();
104:                for (int i = 0; i < products.length - 1; i++) {
105:                    ((XCaptionedImage) products[i]).addCaptionListener(this );
106:                }
107:
108:                /* Add a property change listener to listen for changes to the cart list and 
109:                 * update the totla price accordingly.
110:                 */
111:                cartList
112:                        .addPropertyChangeListener(new PropertyChangeListener() {
113:                            public void propertyChange(PropertyChangeEvent evt) {
114:                                calculateTotal(cartList);
115:                            }
116:                        });
117:            }
118:
119:            public void showPage() {
120:                XPageManager pageMgr = XProjectManager.getPageManager();
121:                pageMgr.showPage("Welcome");
122:            }
123:
124:            /**
125:             * Get drag info for the dragged object.
126:             */
127:            public XDragInfo getDragInfo(String key) {
128:                return (XDragInfo) infoMap.get(key);
129:            }
130:
131:            /**
132:             * Set up the drag info for each captioned image.
133:             */
134:            private void setupDragInfo() {
135:                infoMap = new HashMap();
136:                String[] keys = { XDragInfo.TITLE, XDragInfo.KEY, "price",
137:                        "image", XDragInfo.DESCRIPTION };
138:
139:                Object[][] v = {
140:                        {
141:                                "Canon Digital Camera",
142:                                "camera",
143:                                "$249.99",
144:                                "camera.jpg",
145:                                "The Canon PowerShot SD550 is a sleek 7 megapixel ultracompact. The Canon PowerShot SD550 is the older brother of the PowerShot SD450. The camera also features an oversized 2.5-inch LCD display that gives excellent previews of your 7.1 megapixel photos. An orientation sensor rotates your preview image depending on which way you hold the camera, horizontally or vertically." },
146:                        {
147:                                "Netgear Network Storage Device",
148:                                "netstore",
149:                                "$99.99",
150:                                "networkstorage.jpg",
151:                                "NETGEAR’s Storage Central is an innovation for storing and protecting music, games, photos, videos, and other important files on a secure network device. It functions just like a local disk drive, accessible from any network computer, but without requiring a dedicated PC. " },
152:                        {
153:                                "Netgear Wireless Card",
154:                                "wireless",
155:                                "$39.99",
156:                                "wirelesscard.jpg",
157:                                "With the RangeMax NEXT Notebook adapter inserted, your PC will maintain a steady, constant connection (when used in conjunction with the WNR834B or DG834N Wireless Router), with sufficient bandwidth available to stream, download, browse the Internet, and transfer files all at the same time.With RangeMax NEXT you should not experience any more frustrating interruptions or freezes, just a constant connection that enables you and your household to use the Internet and wireless network as you choose, whenever you choose." },
158:                        {
159:                                "Blackberry",
160:                                "blackberry",
161:                                "$399.99",
162:                                "blackberry.jpg",
163:                                "The BlackBerry Pearl comes complete with digital camera, multimedia capabilities and expandable memory, while also offering push-based wireless access to email, phone that includes Speaker-Independent Voice Activated Dialling, text messaging, Internet and intranet browsing, organiser, and other data applications." },
164:                        {
165:                                "ATI Graphics Card",
166:                                "graphicscard",
167:                                "$299.99",
168:                                "graphicscard.jpg",
169:                                "Designed from the ground up to deliver maximum graphical detail at the best possible frame rates, the Radeon X1900’s state-of-the-art architecture includes an ultra-threaded engine for unparalleled shader performance. In addition, it is CrossFire™ ready, allowing your greatest multi-GPU fantasies to come true. The Radeon X1900 ups the ante with Avivo™ video and display technology delivering movies, games, and photos in high-definition format with stunning color and realism." },
170:                        {
171:                                "Noise Reduction Earphones",
172:                                "earphones",
173:                                "$19.99",
174:                                "earphones.jpg",
175:                                "This Able Planet Clear Harmony Stereo Headset has Able Planet LINX technology installed, which provides people with all levels of hearing loss the opportunity to hear better by enhancing the clarity in speech, providing richer sounding music, and enhancing the overall sound quality. Clear Harmony increases the perception of loudness without increasing the volume control of the device. Youll hear premium sound with reduced distortion. Adjustable headband gives you a comfortable and secure fit. Volume control on the cord for easy level adjustment. Straight, dual entry 4-foot cord with 1/8 and 1/4 stereo plugs for use with stereos, personal computers, CD players, MP3 players and IPOD's. Cannot be used with hearing aids." },
176:                        {
177:                                "Electronic Dictionary",
178:                                "dictionary",
179:                                "$49.99",
180:                                "dictionary.jpg",
181:                                "Invest in yourself with this easy-to-use Speaking Electronic Dictionary and learn a new word each time you turn the unit on. You will master grammar, solve crossword puzzles, expand your vocabulary and improve your spelling before you know it! The right words are easy to find with Franklin's talking thesaurus and renowned phonetic spell correction feature that allows you to enter words by how they sound, while the large 8-line display screen offers visibility with and without your reading glasses." },
182:                        {
183:                                "i-Phone",
184:                                "iphone",
185:                                "$799.99",
186:                                "iphone.jpg",
187:                                "iPhone combines three amazing products — a revolutionary mobile phone, a widescreen iPod with touch controls, and a breakthrough Internet communications device with desktop-class email, web browsing, maps, and searching — into one small and lightweight handheld device. iPhone also introduces an entirely new user interface based on a large multi-touch display and pioneering new software, letting you control everything with just your fingers. So it ushers in an era of software power and sophistication never before seen in a mobile device, completely redefining what you can do on a mobile phone." },
188:                        {
189:                                "Tablet PC",
190:                                "tabletpc",
191:                                "$699.99",
192:                                "tabletpc.jpg",
193:                                "The revolutionary Compaq Tablet PC operates as a full function PC, delivering performance and compatibility while weighing less than three pounds. Designed to operate in multiple modes including tablet, portable notebook and desktop, the Compaq Tablet PC was engineered to allow mobile professionals to transition through different working environments quickly, easily and discreetly." },
194:                        {
195:                                "MP3 Player",
196:                                "mp3player",
197:                                "$99.99",
198:                                "mp3player.jpg",
199:                                "Creative's Zen Vision:M is the ultimate player for people who want to enjoy music and movies on the go. This stylish, versatile system features an advanced 2.5-inch high-resolution colour screen that can display movies and stills up to an amazing 262,144 colours! The Zen Vision:M's rechargeable battery delivers playtimes up to four hours with video, up to 14 hours with music. For live entertainment or capturing those special moments there's also a built-in FM radio and voice recorder." },
200:                        {
201:                                "Hard-Drive",
202:                                "harddrive",
203:                                "$89.99",
204:                                "harddrive.jpg",
205:                                "This 4gb jumbo-drive features an AutoRun, user friendly interface, password protectionability to schedule and back up specified files, SKYPE application, portable Thunderbird (portable client email server) application, portable open office suite (Spread sheet, word processing,draw,presentation,data base), 180 degree turn around USB connection." },
206:                        {
207:                                "Philips Digital TV",
208:                                "digitaltv",
209:                                "$1599.99",
210:                                "digitaltv.jpg",
211:                                "Enjoy the ultimate viewing experience of this Philips Cineos Flat TV with Pixel Plus 3 HD, Ambilight Surround and Clear LCD technology. The Digital Media Reader with PC link gives you full access to multimedia content." } };
212:
213:                // Put info into hashmap.
214:                for (int i = 0; i < v.length; i++) {
215:                    XDragInfo dragInfo = new XDragInfo();
216:                    dragInfo.addValues(keys, v[i]);
217:                    infoMap.put((String) v[i][1], dragInfo);
218:                }
219:
220:                values = v;
221:            }
222:
223:            /**
224:             * Updates the display panel with relevant product info if the mouse enters 
225:             * one of the captioned images.
226:             * @param e the passed <CODE>MouseEvent</CODE>
227:             */
228:            public void mouseEntered(MouseEvent e) {
229:                if (e.getSource() == productsPanel) {
230:                    descriptionArea.setText("");
231:                } else {
232:                    for (int i = 0; i < products.length - 1; i++) {
233:                        if (e.getSource() == products[i]) {
234:                            descriptionArea.setText((String) values[i][4]);
235:                            break;
236:                        }
237:                    }
238:                }
239:            }
240:
241:            /**
242:             * Calculate the total price of all the products in the cart list.
243:             * @param list <CODE>JList<CODE> representing the product list.
244:             */
245:            public void calculateTotal(JList list) {
246:                ListModel model = list.getModel();
247:
248:                if (model.getSize() > previousSize) {
249:                    double total = 0;
250:                    for (int i = 0; i < model.getSize(); i++) {
251:                        XDragInfo info = (XDragInfo) model.getElementAt(i);
252:                        String price = (String) info.get("price");
253:
254:                        double current = Double.parseDouble(price.substring(1));
255:                        total = total + current;
256:
257:                        String result = "$" + total;
258:                        result = result.substring(0, result.indexOf(".") + 3);
259:                        totalPrice.setText(result);
260:                    }
261:                    previousSize = model.getSize();
262:                }
263:            }
264:
265:            public void mouseExited(MouseEvent e) {
266:            }
267:
268:            public void mouseClicked(MouseEvent e) {
269:            }
270:
271:            public void mousePressed(MouseEvent e) {
272:            }
273:
274:            public void mouseReleased(MouseEvent e) {
275:            }
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.