/** get the Color corresponding with the Object (pen or brush object). */ private Color getColorFromObject(int brushObject) { Color color = null; if ( brushObject >= 0 ) { GdiObject gdiObj = getObject( brushObject ); return (Color)gdiObj.obj; } else return null; }
private void resetBounds() { // calculate geometry size scale = (float)getWidthPixels() / (float)vpW ; if (_bright != -1) { _bright = (int)(scale * (vpX +_bright)); _bleft = (int)(scale * (vpX +_bleft)); _bbottom = (int)(scale * (vpY +_bbottom)); _btop = (int)(scale * (vpY +_btop)); } // calculate image size if (_iright != -1) { _iright = (int)((float)_iright * (float)getWidthPixels() / (float)width); _ileft = (int)((float)_ileft * (float)getWidthPixels() / (float)width); _ibottom = (int)((float)_ibottom * (float)getWidthPixels() / (float)width); _itop = (int)((float)_itop * (float)getWidthPixels() / (float)width); // merge image and geometry size if ((_bright == -1) || (_iright > _bright)) _bright = _iright; if ((_bleft == -1) || (_ileft < _bleft)) _bleft = _ileft; if ((_btop == -1) || (_itop < _btop)) _btop = _itop; if ((_bbottom == -1) || (_ibottom > _bbottom)) _bbottom = _ibottom; } if ((_bleft != -1) && (_bright != -1)) _bwidth = _bright - _bleft; if ((_btop != -1) && (_bbottom != -1)) _bheight = _bbottom - _btop; }
/** Creates a new WMFHeaderProperties, and sets the associated WMF File. * @param wmffile the WMF Metafile */ public WMFHeaderProperties(File wmffile) throws IOException { super(); reset(); stream = new DataInputStream(new BufferedInputStream(new FileInputStream(wmffile))); read(stream); stream.close(); }
recSize = readInt( is ); functionId = readShort( is ); if ( functionId <= 0 ) break; int mapmode = readShort( is ); vpY = readShort( is ); vpX = readShort( is ); vpH = readShort( is ); vpW = readShort( is ); if (! isotropic) scaleXY = (float)vpW / vpH; vpW = (int)(vpW * scaleXY); int penStyle = readShort( is ); readInt( is ); // width int colorref = readInt( is ); int red = colorref & 0xff; int green = ( colorref & 0xff00 ) >> 8; if (recSize == 6) readShort(is); // if size greater than 5 if ( penStyle == WMFConstants.META_PS_NULL ) { objIndex = addObjectAt( NULL_PEN, color, objIndex ); } else { objIndex = addObjectAt( PEN, color, objIndex );
/** Resize the bounds of the WMF image according with the bounds of the geometric * Shape. * There will be no resizing if one of the following properties is true : * <ul> * <li>the brush and the pen objects are < 0 (null objects)</li> * <li>the color of the geometric Shape is white, and no other Shapes has occured</li> * </ul> */ private void paint(int brushObject, int penObject, Shape shape) { if (( brushObject >= 0 ) || (penObject >= 0)) { Color col; if (brushObject >= 0) col = getColorFromObject(brushObject); else col = getColorFromObject(penObject); if (!(firstEffectivePaint && (col.equals(Color.white)))) { Rectangle rec = shape.getBounds(); resizeBounds((int)rec.getMinX(), (int)rec.getMinY()); resizeBounds((int)rec.getMaxX(), (int)rec.getMaxY()); firstEffectivePaint = false; } } }
/** Creates the properties associated file. */ public void setFile(File wmffile) throws IOException { stream = new DataInputStream(new BufferedInputStream(new FileInputStream(wmffile))); read(stream); stream.close(); }
recSize = readInt( is ); functionId = readShort( is ); if ( functionId <= 0 ) break; int mapmode = readShort( is ); vpY = readShort( is ); vpX = readShort( is ); vpH = readShort( is ); vpW = readShort( is ); if (! isotropic) scaleXY = (float)vpW / (float)vpH; vpW = (int)(vpW * scaleXY); int penStyle = readShort( is ); readInt( is ); // width int colorref = readInt( is ); int red = colorref & 0xff; int green = ( colorref & 0xff00 ) >> 8; if (recSize == 6) readShort(is); // if size greater than 5 if ( penStyle == WMFConstants.META_PS_NULL ) { objIndex = addObjectAt( NULL_PEN, color, objIndex ); } else { objIndex = addObjectAt( PEN, color, objIndex );
/** Resize the bounds of the WMF image according with the bounds of the geometric * Shape. * There will be no resizing if one of the following properties is true : * <ul> * <li>the brush and the pen objects are < 0 (null objects)</li> * <li>the color of the geometric Shape is white, and no other Shapes has occured</li> * </ul> */ private void paint(int brushObject, int penObject, Shape shape) { if (( brushObject >= 0 ) || (penObject >= 0)) { Color col; if (brushObject >= 0) col = getColorFromObject(brushObject); else col = getColorFromObject(penObject); if (!(firstEffectivePaint && (col.equals(Color.white)))) { Rectangle rec = shape.getBounds(); resizeBounds((int)rec.getMinX(), (int)rec.getMinY()); resizeBounds((int)rec.getMaxX(), (int)rec.getMaxY()); firstEffectivePaint = false; } } }
/** Creates the properties associated file. */ public void setFile(File wmffile) throws IOException { stream = new DataInputStream(new BufferedInputStream(new FileInputStream(wmffile))); read(stream); stream.close(); }
/** Resize the bounds of the WMF image according with the bounds of the geometric * Shape. * There will be no resizing if one of the following properties is true : * <ul> * <li>the pen objects is < 0 (null object)</li> * <li>the color of the geometric Shape is white, and no other Shapes has occured</li> * </ul> */ private void paintWithPen(int penObject, Shape shape) { if (penObject >= 0) { Color col = getColorFromObject(penObject); if (!(firstEffectivePaint && (col.equals(Color.white)))) { Rectangle rec = shape.getBounds(); resizeBounds((int)rec.getMinX(), (int)rec.getMinY()); resizeBounds((int)rec.getMaxX(), (int)rec.getMaxY()); firstEffectivePaint = false; } } }
/** Creates a new WMFHeaderProperties, and sets the associated WMF File. * @param wmffile the WMF Metafile */ public WMFHeaderProperties(File wmffile) throws IOException { super(); reset(); stream = new DataInputStream(new BufferedInputStream(new FileInputStream(wmffile))); read(stream); stream.close(); }
/** get the Color corresponding with the Object (pen or brush object). */ private Color getColorFromObject(int brushObject) { Color color = null; if ( brushObject >= 0 ) { GdiObject gdiObj = getObject( brushObject ); return (Color)gdiObj.obj; } else return null; }
private void resetBounds() { // calculate geometry size scale = (float)getWidthPixels() / vpW; if (_bright != -1) { _bright = (int)(scale * (vpX +_bright)); _bleft = (int)(scale * (vpX +_bleft)); _bbottom = (int)(scale * (vpY +_bbottom)); _btop = (int)(scale * (vpY +_btop)); } // calculate image size if (_iright != -1) { _iright = (int)((float)_iright * getWidthPixels() / width); _ileft = (int)((float)_ileft * getWidthPixels() / width); _ibottom = (int)((float)_ibottom * getWidthPixels() / width); _itop = (int)((float)_itop * getWidthPixels() / width); // merge image and geometry size if ((_bright == -1) || (_iright > _bright)) _bright = _iright; if ((_bleft == -1) || (_ileft < _bleft)) _bleft = _ileft; if ((_btop == -1) || (_itop < _btop)) _btop = _itop; if ((_bbottom == -1) || (_ibottom > _bbottom)) _bbottom = _ibottom; } if ((_bleft != -1) && (_bright != -1)) _bwidth = _bright - _bleft; if ((_btop != -1) && (_bbottom != -1)) _bheight = _bbottom - _btop; }
/** Resize the bounds of the WMF image according with the bounds of the geometric * Shape. * There will be no resizing if one of the following properties is true : * <ul> * <li>the pen objects is < 0 (null object)</li> * <li>the color of the geometric Shape is white, and no other Shapes has occured</li> * </ul> */ private void paintWithPen(int penObject, Shape shape) { if (penObject >= 0) { Color col = getColorFromObject(penObject); if (!(firstEffectivePaint && (col.equals(Color.white)))) { Rectangle rec = shape.getBounds(); resizeBounds((int)rec.getMinX(), (int)rec.getMinY()); resizeBounds((int)rec.getMaxX(), (int)rec.getMaxY()); firstEffectivePaint = false; } } }