com.java4less.rchart.gc
Class GraphicsProvider

java.lang.Object
  |
  +--com.java4less.rchart.gc.GraphicsProvider

public class GraphicsProvider
extends java.lang.Object

Use this class to create graphic objects like fonts, colors and images.
 This class provides a layer on the AWT and SWT graphic implementation which allows rchart to be independent of them. You can use the setMode() method to select the AWT of SWT implementation.
 


Field Summary
static int MODE_AWT_SWING
          AWT /Swing, for JDK 1.2 or later
static int MODE_AWT1
          JDK 1.1 compatible mode
static int MODE_SWT
          SWT mode
 
Constructor Summary
GraphicsProvider()
           
 
Method Summary
static ChartImage createImage(int w, int h)
          create a new image of the given size
static ChartImage createTransparentImage(int w, int h, ChartColor transparent)
          create a new transparent image of the given size
static ChartColor getColor(int red, int green, int blue)
           
static ChartColor getColor(java.lang.String c)
           
static ChartColor getColorFromObject(java.lang.Object o)
           
static ChartFont getFont(java.lang.String c, int style, int size)
          create font from string value
static ChartFont getFontFromObject(java.lang.Object o)
           
static ChartGraphics getGraphics(java.lang.Object o)
          create Graphic context from awt (java.awt.Graphics) or swt (GC) graphic context
static ChartImage getImage(java.lang.Object o)
          create Image from awt (java.awt.Image) or swt image
static ChartImage getImageFromFile(java.lang.String file)
          create Image from file
static int getMode()
          get provider mode
static void setMode(int m)
          set provider mode.
static void startUIThread(java.lang.Runnable r)
          this starts a thread which can execute UI operations (required by SWT)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_AWT_SWING

public static int MODE_AWT_SWING
AWT /Swing, for JDK 1.2 or later


MODE_SWT

public static int MODE_SWT
SWT mode


MODE_AWT1

public static int MODE_AWT1
JDK 1.1 compatible mode

Constructor Detail

GraphicsProvider

public GraphicsProvider()
Method Detail

setMode

public static void setMode(int m)
set provider mode. You should not change the mode once you have set it. This value is a global setting for you application.


getMode

public static int getMode()
get provider mode

Returns:
MODE_AWT_SWING or MODE_SWT

getColor

public static ChartColor getColor(java.lang.String c)

getColor

public static ChartColor getColor(int red,
                                  int green,
                                  int blue)

getColorFromObject

public static ChartColor getColorFromObject(java.lang.Object o)

getFont

public static ChartFont getFont(java.lang.String c,
                                int style,
                                int size)
create font from string value

Parameters:
c - name of the font
style - ChartFont.PLAIN, ChartFont.BOLD or ChartFont.ITALIC
size - size of the font
Returns:

getFontFromObject

public static ChartFont getFontFromObject(java.lang.Object o)

getGraphics

public static ChartGraphics getGraphics(java.lang.Object o)
create Graphic context from awt (java.awt.Graphics) or swt (GC) graphic context

Parameters:
o -
Returns:

getImage

public static ChartImage getImage(java.lang.Object o)
create Image from awt (java.awt.Image) or swt image

Parameters:
o -
Returns:

getImageFromFile

public static ChartImage getImageFromFile(java.lang.String file)
create Image from file

Parameters:
file - filename
Returns:

createImage

public static ChartImage createImage(int w,
                                     int h)
create a new image of the given size

Parameters:
w - width
h - height
Returns:

createTransparentImage

public static ChartImage createTransparentImage(int w,
                                                int h,
                                                ChartColor transparent)
create a new transparent image of the given size

Parameters:
w - width
h - height
Returns:

startUIThread

public static void startUIThread(java.lang.Runnable r)
this starts a thread which can execute UI operations (required by SWT)

Parameters:
r -