Control类:
toControl
(
Point
point)
Returns a point which is the result of converting the argument, which is specified in display relative coordinates, to coordinates relative to the receiver.
将
Point
由
Display
的绝对值转化为
Control
的相对值。
toDisplay
(
Point
point)
Returns a point which is the result of converting the argument, which is specified in coordinates relative to the receiver, to display relative coordinates.
将
Point
由
Control
的相对值转化为
Display
的绝对值。
Example:
Button button =
new
Button( s, SWT.
BORDER
);
System.
out
.println( button.getLocation( ) );
//Point {0, 0}
System.
out
.println( button.toDisplay( button.getLocation( ) ) );
//Point {70, 89}
System.
out
.println( button.toControl( button.toDisplay( button.getLocation( ) ) ) );
//Point {0, 0}
Device类:
getDepth
()
Returns the bit depth of the screen, which is the number of bits it takes to represent the number of unique colors that the screen is currently capable of displaying.
拿到操作系统的颜色深度。
getDPI
()
Returns a point whose x coordinate is the horizontal dots per inch of the display, and whose y coordinate is the vertical dots per inch of the display.
拿到操作系统的DPI值。
Example:
System.out.println(Display.getDefault( ).getDepth( ));//32
System.out.println(Display.getDefault( ).getDPI( ));//Point {96, 96}