@Override public void paintComponent(final Graphics g) { Graphics2D g2d = (Graphics2D) g.create(); Dimension srcSize = image.getSizeForPaint(g2d); int wSrc = srcSize.width; int hSrc = srcSize.height; int wImg = getPreferredSize().width; int hImg = getPreferredSize().height; int xOffset = (getSize().width - wImg) / 2; RenderingHints hints = new RenderingHints( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2d.setRenderingHints(hints); FSkin.drawImage( g2d, image, xOffset, 0, wImg + xOffset, hImg, // Destination 0, 0, wSrc, hSrc); // Source 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(); }