Class RMAWTUtils

  • All Implemented Interfaces:
    RMPropertyChanger, java.lang.Cloneable

    public class RMAWTUtils
    extends RMObject
    This class has a bunch of convenience utility methods from drawing lines, RMRects, buttons, etc.
    • Constructor Summary

      Constructors 
      Constructor Description
      RMAWTUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void drawButton​(java.awt.Graphics2D g, double x, double y, double w, double h, boolean isPressed)
      Draws a button for the given rect with an option for pressed.
      static void drawButton​(java.awt.Graphics2D g, RMRect aRect, boolean isPressed)
      Draws a button for the given rect with an option for pressed.
      static void drawLine​(java.awt.Graphics2D g, double p1x, double p1y, double p2x, double p2y)
      Draws a line between the given points.
      static void drawLine​(java.awt.Graphics2D g, RMPoint p1, RMPoint p2)
      Draws a line between the given points.
      static void drawRect​(java.awt.Graphics2D g, double x, double y, double w, double h)
      Strokes the given rect.
      static void fill3DRect​(java.awt.Graphics2D g, double x, double y, double w, double h, boolean isRaised)
      Fills the given rect with simple 3D button effect.
      static void fill3DRect​(java.awt.Graphics2D g, RMRect aRect, boolean isRaised)
      Fills the given rect with simple 3D button effect.
      static void fillRect​(java.awt.Graphics2D g, double x, double y, double w, double h)
      Fills the given rect.
      static java.awt.Color fromStringColor​(java.lang.String aString)
      Returns a Color from a String/hex representation.
      static java.awt.Insets fromStringInsets​(java.lang.String aString)
      Returns an Insets instance from given string.
      static java.awt.image.BufferedImage getBufferedImage​(int aWidth, int aHeight, boolean withAlpha)
      Returns a compatible buffered image for width and height with given transparency.
      static java.awt.image.BufferedImage getBufferedImage​(java.awt.Image anImage)
      Returns a buffered image for an AWT image with transparency.
      static java.awt.image.BufferedImage getBufferedImage​(java.awt.Image anImage, boolean withAlpha)
      Returns a buffered image for an AWT image.
      static byte[] getBytesJPEG​(java.awt.Image anImage)
      Returns a JPeg byte array for the given buffered image.
      static byte[] getBytesPNG​(java.awt.Image anImage)
      Returns a PNG byte array for the given buffered image.
      static java.awt.Cursor getHiddenCursor()
      A method to hide the cursor.
      static java.awt.Image getImageForString​(java.lang.String aString, java.awt.Font aFont)
      Returns an image for the given string and font.
      static java.awt.Cursor getResizeCursor​(int anEdgeMask)
      Returns a resize cursor for a rect edge mask.
      static java.awt.BasicStroke getStroke​(float aStrokeWidth)
      Returns a basic stroke with the given stroke width.
      static boolean isCommandDown​(java.awt.event.InputEvent anEvent)
      Returns whether the given event has command down.
      static boolean isControlDown​(java.awt.event.InputEvent anEvent)
      Returns whether the given input event has control down.
      static boolean setAntialiasing​(java.awt.Graphics2D g, boolean aFlag)
      Turns antialiasing on or off for a given graphics (returns previous state).
      static java.lang.String toStringColor​(java.awt.Color aColor)
      Returns a String/hex representation of a given color (eg, "#FF00D8").
      static java.lang.String toStringInsets​(java.awt.Insets theInsets)
      Returns a string representation of a given Insets.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • Stroke1

        public static final java.awt.BasicStroke Stroke1
      • StrokeDash1

        public static final java.awt.BasicStroke StrokeDash1
      • COMMAND_MASK

        public static final int COMMAND_MASK
      • CONTROL_MASK

        public static final int CONTROL_MASK
      • Arial8

        public static java.awt.Font Arial8
      • Arial10

        public static java.awt.Font Arial10
      • ArialBold10

        public static java.awt.Font ArialBold10
      • Arial11

        public static java.awt.Font Arial11
      • ArialBold11

        public static java.awt.Font ArialBold11
      • Arial12

        public static java.awt.Font Arial12
      • ArialBold12

        public static java.awt.Font ArialBold12
      • Arial14

        public static java.awt.Font Arial14
      • ArialBold14

        public static java.awt.Font ArialBold14
      • Helvetica10

        public static java.awt.Font Helvetica10
      • Helvetica11

        public static java.awt.Font Helvetica11
      • HelveticaBold11

        public static java.awt.Font HelveticaBold11
      • Helvetica12

        public static java.awt.Font Helvetica12
      • HelveticaBold12

        public static java.awt.Font HelveticaBold12
    • Constructor Detail

      • RMAWTUtils

        public RMAWTUtils()
    • Method Detail

      • isCommandDown

        public static boolean isCommandDown​(java.awt.event.InputEvent anEvent)
        Returns whether the given event has command down.
      • isControlDown

        public static boolean isControlDown​(java.awt.event.InputEvent anEvent)
        Returns whether the given input event has control down.
      • getStroke

        public static java.awt.BasicStroke getStroke​(float aStrokeWidth)
        Returns a basic stroke with the given stroke width.
      • drawLine

        public static void drawLine​(java.awt.Graphics2D g,
                                    RMPoint p1,
                                    RMPoint p2)
        Draws a line between the given points.
      • drawLine

        public static void drawLine​(java.awt.Graphics2D g,
                                    double p1x,
                                    double p1y,
                                    double p2x,
                                    double p2y)
        Draws a line between the given points.
      • drawRect

        public static void drawRect​(java.awt.Graphics2D g,
                                    double x,
                                    double y,
                                    double w,
                                    double h)
        Strokes the given rect.
      • fillRect

        public static void fillRect​(java.awt.Graphics2D g,
                                    double x,
                                    double y,
                                    double w,
                                    double h)
        Fills the given rect.
      • fill3DRect

        public static void fill3DRect​(java.awt.Graphics2D g,
                                      RMRect aRect,
                                      boolean isRaised)
        Fills the given rect with simple 3D button effect.
      • fill3DRect

        public static void fill3DRect​(java.awt.Graphics2D g,
                                      double x,
                                      double y,
                                      double w,
                                      double h,
                                      boolean isRaised)
        Fills the given rect with simple 3D button effect.
      • drawButton

        public static void drawButton​(java.awt.Graphics2D g,
                                      RMRect aRect,
                                      boolean isPressed)
        Draws a button for the given rect with an option for pressed.
      • drawButton

        public static void drawButton​(java.awt.Graphics2D g,
                                      double x,
                                      double y,
                                      double w,
                                      double h,
                                      boolean isPressed)
        Draws a button for the given rect with an option for pressed.
      • setAntialiasing

        public static boolean setAntialiasing​(java.awt.Graphics2D g,
                                              boolean aFlag)
        Turns antialiasing on or off for a given graphics (returns previous state).
      • toStringInsets

        public static java.lang.String toStringInsets​(java.awt.Insets theInsets)
        Returns a string representation of a given Insets.
      • fromStringInsets

        public static java.awt.Insets fromStringInsets​(java.lang.String aString)
        Returns an Insets instance from given string.
      • toStringColor

        public static java.lang.String toStringColor​(java.awt.Color aColor)
        Returns a String/hex representation of a given color (eg, "#FF00D8").
      • fromStringColor

        public static java.awt.Color fromStringColor​(java.lang.String aString)
        Returns a Color from a String/hex representation.
      • getResizeCursor

        public static java.awt.Cursor getResizeCursor​(int anEdgeMask)
        Returns a resize cursor for a rect edge mask.
      • getBytesJPEG

        public static byte[] getBytesJPEG​(java.awt.Image anImage)
        Returns a JPeg byte array for the given buffered image.
      • getBytesPNG

        public static byte[] getBytesPNG​(java.awt.Image anImage)
        Returns a PNG byte array for the given buffered image.
      • getBufferedImage

        public static java.awt.image.BufferedImage getBufferedImage​(java.awt.Image anImage)
        Returns a buffered image for an AWT image with transparency.
      • getBufferedImage

        public static java.awt.image.BufferedImage getBufferedImage​(java.awt.Image anImage,
                                                                    boolean withAlpha)
        Returns a buffered image for an AWT image.
      • getBufferedImage

        public static java.awt.image.BufferedImage getBufferedImage​(int aWidth,
                                                                    int aHeight,
                                                                    boolean withAlpha)
        Returns a compatible buffered image for width and height with given transparency.
      • getImageForString

        public static java.awt.Image getImageForString​(java.lang.String aString,
                                                       java.awt.Font aFont)
        Returns an image for the given string and font.
      • getHiddenCursor

        public static java.awt.Cursor getHiddenCursor()
        A method to hide the cursor.