public abstract class Gelem
extends java.lang.Object
invariant: numberOfLines() >= 1 && numberOfColumns() >= 1
This class follows DbC(tm) methodology. Where possible, contracts are implement with JML and native's Java assert.
| Constructor and Description |
|---|
Gelem()
Constructs a new Gelem (1x1 cells).
|
Gelem(int numberOfLines,
int numberOfColumns)
Constructs a new Gelem (numberOfLines x numberOfColumns cells).
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
className()
gelem's class name.
|
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).
|
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.
|
void |
mutableDraw(java.awt.Graphics g,
int line,
int column,
int cellWidth,
int cellHeight,
java.awt.Color background)
Draw the mutable part of the gelem (does nothing in immutable gelem's).
|
void |
mutableErase(java.awt.Graphics g,
int line,
int column,
int cellWidth,
int cellHeight,
java.awt.Color background)
Draw the mutable part of the gelem (does nothing in immutable gelem's).
|
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.
|
public Gelem()
public Gelem(int numberOfLines,
int numberOfColumns)
requires: numberOfLines >= 1 && numberOfColumns >= 1
numberOfLines - number of linesnumberOfColumns - number of columnspublic int numberOfLines()
int number of linespublic int numberOfColumns()
int number of columnspublic 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 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 cellbackground - background colorpublic void mutableDraw(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 void mutableErase(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 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 cellint positionpublic int y(int line,
int cellHeight)
line - line of gelem.cellHeight - number of vertical pixels per cellint positionpublic int width(int cellWidth)
cellWidth - number of horizontal pixels per cellint number of pixelspublic int height(int cellHeight)
cellHeight - number of vertical pixels per cellint number of pixelspublic java.lang.String className()
String the namepublic boolean isMutable()
boolean true if mutable, otherwise retuns falsepublic MutableGelem mutable()
requires: isMutable()
boolean a reference to an object if mutable, otherwise retuns null