Package be.tarsos.dsp.ui.layers
Class LayerUtilities
java.lang.Object
be.tarsos.dsp.ui.layers.LayerUtilities
public class LayerUtilities
extends java.lang.Object
-
Method Summary
Modifier and Type Method Description static java.awt.geom.Rectangle2D
drawString(java.awt.Graphics2D graphics, java.lang.String text, double x, double y, boolean centerHorizontal, boolean centerVertical, java.awt.Color backgroundColor)
static java.awt.geom.Rectangle2D
drawString(java.awt.Graphics2D graphics, java.lang.String text, double x, double y, boolean centerHorizontal, boolean centerVertical, java.awt.Color backgroundColor, java.awt.Color textColor)
static float
pixelsToUnits(java.awt.Graphics2D g, int pixels, boolean horizontal)
Transforms a number of pixels into a corresponding time or frequency span.static java.awt.geom.Point2D
pixelsToUnits(java.awt.Graphics2D g, int x, int y)
Transforms pixels to time and frequency.static float
unitsToPixels(java.awt.Graphics2D g, float units, boolean horizontal)
-
Method Details
-
pixelsToUnits
public static java.awt.geom.Point2D pixelsToUnits(java.awt.Graphics2D g, int x, int y)Transforms pixels to time and frequency.- Parameters:
g
- The current graphics, with a meaningful transform applied to it.x
- The x coordinate, in pixels.y
- The y coordinate, in pixels.- Returns:
- A point with time (in milliseconds) as x coordinate, and frequency (in cents) as y coordinate.
-
pixelsToUnits
public static float pixelsToUnits(java.awt.Graphics2D g, int pixels, boolean horizontal)Transforms a number of pixels into a corresponding time or frequency span. E.g. 10 horizontal pixels could translate to 320 milliseconds. 10 vertical pixels could translate to 32cents.- Parameters:
g
- The current graphics, with a meaningful transform applied to it.pixels
- The number of pixelshorizontal
- Is it the horizontal or vertical axis?- Returns:
- A number of cents or milliseconds.
-
unitsToPixels
public static float unitsToPixels(java.awt.Graphics2D g, float units, boolean horizontal) -
drawString
public static java.awt.geom.Rectangle2D drawString(java.awt.Graphics2D graphics, java.lang.String text, double x, double y, boolean centerHorizontal, boolean centerVertical, java.awt.Color backgroundColor) -
drawString
public static java.awt.geom.Rectangle2D drawString(java.awt.Graphics2D graphics, java.lang.String text, double x, double y, boolean centerHorizontal, boolean centerVertical, java.awt.Color backgroundColor, java.awt.Color textColor)
-