001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * CasaCustomizer.java
044: *
045: * Created on January 26, 2007, 2:56 PM
046: *
047: * To change this template, choose Tools | Template Manager
048: * and open the template in the editor.
049: */
050:
051: package org.netbeans.modules.compapp.casaeditor.graph;
052:
053: import java.awt.Color;
054: import java.awt.Font;
055: import java.util.LinkedHashMap;
056: import java.util.prefs.Preferences;
057: import org.netbeans.api.visual.widget.LayerWidget;
058: import org.netbeans.api.visual.widget.Scene;
059:
060: import org.netbeans.api.visual.widget.Widget;
061: import org.netbeans.modules.compapp.casaeditor.design.CasaModelGraphScene;
062: import org.netbeans.modules.compapp.casaeditor.graph.awt.GradientRectangleColorScheme;
063:
064: /**
065: *
066: * @author rdara
067: */
068: public class CasaCustomizer {
069:
070: private static final String S_COLOR_REGION_BINDING = "COLOR_REGION_BINDING"; // NOI18N
071: private static final String S_COLOR_REGION_ENGINE = "COLOR_REGION_ENGINE"; // NOI18N
072: private static final String S_COLOR_REGION_EXTERNAL = "COLOR_REGION_EXTERNAL"; // NOI18N
073:
074: private static final String S_COLOR_SU_INTERNAL_BORDER = "COLOR_SU_INTERNAL_BORDER"; // NOI18N
075: private static final String S_COLOR_SU_INTERNAL_TITLE = "COLOR_SU_INTERNAL_TITLE"; // NOI18N
076: private static final String S_COLOR_SU_INTERNAL_BACKGROUND = "COLOR_SU_INTERNAL_BACKGROUND"; // NOI18N
077: private static final String S_COLOR_SU_INTERNAL_PIN = "COLOR_SU_INTERNAL_PIN"; // NOI18N
078:
079: private static final String S_COLOR_SU_EXTERNAL_BORDER = "COLOR_SU_EXTERNAL_BORDER"; // NOI18N
080: private static final String S_COLOR_SU_EXTERNAL_TITLE = "COLOR_SU_EXTERNAL_TITLE"; // NOI18N
081: private static final String S_COLOR_SU_EXTERNAL_BACKGROUND = "COLOR_SU_EXTERNAL_BACKGROUND"; // NOI18N
082: private static final String S_COLOR_SU_EXTERNAL_PIN = "COLOR_SU_EXTERNAL_PIN"; // NOI18N
083:
084: private static final String S_COLOR_BC_TITLE = "COLOR_BC_TITLE"; // NOI18N
085: private static final String S_COLOR_BC_BACKGROUND = "COLOR_BC_BACKGROUND"; // NOI18N
086: private static final String S_COLOR_BC_BORDER = "COLOR_BC_BORDER"; // NOI18N
087: private static final String S_COLOR_BC_TITLE_BACKGROUND = "COLOR_BC_TITLE_BACKGROUND"; // NOI18N
088: private static final String S_COLOR_BC_LABEL = "COLOR_BC_LABEL"; // NOI18N
089:
090: private static final String S_COLOR_SELECTION = "COLOR_SELECTION"; // NOI18N
091:
092: private static final String S_COLOR_CONNECTION_NORMAL = "COLOR_CONNECTION_NORMAL"; // NOI18N
093: private static final String S_COLOR_CONNECTION_HOVERED = "COLOR_CONNECTION_HOVERED"; // NOI18N
094:
095: private static final String S_COLOR_BC_REGION_TITLE = "COLOR_BC_REGION_TITLE"; // NOI18N
096: private static final String S_COLOR_SU_REGION_TITLE = "COLOR_SU_REGION_TITLE"; // NOI18N
097: private static final String S_COLOR_EXT_SU_REGION_TITLE = "COLOR_EXT_SU_REGION_TITLE"; // NOI18N
098:
099: private static final String S_FONT_BC_REGION_TITLE = "FONT_BC_REGION_TITLE"; // NOI18N
100: private static final String S_FONT_SU_REGION_TITLE = "FONT_SU_REGION_TITLE"; // NOI18N
101: private static final String S_FONT_EXT_SU_REGION_TITLE = "FONT_EXT_SU_REGION_TITLE"; // NOI18N
102:
103: private static final String S_FONT_BC_TITLE = "FONT_BC_TITLE"; // NOI18N
104: private static final String S_FONT_BC_LABEL = "FONT_BC_LABEL"; // NOI18N
105: private static final String S_FONT_SU_TITLE = "FONT_SU_TITLE"; // NOI18N
106: private static final String S_FONT_SU_PIN = "FONT_SU_PIN"; // NOI18N
107:
108: private static final String S_FONT_EXT_SU_TITLE = "FONT_EXT_SU_TITLE"; // NOI18N
109: private static final String S_FONT_EXT_SU_PIN = "FONT_EXT_SU_PIN"; // NOI18N
110:
111: public static final String PROPERTY_CHANGE = "Customizer_Property_Changed"; // NOI18N
112:
113: //private Font FONT_BC_HEADER = new Font("Helvetica", Font.BOLD, 14);
114:
115: private LinkedHashMap<String, Color> mColorsMap = new LinkedHashMap<String, Color>();
116: private LinkedHashMap<String, Font> mFontsMap = new LinkedHashMap<String, Font>();
117: private LinkedHashMap<String, GradientRectangleColorScheme> mGradientsMap = new LinkedHashMap<String, GradientRectangleColorScheme>();
118:
119: private static String S_SEPARATOR = ","; // NOI18N
120:
121: /**
122: * Default Lable Font: java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12]
123: * Default Lable color: java.awt.Color[r=0,g=0,b=0]
124: */
125:
126: public LinkedHashMap<String, Color> getColorsMapReference() {
127: return mColorsMap;
128: }
129:
130: public LinkedHashMap<String, Font> getFontsMapReference() {
131: return mFontsMap;
132: }
133:
134: public LinkedHashMap<String, GradientRectangleColorScheme> getGradientsMapReference() {
135: return mGradientsMap;
136: }
137:
138: /** Creates a new instance of CasaCustomizer */
139: public CasaCustomizer() {
140: loadFromPreferences(getPreferences(), false);
141: }
142:
143: private Preferences getPreferences() {
144: String ourNodeName = "/org/netbeans/modules/compapp/casaeditor/graph/CasaCustomizer"; // NOI18N
145: Preferences prefs = Preferences.userRoot().node(ourNodeName);
146: //Preferences prefs = Preferences.systemRoot().node(ourNodeName);
147: return prefs;
148: }
149:
150: public Color getCOLOR_REGION_BINDING() {
151: return mColorsMap.get(S_COLOR_REGION_BINDING);
152: }
153:
154: public void setCOLOR_REGION_BINDING(Color COLOR_REGION_BINDING) {
155: mColorsMap.put(S_COLOR_REGION_BINDING, COLOR_REGION_BINDING);
156: }
157:
158: public Color getCOLOR_REGION_ENGINE() {
159: return mColorsMap.get(S_COLOR_REGION_ENGINE);
160: }
161:
162: public void setCOLOR_REGION_ENGINE(Color COLOR_REGION_ENGINE) {
163: mColorsMap.put(S_COLOR_REGION_ENGINE, COLOR_REGION_ENGINE);
164: }
165:
166: public Color getCOLOR_REGION_EXTERNAL() {
167: return mColorsMap.get(S_COLOR_REGION_EXTERNAL);
168: }
169:
170: public void setCOLOR_REGION_EXTERNAL(Color COLOR_REGION_EXTERNAL) {
171: mColorsMap.put(S_COLOR_REGION_EXTERNAL, COLOR_REGION_EXTERNAL);
172: }
173:
174: public Color getCOLOR_SU_INTERNAL_BORDER() {
175: return mColorsMap.get(S_COLOR_SU_INTERNAL_BORDER);
176: }
177:
178: public void setCOLOR_SU_INTERNAL_BORDER(
179: Color COLOR_SU_INTERNAL_BORDER) {
180: mColorsMap.put(S_COLOR_SU_INTERNAL_BORDER,
181: COLOR_SU_INTERNAL_BORDER);
182: }
183:
184: public Color getCOLOR_SU_INTERNAL_TITLE() {
185: return mColorsMap.get(S_COLOR_SU_INTERNAL_TITLE);
186: }
187:
188: public void setCOLOR_SU_INTERNAL_TITLE(Color COLOR_SU_INTERNAL_TITLE) {
189: mColorsMap.put(S_COLOR_SU_INTERNAL_TITLE,
190: COLOR_SU_INTERNAL_TITLE);
191: }
192:
193: public Color getCOLOR_SU_INTERNAL_BACKGROUND() {
194: return mColorsMap.get(S_COLOR_SU_INTERNAL_BACKGROUND);
195: }
196:
197: public void setCOLOR_SU_INTERNAL_BACKGROUND(
198: Color COLOR_SU_INTERNAL_BACKGROUND) {
199: mColorsMap.put(S_COLOR_SU_INTERNAL_BACKGROUND,
200: COLOR_SU_INTERNAL_BACKGROUND);
201: }
202:
203: public Color getCOLOR_SU_INTERNAL_PIN() {
204: return mColorsMap.get(S_COLOR_SU_INTERNAL_PIN);
205: }
206:
207: public void setCOLOR_SU_INTERNAL_PIN(Color COLOR_SU_INTERNAL_PIN) {
208: mColorsMap.put(S_COLOR_SU_INTERNAL_PIN, COLOR_SU_INTERNAL_PIN);
209: }
210:
211: public Color getCOLOR_SU_EXTERNAL_BORDER() {
212: return mColorsMap.get(S_COLOR_SU_EXTERNAL_BORDER);
213: }
214:
215: public void setCOLOR_SU_EXTERNAL_BORDER(
216: Color COLOR_SU_EXTERNAL_BORDER) {
217: mColorsMap.put(S_COLOR_SU_EXTERNAL_BORDER,
218: COLOR_SU_EXTERNAL_BORDER);
219: }
220:
221: public Color getCOLOR_SU_EXTERNAL_TITLE() {
222: return mColorsMap.get(S_COLOR_SU_EXTERNAL_TITLE);
223: }
224:
225: public void setCOLOR_SU_EXTERNAL_TITLE(Color COLOR_SU_EXTERNAL_TITLE) {
226: mColorsMap.put(S_COLOR_SU_EXTERNAL_TITLE,
227: COLOR_SU_EXTERNAL_TITLE);
228: }
229:
230: public Color getCOLOR_SU_EXTERNAL_BACKGROUND() {
231: return mColorsMap.get(S_COLOR_SU_EXTERNAL_BACKGROUND);
232: }
233:
234: public void setCOLOR_SU_EXTERNAL_BACKGROUND(
235: Color COLOR_SU_EXTERNAL_BACKGROUND) {
236: mColorsMap.put(S_COLOR_SU_EXTERNAL_BACKGROUND,
237: COLOR_SU_EXTERNAL_BACKGROUND);
238: }
239:
240: public Color getCOLOR_SU_EXTERNAL_PIN() {
241: return mColorsMap.get(S_COLOR_SU_EXTERNAL_PIN);
242: }
243:
244: public void setCOLOR_SU_EXTERNAL_PIN(Color COLOR_SU_EXTERNAL_PIN) {
245: mColorsMap.put(S_COLOR_SU_EXTERNAL_PIN, COLOR_SU_EXTERNAL_PIN);
246: }
247:
248: public Color getCOLOR_BC_TITLE() {
249: return mColorsMap.get(S_COLOR_BC_TITLE);
250: }
251:
252: public void setCOLOR_BC_TITLE(Color COLOR_BC_TITLE) {
253: mColorsMap.put(S_COLOR_BC_BACKGROUND, COLOR_BC_TITLE);
254: }
255:
256: public Color getCOLOR_BC_BACKGROUND() {
257: return mColorsMap.get(S_COLOR_BC_BACKGROUND);
258: }
259:
260: public void setCOLOR_BC_BACKGROUND(Color COLOR_BC_BACKGROUND) {
261: mColorsMap.put(S_COLOR_BC_BACKGROUND, COLOR_BC_BACKGROUND);
262: }
263:
264: public Color getCOLOR_BC_TITLE_BACKGROUND() {
265: return mColorsMap.get(S_COLOR_BC_TITLE_BACKGROUND);
266: }
267:
268: public void setCOLOR_BC_TITLE_BACKGROUND(
269: Color COLOR_BC_TITLE_BACKGROUND) {
270: mColorsMap.put(S_COLOR_BC_TITLE_BACKGROUND,
271: COLOR_BC_TITLE_BACKGROUND);
272: }
273:
274: public Color getCOLOR_BC_BORDER() {
275: return mColorsMap.get(S_COLOR_BC_BORDER);
276: }
277:
278: public void setCOLOR_BC_BORDER(Color COLOR_BC_BORDER) {
279: mColorsMap.put(S_COLOR_BC_BORDER, COLOR_BC_BORDER);
280: }
281:
282: public Color getCOLOR_BC_LABEL() {
283: return mColorsMap.get(S_COLOR_BC_LABEL);
284: }
285:
286: public void setCOLOR_BC_LABEL(Color COLOR_BC_LABEL) {
287: mColorsMap.put(S_COLOR_BC_LABEL, COLOR_BC_LABEL);
288: }
289:
290: public Color getCOLOR_HOVERED_EDGE() {
291: return mColorsMap.get(S_COLOR_CONNECTION_HOVERED);
292: }
293:
294: public void setCOLOR_HOVERED_EDGE(Color COLOR_HOVERED_EDGE) {
295: mColorsMap.put(S_COLOR_CONNECTION_HOVERED, COLOR_HOVERED_EDGE);
296: }
297:
298: public Color getCOLOR_SELECTION() {
299: return mColorsMap.get(S_COLOR_SELECTION);
300: }
301:
302: public void setCOLOR_SELECTION(Color COLOR_SELECTION) {
303: mColorsMap.put(S_COLOR_SELECTION, COLOR_SELECTION);
304: }
305:
306: public Color getCOLOR_CONNECTION_NORMAL() {
307: return mColorsMap.get(S_COLOR_CONNECTION_NORMAL);
308: }
309:
310: public void setCOLOR_CONNECTION_NORMAL(
311: Color CASA_CONNECTION_COLOR_NORMAL) {
312: mColorsMap.put(S_COLOR_CONNECTION_NORMAL,
313: CASA_CONNECTION_COLOR_NORMAL);
314: }
315:
316: //Region title colors
317: public Color getCOLOR_BC_REGION_TITLE() {
318: return mColorsMap.get(S_COLOR_BC_REGION_TITLE);
319: }
320:
321: public void setCOLOR_BC_REGION_TITLE(Color color) {
322: mColorsMap.put(S_COLOR_BC_REGION_TITLE, color);
323: }
324:
325: public Color getCOLOR_SU_REGION_TITLE() {
326: return mColorsMap.get(S_COLOR_SU_REGION_TITLE);
327: }
328:
329: public void setCOLOR_SU_REGION_TITLE(Color color) {
330: mColorsMap.put(S_COLOR_SU_REGION_TITLE, color);
331: }
332:
333: public Color getCOLOR_EXT_SU_REGION_TITLE() {
334: return mColorsMap.get(S_COLOR_EXT_SU_REGION_TITLE);
335: }
336:
337: public void setCOLOR_EXT_SU_REGION_TITLE(Color color) {
338: mColorsMap.put(S_COLOR_EXT_SU_REGION_TITLE, color);
339: }
340:
341: public Font getFONT_BC_REGION_TITLE() {
342: return mFontsMap.get(S_FONT_BC_REGION_TITLE);
343: }
344:
345: public void setFONT_BC_REGION_TITLE(Font font) {
346: mFontsMap.put(S_FONT_BC_REGION_TITLE, font);
347: }
348:
349: public Font getFONT_SU_REGION_TITLE() {
350: return mFontsMap.get(S_FONT_SU_REGION_TITLE);
351: }
352:
353: public void setFONT_SU_REGION_TITLE(Font font) {
354: mFontsMap.put(S_FONT_SU_REGION_TITLE, font);
355: }
356:
357: public Font getFONT_EXT_SU_REGION_TITLE() {
358: return mFontsMap.get(S_FONT_EXT_SU_REGION_TITLE);
359: }
360:
361: public void setFONT_EXT_SU_REGION_TITLE(Font font) {
362: mFontsMap.put(S_FONT_EXT_SU_REGION_TITLE, font);
363: }
364:
365: public Font getFONT_BC_HEADER() {
366: return mFontsMap.get(S_FONT_BC_TITLE);
367: }
368:
369: public void setFONT_BC_HEADER(Font font) {
370: mFontsMap.put(S_FONT_BC_TITLE, font);
371: }
372:
373: public Font getFONT_BC_LABEL() {
374: return mFontsMap.get(S_FONT_BC_LABEL);
375: }
376:
377: public void setFONT_BC_LABEL(Font font) {
378: mFontsMap.put(S_FONT_BC_LABEL, font);
379: }
380:
381: public Font getFONT_SU_HEADER() {
382: return mFontsMap.get(S_FONT_SU_TITLE);
383: }
384:
385: public void setFONT_SU_HEADER(Font font) {
386: mFontsMap.put(S_FONT_SU_TITLE, font);
387: }
388:
389: public Font getFONT_SU_PIN() {
390: return mFontsMap.get(S_FONT_SU_PIN);
391: }
392:
393: public void setFONT_SU_PIN(Font font) {
394: mFontsMap.put(S_FONT_SU_PIN, font);
395: }
396:
397: public Font getFONT_EXT_SU_HEADER() {
398: return mFontsMap.get(S_FONT_EXT_SU_TITLE);
399: }
400:
401: public void setFONT_EXT_SU_HEADER(Font font) {
402: mFontsMap.put(S_FONT_EXT_SU_TITLE, font);
403: }
404:
405: public Font getFONT_EXT_SU_PIN() {
406: return mFontsMap.get(S_FONT_EXT_SU_PIN);
407: }
408:
409: public void setFONT_EXT_SU_PIN(Font font) {
410: mFontsMap.put(S_FONT_EXT_SU_PIN, font);
411: }
412:
413: public GradientRectangleColorScheme getGradientINT_SU_BACKGROUND() {
414: return mGradientsMap.get(S_COLOR_SU_INTERNAL_BACKGROUND);
415: }
416:
417: public GradientRectangleColorScheme getGradientEXT_SU_BACKGROUND() {
418: return mGradientsMap.get(S_COLOR_SU_EXTERNAL_BACKGROUND);
419: }
420:
421: public GradientRectangleColorScheme getGradientBC_TITLE_BACKGROUND() {
422: return mGradientsMap.get(S_COLOR_BC_TITLE_BACKGROUND);
423: }
424:
425: public void renderCasaDesignView(CasaModelGraphScene scene) {
426: changeBindingRegion(scene);
427: changeEngineRegion(scene);
428: changeExternalRegion(scene);
429: changeConnectionLayer(scene);
430: scene.revalidate();
431: scene.validate();
432: }
433:
434: private void changeBindingRegion(CasaModelGraphScene scene) {
435: CasaRegionWidget regionWidget = (CasaRegionWidget) scene
436: .getBindingRegion();
437: //LayerWidget regionWidget = getScene().getBindingRegion();
438: regionWidget.setBackground(getCOLOR_REGION_BINDING());
439: regionWidget.setCOLOR_REGION_TITLE(getCOLOR_BC_REGION_TITLE());
440: regionWidget.setFONT_REGION_TITLE(getFONT_BC_REGION_TITLE());
441:
442: for (Widget widget : regionWidget.getChildren()) {
443: if (widget instanceof CasaNodeWidgetBinding) {
444: change((CasaNodeWidgetBinding) widget);
445: }
446: }
447:
448: }
449:
450: private void changeEngineRegion(CasaModelGraphScene scene) {
451: CasaRegionWidget regionWidget = (CasaRegionWidget) scene
452: .getEngineRegion();
453: //LayerWidget regionWidget = getScene().getEngineRegion();
454: regionWidget.setBackground(getCOLOR_REGION_ENGINE());
455: regionWidget.setCOLOR_REGION_TITLE(getCOLOR_SU_REGION_TITLE());
456: regionWidget.setFONT_REGION_TITLE(getFONT_SU_REGION_TITLE());
457:
458: for (Widget widget : regionWidget.getChildren()) {
459: if (widget instanceof CasaNodeWidgetEngineInternal) {
460: change((CasaNodeWidgetEngineInternal) widget);
461: }
462: }
463: }
464:
465: private void changeExternalRegion(CasaModelGraphScene scene) {
466: CasaRegionWidget regionWidget = (CasaRegionWidget) scene
467: .getExternalRegion();
468: //LayerWidget regionWidget = getScene().getExternalRegion();
469: regionWidget.setBackground(getCOLOR_REGION_EXTERNAL());
470: regionWidget
471: .setCOLOR_REGION_TITLE(getCOLOR_EXT_SU_REGION_TITLE());
472: regionWidget
473: .setFONT_REGION_TITLE(getFONT_EXT_SU_REGION_TITLE());
474:
475: for (Widget widget : regionWidget.getChildren()) {
476: if (widget instanceof CasaNodeWidgetEngineExternal) {
477: change((CasaNodeWidgetEngineExternal) widget);
478: }
479: }
480: }
481:
482: private void changeConnectionLayer(CasaModelGraphScene scene) {
483: LayerWidget regionWidget = scene.getConnectionLayer();
484: for (Widget widget : regionWidget.getChildren()) {
485: if (widget instanceof CasaConnectionWidget) {
486: change((CasaConnectionWidget) widget);
487: }
488: }
489: }
490:
491: private void change(CasaNodeWidgetEngineInternal internalSUWidget) {
492: internalSUWidget.setTitleColor(getCOLOR_SU_INTERNAL_TITLE());
493: internalSUWidget.setTitleFont(getFONT_SU_HEADER());
494: internalSUWidget.setPinFont(getFONT_SU_PIN());
495: internalSUWidget.setPinColor(getCOLOR_SU_INTERNAL_PIN());
496: internalSUWidget.readjustBounds();
497: }
498:
499: private void change(CasaNodeWidgetEngineExternal externalSUWidget) {
500: externalSUWidget.setTitleColor(getCOLOR_SU_EXTERNAL_TITLE());
501: externalSUWidget.setTitleFont(this .getFONT_EXT_SU_HEADER());
502: externalSUWidget.setPinFont(getFONT_EXT_SU_PIN());
503: externalSUWidget.setPinColor(getCOLOR_SU_EXTERNAL_PIN());
504: externalSUWidget.readjustBounds();
505: }
506:
507: private void change(CasaNodeWidgetBinding bindingWidget) {
508: bindingWidget.setBackgroundColor(getCOLOR_BC_BACKGROUND());
509: bindingWidget.regenerateHeaderBorder();
510: bindingWidget.regenerateVerticalTextBarImage(); //For FONT_BC_HEADER
511: bindingWidget
512: .setTitleBackgroundColor(getCOLOR_BC_TITLE_BACKGROUND());
513: bindingWidget.setLabelColor(getCOLOR_BC_LABEL());
514: bindingWidget.setLabelFont(getFONT_BC_LABEL());
515: }
516:
517: private void change(CasaConnectionWidget connectionWidget) {
518: connectionWidget
519: .setForegroundColor(getCOLOR_CONNECTION_NORMAL());
520: }
521:
522: public Font getFont(String str) {
523: //Font name, style, size
524: if (str == null || str.trim().equals("")) { // NOI18N
525: Scene scene = new Scene();
526: return scene.getDefaultFont().deriveFont(Font.BOLD);
527: }
528: String[] strNumbers = str.split(S_SEPARATOR); // NOI18N
529: int appearance = Integer.parseInt(strNumbers[1].trim());
530: int size = Integer.parseInt(strNumbers[2].trim());
531: return new Font(strNumbers[0].trim(), appearance, size);
532: }
533:
534: public GradientRectangleColorScheme getGradient(String str) {
535: String[] strNumbers = str.split(S_SEPARATOR); // NOI18N
536: return new GradientRectangleColorScheme(new Color(Integer
537: .parseInt(strNumbers[0])), new Color(Integer
538: .parseInt(strNumbers[1])), new Color(Integer
539: .parseInt(strNumbers[2])), new Color(Integer
540: .parseInt(strNumbers[3])), new Color(Integer
541: .parseInt(strNumbers[4])));
542: }
543:
544: public Boolean getBoolean(String str) {
545: Boolean bValue;
546: if (str.equalsIgnoreCase("true")) { // NOI18N
547: bValue = new Boolean(true);
548: } else {
549: bValue = new Boolean(false);
550: }
551: return bValue;
552: }
553:
554: public Object getValue(String key) {
555: Object retValue = null;
556: if (getColorsMapReference().containsKey(key)) {
557: retValue = (Object) getColorsMapReference().get(key);
558: } else if (getFontsMapReference().containsKey(key)) {
559: retValue = (Object) getFontsMapReference().get(key);
560: }
561: return retValue;
562: }
563:
564: public void setValue(String key, Color color) {
565: getColorsMapReference().put(key, color);
566: if (mGradientsMap.containsKey(key)) {
567: GradientRectangleColorScheme gradientColor = new GradientRectangleColorScheme(
568: null, color);
569: mGradientsMap.put(key, gradientColor);
570: }
571: CasaFactory.getCasaCustomizerRegistor().propagateChange();
572: }
573:
574: public void setValue(String key, Font font) {
575: getFontsMapReference().put(key, font);
576: CasaFactory.getCasaCustomizerRegistor().propagateChange();
577: }
578:
579: public void setValue(String key,
580: GradientRectangleColorScheme gradient) {
581: getGradientsMapReference().put(key, gradient);
582: CasaFactory.getCasaCustomizerRegistor().propagateChange();
583: }
584:
585: public void restoreDefaults(boolean bPropagateChange) {
586: LinkedHashMap<String, String> defaultColors = getDefaultColors();
587: int i;
588: for (String key : defaultColors.keySet()) {
589: i = Integer.parseInt(defaultColors.get(key));
590: mColorsMap.put(key, new Color(i));
591: }
592: LinkedHashMap<String, String> defaultFonts = getDefaultFonts();
593: Font font;
594: for (String key : defaultFonts.keySet()) {
595: font = getFont(defaultFonts.get(key));
596: mFontsMap.put(key, font);
597: }
598:
599: LinkedHashMap<String, String> dafaultGradients = getDefaultGradients();
600: GradientRectangleColorScheme gradientColor;
601: for (String key : dafaultGradients.keySet()) {
602: gradientColor = getGradient(dafaultGradients.get(key));
603: mGradientsMap.put(key, gradientColor);
604: }
605:
606: if (bPropagateChange) {
607: CasaFactory.getCasaCustomizerRegistor().propagateChange();
608: }
609: }
610:
611: public void loadFromPreferences(Preferences prefs,
612: boolean bRenderDesignView) {
613: LinkedHashMap<String, String> defaultColors = getDefaultColors();
614: String value;
615: int i;
616: for (String key : defaultColors.keySet()) {
617: value = prefs.get(key, defaultColors.get(key));
618: try {
619: i = Integer.parseInt(value);
620: } catch (Exception e) {
621: i = Integer.parseInt(defaultColors.get(key));
622: }
623: mColorsMap.put(key, new Color(i));
624: }
625:
626: LinkedHashMap<String, String> defaultFonts = getDefaultFonts();
627: Font font;
628: for (String key : defaultFonts.keySet()) {
629: value = prefs.get(key, defaultFonts.get(key));
630: try {
631: font = getFont(value);
632: } catch (Exception e) {
633: font = getFont(defaultFonts.get(key));
634: }
635: mFontsMap.put(key, font);
636: }
637:
638: LinkedHashMap<String, String> dafaultGradients = getDefaultGradients();
639: GradientRectangleColorScheme gradientColor;
640: for (String key : dafaultGradients.keySet()) {
641: value = prefs.get(key, dafaultGradients.get(key));
642: try {
643: gradientColor = getGradient(value);
644: } catch (Exception e) {
645: gradientColor = getGradient(dafaultGradients.get(key));
646: }
647: mGradientsMap.put(key, gradientColor);
648: }
649:
650: if (bRenderDesignView) {
651: CasaFactory.getCasaCustomizerRegistor().propagateChange();
652: }
653: }
654:
655: public void savePreferences() {
656: String ourNodeName = "/org/netbeans/modules/compapp/casaeditor/graph/CasaCustomizer"; // NOI18N
657: Preferences prefs = Preferences.userRoot().node(ourNodeName);
658:
659: for (String key : mColorsMap.keySet()) {
660: prefs.put(key, Integer.toString(mColorsMap.get(key)
661: .getRGB()));
662: }
663: Font font;
664: String value;
665: for (String key : mFontsMap.keySet()) {
666: font = mFontsMap.get(key);
667: value = font.getName() + S_SEPARATOR
668: + Integer.toString(font.getStyle()) + S_SEPARATOR
669: + Integer.toString(font.getSize()); // NOI18N
670: prefs.put(key, value);
671: }
672:
673: GradientRectangleColorScheme gradientColor;
674: for (String key : mGradientsMap.keySet()) {
675: gradientColor = mGradientsMap.get(key);
676: value = Integer
677: .toString(gradientColor.getColor1().getRGB())
678: + S_SEPARATOR
679: + Integer.toString(gradientColor.getColor2()
680: .getRGB())
681: + S_SEPARATOR
682: + Integer.toString(gradientColor.getColor3()
683: .getRGB())
684: + S_SEPARATOR
685: + Integer.toString(gradientColor.getColor4()
686: .getRGB())
687: + S_SEPARATOR
688: + Integer.toString(gradientColor.getColor5()
689: .getRGB());
690: prefs.put(key, value);
691: }
692: }
693:
694: public LinkedHashMap<String, String> getDefaultColors() {
695: LinkedHashMap<String, String> colorsMap = new LinkedHashMap<String, String>();
696:
697: // REGIONS
698:
699: colorsMap.put(S_COLOR_REGION_BINDING, new Integer((new Color(
700: 241, 254, 239)).getRGB()).toString());
701: colorsMap.put(S_COLOR_BC_REGION_TITLE, new Integer((new Color(
702: 153, 153, 153)).getRGB()).toString());
703: colorsMap.put(S_COLOR_REGION_ENGINE, new Integer((new Color(
704: 255, 255, 255)).getRGB()).toString());
705: colorsMap.put(S_COLOR_SU_REGION_TITLE, new Integer((new Color(
706: 153, 153, 153)).getRGB()).toString());
707: colorsMap.put(S_COLOR_REGION_EXTERNAL, new Integer((new Color(
708: 251, 249, 242)).getRGB()).toString());
709: colorsMap.put(S_COLOR_EXT_SU_REGION_TITLE, new Integer(
710: (new Color(153, 153, 153)).getRGB()).toString());
711:
712: // WIDGETS
713:
714: colorsMap.put(S_COLOR_BC_TITLE, new Integer((new Color(102,
715: 102, 102)).getRGB()).toString());
716: colorsMap.put(S_COLOR_BC_LABEL, new Integer((new Color(102,
717: 102, 102)).getRGB()).toString());
718: colorsMap.put(S_COLOR_BC_BACKGROUND, new Integer((new Color(
719: 255, 255, 255)).getRGB()).toString());
720: colorsMap.put(S_COLOR_BC_TITLE_BACKGROUND, new Integer(
721: (new Color(180, 200, 220)).getRGB()).toString());
722: colorsMap.put(S_COLOR_BC_BORDER, new Integer((new Color(186,
723: 205, 240)).getRGB()).toString());
724:
725: colorsMap.put(S_COLOR_SU_INTERNAL_BORDER, new Integer(
726: (new Color(186, 205, 240)).getRGB()).toString());
727: colorsMap.put(S_COLOR_SU_INTERNAL_TITLE, new Integer(
728: (new Color(102, 102, 102)).getRGB()).toString());
729: colorsMap.put(S_COLOR_SU_INTERNAL_PIN, new Integer((new Color(
730: 102, 102, 102)).getRGB()).toString());
731: colorsMap.put(S_COLOR_SU_INTERNAL_BACKGROUND, new Integer(
732: (new Color(241, 249, 249)).getRGB()).toString());
733:
734: colorsMap.put(S_COLOR_SU_EXTERNAL_BORDER, new Integer(
735: (new Color(186, 205, 240)).getRGB()).toString());
736: colorsMap.put(S_COLOR_SU_EXTERNAL_TITLE, new Integer(
737: (new Color(102, 102, 102)).getRGB()).toString());
738: colorsMap.put(S_COLOR_SU_EXTERNAL_PIN, new Integer((new Color(
739: 102, 102, 102)).getRGB()).toString());
740: colorsMap.put(S_COLOR_SU_EXTERNAL_BACKGROUND, new Integer(
741: (new Color(241, 249, 249)).getRGB()).toString());
742:
743: // SELECTION COLOR
744:
745: colorsMap.put(S_COLOR_SELECTION, new Integer((new Color(255,
746: 100, 0)).getRGB()).toString());
747:
748: // CONNECTIONS
749:
750: colorsMap.put(S_COLOR_CONNECTION_NORMAL, new Integer(
751: (new Color(204, 204, 255)).getRGB()).toString());
752: colorsMap.put(S_COLOR_CONNECTION_HOVERED, new Integer(
753: (new Color(38, 85, 185)).getRGB()).toString());
754:
755: return colorsMap;
756: }
757:
758: public LinkedHashMap<String, String> getDefaultFonts() {
759: LinkedHashMap<String, String> fontsMap = new LinkedHashMap<String, String>();
760:
761: fontsMap.put(S_FONT_BC_REGION_TITLE, "Dialog, 1, 14"); // NOI18N
762: fontsMap.put(S_FONT_SU_REGION_TITLE, "Dialog, 1, 14"); // NOI18N
763: fontsMap.put(S_FONT_EXT_SU_REGION_TITLE, "Dialog, 1, 14"); // NOI18N
764:
765: fontsMap.put(S_FONT_BC_TITLE, "SansSerif, 1, 14"); // NOI18N
766: fontsMap.put(S_FONT_BC_LABEL, "Dialog, 0, 12"); // NOI18N
767: fontsMap.put(S_FONT_SU_TITLE, ""); // NOI18N
768: fontsMap.put(S_FONT_SU_PIN, "Dialog, 0, 12"); // NOI18N
769: fontsMap.put(S_FONT_EXT_SU_TITLE, ""); // NOI18N
770: fontsMap.put(S_FONT_EXT_SU_PIN, "Dialog, 0, 12"); // NOI18N
771:
772: return fontsMap;
773: }
774:
775: public LinkedHashMap<String, String> getDefaultGradients() {
776: LinkedHashMap<String, String> gradientsMap = new LinkedHashMap<String, String>();
777:
778: String gradientColor = new Integer((new Color(221, 235, 246))
779: .getRGB()).toString()
780: + S_SEPARATOR
781: + new Integer((new Color(255, 255, 255)).getRGB())
782: .toString()
783: + S_SEPARATOR
784: + new Integer((new Color(214, 235, 255)).getRGB())
785: .toString()
786: + S_SEPARATOR
787: + new Integer((new Color(241, 249, 253)).getRGB())
788: .toString()
789: + S_SEPARATOR
790: + new Integer((new Color(255, 255, 255)).getRGB())
791: .toString();
792:
793: gradientsMap.put(S_COLOR_SU_INTERNAL_BACKGROUND, gradientColor);
794: gradientsMap.put(S_COLOR_SU_EXTERNAL_BACKGROUND, gradientColor);
795: gradientsMap.put(S_COLOR_BC_TITLE_BACKGROUND, gradientColor);
796:
797: return gradientsMap;
798: }
799: }
|