jcontrol.graphics
Class XDisplay

java.lang.Object
  extended by jcontrol.io.AbstractGraphics
      extended by jcontrol.graphics.XDisplay
All Implemented Interfaces:
XGraphics, Graphics

public class XDisplay
extends AbstractGraphics


Field Summary
 
Fields inherited from class jcontrol.io.AbstractGraphics
NEGATIVE, OFF, ON, SYSTEMFONT
 
Fields inherited from interface jcontrol.graphics.XGraphics
ANCHOR_BASELINE, ANCHOR_BOTTOM, ANCHOR_HCENTER, ANCHOR_LEFT, ANCHOR_RIGHT, ANCHOR_TOP, ANCHOR_VCENTER, DRAWMODE_AND, DRAWMODE_INVERSE, DRAWMODE_MASK, DRAWMODE_NORMAL, DRAWMODE_OR, DRAWMODE_XOR, MAX_BRIGHTNESS, MAX_CONTRAST, MIN_BRIGHTNESS, MIN_CONTRAST, STROKEMODE_DOTTED, STROKEMODE_SOLID
 
Fields inherited from interface jcontrol.io.Graphics
AND, INVERSE, NORMAL, OR, XOR
 
Constructor Summary
XDisplay()
           
 
Method Summary
 boolean clipRect(int nx, int ny, int nw, int nh)
          Intersects the stored ClipRect with another represented by the given values.
 XGraphics cloneXGraphics()
          Creates a clone of this XGraphics object that has the same settings as this one, but acts independently.
 void copyArea(int x, int y, int width, int height, int dx, int dy)
          NOTE: not supported
Copies an area within the framebuffer.
 void drawArc(int x, int y, int width, int height, int startangle, int arcangle)
          NOTE: not supported
Draws an elliptic arc.
 int drawChar(char c, int x, int y, int anchor)
          NOTE: not supported
Draws a single character with the currently set font.
 void drawImage(Object drawable, int x, int y)
          Draws an image to the specified coordinates.
 void drawImage(Object drawable, int x, int y, int anchor)
          NOTE: not supported
Draws an image.
 void drawImage(Object drawable, int x, int y, int width, int height, int xoff, int yoff)
          Draws a subimage to the specified coordinates.
 void drawOval(int x, int y, int width, int height)
          Draws an ellipse.
 void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
          NOTE: not supported
Draws a closed polyline.
 void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
          NOTE: not supported
Draws a polyline.
 void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
          Draws a rounded rectangle.
 void drawString(String s, int x, int y, int anchor)
          NOTE: not supported
Draws a text string with the currently set font.
 void fillArc(int x, int y, int width, int height, int startangle, int arcangle)
          NOTE: not supported
Draws a filled elliptic arc, which is similar to a pie charts element.
 void fillOval(int x, int y, int width, int height)
          Draws a filled ellipse.
 void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
          NOTE: not supported
Draws a polygon.
 void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
          Draws a filled rounded rectangle.
protected  void finalize()
          free internal data structures used by this xdisplay object.
 int getBackground()
          Returns the ARGB value of the current background color.
 int getBrightness()
          Get current backlight brightness.
 int getClipHeight()
          Returns the height of the clipping rectangle
 int getClipWidth()
          Returns the width of the clipping rectangle
 int getClipX()
          Returns the relative x-location of the clipping rectangle
 int getClipY()
          Returns the relative y-location of the clipping rectangle
 int getColor()
          Returns the ARGB value of the current drawing color.
 int getContrast()
          Get current display contrast.
 Object getFont()
          Returns the currently set font.
 int getStrokeMode()
          NOTE: not supported
Returns the current stroke mode.
 int getTranslateX()
          Returns the absolute x-location of the origin
 int getTranslateY()
          Returns the absolute y-location of the origin
 boolean isClipRectEmpty()
          Checks, if the current clipping rectangle is empty (i.e. doesn't cover any pixel).
 boolean isOverlapping(int x, int y, int width, int height)
          Checks, if the given rectangle overlaps (or - mathematically spoken - intersects) with the current clipping rectangle.
 void setBackground(Color color)
          Sets the background color.
 void setBrightness(int value)
          Set backlight's brightness
 void setClip(int nx, int ny, int nw, int nh)
          Sets the clipping rectangle.
 void setColor(Color color)
          Sets the drawing color.
 void setContrast(int value)
          Set displays contrast
 void setFont(Object newfont)
          Sets the font to use.
 void setStrokeMode(int mode)
          NOTE: not supported
Sets the stroke mode.
 void swapColors()
          Swaps drawing and background color.
 void translate(int dx, int dy)
          Moves the translation (origin) point.
 
Methods inherited from class jcontrol.io.AbstractGraphics
clearDisplay, clearRect, drawChar, drawLine, drawRect, drawString, drawString, fillRect, getDrawMode, getFontHeight, getPixel, getTextWidth, scroll, setBackground, setColor, setDisplayMode, setDrawMode, setPixel
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 
Methods inherited from interface jcontrol.graphics.XGraphics
drawChar, scroll, setBackground, setColor
 
Methods inherited from interface jcontrol.io.Graphics
clearRect, drawLine, drawRect, drawString, drawString, fillRect, getDrawMode, getFontHeight, getPixel, getTextWidth, setDrawMode, setPixel
 

Constructor Detail

XDisplay

public XDisplay()
Method Detail

cloneXGraphics

public XGraphics cloneXGraphics()
Creates a clone of this XGraphics object that has the same settings as this one, but acts independently.

Returns:
clone

setBrightness

public void setBrightness(int value)
Set backlight's brightness

Parameters:
value - value between 0 (backlight off) and 0xffff (very bright)

getBrightness

public int getBrightness()
Get current backlight brightness.

Returns:
The current brightness of the backlight.

setContrast

public void setContrast(int value)
Set displays contrast

Parameters:
value - value between 0 (contrast off) and 0xffff (very high contrast)

getContrast

public int getContrast()
Get current display contrast.

Returns:
The current contrast of the display.

finalize

protected void finalize()
free internal data structures used by this xdisplay object.


setColor

public void setColor(Color color)
Sets the drawing color.

Specified by:
setColor in interface XGraphics
Parameters:
c - new drawing color

getColor

public int getColor()
Returns the ARGB value of the current drawing color.

Specified by:
getColor in interface XGraphics
Returns:
drawing color (ARGB value)

setBackground

public void setBackground(Color color)
Sets the background color.

Specified by:
setBackground in interface XGraphics
Parameters:
c - new background color

getBackground

public int getBackground()
Returns the ARGB value of the current background color.

Specified by:
getBackground in interface XGraphics
Returns:
background color (ARGB value)

swapColors

public void swapColors()
Swaps drawing and background color.

Specified by:
swapColors in interface XGraphics

setFont

public void setFont(Object newfont)
Sets the font to use.

Specified by:
setFont in interface Graphics
Overrides:
setFont in class AbstractGraphics
Parameters:
newfont - the font to use, possible values: SYSTEMFONT (default) or a instance of Resource specifying the font, the resource has to be in JCFD format (use FontEdit of the JControl toolware to generate).
See Also:
AbstractGraphics.drawString(java.lang.String s, int x, int y), AbstractGraphics.SYSTEMFONT

getFont

public Object getFont()
Returns the currently set font.

Specified by:
getFont in interface XGraphics
Returns:
font

translate

public void translate(int dx,
                      int dy)
Moves the translation (origin) point.

Specified by:
translate in interface XGraphics
Parameters:
dx - horizontal translation
dy - vertical translation

clipRect

public boolean clipRect(int nx,
                        int ny,
                        int nw,
                        int nh)
Intersects the stored ClipRect with another represented by the given values. The given ClipRect is interpretated in this XGraphics's coordinate-space. The origin doesn't get moved in this method.

Specified by:
clipRect in interface XGraphics
Parameters:
nx - new ClipRect x
ny - new ClipRect y
nw - new ClipRect width
nh - new ClipRect height
Returns:
true, if resulting clip rect is not empty

setClip

public void setClip(int nx,
                    int ny,
                    int nw,
                    int nh)
Sets the clipping rectangle. The only limit is the size of the underlying framebuffer. This method should be handled with care from within graphical frameworks like Xui, because it can enable access to the whole screen at any time, opening the door for graphical errors.

The coordinates are treated as relative to the current translation point.

Specified by:
setClip in interface XGraphics
Parameters:
x - new x-location of the clipping rectangle
y - new x-location of the clipping rectangle
width - new width of the clipping rectangle
height - new height of the clipping rectangle

getTranslateX

public int getTranslateX()
Returns the absolute x-location of the origin

Specified by:
getTranslateX in interface XGraphics
Returns:
absolute x-location of origin

getTranslateY

public int getTranslateY()
Returns the absolute y-location of the origin

Specified by:
getTranslateY in interface XGraphics
Returns:
absolute y-location of origin

getClipX

public int getClipX()
Returns the relative x-location of the clipping rectangle

Specified by:
getClipX in interface XGraphics
Returns:
absolute x-location of clipping rectangle

getClipY

public int getClipY()
Returns the relative y-location of the clipping rectangle

Specified by:
getClipY in interface XGraphics
Returns:
absolute y-location of clipping rectangle

getClipWidth

public int getClipWidth()
Returns the width of the clipping rectangle

Specified by:
getClipWidth in interface XGraphics
Returns:
width of clipping rectangle

getClipHeight

public int getClipHeight()
Returns the height of the clipping rectangle

Specified by:
getClipHeight in interface XGraphics
Returns:
height of clipping rectangle

isOverlapping

public boolean isOverlapping(int x,
                             int y,
                             int width,
                             int height)
Checks, if the given rectangle overlaps (or - mathematically spoken - intersects) with the current clipping rectangle.

The coordinates are treated as relative to the current translation point.

Specified by:
isOverlapping in interface XGraphics
Parameters:
x - x-location of rectangle to test
y - y-location of rectangle to test
width - width of rectangle to test
height - height of rectangle to test
Returns:
true, if the two rectangles are overlapping each other, otherwise false

isClipRectEmpty

public boolean isClipRectEmpty()
Checks, if the current clipping rectangle is empty (i.e. doesn't cover any pixel).

Specified by:
isClipRectEmpty in interface XGraphics
Returns:
true, if clipping rectangle is empty

drawRoundRect

public void drawRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Draws a rounded rectangle.

Specified by:
drawRoundRect in interface XGraphics
Parameters:
x - x-location
y - y-location
width - width
height - height
arcWidth -
arcHeight -

fillRoundRect

public void fillRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Draws a filled rounded rectangle.

Specified by:
fillRoundRect in interface XGraphics
Parameters:
x - x-location
y - y-location
width - width
height - height
arcWidth -
arcHeight -

drawOval

public void drawOval(int x,
                     int y,
                     int width,
                     int height)
Draws an ellipse.

Specified by:
drawOval in interface XGraphics
Parameters:
x - x-location
y - y-location
width - width
height - height

fillOval

public void fillOval(int x,
                     int y,
                     int width,
                     int height)
Draws a filled ellipse.

Specified by:
fillOval in interface XGraphics
Parameters:
x - x-location
y - y-location
width - width
height - height

drawImage

public void drawImage(Object drawable,
                      int x,
                      int y)
Draws an image to the specified coordinates. The image is drawn by its natural size, it may be cropped to the graphics device boundaries. The image object to draw can be of several types:

Specified by:
drawImage in interface Graphics
Overrides:
drawImage in class AbstractGraphics
Parameters:
drawable - the image to draw
x - the horizontal coordinate
y - the vertical coordinate

drawImage

public void drawImage(Object drawable,
                      int x,
                      int y,
                      int width,
                      int height,
                      int xoff,
                      int yoff)
Draws a subimage to the specified coordinates. The image is drawn by its natural size, it may be cropped to the graphics device boundaries. The source image may be shifted and cropped to a specified subimage.

Specified by:
drawImage in interface Graphics
Overrides:
drawImage in class AbstractGraphics
Parameters:
drawable - the image to draw
x - the horizontal coordinate
y - the vertical coordinate
width - the width of the sub image within the source image
height - the height of the sub image within the source image
xoff - horizontal offset of the sub image within the source image
yoff - vertical offset of the sub image within the source image
See Also:
drawImage(Object, int, int)

setStrokeMode

public void setStrokeMode(int mode)
NOTE: not supported
Sets the stroke mode.

Specified by:
setStrokeMode in interface XGraphics
Parameters:
stroke - mode (STROKEMODE_SOLID or STROKEMODE_DOTTED)

getStrokeMode

public int getStrokeMode()
NOTE: not supported
Returns the current stroke mode.

Specified by:
getStrokeMode in interface XGraphics
Returns:
current strokemode

drawArc

public void drawArc(int x,
                    int y,
                    int width,
                    int height,
                    int startangle,
                    int arcangle)
NOTE: not supported
Draws an elliptic arc.

Specified by:
drawArc in interface XGraphics
Parameters:
x - x-location of the underlying ellipse
y - y-location of the underlying ellipse
width - width of the underlying ellipse
height - height of the underlying ellipse
startAngle - angle from where to start drawing (in degrees)
arcAngle - angle along which the arc has to be drawn (in degrees)

fillArc

public void fillArc(int x,
                    int y,
                    int width,
                    int height,
                    int startangle,
                    int arcangle)
NOTE: not supported
Draws a filled elliptic arc, which is similar to a pie charts element.

Specified by:
fillArc in interface XGraphics
Parameters:
x - x-location of the underlying ellipse
y - y-location of the underlying ellipse
width - width of the underlying ellipse
height - height of the underlying ellipse
startAngle - angle from where to start drawing (in degrees)
arcAngle - angle along which the arc has to be drawn (in degrees)

drawPolygon

public void drawPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
NOTE: not supported
Draws a closed polyline. Closed means that a line is drawn between the first and the last point defining the polyline.

Specified by:
drawPolygon in interface XGraphics
Parameters:
xPoints - x-locations of the polyline's points
yPoints - y-locations of the polyline's points
nPoints - number of points
See Also:
drawPolyline(int[], int[], int)

drawPolyline

public void drawPolyline(int[] xPoints,
                         int[] yPoints,
                         int nPoints)
NOTE: not supported
Draws a polyline.

Specified by:
drawPolyline in interface XGraphics
Parameters:
xPoints - x-locations of the polyline's points
yPoints - y-locations of the polyline's points
nPoints - number of points
See Also:
drawPolygon(int[], int[], int)

fillPolygon

public void fillPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
NOTE: not supported
Draws a polygon.

Specified by:
fillPolygon in interface XGraphics
Parameters:
xPoints - x-locations of the polygon's points
yPoints - y-locations of the polygon's points
nPoints - number of points

drawChar

public int drawChar(char c,
                    int x,
                    int y,
                    int anchor)
NOTE: not supported
Draws a single character with the currently set font. An anchor can be used to specify the alignment of the character to the defined location.

Specified by:
drawChar in interface XGraphics
Parameters:
c - character to draw
x - x-location
y - y-location
anchor - character alignment (e.g. ANCHOR_HCENTER or ANCHOR_BASELINE, ...)
Returns:
width of the visible part(!) of the drawn character

drawString

public void drawString(String s,
                       int x,
                       int y,
                       int anchor)
NOTE: not supported
Draws a text string with the currently set font. An anchor can be used to specify the alignment of the text to the defined location.

Specified by:
drawString in interface XGraphics
Parameters:
s - text to draw
x - x-location
y - y-location
anchor - text alignment (e.g. ANCHOR_HCENTER or ANCHOR_BASELINE, ...)

drawImage

public void drawImage(Object drawable,
                      int x,
                      int y,
                      int anchor)
NOTE: not supported
Draws an image. An anchor can be used to specify the alignment of the image to the defined location.

Specified by:
drawImage in interface XGraphics
Parameters:
drawable - drawable object (e.g. Image or a Resource containing a bitmap image)
x - x-location
y - y-location
anchor - image alignment (e.g. ANCHOR_HCENTER or ANCHOR_TOP, ...)

copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int dx,
                     int dy)
NOTE: not supported
Copies an area within the framebuffer. The draw mode gets ignored here.

Specified by:
copyArea in interface XGraphics
Parameters:
x - x-location of area to copy
y - y-location of area to copy
width - width of area to copy
height - height of area to copy
dx - destination x-location
dy - destination y-location