|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--javax.servlet.GenericServlet
|
+--javax.servlet.http.HttpServlet
|
+--com.vmax.servlet.core.CachedServlet
|
+--com.vmax.servlet.core.CachedGraphicsServlet
This class provides basic functinality for Graphics servlets suite. To implement your own graphics servlet you only need to override 3 abstract methods
| Field Summary | |
static int |
ALIGN_BOTTOM
bottom alignment |
static int |
ALIGN_CENTER
center horizontal alignment |
static int |
ALIGN_LEFT
Left alignment |
static int |
ALIGN_MIDDLE
Middle verrtial allignment |
static int |
ALIGN_RIGHT
right alinment |
static int |
ALIGN_TOP
TOP alignment |
static long |
DAY
|
static long |
HOUR
|
static long |
MONTH
|
static java.lang.String |
TTL
|
static long |
WEEK
|
static long |
YEAR
|
| Constructor Summary | |
CachedGraphicsServlet()
|
|
| Method Summary | |
protected java.lang.String |
countHash(BasicHttpRequest req,
java.lang.String[] parameterNames)
|
void |
destroy()
|
void |
drawLines(java.awt.Graphics2D graphics,
java.util.List lines,
java.awt.Rectangle text_rect,
java.awt.FontMetrics fm,
int align)
Method to draw text lines |
abstract java.lang.String[] |
getActualParameterNames()
This method supposed to return array of parameters names which are actual parameters for your servlet, this is necessary because request may contain other parameters which are not in use. |
int |
getAlignParameter(BasicHttpRequest req,
java.lang.String name,
int deft)
Usefull function to obtain alignment parameters. |
java.lang.String |
getBasePath()
|
java.awt.Color |
getColorParam(BasicHttpRequest req,
java.lang.String name,
int deft)
Usefull function to obtain parameter value from request as hex value of color in aarrggbb format and construct Color object. |
abstract java.lang.String |
getContentType(javax.servlet.http.HttpServletRequest req)
This method is used to get content type for setting response content type. |
protected long |
getExpiration(javax.servlet.http.HttpServletRequest req)
|
java.io.File |
getFontsDir()
method to get fonts directory defined with servlet init parameter fonts_dir |
int |
getHexParam(BasicHttpRequest req,
java.lang.String name,
int deft)
Usefull function to obtain String parameter value from request interpreting it as hexadecimal string or use default. |
java.awt.image.BufferedImage |
getImageParam(BasicHttpRequest req,
java.lang.String name)
Usful method to get parameter value as image name and looad image from backgrounds directory. |
java.awt.FontMetrics |
getMetrics(java.awt.Font font)
Function to obtain font metrics for futher dimensions calculations |
int |
getParam(BasicHttpRequest req,
java.lang.String name,
int deft)
Usefull function to obtain int parameter value interpreting it as decimal integer string from request or use default. |
java.lang.String |
getParam(BasicHttpRequest req,
java.lang.String name,
java.lang.String deft)
Usefull function to obtain String parameter value from request or use default. |
java.awt.Dimension |
getRequiredRect(java.util.List lines,
java.awt.FontMetrics fm,
int minWidth,
int minHeight)
Method to obtain dimensions required to fit List of lines |
static java.io.File |
getWorkingDir(javax.servlet.ServletContext context,
java.lang.String paramName,
java.lang.String deft,
boolean create)
|
java.io.File |
getWorkingDir(java.lang.String paramName,
java.lang.String deft,
boolean create)
|
void |
init(javax.servlet.ServletConfig servletConfig)
|
java.awt.Font |
loadFontFromPath(java.lang.String fontpath,
int fontSize)
Function to get Font. |
java.lang.String |
seekParam(BasicHttpRequest req,
java.lang.String name)
|
abstract void |
serve(BasicHttpRequest req,
java.io.ByteArrayOutputStream baos)
Basic painting method to implement pinting logic. |
protected void |
service(BasicHttpRequest req,
javax.servlet.http.HttpServletResponse res,
long expiration)
|
void |
service(javax.servlet.ServletRequest req,
javax.servlet.ServletResponse res)
|
void |
setRenderingHints(java.awt.Graphics2D g)
Set optimal rendering parameters for generating graphics |
protected void |
setResponseHeaders(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
If you need to add specific headers to response, than override this method |
java.util.ArrayList |
splitText(java.lang.String text,
java.awt.FontMetrics fm,
int w)
Function to split text in multiline in desired width using given fontMetrics. |
static void |
tileBackground(java.awt.image.BufferedImage im,
java.awt.Graphics2D graphics,
java.awt.image.BufferedImage bgim,
int align)
Method to tile background image over given graphics object |
| Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service |
| Methods inherited from class javax.servlet.GenericServlet |
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int ALIGN_TOP
public static final int ALIGN_MIDDLE
public static final int ALIGN_BOTTOM
public static final int ALIGN_LEFT
public static final int ALIGN_CENTER
public static final int ALIGN_RIGHT
public static final java.lang.String TTL
public static final long YEAR
public static final long MONTH
public static final long WEEK
public static final long DAY
public static final long HOUR
| Constructor Detail |
public CachedGraphicsServlet()
| Method Detail |
public abstract java.lang.String[] getActualParameterNames()
getActualParameterNames in class com.vmax.servlet.core.CachedServletpublic abstract java.lang.String getContentType(javax.servlet.http.HttpServletRequest req)
getContentType in class com.vmax.servlet.core.CachedServletreq - - original http request
public abstract void serve(BasicHttpRequest req,
java.io.ByteArrayOutputStream baos)
throws java.lang.Exception
serve in class com.vmax.servlet.core.CachedServletreq - - request wrapperbaos - - output stream to write image data
java.lang.Exception
public void init(javax.servlet.ServletConfig servletConfig)
throws javax.servlet.ServletException
init in interface javax.servlet.Servletinit in class com.vmax.servlet.core.CachedServletjavax.servlet.ServletExceptionpublic void setRenderingHints(java.awt.Graphics2D g)
g -
public java.awt.Font loadFontFromPath(java.lang.String fontpath,
int fontSize)
throws java.io.IOException,
java.awt.FontFormatException
fontpath - - name of font file or path to font file, relative to fonts_dirfontSize - - font sixe in pixels
java.io.IOException
java.awt.FontFormatExceptionpublic java.awt.FontMetrics getMetrics(java.awt.Font font)
public java.awt.Color getColorParam(BasicHttpRequest req,
java.lang.String name,
int deft)
req - - requestname - - parameter namedeft - - default value
public java.lang.String getParam(BasicHttpRequest req,
java.lang.String name,
java.lang.String deft)
req - - requestname - - parameter namedeft - - default value
public int getParam(BasicHttpRequest req,
java.lang.String name,
int deft)
req - - requestname - - parameter namedeft - - default value
public int getHexParam(BasicHttpRequest req,
java.lang.String name,
int deft)
req - - requestname - - parameter namedeft - - default value
public int getAlignParameter(BasicHttpRequest req,
java.lang.String name,
int deft)
req - - requestname - - parameter namedeft - - default value
public java.util.ArrayList splitText(java.lang.String text,
java.awt.FontMetrics fm,
int w)
text - fm - w -
public java.awt.Dimension getRequiredRect(java.util.List lines,
java.awt.FontMetrics fm,
int minWidth,
int minHeight)
lines - - ordered List of text linesfm - - font metrics to use for text dimensions calculationsminWidth - - minimum Width to returnminHeight - - minimumHeight to return
public void drawLines(java.awt.Graphics2D graphics,
java.util.List lines,
java.awt.Rectangle text_rect,
java.awt.FontMetrics fm,
int align)
graphics - - graphics object to draw on.lines - - ordered List of linestext_rect - - rectangle to define offsets and dimensions of text alignment bounds.fm - - font metrics object for size calculationsalign - - alignment parameter
public java.awt.image.BufferedImage getImageParam(BasicHttpRequest req,
java.lang.String name)
req - - http requestname - - image file name
public static void tileBackground(java.awt.image.BufferedImage im,
java.awt.Graphics2D graphics,
java.awt.image.BufferedImage bgim,
int align)
im - - image to paint over, passed only to obtain it's dimensionsgraphics - - graphics object to draw onbgim - - background image to tilealign - - background alignment.public java.io.File getFontsDir()
protected void setResponseHeaders(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
req - res -
protected java.lang.String countHash(BasicHttpRequest req,
java.lang.String[] parameterNames)
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public java.io.File getWorkingDir(java.lang.String paramName,
java.lang.String deft,
boolean create)
public static java.io.File getWorkingDir(javax.servlet.ServletContext context,
java.lang.String paramName,
java.lang.String deft,
boolean create)
protected void service(BasicHttpRequest req,
javax.servlet.http.HttpServletResponse res,
long expiration)
throws javax.servlet.ServletException,
java.io.IOException
javax.servlet.ServletException
java.io.IOException
public void service(javax.servlet.ServletRequest req,
javax.servlet.ServletResponse res)
throws javax.servlet.ServletException,
java.io.IOException
service in interface javax.servlet.Servletservice in class javax.servlet.http.HttpServletjavax.servlet.ServletException
java.io.IOExceptionprotected long getExpiration(javax.servlet.http.HttpServletRequest req)
public java.lang.String getBasePath()
public void destroy()
destroy in interface javax.servlet.Servletdestroy in class javax.servlet.GenericServlet
public java.lang.String seekParam(BasicHttpRequest req,
java.lang.String name)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||