| 1 |
|
| 2 |
package org.freehep.graphicsio.swf; |
| 3 |
|
| 4 |
import java.awt.Color; |
| 5 |
import java.io.IOException; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
public class Gradient { |
| 15 |
|
| 16 |
private int ratio, endRatio; |
| 17 |
|
| 18 |
private Color color, endColor; |
| 19 |
|
| 20 |
public Gradient(int ratio, Color color) { |
| 21 |
this.ratio = ratio; |
| 22 |
this.color = color; |
| 23 |
} |
| 24 |
|
| 25 |
public Gradient(int ratio, int endRatio, Color color, Color endColor) { |
| 26 |
this(ratio, color); |
| 27 |
this.endRatio = endRatio; |
| 28 |
this.endColor = endColor; |
| 29 |
} |
| 30 |
|
| 31 |
public Gradient(SWFInputStream input, boolean isMorphStyle, boolean hasAlpha) |
| 32 |
throws IOException { |
| 33 |
ratio = input.readUnsignedByte(); |
| 34 |
color = input.readColor(hasAlpha); |
| 35 |
if (isMorphStyle) { |
| 36 |
endRatio = input.readUnsignedByte(); |
| 37 |
endColor = input.readColor(true); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
public void write(SWFOutputStream swf, boolean isMorphStyle, boolean hasAlpha) throws IOException { |
| 42 |
swf.writeUnsignedByte(ratio); |
| 43 |
swf.writeColor(color, hasAlpha); |
| 44 |
if (isMorphStyle) { |
| 45 |
swf.writeUnsignedByte(endRatio); |
| 46 |
swf.writeColor(endColor, true); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
public String toString() { |
| 51 |
return "Gradient " + ratio + ", " + color |
| 52 |
+ ((endColor != null) ? ", " + endRatio + ", " + endColor : ""); |
| 53 |
} |
| 54 |
} |