Source Code Cross Referenced for DialogTools.java in  » GIS » openjump » de » fho » jump » pirol » ui » tools » 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 » GIS » openjump » de.fho.jump.pirol.ui.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 17.03.2005 for PIROL
003:         *
004:         * SVN header information:
005:         *  $Author: javamap $
006:         *  $Rev: 856 $
007:         *  $Date: 2007-06-18 21:15:27 -0700 (Mon, 18 Jun 2007) $
008:         *  $Id: DialogTools.java 856 2007-06-19 04:15:27Z javamap $
009:         */
010:        package de.fho.jump.pirol.ui.tools;
011:
012:        import java.awt.Component;
013:        import java.awt.Dimension;
014:        import java.awt.GridLayout;
015:        import java.awt.Window;
016:        import java.text.DecimalFormatSymbols;
017:        import java.util.ArrayList;
018:        import java.util.List;
019:
020:        import javax.swing.JComponent;
021:        import javax.swing.JLabel;
022:        import javax.swing.JPanel;
023:
024:        import com.vividsolutions.jump.workbench.ui.GUIUtil;
025:
026:        import de.fho.jump.pirol.utilities.apiTools.ToolToMakeYourLifeEasier;
027:
028:        /**
029:         * @author <strong>Ole Rahn, Stefan Ostermann, Carsten Schulze</strong>
030:         * <br>
031:         * <br>FH Osnabrück - University of Applied Sciences Osnabrück
032:         * <br>Project PIROL 2005
033:         * <br>Daten- und Wissensmanagement
034:         * 
035:         * @since 1.2: changed by Stefan Ostermann at 2005-04-26: added method to return localized
036:         * string of a double value.
037:         * @since <br>1.3 changed by Carsten Schulze at 2005-05-22: added a method to 
038:         * center a given AWT-Window (or subclasses) on the screen.
039:         * @version $Rev: 856 $
040:         */
041:        public class DialogTools extends ToolToMakeYourLifeEasier {
042:
043:            /**
044:             * This method centers the window (or subclasses of it) on the screen.
045:             * @param window the java.awt.Window (or a subclass of it) that should be 
046:             * displayed in the middle of the screen. 
047:             */
048:            public static void centerOnScreen(Window window) {
049:                //        Dimension screenDim = window.getToolkit().getScreenSize();
050:                //        Dimension windowDim = window.getSize();
051:                //        int x = (screenDim.width / 2) - (windowDim.width / 2);
052:                //        int y = (screenDim.height / 2) - (windowDim.height / 2);
053:                //        
054:                //        window.setLocation(x,y);
055:
056:                GUIUtil.centreOnScreen(window);
057:            }
058:
059:            public static void centerOnWindow(Component component) {
060:                GUIUtil.centreOnWindow(component);
061:            }
062:
063:            public static void centerOnWindow(Component component2move,
064:                    Component component2CenterOn) {
065:                GUIUtil.centre(component2move, component2CenterOn);
066:            }
067:
068:            /**
069:             * This method creates a JPanel with several JLabels on it. For another 
070:             * method to display multiline bold text, have a look at the 
071:             * {javax.swing.JTextArea} and the {@link java.awt.Font} object.
072:             * @param text the text to split up into some JLabels.
073:             * @param charsPerLine the maximum number of characters per line text.
074:             * @return the panel with the labels on it.
075:             */
076:            public static JPanel getPanelWithLabels(String text,
077:                    int charsPerLine) {
078:                List<String> labelTextParts = new ArrayList<String>();
079:                if (text.length() > charsPerLine) {
080:                    int estimatedStrings = (int) Math.ceil((float) text
081:                            .length()
082:                            / charsPerLine);
083:
084:                    String copyLabelText = text.toString();
085:                    for (int i = 0; i < estimatedStrings; i++) {
086:                        if (copyLabelText.indexOf(" ", charsPerLine) > -1)
087:                            labelTextParts.add(copyLabelText
088:                                    .substring(0, copyLabelText.indexOf(" ",
089:                                            charsPerLine) + 1));
090:                        else
091:                            labelTextParts.add(copyLabelText);
092:                        copyLabelText = copyLabelText
093:                                .substring(((String) labelTextParts.get(i))
094:                                        .length());
095:                    }
096:
097:                } else {
098:                    labelTextParts.add(text);
099:                }
100:
101:                JPanel texts = new JPanel();
102:                GridLayout gl = new GridLayout(labelTextParts.size(), 1);
103:                gl.setHgap(0);
104:                texts.setLayout(gl);
105:                //texts.setPreferredSize( new Dimension(400, 50));
106:                for (int i = 0; i < labelTextParts.size(); i++) {
107:                    texts.add(new JLabel("  " + labelTextParts.get(i) + "  "));
108:                }
109:                texts.doLayout();
110:                return texts;
111:            }
112:
113:            /**
114:             * This method replaces the localized decimal seperator with a dot.
115:             * @param s the String containing the double value.
116:             * @return the now dotted double value.
117:             * @see #numberStringToLocalNumberString(String)
118:             * @see #numberToLocalNumberString(double)
119:             */
120:            public static double localNumberStringToDouble(String s) {
121:                DecimalFormatSymbols ds = new DecimalFormatSymbols();
122:                s = s.replace(ds.getDecimalSeparator(), '.');
123:                return Double.parseDouble(s);
124:            }
125:
126:            /**
127:             * This method replaces the dot with the localized decimal seperator.
128:             * @param s the String containing the double value.
129:             * @return the localized String containing the double value.
130:             * @see #localNumberStringToDouble(String)
131:             * @see #numberToLocalNumberString(double)
132:             */
133:            public static String numberStringToLocalNumberString(String s) {
134:                DecimalFormatSymbols ds = new DecimalFormatSymbols();
135:                s = s.replace('.', ds.getDecimalSeparator());
136:                return s;
137:            }
138:
139:            /**
140:             * This method replaces the dot with the localized decimal seperator.
141:             * @param number the double value.
142:             * @return the localized String containing the double value.
143:             * @see #numberStringToLocalNumberString(String)
144:             * @see #localNumberStringToDouble(String)
145:             */
146:            public static String numberToLocalNumberString(double number) {
147:                String s = new Double(number).toString();
148:                return DialogTools.numberStringToLocalNumberString(s);
149:            }
150:
151:            /**
152:             * Sets the prefered width of an JComponent and keeps it prefered height.
153:             * @param component the component to alter
154:             * @param width the new prefered width
155:             */
156:            public static void setPreferedWidth(JComponent component, int width) {
157:                int preferedHeight = component.getPreferredSize().height;
158:                component
159:                        .setPreferredSize(new Dimension(width, preferedHeight));
160:            }
161:
162:            /**
163:             * Sets the prefered height of an JComponent and keeps it prefered height.
164:             * @param component the component to alter
165:             * @param height the new prefered width
166:             */
167:            public static void setPreferedHeight(JComponent component,
168:                    int height) {
169:                int preferedWidth = component.getPreferredSize().width;
170:                component
171:                        .setPreferredSize(new Dimension(preferedWidth, height));
172:            }
173:
174:            public static void setMaximumWidth(JComponent component, int width) {
175:                int preferedHeight = component.getPreferredSize().height;
176:                component.setMaximumSize(new Dimension(width, preferedHeight));
177:            }
178:
179:            public static void setMaximumHeight(JComponent component, int height) {
180:                int preferedWidth = component.getPreferredSize().width;
181:                component.setMaximumSize(new Dimension(preferedWidth, height));
182:            }
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.