-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextLine.java
More file actions
43 lines (41 loc) · 1.05 KB
/
Copy pathTextLine.java
File metadata and controls
43 lines (41 loc) · 1.05 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
/**
* Clasa TextLine, extindere a clasei parinte ModelPrimitiva
* @author claudiu
*
*/
public class TextLine extends ModelPrimitiva{
/**
* Constructorul clasei TextLine
* Construieste si corpul obiectului in functie de dimensiunea textului
* @param name - numele obiectului
* @param text - textul de scris
*/
public TextLine(String name, String text){
super();
nume = name;
height = 1;
width = text.length();
this.text = text;
MakeBody();//Construiesc corpul
}
/**
* Metoda de construire a corpului obiectului
*/
public void MakeBody(){
body = new char[height][width];//Realoc o matrice in functie de latime si inalime
int i;
for (i=0; i<width; i++){
if (i<text.length()){
body[0][i] = text.charAt(i);//Construiesc cu literele din text
}
else body[0][i] = ' ';//...iar restul cu spatii
}
}
/**
* Redimensioneaza obiectul cu noile marimi primite ca parametru si reconstruieste corpul
*/
public void resize(int i, int j){
super.resize(i, j);
this.MakeBody();
}
}