View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.plugin.basic;
17  
18  import java.util.Iterator;
19  import java.util.List;
20  
21  import org.seasar.tuigwaa.cms.core.CmsRequest;
22  import org.seasar.tuigwaa.cms.core.CmsResponse;
23  import org.seasar.tuigwaa.plugin.PluginException;
24  import org.seasar.tuigwaa.plugin.PluginRequest;
25  
26  import com.lowagie.text.Chunk;
27  import com.lowagie.text.Font;
28  import com.lowagie.text.Phrase;
29  
30  public class PdfSizePlugin extends SizePlugin {
31  
32  	public Object doPDFView(CmsRequest request, CmsResponse response, PluginRequest prequest) throws PluginException {
33  				
34  		String[] array = prequest.getArgs();
35  		Object child = prequest.getChild();
36  		
37  		if(array == null) return child;
38  		
39  		if(array.length >= 1){
40  
41  			String sizestr = array[0].replaceAll("px|PX|pX|Px","");
42  			float size = Float.parseFloat(sizestr);			
43  		
44  			if(child instanceof Phrase){
45  				Phrase p = (Phrase) child;
46  				List list = p.getChunks();
47  				if(list != null){
48  					for(Iterator i = list.iterator();i.hasNext();){
49  						Chunk c = (Chunk)i.next();
50  						Font nf = new Font(c.font());
51  						nf.setSize(size);
52  						c.setFont(nf);
53  					}
54  				}
55  			}
56  		}
57  		return child;
58  	}
59  	
60  }