Package com.inductiveautomation.rm.base
Class RMAWTUtils
- java.lang.Object
-
- com.inductiveautomation.rm.base.RMListenerList
-
- com.inductiveautomation.rm.base.RMObject
-
- com.inductiveautomation.rm.base.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.
-
-
Field Summary
Fields Modifier and Type Field Description static java.awt.FontArial10static java.awt.FontArial11static java.awt.FontArial12static java.awt.FontArial14static java.awt.FontArial8static java.awt.FontArialBold10static java.awt.FontArialBold11static java.awt.FontArialBold12static java.awt.FontArialBold14static intCOMMAND_MASKstatic intCONTROL_MASKstatic java.awt.FontHelvetica10static java.awt.FontHelvetica11static java.awt.FontHelvetica12static java.awt.FontHelveticaBold11static java.awt.FontHelveticaBold12static java.awt.BasicStrokeStroke1static java.awt.BasicStrokeStrokeDash1
-
Constructor Summary
Constructors Constructor Description RMAWTUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddrawButton(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 voiddrawButton(java.awt.Graphics2D g, RMRect aRect, boolean isPressed)Draws a button for the given rect with an option for pressed.static voiddrawLine(java.awt.Graphics2D g, double p1x, double p1y, double p2x, double p2y)Draws a line between the given points.static voiddrawLine(java.awt.Graphics2D g, RMPoint p1, RMPoint p2)Draws a line between the given points.static voiddrawRect(java.awt.Graphics2D g, double x, double y, double w, double h)Strokes the given rect.static voidfill3DRect(java.awt.Graphics2D g, double x, double y, double w, double h, boolean isRaised)Fills the given rect with simple 3D button effect.static voidfill3DRect(java.awt.Graphics2D g, RMRect aRect, boolean isRaised)Fills the given rect with simple 3D button effect.static voidfillRect(java.awt.Graphics2D g, double x, double y, double w, double h)Fills the given rect.static java.awt.ColorfromStringColor(java.lang.String aString)Returns a Color from a String/hex representation.static java.awt.InsetsfromStringInsets(java.lang.String aString)Returns an Insets instance from given string.static java.awt.image.BufferedImagegetBufferedImage(int aWidth, int aHeight, boolean withAlpha)Returns a compatible buffered image for width and height with given transparency.static java.awt.image.BufferedImagegetBufferedImage(java.awt.Image anImage)Returns a buffered image for an AWT image with transparency.static java.awt.image.BufferedImagegetBufferedImage(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.CursorgetHiddenCursor()A method to hide the cursor.static java.awt.ImagegetImageForString(java.lang.String aString, java.awt.Font aFont)Returns an image for the given string and font.static java.awt.CursorgetResizeCursor(int anEdgeMask)Returns a resize cursor for a rect edge mask.static java.awt.BasicStrokegetStroke(float aStrokeWidth)Returns a basic stroke with the given stroke width.static booleanisCommandDown(java.awt.event.InputEvent anEvent)Returns whether the given event has command down.static booleanisControlDown(java.awt.event.InputEvent anEvent)Returns whether the given input event has control down.static booleansetAntialiasing(java.awt.Graphics2D g, boolean aFlag)Turns antialiasing on or off for a given graphics (returns previous state).static java.lang.StringtoStringColor(java.awt.Color aColor)Returns a String/hex representation of a given color (eg, "#FF00D8").static java.lang.StringtoStringInsets(java.awt.Insets theInsets)Returns a string representation of a given Insets.-
Methods inherited from class com.inductiveautomation.rm.base.RMObject
addPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener, sendPropertyChange, toString
-
Methods inherited from class com.inductiveautomation.rm.base.RMListenerList
addListener, clone, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, hasListeners, removeListener
-
-
-
-
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
-
-
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.
-
-