Interface GraphicsUtils


public interface GraphicsUtils
Multi-platform graphic utils interface. This allows platforms with poor java.awt.Graphics2D implementations to share most of the application source code.
Author:
Juan Lucas Dominguez Rubio jldominguez at prodevelop.es
  • Method Details

    • createBufferedImage

      BufferedImage createBufferedImage(int w, int h, int type)
      Create a buffered Image of the given size and type. In this context, buffered image means editable image (admits setRGB etc)
      Parameters:
      w - width in pixels of the requested image
      h - height in pixels of the requested image
      type - image type (refers to bands, etc. see
      invalid reference
      Image
      Returns:
      a buffered (editable) image of the desired size and type
    • copyBufferedImage

      BufferedImage copyBufferedImage(BufferedImage img)
      Produces a copy of a buffered image with the same graphic content (pixel color)
      Parameters:
      img - image to be copied
      Returns:
      new instance of a BufferedImage (editable) with same size, type and graphic content.
    • deriveFont

      Font deriveFont(Font srcfont, float newheight)
      Returns an istance of Font which is the same as the one provided except for the size.
      Parameters:
      srcfont - provided font to be used as model
      newheight - height in pixels of the new fonr
      Returns:
      the new font, same properties as the provided font, but different size
    • getScreenDPI

      int getScreenDPI()
      Returns device screen DPI (dots per inch)
      Returns:
      number of pixels per inch in the current screen
    • translate

      void translate(Graphics2D g, double x, double y)
      Adds a translation operation to the Graphics2D object's transformation matrix.
      Parameters:
      g - Object whose transformation matrix has to be modified
      x - horizontal offset of the translation
      y - vertical offset of the translation
    • createPrintAttributes

      PrintAttributes createPrintAttributes()
      Creates an object that implements the PrintAttributes interface with default/trivial values.
      Returns:
      an object that implements the PrintAttributes interface with default/trivial values.
    • setRenderingHintsForDrawing

      void setRenderingHintsForDrawing(Graphics2D g)
      Sets the rendering hints to the Graphics2D object in a way that is suitable for drawing.
      Parameters:
      g - the Graphics2D object whose rendering hints have to be set for drawing
    • setRenderingHintsForPrinting

      void setRenderingHintsForPrinting(Graphics2D g)
      Sets the rendering hints to the Graphics2D object in a way that is suitable for printing.
      Parameters:
      g - the Graphics2D object whose rendering hints have to be set for printing