|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpt.ua.gboard.Gelem
public abstract class Gelem
Abstract graphical element occupying a rectangular group of cells in a GBoard.
invariant: numberOfLines() >= 1 && numberOfColumns() >= 1
This class follows DbC(tm) methodology. Where possible, contracts are implement with JML and native's Java assert.
Constructor Summary | |
---|---|
Gelem()
Constructs a new Gelem (1x1 cells). |
|
Gelem(int numberOfLines,
int numberOfColumns)
Constructs a new Gelem (numberOfLines x numberOfColumns cells). |
Method Summary | |
---|---|
abstract void |
draw(java.awt.Graphics g,
int line,
int column,
int cellWidth,
int cellHeight,
java.awt.Color background)
Draw Gelem in GBoard (it should be exported only to GBoard). |
abstract void |
erase(java.awt.Graphics g,
int line,
int column,
int cellWidth,
int cellHeight,
java.awt.Color background)
Erase Gelem from GBoard (it should be exported only to GBoard). |
int |
height(int cellHeight)
Height (in pixels) of current gelem. |
boolean |
intersects(int line,
int column,
Gelem other,
int otherLine,
int otherColumn)
Does current gelem at position (line, column) intersects gelem other at position (otherLine, otherColumn)? |
boolean |
isMutable()
Is gelem mutable? A mutable gelem automatically updates GBoard when updated. |
MutableGelem |
mutable()
If mutable, returns a mutable version of current gelem, otherwise it returns null. |
int |
numberOfColumns()
Column dimensions of Gelem measured in number of cells. |
int |
numberOfLines()
Line dimensions of Gelem measured in number of cells. |
int |
width(int cellWidth)
Width (in pixels) of current gelem. |
int |
x(int column,
int cellWidth)
Pixel x position of gelem. |
int |
y(int line,
int cellHeight)
Pixel y position of gelem. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Gelem()
public Gelem(int numberOfLines, int numberOfColumns)
requires: numberOfLines >= 1 && numberOfColumns >= 1
numberOfLines
- number of linesnumberOfColumns
- number of columnsMethod Detail |
---|
public int numberOfLines()
int
number of linespublic int numberOfColumns()
int
number of columnspublic abstract void draw(java.awt.Graphics g, int line, int column, int cellWidth, int cellHeight, java.awt.Color background)
requires: g != null && background != null
(incomplete!)
g
- Java's Graphics object to use in drawingline
- line in GBoard to draw Gelem.column
- column in GBoard to draw Gelem.cellWidth
- number of horizontal pixels per cellcellHeight
- number of vertical pixels per cellbackground
- background colorpublic abstract void erase(java.awt.Graphics g, int line, int column, int cellWidth, int cellHeight, java.awt.Color background)
requires: g != null && background != null
(incomplete!)
g
- Java's Graphics object to use in drawingline
- line in GBoard to draw Gelem.column
- column in GBoard to draw Gelem.cellWidth
- number of horizontal pixels per cellcellHeight
- number of vertical pixels per cellpublic boolean intersects(int line, int column, Gelem other, int otherLine, int otherColumn)
requires: other != null
line
- line of current Gelem.column
- column of current Gelem.other
- the other gelemotherLine
- line of other Gelem.otherColumn
- column of other Gelem.
boolean
true if they intersectpublic int x(int column, int cellWidth)
column
- column of gelem.cellWidth
- number of horizontal pixels per cell
int
positionpublic int y(int line, int cellHeight)
line
- line of gelem.cellHeight
- number of vertical pixels per cell
int
positionpublic int width(int cellWidth)
cellWidth
- number of horizontal pixels per cell
int
number of pixelspublic int height(int cellHeight)
cellHeight
- number of vertical pixels per cell
int
number of pixelspublic boolean isMutable()
boolean
true if mutable, otherwise retuns falsepublic MutableGelem mutable()
boolean
a reference to an object if mutable, otherwise retuns null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |