@Override public Bounds getBounds(Component component) { return new Bounds(x, y, width, height); }
public boolean contains(Bounds bounds) { if (bounds == null) { throw new IllegalArgumentException("bounds is null"); } return contains(bounds.x, bounds.y, bounds.width, bounds.height); }
/** * Returns the component's bounding area including decorators. * * @return * The decorated bounding area. The <tt>x</tt> and <tt>y</tt> values are * relative to the parent container. */ public Bounds getDecoratedBounds() { Bounds decoratedBounds = new Bounds(0, 0, getWidth(), getHeight()); for (Decorator decorator : decorators) { decoratedBounds = decoratedBounds.union(decorator.getBounds(this)); } return new Bounds(decoratedBounds.x + x, decoratedBounds.y + y, decoratedBounds.width, decoratedBounds.height); }
Bounds paintBounds = new Bounds(0, 0, getWidth(), getHeight()); Rectangle clipBounds = graphics.getClipBounds(); if (clipBounds != null) { paintBounds = paintBounds.intersect(clipBounds); && component.getBounds().contains(paintBounds)) { paintContainer = false; break; && decoratedBounds.intersects(paintBounds)) { Bounds componentBounds = component.getBounds();
@Override public Bounds getCharacterBounds(int offset) { Bounds characterBounds = null; for (int i = 0, n = nodeViews.getLength(); i < n; i++) { TextPaneSkinNodeView nodeView = nodeViews.get(i); int nodeViewOffset = nodeView.getOffset(); int characterCount = nodeView.getCharacterCount(); if (offset >= nodeViewOffset && offset < nodeViewOffset + characterCount) { characterBounds = nodeView.getCharacterBounds(offset - nodeViewOffset); if (characterBounds != null) { characterBounds = characterBounds.translate(nodeView.getX(), nodeView.getY()); } break; } } if (characterBounds != null) { characterBounds = characterBounds.intersect(0, 0, getWidth(), getHeight()); } return characterBounds; }
@Override public Graphics2D prepare(Component component, Graphics2D graphics) { int width = component.getWidth(); int height = component.getHeight(); if (width > 0 && height > 0) { if (shadowImage == null || shadowImage.getWidth() != width + 2 * blurRadius || shadowImage.getHeight() != height + 2 * blurRadius) { // Recreate the shadow BufferedImage rectangleImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D rectangleImageGraphics = rectangleImage.createGraphics(); rectangleImageGraphics.setColor(Color.BLACK); rectangleImageGraphics.fillRect(0, 0, width, height); rectangleImageGraphics.dispose(); shadowImage = createShadow(rectangleImage); } // Avoid drawing shadow if it will be covered by the component itself: Bounds paintBounds = new Bounds(0, 0, width, height); if (!component.isOpaque() || !paintBounds.contains(new Bounds(graphics.getClipBounds()))) graphics.drawImage(shadowImage, xOffset - blurRadius, yOffset - blurRadius, null); } else { shadowImage = null; } return graphics; }
public boolean intersects(Bounds bounds) { if (bounds == null) { throw new IllegalArgumentException("bounds is null"); } return intersects(bounds.x, bounds.y, bounds.width, bounds.height); }
public boolean contains(int x, int y, int width, int height) { return (!isEmpty() && x >= this.x && y >= this.y && x + width <= this.x + this.width && y + height <= this.y + this.height); }
public Bounds translate(Point offset) { return translate(offset.x, offset.y); }
public Bounds intersect(Bounds bounds) { return intersect(bounds.x, bounds.y, bounds.width, bounds.height); }
caret = leadingSelectionBounds.toRectangle(); caret.width = 1;
public Bounds union(Bounds bounds) { return union(bounds.x, bounds.y, bounds.width, bounds.height); }
Bounds paintBounds = new Bounds(0, 0, getWidth(), getHeight()); Rectangle clipBounds = graphics.getClipBounds(); if (clipBounds != null) { paintBounds = paintBounds.intersect(clipBounds); && component.getBounds().contains(paintBounds)) { paintContainer = false; break; && decoratedBounds.intersects(paintBounds)) { Bounds componentBounds = component.getBounds();
@Override public Bounds getCharacterBounds(int offset) { Bounds characterBounds = null; for (int i = 0, n = nodeViews.getLength(); i < n; i++) { TextPaneSkinNodeView nodeView = nodeViews.get(i); int nodeViewOffset = nodeView.getOffset(); int characterCount = nodeView.getCharacterCount(); if (offset >= nodeViewOffset && offset < nodeViewOffset + characterCount) { characterBounds = nodeView.getCharacterBounds(offset - nodeViewOffset); if (characterBounds != null) { characterBounds = characterBounds.translate(nodeView.getX(), nodeView.getY()); } break; } } if (characterBounds != null) { characterBounds = characterBounds.intersect(0, 0, getWidth(), getHeight()); } return characterBounds; }
/** * Returns the component's bounding area including decorators. * * @return * The decorated bounding area. The <tt>x</tt> and <tt>y</tt> values are * relative to the parent container. */ public Bounds getDecoratedBounds() { Bounds decoratedBounds = new Bounds(0, 0, getWidth(), getHeight()); for (Decorator decorator : decorators) { decoratedBounds = decoratedBounds.union(decorator.getBounds(this)); } return new Bounds(decoratedBounds.x + x, decoratedBounds.y + y, decoratedBounds.width, decoratedBounds.height); }
@Override public Graphics2D prepare(Component component, Graphics2D graphics) { int width = component.getWidth(); int height = component.getHeight(); if (width > 0 && height > 0) { if (shadowImage == null || shadowImage.getWidth() != width + 2 * blurRadius || shadowImage.getHeight() != height + 2 * blurRadius) { // Recreate the shadow BufferedImage rectangleImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D rectangleImageGraphics = rectangleImage.createGraphics(); rectangleImageGraphics.setColor(Color.BLACK); rectangleImageGraphics.fillRect(0, 0, width, height); rectangleImageGraphics.dispose(); shadowImage = createShadow(rectangleImage); } // Avoid drawing shadow if it will be covered by the component itself: Bounds paintBounds = new Bounds(0, 0, width, height); if (!component.isOpaque() || !paintBounds.contains(new Bounds(graphics.getClipBounds()))) { graphics.drawImage(shadowImage, xOffset - blurRadius, yOffset - blurRadius, null); } } else { shadowImage = null; } return graphics; }
public boolean intersects(Bounds bounds) { if (bounds == null) { throw new IllegalArgumentException("bounds is null"); } return intersects(bounds.x, bounds.y, bounds.width, bounds.height); }
public boolean contains(int xArgument, int yArgument, int widthArgument, int heightArgument) { return (!isEmpty() && xArgument >= this.x && yArgument >= this.y && xArgument + widthArgument <= this.x + this.width && yArgument + heightArgument <= this.y + this.height); }
public Bounds translate(Point offset) { return translate(offset.x, offset.y); }