| 1 |
|
| 2 |
package org.freehep.graphicsio.cgm; |
| 3 |
|
| 4 |
import java.awt.Color; |
| 5 |
import java.io.IOException; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
public class PatternTable extends CGMTag { |
| 15 |
|
| 16 |
private int index; |
| 17 |
|
| 18 |
private Color[][] colorArray; |
| 19 |
|
| 20 |
private int precision; |
| 21 |
|
| 22 |
public PatternTable() { |
| 23 |
super(5, 32, 1); |
| 24 |
} |
| 25 |
|
| 26 |
public PatternTable(int index, Color[][] colorArray, int precision) { |
| 27 |
this(); |
| 28 |
this.index = index; |
| 29 |
this.colorArray = colorArray; |
| 30 |
|
| 31 |
this.precision = 0; |
| 32 |
} |
| 33 |
|
| 34 |
public void write(int tagID, CGMOutputStream cgm) throws IOException { |
| 35 |
cgm.writeIntegerIndex(index); |
| 36 |
cgm.writeInteger(colorArray.length); |
| 37 |
cgm.writeInteger(colorArray[0].length); |
| 38 |
cgm.writeInteger(precision); |
| 39 |
for (int i = 0; i < colorArray.length; i++) { |
| 40 |
for (int j = 0; j < colorArray[i].length; j++) { |
| 41 |
cgm.writeColor(colorArray[i][j]); |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
public void write(int tagID, CGMWriter cgm) throws IOException { |
| 47 |
cgm.print("PATTABLE "); |
| 48 |
cgm.writeInteger(index); |
| 49 |
cgm.print(", "); |
| 50 |
cgm.writeInteger(colorArray.length); |
| 51 |
cgm.print(", "); |
| 52 |
cgm.writeInteger(colorArray[0].length); |
| 53 |
cgm.print(", "); |
| 54 |
cgm.writeInteger(0); |
| 55 |
cgm.println(", "); |
| 56 |
cgm.indent(); |
| 57 |
for (int i = 0; i < colorArray.length; i++) { |
| 58 |
cgm.print("("); |
| 59 |
for (int j = 0; j < colorArray[i].length; j++) { |
| 60 |
cgm.writeColor(colorArray[i][j]); |
| 61 |
cgm.print(" "); |
| 62 |
} |
| 63 |
cgm.println(")"); |
| 64 |
} |
| 65 |
cgm.outdent(); |
| 66 |
} |
| 67 |
} |