public void paintComponent(Graphics g) { super.paintComponent(g); if (scene == OVERWORLD) g.drawImage(background, 0, 0, this); if (scene == BATTLE) { if (battleBG == 1) g.drawImage(background, 0, -130, this); else g.drawImage(background, 0, 0, this); } int loop; for (loop = 0; loop < enemies.size(); loop++) { if (scene == OVERWORLD) { enemies.get(loop).drawEnemy(g); } if (scene == BATTLE) { if (enemies.get(loop).getActivity()) { enemies.get(loop).drawEnemy(g); } } } for (loop = 0; loop < spellsThrown.size(); loop++) { spellsThrown.get(loop).drawSpell(g); } player.drawPlayer(g); for (loop = 0; loop < enemies.size(); loop++) { enemies.get(loop).drawSpells(g); } if (scene == BATTLE) { drawMenu(g); if (battleWon) drawVictory(g); else if (battleLost) drawDefeat(g); } }
@Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(color); g.drawLine(0, 0, getWidth(), getHeight()); g.drawLine(getWidth(), 0, 0, getHeight()); }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); int width = this.getBounds().width; int height = this.getBounds().height; Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(3.0f)); g2.drawOval(width / 3, height / 5, width / 3, height / 2); int x1 = width / 2; int y1 = height * 3 / 10; int x2 = x1 + (int) (height / 5 * Math.sin(anguloVela)); int y2 = y1 + (int) (height / 5 * Math.cos(anguloVela)); if (focusVela) { g2.setColor(Color.RED); g2.drawLine(x1, y1, x2, y2); g2.setColor(Color.BLACK); } else { g2.drawLine(x1, y1, x2, y2); } y1 = height * 7 / 10; x2 = x1 + (int) (height / 10 * Math.sin(anguloTimon)); y2 = y1 + (int) (height / 10 * Math.cos(anguloTimon)); if (focusTimon) { g2.setColor(Color.RED); g2.drawLine(x1, y1, x2, y2); g2.setColor(Color.BLACK); } else { g2.drawLine(x1, y1, x2, y2); } }
public void paintComponent(Graphics g) { super.paintComponent(g); setBackground(new Color(219, 219, 72)); Graphics2D g2d = (Graphics2D) g; RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHints(rh); Font fnt = new Font("STENCIL", Font.BOLD, 100); g2d.setColor(new Color(62, 11, 214)); g2d.setFont(fnt); g2d.drawString("Hangman", 240, 100); fnt = new Font("STENCIL", Font.ITALIC, 30); g2d.setFont(fnt); g2d.setColor(new Color(11, 214, 201)); g2d.drawString("created by Ashwin Gupta", 240, 125); /*g2d.setFont(new Font("Arial", Font.PLAIN, 75)); g2d.drawString("PAINT BIG ", 100, 400); g2d.drawString("HANGMAN HERE", 100, 500);*/ // int offset= 20; HangComponents dh = new HangComponents(); g2d.setColor(Color.DARK_GRAY); for (int i = 0; i < 8; i++) { if (i == 7 || i == 6) { g2d.setStroke(new BasicStroke(45)); g2d.draw(dh.hangman[i]); } else g2d.fill(dh.hangman[i]); } }
// färger, se sid 43 i boken // grafiska metoder, sid 248 i boken public void paintComponent(Graphics g) { // för att vara säker på att // "super"-klassen gör sitt // anropar vi den metoden, innan // vi skriver eller ritar super.paintComponent(g); g.drawLine(185, 10, 195, 40); // x1,y1 till x2,y2 g.drawLine(200, 10, 200, 40); g.drawLine(215, 10, 205, 40); g.setColor(Color.white); g.fillOval(50, 30, 300, 150); // x,y,b,h (x,y för ö v h) g.setColor(Color.red); g.drawArc(100, 100, 200, 50, 180, 180); // x,y,b,h,s,l g.setColor(Color.yellow); g.fillRect(200, 100, 30, 30); g.fill3DRect(150, 50, 30, 50, true); // true upphöjd figur g.fill3DRect(250, 50, 30, 50, true); // skriv ut en textsträng, samt ange läget i avståndet från // övre vänstra hörnet i x-led åt höger och i y-led neråt g.drawString("** Tjenare kompis !! **", 20, 20); f = new Font("Arial", Font.BOLD, 30); setBackground(Color.cyan); g.setFont(f); g.setColor(new Color(255, 175, 175)); g.drawString("YEEEEEEEES!!", 100, 250); }
@Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D copy = (Graphics2D) g.create(); if (dragging) { copy.drawImage(imageBuffer, 0, 0, null); if (objectDragging == SelectedForm.LINE) { Line l = (Line) objectDragged; copy.setColor(l.getColor()); copy.drawLine(l.getP1().x, l.getP1().y, l.getP2().x, l.getP2().y); } else if (objectDragging == SelectedForm.SQUARE) { Square sq = (Square) objectDragged; copy.setColor(sq.getColor()); copy.drawRect( sq.adjustRendering().x, sq.adjustRendering().y, sq.getWidth(), sq.getHeight()); } else if (objectDragging == SelectedForm.CIRCLE) { Circle c = (Circle) objectDragged; copy.setColor(c.getColor()); copy.drawOval(c.adjustRendering().x, c.adjustRendering().y, c.getWidth(), c.getHeight()); } else if (objectDragging == SelectedForm.POLYLINE) { Polyline poly = (Polyline) objectDragged; copy.setColor(poly.getColor()); poly.fill(); int[] XIS = poly.getX(); int[] YSP = poly.getY(); copy.drawPolyline(XIS, YSP, poly.getN()); copy.drawLine( XIS[poly.getN() - 1], YSP[poly.getN() - 1], poly.getActualX(), poly.getActualY()); } } else { copy.drawImage(imageBuffer, 0, 0, null); } copy.dispose(); }
public void paintComponent(Graphics g) { super.paintComponent(g); if (uneHashtable.get(unEtat) != null) { g.setColor((Color) uneHashtable.get(unEtat)); g.fillRect(100, 20, 40, 40); } }
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; // draw a rectangle double leftX = 100; double topY = 100; double width = 200; double height = 150; Rectangle2D rect = new Rectangle2D.Double(leftX, topY, width, height); g2.draw(rect); // draw a enclosed ellipse Ellipse2D ellipse = new Ellipse2D.Double(); ellipse.setFrame(rect); g2.draw(ellipse); // draw a diagonal line g2.draw(new Line2D.Double(leftX, topY, leftX + width, topY + height)); // draw a circle with the same center double centerX = rect.getCenterX(); double centerY = rect.getCenterY(); double radius = 150; Ellipse2D circle = new Ellipse2D.Double(); circle.setFrameFromCenter(centerX, centerY, centerX + radius, centerY + radius); g2.draw(circle); }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.BLACK); // TODO draw an inverted triangle instead of a rectangle g.drawRect(playbackPixelPosition(), 0, 1, getHeight()); }
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(wl)); g2.setColor(color); switch (type) { case 1: { g2.draw(new Rectangle2D.Float(wl, wl, getWidth() - 2 * wl, getHeight() - 2 * wl)); break; } case 2: { g2.draw(new Ellipse2D.Float(wl, wl, getWidth() - 2 * wl, getHeight() - 2 * wl)); break; } case 3: { g2.draw( new RoundRectangle2D.Float( wl, wl, getWidth() - 2 * wl, getHeight() - 2 * wl, 10, 10)); break; } case 4: { g2.draw(new Line2D.Float(wl, wl, getWidth(), getHeight())); break; } } }
public void paintComponent(Graphics A00) { super.paintComponent(A00); Graphics2D L00 = (Graphics2D) A00; L00.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); L00.setColor(I00); L00.fillOval(C02 + C03, C02 + C03, C04, C04); int L01 = 90; // 円グラフの描画開始角度 int L02 = 0; // 扇形の中心角 setRates(); for (Color L03 : I01.keySet()) { L02 = Math.round(360f * I01.get(L03) / I02); L01 -= L02; L00.setColor(L03); L00.fillArc(C02, C02, C04, C04, L01, L02); } // 四捨五入の都合で塗り残しが出た場合の対処 L00.fillArc(C02, C02, C04, C04, -270, L02); L00.setColor(I00); L00.drawOval(C02, C02, C04, C04); }
/** * Paint this component. * * @param g the Graphics object to use to render this component */ public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; super.paintComponent(g2); if (grid == null) return; Insets insets = getInsets(); g2.setColor(backgroundColor); g2.fillRect( insets.left, insets.top, numCols * (cellSize + 1) + 1, numRows * (cellSize + 1) + 1); BufferedImage img = null; try { img = ImageIO.read(new File("Thor_GIFs\\ice.png")); } catch (IOException e) { } g2.drawImage( img, insets.left, insets.top, numCols * (cellSize + 1) + 1, numRows * (cellSize + 1) + 1, 0, 0, img.getWidth(), img.getHeight(), null); drawWatermark(g2); // drawGridlines(g2); drawOccupants(g2); drawCurrentLocation(g2); }
public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.GREEN); drawOneGraph(g, a); g.setColor(Color.BLUE); drawOneGraph(g, b); }
@Override protected void paintComponent(Graphics g1) { super.paintComponent(g1); Graphics2D g = (Graphics2D) g1; g.setRenderingHints(renderingHints); moveCamera(); paintWorldImage(g); paintCornice(g); if (minimap) { paintMiniWorld(g); } // paintCheckPoint(g); //debug // paintStart(g); //debug // paintWorld(g); //debug // paintDebugCar(g); // debug paintPanelGame(g); paintCar(g); paintCountDown(g); }
public void paintComponent(Graphics g) { super.paintComponent(g); this.setBackground(Color.black); // Nested for loop to draw all rows and columns for (int x = 0; x < num.tileRow; x++) { for (int y = 0; y < num.tileCol; y++) { if (land.xTile[x][y].isDiscovered) { g.setColor(land.xTile[x][y].locColor); } else { g.setColor(Color.black); } g.fillRect( (land.xTile[x][y].xPos + num.xOff) * num.zoom, (land.xTile[x][y].yPos + num.yOff) * num.zoom, num.tileSq * num.zoom, num.tileSq * num.zoom); } } // Code to draw and animate player g.setColor(Color.red); g.fillRect( num.tileSq * num.zoom * num.tileSq, num.tileSq * num.zoom * num.tileSq, num.tileSq * num.zoom, num.tileSq * num.zoom); g.setColor(Color.white); g.fillRect(num.tileCol * 5 - 50, 0, 150, num.tileRow * 5 + 15); g.setColor(Color.black); g.fillRect(num.tileCol * 5 - 50, 0, 10, num.tileRow * 5 + 15); }
/** * Draws everything onto the main panel. * * @param page Graphics component to draw on */ public void paintComponent(Graphics page) { super.paintComponent(page); setForeground(Color.cyan); renderer.draw(page, this, offX, offY); // hero.draw(this, page, offX, offY); for (Entity effect : effects) { effect.draw(this, page, offX, offY); /*if (effect instanceof Burst) { Burst pop = (Burst) effect; pop.draw(this, page, offX, offY); }*/ } // Draw hero position information Rectangle r = hero.getBounds(); page.drawString("Position: x = " + (r.x + (r.width >> 1)), SCORE_PLACE_X, SCORE_PLACE_Y); final int tab = 100; final int lineHeight = 20; page.drawString("y = " + (r.y + (r.height >> 1)), SCORE_PLACE_X + tab, SCORE_PLACE_Y); page.drawString("Frame: " + frame, SCORE_PLACE_X, SCORE_PLACE_Y + lineHeight); if (!running) { page.drawString("Game over :(", WIDTH / 2, HEIGHT / 2); } }
@Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2D = (Graphics2D) g.create(); // Draw each space for (int i = 0, degrees = 0; i < imageNames.size() / 2; ++i) { g2D.setColor( WHEEL_COLORS.get(imageNames.get(i).substring(0, imageNames.get(i).indexOf('.')))); g2D.fillArc(150, 45, 480, 480, degrees, DEGREES_EACH); degrees += DEGREES_EACH; } // Set the origin and rotate before drawing the images g2D.translate(390, 285); g2D.rotate(Math.toRadians(-100)); // Draw wheel spaces for (int i = 0; i < imageNames.size() / 2; ++i) { g2D.drawImage(IMAGES.get(imageNames.get(i)), -42, 0, this); g2D.rotate(Math.toRadians(-DEGREES_EACH)); } // Reset origin g2D.translate(-390, -285); // Draw the arrow to indicate where the wheel stopped g.drawImage(IMAGES.get("arrow.png"), 370, 10, this); }
protected void paintComponent(Graphics g2) { super.paintComponent(g2); Graphics2D g = (Graphics2D) g2; test.draw(g2, 0, 0); // Shape triangle = new Polygon(new int[] {15, 20, 10}, new int[] {0, 10, 10}, 3); Shape square = new Rectangle2D.Double(0, 0, 30, 30); g.setColor(Color.white); g.translate(20, 20); // g.rotate(theta, 10, 10); // g.fill(star); // g.setColor(new Color(0, 86, 141)); // g.fill(square); if (star2 != null) g.fill(star2); // Graphics2D g3 = (Graphics2D) g; // 3.fill(star); // g.setStroke(new BasicStroke(1)); // g.translate(x, y); // g.draw(line); // g.draw(line2); }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D graphics = (Graphics2D) g; graphics.setPaint(Color.GREEN); Ellipse2D.Double circle = new Ellipse2D.Double(ball.getX(), ball.getY(), ball.getDiameter(), ball.getDiameter()); // graphics.fillOval(ball.getX(), ball.getY(), ball.getDiameter(), ball.getDiameter()); graphics.fill(circle); if (frame.getWidth() != frameWidth || frame.getHeight() != frameHeight) { repaint(); updateSizes(frame.getWidth(), frame.getHeight()); } try { Thread.sleep(7); } catch (InterruptedException e) { } if (begin && !grabBall) { moveBall(); } else if (grabBall) { followMouse(); } }
public void paintComponent(Graphics g) { super.paintComponent(g); if (image != null) { // System.out.println("ImagePanel paintComponent " + ++paintCount); g.drawImage(image, 0, 0, this); } }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setColor(Color.GREEN); if (player != null) { g2d.fillOval(player.getX(), player.getY(), 5, 5); } /* if(trees != null) { for(Circle tree: trees) { g2d.fillOval((int) tree.x, (int) tree.y,(int) tree.RADIUS,(int) tree.RADIUS); } } if(bigHerbivores != null) { for(BigHerbivore c: bigHerbivores) { int rad = Math.round(c.RADIUS/2); g2d.setColor(Color.RED); g2d.fillOval((int) c.x - rad,(int) c.y - rad,(int) c.RADIUS,(int) c.RADIUS); g2d.drawLine((int) c.x,(int) c.y,(int) c.destX,(int) c.destY); } } */ }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); if (floorPlan != null) { // colocando a posicao inicial na tela e pegando uma instancia do transformador AffineTransform at = AffineTransform.getTranslateInstance(transfPosX, transfPosY); // double escala = INDICE_ESCALA / 100.0; // double sx = ((double) floorPlan.getWidth()) * escala ; // double sy = ((double) floorPlan.getHeight()) * escala; at.scale(escala, escala); System.out.println("Meu teste: " + floorPlan.getWidth() + " " + floorPlan.getHeight()); g2d.drawRenderedImage(floorPlan, at); } if (pathNormalizer != null) { g2d.setColor(Color.red); g2d.draw(pathNormalizer); } if (path != null) { g2d.setColor(Color.black); g2d.draw(path); } }
@Override public void paintComponent(java.awt.Graphics context) { super.paintComponent(context); final Canvas canvas = new Canvas(context); GameView.getInstance().paintAll(canvas); }
protected void paintComponent(Graphics g) { super.paintComponent(g); g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); double energy, distance, scaledVal; int horizSize = 100; int index = 0; float v; int boxsize = 5; for (int y = 0; y < horizSize; y++) { for (int x = 0; x < horizSize; x++) { energy = (double) x / (double) horizSize; // x axis is my // energy distance = (double) y / (double) horizSize; // y axis is the // distance scaledVal = (10.0 + FQ_learner.nearestValue(energy, distance, action)) / 20.0; v = (float) scaledVal; if (v < 0) v = 0; // System.out.println(v); g2.setPaint(new Color(v, v, v, 1)); g2.fill(new Rectangle2D.Double(x * boxsize, y * boxsize, boxsize, boxsize)); index++; } } // System.out.println("painted"); }
// paintComponent is what Swing calls to update the displayed graphics. @Override public void paintComponent(Graphics g) { super.paintComponent(g); renderMapPrivate(g); repaint(); }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); if (image != null) { g.drawImage(image, 0, 0, this); } }
/* * Draws gnomon with base at bottom. Again, coordinate system is translated to commonly used coordinate system. */ public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D img = (Graphics2D) g; img.translate(0, this.getHeight()); img.drawString("Gnomon angle", 20, -5); img.scale(1.0, -1.0); double x, y; // baseLine is the bottom, hLine is the height of the gnomon, angleLine is the style (diagonal // portion) Line2D baseLine, hLine, angleLine; if (gnomonAngle < Math.atan( this.getHeight() / (this.getWidth() / 2))) { // style will extend to center of image y = Math.tan(gnomonAngle) * (this.getWidth() / 2); baseLine = new Line2D.Double(0, 0, this.getWidth() / 2, 0); hLine = new Line2D.Double(this.getWidth() / 2, 0, this.getWidth() / 2, y); angleLine = new Line2D.Double(0, 0, this.getWidth() / 2, y); } else { // style needs to be closer to maintain the angle x = this.getHeight() / Math.tan(gnomonAngle); baseLine = new Line2D.Double(0, 0, x, 0); hLine = new Line2D.Double(x, 0, x, this.getHeight()); angleLine = new Line2D.Double(0, 0, x, this.getHeight()); } img.draw(baseLine); img.draw(hLine); img.draw(angleLine); }
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2D = (Graphics2D) g; for (GEShape shape : shapeList) { shape.draw(g2D); } }
protected void paintComponent(Graphics g) { super.paintComponent(g); int y = 0; g.setColor(new Color(156, 154, 140)); g.drawLine(0, y, getWidth(), y); y++; g.setColor(new Color(196, 194, 183)); g.drawLine(0, y, getWidth(), y); y++; g.setColor(new Color(218, 215, 201)); g.drawLine(0, y, getWidth(), y); y++; g.setColor(new Color(233, 231, 217)); g.drawLine(0, y, getWidth(), y); y = getHeight() - 3; g.setColor(new Color(233, 232, 218)); g.drawLine(0, y, getWidth(), y); y++; g.setColor(new Color(233, 231, 216)); g.drawLine(0, y, getWidth(), y); y = getHeight() - 1; g.setColor(new Color(221, 221, 220)); g.drawLine(0, y, getWidth(), y); }
// draw rectangles and arcs public void paintComponent(Graphics g) { super.paintComponent(g); // call superclass's paintComponent // start at 0 and sweep 360 degrees g.setColor(Color.RED); g.drawRect(15, 35, 80, 80); g.setColor(Color.BLACK); g.drawArc(15, 35, 80, 80, 0, 360); // start at 0 and sweep 110 degrees g.setColor(Color.RED); g.drawRect(100, 35, 80, 80); g.setColor(Color.BLACK); g.drawArc(100, 35, 80, 80, 0, 110); // start at 0 and sweep -270 degrees g.setColor(Color.RED); g.drawRect(185, 35, 80, 80); g.setColor(Color.BLACK); g.drawArc(185, 35, 80, 80, 0, -270); // start at 0 and sweep 360 degrees g.fillArc(15, 120, 80, 40, 0, 360); // start at 270 and sweep -90 degrees g.fillArc(100, 120, 80, 40, 270, -90); // start at 0 and sweep -270 degrees g.fillArc(185, 120, 80, 40, 0, -270); } // end method paintComponent