Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Rich Ajax Platform
Release 1.2

org.eclipse.rwt.graphics
Class Graphics

java.lang.Object
  extended by
org.eclipse.rwt.graphics.Graphics

public final class Graphics
extends Object

This is a helper class for operations with text, fonts, colors and images. As RAP needs to handle with multiple clients simultaneously there are no constructors for these objects to share them between different sessions in order to have a much smaller memory footprint.

Since:
1.0

Method Summary
static float getAvgCharWidth ( Font font)
          Returns the average character width of the specified font, measured in pixels.
static int getCharHeight ( Font font)
          Returns the height of the specified font, measured in pixels.
static  Color getColor (int red, int green, int blue)
          Returns a Color given the desired red, green and blue values expressed as ints in the range 0 to 255 (where 0 is black and 255 is full brightness).
static  Color getColor ( RGB rgb)
          Returns an instance of Color given an RGB describing the desired red, green and blue values.
static  Cursor getCursor (int style)
          Returns an instance of Cursor based on a style constant describing the desired cursor appearance.
static  Font getFont ( FontData data)
          Returns a new font given a font data which describes the desired font's appearance.
static  Font getFont ( String name, int height, int style)
          Returns a Font object given a font name, the height of the desired font in points, and a font style.
static  Image getImage ( String path)
          Returns an instance of Image based on the specified image path.
static  Image getImage ( String path, ClassLoader imageLoader)
          Returns an instance of Image based on the specified image path.
static  Image getImage ( String path, InputStream inputStream)
          Returns an instance of Image based on the specified image path.
static  Point stringExtent ( Font font, String string)
          Returns the extent of the given string.
static  Point textExtent ( Font font, String string, int wrapWidth)
          Returns the extent of the given string.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getColor

public static 
Color getColor(
RGB rgb)
Returns an instance of Color given an RGB describing the desired red, green and blue values.

Parameters:
rgb - the RGB values of the desired color
Returns:
the color
See Also:
RGB, Device.getSystemColor(int)

getColor

public static 
Color getColor(int red,
                             int green,
                             int blue)
Returns a Color given the desired red, green and blue values expressed as ints in the range 0 to 255 (where 0 is black and 255 is full brightness).

Parameters:
red - the amount of red in the color
green - the amount of green in the color
blue - the amount of blue in the color
Returns:
the color

getFont

public static 
Font getFont(
FontData data)
Returns a new font given a font data which describes the desired font's appearance.

Parameters:
data - the FontData to use
Returns:
the font

getFont

public static 
Font getFont(
String name,
                           int height,
                           int style)
Returns a Font object given a font name, the height of the desired font in points, and a font style.

Parameters:
name - the name of the font (must not be null)
height - the font height in points
style - a bit or combination of NORMAL, BOLD, ITALIC
Returns:
the font

getImage

public static 
Image getImage(
String path)
Returns an instance of Image based on the specified image path. The image has to be on the applications class-path.

Parameters:
path - the path to the image
Returns:
the image

getImage

public static 
Image getImage(
String path,
                             
ClassLoader imageLoader)
Returns an instance of Image based on the specified image path. The image has to be on the applications class-path. Uses the specified classloader to load the image.

Parameters:
path - the path to the image
imageLoader - the classloader to use
Returns:
the image

getImage

public static 
Image getImage(
String path,
                             
InputStream inputStream)
Returns an instance of Image based on the specified image path. The image will be read from the provided InputStream.

Parameters:
path - the path to the image
inputStream - the input stream for the image
Returns:
the image

getCursor

public static 
Cursor getCursor(int style)
Returns an instance of Cursor based on a style constant describing the desired cursor appearance.

Parameters:
style - the style of the cursor to create
Returns:
the cursor
Since:
1.2
See Also:
SWT.CURSOR_ARROW, SWT.CURSOR_WAIT, SWT.CURSOR_CROSS, SWT.CURSOR_HELP, SWT.CURSOR_SIZEALL, SWT.CURSOR_SIZENS, SWT.CURSOR_SIZEWE, SWT.CURSOR_SIZEN, SWT.CURSOR_SIZES, SWT.CURSOR_SIZEE, SWT.CURSOR_SIZEW, SWT.CURSOR_SIZENE, SWT.CURSOR_SIZESE, SWT.CURSOR_SIZESW, SWT.CURSOR_SIZENW, SWT.CURSOR_IBEAM, SWT.CURSOR_HAND

textExtent

public static 
Point textExtent(
Font font,
                               
String string,
                               int wrapWidth)
Returns the extent of the given string. Tab expansion and carriage return processing are performed.

The extent of a string is the width and height of the rectangular area it would cover if drawn in a particular font.

Parameters:
font - the font for which the result is valid
string - the string to measure
wrapWidth - the maximum width of the text. The text will be wrapped to match this width. If set to 0, no wrapping will be performed.
Returns:
a point containing the extent of the string
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null

stringExtent

public static 
Point stringExtent(
Font font,
                                 
String string)
Returns the extent of the given string. No tab expansion or carriage return processing will be performed.

The extent of a string is the width and height of the rectangular area it would cover if drawn in a particular font.

Parameters:
font - the font for which the result is valid
string - the string to measure
Returns:
a point containing the extent of the string
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null

getCharHeight

public static int getCharHeight(
Font font)
Returns the height of the specified font, measured in pixels.

Parameters:
font - the font for which the result is valid
Returns:
the height of the font

getAvgCharWidth

public static float getAvgCharWidth(
Font font)
Returns the average character width of the specified font, measured in pixels.

Parameters:
font - the font for which the result is valid
Returns:
the average character width of the font

Eclipse Rich Ajax Platform
Release 1.2

Copyright (c) Innoopract Informationssysteme GmbH and others 2002, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire