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


001:        package com.xoetrope.carousel.wizard;
002:
003:        import java.util.Vector;
004:
005:        import java.awt.Color;
006:        import java.awt.Font;
007:        import java.awt.Rectangle;
008:        import java.awt.SystemColor;
009:        import java.awt.event.ActionEvent;
010:        import java.awt.event.ActionListener;
011:        import java.awt.event.ComponentEvent;
012:        import java.awt.event.InputEvent;
013:        import java.awt.event.MouseEvent;
014:        import javax.swing.BorderFactory;
015:        import javax.swing.JColorChooser;
016:        import javax.swing.JLabel;
017:        import javax.swing.JPanel;
018:        import javax.swing.JTextArea;
019:        import javax.swing.SwingConstants;
020:        import javax.swing.event.ChangeEvent;
021:        import javax.swing.event.ChangeListener;
022:
023:        import net.xoetrope.swing.XImage;
024:        import net.xoetrope.editor.project.XEditorProject;
025:
026:        /**
027:         *
028:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
029:         * the GNU Public License (GPL), please see license.txt for more details. If
030:         * you make commercial use of this software you must purchase a commercial
031:         * license from Xoetrope.</p>
032:         * <p> $Revision: 1.5 $</p>
033:         */
034:        public class XColourPanel extends XWizardPanel implements 
035:                ActionListener, ChangeListener {
036:            private XImage imageControl1 = new XImage();
037:            private JTextArea jTextArea1 = new JTextArea();
038:            private JPanel schemePanel = new JPanel();
039:            private JLabel jLabel1 = new JLabel();
040:            private JLabel headingsLabel = new JLabel();
041:            private javax.swing.JButton buttonB = new javax.swing.JButton();
042:            private javax.swing.JButton buttonA = new javax.swing.JButton();
043:            private JPanel lineColour = new JPanel();
044:            private JLabel subheadingsLabel = new JLabel();
045:            private JTextArea bodyTextArea = new JTextArea();
046:            private JPanel placeHolderPanel = new JPanel();
047:            private JLabel hintLabel = new JLabel();
048:            private JLabel predefinedLabel = new JLabel();
049:            private String schemes[] = { "Professional", "Casual",
050:                    "High Contrast", "System" };
051:            private javax.swing.JComboBox schemeList = new javax.swing.JComboBox(
052:                    schemes);
053:            private JLabel codeLabel = new JLabel();
054:
055:            private XEditorProject currentProject;
056:
057:            public static final int COLOR_HEADING = 0;
058:            public static final int COLOR_SUBHEADING = 1;
059:            public static final int COLOR_BODYTEXT = 2;
060:            public static final int COLOR_CAPTION = 3;
061:            public static final int COLOR_CODE = 4;
062:            public static final int COLOR_BTNTEXT = 5;
063:            public static final int COLOR_BTNFACE = 6;
064:            public static final int COLOR_BKGROUND = 7;
065:            public static final int COLOR_LINE = 8;
066:            public static final int COLOR_PLACEHOLDER = 9;
067:            public static final int NUM_COLORS_PER_SCHEME = 10;
068:
069:            public static final int PROFESSION_SCHEME = 0;
070:            public static final int CASUAL_SCHEME = 1;
071:            public static final int HIGHCONTRAST_SCHEME = 2;
072:            public static final int SYSTEM_SCHEME = 3;
073:
074:            Color[] profScheme = { new Color(51, 0, 153), // Heading
075:                    new Color(51, 0, 153), // Sub heading
076:                    new Color(51, 0, 153), // Body
077:                    new Color(0, 0, 102), // Caption
078:                    new Color(0, 0, 255), // Code
079:                    new Color(0, 0, 153), // Button text
080:                    new Color(153, 153, 255), // Button face
081:                    new Color(204, 204, 255), // Background
082:                    new Color(255, 0, 0), // Line
083:                    new Color(200, 200, 240), // Placeholder
084:            };
085:
086:            Color[] casualScheme = { new Color(0, 0, 102), // Heading
087:                    new Color(0, 0, 102), // Sub heading
088:                    new Color(0, 101, 101), // Body
089:                    new Color(155, 101, 0), // Caption
090:                    new Color(101, 0, 50), // Code
091:                    new Color(0, 0, 153), // Button text
092:                    new Color(0, 204, 204), // Button face
093:                    new Color(204, 255, 255), // Background
094:                    new Color(0, 204, 204), // Line
095:                    new Color(0, 204, 204), // Placeholder
096:            };
097:
098:            Color[] highContrastScheme = { new Color(254, 255, 0), // Heading
099:                    new Color(255, 204, 0), // Sub heading
100:                    new Color(255, 255, 255), // Body
101:                    new Color(255, 203, 101), // Caption
102:                    new Color(153, 255, 255), // Code
103:                    new Color(0, 0, 101), // Button text
104:                    new Color(204, 204, 255), // Button face
105:                    new Color(0, 0, 101), // Background
106:                    new Color(255, 204, 0), // Line
107:                    new Color(0, 51, 153), // Placeholder
108:            };
109:
110:            Color[] systemScheme = { SystemColor.activeCaptionText, // Heading
111:                    SystemColor.textHighlight, // Sub heading
112:                    SystemColor.textText, // Body
113:                    SystemColor.inactiveCaption, // Caption
114:                    SystemColor.textHighlight, // Code
115:                    SystemColor.controlText, // Button text
116:                    SystemColor.control, // Button face
117:                    SystemColor.control, // Background
118:                    SystemColor.textHighlight, // Line
119:                    SystemColor.window, // Placeholder
120:            };
121:
122:            private Vector wizardColours;
123:            private Vector wizardFonts;
124:
125:            public XColourPanel(XEditorProject proj, Vector colours,
126:                    Vector fonts, String name, String panelNumber) {
127:                super (name);
128:                currentProject = proj;
129:
130:                wizardColours = colours;
131:                wizardFonts = fonts;
132:
133:                useColorScheme(0);
134:
135:                try {
136:                    jbInit(panelNumber);
137:                } catch (Exception ex) {
138:                    ex.printStackTrace();
139:                }
140:            }
141:
142:            void jbInit(String panelNumber) throws Exception {
143:                Font font = new java.awt.Font("SansSerif", 0, 11);
144:
145:                setLayout(null);
146:                imageControl1.setBackground(getBackground());
147:                imageControl1.setBounds(new Rectangle(5, 9, 179, 366));
148:                imageControl1.setImage(currentProject
149:                        .getImage("com/xoetrope/carousel/wizard/colours.jpg"));
150:                imageControl1.setBorder(BorderFactory.createEtchedBorder());
151:
152:                jTextArea1.setBackground(getBackground());
153:                jTextArea1
154:                        .setText("Step "
155:                                + panelNumber
156:                                + ": Choose a colourscheme for your catalogue. Click on each item "
157:                                + "to change its colour.");
158:                jTextArea1.setLineWrap(true);
159:                jTextArea1.setWrapStyleWord(true);
160:                jTextArea1.setBounds(new Rectangle(190, 10, 400, 39));
161:
162:                schemePanel.setBorder(BorderFactory.createEtchedBorder());
163:                schemePanel.setBounds(new Rectangle(191, 73, 397, 302));
164:                schemePanel.setLayout(null);
165:
166:                jLabel1.setText("Schemes");
167:                jLabel1.setBounds(new Rectangle(191, 55, 88, 17));
168:
169:                headingsLabel
170:                        .setToolTipText("Click here to set the colours for headline items");
171:                headingsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
172:                headingsLabel.setText("Headings");
173:                headingsLabel.setBounds(new Rectangle(223, 41, 164, 31));
174:                headingsLabel
175:                        .addMouseListener(new java.awt.event.MouseAdapter() {
176:
177:                            public void mouseClicked(MouseEvent e) {
178:                                headingsLabel_mouseClicked(e);
179:                            }
180:                        });
181:                buttonB.setToolTipText("Click to set button colours");
182:                buttonB.setText("Buttons");
183:                buttonB.setBounds(new Rectangle(308, 266, 79, 27));
184:                buttonB.addMouseListener(new java.awt.event.MouseAdapter() {
185:
186:                    public void mouseClicked(MouseEvent e) {
187:                        buttonB_mouseClicked(e);
188:                    }
189:                });
190:                buttonA.setToolTipText("Click to set button colours");
191:                buttonA.setText("Buttons");
192:                buttonA.setBounds(new Rectangle(228, 266, 79, 27));
193:                buttonA.addMouseListener(new java.awt.event.MouseAdapter() {
194:
195:                    public void mouseClicked(MouseEvent e) {
196:                        buttonA_mouseClicked(e);
197:                    }
198:                });
199:                lineColour.setBackground(Color.red);
200:                lineColour
201:                        .setToolTipText("Click here to change the default colour for lines and other graphics "
202:                                + "items");
203:                lineColour.setBounds(new Rectangle(16, 73, 372, 5));
204:                lineColour.addMouseListener(new java.awt.event.MouseAdapter() {
205:
206:                    public void mouseClicked(MouseEvent e) {
207:                        lineColour_mouseClicked(e);
208:                    }
209:                });
210:                subheadingsLabel
211:                        .setToolTipText("Click here to change the colours for sub headings texts");
212:                subheadingsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
213:                subheadingsLabel.setText("sub headings");
214:                subheadingsLabel.setBounds(new Rectangle(204, 85, 184, 17));
215:                subheadingsLabel
216:                        .addMouseListener(new java.awt.event.MouseAdapter() {
217:
218:                            public void mouseClicked(MouseEvent e) {
219:                                subheadingsLabel_mouseClicked(e);
220:                            }
221:                        });
222:                bodyTextArea.setLineWrap(true);
223:                bodyTextArea.setWrapStyleWord(true);
224:                bodyTextArea
225:                        .setToolTipText("Click here to change the colour of the main body text items");
226:                bodyTextArea.setBackground(SystemColor.control);
227:                bodyTextArea
228:                        .setText("Body text... click on the object of interest to set its foreground "
229:                                + "colour or click with the right mouse button to set the background "
230:                                + "colour.");
231:                bodyTextArea.setBounds(new Rectangle(193, 104, 196, 112));
232:                bodyTextArea
233:                        .addMouseListener(new java.awt.event.MouseAdapter() {
234:
235:                            public void mouseClicked(MouseEvent e) {
236:                                bodyTextArea_mouseClicked(e);
237:                            }
238:                        });
239:                placeHolderPanel.setBackground(Color.white);
240:                placeHolderPanel
241:                        .setToolTipText("Click here to change the colours of any place holders or pictures");
242:                placeHolderPanel.setBounds(new Rectangle(17, 95, 161, 132));
243:                placeHolderPanel
244:                        .addMouseListener(new java.awt.event.MouseAdapter() {
245:
246:                            public void mouseClicked(MouseEvent e) {
247:                                placeHolderPanel_mouseClicked(e);
248:                            }
249:                        });
250:                hintLabel
251:                        .setToolTipText("Set teh colour of the hints and captions text by clicking here");
252:                hintLabel.setText("Hints and captions");
253:                hintLabel.setBounds(new Rectangle(17, 233, 159, 17));
254:                hintLabel.addMouseListener(new java.awt.event.MouseAdapter() {
255:
256:                    public void mouseClicked(MouseEvent e) {
257:                        hintLabel_mouseClicked(e);
258:                    }
259:                });
260:                predefinedLabel.setText("Predefined schemes");
261:                predefinedLabel.setBounds(new Rectangle(10, 11, 111, 17));
262:                schemeList
263:                        .setToolTipText("Choose a predefined colour scheme from this list.");
264:                schemeList.setBounds(new Rectangle(132, 7, 256, 24));
265:                schemeList
266:                        .addActionListener(new java.awt.event.ActionListener() {
267:
268:                            public void actionPerformed(ActionEvent e) {
269:                                schemeList_actionPerformed(e);
270:                            }
271:                        });
272:                codeLabel
273:                        .setToolTipText("Click here to set the colour for any source code items");
274:                codeLabel.setText("Source Code example;");
275:                codeLabel.setBounds(new Rectangle(196, 220, 193, 17));
276:                codeLabel.addMouseListener(new java.awt.event.MouseAdapter() {
277:
278:                    public void mouseClicked(MouseEvent e) {
279:                        codeLabel_mouseClicked(e);
280:                    }
281:                });
282:                this 
283:                        .addComponentListener(new java.awt.event.ComponentAdapter() {
284:
285:                            public void componentShown(ComponentEvent e) {
286:                                panelComponentShown(e);
287:                            }
288:                        });
289:                add(imageControl1, null);
290:                add(jTextArea1, null);
291:                add(schemePanel, null);
292:                schemePanel.add(buttonB, null);
293:                schemePanel.add(buttonA, null);
294:                schemePanel.add(predefinedLabel, null);
295:                schemePanel.add(schemeList, null);
296:                schemePanel.add(headingsLabel, null);
297:                schemePanel.add(lineColour, null);
298:                schemePanel.add(subheadingsLabel, null);
299:                schemePanel.add(bodyTextArea, null);
300:                schemePanel.add(placeHolderPanel, null);
301:                schemePanel.add(hintLabel, null);
302:                schemePanel.add(codeLabel, null);
303:                add(jLabel1, null);
304:
305:                updatePanel();
306:            }
307:
308:            public void actionPerformed(ActionEvent evt) {
309:            }
310:
311:            public void stateChanged(ChangeEvent evt) {
312:            }
313:
314:            public void updatePanel() {
315:                if (wizardFonts.size() > 0) {
316:                    headingsLabel.setFont((Font) wizardFonts.elementAt(0));
317:                    subheadingsLabel.setFont((Font) wizardFonts.elementAt(1));
318:                    bodyTextArea.setFont((Font) wizardFonts.elementAt(2));
319:                    hintLabel.setFont((Font) wizardFonts.elementAt(3));
320:                    codeLabel.setFont((Font) wizardFonts.elementAt(4));
321:                }
322:
323:                predefinedLabel.setForeground((Color) wizardColours
324:                        .elementAt(COLOR_CAPTION));
325:                headingsLabel.setForeground((Color) wizardColours
326:                        .elementAt(COLOR_HEADING));
327:                subheadingsLabel.setForeground((Color) wizardColours
328:                        .elementAt(COLOR_SUBHEADING));
329:                bodyTextArea.setForeground((Color) wizardColours
330:                        .elementAt(COLOR_BODYTEXT));
331:                hintLabel.setForeground((Color) wizardColours
332:                        .elementAt(COLOR_CAPTION));
333:                codeLabel.setForeground((Color) wizardColours
334:                        .elementAt(COLOR_CODE));
335:                buttonA.setForeground((Color) wizardColours
336:                        .elementAt(COLOR_BTNTEXT));
337:                buttonB.setForeground((Color) wizardColours
338:                        .elementAt(COLOR_BTNTEXT));
339:                Color bgColor = (Color) wizardColours.elementAt(COLOR_BKGROUND);
340:
341:                Color bfc = (Color) wizardColours.elementAt(COLOR_BTNTEXT);
342:                //  buttonB.setBorder( new EtchedBorder( new Color( 200, 200, 255 ), new Color( 128, 128, 192 )));
343:                headingsLabel.setBackground(bgColor);
344:                subheadingsLabel.setBackground(bgColor);
345:
346:                bodyTextArea.setBackground(bgColor);
347:                hintLabel.setBackground(bgColor);
348:                codeLabel.setBackground(bgColor);
349:                schemePanel.setBackground(bgColor);
350:                buttonA.setBackground((Color) wizardColours
351:                        .elementAt(COLOR_BTNFACE));
352:                buttonB.setBackground((Color) wizardColours
353:                        .elementAt(COLOR_BTNFACE));
354:                lineColour.setBackground((Color) wizardColours
355:                        .elementAt(COLOR_LINE));
356:                placeHolderPanel.setBackground((Color) wizardColours
357:                        .elementAt(COLOR_PLACEHOLDER));
358:
359:                headingsLabel.setVisible(false);
360:                headingsLabel.setVisible(true);
361:                subheadingsLabel.setVisible(false);
362:                subheadingsLabel.setVisible(true);
363:                bodyTextArea.setVisible(false);
364:                bodyTextArea.setVisible(true);
365:                hintLabel.setVisible(false);
366:                hintLabel.setVisible(true);
367:                codeLabel.setVisible(false);
368:                codeLabel.setVisible(true);
369:            }
370:
371:            void panelComponentShown(ComponentEvent e) {
372:                updatePanel();
373:            }
374:
375:            void setupColor(int idx, String caption) {
376:                JColorChooser jcd = new JColorChooser();
377:                Color newColor = jcd.showDialog(this , caption,
378:                        (Color) wizardColours.elementAt(idx));
379:                if (newColor != null)
380:                    wizardColours.setElementAt(newColor, idx);
381:                updatePanel();
382:            }
383:
384:            public Color getColor(int clrIdx) {
385:                return (Color) wizardColours.elementAt(clrIdx);
386:            }
387:
388:            void headingsLabel_mouseClicked(MouseEvent e) {
389:                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == 0)
390:                    setupColor(COLOR_HEADING, "Headings Colour");
391:                else
392:                    setupColor(COLOR_BKGROUND, "Background Colour");
393:            }
394:
395:            void subheadingsLabel_mouseClicked(MouseEvent e) {
396:                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == 0)
397:                    setupColor(COLOR_SUBHEADING, "Sub Headings Colour");
398:                else
399:                    setupColor(COLOR_BKGROUND, "Background Colour");
400:            }
401:
402:            void bodyTextArea_mouseClicked(MouseEvent e) {
403:                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == 0)
404:                    setupColor(COLOR_BODYTEXT, "Body Text Colour");
405:                else
406:                    setupColor(COLOR_BKGROUND, "Background Colour");
407:            }
408:
409:            void hintLabel_mouseClicked(MouseEvent e) {
410:                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == 0)
411:                    setupColor(COLOR_CAPTION, "Hints Colour");
412:                else
413:                    setupColor(COLOR_BKGROUND, "Background Colour");
414:            }
415:
416:            void codeLabel_mouseClicked(MouseEvent e) {
417:                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == 0)
418:                    setupColor(COLOR_CODE, "Code Colour");
419:                else
420:                    setupColor(COLOR_BKGROUND, "Background Colour");
421:            }
422:
423:            void lineColour_mouseClicked(MouseEvent e) {
424:                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == 0)
425:                    setupColor(COLOR_LINE, "Line Colour");
426:                else
427:                    setupColor(COLOR_LINE, "Line Colour");
428:            }
429:
430:            void buttonA_mouseClicked(MouseEvent e) {
431:                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == 0)
432:                    setupColor(COLOR_BTNTEXT, "Button Colour");
433:                else
434:                    setupColor(COLOR_BTNFACE, "Button Background Colour");
435:            }
436:
437:            void buttonB_mouseClicked(MouseEvent e) {
438:                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == 0)
439:                    setupColor(COLOR_BTNTEXT, "Button Colour");
440:                else
441:                    setupColor(COLOR_BTNFACE, "Button Background Colour");
442:            }
443:
444:            void placeHolderPanel_mouseClicked(MouseEvent e) {
445:                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == 0)
446:                    setupColor(COLOR_PLACEHOLDER, "Placeholder Colour");
447:                else
448:                    setupColor(COLOR_PLACEHOLDER, "Placeholder Colour");
449:            }
450:
451:            void schemeList_actionPerformed(ActionEvent e) {
452:                int selIdx = schemeList.getSelectedIndex();
453:                useColorScheme(selIdx);
454:                updatePanel();
455:            }
456:
457:            public void useColorScheme(int idx) {
458:                Color[] colorScheme = profScheme;
459:                switch (idx) {
460:                case PROFESSION_SCHEME:
461:                    colorScheme = profScheme;
462:                    break;
463:
464:                case CASUAL_SCHEME:
465:                    colorScheme = casualScheme;
466:                    break;
467:
468:                case HIGHCONTRAST_SCHEME:
469:                    colorScheme = highContrastScheme;
470:                    break;
471:
472:                case SYSTEM_SCHEME:
473:                default:
474:                    colorScheme = systemScheme;
475:                    break;
476:                }
477:
478:                wizardColours.clear();
479:                for (int i = 0; i < NUM_COLORS_PER_SCHEME; i++) {
480:                    wizardColours.addElement(colorScheme[i]);
481:                }
482:            }
483:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.