001: /*
002: * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of Substance Kirill Grouchnikov nor the names of
015: * its contributors may be used to endorse or promote products derived
016: * from this software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030: package org.jvnet.substance.utils.params;
031:
032: import org.jvnet.substance.SubstanceLookAndFeel;
033: import org.jvnet.substance.utils.SubstanceConstants.ImageWatermarkKind;
034:
035: /**
036: * Reads the properties from JVM flags. This class is <b>for internal use only</b>.
037: *
038: * @author Kirill Grouchnikov
039: */
040: public class JvmFlagsParamReader implements ParamReader {
041: /**
042: * Retrieves a single parameter from the VM flags.
043: *
044: * @param parameterName
045: * Parameter name.
046: * @return Parameter value.
047: */
048: protected String getParameter(String parameterName) {
049: String paramValue = null;
050: try {
051: paramValue = System.getProperty(parameterName);
052: return paramValue;
053: } catch (Exception exc) {
054: // probably running in unsecure JNLP - ignore
055: return null;
056: }
057: }
058:
059: /*
060: * (non-Javadoc)
061: *
062: * @see org.jvnet.substance.utils.params.ParamReader#getButtonShaperProperty()
063: */
064: public String getButtonShaperProperty() {
065: return this
066: .getParameter(SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY);
067: }
068:
069: /*
070: * (non-Javadoc)
071: *
072: * @see org.jvnet.substance.utils.params.ParamReader#getGradientPainterProperty()
073: */
074: public String getGradientPainterProperty() {
075: return this
076: .getParameter(SubstanceLookAndFeel.GRADIENT_PAINTER_PROPERTY);
077: }
078:
079: /*
080: * (non-Javadoc)
081: *
082: * @see org.jvnet.substance.utils.params.ParamReader#getTitlePainterProperty()
083: */
084: public String getTitlePainterProperty() {
085: return this
086: .getParameter(SubstanceLookAndFeel.TITLE_PAINTER_PROPERTY);
087: }
088:
089: /*
090: * (non-Javadoc)
091: *
092: * @see org.jvnet.substance.utils.params.ParamReader#getBorderPainterProperty()
093: */
094: public String getBorderPainterProperty() {
095: return this
096: .getParameter(SubstanceLookAndFeel.BORDER_PAINTER_PROPERTY);
097: }
098:
099: /*
100: * (non-Javadoc)
101: *
102: * @see org.jvnet.substance.utils.params.ParamReader#getThemeProperty()
103: */
104: public String getThemeProperty() {
105: return this .getParameter(SubstanceLookAndFeel.THEME_PROPERTY);
106: }
107:
108: /*
109: * (non-Javadoc)
110: *
111: * @see org.jvnet.substance.utils.params.ParamReader#getWatermarkThemeProperty()
112: */
113: public String getWatermarkProperty() {
114: return this
115: .getParameter(SubstanceLookAndFeel.WATERMARK_PROPERTY);
116: }
117:
118: /*
119: * (non-Javadoc)
120: *
121: * @see org.jvnet.substance.utils.params.ParamReader#getWatermarkImageProperty()
122: */
123: public String getWatermarkImageProperty() {
124: return this
125: .getParameter(SubstanceLookAndFeel.WATERMARK_IMAGE_PROPERTY);
126: }
127:
128: /*
129: * (non-Javadoc)
130: *
131: * @see org.jvnet.substance.utils.params.ParamReader#toBleedWatermark()
132: */
133: public boolean toBleedWatermark() {
134: String paramToBleedWatermark = this
135: .getParameter(SubstanceLookAndFeel.WATERMARK_TO_BLEED);
136: return (paramToBleedWatermark != null);
137: }
138:
139: /*
140: * (non-Javadoc)
141: *
142: * @see org.jvnet.substance.utils.params.ParamReader#getTraceFileNameProperty()
143: */
144: public String getTraceFileNameProperty() {
145: return this .getParameter(SubstanceLookAndFeel.TRACE_FILE);
146: }
147:
148: /*
149: * (non-Javadoc)
150: *
151: * @see org.jvnet.substance.utils.params.ParamReader#toShowExtraElementProperty()
152: */
153: public boolean toShowExtraElementProperty() {
154: String paramNoExtraElements = this
155: .getParameter(SubstanceLookAndFeel.NO_EXTRA_ELEMENTS);
156: return (paramNoExtraElements == null);
157: }
158:
159: /*
160: * (non-Javadoc)
161: *
162: * @see org.jvnet.substance.utils.params.ParamReader#toShowHeapStatusPanelProperty()
163: */
164: public String toShowHeapStatusPanelProperty() {
165: return this
166: .getParameter(SubstanceLookAndFeel.HEAP_STATUS_PANEL);
167: }
168:
169: /**
170: * Returns the configuration filename.
171: *
172: * @return Configuration filename.
173: * @see PropertiesFileParamReader
174: * @see SubstanceLookAndFeel#CONFIG_FILE
175: */
176: public String getConfigFileName() {
177: return this .getParameter(SubstanceLookAndFeel.CONFIG_FILE);
178: }
179:
180: /*
181: * (non-Javadoc)
182: *
183: * @see org.jvnet.substance.utils.params.ParamReader#toEnableInvertedThemes()
184: */
185: public boolean toEnableInvertedThemes() {
186: String paramEnableInvertedThemes = this
187: .getParameter(SubstanceLookAndFeel.ENABLE_INVERTED_THEMES);
188: return (paramEnableInvertedThemes != null);
189: }
190:
191: /*
192: * (non-Javadoc)
193: *
194: * @see org.jvnet.substance.utils.params.ParamReader#toEnableNegatedThemes()
195: */
196: public boolean toEnableNegatedThemes() {
197: String paramEnableNegatedThemes = this
198: .getParameter(SubstanceLookAndFeel.ENABLE_NEGATED_THEMES);
199: return (paramEnableNegatedThemes != null);
200: }
201:
202: /*
203: * (non-Javadoc)
204: *
205: * @see org.jvnet.substance.utils.params.ParamReader#isDebugUiMode()
206: */
207: public boolean isDebugUiMode() {
208: String paramDebugUiMode = this
209: .getParameter(SubstanceLookAndFeel.DEBUG_UI_MODE);
210: return (paramDebugUiMode != null);
211: }
212:
213: /*
214: * (non-Javadoc)
215: *
216: * @see org.jvnet.substance.utils.params.ParamReader#getWatermarkImageKindProperty()
217: */
218: public ImageWatermarkKind getWatermarkImageKindProperty() {
219: String paramWatermarkImageKind = this
220: .getParameter(SubstanceLookAndFeel.WATERMARK_IMAGE_KIND);
221: if (paramWatermarkImageKind == null)
222: return null;
223: return ImageWatermarkKind.valueOf(paramWatermarkImageKind);
224: }
225:
226: /*
227: * (non-Javadoc)
228: *
229: * @see org.jvnet.substance.utils.params.ParamReader#getWatermarkImageOpacityProperty()
230: */
231: public Float getWatermarkImageOpacityProperty() {
232: String paramWatermarkImageOpacity = this
233: .getParameter(SubstanceLookAndFeel.WATERMARK_IMAGE_OPACITY);
234: if (paramWatermarkImageOpacity == null)
235: return null;
236: try {
237: return Float.parseFloat(paramWatermarkImageOpacity);
238: } catch (NumberFormatException nfe) {
239: return null;
240: }
241: }
242: }
|