|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jfree.experimental.swt.SWTUtils
public class SWTUtils
Utility class gathering some useful and general method. Mainly convert forth and back graphical stuff between awt and swt.
| Field Summary | |
|---|---|
protected static javax.swing.JPanel |
DUMMY_PANEL
A dummy JPanel used to provide font metrics. |
| Constructor Summary | |
|---|---|
SWTUtils()
|
|
| Method Summary | |
|---|---|
static java.awt.Color |
toAwtColor(Color color)
Creates an awt color instance to match the rgb values of the specified swt color. |
static java.awt.Font |
toAwtFont(Device device,
Font font)
Create an awt font by converting as much information as possible from the provided swt Font. |
static java.awt.Font |
toAwtFont(Device device,
FontData fontData,
boolean ensureSameSize)
Create an awt font by converting as much information as possible from the provided swt FontData. |
static java.awt.event.MouseEvent |
toAwtMouseEvent(org.eclipse.swt.events.MouseEvent event)
Creates an AWT MouseEvent from a swt event. |
static java.awt.geom.Point2D |
toAwtPoint(Point p)
Returns an AWT point with the same coordinates as the specified SWT point. |
static java.awt.geom.Rectangle2D |
toAwtRectangle(Rectangle rect)
Transform a swt Rectangle instance into an awt one. |
static Color |
toSwtColor(Device device,
java.awt.Color color)
Creates a swt color instance to match the rgb values of the specified awt color. alpha channel is not supported. |
static Color |
toSwtColor(Device device,
java.awt.Paint paint)
Creates a swt color instance to match the rgb values of the specified awt paint. |
static FontData |
toSwtFontData(Device device,
java.awt.Font font,
boolean ensureSameSize)
Create a FontData object which encapsulate
the essential data to create a swt font. |
static Point |
toSwtPoint(java.awt.Point p)
Returns an SWT point with the same coordinates as the specified AWT point. |
static Point |
toSwtPoint(java.awt.geom.Point2D p)
Returns an SWT point with the same coordinates as the specified AWT point (rounded to integer values). |
static Rectangle |
toSwtRectangle(java.awt.geom.Rectangle2D rect2d)
Transform an awt Rectangle2d instance into a swt one. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final javax.swing.JPanel DUMMY_PANEL
| Constructor Detail |
|---|
public SWTUtils()
| Method Detail |
|---|
public static FontData toSwtFontData(Device device,
java.awt.Font font,
boolean ensureSameSize)
FontData object which encapsulate
the essential data to create a swt font. The data is taken
from the provided awt Font.
Generally speaking, given a font size, the returned swt font will display differently on the screen than the awt one. Because the SWT toolkit use native graphical resources whenever it is possible, this fact is platform dependent. To address this issue, it is possible to enforce the method to return a font with the same size (or at least as close as possible) as the awt one.
When the object is no more used, the user must explicitly call the dispose method on the returned font to free the operating system resources (the garbage collector won't do it).
device - The swt device to draw on (display or gc device).font - The awt font from which to get the data.ensureSameSize - A boolean used to enforce the same size
(in pixels) between the awt font and the newly created swt font.
FontData object.
public static java.awt.Font toAwtFont(Device device,
FontData fontData,
boolean ensureSameSize)
FontData.
Generally speaking, given a font size, an swt font will display differently on the screen than the corresponding awt one. Because the SWT toolkit use native graphical ressources whenever it is possible, this fact is platform dependent. To address this issue, it is possible to enforce the method to return an awt font with the same height as the swt one.
device - The swt device being drawn on (display or gc device).fontData - The swt font to convert.ensureSameSize - A boolean used to enforce the same size
(in pixels) between the swt font and the newly created awt font.
public static java.awt.Font toAwtFont(Device device,
Font font)
Font.
device - The swt device to draw on (display or gc device).font - The swt font to convert.
public static java.awt.Color toAwtColor(Color color)
color - The swt color to match.
public static Color toSwtColor(Device device,
java.awt.Paint paint)
device - The swt device to draw on (display or gc device).paint - The awt color to match.
public static Color toSwtColor(Device device,
java.awt.Color color)
device - The swt device to draw on (display or gc device).color - The awt color to match.
public static Rectangle toSwtRectangle(java.awt.geom.Rectangle2D rect2d)
rect2d - The awt rectangle to map.
Rectangle object.public static java.awt.geom.Rectangle2D toAwtRectangle(Rectangle rect)
rect - the swt Rectangle
public static java.awt.geom.Point2D toAwtPoint(Point p)
p - the SWT point (null not permitted).
p.toSwtPoint(java.awt.Point)public static Point toSwtPoint(java.awt.Point p)
p - the AWT point (null not permitted).
p.toAwtPoint(Point)public static Point toSwtPoint(java.awt.geom.Point2D p)
p - the AWT point (null not permitted).
p.toAwtPoint(Point)public static java.awt.event.MouseEvent toAwtMouseEvent(org.eclipse.swt.events.MouseEvent event)
MouseEvent from a swt event.
This method helps passing SWT mouse event to awt components.
event - The swt event.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||