Class IconAdjuster

    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 used
        basePath - 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. The resourcePath should be the path part of a URL returned from an earlier call to exportAdjustedIcon(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 interface HttpServer.Handler
        Parameters:
        request - HTTP request
        Returns:
        response response to request, or null