Eclipse Remote Application Platform

org.eclipse.rap.rwt.graphics
Class Graphics

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

Deprecated. This class will be removed in future versions. For replacements, see the documentation of the single methods.

@Deprecated
public final class Graphics
extends java.lang.Object

Before RAP 2.0, this class was used to create resources like fonts and colors without a display reference. This practice is obsolete, resources should always be created using a constructor.

The class has also been used as a helper class for measuring texts. This can also be done using a GC.

Since:
2.0

Method Summary
static float getAvgCharWidth(Font font)
          Deprecated. Application code should not need to use this method. If you need an average character width, you can use GC.stringExtent(String) with a string of your choice and calculate the average width.
static int getCharHeight(Font font)
          Deprecated. Application code should not need to use this method. If you need this information, you can use GC.stringExtent(String) with a string of your choice and get the height of the result.
static Color getColor(int red, int green, int blue)
          Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Color(Device, int, int, int) instead.
static Color getColor(RGB rgb)
          Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Color(Device, RGB) instead.
static Font getFont(FontData data)
          Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Font(Device, FontData) instead.
static Font getFont(java.lang.String name, int height, int style)
          Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Font(Device, String, int, int) instead.
static Image getImage(java.lang.String path)
          Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Image(Device, InputStream)} instead.
static Image getImage(java.lang.String path, java.lang.ClassLoader imageLoader)
          Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Image(Device, InputStream)} instead.
static Image getImage(java.lang.String path, java.io.InputStream inputStream)
          Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Image(Device, InputStream)} instead.
static Point stringExtent(Font font, java.lang.String string)
          Deprecated. You can use SWT API to measure a string. Create a GC, set the font, and measure the string using GC.stringExtent(String). Don't forget to dispose the GC afterwards.
static Point textExtent(Font font, java.lang.String string, int wrapWidth)
          Deprecated. In most cases, you can use SWT API to measure texts. Create a GC, set the font, and measure the text using GC.textExtent(String). Don't forget to dispose the GC afterwards.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getColor

@Deprecated
public static Color getColor(RGB rgb)
Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Color(Device, RGB) instead.

Returns an instance of Color given an RGB describing the desired red, green and blue values.

Note: it is considered an error to attempt to dispose of colors that were created by this method. An IllegalStateException is thrown in this case.

Parameters:
rgb - the RGB values of the desired color - must not be null
Returns:
the color
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the rgb argument is null
  • ERROR_THREAD_INVALID_ACCESS - if not called from the current display's UI thread
See Also:
RGB, Device.getSystemColor(int)

getColor

@Deprecated
public static Color getColor(int red,
                                        int green,
                                        int blue)
Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Color(Device, int, int, int) instead.

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).

Note: it is considered an error to attempt to dispose of colors that were created by this method. An IllegalStateException is thrown in this case.

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
Throws:
java.lang.IllegalArgumentException -
  • ERROR_THREAD_INVALID_ACCESS - if not called from the current display's UI thread

getFont

@Deprecated
public static Font getFont(FontData data)
Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Font(Device, FontData) instead.

Returns a new font given a font data which describes the desired font's appearance.

Note: it is considered an error to attempt to dispose of fonts that were created by this method. An IllegalStateException is thrown in this case.

Parameters:
data - the FontData to use - must not be null
Returns:
the font
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the data argument is null
  • ERROR_THREAD_INVALID_ACCESS - if not called from the current display's UI thread

getFont

@Deprecated
public static Font getFont(java.lang.String name,
                                      int height,
                                      int style)
Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Font(Device, String, int, int) instead.

Returns a Font object given a font name, the height of the desired font in points, and a font style.

Note: it is considered an error to attempt to dispose of fonts that were created by this method. An IllegalStateException is thrown in this case.

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
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the name argument is null
  • ERROR_INVALID_ARGUMENT - if the height is negative
  • ERROR_THREAD_INVALID_ACCESS - if not called from the current display's UI thread

getImage

@Deprecated
public static Image getImage(java.lang.String path)
Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Image(Device, InputStream)} instead.

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
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the path is null
  • ERROR_ILLEGAL_ARGUMENT - if the path is invalid
java.lang.IllegalArgumentException -
  • ERROR_THREAD_INVALID_ACCESS - if not called from the current display's UI thread
SWTException -
  • ERROR_IO - if an IO error occurs while reading from the stream
  • ERROR_INVALID_IMAGE - if the image stream contains invalid data
  • ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format

getImage

@Deprecated
public static Image getImage(java.lang.String path,
                                        java.lang.ClassLoader imageLoader)
Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Image(Device, InputStream)} instead.

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
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the path is null
  • ERROR_ILLEGAL_ARGUMENT - if the path is invalid
  • ERROR_THREAD_INVALID_ACCESS - if not called from the current display's UI thread
SWTException -
  • ERROR_IO - if an IO error occurs while reading from the stream
  • ERROR_INVALID_IMAGE - if the image stream contains invalid data
  • ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format

getImage

@Deprecated
public static Image getImage(java.lang.String path,
                                        java.io.InputStream inputStream)
Deprecated. Factory created resources are obsolete and will be removed in a future release. Use the constructor Image(Device, InputStream)} instead.

Returns an instance of Image based on the specified image path. The image will be read from the provided InputStream.

Parameters:
path - the path the image resource is registered at
inputStream - the input stream for the image
Returns:
the image
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the path is null
  • ERROR_NULL_ARGUMENT - if the inputStream is null
  • ERROR_INVALID_ARGUMENT - if the path is invalid
  • ERROR_THREAD_INVALID_ACCESS - if not called from the current display's UI thread
SWTException -
  • ERROR_IO - if an IO error occurs while reading from the stream
  • ERROR_INVALID_IMAGE - if the image stream contains invalid data
  • ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format

textExtent

@Deprecated
public static Point textExtent(Font font,
                                          java.lang.String string,
                                          int wrapWidth)
Deprecated. In most cases, you can use SWT API to measure texts. Create a GC, set the font, and measure the text using GC.textExtent(String). Don't forget to dispose the GC afterwards.

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:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the font or string argument is null
  • ERROR_THREAD_INVALID_ACCESS - if not called from the current display's UI thread

stringExtent

@Deprecated
public static Point stringExtent(Font font,
                                            java.lang.String string)
Deprecated. You can use SWT API to measure a string. Create a GC, set the font, and measure the string using GC.stringExtent(String). Don't forget to dispose the GC afterwards.

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:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the font or string arguemnt is null
  • ERROR_THREAD_INVALID_ACCESS - if not called from the current display's UI thread

getCharHeight

@Deprecated
public static int getCharHeight(Font font)
Deprecated. Application code should not need to use this method. If you need this information, you can use GC.stringExtent(String) with a string of your choice and get the height of the result.

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
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the font argument is null
  • ERROR_THREAD_INVALID_ACCESS - if not called from the current display's UI thread

getAvgCharWidth

@Deprecated
public static float getAvgCharWidth(Font font)
Deprecated. Application code should not need to use this method. If you need an average character width, you can use GC.stringExtent(String) with a string of your choice and calculate the average width.

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
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the font argument is null
  • ERROR_THREAD_INVALID_ACCESS - if not called from the current display's UI thread

Eclipse Remote Application Platform

Copyright (c) EclipseSource and others 2002, 2012. All rights reserved.