172
173 // --- View methods -------------------------------------------
174
175 /**
176 * Renders using the given rendering surface and area on that surface.
177 * The view may need to do layout and create child views to enable
178 * itself to render into the given allocation.
179 *
180 * @param g the rendering surface to use
181 * @param a the allocated region to render into
182 *
183 * @see View#paint
184 */
185 public void paint(Graphics g, Shape a) {
186 Rectangle r = (Rectangle) a;
187 g.clipRect(r.x, r.y, r.width, r.height);
188 super.paint(g, a);
189 }
190
191 /**
192 * Adjusts <code>a</code> based on the visible region and returns it.
193 */
194 Shape adjustPaintRegion(Shape a) {
195 return adjustAllocation(a);
196 }
197
198 /**
199 * Determines the preferred span for this view along an
200 * axis.
201 *
202 * @param axis may be either View.X_AXIS or View.Y_AXIS
203 * @return the span the view would like to be rendered into >= 0.
204 * Typically the view is told to render into the span
205 * that is returned, although there is no guarantee.
206 * The parent may choose to resize or break the view.
207 */
208 public float getPreferredSpan(int axis) {
209 switch (axis) {
210 case View.X_AXIS:
211 Segment buff = SegmentCache.getSharedSegment();
212 Document doc = getDocument();
|
172
173 // --- View methods -------------------------------------------
174
175 /**
176 * Renders using the given rendering surface and area on that surface.
177 * The view may need to do layout and create child views to enable
178 * itself to render into the given allocation.
179 *
180 * @param g the rendering surface to use
181 * @param a the allocated region to render into
182 *
183 * @see View#paint
184 */
185 public void paint(Graphics g, Shape a) {
186 Rectangle r = (Rectangle) a;
187 g.clipRect(r.x, r.y, r.width, r.height);
188 super.paint(g, a);
189 }
190
191 /**
192 * Adjusts {@code a} based on the visible region and returns it.
193 */
194 Shape adjustPaintRegion(Shape a) {
195 return adjustAllocation(a);
196 }
197
198 /**
199 * Determines the preferred span for this view along an
200 * axis.
201 *
202 * @param axis may be either View.X_AXIS or View.Y_AXIS
203 * @return the span the view would like to be rendered into >= 0.
204 * Typically the view is told to render into the span
205 * that is returned, although there is no guarantee.
206 * The parent may choose to resize or break the view.
207 */
208 public float getPreferredSpan(int axis) {
209 switch (axis) {
210 case View.X_AXIS:
211 Segment buff = SegmentCache.getSharedSegment();
212 Document doc = getDocument();
|