| 1 |
// Copyright 2002, FreeHEP. |
| 2 |
package org.freehep.graphicsio.emf.gdi; |
| 3 |
|
| 4 |
import java.awt.Font; |
| 5 |
import java.io.IOException; |
| 6 |
|
| 7 |
import org.freehep.graphicsio.emf.EMFConstants; |
| 8 |
import org.freehep.graphicsio.emf.EMFInputStream; |
| 9 |
import org.freehep.graphicsio.emf.EMFOutputStream; |
| 10 |
import org.freehep.graphicsio.emf.EMFRenderer; |
| 11 |
|
| 12 |
/** |
| 13 |
* EMF ExtLogFontW |
| 14 |
* |
| 15 |
* @author Mark Donszelmann |
| 16 |
* @version $Id: freehep-graphicsio-emf/src/main/java/org/freehep/graphicsio/emf/gdi/ExtLogFontW.java c0f15e7696d3 2007/01/22 19:26:48 duns $ |
| 17 |
*/ |
| 18 |
public class ExtLogFontW implements EMFConstants, GDIObject { |
| 19 |
|
| 20 |
private LogFontW font; |
| 21 |
|
| 22 |
private String fullName; |
| 23 |
|
| 24 |
private String style; |
| 25 |
|
| 26 |
private int version; |
| 27 |
|
| 28 |
private int styleSize; |
| 29 |
|
| 30 |
private int match; |
| 31 |
|
| 32 |
private byte[] vendorID; |
| 33 |
|
| 34 |
private int culture; |
| 35 |
|
| 36 |
private Panose panose; |
| 37 |
|
| 38 |
public ExtLogFontW(LogFontW font, String fullName, String style, |
| 39 |
int version, int styleSize, int match, byte[] vendorID, |
| 40 |
int culture, Panose panose) { |
| 41 |
this.font = font; |
| 42 |
this.fullName = fullName; |
| 43 |
this.style = style; |
| 44 |
this.version = version; |
| 45 |
this.styleSize = styleSize; |
| 46 |
this.match = match; |
| 47 |
this.vendorID = vendorID; |
| 48 |
this.culture = culture; |
| 49 |
this.panose = panose; |
| 50 |
} |
| 51 |
|
| 52 |
public ExtLogFontW(Font font) { |
| 53 |
this.font = new LogFontW(font); |
| 54 |
this.fullName = ""; |
| 55 |
this.style = ""; |
| 56 |
this.version = 0; |
| 57 |
this.styleSize = 0; |
| 58 |
this.match = 0; |
| 59 |
this.vendorID = new byte[] { 0, 0, 0, 0 }; |
| 60 |
this.culture = 0; |
| 61 |
this.panose = new Panose(); |
| 62 |
} |
| 63 |
|
| 64 |
public ExtLogFontW(EMFInputStream emf) throws IOException { |
| 65 |
font = new LogFontW(emf); |
| 66 |
fullName = emf.readWCHAR(64); |
| 67 |
style = emf.readWCHAR(32); |
| 68 |
version = emf.readDWORD(); |
| 69 |
styleSize = emf.readDWORD(); |
| 70 |
match = emf.readDWORD(); |
| 71 |
emf.readDWORD(); |
| 72 |
vendorID = emf.readBYTE(4); |
| 73 |
culture = emf.readDWORD(); |
| 74 |
panose = new Panose(emf); |
| 75 |
emf.readWORD(); // Pad to 4-byte boundary |
| 76 |
// to avoid an eception |
| 77 |
emf.popBuffer(); |
| 78 |
} |
| 79 |
|
| 80 |
public void write(EMFOutputStream emf) throws IOException { |
| 81 |
font.write(emf); |
| 82 |
emf.writeWCHAR(fullName, 64); |
| 83 |
emf.writeWCHAR(style, 32); |
| 84 |
emf.writeDWORD(version); |
| 85 |
emf.writeDWORD(styleSize); |
| 86 |
emf.writeDWORD(match); |
| 87 |
emf.writeDWORD(0); // reserved |
| 88 |
emf.writeBYTE(vendorID); |
| 89 |
emf.writeDWORD(culture); |
| 90 |
panose.write(emf); |
| 91 |
emf.writeWORD(0); |
| 92 |
} |
| 93 |
|
| 94 |
public String toString() { |
| 95 |
return super.toString() + |
| 96 |
"\n LogFontW\n" + font.toString() + |
| 97 |
"\n fullname: " + fullName + |
| 98 |
"\n style: " + style + |
| 99 |
"\n version: " + version + |
| 100 |
"\n stylesize: " + styleSize + |
| 101 |
"\n match: " + match + |
| 102 |
"\n vendorID: " + vendorID + |
| 103 |
"\n culture: " + culture + |
| 104 |
"\n" + panose.toString(); |
| 105 |
} |
| 106 |
|
| 107 |
/** |
| 108 |
* displays the tag using the renderer |
| 109 |
* |
| 110 |
* @param renderer EMFRenderer storing the drawing session data |
| 111 |
*/ |
| 112 |
public void render(EMFRenderer renderer) { |
| 113 |
renderer.setFont(font.getFont()); |
| 114 |
} |
| 115 |
} |