Package org.astrogrid.samp.bridge
Class IconAdjuster
- java.lang.Object
-
- org.astrogrid.samp.bridge.IconAdjuster
-
- All Implemented Interfaces:
HttpServer.Handler
- Direct Known Subclasses:
ProxyManager.ProxyIconAdjuster
abstract class IconAdjuster extends java.lang.Object implements HttpServer.Handler
HttpServer handler for turning the URL of one icon into the URL of another, related icon.- Since:
- 23 Jul 2009
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description private java.net.URL
baseUrl_
private static java.lang.String
OUTPUT_FORMAT_NAME
private static java.lang.String
OUTPUT_MIME_TYPE
-
Constructor Summary
Constructors Constructor Description IconAdjuster(HttpServer server, java.lang.String basePath)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.awt.image.RenderedImage
adjustImage(java.awt.image.BufferedImage inImage)
Produces an adjusted image for serving.java.net.URL
exportAdjustedIcon(java.net.URL iconUrl)
Returns a URL at which the dynamically adjusted version of the icon at the given URL will be served.private java.net.URL
getOriginalUrl(java.lang.String resourcePath)
Returns the URL at which the underlying icon for the one represented by the given server path.HttpServer.Response
serveRequest(HttpServer.Request request)
Provides a response to an HTTP request.
-
-
-
Field Detail
-
baseUrl_
private final java.net.URL baseUrl_
-
OUTPUT_FORMAT_NAME
private static final java.lang.String OUTPUT_FORMAT_NAME
- See Also:
- Constant Field Values
-
OUTPUT_MIME_TYPE
private static final java.lang.String OUTPUT_MIME_TYPE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IconAdjuster
public IconAdjuster(HttpServer server, java.lang.String basePath)
Constructor.- Parameters:
server
- server with which this handler will be usedbasePath
- path at which the dynamic URLs generated by this server will be rooted
-
-
Method Detail
-
adjustImage
public abstract java.awt.image.RenderedImage adjustImage(java.awt.image.BufferedImage inImage)
Produces an adjusted image for serving.- Parameters:
inImage
- input image- Returns:
- adjusted version of
inImage
-
exportAdjustedIcon
public java.net.URL exportAdjustedIcon(java.net.URL iconUrl)
Returns a URL at which the dynamically adjusted version of the icon at the given URL will be served.- Parameters:
iconUrl
- URL of existing icon (GIF, PNG or JPEG)
-
getOriginalUrl
private java.net.URL getOriginalUrl(java.lang.String resourcePath) throws java.net.MalformedURLException
Returns the URL at which the underlying icon for the one represented by the given server path. TheresourcePath
should be the path part of a URL returned from an earlier call toexportAdjustedIcon(java.net.URL)
.- Parameters:
resourcePath
- path part of a URL requesting an adjusted icon- Returns:
- original icon corresponding to resourcePath, or null if it doesn't look like a path this object dispensed
- Throws:
java.net.MalformedURLException
-
serveRequest
public HttpServer.Response serveRequest(HttpServer.Request request)
Description copied from interface:HttpServer.Handler
Provides a response to an HTTP request. A handler which does not recognise the URL should simply return null; in this case there may be another handler which is able to serve the request. If the URL appears to be in this handler's domain but the request cannot be served for some reason, an error response should be returned.- Specified by:
serveRequest
in interfaceHttpServer.Handler
- Parameters:
request
- HTTP request- Returns:
- response response to request, or null
-
-