@@ -3,9 +3,6 @@
import java.io.IOException;
-import org.freehep.util.io.Tag;
-import org.freehep.util.io.TaggedInputStream;
-import org.freehep.util.io.TaggedOutputStream;
import org.freehep.graphicsio.emf.EMFInputStream;
import org.freehep.graphicsio.emf.EMFOutputStream;
import org.freehep.graphicsio.emf.EMFTag;
@@ -19,7 +16,6 @@
public abstract class EMFPlusTag extends EMFTag {
private static final int OFFSET = 0x00004000;
- protected int flags = 0;
/**
* Constructs an EMFPlusTag.
@@ -31,29 +27,30 @@
super(id+OFFSET, version+OFFSET);
}
- public Tag read(int tagID, TaggedInputStream input, int len)
+ public EMFTag read(int tagID, EMFInputStream emf, int len)
throws IOException {
- EMFInputStream emf = (EMFInputStream)input;
- int flags = emf.readUINT();
+ len = emf.readUINT(); // intermediate length
return read(tagID-OFFSET, flags, emf, len);
}
public abstract EMFPlusTag read(int tagID, int flags, EMFInputStream emf, int len)
throws IOException;
- public void write(int tagID, TaggedOutputStream output) throws IOException {
- EMFOutputStream emf = (EMFOutputStream)output;
- emf.writeUINT(flags);
- write(tagID-OFFSET, emf);
+ public void write(int tagID, EMFOutputStream emf) throws IOException {
+ emf.pushBuffer();
+ write(tagID-OFFSET, flags, emf);
+ int len = emf.popBuffer();
+ emf.writeUINT(len);
+ emf.append();
}
- public abstract void write(int tagID, EMFOutputStream emf) throws IOException;
+ public abstract void write(int tagID, int flags, EMFOutputStream emf) throws IOException;
- /**
- * @return a description of the tagName and tagID
- */
public String toString() {
- return "EMFPlusTag " + getName() + " (" + getTag() + ")";
+ int id = getTag();
+ String s = "EMF+Tag " + getName() + " (" + id + ") (0x"+Integer.toHexString(id)+")\n";
+ s += " flags: 0x"+Integer.toHexString(flags);
+ return s;
}
}
|