-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlyphFactory.java
More file actions
35 lines (26 loc) · 811 Bytes
/
GlyphFactory.java
File metadata and controls
35 lines (26 loc) · 811 Bytes
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
package structural.flyweight;
public class GlyphFactory {
/**
* contains references to Character Glyphs indexed by character code. The array is initialized in the constructor
*/
private Character[] characters = new Character[N_CHAR_CODES];
private static final int N_CHAR_CODES = 128;
public GlyphFactory() {
for (int i = 0; i < N_CHAR_CODES; i++) {
characters[i] = null;
}
}
public Character CreateCharacter(char character) {
if (characters[character] != null) {
characters[character] = new Character(character);
}
return characters[character];
}
public Object CreateRow() {
return new Object();
}
public Object CreateColumn() {
return new Object();
}
/* ... */
}