| 1 |
// Copyright 2002, FreeHEP. |
| 2 |
package org.freehep.graphicsio.emf.gdi; |
| 3 |
|
| 4 |
import java.io.IOException; |
| 5 |
|
| 6 |
import org.freehep.graphicsio.emf.EMFConstants; |
| 7 |
import org.freehep.graphicsio.emf.EMFInputStream; |
| 8 |
import org.freehep.graphicsio.emf.EMFOutputStream; |
| 9 |
import org.freehep.graphicsio.emf.EMFTag; |
| 10 |
import org.freehep.graphicsio.emf.EMFRenderer; |
| 11 |
|
| 12 |
/** |
| 13 |
* ExtSelectClipRgn TAG. |
| 14 |
* |
| 15 |
* @author Mark Donszelmann |
| 16 |
* @version $Id: freehep-graphicsio-emf/src/main/java/org/freehep/graphicsio/emf/gdi/ExtSelectClipRgn.java 10ec7516e3ce 2007/02/06 18:42:34 duns $ |
| 17 |
*/ |
| 18 |
public class ExtSelectClipRgn extends AbstractClipPath { |
| 19 |
|
| 20 |
private Region rgn; |
| 21 |
|
| 22 |
public ExtSelectClipRgn() { |
| 23 |
super(75, 1, EMFConstants.RGN_COPY); |
| 24 |
} |
| 25 |
|
| 26 |
public ExtSelectClipRgn(int mode, Region rgn) { |
| 27 |
super(75, 1, mode); |
| 28 |
this.rgn = rgn; |
| 29 |
} |
| 30 |
|
| 31 |
public EMFTag read(int tagID, EMFInputStream emf, int len) |
| 32 |
throws IOException { |
| 33 |
|
| 34 |
int length = emf.readDWORD(); |
| 35 |
int mode = emf.readDWORD(); |
| 36 |
return new ExtSelectClipRgn( |
| 37 |
mode, |
| 38 |
length > 8 ? new Region(emf) : null); |
| 39 |
} |
| 40 |
|
| 41 |
public void write(int tagID, EMFOutputStream emf) throws IOException { |
| 42 |
emf.writeDWORD(rgn.length()); |
| 43 |
emf.writeDWORD(getMode()); |
| 44 |
rgn.write(emf); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* displays the tag using the renderer |
| 49 |
* |
| 50 |
* @param renderer EMFRenderer storing the drawing session data |
| 51 |
*/ |
| 52 |
public void render(EMFRenderer renderer) { |
| 53 |
if (rgn == null || rgn.getBounds() == null) { |
| 54 |
return; |
| 55 |
} |
| 56 |
|
| 57 |
render(renderer, rgn.getBounds()); |
| 58 |
} |
| 59 |
} |