| 1 |
package org.freehep.graphicsio.emf.gdi; |
| 2 |
|
| 3 |
import java.awt.Rectangle; |
| 4 |
import java.io.IOException; |
| 5 |
|
| 6 |
import org.freehep.graphicsio.emf.EMFInputStream; |
| 7 |
import org.freehep.graphicsio.emf.EMFOutputStream; |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
* @author tonyj |
| 12 |
*/ |
| 13 |
public class Region { |
| 14 |
private Rectangle bounds; |
| 15 |
|
| 16 |
private Rectangle region; |
| 17 |
|
| 18 |
public Region(Rectangle bounds, Rectangle region) { |
| 19 |
this.bounds = bounds; |
| 20 |
this.region = region; |
| 21 |
} |
| 22 |
|
| 23 |
public Region(EMFInputStream emf) throws IOException { |
| 24 |
/* int length = */ emf.readDWORD(); |
| 25 |
/* int mode = */ emf.readDWORD(); |
| 26 |
/* int nRect = */ emf.readDWORD(); |
| 27 |
int size = emf.readDWORD(); |
| 28 |
bounds = emf.readRECTL(); |
| 29 |
region = emf.readRECTL(); |
| 30 |
for (int i = 16; i < size; i += 16) |
| 31 |
emf.readRECTL(); |
| 32 |
} |
| 33 |
|
| 34 |
public void write(EMFOutputStream emf) throws IOException { |
| 35 |
emf.writeDWORD(32); |
| 36 |
emf.writeDWORD(1); // RDH_RECTANGLES |
| 37 |
emf.writeDWORD(1); |
| 38 |
emf.writeDWORD(16); |
| 39 |
emf.writeRECTL(bounds); |
| 40 |
emf.writeRECTL(region); |
| 41 |
} |
| 42 |
|
| 43 |
public int length() { |
| 44 |
return 48; |
| 45 |
} |
| 46 |
|
| 47 |
public String toString() { |
| 48 |
return " Region\n" + " bounds: " + bounds + |
| 49 |
"\n region: " + region; |
| 50 |
} |
| 51 |
|
| 52 |
public Rectangle getBounds() { |
| 53 |
return bounds; |
| 54 |
} |
| 55 |
} |