View Javadoc

1   // Copyright 2001, FreeHEP.
2   package org.freehep.graphicsio.emf;
3   
4   import java.io.IOException;
5   import java.util.logging.Logger;
6   
7   import org.freehep.util.io.Tag;
8   import org.freehep.util.io.TaggedInputStream;
9   import org.freehep.util.io.TaggedOutputStream;
10  import org.freehep.graphicsio.emf.gdi.GDIObject;
11  
12  /**
13   * EMF specific tag, from which all other EMF Tags inherit.
14   * 
15   * @author Mark Donszelmann
16   * @version $Id: EMFTag.java 10367 2007-01-22 19:26:48Z duns $
17   */
18  public abstract class EMFTag extends Tag implements GDIObject {
19  
20      /**
21       * logger for all instances
22       */
23      protected static final Logger logger = Logger.getLogger("org.freehep.graphicsio.emf");
24  
25      /**
26       * Constructs a EMFTag.
27       * 
28       * @param id id of the element
29       * @param version emf version in which this element was first supported
30       */
31      protected EMFTag(int id, int version) {
32          super(id, version);
33      }
34  
35      public Tag read(int tagID, TaggedInputStream input, int len)
36              throws IOException {
37  
38          return read(tagID, (EMFInputStream) input, len);
39      }
40  
41      public abstract EMFTag read(int tagID, EMFInputStream emf, int len)
42              throws IOException;
43  
44      public void write(int tagID, TaggedOutputStream output) throws IOException {
45          write(tagID, (EMFOutputStream) output);
46      }
47  
48      /**
49       * Writes the extra tag information to the outputstream in binary format.
50       * This implementation writes nothing, but concrete tags may override this
51       * method. This method is called just after the TagHeader is written.
52       * 
53       * @param tagID id of the tag
54       * @param emf Binary CGM output stream
55       * @throws java.io.IOException thrown by EMFOutputStream
56       */
57      public void write(int tagID, EMFOutputStream emf) throws IOException {
58          // empty
59      }
60  
61      /**
62       * @return a description of the tagName and tagID
63       */
64      public String toString() {
65          return "EMFTag " + getName() + " (" + getTag() + ")";
66      }
67  
68      /**
69       * displays the tag using the renderer
70       *
71       * @param renderer EMFRenderer storing the drawing session data
72       */
73      public void render(EMFRenderer renderer) {
74          logger.warning("EMF tag not supported: " + toString());
75      }
76  }