/** Custom JPanel for containing LblMenuItem components. Mostly just handles repainting. */ @SuppressWarnings("serial") public class PnlGroup extends SkinnedPanel { private final SkinColor clrTheme = FSkin.getColor(FSkin.Colors.CLR_THEME); private final SkinColor l00 = clrTheme.stepColor(0); private final SkinColor l10 = clrTheme.stepColor(10); private final SkinColor d20 = clrTheme.stepColor(-20); private final SkinColor d60 = clrTheme.stepColor(-60); private final SkinColor d80 = clrTheme.stepColor(-80); /** Custom JPanel for containing LblMenuItem components. Mostly just handles repainting. */ public PnlGroup() { this.setLayout(new MigLayout("insets 10px 0 10px 0, gap 0, wrap")); this.setBackground(d20); this.setOpaque(false); } @Override public void paintComponent(Graphics g) { final JLabel lbl = CHomeUI.SINGLETON_INSTANCE.getLblSelected(); int yTop = (lbl.getY() + lbl.getParent().getY()); // super.paintComponent(g); final Graphics2D g2d = (Graphics2D) g.create(); final int w = getWidth(); final int h = getHeight(); FSkin.setGraphicsColor(g2d, d20); // Selected in this group, don't draw background under selected label. if (getY() < yTop && yTop < getY() + h) { g2d.fillRect(0, 0, w, lbl.getY()); g2d.fillRect(0, lbl.getY() + lbl.getHeight(), w, h); FSkin.setGraphicsGradientPaint(g2d, w - 8, 0, l00, w, 0, d80); g2d.fillRect(w - 6, 0, w, lbl.getY()); g2d.fillRect(w - 6, lbl.getY() + lbl.getHeight(), w, h); } // Selected not in this group; draw full background. else { g2d.fillRect(0, 0, w, h); FSkin.setGraphicsGradientPaint(g2d, w - 8, 0, l00, w, 0, d80); g2d.fillRect(w - 6, 0, w, h); } FSkin.setGraphicsColor(g2d, l10); g2d.drawLine(0, h - 1, w - 1, h - 1); FSkin.setGraphicsColor(g2d, d60); g2d.drawLine(0, 0, w - 1, 0); g2d.dispose(); } }
@Override public void paintComponent(final Graphics g) { Graphics2D g2d = (Graphics2D) g.create(); int width = getWidth() - 100; int height = getHeight() - 40; if (size.equals(BoxSize.MEDIUM)) { height -= 196; g2d.translate(0, 98); } else if (size.equals(BoxSize.LARGE)) { height -= 588; g2d.translate(0, 294); } else if (size.equals(BoxSize.LARGE_SINGLE)) { height -= 665; g2d.translate(0, 333); } g2d.setColor(clr1.getColor()); g2d.setStroke(new BasicStroke(4)); if (lineSide.equals(LineSide.LEFT) || lineSide.equals(LineSide.BOTH)) { g2d.drawLine(0, height / 2 + 20, 47, height / 2 + 20); } g2d.translate(50, 20); if (lineSide.equals(LineSide.RIGHT) || lineSide.equals(LineSide.BOTH)) { g2d.drawLine(width, height / 2, width + 65, height / 2); if (lineDir.equals(LineDirection.DOWN)) { g2d.drawLine(width + 48, height / 2, width + 48, height + 400); } else if (lineDir.equals(LineDirection.UP)) { g2d.drawLine(width + 48, height / 2, width + 48, -400); } else if (lineDir.equals(LineDirection.STRAIGHT)) { g2d.drawLine(width, height / 2, width + 45, height / 2); } } FSkin.setGraphicsGradientPaint(g2d, 0, 0, clr3, 0, height / 2 + 15, clr2); g2d.fillRect(0, 0, width, height / 2); FSkin.setGraphicsGradientPaint(g2d, 0, height / 2 - 15, clr2, 0, height, clr3); g2d.fillRect(0, height / 2, width, height / 2); g2d.setColor(clr1.getColor()); g2d.setStroke(new BasicStroke(4)); g2d.drawRect(1, 1, width - 2, height - 2); if (!singleBox) { FSkin.setGraphicsGradientPaint( g2d, 70, height / 2 - 1, clr1.alphaColor(0), width, height / 2 - 1, clr1); g2d.setStroke(new BasicStroke(2)); g2d.drawRect(70, height / 2 - 1, width - 70, 2); } g2d.setColor(FSkin.getColor(Colors.CLR_TEXT).getColor()); g2d.setStroke(new BasicStroke(1)); if (!singleBox) { Rectangle2D textSize = g2d.getFontMetrics().getStringBounds("VS", g2d); g2d.drawString( "VS", (width + (int) textSize.getWidth()) / 2, (height + (int) textSize.getHeight()) / 2 - 2); } // Padding here g2d.translate(12, 12); g2d.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); Dimension srcSize = img1.getSizeForPaint(g2d); int wSrc = srcSize.width; int hSrc = srcSize.height; FSkin.drawImage( g2d, img1, 0, 0, wImg, hImg, // Destination 0, 0, wSrc, hSrc); // Source g2d.translate(0, 77); if (!singleBox) { FSkin.drawImage( g2d, img2, 0, 0, wImg, hImg, // Destination 0, 0, wSrc, hSrc); // Source } g2d.dispose(); }