/** * Draw the vectors at the data points. If this data has been attached to an Axis then scale the * data based on the axis maximum/minimum otherwise scale using the data's maximum/minimum * * @param g Graphics state * @param bounds The data window to draw into */ public void draw_data(Graphics g, Rectangle bounds) { Color c; if (xaxis != null) { xmax = xaxis.maximum; xmin = xaxis.minimum; } if (yaxis != null) { ymax = yaxis.maximum; ymin = yaxis.minimum; } xrange = xmax - xmin; yrange = ymax - ymin; /* ** draw the legend before we clip the data window */ draw_legend(g, bounds); /* ** Clip the data window */ if (clipping) g.clipRect(bounds.x, bounds.y, bounds.width, bounds.height); c = g.getColor(); if (linecolor != null) g.setColor(linecolor); else g.setColor(c); drawVectors(g, bounds); g.setColor(c); }
public void paint(Graphics g) { // chose Font with selected value f = new Font( lFont.getSelectedItem(), lStyle.getSelectedIndex(), Integer.parseInt(lSize.getSelectedItem())); // Clear Background g.setColor(Color.white); g.fillRect(0, 85, 400, 200); g.setColor(Color.black); if (f != null) { g.setFont(f); } g.drawString(sString.getText(), 20, 120); // Get Unicode char format FFFF in textfield sChar String s = sChar.getText(); char c; try { c = (char) Integer.parseInt(s, 16); if (Character.isDefined(c)) g.drawString("char \\u" + s + " is " + c, 20, 180); else g.drawString("char \\u" + s + " not exist", 20, 180); } catch (Exception e) { // Can parse this string g.drawString("" + e, 20, 180); } }
public void paint(Graphics g) { g.setColor(Color.red); g.fillRect(xpos1, ypos1, width, length); g.setColor(Color.blue); g.fillRect(xpos2, ypos2, width, length); g.setColor(Color.green); g.fillOval(x_pos - radius, y_pos - radius, 2 * radius, 2 * radius); Font text = new Font("Arial", Font.BOLD, 16); setFont(text); g.setColor(Color.white); g.drawString("Pong v. 1.0", 200, 25); message1 = "Player 1 Score: " + score1; message2 = "Player 2 Score: " + score2; g.drawString(message1, 10, 30); g.drawString(message2, 325, 30); if ((score1 == 10) || (score2 == 10)) { g.drawString(gameover, 175, 250); } }
/** Paint it. */ public void paint(Graphics g) { Dimension d = getSize(); if (!inited || buff == null || d.width != buffSize.width || d.height != buffSize.height) { buffSize.width = d.width; buffSize.height = d.height; buff = createImage(d.width + 4, d.height + 4); if (buff == null) return; buffG = buff.getGraphics(); inited = true; } buffG.setColor(Color.lightGray); buffG.fillRect(0, 0, prefSize.width, prefSize.height); PressedRect(buffG, 0, 0, prefSize.width - 2, prefSize.height - 2); buffG.setColor(Color.lightGray); buffG.fillRect(0, 0, prefSize.width + 2, prefSize.height + 2); if (!gameover) if ((gameover = is_game_over())) end_game(); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { drawBlock(buffG, i, j, status(i, j)); } } // PressedRect(buffG,0,0,prefSize.width + 2,prefSize.height + 2); if (buff != null) g.drawImage(buff, 0, 0, null); }
public void draw(Graphics g) { animate(); g.setColor(Color.black); g.fillRect(0, 0, dim.width, dim.height); g.setColor(Color.white); numpaint++; DebugPrinter dbg = new DebugPrinter(g, 50, 60); dbg.print( "Spring-mass demo by yigal irani, drag balls or create new ones by clicking inside box"); dbg.print("frame", numpaint); dbg.print("fps", 1 / timer.time_diff); Point top_left = point_by_vec(new Vec(-1, 1)); g.draw3DRect(top_left.x, top_left.y, screen_dist(2), screen_dist(2), true); for (int i = 0; i < springs.size(); i++) { Spring spring = springs.get2(i); Point p1 = point_by_vec(balls.get2(spring.start).pos); Point p2 = point_by_vec(balls.get2(spring.end).pos); g.drawLine(p1.x, p1.y, p2.x, p2.y); } for (int i = 0; i < balls.size(); i++) { Ball ball = balls.get2(i); Point p = point_by_vec(ball.pos); int screen_radius = screen_dist(RADIUS); g.setColor(Color.blue); g.fillOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2); g.setColor(Color.white); g.drawOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2); g.drawString("" + i, p.x, p.y); } }
/* * Draws a frame around the data area. */ protected void drawFrame(Graphics g, int x, int y, int width, int height) { Color c = g.getColor(); if (framecolor != null) g.setColor(framecolor); g.drawRect(x, y, width, height); g.setColor(c); }
public void paint(Graphics g) { if (first_paint == 1) { g.setColor(new Color(0x0)); g.fillRect(0, 0, SIZE_X, SIZE_Y); g.setColor(new Color(0xffffff)); g.drawRect(0, 0, SIZE_X - 1, SIZE_Y - 1); first_paint = 0; } }
public void run() { int i = -1, tx = -1, ty = -1, alive_cnt; int[] dx = {0, 1, 0, -1}; int[] dy = {-1, 0, 1, 0}; Graphics g = getGraphics(); while (true) { try { alive_cnt = 0; for (i = 0; i < NUM_PLAYERS; i++) { if (palive[i] == 1) { if (i > 0) DoAI(i); tx = px[i] + dx[pdir[i]]; ty = py[i] + dy[pdir[i]]; if ((tx < 0) || (tx >= SIZE_X) || (ty < 0) || (ty >= SIZE_Y) || (map[tx + ty * SIZE_X] != 0)) { palive[i] = 0; } else { px[i] = tx; py[i] = ty; map[tx + ty * SIZE_X] = (byte) (i + 1); } } if (palive[i] == 1) { alive_cnt++; g.setColor(new Color(pcolor[i])); g.drawLine(px[i], py[i], px[i], py[i]); } } if (palive[0] == 0) { g.setColor(new Color(0xff7070)); g.drawString("You Lose!", 50, 120); repaint(); stop(); } else if (alive_cnt == 1) { g.setColor(new Color(0x7070ff)); g.drawString("You Win!", 50, 120); repaint(); stop(); } repaint(); Thread.sleep(25); } catch (InterruptedException e) { g.drawString("IException!", 50, 100); repaint(); stop(); } catch (Exception e) { g.drawString("Exception:" + e.toString() + "\n", 50, 100); repaint(); } } }
public void tekenBoom(Graphics g, int x, int y, int breedte, int hoogte) { int diameterB = breedte * 3; int diameterH = hoogte * 4 / 5; g.setColor(new Color(160, 82, 45)); g.fillRect(x, y - hoogte, breedte, hoogte); g.setColor(Color.GREEN); g.fillOval( x + (breedte / 2) - (diameterB / 2), y - (hoogte + (diameterH / 2)), diameterB, diameterH); }
public void stare_paint(Graphics g) { int licznik = 0; test++; for (int i = 0; i < 100; i += 3) { g.setColor(kolory[licznik++ % kolory.length]); g.fillRoundRect(i, i, 400 - i * 2, 200 - i * 2, 10, 10); } g.setFont(f); g.setColor(kolor); g.drawString("Trebuchet MS jest " + test, 50, 100); }
public void getColorOfSquare(Graphics board, int row, int column) { // If the square falls on both an even row and column, it's a red square if ((row % 2) == (column % 2)) { // Set the red color board.setColor(Color.red); } else // otherwise it's black { // Set the black color board.setColor(Color.black); } }
/** * This paints the entire plot. It calls the draw methods of all the attached axis and data sets. * The order of drawing is - Axis first, data legends next, data last. * * @params g Graphics state. */ public void paint(Graphics g) { int i; Graphics lg = g.create(); Rectangle r = bounds(); /* The r.x and r.y returned from bounds is relative to the ** parents space so set them equal to zero. */ r.x = 0; r.y = 0; if (DefaultBackground == null) DefaultBackground = this.getBackground(); if (DataBackground == null) DataBackground = this.getBackground(); // System.out.println("Graph2D paint method called!"); if (!paintAll) return; r.x += borderLeft; r.y += borderTop; r.width -= borderLeft + borderRight; r.height -= borderBottom + borderTop; paintFirst(lg, r); if (!axis.isEmpty()) r = drawAxis(lg, r); else { if (clearAll) { Color c = g.getColor(); g.setColor(DataBackground); g.fillRect(r.x, r.y, r.width, r.height); g.setColor(c); } drawFrame(lg, r.x, r.y, r.width, r.height); } paintBeforeData(lg, r); if (!dataset.isEmpty()) { datarect.x = r.x; datarect.y = r.y; datarect.width = r.width; datarect.height = r.height; for (i = 0; i < dataset.size(); i++) { ((DataSet) dataset.elementAt(i)).draw_data(lg, r); } } paintLast(lg, r); lg.dispose(); }
/** paints the Spinner */ public void paint(Graphics g) { int start_angle = 90; int done_angle = (int) (percentDone * 360); g.setColor(getBackground()); g.fillArc(3, 3, getSize().width - 8, getSize().height - 8, 0, 360); g.setColor(getForeground()); g.fillArc(3, 3, getSize().width - 8, getSize().height - 8, start_angle, done_angle); g.setColor(Color.black); g.drawArc(3, 3, getSize().width - 8, getSize().height - 8, 0, 360); }
void PressedRect(Graphics g, int x, int y, int w, int h) { Color dg = new Color(128, 128, 128); g.setColor(Color.lightGray); g.drawLine(x + 1, y + h - 1, x + 1, y + h - 1); g.setColor(dg); g.drawLine(x, y, x + w - 1, y); g.drawLine(x, y, x, y + h - 1); g.setColor(Color.black); g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2); g.setColor(Color.white); g.drawLine(x + w, y, x + w, y + h); g.drawLine(x + w, y + h, x, y + h); }
public void paint(Graphics g) { Message("Copyright Feb, 2000 Weicon Conan Yuan.", "All Rights Reserved", 7); for (int i = 0; i < NUM_LOCATIONS; i++) { locs[i].draw(g, this); g.setColor(txtcolor); if (locs[i].ToDraw()) { g.drawString("" + i, locs[i].GetX(), locs[i].GetY() + 10); } } g.setColor(Color.red); g.drawRect(400, 200, 30, 30); g.fillRect(400, 200, 30, 30); Message("Cheat", 4); }
/** Update - Method, implements double buffering */ public void update(Graphics g) { // initialize buffer if (dbImage == null) { dbImage = createImage(this.getSize().width, this.getSize().height); dbg = dbImage.getGraphics(); } // clear screen in background dbg.setColor(getBackground()); dbg.fillRect(0, 0, this.getSize().width, this.getSize().height); // draw elements in background dbg.setColor(getForeground()); paint(dbg); // draw image on the screen g.drawImage(dbImage, 0, 0, this); }
public void paint(Graphics g) { g.setFont(bigFont); g.drawString("Shapes and Colors", 80, 20); g.setColor(redColor); g.drawRect(100, 100, 100, 100); g.fillRect(110, 110, 80, 80); g.setColor(weirdColor); g.fillArc(120, 120, 60, 60, 0, 360); g.setColor(Color.yellow); g.drawLine(140, 140, 160, 160); g.setColor(Color.black); }
public void paint(Graphics g) { if (!gameComplete) { if (!initialPaintComplete) { g.setColor(Color.WHITE); g.fillRect(0, 0, MaxX, MaxY); initialPaintComplete = true; } Graphics blockGraphics = blockBuffer.getGraphics(); Graphics padGraphics = padBuffer.getGraphics(); Graphics ballGraphics = ballBuffer.getGraphics(); Graphics ballPreviousGraphics = ballBufferPrevious.getGraphics(); ballPreviousGraphics.setColor(Color.WHITE); ballPreviousGraphics.fillRect(0, 0, ballDiameter, ballDiameter); g.drawImage(ballBufferPrevious, ballPreviousX, ballPreviousY, null); ballGraphics.setColor(Color.BLUE); ballGraphics.fillOval(0, 0, ballDiameter, ballDiameter); // whole line white g.drawImage(ballBuffer, ballX, ballY, null); ballGraphics.setColor(Color.RED); ballGraphics.fillOval(4, 4, ballDiameter - 8, ballDiameter - 8); // whole line white g.drawImage(ballBuffer, ballX, ballY, null); padGraphics.setColor(Color.WHITE); padGraphics.fillRect(0, 0, MaxX, blockHeight); // whole line white padGraphics.setColor(Color.BLACK); padLeft = padx - padLength / 2; if (padLeft >= 0 && padx + padLength / 2 < MaxX) { padGraphics.fillRoundRect(padLeft, 0, padLength, padHeight, padHeight, padHeight); } if (padLeft < 0) { padGraphics.fillRoundRect(0, 0, padLength, padHeight, padHeight, padHeight); } else if (padx + padLength / 2 >= MaxX) { padGraphics.fillRoundRect(MaxX - padLength, 0, padLength, padHeight, padHeight, padHeight); } g.drawImage(padBuffer, 0, padTop, null); // g.drawString(msg, 50, 50); // Drawing Blocks Iterator<Entry<String, Color>> it = blockMap.entrySet().iterator(); blockGraphics.setColor(Color.WHITE); blockGraphics.fillRect(0, 0, blockSetWidth, blockSetHeight); // whole line white while (it.hasNext()) { Map.Entry<String, Color> pairs = (Map.Entry<String, Color>) it.next(); String coordinate = pairs.getKey(); blockGraphics.setColor(pairs.getValue()); blockGraphics.fillRect( new Pair(coordinate).first, new Pair(coordinate).second, blockLength, blockHeight); } if (repaintBlocks) { g.drawImage(blockBuffer, blockStartX, blockStartY, null); if (--count < 0) repaintBlocks = false; } } }
public void paint(Graphics g) { msg = this.getParameter("p1"); System.out.println("paint..."); g.setColor(Color.red); g.drawLine(10, 20, 50, 50); g.drawString(msg, 100, 200); }
public void drawBoardTrim(Graphics board, int row, int column, int sizeOfSquare) { // Set the color to "goldish" board.setColor(Color.orange); // Apply solid color beneath the board to add thickness to trim board.fillRect(0, 0, (row * sizeOfSquare) + 5, (column * sizeOfSquare) + 5); }
public void mouseWheelMoved(MouseWheelEvent event) { int zoom = event.getWheelRotation(); mx = event.getX(); my = event.getY(); showStatus("Mouse rotated (" + zoom + ")"); // zoom out if (zoom >= 0) { dbg.setColor(Color.black); // dbg.drawImage (background, SIZE/2-current_size/2, // SIZE/2-current_size/2, current_size, current_size, this); } // zoom in else if (zoom < 0) { int width = building.getWidth(this); int height = building.getHeight(this); dbg.drawImage( building, width, height, width / 2, height / 2, width, height, width, height, this); } repaint(); event.consume(); }
public void paint(Graphics g) { g.setColor(Color.pink); g.drawRect(40, 40, 80, 80); g.drawLine(80, 10, 40, 40); g.drawLine(80, 10, 120, 40); g.drawRect(70, 80, 20, 40); }
public void Message(String s, int i) { Graphics g = getGraphics(); if (s == null) { g.setColor(bgcolor); g.drawRect(400, 50 * i - 10, 200, 10); g.fillRect(400, 50 * i - 10, 200, 10); return; } /* g.setColor(Color.blue); g.drawRect(400,50 * i - 10,200,10); g.fillRect(400,50 * i - 10,200,10); */ g.setColor(txtcolor); g.drawString(s, 400, 50 * i); }
public void displayScore2( Graphics g, int cx, int cy, int sx1, int sy1, int sx2, int sy2, int sx3, int sy3) { g.setFont(scoreFont); g.setColor(Color.WHITE); g.drawImage(new ImageIcon("InGameMenu/coin.png").getImage(), cx, cy, this); g.drawString("" + coins, sx1, sy1); g.drawString("Score: " + score, sx2, sy2); g.drawString("Height: " + height + " m", sx3, sy3); }
public void draw(Graphics g, ImageObserver ob) { if (!todraw) { g.setColor(bgcolor); g.drawRect(x, y, w + 2 * border, h + 2 * border); g.fillRect(x, y, w + 2 * border, h + 2 * border); return; } if (selected) g.setColor(selected_color); else g.setColor(unselected_color); g.drawRect(x, y, w + 2 * border, h + 2 * border); g.fillRect(x, y, w + 2 * border, h + 2 * border); g.drawImage(image[im], x + border, y + border, ob); // g.setColor(Color.black); // g.drawString("" + im,x+5,y+5); }
public void paint(Graphics g) { // Draw dark night sky g.setColor(Color.black); g.fillRect(0, 0, 800, 600); // Draw stars g.setColor(Color.white); g.fillOval(100, 100, 4, 4); g.fillOval(73, 212, 4, 4); g.fillOval(57, 356, 4, 4); g.fillOval(200, 56, 4, 4); g.fillOval(173, 212, 4, 4); g.fillOval(157, 456, 4, 4); g.fillOval(300, 235, 4, 4); g.fillOval(263, 412, 4, 4); g.fillOval(357, 286, 4, 4); g.fillOval(400, 576, 4, 4); g.fillOval(352, 312, 4, 4); g.fillOval(457, 556, 4, 4); g.fillOval(333, 453, 4, 4); g.fillOval(443, 72, 4, 4); g.fillOval(557, 446, 4, 4); g.fillOval(600, 444, 4, 4); g.fillOval(534, 512, 4, 4); g.fillOval(657, 336, 4, 4); g.fillOval(700, 313, 4, 4); g.fillOval(623, 273, 4, 4); g.fillOval(757, 226, 4, 4); g.fillOval(555, 333, 4, 4); g.fillOval(333, 555, 4, 4); g.fillOval(444, 444, 4, 4); g.fillOval(222, 444, 4, 4); g.fillOval(777, 555, 4, 4); g.fillOval(700, 444, 4, 4); g.fillOval(200, 300, 4, 4); g.fillOval(333, 222, 4, 4); g.fillOval(555, 222, 4, 4); // Draw crescent moon g.setColor(Color.YELLOW); g.fillOval(500, 30, 200, 200); g.setColor(Color.BLACK); g.fillOval(500, 30, 150, 150); }
public void drawBomb(Graphics g, int x, int y) { Color c = g.getColor(); g.setColor(new Color(128, 128, 128)); g.drawLine(x + 2, y + 7, x + 12, y + 7); g.drawLine(x + 7, y + 2, x + 7, y + 12); g.fillRect(x + 6, y + 4, 3, 7); g.fillRect(x + 4, y + 6, 7, 3); g.setColor(Color.black); g.fillRect(x + 5, y + 5, 5, 5); g.drawLine(x + 3, y + 7, x + 11, y + 7); g.drawLine(x + 7, y + 3, x + 7, y + 11); g.drawLine(x + 4, y + 4, x + 4, y + 4); g.drawLine(x + 4, y + 10, x + 4, y + 10); g.drawLine(x + 10, y + 4, x + 10, y + 4); g.drawLine(x + 10, y + 10, x + 10, y + 10); g.setColor(Color.white); g.drawLine(x + 6, y + 6, x + 6, y + 6); g.setColor(c); }
public void paint(Graphics g){ g.setColor(Color.blue); setBackground(Color.white); g.drawRect(30,30,200,200); setBackground(Color.white); g.drawString("Hello World, I am an Applet !",50,50); g.drawString(s,50,110); g.drawString(getParameter("name").toString(),50,70); g.drawString(getParameter("myName").toString(),50,100); }*/
/** * This method is called via the Graph2D.repaint() method. All it does is blank the canvas (with * the background color) before calling paint. */ public void update(Graphics g) { // System.out.println("Graph2d update method called"); if (clearAll) { Color c = g.getColor(); /* The r.x and r.y returned from bounds is relative to the ** parents space so set them equal to zero */ Rectangle r = bounds(); r.x = 0; r.y = 0; g.setColor(getBackground()); g.fillRect(r.x, r.y, r.width, r.height); g.setColor(c); } if (paintAll) paint(g); }
public void gameOverMenu( Graphics g) { // CHANGE THIS TO INCLUDE HIGHSCORES AND STUFF AFTER TEXTFILES ARE MADE // Menu that shows up when user gets Game Over if (pause == true && die == true) { g.drawImage( new ImageIcon("InGameMenu/pauseBckgrnd.png").getImage(), 0, 0, this); // Graphics stuff g.setFont(scoreFont); g.setColor(Color.BLACK); g.drawImage(new ImageIcon("InGameMenu/GameOver.png").getImage(), 10, 200, this); displayScore2(g, 115, 350, 185, 385, 110, 440, 110, 490); // Shows stats g.drawImage(menuB.getPic(mx, my), menuB.getX(), menuB.getY(), this); // Draws menu button } }