private void animateDraw(Point currentP) { Graphics2D g2D = (Graphics2D) getGraphics(); g2D.setXORMode(g2D.getBackground()); currentShape.draw(g2D); currentShape.setCoordinate(currentP); currentShape.draw(g2D); }
public void switchForegroundBackgroundColors() { Color fg = gc.getColor(); Color bg = gc.getBackground(); gc.setColor(bg); gc.setBackground(fg); }
protected boolean isTargetEclipsed(Graphics2D g) { if (getTarget().isParentHidden()) { g.setColor(g.getBackground()); g.setStroke(getEclipsedStroke()); return true; } return false; }
public void drawCellPoint(Graphics2D g, WorkPanelIfc wpIfc, boolean erase) { this.wpIfc = wpIfc; if (erase) { g.setColor(g.getBackground()); } else { g.setColor(this.color); } int cellS = this.wpIfc.getCellSize(); int x = this.x * cellS + 1; int y = this.y * cellS + 1; // cellS--; g.fillRect(x, y, cellS, cellS); }
@Override protected void draw(final Graphics2D g) { final CubicCurve2D.Float graph = update(); final Color color = getColor(); g.setColor(color); final Stroke stroke = getStroke(); g.setStroke(stroke); g.draw(graph); if (isTargetEclipsed()) { g.setColor(g.getBackground()); g.setStroke(EdgeView.getEclipsedStroke()); g.draw(graph); g.setStroke(stroke); g.setColor(color); } }
protected void setHostGraphics(Graphics graphics) { hostGraphics = (Graphics2D) graphics; resolution = (graphics instanceof PrinterGraphics) ? 0 : 1; tagHandler = new GenericTagHandler(hostGraphics); super.setBackground(hostGraphics.getBackground()); super.setColor(hostGraphics.getColor()); super.setPaint(hostGraphics.getPaint()); super.setFont(hostGraphics.getFont()); Stroke s = hostGraphics.getStroke(); if (s instanceof BasicStroke) { lineWidth = ((BasicStroke) s).getLineWidth(); } webColor = WebColor.create(getColor()); setRenderingHint(KEY_SYMBOL_BLIT, VALUE_SYMBOL_BLIT_ON); }
@Override public void draw(Graphics2D pGraphics2D) { Shape shape = getShape(); if (shape == null) { return; } /* Area shadow = new Area(shape); shadow.transform(AffineTransform.getTranslateInstance(SHADOW_GAP, SHADOW_GAP)); shadow.subtract(new Area(shape)); */ Color oldColor = pGraphics2D.getColor(); pGraphics2D.translate(SHADOW_GAP, SHADOW_GAP); pGraphics2D.setColor(SHADOW_COLOR); pGraphics2D.fill(shape); pGraphics2D.translate(-SHADOW_GAP, -SHADOW_GAP); pGraphics2D.setColor(pGraphics2D.getBackground()); pGraphics2D.fill(shape); pGraphics2D.setColor(oldColor); }
/** * The GraphicDrawer.paint() Function allows the user to draw pre-defined graphics into a given * Graphics Object. The user may give the rectangle properties which defines at best the desired * area to draw with a Int id which requests the desired graphic, whenever it's vectorial or * raster graphics * * @author LuisArturo */ public void paint(int id, Dimension r, Graphics g) { Graphics2D g2; switch (id) { case FILE: { g2 = (Graphics2D) g; try { FileInputStream img = new FileInputStream("archivo.png"); BufferedImage in = ImageIO.read(img); g2.drawImage( in, r.width * 2 / 10, r.height * 2 / 10, r.width * 2 / 3, r.height * 2 / 3, null); } catch (Exception e) { e.printStackTrace(); } } break; case REDO: { g2 = (Graphics2D) g; g2.setColor(color); g2.fillArc( r.width * 2 / 10, r.height * 2 / 10, r.width * 6 / 10, r.height * 6 / 10, 270, 225); Polygon p = new Polygon(); p.addPoint(r.width * 2 / 10, r.height * 2 / 10); p.addPoint(r.width * 2 / 10, r.height * 5 / 10); p.addPoint(r.width * 5 / 10, r.height * 5 / 10); g2.fillPolygon(p); g2.setColor(g2.getBackground()); g2.fillArc( r.width * 3 / 10, r.height * 3 / 10, r.width * 4 / 10, r.height * 4 / 10, 270, 225); } break; case TEXT: { g2 = (Graphics2D) g; g2.setColor(color); g2.setFont(new Font("Serif", Font.ITALIC | Font.BOLD, r.height * 6 / 10)); g2.drawChars("A".toCharArray(), 0, 1, r.width * 3 / 10, r.height * 7 / 10); } break; case SELECT: { g2 = (Graphics2D) g; try { FileInputStream img = new FileInputStream("mano.png"); BufferedImage in = ImageIO.read(img); g2.drawImage( in, r.width * 1 / 10, r.height * 1 / 10, r.width * 2 / 3, r.height * 2 / 3, null); } catch (Exception e) { e.printStackTrace(); } } break; case PENCIL: { g2 = (Graphics2D) g; try { FileInputStream img = new FileInputStream("lapiz.png"); BufferedImage in = ImageIO.read(img); g2.drawImage( in, r.width * 2 / 10, r.height * 2 / 10, r.width * 2 / 3, r.height * 2 / 3, null); } catch (Exception e) { e.printStackTrace(); } } break; case ARROW: { g2 = (Graphics2D) g; try { FileInputStream img = new FileInputStream("arrow.png"); BufferedImage in = ImageIO.read(img); g2.drawImage( in, r.width * 2 / 10, r.height * 2 / 10, r.width * 2 / 3, r.height * 2 / 3, null); } catch (Exception e) { e.printStackTrace(); } } break; case ZOOM: { g2 = (Graphics2D) g; try { FileInputStream img = new FileInputStream("zoom.png"); BufferedImage in = ImageIO.read(img); g2.drawImage( in, r.width * 2 / 10, r.height * 2 / 10, r.width * 2 / 3, r.height * 2 / 3, null); } catch (Exception e) { e.printStackTrace(); } } break; } }
public Color getBackground() { return g2d.getBackground(); }