Home » pdfbox-1.1.0-src » org.apache.jempbox.xmp » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.jempbox.xmp;
   18   
   19   import org.apache.jempbox.impl.XMLUtil;
   20   import org.w3c.dom.Element;
   21   
   22   /**
   23    * This class represents a thumbnail datatype.
   24    * 
   25    * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
   26    * @version $Revision: 1.3 $
   27    */
   28   public class Thumbnail
   29   {
   30       /**
   31        * A supported thumnail format.
   32        */
   33       public static final String FORMAT_JPEG = "JPEG";
   34       
   35       
   36       /**
   37        * The DOM representation of this object.
   38        */
   39       protected Element parent = null;
   40       
   41       /**
   42        * Create a new thumbnail element.
   43        * 
   44        * @param metadata The metadata document that his thumbnail will be part of.
   45        */
   46       public Thumbnail( XMPMetadata metadata )
   47       {
   48           this( metadata.xmpDocument.createElement( "rfd:li" ) );
   49       }
   50       
   51       /**
   52        * Create a thumnail based on a parent property set.
   53        *
   54        * @param parentElement The parent element that will store the thumbnail properties.
   55        */
   56       public Thumbnail( Element parentElement )
   57       {
   58           parent = parentElement;
   59           parent.setAttributeNS( 
   60               XMPSchema.NS_NAMESPACE, 
   61               "xmlns:xapGImg", 
   62               "http://ns.adobe.com/xap/1.0/g/img/" );
   63       }
   64       
   65       /**
   66        * Get the underlying XML element.
   67        * 
   68        * @return The XML element that this object represents.
   69        */
   70       public Element getElement()
   71       {
   72           return parent;
   73       }
   74       
   75       /**
   76        * Get the height of the image in pixels.
   77        * 
   78        * @return The height of the image in pixels.
   79        */
   80       public Integer getHeight()
   81       {
   82           return XMLUtil.getIntValue( parent, "xapGImg:height" );
   83       }
   84       
   85       /**
   86        * Set the height of the element.
   87        * 
   88        * @param height The updated height of the element.
   89        */
   90       public void setHeight( Integer height )
   91       {
   92           XMLUtil.setIntValue( parent, "xapGImg:height", height );
   93       }
   94       
   95       /**
   96        * Get the width of the image in pixels.
   97        * 
   98        * @return The width of the image in pixels.
   99        */
  100       public Integer getWidth()
  101       {
  102           return XMLUtil.getIntValue( parent, "xapGImg:width" );
  103       }
  104       
  105       /**
  106        * Set the width of the element.
  107        * 
  108        * @param width The updated width of the element.
  109        */
  110       public void setWidth( Integer width )
  111       {
  112           XMLUtil.setIntValue( parent, "xapGImg:width", width );
  113       }
  114       
  115       /**
  116        * Set the format of the thumbnail, currently only JPEG is supported.  See FORMAT_XXX constants.
  117        * 
  118        * @param format The image format.
  119        */
  120       public void setFormat( String format )
  121       {
  122           XMLUtil.setStringValue( parent, "xapGImg:format", format );
  123       }
  124       
  125       /**
  126        * Get the format of the thumbnail.  See FORMAT_XXX constants.
  127        * 
  128        * @return The image format.
  129        */
  130       public String getFormat()
  131       {
  132           return XMLUtil.getStringValue( parent, "xapGImg:format" );
  133       }
  134       
  135       /**
  136        * Set the image data in base 64 encoding.
  137        * 
  138        * @param image The image.
  139        */
  140       public void setImage( String image )
  141       {
  142           XMLUtil.setStringValue( parent, "xapGImg:image", image );
  143       }
  144       
  145       /**
  146        * Get the image data in base 64 encoding.
  147        * 
  148        * @return The image data.
  149        */
  150       public String getImage()
  151       {
  152           return XMLUtil.getStringValue( parent, "xapGImg:format" );
  153       }
  154   }

Home » pdfbox-1.1.0-src » org.apache.jempbox.xmp » [javadoc | source]