Java Reference
In-Depth Information
6.
//
left corner of the black rectangle to
7.
//
be only at:
8.
//
0/stepNo, 1/stepNo,...,allowedMax/stepNo
9.
//
of the current width or height of the panel.
10.
//
With the choice below this is
11.
//
0/9, 1/9, 2/9, 3/9, 4/9, 5/9, and 6/9
.
12.
13.
private static final int
stepNo
= 9;
14.
private static final int
allowedMax = 6;
15.
16.
//
The next variable specifies the length and
17.
//
height of the black rectangle as a number
18.
//
of steps. Here we take 3
.
19.
20.
private static final int
blackRectSteps = 3;
21.
22.
//
The next two variables contain the
23.
//
current position of the black rectangle
24.
//
(in fractions of the current width and height
25.
//
of the panel)
.
26.
27.
28.
private int
upperLeftX, upperLeftY;
29.
30.
public
PositionModel(
int
x,
int
y) {
31.
upperLeftX = x;
32.
upperLeftY = y;
33.
}
34.
35.
36.
public int
getXInSteps(){
37.
return
(upperLeftX);
38.
}
39.
40.
public int
getYInSteps(){
41.
return
(upperLeftY);
42.
}
43.
44.
public int
getNoOfSteps(){
45.
return
(stepNo);
46.
}
47.
public int
getBlackSizeInSteps(){
48.
return
(blackRectSteps);
49.
}
50.
51.
Search WWH ::
Custom Search