001: /*
002: * $Id: MorphLineStyle.java,v 1.1 2002/02/15 23:46:26 skavish Exp $
003: *
004: * ==========================================================================
005: *
006: * The JGenerator Software License, Version 1.0
007: *
008: * Copyright (c) 2000 Dmitry Skavish (skavish@usa.net). All rights reserved.
009: *
010: * Redistribution and use in source and binary forms, with or without
011: * modification, are permitted provided that the following conditions are met:
012: *
013: * 1. Redistributions of source code must retain the above copyright
014: * notice, this list of conditions and the following disclaimer.
015: *
016: * 2. Redistributions in binary form must reproduce the above copyright
017: * notice, this list of conditions and the following disclaimer in
018: * the documentation and/or other materials provided with the
019: * distribution.
020: *
021: * 3. The end-user documentation included with the redistribution, if
022: * any, must include the following acknowlegement:
023: * "This product includes software developed by Dmitry Skavish
024: * (skavish@usa.net, http://www.flashgap.com/)."
025: * Alternately, this acknowlegement may appear in the software itself,
026: * if and wherever such third-party acknowlegements normally appear.
027: *
028: * 4. The name "The JGenerator" must not be used to endorse or promote
029: * products derived from this software without prior written permission.
030: * For written permission, please contact skavish@usa.net.
031: *
032: * 5. Products derived from this software may not be called "The JGenerator"
033: * nor may "The JGenerator" appear in their names without prior written
034: * permission of Dmitry Skavish.
035: *
036: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: * DISCLAIMED. IN NO EVENT SHALL DMITRY SKAVISH OR THE OTHER
040: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: * SUCH DAMAGE.
048: *
049: */
050:
051: package org.openlaszlo.iv.flash.api.shape;
052:
053: import org.openlaszlo.iv.flash.util.*;
054: import org.openlaszlo.iv.flash.api.*;
055: import org.openlaszlo.iv.flash.parser.*;
056: import java.io.PrintStream;
057:
058: /**
059: * A line style represents a width and color of a line.
060: *
061: * @author Dmitry Skavish
062: * @see LineStyle
063: */
064: public final class MorphLineStyle extends FlashItem {
065:
066: private LineStyle style_start;
067: private LineStyle style_end;
068:
069: public MorphLineStyle() {
070: }
071:
072: /**
073: * Creates line style of specified color and width
074: *
075: */
076: public MorphLineStyle(int width_start, Color color_start,
077: int width_end, Color color_end) {
078: style_start = new LineStyle(width_start, color_start);
079: style_end = new LineStyle(width_end, color_end);
080: }
081:
082: public MorphLineStyle(LineStyle style_start, LineStyle style_end) {
083: this .style_start = style_start;
084: this .style_end = style_end;
085: }
086:
087: /**
088: * Returns start width of this linestyle.
089: *
090: * @return start width of this linestyle
091: */
092: public int getWidthStart() {
093: return style_start.getWidth();
094: }
095:
096: /**
097: * Sets start width of this linestyle
098: *
099: * @param width width of this linestyle
100: */
101: public void setWidthStart(int width) {
102: style_start.setWidth(width);
103: }
104:
105: /**
106: * Returns end width of this linestyle.
107: *
108: * @return width of this linestyle
109: */
110: public int getWidthEnd() {
111: return style_end.getWidth();
112: }
113:
114: /**
115: * Sets end width of this linestyle
116: *
117: * @param width width of this linestyle
118: */
119: public void setWidthEnd(int width) {
120: style_end.setWidth(width);
121: }
122:
123: /**
124: * Returns start color of this linestyle
125: *
126: * @return color of this linestyle
127: */
128: public Color getColorStart() {
129: return style_start.getColor();
130: }
131:
132: /**
133: * Sets start color of this linestyle
134: *
135: * @param color specified color
136: */
137: public void setColorStart(Color color) {
138: style_start.setColor(color);
139: }
140:
141: /**
142: * Returns end color of this linestyle
143: *
144: * @return color of this linestyle
145: */
146: public Color getColorEnd() {
147: return style_end.getColor();
148: }
149:
150: /**
151: * Sets end color of this linestyle
152: *
153: * @param color specified color
154: */
155: public void setColorEnd(Color color) {
156: style_end.setColor(color);
157: }
158:
159: public static MorphLineStyle parse(Parser p) {
160: int width_start = p.getUWord();
161: int width_end = p.getUWord();
162: Color color_start = AlphaColor.parse(p);
163: Color color_end = AlphaColor.parse(p);
164: return new MorphLineStyle(width_start, color_start, width_end,
165: color_end);
166: }
167:
168: public void write(FlashOutput fob) {
169: fob.writeWord(getWidthStart());
170: fob.writeWord(getWidthEnd());
171: getColorStart().writeRGBA(fob);
172: getColorEnd().writeRGBA(fob);
173: }
174:
175: public void printContent(PrintStream out, String indent) {
176: out.println(indent + "MorphLineStyle: start:");
177: style_start.printContent(out, indent + " ");
178: out.println(indent + " end:");
179: style_end.printContent(out, indent + " ");
180: }
181:
182: protected FlashItem copyInto(FlashItem item, ScriptCopier copier) {
183: ((MorphLineStyle) item).style_start = (LineStyle) style_start
184: .getCopy(copier);
185: ((MorphLineStyle) item).style_end = (LineStyle) style_end
186: .getCopy(copier);
187: return item;
188: }
189:
190: public FlashItem getCopy(ScriptCopier copier) {
191: return copyInto(new MorphLineStyle(), copier);
192: }
193: }
|