List of usage examples for java.awt Graphics2D fillPolygon
public void fillPolygon(Polygon p)
From source file:org.squidy.designer.zoom.ActionShape.java
@Override protected void paintShapeZoomedIn(PPaintContext paintContext) { Graphics2D g = paintContext.getGraphics(); RectangularShape r = (RectangularShape) getZoomedOutShape(); if (r instanceof RoundRectangle2D) { // int width = (int)(r.getMaxX()-r.getMinX()); // int height = (int)(r.getMaxY()-r.getMinY()); // BufferedImage shadeStarted = new BufferedImage(width, height, // BufferedImage.TYPE_INT_RGB); // BufferedImage shadeStopped = new BufferedImage(width, height, // BufferedImage.TYPE_INT_RGB); // BufferedImage shadeFailure = new BufferedImage(width, height, // BufferedImage.TYPE_INT_RGB); // shadeStarted.getGraphics().setColor(COLOR_STARTED); // shadeStopped.getGraphics().setColor(COLOR_STOPPED); // shadeFailure.getGraphics().setColor(COLOR_FAILURE); // shadeStarted.getGraphics().fillRect(0, 0, width, height); // shadeStopped.getGraphics().fillRect(0, 0, width, height); // shadeFailure.getGraphics().fillRect(0, 0, width, height); // g.setStroke(STROKE_ZOOMED_IN); g.setStroke(StrokeUtils.getBasicStroke(7f)); g.setColor(failure ? COLOR_FAILURE : started ? COLOR_STARTED : COLOR_STOPPED); if (polygonRendering) { if (isRenderPrimitiveRect()) { if (!isHierarchicalZoomInProgress()) { Polygon shadeHorizontal = new Polygon(); Polygon shadeVertical = new Polygon(); double shift = 1; shapeZoomedIn.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); Rectangle bounds = shapeZoomedIn.getBounds(); shadeHorizontal.addPoint(bounds.x, bounds.y + bounds.height); shadeHorizontal.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shift = 5;/*from w w w. j a va2 s . c o m*/ shapeZoomedIn.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); bounds = shapeZoomedIn.getBounds(); shadeHorizontal.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeHorizontal.addPoint(bounds.x, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y); g.fillPolygon(shadeHorizontal); g.fillPolygon(shadeVertical); } } else { g.draw(shapeZoomedIn); } } else { for (double shift = 6.; shift >= 1.; shift -= 1.) { shapeZoomedIn.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); if (isRenderPrimitiveRect()) { if (!isHierarchicalZoomInProgress()) { Rectangle bounds = shapeZoomedIn.getBounds(); // g.drawImage(shadeStarted,null,bounds.x, // bounds.y); // g.fillRect(bounds.x, bounds.y, bounds.width, // bounds.height); g.drawLine(bounds.x + 1, bounds.y + bounds.height, bounds.x + bounds.width - 3, bounds.y + bounds.height); g.drawLine(bounds.x + bounds.width, bounds.y + 1, bounds.x + bounds.width, bounds.y + bounds.height - 3); } } else { g.draw(shapeZoomedIn); } } } } super.paintShapeZoomedIn(paintContext); }
From source file:org.squidy.designer.zoom.ActionShape.java
@Override protected void paintShapeZoomedOut(PPaintContext paintContext) { Graphics2D g = paintContext.getGraphics(); RectangularShape r = (RectangularShape) getZoomedOutShape(); if (r instanceof RoundRectangle2D) { // g.setStroke(STROKE_ZOOMED_OUT); g.setColor(failure ? COLOR_FAILURE : started ? COLOR_STARTED : COLOR_STOPPED); g.setStroke(StrokeUtils.getBasicStroke(20f)); if (polygonRendering) { if (isRenderPrimitiveRect()) { if (!isHierarchicalZoomInProgress()) { Polygon shadeHorizontal = new Polygon(); Polygon shadeVertical = new Polygon(); double shift = 1; shapeZoomedOut.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); Rectangle bounds = shapeZoomedOut.getBounds(); shadeHorizontal.addPoint(bounds.x, bounds.y + bounds.height); shadeHorizontal.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shift = 30;//from w w w . j a va2 s .c o m shapeZoomedOut.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); bounds = shapeZoomedOut.getBounds(); shadeHorizontal.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeHorizontal.addPoint(bounds.x, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y); g.fillPolygon(shadeHorizontal); g.fillPolygon(shadeVertical); } } else { g.draw(shapeZoomedOut); } } else { for (double shift = 30.; shift >= 1.; shift -= 5.) { shapeZoomedOut.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); if (isRenderPrimitiveRect()) { if (!isHierarchicalZoomInProgress()) { Rectangle bounds = shapeZoomedOut.getBounds(); // g.fillRect(bounds.x, bounds.y, bounds.width, // bounds.height); g.drawLine(bounds.x + 1, bounds.y + bounds.height, bounds.x + bounds.width - 3, bounds.y + bounds.height); g.drawLine(bounds.x + bounds.width, bounds.y + 1, bounds.x + bounds.width, bounds.y + bounds.height - 3); } } else { g.draw(shapeZoomedOut); } } } } super.paintShapeZoomedOut(paintContext); }
From source file:org.uva.itast.blended.omr.scanners.SolidSquareMarkScanner.java
/** * @param pageImage/* ww w .j ava 2 s . com*/ */ public void putEmphasisMarkOnImage(PageImage pageImage, Color color) { Graphics2D g = pageImage.getReportingGraphics(); // int centerColor=imagen.getRGB(maxsimX, maxsimY); // g.setXORMode(new Color(centerColor)); // g.setColor(Color.RED); // g.fillOval(maxsimX - markWidth/2, maxsimY - markHeight/2, markWidth, // markHeight); // g.setPaintMode(); Dimension2D markDimsPx = pageImage.sizeInPixels(new Size(markWidth, markHeight)); int markWidth = (int) markDimsPx.getWidth(); int markHeight = (int) markDimsPx.getHeight(); g.setColor(color); AffineTransform t = g.getTransform(); g.drawLine(maxsimX, maxsimY - markHeight / 2 - 1, maxsimX, maxsimY - markHeight / 2 - (int) (20 / t.getScaleY())); Polygon arrowHead = new Polygon(); arrowHead.addPoint(maxsimX, (int) (maxsimY - markHeight / 2 - 1 / t.getScaleY())); arrowHead.addPoint((int) (maxsimX - 6 / t.getScaleX()), (int) (maxsimY - markHeight / 2 - 6 / t.getScaleY())); arrowHead.addPoint((int) (maxsimX + 6 / t.getScaleX()), (int) (maxsimY - markHeight / 2 - 6 / t.getScaleY())); g.fillPolygon(arrowHead); g.setStroke(new BasicStroke(2, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1, new float[] { (float) (3 / t.getScaleX()), (float) (3 / t.getScaleY()) }, 0)); g.drawRect(maxsimX - markWidth / 2 - 1, maxsimY - markHeight / 2 - 1, markWidth + 1, markHeight + 1); }