org.jtgl.core
Class JTGLGraphics

java.lang.Object
  extended by org.jtgl.core.JTGLGraphics

public abstract class JTGLGraphics
extends java.lang.Object

Graphics context where all drawing operations are performed

Author:
Manuel Polo (manuel_polo at yahoo dot es)

Field Summary
protected  JTGLColor _currBGColor
          Current background color
protected  JTGLColor _currColor
          Current foreground color
 
Constructor Summary
JTGLGraphics()
          Creates a new instance of JTGLGraphics
 
Method Summary
 void begin()
          Signals the begining of usage of this graphics context.
 void clear()
           
 void clear(int x, int y, int width, int height)
           
 void clear(int x, int y, int width, int height, JTGLColor color)
           
 void clear(JTGLColor color)
           
 void clear(JTGLRect rect)
           
 void clear(JTGLRect rect, JTGLColor color)
           
 void clipReset()
           
abstract  void copyArea(int x_src, int y_src, int width, int height, int x_dest, int y_dest)
           
abstract  void drawChar(char ch, int x, int y)
           
 void drawChars(char[] chars, int offset, int length, int x, int y)
           
abstract  void drawImage(JTGLImage img, int x, int y)
           
abstract  void drawLine(int xf, int yf, int xt, int yt)
           
 void drawLine(int xf, int yf, int xt, int yt, JTGLColor color)
           
 void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
           
 void drawPolygon(int[] xPoints, int[] yPoints, int offset, int nPoints)
           
 void drawPolyLine(int[] xPoints, int[] yPoints, int nPoints)
           
 void drawPolyLine(int[] xPoints, int[] yPoints, int nPoints, boolean closePath)
           
 void drawPolyLine(int[] xPoints, int[] yPoints, int offset, int nPoints, boolean closePath)
           
 void drawRect(int x, int y, int width, int height)
           
 void drawRect(int x, int y, int width, int height, JTGLColor color)
           
 void drawRect(JTGLRect rect)
           
 void drawRect(JTGLRect rect, JTGLColor color)
           
abstract  void drawRegion(JTGLImage src, int x_src, int y_src, int width, int height, int x_dest, int y_dest)
           
 void drawString(java.lang.String str, int x, int y)
           
 void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3)
           
 void end()
          Signals the end of usage of this graphics context.
 void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
           
 void fillPolygon(int[] xPoints, int[] yPoints, int offset, int nPoints)
           
abstract  void fillRect(int x, int y, int width, int height)
           
 void fillRect(int x, int y, int width, int height, JTGLColor color)
           
 void fillRect(JTGLRect rect)
           
 void fillRect(JTGLRect rect, JTGLColor color)
           
 void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3)
           
abstract  void flush()
          Flush all pending drawing operations to destination such as screen.
 JTGLColor getBackgroundColor()
           
abstract  JTGLRect getClip()
           
 int getClipHeight()
           
 int getClipWidth()
           
 int getClipX()
           
 int getClipY()
           
 JTGLColor getColor()
           
abstract  JTGLFont getDefaultFont()
           
 JTGLFont getFont()
           
 int getHeight()
          Gets original context height independent of actual clipping height.
 int getPixel(int x, int y)
           
 int getTranslationX()
           
 int getTranslationY()
           
 int getWidth()
          Gets original context width independent of actual clipping width.
 void init()
          Initializes this graphics context.
 boolean isFullContextClipped()
           
 void restoreClip()
           
 void restoreColor()
           
 void saveClip()
           
 void saveColor(JTGLColor color)
           
 void setBackgroundColor(JTGLColor color)
          Background color is used when clearing this context and for auxiliary color.
 JTGLRect setClip(int x, int y, int width, int height)
           
 JTGLRect setClip(int x, int y, int width, int height, boolean updateInternal)
           
 JTGLRect setClip(JTGLRect clip)
           
protected abstract  void setClipInternal(int x, int y, int width, int height)
           
 void setColor(int r, int g, int b)
           
 void setColor(int a, int r, int g, int b)
           
 void setColor(JTGLColor color)
           
protected abstract  void setColorInternal(int argbColor)
          Sets the internal foreground color packed in ARGB format
protected  void setColorInternal(JTGLColor color)
          Sets the internal foregound color Subclases may overide this methof if another color packaging or translation (from JTGLColor) is needed.
 void setFont(JTGLFont font)
           
protected abstract  void setFontInternal(java.lang.Object nativeFont)
           
 void setFontSize(int sizeIndex)
          Changes current font's size to a fixed font size defined by JTGLFont's constants: JTGLFont.SIZE_SMALL JTGLFont.SIZE_MEDIUM JTGLFont.SIZE_LARGE Subsclasses of JTGLFont should return a minimun integer array of three predefined sizes.
protected  void setNativeGraphics(java.lang.Object nativeGraphics)
          Change or wraps a native graphics context (Used whithin a non-double-buffered scenario)
 void setOrigin(int x, int y)
           
 void setPixel(int x, int y, JTGLColor color)
           
 void translate(int tx, int ty)
           
protected abstract  void translateInternal(int tx, int ty)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_currColor

protected JTGLColor _currColor
Current foreground color


_currBGColor

protected JTGLColor _currBGColor
Current background color

Constructor Detail

JTGLGraphics

public JTGLGraphics()
Creates a new instance of JTGLGraphics

Method Detail

init

public void init()
Initializes this graphics context. This *MUST* be called once before any operation


begin

public void begin()
Signals the begining of usage of this graphics context.


end

public void end()
Signals the end of usage of this graphics context. Implementations must release any acquired resources.


flush

public abstract void flush()
Flush all pending drawing operations to destination such as screen.


setFont

public final void setFont(JTGLFont font)
Parameters:
font -

setFontInternal

protected abstract void setFontInternal(java.lang.Object nativeFont)

getFont

public final JTGLFont getFont()
Returns:

setFontSize

public final void setFontSize(int sizeIndex)
Changes current font's size to a fixed font size defined by JTGLFont's constants: JTGLFont.SIZE_SMALL JTGLFont.SIZE_MEDIUM JTGLFont.SIZE_LARGE Subsclasses of JTGLFont should return a minimun integer array of three predefined sizes.


getDefaultFont

public abstract JTGLFont getDefaultFont()

drawChar

public abstract void drawChar(char ch,
                              int x,
                              int y)
Parameters:
ch -
x -
y -

drawChars

public void drawChars(char[] chars,
                      int offset,
                      int length,
                      int x,
                      int y)
Parameters:
chars -
offset -
length -
x -
y -

drawString

public void drawString(java.lang.String str,
                       int x,
                       int y)
Parameters:
str -
x -
y -

translate

public final void translate(int tx,
                            int ty)
Parameters:
tx -
ty -

translateInternal

protected abstract void translateInternal(int tx,
                                          int ty)
Parameters:
tx -
ty -

getTranslationX

public final int getTranslationX()
Returns:

getTranslationY

public final int getTranslationY()
Returns:

setOrigin

public void setOrigin(int x,
                      int y)
Parameters:
x -
y -

getWidth

public final int getWidth()
Gets original context width independent of actual clipping width.

Returns:
width of context

getHeight

public final int getHeight()
Gets original context height independent of actual clipping height.

Returns:
height of context

setClip

public JTGLRect setClip(JTGLRect clip)
Parameters:
clip -
Returns:

setClip

public JTGLRect setClip(int x,
                        int y,
                        int width,
                        int height,
                        boolean updateInternal)
Parameters:
x -
y -
width -
height -
updateInternal -
Returns:

setClip

public JTGLRect setClip(int x,
                        int y,
                        int width,
                        int height)
Parameters:
x -
y -
width -
height -
Returns:

setClipInternal

protected abstract void setClipInternal(int x,
                                        int y,
                                        int width,
                                        int height)
Parameters:
x -
y -
width -
height -

getClip

public abstract JTGLRect getClip()
Returns:

isFullContextClipped

public final boolean isFullContextClipped()

clipReset

public final void clipReset()

getClipX

public final int getClipX()
Returns:

getClipY

public final int getClipY()
Returns:

getClipWidth

public final int getClipWidth()
Returns:

getClipHeight

public final int getClipHeight()
Returns:

saveClip

public final void saveClip()

restoreClip

public final void restoreClip()

setColor

public void setColor(int r,
                     int g,
                     int b)
Parameters:
r -
g -
b -

setColor

public void setColor(int a,
                     int r,
                     int g,
                     int b)
Parameters:
a -
r -
g -
b -

getBackgroundColor

public JTGLColor getBackgroundColor()
Returns:

setBackgroundColor

public void setBackgroundColor(JTGLColor color)
Background color is used when clearing this context and for auxiliary color.

Parameters:
color -

setColor

public void setColor(JTGLColor color)
Parameters:
color -

getColor

public JTGLColor getColor()
Returns:

saveColor

public final void saveColor(JTGLColor color)
Parameters:
color -

restoreColor

public final void restoreColor()

setColorInternal

protected void setColorInternal(JTGLColor color)
Sets the internal foregound color Subclases may overide this methof if another color packaging or translation (from JTGLColor) is needed.

Parameters:
color -

setColorInternal

protected abstract void setColorInternal(int argbColor)
Sets the internal foreground color packed in ARGB format

Parameters:
argbColor -

clear

public void clear(int x,
                  int y,
                  int width,
                  int height,
                  JTGLColor color)
Parameters:
x -
y -
width -
height -
color -

clear

public void clear(JTGLRect rect)
Parameters:
rect -

clear

public void clear(JTGLRect rect,
                  JTGLColor color)
Parameters:
rect -
color -

clear

public void clear()

clear

public void clear(JTGLColor color)
Parameters:
color -

clear

public void clear(int x,
                  int y,
                  int width,
                  int height)
Parameters:
x -
y -
width -
height -

setPixel

public void setPixel(int x,
                     int y,
                     JTGLColor color)
Parameters:
x -
y -
color -

getPixel

public int getPixel(int x,
                    int y)
Parameters:
x -
y -
Returns:

drawLine

public abstract void drawLine(int xf,
                              int yf,
                              int xt,
                              int yt)
Parameters:
xf -
yf -
xt -
yt -

drawLine

public void drawLine(int xf,
                     int yf,
                     int xt,
                     int yt,
                     JTGLColor color)
Parameters:
xf -
yf -
xt -
yt -
color -

drawPolyLine

public void drawPolyLine(int[] xPoints,
                         int[] yPoints,
                         int offset,
                         int nPoints,
                         boolean closePath)
Parameters:
xPoints -
yPoints -
offset -
nPoints -
closePath -

drawPolyLine

public void drawPolyLine(int[] xPoints,
                         int[] yPoints,
                         int nPoints,
                         boolean closePath)
Parameters:
xPoints -
yPoints -
nPoints -
closePath -

drawPolyLine

public void drawPolyLine(int[] xPoints,
                         int[] yPoints,
                         int nPoints)
Parameters:
xPoints -
yPoints -
nPoints -

drawPolygon

public void drawPolygon(int[] xPoints,
                        int[] yPoints,
                        int offset,
                        int nPoints)
Parameters:
xPoints -
yPoints -
offset -
nPoints -

drawPolygon

public void drawPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Parameters:
xPoints -
yPoints -
nPoints -

fillPolygon

public void fillPolygon(int[] xPoints,
                        int[] yPoints,
                        int offset,
                        int nPoints)
Parameters:
xPoints -
yPoints -
offset -
nPoints -

fillPolygon

public void fillPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Parameters:
xPoints -
yPoints -
nPoints -

drawTriangle

public void drawTriangle(int x1,
                         int y1,
                         int x2,
                         int y2,
                         int x3,
                         int y3)
Parameters:
x1 -
y1 -
x2 -
y2 -
x3 -
y3 -

fillTriangle

public void fillTriangle(int x1,
                         int y1,
                         int x2,
                         int y2,
                         int x3,
                         int y3)
Parameters:
x1 -
y1 -
x2 -
y2 -
x3 -
y3 -

drawRect

public void drawRect(int x,
                     int y,
                     int width,
                     int height)
Parameters:
x -
y -
width -
height -

drawRect

public void drawRect(int x,
                     int y,
                     int width,
                     int height,
                     JTGLColor color)
Parameters:
x -
y -
width -
height -
color -

drawRect

public void drawRect(JTGLRect rect)
Parameters:
rect -

drawRect

public void drawRect(JTGLRect rect,
                     JTGLColor color)
Parameters:
rect -
color -

fillRect

public abstract void fillRect(int x,
                              int y,
                              int width,
                              int height)
Parameters:
x -
y -
width -
height -

fillRect

public void fillRect(int x,
                     int y,
                     int width,
                     int height,
                     JTGLColor color)
Parameters:
x -
y -
width -
height -
color -

fillRect

public void fillRect(JTGLRect rect)
Parameters:
rect -

fillRect

public void fillRect(JTGLRect rect,
                     JTGLColor color)
Parameters:
rect -
color -

drawImage

public abstract void drawImage(JTGLImage img,
                               int x,
                               int y)
Parameters:
img -
x -
y -

drawRegion

public abstract void drawRegion(JTGLImage src,
                                int x_src,
                                int y_src,
                                int width,
                                int height,
                                int x_dest,
                                int y_dest)
Parameters:
src -
x_src -
y_src -
width -
height -
x_dest -
y_dest -

copyArea

public abstract void copyArea(int x_src,
                              int y_src,
                              int width,
                              int height,
                              int x_dest,
                              int y_dest)
Parameters:
x_src -
y_src -
width -
height -
x_dest -
y_dest -

setNativeGraphics

protected void setNativeGraphics(java.lang.Object nativeGraphics)
Change or wraps a native graphics context (Used whithin a non-double-buffered scenario)