public void draw(Graphics g) { try { drawBackground(g); boolean needOverlayDrawn = true; for (FDisplayObject child : children) { if (child.isVisible()) { if (child.drawAboveOverlay() && needOverlayDrawn) { drawOverlay(g); needOverlayDrawn = false; } final boolean disabled = !child.isEnabled(); if (disabled) { g.setAlphaComposite(DISABLED_COMPOSITE); } g.draw(child); if (disabled) { g.resetAlphaComposite(); } child.drawOnContainer( g); // give child an additional chance to draw additional content on container outside // its bounds } } if (needOverlayDrawn) { drawOverlay(g); } } catch (ConcurrentModificationException ex) { // ignore concurrent modification exceptions during render } catch (Exception ex) { BugReporter.reportException(ex); } }
@Override public void draw(Graphics g) { float x = 0; float y = 0; float w = getWidth(); float h = preferredHeight; boolean needAlpha = (activeStackInstance != stackInstance); if (needAlpha) { // use alpha for non-active items on stack g.setAlphaComposite(ALPHA_COMPOSITE); } g.startClip(0, 0, w, getHeight()); // clip based on actual height g.fillRect(Color.BLACK, x, y, w, h); // draw rectangle for border x += BORDER_THICKNESS; y += BORDER_THICKNESS; w -= 2 * BORDER_THICKNESS; h -= 2 * BORDER_THICKNESS; g.fillRect(backColor, x, y, w, h); x += PADDING; y += PADDING; CardRenderer.drawCardWithOverlays( g, stackInstance.getSourceCard(), x, y, CARD_WIDTH, CARD_HEIGHT, CardStackPosition.Top); x += CARD_WIDTH + PADDING; w -= x + PADDING - BORDER_THICKNESS; h -= y + PADDING - BORDER_THICKNESS; textRenderer.drawText( g, text, FONT, foreColor, x, y, w, h, y, h, true, HAlignment.LEFT, true); g.endClip(); if (needAlpha) { g.resetAlphaComposite(); } }
@Override protected void drawOverlay(Graphics g) { float y = getHeight() - FList.LINE_THICKNESS / 2; g.drawLine(FList.LINE_THICKNESS, FList.LINE_COLOR, 0, y, getWidth(), y); }