Package adams.gui.core
Class Cursors
- java.lang.Object
-
- adams.gui.core.Cursors
-
public class Cursors extends Object
For creating cursors.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description Cursors()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static Cursorcache(String name, BufferedImage img, Point p, double scale)Creates and caches the cursor.protected static Cursorcache(String name, ImageIcon img, Point p, double scale)Creates and caches the cursor.static Cursorcircle(int diameter)Creates a circle cursor with the specified diameter.static Cursorcircle(int diameter, double scale)Creates a circle cursor with the specified diameter.static CursorcircleWithPointer(int diameter)Creates a circle with the specified diameter overlayed with the cursor.static Cursorcrosshair(int diameter)Creates a cross-hair cursor with the specified diameter.static Cursorcrosshair(int diameter, double scale)Creates a cross-hair cursor with the specified diameter.static Cursordisabled()Creates a disabled pointer cursor.static CursorfromFile(File file, int x, int y)Uses the image as icon.static CursorfromFile(File file, int x, int y, double scale)Uses the image as icon.static CursorfromFile(String fileName, int x, int y)Uses the image as icon.static CursorfromFile(String fileName, int x, int y, double scale)Uses the image as icon.static CursorfromIcon(String iconName, int x, int y)Uses the ADAMS image (located adams.gui.images) as icon.static CursorfromIcon(String iconName, int x, int y, double scale)Uses the ADAMS image (located adams.gui.images) as icon.static Map<String,Cursor>getCache()Returns the cursor cache.protected static PointgetPointerHotspot()Returns the hotspot for the pointer.protected static BufferedImagegetPointerImage()Returns the pointer image (loads it on demand).protected static BufferedImagescale(BufferedImage img, double scale)Scales the image according to the scale factor.protected static Pointscale(Point p, double scale)Scales the hotspot point.protected static BufferedImagescale(ImageIcon icon, double scale)Scales the image icon according to the scale factor.static Cursorsquare(int width)Creates a square cursor with the specified width.static Cursorsquare(int width, double scale)Creates a square cursor with the specified width.static CursorsquareWithPointer(int width)Creates a square with the specified width overlayed with the cursor.
-
-
-
Field Detail
-
m_Pointer
protected static BufferedImage m_Pointer
the pointer image.
-
-
Method Detail
-
getPointerImage
protected static BufferedImage getPointerImage()
Returns the pointer image (loads it on demand).- Returns:
- the image
-
getPointerHotspot
protected static Point getPointerHotspot()
Returns the hotspot for the pointer.- Returns:
- the hotspot (0-based coordinates)
- See Also:
getPointerImage()
-
scale
protected static BufferedImage scale(BufferedImage img, double scale)
Scales the image according to the scale factor.- Parameters:
img- the image to scalescale- the scale factor- Returns:
- the scaled image
-
scale
protected static BufferedImage scale(ImageIcon icon, double scale)
Scales the image icon according to the scale factor.- Parameters:
icon- the image to scalescale- the scale factor- Returns:
- the scaled image
-
scale
protected static Point scale(Point p, double scale)
Scales the hotspot point.- Parameters:
p- the hotspot to scalescale- the scale factor (1 = 100%)- Returns:
- the scaled hotspot
-
cache
protected static Cursor cache(String name, ImageIcon img, Point p, double scale)
Creates and caches the cursor.- Parameters:
name- the name of the cursorimg- the image for the cursorp- the hotspotscale- the scale factor- Returns:
- the cursor, default cursor if failed to create
-
cache
protected static Cursor cache(String name, BufferedImage img, Point p, double scale)
Creates and caches the cursor.- Parameters:
name- the name of the cursorimg- the image for the cursorp- the hotspotscale- the scale factor- Returns:
- the cursor, default cursor if failed to create
-
getCache
public static Map<String,Cursor> getCache()
Returns the cursor cache.- Returns:
- the cache (name - cursor)
-
disabled
public static Cursor disabled()
Creates a disabled pointer cursor.- Returns:
- the cursor
-
square
public static Cursor square(int width)
Creates a square cursor with the specified width.- Parameters:
width- the width of the square- Returns:
- the cursor
-
square
public static Cursor square(int width, double scale)
Creates a square cursor with the specified width.- Parameters:
width- the width of the squarescale- for scaling the cursor (1.0 = 100%)- Returns:
- the cursor
-
squareWithPointer
public static Cursor squareWithPointer(int width)
Creates a square with the specified width overlayed with the cursor.- Parameters:
width- the width of the square- Returns:
- the cursor
-
circle
public static Cursor circle(int diameter)
Creates a circle cursor with the specified diameter.- Parameters:
diameter- the diameter of the circle- Returns:
- the cursor
-
circle
public static Cursor circle(int diameter, double scale)
Creates a circle cursor with the specified diameter.- Parameters:
diameter- the diameter of the circlescale- for scaling the cursor (1.0 = 100%)- Returns:
- the cursor
-
circleWithPointer
public static Cursor circleWithPointer(int diameter)
Creates a circle with the specified diameter overlayed with the cursor.- Parameters:
diameter- the diameter of the circle- Returns:
- the cursor
-
crosshair
public static Cursor crosshair(int diameter)
Creates a cross-hair cursor with the specified diameter.- Parameters:
diameter- the diameter of the cross-hair- Returns:
- the cursor
-
crosshair
public static Cursor crosshair(int diameter, double scale)
Creates a cross-hair cursor with the specified diameter.- Parameters:
diameter- the diameter of the cross-hairscale- for scaling the cursor (1.0 = 100%)- Returns:
- the cursor
-
fromIcon
public static Cursor fromIcon(String iconName, int x, int y)
Uses the ADAMS image (located adams.gui.images) as icon.- Parameters:
iconName- the name of the image (no path)x- the x coordinate for the cursor hotspoty- the y coordinate for the cursor hotspot- Returns:
- the cursor
- Throws:
IllegalStateException- if the icon doesn't exist
-
fromIcon
public static Cursor fromIcon(String iconName, int x, int y, double scale)
Uses the ADAMS image (located adams.gui.images) as icon.- Parameters:
iconName- the name of the image (no path)x- the x coordinate for the cursor hotspoty- the y coordinate for the cursor hotspotscale- for scaling the cursor (1.0 = 100%)- Returns:
- the cursor
- Throws:
IllegalStateException- if the icon doesn't exist
-
fromFile
public static Cursor fromFile(String fileName, int x, int y)
Uses the image as icon.- Parameters:
fileName- the name of the image (incl path)x- the x coordinate for the cursor hotspoty- the y coordinate for the cursor hotspot- Returns:
- the cursor
- Throws:
IllegalStateException- if the icon doesn't exist
-
fromFile
public static Cursor fromFile(String fileName, int x, int y, double scale)
Uses the image as icon.- Parameters:
fileName- the name of the image (incl path)x- the x coordinate for the cursor hotspoty- the y coordinate for the cursor hotspotscale- for scaling the cursor (1.0 = 100%)- Returns:
- the cursor
- Throws:
IllegalStateException- if the icon doesn't exist
-
fromFile
public static Cursor fromFile(File file, int x, int y)
Uses the image as icon.- Parameters:
file- the name of the image (incl path)x- the x coordinate for the cursor hotspoty- the y coordinate for the cursor hotspot- Returns:
- the cursor
- Throws:
IllegalStateException- if the icon doesn't exist
-
fromFile
public static Cursor fromFile(File file, int x, int y, double scale)
Uses the image as icon.- Parameters:
file- the name of the image (incl path)x- the x coordinate for the cursor hotspoty- the y coordinate for the cursor hotspotscale- for scaling the cursor (1.0 = 100%)- Returns:
- the cursor
- Throws:
IllegalStateException- if the icon doesn't exist
-
-