org.apache.batik.transcoder.wmf.tosvg
Class AbstractWMFReader
public abstract
class
AbstractWMFReader
extends Object
This class provides a general framework to read WMF Metafiles.
Method Summary |
int | addObject(int type, Object obj) |
int | addObjectAt(int type, Object obj, int idx)
Adds a GdiObject to the internal handle table.
|
int | getBottomUnits() get the bottom units in the WMF Metafile. |
int | getHeightPixels() get the height of the WMF Metafile, in pixels. |
int | getHeightUnits() get the height units in the WMF Metafile. |
int | getLeftUnits() get the left units in the WMF Metafile. |
int | getMetaFileUnitsPerInch() get the number of Metafile units per inch in the WMF Metafile.
|
int | getNumObjects()
Returns the number of GdiObjects in the handle table |
GdiObject | getObject(int idx)
Returns a GdiObject from the handle table |
float | getPixelsPerUnit() Return the number of pixels per unit. |
Rectangle2D | getRectangleInch() get the Rectangle defining the viewport of the WMF Metafile, in inchs. |
Rectangle2D | getRectanglePixel() get the Rectangle defining the viewport of the WMF Metafile, in pixels. |
Rectangle | getRectangleUnits() get the Rectangle defining the viewport of the WMF Metafile, in Metafile units.
|
int | getRightUnits() get the right units in the WMF Metafile. |
int | getTopUnits() get the top units in the WMF Metafile. |
float | getUnitsToPixels() get the factor to transform Metafile dimensions in pixels |
float | getViewportHeightInch()
Returns the viewport height, in inches. |
float | getViewportHeightUnits()
Returns the viewport height, in Metafile Units |
float | getViewportWidthInch()
Returns the viewport width, in inches. |
float | getViewportWidthUnits()
Returns the viewport width, in Metafile Units |
int | getVpH()
Returns the viewport height, in pixels. |
float | getVpHFactor() get the factor to transform logical units height in pixels |
int | getVpW()
Returns the viewport width, in pixels. |
float | getVpWFactor() get the factor to transform logical units width in pixels |
int | getWidthPixels() get the width of the WMF Metafile, in pixels. |
int | getWidthUnits() get the width units in the WMF Metafile. |
int | getXSign() Return the sign of X coordinates. |
int | getYSign() Return the sign of Y coordinates. |
boolean | isReading() |
void | read(DataInputStream is) Reads the WMF file from the specified Stream, read it and set the following
properties:
If the file contains an APM
(aldus placeable header), this method read these additionnal properties :
- left : Left coordinate in metafile units
- right : Right coordinate in metafile units
- top : Top coordinate in metafile units
- bottom : Bottom coordinate in metafile units
- inch : Number of metafile units per inch
Then it calls the readRecords abstract method,
whose behavior is left to the subclass . |
protected int | readInt(DataInputStream is)
Read the next int (4 bytes) value in the DataInputStream. |
protected abstract boolean | readRecords(DataInputStream is) Read this InputStream records. |
protected short | readShort(DataInputStream is)
Read the next short (2 bytes) value in the DataInputStream. |
abstract void | reset() resets this WMFReader. |
protected void | setReading(boolean state) |
protected int bottom
protected volatile boolean bReading
protected int height
protected int inch
protected boolean isAldus
protected boolean isotropic
public int lastObjectIdx
protected int left
protected int mtHeaderSize
protected int mtMaxRecord
protected int mtNoObjects
protected int mtNoParameters
protected int mtSize
protected int mtType
protected int mtVersion
public static final float MM_PER_PIXEL
protected int numObjects
protected List objectVector
public static final float PIXEL_PER_INCH
protected int right
protected float scaleX
protected float scaleXY
protected float scaleY
protected int top
protected int vpH
protected int vpW
protected int vpX
protected int vpY
protected int width
protected int windowHeight
protected int windowWidth
protected int xSign
protected int ySign
public AbstractWMFReader()
public AbstractWMFReader(int width, int height)
public int addObject(int type, Object obj)
public int addObjectAt(int type, Object obj, int idx)
Adds a GdiObject to the internal handle table.
Wmf files specify the index as given in EMF records such as
EMRCREATEPENINDIRECT whereas WMF files always use 0.
This function should not normally be called by an application.
Returns: the object index
public int getBottomUnits()
get the bottom units in the WMF Metafile. This value is given
in the Aldus Placable Header.
public int getHeightPixels()
get the height of the WMF Metafile, in pixels.
public int getHeightUnits()
get the height units in the WMF Metafile. This value is given
in the Aldus Placable Header.
public int getLeftUnits()
get the left units in the WMF Metafile. This value is given
in the Aldus Placable Metafile.
public int getMetaFileUnitsPerInch()
get the number of Metafile units per inch in the WMF Metafile.
This value is given in the Aldus Placable Header.
public int getNumObjects()
Returns the number of GdiObjects in the handle table
Returns a GdiObject from the handle table
public float getPixelsPerUnit()
Return the number of pixels per unit.
public Rectangle2D getRectangleInch()
get the Rectangle defining the viewport of the WMF Metafile, in inchs.
public Rectangle2D getRectanglePixel()
get the Rectangle defining the viewport of the WMF Metafile, in pixels.
public Rectangle getRectangleUnits()
public int getRightUnits()
get the right units in the WMF Metafile. This value is given
in the Aldus Placable Header.
public int getTopUnits()
get the top units in the WMF Metafile. This value is given
in the Aldus Placable Header.
public float getUnitsToPixels()
get the factor to transform Metafile dimensions in pixels
public float getViewportHeightInch()
Returns the viewport height, in inches.
public float getViewportHeightUnits()
Returns the viewport height, in Metafile Units
public float getViewportWidthInch()
Returns the viewport width, in inches.
public float getViewportWidthUnits()
Returns the viewport width, in Metafile Units
public int getVpH()
Returns the viewport height, in pixels.
public float getVpHFactor()
get the factor to transform logical units height in pixels
public int getVpW()
Returns the viewport width, in pixels.
public float getVpWFactor()
get the factor to transform logical units width in pixels
public int getWidthPixels()
get the width of the WMF Metafile, in pixels.
public int getWidthUnits()
get the width units in the WMF Metafile. This value is given
in the Aldus Placable Header.
public int getXSign()
Return the sign of X coordinates. It is equal to 1 by default, but can be -1 if
all X coordinates are inversed.
public int getYSign()
Return the sign of Y coordinates. It is equal to 1 by default, but can be -1 if
all Y coordinates are inversed.
public boolean isReading()
Returns: true if the reader is currently reading an InputStream.
public void read(DataInputStream is)
Reads the WMF file from the specified Stream, read it and set the following
properties:
If the file contains an APM
(aldus placeable header), this method read these additionnal properties :
- left : Left coordinate in metafile units
- right : Right coordinate in metafile units
- top : Top coordinate in metafile units
- bottom : Bottom coordinate in metafile units
- inch : Number of metafile units per inch
Then it calls the readRecords abstract method,
whose behavior is left to the subclass
.
protected int readInt(DataInputStream is)
Read the next int (4 bytes) value in the DataInputStream.
protected abstract boolean readRecords(DataInputStream is)
Read this InputStream records. The aldus placeable header have already been
read (see
read). The behavior of this method is left
to the subclass.
Each Metafile record is composed of :
- the size of the Record in int (32 bits)
- the function ID for the Record on a short word (16 bits)
- the function parameters, according to the WMF Metafile specification.
the remaining size in short words (16 bits) for the parameters is equal to
the total size for the record minus 3 short words (= 16 + 32 bits)
Example :
while (functionId > 0) {
recSize = readInt( is );
// Subtract size in 16-bit words of recSize and functionId;
recSize -= 3;
functionId = readShort( is );
if ( functionId <= 0 )
break;
switch ( functionId ) {
case WMFConstants.<a WMF function ID> {
do something when this function is encountered
}
break;
default:
for ( int j = 0; j < recSize; j++ )
readShort(is);
break;
See Also: WMFConstants
protected short readShort(DataInputStream is)
Read the next short (2 bytes) value in the DataInputStream.
public abstract void reset()
resets this WMFReader.
protected void setReading(boolean state)
Copyright B) 2008 Apache Software Foundation. All Rights Reserved.