1 17 18 19 20 package org.apache.fop.render; 21 22 import java.util.Map ; 24 25 import org.apache.avalon.framework.configuration.Configuration; 27 import org.apache.fop.apps.FOUserAgent; 28 29 34 public class RendererContext { 35 36 private String mime; 37 private AbstractRenderer renderer; 38 private FOUserAgent userAgent; 39 private Map props = new java.util.HashMap (); 40 41 47 public RendererContext(AbstractRenderer renderer, String m) { 48 this.renderer = renderer; 49 this.mime = m; 50 } 51 52 55 public AbstractRenderer getRenderer() { 56 return renderer; 57 } 58 59 64 public String getMimeType() { 65 return mime; 66 } 67 68 73 public void setUserAgent(FOUserAgent ua) { 74 userAgent = ua; 75 } 76 77 82 public FOUserAgent getUserAgent() { 83 return userAgent; 84 } 85 86 92 public void setProperty(String name, Object val) { 93 props.put(name, val); 94 } 95 96 102 public Object getProperty(String prop) { 103 return props.get(prop); 104 } 105 106 112 public static RendererContextWrapper wrapRendererContext(RendererContext context) { 113 RendererContextWrapper wrapper = new RendererContextWrapper(context); 114 return wrapper; 115 } 116 117 121 public static class RendererContextWrapper { 122 123 124 protected RendererContext context; 125 126 130 public RendererContextWrapper(RendererContext context) { 131 this.context = context; 132 } 133 134 135 public FOUserAgent getUserAgent() { 136 return context.getUserAgent(); 137 } 138 139 140 public int getCurrentXPosition() { 141 return ((Integer )context.getProperty(RendererContextConstants.XPOS)).intValue(); 142 } 143 144 145 public int getCurrentYPosition() { 146 return ((Integer )context.getProperty(RendererContextConstants.YPOS)).intValue(); 147 } 148 149 150 public int getWidth() { 151 return ((Integer )context.getProperty(RendererContextConstants.WIDTH)).intValue(); 152 } 153 154 155 public int getHeight() { 156 return ((Integer )context.getProperty(RendererContextConstants.HEIGHT)).intValue(); 157 } 158 159 160 public Configuration getHandlerConfiguration() { 161 return (Configuration)context.getProperty( 162 RendererContextConstants.HANDLER_CONFIGURATION); 163 } 164 165 166 public Map getForeignAttributes() { 167 return (Map )context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); 168 } 169 170 } 171 } 172 173 | Popular Tags |