-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMap1.java
More file actions
52 lines (41 loc) · 1.74 KB
/
CMap1.java
File metadata and controls
52 lines (41 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication2;
/******************************************************************************************
CMap1对CMap地实现
span( ) 表示合并的单元格的列,返回的是合并的格数。
visibleCell() 表示要渲染的格。返回的渲染的开始格的行。
本程序的table是16行10列,合并的单元格是第一列和最后一列(最后一列是第10列)每两个行。
*******************************************************************************************/
import javax.swing.*;
import javax.swing.table.*;
class CMap1 implements CMap {
public int span(int row, int column) {
if( column == 0 || column == 9 )
return 2;
return 1;
}
public int visibleCell(int row, int column) {
if( ( ( row >= 0 ) && ( row < 2 ) ) && ( column == 0 || column == 9 ) )
return 0;
if( ( ( row >= 2 ) && ( row < 4 ) ) && ( column == 0 || column == 9 ) )
return 2;
if( ( ( row >= 4 ) && ( row < 6 ) ) && ( column == 0 || column == 9 ) )
return 4;
if( ( ( row >= 6 ) && ( row < 8 ) ) && ( column == 0 || column == 9 ) )
return 6;
if( ( ( row >= 8 ) && ( row < 10 ) ) && ( column == 0 || column == 9 ) )
return 8;
if( ( ( row >= 10 ) && ( row < 12 ) ) && ( column == 0 || column == 9 ) )
return 10;
if( ( ( row >= 12 ) && ( row < 14 ) ) && ( column == 0 || column == 9 ) )
return 12;
if( ( ( row >= 14 ) && ( row < 16 ) ) && ( column == 0 || column == 9 ) )
return 14;
System.out.println( ">>>row = " + row + "column = " + column );
return row;
}
}