| 1 |
// Copyright 2002, FreeHEP. |
| 2 |
package org.freehep.graphicsio.emf.gdi; |
| 3 |
|
| 4 |
import java.io.IOException; |
| 5 |
|
| 6 |
import org.freehep.graphicsio.emf.EMFInputStream; |
| 7 |
import org.freehep.graphicsio.emf.EMFOutputStream; |
| 8 |
import org.freehep.graphicsio.emf.EMFTag; |
| 9 |
import org.freehep.graphicsio.emf.EMFRenderer; |
| 10 |
|
| 11 |
/** |
| 12 |
* SelectObject TAG. |
| 13 |
* |
| 14 |
* @author Mark Donszelmann |
| 15 |
* @version $Id: freehep-graphicsio-emf/src/main/java/org/freehep/graphicsio/emf/gdi/SelectObject.java 10ec7516e3ce 2007/02/06 18:42:34 duns $ |
| 16 |
*/ |
| 17 |
public class SelectObject extends EMFTag { |
| 18 |
|
| 19 |
private int index; |
| 20 |
|
| 21 |
public SelectObject() { |
| 22 |
super(37, 1); |
| 23 |
} |
| 24 |
|
| 25 |
public SelectObject(int index) { |
| 26 |
this(); |
| 27 |
this.index = index; |
| 28 |
} |
| 29 |
|
| 30 |
public EMFTag read(int tagID, EMFInputStream emf, int len) |
| 31 |
throws IOException { |
| 32 |
|
| 33 |
return new SelectObject(emf.readDWORD()); |
| 34 |
} |
| 35 |
|
| 36 |
public void write(int tagID, EMFOutputStream emf) throws IOException { |
| 37 |
emf.writeDWORD(index); |
| 38 |
} |
| 39 |
|
| 40 |
public String toString() { |
| 41 |
return super.toString() + |
| 42 |
"\n index: 0x" + Integer.toHexString(index); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* displays the tag using the renderer |
| 47 |
* |
| 48 |
* @param renderer EMFRenderer storing the drawing session data |
| 49 |
*/ |
| 50 |
public void render(EMFRenderer renderer) { |
| 51 |
GDIObject gdiObject; |
| 52 |
|
| 53 |
if (index < 0) { |
| 54 |
gdiObject = StockObjects.getStockObject(index); |
| 55 |
} else { |
| 56 |
gdiObject = renderer.getGDIObject(index); |
| 57 |
} |
| 58 |
|
| 59 |
if (gdiObject != null) { |
| 60 |
// render that object |
| 61 |
gdiObject.render(renderer); |
| 62 |
} else { |
| 63 |
logger.warning("gdi object with index " + index + " not found"); |
| 64 |
} |
| 65 |
} |
| 66 |
} |