@MinDoc(copyright="Copyright 1998 - 2003, 2004, 2008, 2009 A. Weinert", author="Albrecht Weinert", version="V.11", lastModified="5.02.2019", lastModifiedBy="A. Weinert", usage="import, use as Paintable", purpose="a matrix display for graphical applications") public class MatrixDisplay extends Object implements Paintable
01234..01234..01234
0 *** ***
1 * * * *
2 * * * *
3 ***** **** ****
4 * * * * *
5 * * **** *
6 * * * ***
7 ****
( A g 9 )
DisplayPattern
features such pattern. For one line of 20
characters (and distance 2 dots) a MatrixDisplay
of 138 * 8 would
have to be made.Value | Meaning | Colour |
---|---|---|
0 | Off | background colour |
else | On | foreground colour |
DisplayPattern
Modifier and Type | Field and Description |
---|---|
int |
allXdots
Number of all points, X direction, horizontal .
|
int |
allYdots
Number of all points, Y direction, vertical .
|
Color |
background
Background colour..
|
protected byte[][] |
dots
State of the points.
|
Color |
foreground
Foreground colour.
|
Color |
marginGround
Margin colour.
|
protected MatrixDisplayDim |
matDisDim |
boolean |
onRound
"On point" shall be round.
|
static int |
SCR_R_X
Scroll reserve, X direction, extra columns to right.
|
static int |
SCR_R_Y
Scroll reserve, in Y direction, additional lines below.
|
Constructor and Description |
---|
MatrixDisplay(int noXdots,
int noYdots,
int margin,
int size,
int dist)
Constructor with equal x and y sizes for the matrix dots.
|
MatrixDisplay(int noXdots,
int noYdots,
int marginX,
int marginY,
int sizeX,
int sizeY,
int distX,
int distY)
Universal Constructor by independent x and y dimensions .
|
MatrixDisplay(MatrixDisplayDim size)
Constructor by predefined dimensions.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all points.
|
byte |
getDot(int x,
int y)
Get a point's state.
|
void |
paint(Graphics g,
int px,
int py,
int w,
int h)
Painting the matrix display dots.
|
void |
setAllBack(Color c)
Set the background and margin colour.
|
void |
setBackground(Color c)
Set the background colour.
|
void |
setDot(int x,
int y,
byte dot)
Set a point's state.
|
void |
setDots(int x,
int y,
int xNum,
int yNum,
byte[][] muster,
int xOff,
int yOff)
Set multiple points.
|
void |
setForeground(Color c)
Set the foreground colour.
|
void |
setMarginGround(Color c)
Set the margin colour.
|
void |
setShift(int sX,
int sY)
Shift the display to top and to left by number of pixels.
|
public static final int SCR_R_X
public final int allXdots
SCR_R_Y
.public static final int SCR_R_Y
public final int allYdots
public boolean onRound
protected final byte[][] dots
new
byte[noYdots
+
SCR_R_Y
][noXdots
+
SCR_R_X
]
new
byte[allYdots
][allXdots
]
protected final MatrixDisplayDim matDisDim
public Color foreground
public Color background
public Color marginGround
public MatrixDisplay(int noXdots, int noYdots, int margin, int size, int dist)
noXdots
- Number of points horizontal ( >= 1)noYdots
- Number of points vertical ( >= 1 )margin
- Horizontal and vertical margin in pixel ( >= 0 )size
- The dot's horizontal and vertical dimension in pixel ( >= 1 )dist
- The dot's horizontal and vertical distance including their
size ( >= size )public MatrixDisplay(MatrixDisplayDim size)
size
- all dimensions in one objectpublic MatrixDisplay(int noXdots, int noYdots, int marginX, int marginY, int sizeX, int sizeY, int distX, int distY)
noXdots
- Number of points horizontal ( >= 1)noYdots
- Number of points vertical ( >= 1)marginX
- Horizontal margin in Pixel ( >= 0)marginY
- Vertical margin in Pixel ( >= 0)sizeX
- The dot's horizontal dimension in pixel ( >= 1)sizeY
- The dot's vertical dimension in pixel ( >= 1)distX
- Horizontal distance of the dots including their ( >= size)distY
- Vertical distance of the dots including their ( >= size)public byte getDot(int x, int y)
public void setDot(int x, int y, byte dot)
public void clear()
public void setDots(int x, int y, int xNum, int yNum, byte[][] muster, int xOff, int yOff)
dots
(itself) is taken as source and this
method will scroll the content.x
- Start column in the MatrixDisplayy
- Start line in the MatrixDisplayxNum
- Number of columns to change (will be automatically limited)yNum
- same for the linesmuster
- a matrix point content (as source);
null takes the actual content (shift operations)xOff
- Starting column in muster (source)yOff
- Starting line in muster (source)public void setMarginGround(Color c)
public void setBackground(Color c)
public void setAllBack(Color c)
public void setForeground(Color c)
public void setShift(int sX, int sY)
xDist
to left respectively by maximal
yDist
pixel to the top bringing
(parts of) the scroll reserve in sight.setDots(int, int, int, int, null, int, int)
.
It just manipulates the origins for the next paint. This allows for
smother scrolling implementations.public void paint(Graphics g, int px, int py, int w, int h)
paint
in interface Paintable
g
- The notorious Graphics
object (that can
nowadays be expected to be a Graphics2D
).px
- y are the left upper corner of where to paint;
y grows downwards [sic!]w
- height are the size of an surrounding rectangle
to paint within; if null (0, 0) either this object's
"natural" size (if there is such thing) shall be used
or nothing is to be donePaintable.paint(Graphics, Point, Dimension)