Source Code Cross Referenced for AWTUtil.java in  » Web-Framework » RSF » uk » org » ponder » swingutil » 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 » Web Framework » RSF » uk.org.ponder.swingutil 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 21-Sep-2003
003:         */
004:        package uk.org.ponder.swingutil;
005:
006:        import java.awt.RenderingHints;
007:
008:        import java.awt.Color;
009:        import java.awt.Component;
010:        import java.awt.Container;
011:        import java.awt.FlowLayout;
012:        import java.awt.Graphics;
013:        import java.awt.Rectangle;
014:        import java.awt.Graphics2D;
015:
016:        import javax.swing.BoxLayout; // QQQQQ this can probably be done without Swing
017:        import javax.swing.JPanel;
018:
019:        /**
020:         * A collection of small utility methods useful in dealing with the AWT GUI libraries.
021:         * @author Bosmon
022:         */
023:
024:        public class AWTUtil {
025:            public static void labelledOutLayer(Container parent,
026:                    Component[] labels, Component[] labelled,
027:                    LayoutSpec layoutspec) {
028:                GBLWrap gblw = new GBLWrap(parent);
029:                for (int i = 0; i < labels.length; ++i) {
030:                    if (i == labels.length - 1) {
031:                        gblw.endcol();
032:                    }
033:                    gblw.apply(labels[i], "l");
034:                    if (i == labels.length - 1) {
035:                        gblw.endcol();
036:                    }
037:                    Component righty = labelled[i];
038:                    if (righty instanceof  JPanel) {
039:                        ((JPanel) righty).add(layoutspec.getStrut());
040:                    } else {
041:                        JPanel newpanel = layoutspec.getPanel();
042:                        newpanel.add(righty);
043:                        righty = newpanel;
044:                    }
045:                    gblw.endrow().apply(righty, "l");
046:                }
047:
048:            }
049:
050:            public static void flowOutLayer(Container parent,
051:                    Component[] labels, Component[] labelled,
052:                    LayoutSpec layoutspec) {
053:                parent.setLayout(new BoxLayout(parent, BoxLayout.Y_AXIS));
054:                for (int i = 0; i < labels.length; ++i) {
055:                    JPanel rowpanel = new JPanel(new FlowLayout(
056:                            FlowLayout.LEFT, 0, 0));
057:                    rowpanel.add(labels[i]);
058:                    rowpanel.add(labelled[i]);
059:                    rowpanel.add(layoutspec.getStrut());
060:                    parent.add(rowpanel);
061:                }
062:            }
063:
064:            public static void fillRect(Graphics g, int x1, int y1, int width,
065:                    int height) {
066:                if (width < 0) {
067:                    x1 = x1 + width;
068:                    width = -width;
069:                }
070:                if (height < 0) {
071:                    y1 = y1 + height;
072:                    height = -height;
073:                }
074:                g.fillRect(x1, y1, width, height);
075:            }
076:
077:            public static void drawRect(Graphics g, int x1, int y1, int width,
078:                    int height) {
079:                if (width < 0) {
080:                    x1 = x1 + width;
081:                    width = -width;
082:                }
083:                if (height < 0) {
084:                    y1 = y1 + height;
085:                    height = -height;
086:                }
087:                g.drawRect(x1, y1, width, height);
088:            }
089:
090:            public static double colorToLuminance(Color c) {
091:                //      System.out.println(c.toString());
092:                double luminance = (0.212671 * c.getRed() + 0.715160
093:                        * c.getGreen() + 0.072169 * c.getBlue()) / 255;
094:                //      System.out.println("" + luminance);
095:                return luminance;
096:            }
097:
098:            public static void setClipBounds(Graphics g, Rectangle toset) {
099:                g.setClip(toset.x, toset.y, toset.width, toset.height);
100:            }
101:
102:            /** Sets the clip bounds of the specified graphics context to the intersection of the
103:             * two supplied clip bounds.
104:             * @param g The graphics object for which the clip bounds are to be adjusted.
105:             * @param origbounds The first rectangle to be intersected (the original OS clip
106:             * bounds)
107:             * @param toset The second rectangle to be intersected.
108:             */
109:            public static void setClipBounds(Graphics g, Rectangle origbounds,
110:                    Rectangle toset) {
111:                Rectangle intersect = origbounds.intersection(toset);
112:                setClipBounds(g, intersect);
113:            }
114:
115:            public static void expandRectangle(Rectangle toexpand, int amount) {
116:                toexpand.x -= amount;
117:                toexpand.y -= amount;
118:                toexpand.width += 2 * amount;
119:                toexpand.height += 2 * amount;
120:            }
121:
122:            public static void antiAlias(Graphics2D graphics, boolean state) {
123:                graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
124:                        state ? RenderingHints.VALUE_ANTIALIAS_ON
125:                                : RenderingHints.VALUE_ANTIALIAS_OFF);
126:
127:            }
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.