Refine search
/** * Glyph bounding boxes. */ @Override protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode, Vector displacement) throws IOException { // draw glyph super.showGlyph(textRenderingMatrix, font, code, unicode, displacement); // bbox in EM -> user units Shape bbox = new Rectangle2D.Float(0, 0, font.getWidth(code) / 1000, 1); AffineTransform at = textRenderingMatrix.createAffineTransform(); bbox = at.createTransformedShape(bbox); // save Graphics2D graphics = getGraphics(); Color color = graphics.getColor(); Stroke stroke = graphics.getStroke(); Shape clip = graphics.getClip(); // draw graphics.setClip(graphics.getDeviceConfiguration().getBounds()); graphics.setColor(Color.RED); graphics.setStroke(new BasicStroke(.5f)); graphics.draw(bbox); // restore graphics.setStroke(stroke); graphics.setColor(color); graphics.setClip(clip); }
/** * Filled path bounding boxes. */ @Override public void fillPath(int windingRule) throws IOException { // bbox in user units Shape bbox = getLinePath().getBounds2D(); // draw path (note that getLinePath() is now reset) super.fillPath(windingRule); // save Graphics2D graphics = getGraphics(); Color color = graphics.getColor(); Stroke stroke = graphics.getStroke(); Shape clip = graphics.getClip(); // draw graphics.setClip(graphics.getDeviceConfiguration().getBounds()); graphics.setColor(Color.GREEN); graphics.setStroke(new BasicStroke(.5f)); graphics.draw(bbox); // restore graphics.setStroke(stroke); graphics.setColor(color); graphics.setClip(clip); }
@Override public void paint(Graphics2D g) { Rectangle2D bounds = getBounds(); // g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); // g.setColor(Color.red); // g.draw(bounds); // if the area to draw a chart on is so small, don't even bother if (bounds.getWidth() < 30) { return; } java.awt.Shape saveClip = g.getClip(); // this is for preventing the series to be drawn outside the plot area if min and max is // overridden to fall inside the data range g.setClip(bounds.createIntersection(bounds)); chart.toolTips.prepare(g); doPaint(g); chart.toolTips.paint(g); g.setClip(saveClip); }
protected void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); AffineTransform aT = g2.getTransform(); Shape oldshape = g2.getClip(); g2.rotate(Math.toRadians(300)); super.paintComponent(g); g2.setTransform(aT); g2.setClip(oldshape); }
@Override public void paintComponent(final Graphics g) { super.paintComponent(g); Graphics2D gImg = (Graphics2D) g; Shape oldClip= gImg.getClip(); Polygon shape = new Polygon( new int[] { 0, 100, 100, 50, 0}, new int[] {200, 200, 100, 50, 100}, 5); gImg.setClip(shape); gImg.setColor(new Color(255, 0, 0, 50)); gImg.fill(shape); gImg.setClip(oldClip); }
public void renderEntities(final Graphics2D g, final Collection<? extends IEntity> entities, final boolean sort, final Shape clip) { // set render shape according to the vision final Shape oldClip = g.getClip(); if (clip != null) { g.setClip(clip); } this.renderEntities(g, entities, sort); g.setClip(oldClip); }
public static void fillComponent(Graphics g, Component c, int x, int y, int w, int h) { Graphics2D g2D = (Graphics2D) g; Shape savedClip = g2D.getClip(); Area clipArea = new Area(new Rectangle2D.Double(x, y, w, h)); if (savedClip != null) { clipArea.intersect(new Area(savedClip)); } g2D.setClip(clipArea); fillComponent(g, c); g2D.setClip(savedClip); } }
@Override public Graphics2D prepare(Component component, Graphics2D graphics) { this.graphics = graphics; int width = component.getWidth(); int height = component.getHeight(); if (bufferedImage == null || bufferedImage.getWidth() != width || bufferedImage.getHeight() != height) { bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); } bufferedImageGraphics = bufferedImage.createGraphics(); bufferedImageGraphics.setClip(graphics.getClip()); return bufferedImageGraphics; }
@Override public Graphics2D prepare(Component component, Graphics2D graphicsArgument) { this.graphics = graphicsArgument; int width = component.getWidth(); int height = component.getHeight(); if (bufferedImage == null || bufferedImage.getWidth() != width || bufferedImage.getHeight() != height) { bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); } bufferedImageGraphics = bufferedImage.createGraphics(); bufferedImageGraphics.setClip(graphicsArgument.getClip()); return bufferedImageGraphics; }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.translate(x, y); Area clip = new Area(new Rectangle(0, 0, this.width, this.height)); if (g2d.getClip() != null) clip.intersect(new Area(g2d.getClip())); g2d.setClip(clip); double coef1 = (double) this.width / (double) getOrigWidth(); double coef2 = (double) this.height / (double) getOrigHeight(); double coef = Math.min(coef1, coef2); g2d.scale(coef, coef); paint(g2d); g2d.dispose(); } }