@NotNull @Override public BufferedImage applyFilter(@NotNull BufferedImage bufferedImage) { Graphics2D graphics2D = bufferedImage.createGraphics(); if (rectangleType.equals(RectangleType.CORNERED)) drawCornerRectangle(graphics2D, color.getBackground(), borderWeight, rectangle); else drawRectangle(graphics2D, rectangle, color.getBackground(), borderWeight, false); graphics2D.dispose(); return bufferedImage; }
@NotNull @Override public BufferedImage applyFilter(@NotNull BufferedImage bufferedImage) { Graphics2D graphics2D = bufferedImage.createGraphics(); rectangle.stream().filter(point -> point != null).forEach(point -> drawRectangle(graphics2D, new Rectangle(point.x, point.y, borderWeight.thickness(), borderWeight.thickness()), color.getBackground(), borderWeight)); graphics2D.dispose(); return bufferedImage; }
@NotNull @Override public BufferedImage applyFilter(@NotNull BufferedImage bufferedImage) { Graphics2D graphics2D = bufferedImage.createGraphics(); graphics2D.setColor(color.getBackground()); graphics2D.setStroke(new BasicStroke(lineThickness.thickness())); Point leftRectangleBottom = new Point(rectangle1.x + rectangle1.width, rectangle1.y + rectangle1.height); Point leftRectangleTop = new Point(rectangle1.x + rectangle1.width, rectangle1.y); Point rightRectangleTop = new Point(rectangle2.x + xOffset, rectangle2.y + insets.top); Point rightRectangleBottom = new Point(rectangle2.x + xOffset, rectangle2.y + insets.top + rectangle2.height); PointDistance pointDistance = calculatePoints(leftRectangleTop, leftRectangleBottom, rightRectangleTop, rightRectangleBottom); graphics2D.drawLine(pointDistance.getLeftPoint().x, pointDistance.getLeftPoint().y, pointDistance.getRightPoint().x, pointDistance.getRightPoint().y); graphics2D.dispose(); return bufferedImage; }
@NotNull @Override public BufferedImage applyFilter(@NotNull BufferedImage bufferedImage) { Graphics2D graphics2D = bufferedImage.createGraphics(); imageGrownBy = calculateGrowth(); GrowImageFilter growImageFilter = new GrowImageFilter(imageGrownBy); BufferedImage grownImage = growImageFilter.applyFilter(bufferedImage); int height = calculateHeight(); ImageCaptionFilter imageCaptionFilter = new ImageCaptionFilter(location, OverlayUtils.calculateMaxFontForString(graphics2D, font, grownImage.getWidth() - magicPadding, height, text), color.getBackground(), text, 10); graphics2D.dispose(); return imageCaptionFilter.applyFilter(grownImage); }
private void applyText(Graphics2D graphics2D) { graphics2D.setFont(requestedFont); graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); int availableWidthForTextContainer = boundedTextContainerWidth(graphics2D); setupFontWidth(graphics2D, availableWidthForTextContainer); int availableHeightForTextContainer = boundedTextContainerHeight(graphics2D); setupFontHeight(graphics2D, availableWidthForTextContainer, availableHeightForTextContainer); int startingX = calculateTextContainerStartingPointX(availableWidthForTextContainer); int startingY = calculateTextContainerStartingPointY(baseRectangle, availableHeightForTextContainer, rectangleTextPosition); Rectangle textContainer = new Rectangle(startingX, startingY, availableWidthForTextContainer, availableHeightForTextContainer); drawOutliningRectangle(graphics2D, textContainer, cognitiveJColourPalette.getBackground()); applyTextOver(graphics2D, textContainer); }