001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.bpel.design.decoration;
021:
022: public class Decoration {
023:
024: private DimmDescriptor dimmed;
025:
026: private GlowDescriptor glow;
027:
028: private StrokeDescriptor stroke;
029:
030: private TextstyleDescriptor textstyle;
031:
032: private ComponentsDescriptor components;
033:
034: private StripeDescriptor stripe;
035:
036: public Decoration() {
037: }
038:
039: public Decoration(Descriptor descriptor) {
040: this (new Descriptor[] { descriptor });
041: }
042:
043: public Decoration(Descriptor[] descriptors) {
044: for (Descriptor d : descriptors) {
045: if (d instanceof DimmDescriptor) {
046: dimmed = (DimmDescriptor) d;
047: } else if (d instanceof GlowDescriptor) {
048: glow = (GlowDescriptor) d;
049: } else if (d instanceof StrokeDescriptor) {
050: stroke = (StrokeDescriptor) d;
051: } else if (d instanceof TextstyleDescriptor) {
052: textstyle = (TextstyleDescriptor) d;
053: } else if (d instanceof ComponentsDescriptor) {
054: components = (ComponentsDescriptor) d;
055: } else if (d instanceof StripeDescriptor) {
056: stripe = (StripeDescriptor) d;
057: }
058: }
059: }
060:
061: public GlowDescriptor getGlow() {
062: return glow;
063: }
064:
065: public boolean hasGlow() {
066: return (glow != null);
067: }
068:
069: public boolean hasDimmed() {
070: return (dimmed != null);
071: }
072:
073: public DimmDescriptor getDimmed() {
074: return dimmed;
075: }
076:
077: public StrokeDescriptor getStroke() {
078: return stroke;
079: }
080:
081: public StripeDescriptor getStripe() {
082: return stripe;
083: }
084:
085: public boolean hasStroke() {
086: return (stroke != null);
087: }
088:
089: public boolean hasStripe() {
090: return (stripe != null);
091: }
092:
093: public TextstyleDescriptor getTextstyle() {
094: return textstyle;
095: }
096:
097: public boolean hasTextstyle() {
098: return (textstyle != null);
099: }
100:
101: public boolean hasComponents() {
102: return (components != null);
103: }
104:
105: public ComponentsDescriptor getComponents() {
106: return components;
107: }
108:
109: public Decoration combineWith(Decoration d) {
110: if (d == null) {
111: return this ;
112: }
113:
114: if (d.hasGlow()) {
115: glow = d.getGlow();
116: }
117:
118: if (d.hasStroke()) {
119: stroke = d.getStroke();
120: }
121:
122: if (d.hasDimmed()) {
123: dimmed = d.getDimmed();
124: }
125:
126: if (d.hasTextstyle()) {
127: textstyle = d.getTextstyle();
128: }
129:
130: if (d.hasComponents()) {
131: if (components == null) {
132: components = new ComponentsDescriptor();
133: }
134: components.addAll(d.getComponents());
135: }
136:
137: if (d.hasStripe()) {
138: stripe = StripeDescriptor.merge(stripe, d.getStripe());
139: }
140:
141: return this;
142: }
143:
144: }
|