001package com.hfg.xml.msofficexml.part; 002 003import java.io.InputStream; 004 005import com.hfg.graphics.units.GfxSize2D; 006import com.hfg.image.ImageFormat; 007import com.hfg.util.StringUtil; 008import com.hfg.xml.msofficexml.OfficeOpenXmlDocument; 009 010//------------------------------------------------------------------------------ 011/** 012 Represents an Office Open XML image part. 013 014 @author J. Alex Taylor, hairyfatguy.com 015 */ 016//------------------------------------------------------------------------------ 017// com.hfg XML/HTML Coding Library 018// 019// This library is free software; you can redistribute it and/or 020// modify it under the terms of the GNU Lesser General Public 021// License as published by the Free Software Foundation; either 022// version 2.1 of the License, or (at your option) any later version. 023// 024// This library is distributed in the hope that it will be useful, 025// but WITHOUT ANY WARRANTY; without even the implied warranty of 026// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 027// Lesser General Public License for more details. 028// 029// You should have received a copy of the GNU Lesser General Public 030// License along with this library; if not, write to the Free Software 031// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 032// 033// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 034// jataylor@hairyfatguy.com 035//------------------------------------------------------------------------------ 036 037public class ImagePart extends MediaPart 038{ 039 private ImageFormat mImageFormat; 040 private Float mScalingFactor; 041 042 //########################################################################### 043 // CONSTRUCTORS 044 //########################################################################### 045 046 //--------------------------------------------------------------------------- 047 public ImagePart(OfficeOpenXmlDocument inParentDoc, InputStream inStream, String inName) 048 { 049 super(inParentDoc, inStream, inName); 050 } 051 052 //--------------------------------------------------------------------------- 053 public ImagePart(OfficeOpenXmlDocument inParentDoc, InputStream inStream, String inName, GfxSize2D inDimensions) 054 { 055 super(inParentDoc, inStream, inName, inDimensions); 056 } 057 058 //########################################################################### 059 // PUBLIC METHODS 060 //########################################################################### 061 062 //--------------------------------------------------------------------------- 063 /** 064 Specifies the scaling factor that was used (for informational purposes). 065 * @param inValue the scaling factor used to adjust the displayed image size 066 * @return this document part to enable method chaining. 067 */ 068 public ImagePart setScalingFactor(float inValue) 069 { 070 mScalingFactor = inValue; 071 return this; 072 } 073 074 //--------------------------------------------------------------------------- 075 /** 076 Returns the scaling factor that was used (for informational purposes). 077 * @return the scaling factor used to adjust the displayed image size 078 */ 079 public Float getScalingFactor() 080 { 081 return mScalingFactor; 082 } 083 084 //########################################################################### 085 // PRIVATE METHODS 086 //########################################################################### 087 088 //--------------------------------------------------------------------------- 089 private ImageFormat getImageFormat() 090 { 091 if (null == mImageFormat) 092 { 093 if (StringUtil.isSet(getFile().getName())) 094 { 095 mImageFormat = ImageFormat.guessFormatFromName(getFile().getName()); 096 } 097 } 098 099 return mImageFormat; 100 } 101}