57 |
private Element elt; |
private Element elt; |
58 |
private View parent; |
private View parent; |
59 |
|
|
60 |
/** |
/** |
61 |
* Creates a new <code>View</code> instance. |
* Creates a new <code>View</code> instance. |
62 |
* |
* |
63 |
* @param elem an <code>Element</code> value |
* @param elem an <code>Element</code> value |
64 |
*/ |
*/ |
65 |
public View(Element elem) |
public View(Element elem) |
66 |
{ |
{ |
67 |
elt = elem; |
elt = elem; |
68 |
} |
} |
69 |
|
|
70 |
public abstract void paint(Graphics g, Shape s); |
public abstract void paint(Graphics g, Shape s); |
71 |
|
|
72 |
public void setParent(View a) |
public void setParent(View a) |
73 |
{ |
{ |
74 |
parent = a; |
parent = a; |
75 |
} |
} |
76 |
|
|
77 |
public View getParent() |
public View getParent() |
78 |
{ |
{ |
79 |
return parent; |
return parent; |
80 |
} |
} |
81 |
|
|
82 |
public void setSize(int w, int h) |
public void setSize(int w, int h) |
83 |
{ |
{ |
84 |
width = w; |
width = w; |
85 |
height = h; |
height = h; |
86 |
} |
} |
87 |
|
|
88 |
public Container getContainer() |
public Container getContainer() |
89 |
{ |
{ |
90 |
return parent != null ? parent.getContainer() : null; |
return parent != null ? parent.getContainer() : null; |
91 |
} |
} |
92 |
|
|
93 |
public Document getDocument() |
public Document getDocument() |
94 |
{ |
{ |
95 |
return getElement().getDocument(); |
return getElement().getDocument(); |
96 |
} |
} |
97 |
|
|
98 |
public Element getElement() |
public Element getElement() |
99 |
{ |
{ |
100 |
return elt; |
return elt; |
101 |
} |
} |
102 |
|
|
103 |
public abstract float getPreferredSpan(int axis); |
public abstract float getPreferredSpan(int axis); |
104 |
|
|
105 |
public float getAlignment(int axis) |
public float getAlignment(int axis) |
106 |
{ |
{ |
107 |
return 0.5f; |
return 0.5f; |
108 |
} |
} |
109 |
|
|
110 |
public AttributeSet getAttributes() |
public AttributeSet getAttributes() |
111 |
{ |
{ |
112 |
return elt.getAttributes(); |
return elt.getAttributes(); |
113 |
} |
} |
114 |
|
|
115 |
public boolean isVisible() |
public boolean isVisible() |
116 |
{ |
{ |
117 |
return true; |
return true; |
118 |
} |
} |
119 |
|
|
120 |
public int getViewCount() |
public int getViewCount() |
121 |
{ |
{ |
122 |
return 0; |
return 0; |
123 |
} |
} |
124 |
|
|
125 |
public View getView(int index) |
public View getView(int index) |
126 |
{ |
{ |
127 |
return null; |
return null; |
128 |
} |
} |
129 |
|
|
130 |
public ViewFactory getViewFactory() |
public ViewFactory getViewFactory() |
131 |
{ |
{ |
132 |
return parent != null ? parent.getViewFactory() : null; |
return parent != null ? parent.getViewFactory() : null; |
133 |
} |
} |
134 |
|
|
135 |
public void replace(int offset, int length, View[] views) |
public void replace(int offset, int length, View[] views) |
136 |
{ |
{ |
137 |
// Default implementation does nothing. |
// Default implementation does nothing. |
138 |
} |
} |
139 |
|
|
140 |
public void insert(int offset, View view) |
public void insert(int offset, View view) |
141 |
{ |
{ |
142 |
View[] array = { view }; |
View[] array = { view }; |
143 |
replace(offset, 1, array); |
replace(offset, 1, array); |
144 |
} |
} |
145 |
|
|
146 |
public void append(View view) |
public void append(View view) |
147 |
{ |
{ |
152 |
public void removeAll() |
public void removeAll() |
153 |
{ |
{ |
154 |
replace(0, getViewCount(), null); |
replace(0, getViewCount(), null); |
155 |
} |
} |
156 |
|
|
157 |
public void remove(int index) |
public void remove(int index) |
158 |
{ |
{ |
161 |
|
|
162 |
public View createFragment(int p0, int p1) |
public View createFragment(int p0, int p1) |
163 |
{ |
{ |
164 |
// The default implementation doesnt support fragmentation. |
// The default implementation doesn't support fragmentation. |
165 |
return this; |
return this; |
166 |
} |
} |
167 |
|
|
168 |
|
public int getStartOffset() |
169 |
|
{ |
170 |
|
return elt.getStartOffset(); |
171 |
|
} |
172 |
|
|
173 |
|
public int getEndOffset() |
174 |
|
{ |
175 |
|
return elt.getEndOffset(); |
176 |
|
} |
177 |
} |
} |
178 |
|
|