List of usage examples for java.awt Graphics2D fill
public abstract void fill(Shape s);
From source file:org.squidy.designer.shape.ZoomShape.java
/** * @param paintContext//from w w w. j ava 2s . c o m */ protected void paintShapeZoomedOut(PPaintContext paintContext) { Shape shapeZoomedOut = getZoomedOutShape(); if (shapeZoomedOut != null) { Graphics2D g = paintContext.getGraphics(); Rectangle bounds = shapeZoomedOut.getBounds(); g.setPaint(getZoomedOutFillPaint()); if (isRenderPrimitiveRect()) g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); else g.fill(shapeZoomedOut); g.setStroke(STROKE_ZOOMED_OUT); g.setPaint(getZoomedOutDrawPaint()); if (isRenderPrimitiveRect()) g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height); else g.draw(shapeZoomedOut); } }
From source file:org.squidy.designer.shape.ZoomShape.java
/** * @param paintContext//from w ww .j av a2 s. c o m */ protected void paintShapeZoomedIn(PPaintContext paintContext) { Shape shapeZoomedIn = getZoomedInShape(); if (shapeZoomedIn != null) { Graphics2D g = paintContext.getGraphics(); Rectangle bounds = shapeZoomedIn.getBounds(); g.setPaint(getZoomedInFillPaint()); if (isRenderPrimitiveRect()) g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); else g.fill(shapeZoomedIn); g.setStroke(STROKE_ZOOMED_IN); g.setPaint(getZoomedInDrawPaint()); if (isRenderPrimitiveRect()) g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height); else g.draw(shapeZoomedIn); } }
From source file:org.squidy.designer.zoom.ConnectorShape.java
@Override protected void paintShapeZoomedIn(PPaintContext paintContext) { super.paintShapeZoomedIn(paintContext); if (getInputPort().getVisible() || getOutputPort().getVisible()) { Graphics2D g = paintContext.getGraphics(); PBounds bounds = getBoundsReference(); double x = bounds.getX(); double y = bounds.getY(); double centerY = bounds.getCenterY(); double width = bounds.getWidth(); // Paint a border for zoom ports. // g.setStroke(new BasicStroke(6f)); // g.setColor(Color.RED); // g.draw(getBoundsReference()); // Painting left port. if (getInputPort().getVisible()) { if (shapePortLeft == null) { double portScale = inputPort.getScale(); double portWidth = inputPort.getWidth() * portScale; double portHeight = inputPort.getHeight() * portScale; shapePortLeft = new RoundRectangle2D.Double(x - portWidth + 15, centerY - portHeight / 2 - 5, 35, 60, 10, 10); }/*w w w . j av a2s .c o m*/ Rectangle boundsPort = shapePortLeft.getBounds(); g.setColor(Constants.Color.COLOR_SHAPE_BACKGROUND); if (isRenderPrimitiveRect()) g.fillRect(boundsPort.x, boundsPort.y, boundsPort.width, boundsPort.height); else g.fill(shapePortLeft); g.setColor(Constants.Color.COLOR_SHAPE_BORDER); g.setStroke(StrokeUtils.getBasicStroke(3f)); if (isRenderPrimitiveRect()) g.drawRect(boundsPort.x, boundsPort.y, boundsPort.width, boundsPort.height); else g.draw(shapePortLeft); } // Painting right port. if (getOutputPort().getVisible()) { if (shapePortRight == null) { double portScale = outputPort.getScale(); double portWidth = outputPort.getWidth() * portScale; double portHeight = outputPort.getHeight() * portScale; shapePortRight = new RoundRectangle2D.Double(x + width - portWidth - 21, centerY - portHeight / 2 - 5, 35, 60, 10, 10); } Rectangle boundsPort = shapePortRight.getBounds(); g.setColor(Constants.Color.COLOR_SHAPE_BACKGROUND); if (isRenderPrimitiveRect()) g.fillRect(boundsPort.x, boundsPort.y, boundsPort.width, boundsPort.height); else g.fill(shapePortRight); g.setColor(Constants.Color.COLOR_SHAPE_BORDER); g.setStroke(StrokeUtils.getBasicStroke(3f)); if (isRenderPrimitiveRect()) g.drawRect(boundsPort.x, boundsPort.y, boundsPort.width, boundsPort.height); else g.draw(shapePortRight); } } }
From source file:org.squidy.designer.zoom.impl.DataTypeShape.java
@Override protected void paintShapeZoomedOut(PPaintContext paintContext) { Graphics2D g = paintContext.getGraphics(); if (dataTypes != null && dataTypes.size() > 0) { int i = 0; alreadyPaintedHighLevelDataTypes.clear(); for (Class<? extends IData> type : dataTypes) { if (type.isAssignableFrom(IData.class)) { continue; }/*ww w .j a va 2 s . com*/ Class<? extends IData> highLevelDataType = DataUtility.getHighLevelDataType(type); if (alreadyPaintedHighLevelDataTypes.contains(highLevelDataType)) { continue; } Color color; if (!COLOR_CACHE.containsKey(highLevelDataType)) { DataType dataType = highLevelDataType.getAnnotation(DataType.class); int[] colorScheme = dataType.color(); color = new Color(colorScheme[0], colorScheme[1], colorScheme[2], colorScheme[3]); COLOR_CACHE.put(highLevelDataType, color); } else { color = COLOR_CACHE.get(highLevelDataType); } translationArrow.setToTranslation(i * 750, 0); paintContext.pushTransform(translationArrow); g.setColor(color); g.fill(arrowShape); g.setStroke(STROKE_ARROW_BOLD); g.setColor(Color.BLACK); g.draw(arrowShape); paintContext.popTransform(translationArrow); alreadyPaintedHighLevelDataTypes.add(highLevelDataType); i++; } } else { drawNoDataType(g); } // g.setColor(Color.BLACK); // g.setStroke(StrokeUtils.getBasicStroke(105f)); // g.draw(getGlobalBoundsZoomedIn()); }
From source file:org.zephyrsoft.sdb2.presenter.SongView.java
@Override public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; int topBorderHeight = topMargin; int bottomBorderHeight = bottomMargin; // gradient upper border as overlay Area areaUpper = new Area(new Rectangle2D.Double(0, 0, getWidth(), topBorderHeight)); g2d.setPaint(new GradientPaint(0, 0, new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), 255), 0, topBorderHeight,/* w ww .j a v a 2 s.c o m*/ new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), 0), false)); g2d.fill(areaUpper); // gradient lower border as overlay Area areaLower = new Area( new Rectangle2D.Double(0, getHeight() - bottomBorderHeight, getWidth(), getHeight())); g2d.setPaint(new GradientPaint(0, getHeight() - bottomBorderHeight, new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), 0), 0, getHeight(), new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), 255), false)); g2d.fill(areaLower); }
From source file:pl.edu.icm.visnow.lib.basic.viewers.Viewer2D.Display2DPanel.java
@Override public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; Font f = g2d.getFont();//from w w w. j ava2s. c o m Color c = g2d.getColor(); Rectangle clear = new Rectangle(0, 0, getWidth(), getHeight()); g2d.setPaint(bgColor); g2d.fill(clear); draw2D(g2d); g2d.setFont(titleFont); g2d.setColor(titleColor); g2d.drawString(titleText, 50, 10 + titleFont.getSize()); g2d.setFont(f); g2d.setColor(c); if (storingFrames && !dontWrite) { if (storingJPEG) { writeImage(controlsFrame.getMovieCreationPanel().getCurrentFrameFileName(), FORMAT_JPEG); } else { writeImage(controlsFrame.getMovieCreationPanel().getGenericFrameFileName(), FORMAT_PNG); } } }
From source file:pl.edu.icm.visnow.lib.utils.ImageUtilities.java
public static BufferedImage rotateImage(BufferedImage img, double angle, int type, Color fillBgColor) { if (img == null) { return null; }// ww w .j a v a2 s. c om if (angle > 360.0 || angle < -360) { angle = angle % 360.0; } if (angle < 0) { angle = 360 + angle; } if (angle == 0.0 || angle == 360.0) { return img; } //System.out.println("angle="+angle); int w = img.getWidth(); int h = img.getHeight(); /* AffineTransform tr = new AffineTransform(); tr.rotate(theta,w/2,h/2); BufferedImageOp op = new AffineTransformOp(tr, type); BufferedImage out = op.filter(img,null); */ /* AffineTransform tr = new AffineTransform(); tr.rotate(theta, w/2.0, h/2.0); AffineTransform translationTransform = findTranslation(tr, img); tr.preConcatenate(translationTransform); BufferedImageOp op = new AffineTransformOp(tr, type); BufferedImage out = op.filter(img,null); */ BufferedImage out = null; if (angle == 90.0 || angle == 180.0 || angle == 270.0) { switch ((int) angle) { case 90: out = new BufferedImage(h, w, img.getType()); for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { out.setRGB(h - y - 1, x, img.getRGB(x, y)); } } break; case 180: out = new BufferedImage(w, h, img.getType()); for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { out.setRGB(w - x - 1, h - y - 1, img.getRGB(x, y)); } } break; case 270: out = new BufferedImage(h, w, img.getType()); for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { out.setRGB(y, w - x - 1, img.getRGB(x, y)); } } break; } } else { double theta = angle * Math.PI / 180.0; int neww = w, newh = h; double dx = 0.0, dy = 0.0; double s = Math.sin(theta); double c = Math.cos(theta); if (angle > 0.0 && angle < 90.0) { neww = (int) Math.round(((double) w) * c + ((double) h) * s); newh = (int) Math.round(((double) w) * s + ((double) h) * c); dx = ((double) h) * s; dy = 0.0; } else if (angle > 90.0 && angle < 180.0) { neww = (int) Math.round(-((double) w) * c + ((double) h) * s); newh = (int) Math.round(((double) w) * s - ((double) h) * c); dx = -((double) w) * c + ((double) h) * s; dy = -((double) h) * c; } else if (angle > 180.0 && angle < 270.0) { neww = (int) Math.round(-((double) w) * c - ((double) h) * s); newh = (int) Math.round(-((double) w) * s - ((double) h) * c); dx = -((double) w) * c; dy = -((double) w) * s - ((double) h) * c; } else if (angle > 270.0 && angle < 360.0) { neww = (int) Math.round(((double) w) * c - ((double) h) * s); newh = (int) Math.round(-((double) w) * s + ((double) h) * c); dx = 0.0; dy = -((double) w) * s; } AffineTransform tr = new AffineTransform(); tr.translate(dx, dy); tr.rotate(theta); BufferedImageOp op = new AffineTransformOp(tr, type); out = new BufferedImage(neww, newh, img.getType()); Graphics2D g2d = (Graphics2D) out.getGraphics(); Rectangle clear = new Rectangle(0, 0, out.getWidth(), out.getHeight()); g2d.setPaint(fillBgColor); g2d.fill(clear); op.filter(img, out); } return out; }
From source file:pl.edu.icm.visnow.lib.utils.ImageUtilities.java
public static BufferedImage translateImage(BufferedImage img, double dx, double dy, int type, Color fillBgColor) {//from w ww . j a v a2 s . c o m if (img == null) { return null; } int w = img.getWidth(); int h = img.getHeight(); BufferedImage out = null; AffineTransform tr = new AffineTransform(); tr.translate(dx, dy); BufferedImageOp op = new AffineTransformOp(tr, type); out = new BufferedImage(w, h, img.getType()); Graphics2D g2d = (Graphics2D) out.getGraphics(); Rectangle clear = new Rectangle(0, 0, out.getWidth(), out.getHeight()); g2d.setPaint(fillBgColor); g2d.fill(clear); op.filter(img, out); return out; }
From source file:pt.lsts.neptus.plugins.sunfish.awareness.SituationAwareness.java
@Override public void paint(Graphics2D g, StateRenderer2D renderer) { double radius = isActive() ? 6 : 2.5; for (AssetTrack track : assets.values()) { List<AssetPosition> positions = track.getTrack(); Point2D lastLoc = null;/* w w w. j a v a 2s . c o m*/ long lastAge = 0; for (AssetPosition p : positions) { if (hiddenPosTypes.contains(p.getType())) continue; if (p.getTimestamp() < oldestTimestampSelection || p.getTimestamp() > newestTimestampSelection) continue; //if (p.getAge() >= maxAge * 3600 * 1000) // continue; Point2D pt = renderer.getScreenPosition(p.getLoc()); if (assetProperties.containsKey(track.getAssetName())) g.setColor(assetProperties.get(track.getAssetName()).color); else g.setColor(track.getColor()); if (lastLoc != null && lastLoc.distance(pt) < 20000) { g.draw(new Line2D.Double(lastLoc, pt)); } g.fill(new Ellipse2D.Double(pt.getX() - radius, pt.getY() - radius, radius * 2, radius * 2)); lastLoc = pt; lastAge = p.getAge(); } g.setStroke(new BasicStroke(2.0f)); if (lastLoc != null) { Color c = cmap2.getColor(1 - (lastAge / (7200000.0))); g.setColor(c); g.setStroke(new BasicStroke(2.0f)); g.draw(new Ellipse2D.Double(lastLoc.getX() - radius - 1.5, lastLoc.getY() - radius - 1.5, radius * 2 + 3, radius * 2 + 3)); } } if (paintLabels) paintLabels(g, renderer); if (paintIcons) paintIcons(g, renderer); }
From source file:savant.amino.AminoCanvas.java
private void paintAminoAcid(Graphics2D g2, AminoAcid a, int pos, int bases, int labelPos, boolean labelled) { if (a != null) { g2.setColor(new Color(a.color.getRed(), a.color.getGreen(), a.color.getBlue(), plugin.getAlpha())); double x0 = track.transformXPos(pos); double x1 = track.transformXPos(pos + bases); g2.fill(new Rectangle2D.Double(x0, 0.0, x1 - x0, getHeight())); if (labelled) { g2.setColor(a == AminoAcid.STOP ? Color.WHITE : Color.BLACK); double charWidth = g2.getFontMetrics().charWidth(a.code); g2.drawString(Character.toString(a.code), (float) (track.transformXPos(labelPos) + track.transformXPos(labelPos + 3) - charWidth) * 0.5F,// w ww . j a v a 2 s .c om getHeight() * 0.5F); } } }