Source Code Cross Referenced for PrefuseConfig.java in  » Database-Client » prefuse » prefuse » util » 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 » prefuse » prefuse.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package prefuse.util;
002:
003:        import java.io.IOException;
004:        import java.util.Properties;
005:        import java.util.logging.FileHandler;
006:        import java.util.logging.Handler;
007:        import java.util.logging.Logger;
008:        import java.util.logging.SimpleFormatter;
009:
010:        import prefuse.util.io.IOLib;
011:
012:        /**
013:         * <p>Runtime configuration settings for the prefuse framework. Maintains a set
014:         * of hardwired configuration settings that can be overrriden by creating a
015:         * text proeprties file containing custom values. By default, prefuse will
016:         * look for the file "prefuse.conf" in the current working directory for
017:         * configuration name/value pairs. The framework can be instructed to look for
018:         * a different file by putting the full path to the file into the
019:         * "prefuse.config" System property (for example by using a -D flag at the
020:         * Java runtime command line).</p>
021:         * 
022:         * <p>
023:         * Some of the supported configuration properties include:
024:         * <ul>
025:         * <li><code>activity.threadPriority</code> - the thread priority of the
026:         * ActivityManager thread. The value should be between 1 and 10, with 5 being
027:         * the standard Java default. The default prefuse setting is 6.</li>
028:         * <li><code>data.io.worker.threadPriority</code> - the thread priority of
029:         * asynchronous database worker threads. The default prefuse setting is 5
030:         * (same as the Java thread default).</li>
031:         * <li><code>data.filter.optimizeThreshold</code> - the minimum number of items
032:         * that must be contained in a table for optimized query plans to be
033:         * considered. The default value is 300.</li>
034:         * <li><code>util.logdir</code> - the directory in which to write prefuse log
035:         * files. The default is "null" which defaults logging output to standard
036:         * output.</li> 
037:         * <li><code>util.logfile</code> - the filename pattern to use for naming
038:         * prefuse log files. The default is "prefuse_log_%g.txt", where the %g
039:         * indicates a unique number for the log file.</li>
040:         * </ul>
041:         * </p>
042:         * 
043:         * <p>
044:         * Application creators are welcome to add their own custom properties
045:         * to the configuration files and use the PrefuseConfig instance to
046:         * access those properties. This class is a singleton, accessed through
047:         * a static accessor method.
048:         * </p>
049:         *  
050:         * @author <a href="http://jheer.org">jeffrey heer</a>
051:         */
052:        public class PrefuseConfig extends Properties {
053:
054:            private static final Logger s_logger = Logger
055:                    .getLogger(PrefuseConfig.class.getName());
056:
057:            private static final PrefuseConfig s_config = new PrefuseConfig();
058:
059:            /**
060:             * Get the global PrefuseConfig instance.
061:             * @return the configuration instance
062:             */
063:            public static PrefuseConfig getConfig() {
064:                return s_config;
065:            }
066:
067:            private PrefuseConfig() {
068:                setDefaults();
069:
070:                String configFile;
071:                try {
072:                    configFile = System.getProperty("prefuse.config");
073:                } catch (Exception e) {
074:                    // in applet mode, we could run afoul of the security manager
075:                    configFile = null;
076:                }
077:                if (configFile == null)
078:                    configFile = "prefuse.conf";
079:                try {
080:                    load(IOLib.streamFromString(configFile));
081:                    s_logger.info("Loaded config file: " + configFile);
082:                } catch (Exception e) {
083:                    // do nothing, just go with the defaults
084:                }
085:
086:                // direct logging file directory, as set by config properties
087:                // default of java.util.Logger is to output to standard error
088:                String logdir = getProperty("util.logdir");
089:                String logfile = getProperty("util.logfile");
090:                if (logdir != null) {
091:                    try {
092:                        Logger logger = Logger.getLogger("prefuse");
093:                        logger.setUseParentHandlers(false);
094:                        Handler fileHandler = new FileHandler(logdir + "/"
095:                                + logfile);
096:                        fileHandler.setFormatter(new SimpleFormatter());
097:                        logger.addHandler(fileHandler);
098:                    } catch (IOException e) {
099:                        e.printStackTrace();
100:                    }
101:                }
102:            }
103:
104:            /**
105:             * Get a prefuse configuration property.
106:             * @param key the name of the property to lookup
107:             * @return the property value, or null if the key is not found
108:             */
109:            public static String get(String key) {
110:                return s_config.getProperty(key);
111:            }
112:
113:            /**
114:             * Get a prefuse configuration property as an integer.
115:             * @param key the name of the property to lookup
116:             * @return the property value, or the minimum possible
117:             * integer value if the key is not found or parsing
118:             * of the number fails.
119:             */
120:            public static int getInt(String key) {
121:                String val = s_config.getProperty(key);
122:                try {
123:                    return Integer.parseInt(val);
124:                } catch (NumberFormatException nfe) {
125:                    return Integer.MIN_VALUE;
126:                }
127:            }
128:
129:            /**
130:             * Get a prefuse configuration property as a long.
131:             * @param key the name of the property to lookup
132:             * @return the property value, or the minimum possible
133:             * long value if the key is not found or parsing
134:             * of the number fails.
135:             */
136:            public static long getLong(String key) {
137:                String val = s_config.getProperty(key);
138:                try {
139:                    return Long.parseLong(val);
140:                } catch (NumberFormatException nfe) {
141:                    return Long.MIN_VALUE;
142:                }
143:            }
144:
145:            /**
146:             * Get a prefuse configuration property as a float.
147:             * @param key the name of the property to lookup
148:             * @return the property value, or a Float.NaN
149:             * value if the key is not found or parsing
150:             * of the number fails.
151:             */
152:            public static float getFloat(String key) {
153:                String val = s_config.getProperty(key);
154:                try {
155:                    return Float.parseFloat(val);
156:                } catch (NumberFormatException nfe) {
157:                    return Float.NaN;
158:                }
159:            }
160:
161:            /**
162:             * Get a prefuse configuration property as a double.
163:             * @param key the name of the property to lookup
164:             * @return the property value, or a Double.NaN
165:             * value if the key is not found or parsing
166:             * of the number fails.
167:             */
168:            public static double getDouble(String key) {
169:                String val = s_config.getProperty(key);
170:                try {
171:                    return Double.parseDouble(val);
172:                } catch (NumberFormatException nfe) {
173:                    return Double.NaN;
174:                }
175:            }
176:
177:            /**
178:             * Get a prefuse configuration property as a boolean.
179:             * @param key the name of the property to lookup
180:             * @return the property value. False is returned
181:             * if the key is not found or does not parse to
182:             * a true/false value.
183:             */
184:            public static boolean getBoolean(String key) {
185:                String val = s_config.getProperty(key);
186:                return "true".equalsIgnoreCase(val);
187:            }
188:
189:            /**
190:             * Sets default values for Prefuse properties
191:             */
192:            private void setDefaults() {
193:                setProperty("size.scale2D", "0.5");
194:                setProperty("activity.threadPriority", "6");
195:                setProperty("data.delimiter", ".");
196:                setProperty("data.graph.nodeGroup", "nodes");
197:                setProperty("data.graph.edgeGroup", "edges");
198:                setProperty("data.visual.fieldPrefix", "_");
199:                setProperty("data.io.worker.threadPriority", String
200:                        .valueOf(Thread.NORM_PRIORITY));
201:
202:                // prefuse will only attempt to optimize filtering operations
203:                // on tables with more rows than this threshold value
204:                setProperty("data.filter.optimizeThreshold", "300");
205:
206:                // setProperty("data.graph.nodeKey", null); // intentionally null
207:                setProperty("data.graph.sourceKey", "source");
208:                setProperty("data.graph.targetKey", "target");
209:                setProperty("data.tree.sourceKey", "parent");
210:                setProperty("data.tree.targetKey", "child");
211:                setProperty("visualization.allItems", "_all_");
212:                setProperty("visualization.focusItems", "_focus_");
213:                setProperty("visualization.selectedItems", "_selected_");
214:                setProperty("visualization.searchItems", "_search_");
215:
216:                // setProperty("util.logdir", null); // intentionally null
217:                setProperty("util.logfile", "prefuse_log_%g.txt");
218:            }
219:
220:        } // end of class PrefuseConfig
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.