/** * Renders using the given rendering surface and area on that surface. * * @param g the rendering surface to use * @param allocation the allocated region to render into * @see View#paint */ public void paint(Graphics g, Shape allocation) { super.paint(g, allocation); Rectangle alloc = allocation.getBounds(); Rectangle clip = g.getClipBounds(); // Since listPainter paints in the insets we have to check for the // case where the child is not painted because the paint region is // to the left of the child. This assumes the ListPainter paints in // the left margin. if ((clip.x + clip.width) < (alloc.x + getLeftInset())) { Rectangle childRect = alloc; alloc = getInsideAllocation(allocation); int n = getViewCount(); int endY = clip.y + clip.height; for (int i = 0; i < n; i++) { childRect.setBounds(alloc); childAllocation(i, childRect); if (childRect.y < endY) { if ((childRect.y + childRect.height) >= clip.y) { listPainter.paint( g, childRect.x, childRect.y, childRect.width, childRect.height, this, i); } } else { break; } } } }
/** * Calculate the needs for the paragraph along the minor axis. * * <p>If size requirements are explicitly specified for the paragraph, use that requirements. * Otherwise, use the requirements of the superclass {@link javax.swing.text.ParagraphView}. * * <p>If the {@code axis} parameter is neither {@code View.X_AXIS} nor {@code View.Y_AXIS}, {@link * IllegalArgumentException} is thrown. If the {@code r} parameter is {@code null,} a new {@code * SizeRequirements} object is created, otherwise the supplied {@code SizeRequirements} object is * returned. * * @param axis the minor axis * @param r the input {@code SizeRequirements} object * @return the new or adjusted {@code SizeRequirements} object * @throws IllegalArgumentException if the {@code axis} parameter is invalid */ protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r) { r = super.calculateMinorAxisRequirements(axis, r); if (BlockView.spanSetFromAttributes(axis, r, cssWidth, cssHeight)) { // Offset by the margins so that pref/min/max return the // right value. int margin = (axis == X_AXIS) ? getLeftInset() + getRightInset() : getTopInset() + getBottomInset(); r.minimum -= margin; r.preferred -= margin; r.maximum -= margin; } return r; }
/** * Paints the <code>ListView</code>. * * @param g the graphics context to use for painting * @param allocation the allocation given to this view */ public void paint(Graphics g, Shape allocation) { super.paint(g, allocation); // FIXME: Why is this overridden? I think that painting would be done // by the superclass and the stylesheet... Maybe find out when this // stuff is implemented properly. }
/** * Fetches this view's properties from the style attributes of this view's element. * * <p>This forwards to super and then fetches a {@link StyleSheet.ListPainter} from the stylesheet * suitable for painting the list. */ protected void setPropertiesFromAttributes() { super.setPropertiesFromAttributes(); painter = getStyleSheet().getListPainter(getAttributes()); }
/** * Paints the child with the specified index into the specified allocation. * * <p>This implementation forwards to the list painter fetched from the {@link StyleSheet} and * then calls <code>super.paintChild(g, a, index)</code>. * * @param g the graphics context to use * @param a the allocation for the child * @param index the child index */ protected void paintChild(Graphics g, Rectangle a, int index) { painter.paint(g, a.x, a.y, a.width, a.height, this, index); super.paintChild(g, a, index); }
/** * Paints one of the children; called by paint(). By default that is all it does, but a subclass * can use this to paint things relative to the child. * * @param g the graphics context * @param alloc the allocated region to render the child into * @param index the index of the child */ protected void paintChild(Graphics g, Rectangle alloc, int index) { listPainter.paint(g, alloc.x, alloc.y, alloc.width, alloc.height, this, index); super.paintChild(g, alloc, index); }