Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jcontrol.io
Class AbstractGraphics

    java.lang.Object
      jcontrol.io.AbstractGraphics

All Implemented Interfaces:
  Graphics

Direct Known Subclasses:
  BufferGraphics, Display, XDisplay

    public abstract class AbstractGraphics

extends Object
implements Graphics

NOTE: do not use this class!

Contains the low-level graphic routines for Display and Buffers. This class should not not used from outside.

See Also:
  `Display`

Field Summary
`static int` | `NEGATIVE` Displaymode.
`static int` | `OFF` Displaymode.
`static int` | `ON` Displaymode.
`static String` | `SYSTEMFONT` Used to specify the internal font with `setFont(Object)`.

Fields inherited from interface jcontrol.io.Graphics
`AND, INVERSE, NORMAL, OR, XOR`

Constructor Summary
`AbstractGraphics()`

Method Summary
`void` | `clearDisplay()` Clears the display.
`void` | `clearRect(int x, int y, int width, int height)` Clears the specified rectangle by filling it with the background color of the current drawing surface.
`int` | `drawChar(char c, int x, int y)` Draws a single character to the Display.
`void` | `drawImage(Object drawable, int x, int y)` Draws an image to the specified coordinates.
`void` | `drawImage(Object drawable, int x, int y, int width, int height, int xoff, int yoff)` Draws an subimage to the specified coordinates.
`void` | `drawLine(int x1, int y1, int x2, int y2)` Draws a line using Bresenham's Algorithm.
`void` | `drawRect(int x, int y, int width, int height)` Draws a rectangular frame.
`int` | `drawString(String s, int x, int y)` Draws a `String` to the display.
`int` | `drawString(String s, int x, int y, int width, int height, int xoff, int yoff)` Draws a `String` to the Display.
`void` | `fillRect(int x, int y, int width, int height)` Draws a filled rectangle.
`int` | `getDrawMode()` Returns the current Drawmode.
`int` | `getFontHeight()` Returns the height of the currently used font in pixels.
`int` | `getPixel(int x, int y)` Returns a single pixels color on the display.
`int` | `getTextWidth(String s)` Returns the width of graphical text in pixels, this is dependent from the currently used font.
`void` | `scroll(int x, int y)` Scrolls the whole display content.
`void` | `setBackground(int color)` Sets the background color (for text etc.).
`void` | `setColor(int color)` Sets the foreground color.
`void` | `setDisplayMode(int mode)` Sets the displaymode.
`void` | `setDrawMode(int mode)` Sets the drawing mode.
`void` | `setFont(Object newfont)` Sets the font to use.
`void` | `setPixel(int x, int y)` Sets a single pixel on the display to foreground color.

Methods inherited from class java.lang.Object
`clone, equals, getClass, notifyAll, toString, wait`

Field Detail

### SYSTEMFONT

    public static final String SYSTEMFONT

  Used to specify the internal font with `setFont(Object)`.

### OFF

    public static final int OFF

  Displaymode. Turns off the display (all pixels hidden, drawing possible).

  See Also:
    `setDisplayMode(int)`, Constant Field Values

### ON

    public static final int ON

  Displaymode. Turns on the display (all pixels visible, default).

  See Also:
    `setDisplayMode(int)`, Constant Field Values

### NEGATIVE

    public static final int NEGATIVE

  Displaymode. Turns the display into negative mode (all pixels inverted, drawing as usual).

  See Also:
    `setDisplayMode(int)`, Constant Field Values

Constructor Detail

### AbstractGraphics

    public AbstractGraphics()

Method Detail

### setColor

    public void setColor(int color)

  Sets the foreground color.

  Specified by:
    `setColor` in interface `Graphics`
  Parameters:
    `color` - (on BW-displays: 0 for black - default, >0 for white)

### setBackground

    public void setBackground(int color)

  Sets the background color (for text etc.).

  Specified by:
    `setBackground` in interface `Graphics`
  Parameters:
    `color` - (on BW-displays: 0 for black, >0 for white - default)

### setDrawMode

    public void setDrawMode(int mode)

  Sets the drawing mode.

  Specified by:
    `setDrawMode` in interface `Graphics`
  Parameters:
    `mode` - drawmode constant or combination of drawmodes

    Possible drawmodes:

    - `Graphics.NORMAL` (no change)
    - `Graphics.INVERSE` (swaps foreground and background color)
    - `Graphics.AND` (logical combination with display pixles, can be combined with `INVERSE`)
    - `Graphics.OR` (logical combination with display pixles, can be combined with `INVERSE`)
    - `Graphics.XOR` (logical combination with display pixles, can be combined with `INVERSE`)
  See Also:
    `setColor(int)`

### getDrawMode

    public int getDrawMode()

  Returns the current Drawmode.

  Specified by:
    `getDrawMode` in interface `Graphics`
  See Also:
    `setDrawMode(int)`

### drawRect

    public void drawRect(int x,
                         int y,
                         int width,
                         int height)

  Draws a rectangular frame.

  Specified by:
    `drawRect` in interface `Graphics`
  Parameters:
    `x` - the horizontal coordinate
    `y` - the vertical coordinate
    `width` - rectangle width
    `height` - rectangle height

### fillRect

    public void fillRect(int x,
                         int y,
                         int width,
                         int height)

  Draws a filled rectangle.

  Specified by:
    `fillRect` in interface `Graphics`
  Parameters:
    `x` - the horizontal coordinate
    `y` - the vertical coordinate
    `width` - rectangle width
    `height` - rectangle height

### clearRect

    public void clearRect(int x,
                          int y,
                          int width,
                          int height)

  Clears the specified rectangle by filling it with the background color of the current drawing surface. The current drawmode is not used.

  Specified by:
    `clearRect` in interface `Graphics`
  Parameters:
    `x` - the horizontal coordinate
    `y` - the vertical coordinate
    `width` - rectangle width
    `height` - rectangle 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 display boundaries. The image object to draw can be of several types:
  - an opened `Resource` pointing to a JCIF file (use JIFEditor to create)
  - a `String[]` array in JCIF format (use JIFEditor to create and paste)
  - a single `String` will behave like `drawString()`
  - a instance of `Drawable` specifiying what to draw
  - `null` will behave like `fillRect()`

  Specified by:
    `drawImage` in interface `Graphics`
  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 an subimage to the specified coordinates. The image is drawn by its natural size, it may be cropped to the display boundaries. The source image may be shifted and cropped to a specified subimage.

  Specified by:
    `drawImage` in interface `Graphics`
  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)`

### setDisplayMode

    public void setDisplayMode(int mode)

  Sets the displaymode.

  Parameters:
    `mode` - displaymode to use

    Possible displaymodes:

    - `ON` (turns the display on - default)
    - `OFF` (turns the display off, background drawing still possible)
    - `NEGATIVE` (turns the display on and inverses all pixels, does not affect drawmodes)

### clearDisplay

    public void clearDisplay()

  Clears the display. Fills the display with the default background color (is not affected by `setBackground(int)`).

### setPixel

    public void setPixel(int x,
                         int y)

  Sets a single pixel on the display to foreground color.

  Specified by:
    `setPixel` in interface `Graphics`
  Parameters:
    `x` - the horizontal coordinate.
    `y` - the vertical coordinate.
  See Also:
    `setColor(int)`

### getPixel

    public int getPixel(int x,
                        int y)

  Returns a single pixels color on the display.

  Specified by:
    `getPixel` in interface `Graphics`
  Parameters:
    `x` - the horizontal coordinate.
    `y` - the vertical coordinate.
  Returns:
    the color of the pixel (on BW-displays: 0 for black, 1 for white)

### drawLine

    public void drawLine(int x1,
                         int y1,
                         int x2,
                         int y2)

  Draws a line using Bresenham's Algorithm.

  Specified by:
    `drawLine` in interface `Graphics`
  Parameters:
    `x1` - the horizontal coordinate of starting point.
    `y1` - the vertical coordinate of starting point.
    `x2` - the horizontal coordinate of ending point.
    `y2` - the vertical coordinate of ending point.

### setFont

    public void setFont(Object newfont)

  Sets the font to use.

  Specified by:
    `setFont` in interface `Graphics`
  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:
    `drawString(java.lang.String s, int x, int y)`, `SYSTEMFONT`

### drawChar

    public int drawChar(char c,
                        int x,
                        int y)

  Draws a single character to the Display.

  Specified by:
    `drawChar` in interface `Graphics`
  Parameters:
    `c` - the charater to draw (only a few special characters are supported, e.g. german umlauts)
    `x` - the horizontal coordinate of the chars upper left corner
    `y` - the vertical coordinate of the chars upper left corner
  Returns:
    the number of horizontal pixels consumed by the text
  See Also:
    `setFont(Object)`, `drawString(String, int, int)`

### drawString

    public int drawString(String s,
                          int x,
                          int y)

  Draws a `String` to the display.

  Specified by:
    `drawString` in interface `Graphics`
  Parameters:
    `s` - the `String` to draw (in some fonts only a few special characters are supported, e.g. german umlauts)
    `x` - the horizontal coordinate of the strings upper left corner
    `y` - the vertical coordinate of the strings upper left corner
  Returns:
    the number of horizontal pixels consumed by the text (depends on current font)
  See Also:
    `setFont(Object)`

### drawString

    public int drawString(String s,
                          int x,
                          int y,
                          int width,
                          int height,
                          int xoff,
                          int yoff)

  Draws a `String` to the Display. The text area may be shifted and cropped to a specified rectangle.

  Specified by:
    `drawString` in interface `Graphics`
  Parameters:
    `s` - the `String` to draw (in some fonts only a few special characters are supported, e.g. german umlauts)
    `x` - the horizontal coordinate of the strings upper left corner
    `y` - the vertical coordinate of the strings upper left corner
    `width` - the width of the text rectangle
    `height` - the height of the text rectangle
    `xoff` - horizontal offset of the text within the rectangle
    `yoff` - vertical offset of the text within the rectangle
  Returns:
    the number of horizontal pixels consumed by the text (depends on current font)
  See Also:
    `setFont(Object)`, `drawString(String, int, int)`

### getTextWidth

    public int getTextWidth(String s)

  Returns the width of graphical text in pixels, this is dependent from the currently used font. Behaves exacly like `drawString()` but omits drawing.

  Specified by:
    `getTextWidth` in interface `Graphics`
  Parameters:
    `s` - the `String` which width is to be calculated
  Returns:
    the text width in pixels if this text would be drawn
  See Also:
    `drawString(String, int, int)`

### getFontHeight

    public int getFontHeight()

  Returns the height of the currently used font in pixels.

  Specified by:
    `getFontHeight` in interface `Graphics`
  Returns:
    the height of the current font
  See Also:
    `setFont(Object)`, `getTextWidth(String)`

### scroll

    public void scroll(int x,
                       int y)

  Scrolls the whole display content. On some JControl devices vertical scrolling is done with display hardware (fast).

  Parameters:
    `x` - scroll in horizontal direction (x>0 : to the right)
    `y` - scroll in vertical direction (y>0 : down)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD