Source Code Cross Referenced for CompoundIcon.java in  » Database-Client » iSQL-Viewer » org » isqlviewer » 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 » Database Client » iSQL Viewer » org.isqlviewer.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the Mozilla Public License
003:         * Version 1.1 (the "License"); you may not use this file except in
004:         * compliance with the License. You may obtain a copy of the License at
005:         * http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009:         * License for the specific language governing rights and limitations
010:         * under the License.
011:         * 
012:         * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013:         *
014:         * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015:         * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016:         *
017:         * Contributor(s): 
018:         *  Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019:         *  
020:         * If you didn't download this code from the following link, you should check
021:         * if you aren't using an obsolete version: http://www.isqlviewer.com
022:         */
023:        package org.isqlviewer.swing;
024:
025:        import java.awt.Component;
026:        import java.awt.Graphics;
027:
028:        import javax.swing.Icon;
029:
030:        /**
031:         * Simple Icon implementation of using two existing icons as one side by side.
032:         * <p>
033:         * 
034:         * @author Mark A. Kobold
035:         * @version 1.0
036:         */
037:        public class CompoundIcon implements  Icon {
038:
039:            private static int lastX = 0;
040:            private static int lastY = 0;
041:
042:            protected Icon right;
043:            protected int iconGap = 2;
044:            protected Icon left;
045:
046:            /**
047:             * Default constructor for this object.
048:             * <p>
049:             * Either parameter for this method can be null if need be however if both icons are null this won't show much ?
050:             * 
051:             * @param leftIcon icon to be shown on the left side.
052:             * @param rightIcon icon to be shown on the right side.
053:             */
054:            public CompoundIcon(Icon leftIcon, Icon rightIcon) {
055:
056:                left = leftIcon;
057:                right = rightIcon;
058:            }
059:
060:            /**
061:             * @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics, int, int)
062:             */
063:            public void paintIcon(Component c, Graphics g, int x, int y) {
064:
065:                lastX = x;
066:                lastY = y;
067:                if (left != null)
068:                    left.paintIcon(c, g, x, y);
069:
070:                if (right != null) {
071:                    int l = (left == null ? 0 : (left.getIconWidth() + iconGap));
072:                    right.paintIcon(c, g, x + l, y);
073:                }
074:            }
075:
076:            /**
077:             * @see javax.swing.Icon#getIconWidth()
078:             */
079:            public int getIconWidth() {
080:
081:                int l = (left == null ? 0 : left.getIconWidth());
082:                int r = (right == null ? 0 : right.getIconWidth());
083:                return l + r + iconGap;
084:            }
085:
086:            /**
087:             * @see javax.swing.Icon#getIconHeight()
088:             */
089:            public int getIconHeight() {
090:
091:                int l = (left == null ? 0 : left.getIconHeight());
092:                int r = (right == null ? 0 : right.getIconHeight());
093:
094:                return Math.max(r, l);
095:            }
096:
097:            /**
098:             * Returns the instance of the icon drawn on thr right side.
099:             * <p>
100:             * 
101:             * @return Icon shown on the right.
102:             */
103:            public Icon getRightIcon() {
104:
105:                return right;
106:            }
107:
108:            /**
109:             * Returns the instance of the icon drawn on thr left side.
110:             * <p>
111:             * 
112:             * @return Icon shown on the left.
113:             */
114:            public Icon getLeftIcon() {
115:
116:                return left;
117:            }
118:
119:            /**
120:             * Replaces the icon on the right side.
121:             * <p>
122:             * 
123:             * @param Icon to be shown on the right.
124:             */
125:            public void setRightIcon(Icon icon) {
126:
127:                right = icon;
128:            }
129:
130:            /**
131:             * Replaces the icon on the left side.
132:             * <p>
133:             * 
134:             * @param Icon to be shown on the left.
135:             */
136:            public void setLeftIcon(Icon icon) {
137:
138:                left = icon;
139:            }
140:
141:            /**
142:             * This method is used to see if the relative coordinates are contained in the left icon.
143:             * <p>
144:             * If the left icon is null this method will always return false.
145:             * 
146:             * @param x relative x coordinate of this compond icon.
147:             * @param y relative y coordinate of this compond icon.
148:             * @return boolean if x and y are within the bounds of the left icon.
149:             */
150:            public boolean isOverIcon(int x, int y) {
151:
152:                int w = (left == null ? 0 : left.getIconWidth());
153:                int h = (left == null ? 0 : left.getIconHeight());
154:
155:                if (!((x >= lastX) && (x <= (lastX + w))))
156:                    return false;
157:                if (!((y >= lastY) && (y <= (lastX + h))))
158:                    return false;
159:
160:                return true;
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.