/** * 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; }
protected void setPropertiesFromAttributes() { super.setPropertiesFromAttributes(); listPainter = getStyleSheet().getListPainter(getAttributes()); }
/** * 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); }