private BufferedImage generateFrame(GifFrame frame) { int width = frame.getColumns() * CELL_WIDTH; BufferedImage img = new BufferedImage(width, frame.getRows() * CELL_HEIGHT + TEXT_AREA_HEIGHT, IMAGE_TYPE_GIF); Graphics graphics = img.getGraphics(); for (int row = 0; row < frame.getRows(); row++) { for (int col = 0; col < frame.getColumns(); col++) { ImageIcon icon = new ImageIcon( "site/images/" + frame.getBoard().get(row, col).getImageFilename() + ".png"); graphics.drawImage(icon.getImage(), col * CELL_WIDTH, row * CELL_HEIGHT, null); } } for (BoxOverlay overlay : frame.getOverlays()) { graphics.setColor(overlay.getColor()); Rectangle rect = overlay.getRectangle(); int rect_x = rect.getLeft() * CELL_WIDTH - OVERLAY_PADDING; int rect_y = rect.getTop() * CELL_HEIGHT - OVERLAY_PADDING; int rect_width = (rect.getRight() - rect.getLeft() + 1) * CELL_WIDTH + 2 * OVERLAY_PADDING; int rect_height = (rect.getBottom() - rect.getTop() + 1) * CELL_HEIGHT + 2 * OVERLAY_PADDING; graphics.drawRect(rect_x, rect_y, rect_width, rect_height); graphics.drawRect(rect_x - 1, rect_y - 1, rect_width + 2, rect_height + 2); } graphics.setColor(FONT_COLOR); graphics.setFont(FONT); FontMetrics fm = graphics.getFontMetrics(); graphics.drawString( frame.getText(), width / 2 - fm.stringWidth(frame.getText()) / 2, frame.getRows() * CELL_HEIGHT + TEXT_AREA_HEIGHT / 2 + fm.getHeight() / 2); return img; }
public void paintComponent(Graphics g) { super.paintComponent(g); setBackground(Color.black); add(l); add(s); drawSpecialLines(g); g.setColor(Color.white); g.fillOval(30, 100, 75, 75); g.setColor(Color.blue); g.fillRect(getWidth() / 2, getHeight() / 2, (int) bl, 10); g.fillRect(getWidth() / 2, getHeight() / 2 + 40, (int) gl, 10); g.fillRect(getWidth() / 2, getHeight() / 2 + 80, (int) ll, 10); g.fillRect(getWidth() / 2, getHeight() / 2 + 120, (int) sl, 10); g.drawImage(bullet.getImage(), 30, getHeight() / 2 - 10, 20, 20, null); g.drawImage(grenade.getImage(), 30, getHeight() / 2 + 40 - 10, 20, 20, null); g.drawImage(laser.getImage(), 30, getHeight() / 2 + 80 - 10, 20, 20, null); g.drawImage(shotgun.getImage(), 30, getHeight() / 2 + 120 - 10, 20, 20, null); g.setColor(Color.yellow); if (gunTrack == 0) { g.drawRect(30, getHeight() / 2 - 10, 20, 20); } else if (gunTrack == 1) { g.drawRect(30, getHeight() / 2 + 40 - 10, 20, 20); } else if (gunTrack == 2) { g.drawRect(30, getHeight() / 2 + 80 - 10, 20, 20); } else { g.drawRect(30, getHeight() / 2 + 120 - 10, 20, 20); } }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Color hiColor = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getFocusFrameColor(), 60); Color loColor = AbstractLookAndFeel.getTheme().getFocusFrameColor(); g.setColor(loColor); g.drawRect(x, y, width - 1, height - 1); g.setColor(hiColor); g.drawRect(x + 1, y + 1, width - 3, height - 3); }
public void displayInstructions(Graphics g) { // Slightly freshened the look of the intro page. g.drawRect(128, 100, 250, 150); // decorative rectangles g.drawRect(122, 95, 260, 162); g.drawString("Welcome to Snake", 200, 130); // Centered instructions g.drawString("Press any key to start", 195, 150); g.drawString("Press 'q' to quit", 210, 170); }
// documentation inherited public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; // center the tile display if we are bigger than we need to be g.translate(_tx, _ty); // // paint coordinates in the grid that contains our tiles // for (int yy = 0; yy < _height; yy++) { // for (int xx = 0; xx < _width; xx++) { // int cx = xx*TILE_WIDTH, cy = yy*TILE_HEIGHT; // g.drawRect(cx, cy, TILE_WIDTH, TILE_HEIGHT); // String coord = (xx-_origX) + "/" + (yy-_origY); // g.drawString(coord, cx+TILE_WIDTH/2, cy+TILE_HEIGHT/2); // } // } // iterate over our tiles, painting each of them for (AtlantiTile tile : _tiles) { tile.paint(g2, _origX, _origY); } // if we have a placing tile, draw that one as well if (_placingTile != null && _validPlacement) { // if the current position is valid, draw the placing tile _placingTile.paint(g2, _origX, _origY); // draw a green rectangle around the placing tile g.setColor(Color.blue); int sx = (_placingTile.x + _origX) * TILE_WIDTH; int sy = (_placingTile.y + _origY) * TILE_HEIGHT; g.drawRect(sx, sy, TILE_WIDTH - 1, TILE_HEIGHT - 1); } // if we have a recently placed tile, draw that one as well if (_placedTile != null) { // draw the tile _placedTile.paint(g2, _origX, _origY); // draw a white rectangle around the placed tile g.setColor(Color.white); int sx = (_placedTile.x + _origX) * TILE_WIDTH; int sy = (_placedTile.y + _origY) * TILE_HEIGHT; g.drawRect(sx, sy, TILE_WIDTH - 1, TILE_HEIGHT - 1); } // draw a white rectangle around the last placed if (_lastPlacedTile != null) { g.setColor(Color.white); int sx = (_lastPlacedTile.x + _origX) * TILE_WIDTH; int sy = (_lastPlacedTile.y + _origY) * TILE_HEIGHT; g.drawRect(sx, sy, TILE_WIDTH - 1, TILE_HEIGHT - 1); } // undo our translations g.translate(-_tx, -_ty); }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { Color logoColor = AbstractLookAndFeel.getMenuSelectionBackgroundColor(); Color borderColorLo = AbstractLookAndFeel.getFrameColor(); Color borderColorHi = ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40); g.setColor(logoColor); if (JTattooUtilities.isLeftToRight(c)) { int dx = getBorderInsets(c).left; g.fillRect(x, y, dx - 1, h - 1); paintLogo(c, g, x, y, w, h); // - highlight g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40)); g.drawLine(x + dx, y + 1, x + w - 2, y + 1); g.setColor(borderColorHi); g.drawLine(x + 1, y, x + 1, y + h - 2); // - outer frame g.setColor(borderColorLo); if (isMenuBarPopup(c)) { // top g.drawLine(x + dx - 1, y, x + w, y); // left g.drawLine(x, y, x, y + h - 1); // bottom g.drawLine(x, y + h - 1, x + w, y + h - 1); // right g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); } else { g.drawRect(x, y, w - 1, h - 1); } // - logo separator g.drawLine(x + dx - 1, y + 1, x + dx - 1, y + h - 1); } else { int dx = getBorderInsets(c).right; g.fillRect(x + w - dx, y, dx, h - 1); paintLogo(c, g, x, y, w, h); // - highlight g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40)); g.drawLine(x + 1, y + 1, x + w - dx - 1, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2); // - outer frame g.setColor(borderColorLo); if (isMenuBarPopup(c)) { // top g.drawLine(x, y, x + w - dx, y); // left g.drawLine(x, y, x, y + h - 1); // bottom g.drawLine(x, y + h - 1, x + w, y + h - 1); // right g.drawLine(x + w - 1, y, x + w - 1, y + h - 1); } else { g.drawRect(x, y, w - 1, h - 1); } // - logo separator g.drawLine(x + w - dx, y + 1, x + w - dx, y + h - 1); } }
/** This draws the "Flush 3D Border" which is used throughout the Metal L&F */ static void drawFlush3DBorder(Graphics g, int x, int y, int w, int h) { g.translate(x, y); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(0, 0, w - 2, h - 2); g.setColor(MetalLookAndFeel.getControlHighlight()); g.drawRect(1, 1, w - 2, h - 2); g.setColor(MetalLookAndFeel.getControl()); g.drawLine(0, h - 1, 1, h - 2); g.drawLine(w - 1, 0, w - 2, 1); g.translate(-x, -y); }
/** * Draws a colored cell. * * @param g graphics reference * @param xs horizontal start position * @param xe horizontal end position * @param ys vertical start position * @param ye vertical end position * @param focus highlighting flag */ public static void drawCell( final Graphics g, final int xs, final int xe, final int ys, final int ye, final boolean focus) { g.setColor(gray); g.drawRect(xs, ys, xe - xs - 1, ye - ys - 1); g.setColor(BACK); g.drawRect(xs + 1, ys + 1, xe - xs - 3, ye - ys - 3); g.setColor(focus ? lgray : BACK); g.fillRect(xs + 1, ys + 1, xe - xs - 2, ye - ys - 2); }
public void draw(Graphics g, Color c, boolean draw_name) { g.setColor(c); g.fillRect(this.x, this.y, this.sx, this.sy); g.setColor(Color.black); g.drawRect(this.x, this.y, this.sx, this.sy); if (draw_name) g.drawString(this.name, this.x, this.y); }
@Override public void paintComponent(Graphics g) { Graphics g2 = g.create(); Dimension d = getSize(); CPArtwork artwork = controller.getArtwork(); Object[] layers = artwork.getLayers(); g2.setColor(new Color(0x606060)); g2.fillRect(0, 0, d.width, d.height - layers.length * layerH); g2.setColor(Color.black); g2.translate(0, d.height - layerH); for (int i = 0; i < layers.length; i++) { drawLayer(g2, (CPLayer) layers[i], i == artwork.getActiveLayerNb()); g2.translate(0, -layerH); } if (layerDragReally) { g2.translate(0, layers.length * layerH - (d.height - layerH)); g2.drawRect(0, layerDragY - layerH / 2, d.width, layerH); int layerOver = (d.height - layerDragY) / layerH; if (layerOver <= layers.length && layerOver != layerDragNb && layerOver != layerDragNb + 1) { g2.fillRect(0, d.height - layerOver * layerH - 2, d.width, 4); } } }
public void paint(Graphics g) { super.paint(g); if (mouseIn) { g.setColor(Color.blue); g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); } }
public void paint(Graphics g) { Dimension dim = getSize(); g.draw3DRect(1, 1, dim.width - 3, dim.height - 3, true); g.setColor(Color.black); g.drawRect(0, 0, dim.width - 1, dim.height - 1); }
/** * The function prints out key to jumpshot data. */ int print (Graphics g, int x, int y, int width, int height) { Font f = g.getFont (); FontMetrics fm = getToolkit ().getFontMetrics (f); int charW = fm.stringWidth (" "), charH = fm.getHeight (); int hgap1 = charW, hgap2 = 2 * charW, vgap = fm.getAscent (); int rectW = 30, rectH = charH; //Dimensions of state rectangles int xcord = x, ycord = y; Enumeration enum = parent.stateDefs.elements (); while (enum.hasMoreElements ()) { RecDef s = (RecDef)enum.nextElement (); if (s.stateVector.size () > 0) { int strW = fm.stringWidth (s.description); if ((xcord + rectW + hgap1 + strW) > (width + x)) { xcord = x; ycord += (charH + vgap); } g.setColor (s.color); g.fillRect (xcord, ycord, rectW, rectH); g.setColor (Color.black); g.drawRect (xcord, ycord, rectW - 1, rectH - 1); g.drawString( s.description, xcord + rectW + hgap1, ycord + rectH - fm.getDescent () - 1); xcord += (rectW + hgap1 + strW + hgap2); } } return (ycord - y + (2 * charH)); }
@Override public void paintIcon(final Component component, final Graphics g, final int i, final int j) { final int iconWidth = getIconWidth(); final int iconHeight = getIconHeight(); if (myColor != null) { g.setColor(myColor); g.fillRect(i, j, iconWidth, iconHeight); } else if (myColours != null) { final Color top = myColours[0]; g.setColor(top); g.fillRect(i, j, iconWidth, 2); final Color right = myColours[1]; g.setColor(right); g.fillRect(i + iconWidth / 2, j + 2, iconWidth / 2, iconHeight / 2); final Color bottom = myColours[2]; g.setColor(bottom); g.fillRect(i, j + iconHeight - 2, iconWidth, 2); final Color left = myColours[3]; g.setColor(left); g.fillRect(i, j + 2, iconWidth / 2, iconHeight / 2); } final Composite old = ((Graphics2D) g).getComposite(); ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f)); g.setColor(Color.BLACK); g.drawRect(i, j, iconWidth - 1, iconHeight - 1); ((Graphics2D) g).setComposite(old); }
/** * Override the pain method do draw the axis lines * * @param g The graphics to paint to */ public void paint(Graphics g) { Rectangle b = getBounds(); g.setColor(canvasBg); g.fillRect(0, 0, b.width, b.height); paintGrid(g); Point center = getCenter(); if (g instanceof Graphics2D) { ((Graphics2D) g).translate(center.x, center.y); } super.paint(g); if (g instanceof Graphics2D) { ((Graphics2D) g).scale(1.0, 1.0); } g.setColor(Color.gray); g.drawLine(0, -10 * b.height, 0, 10 * b.height); g.drawLine(-10 * b.width, 0, 10 * b.width, 0); MetSymbol tmp = highlightedMetSymbol; if (tmp != null) { Rectangle tb = tmp.getBounds(); g.setColor(Color.red); g.drawRect(tb.x - 2, tb.y - 2, tb.width + 4, tb.height + 4); } }
private void drawButton(Graphics g, int x, int y, String txt) { g.setColor(Color.white); g.fillRect(x, y, 30, 30); g.setColor(Color.black); g.drawRect(x, y, 30, 30); g.drawString(txt, x + 18, y + 18); }
@SuppressWarnings("UseJBColor") @Override protected void paintComponent(Graphics g) { final Insets i = getInsets(); final Dimension d = getSize(); final int left = i.left + (d.width - i.left - i.right - WIDTH) / 2; final int top = i.top + (d.height - i.top - i.bottom - HEIGHT) / 2; g.setColor(Color.WHITE); g.fillRect(left, top, WIDTH, HEIGHT); g.setColor(Color.GRAY); g.drawLine(left + 1, i.top + HEIGHT / 2, left + WIDTH - 3, i.top + HEIGHT / 2); g.drawRect(left + 1, top + 1, WIDTH - 3, HEIGHT - 3); for (int k = 1; k < 10; k++) { g.drawLine(left + 1 + k * 31, top + 1, left + 1 + k * 31, top + HEIGHT - 3); } for (int r = 0; r < myRecentColors.size(); r++) { int row = r / 10; int col = r % 10; Color color = myRecentColors.get(r); g.setColor(color); g.fillRect(left + 2 + col * 30 + col + 1, top + 2 + row * 30 + row + 1, 28, 28); } }
public void paintComponent(Graphics g) { g.setColor(new Color(0x8090ff)); g.fillRect(0, 0, level.length * 16, level.height * 16); levelRenderer.render(g, 0); g.setColor(Color.BLACK); g.drawRect(xTile * 16 - 1, yTile * 16 - 1, 17, 17); }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { if (JTattooUtilities.isFrameActive((JComponent) c)) { g.setColor(AbstractLookAndFeel.getWindowBorderColor()); } else { g.setColor(AbstractLookAndFeel.getWindowInactiveBorderColor()); } g.drawRect(x, y, w - 1, h - 1); }
/** Paint the node preview widget */ public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.gray); g.drawRect(0, 0, this.getBounds().width - 1, this.getBounds().height - 1); if (this.node != null) this.node.paint(g); }
public void paintIcon(Component c, Graphics g, int x, int y) { if (color == null) return; g.setColor(color); g.fillRect(x, y, getIconWidth(), getIconHeight()); g.setColor(color.darker()); g.drawRect(x, y, getIconWidth() - 1, getIconHeight() - 1); }
static void drawDefaultButtonBorder(Graphics g, int x, int y, int w, int h, boolean active) { drawButtonBorder(g, x + 1, y + 1, w - 1, h - 1, active); g.translate(x, y); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(0, 0, w - 3, h - 3); g.drawLine(w - 2, 0, w - 2, 0); g.drawLine(0, h - 2, 0, h - 2); g.translate(-x, -y); }
// Border public void drawSpecialLines(Graphics g) { for (int i = 0; i < 11; i++) { if (i % 2 == 0) { g.setColor(new Color(51, 51, 51)); } else { g.setColor(new Color(255, 193, 37)); } g.drawRect(0 + i, 0 + i, this.getWidth() - i * 2, this.getHeight() - i * 2); } }
@Override protected void paintComponent(Graphics g) { g.clearRect(0, 0, getWidth(), getHeight()); g.setColor(Color.BLACK); g.drawRect(CELL_SIZE, CELL_SIZE, maze.width * CELL_SIZE, maze.height * CELL_SIZE); drawWalls(g, maze); boolean even = true; PathCell pathIt = path.first; while (pathIt != null) { even = !even; g.setColor(even ? Color.GREEN : Color.CYAN); g.fillRect( CELL_SIZE + pathIt.node.x * CELL_SIZE + 1, CELL_SIZE + pathIt.node.y * CELL_SIZE + 1, pathIt.node.width * CELL_SIZE - 1, pathIt.node.height * CELL_SIZE - 1); MazeNode door = pathIt.doorNode; g.setColor(Color.YELLOW); if (door != null) { if (door.division == Division.VERTICAL) { g.drawLine( CELL_SIZE + door.doorX * CELL_SIZE, CELL_SIZE + door.doorY * CELL_SIZE + 1, CELL_SIZE + door.doorX * CELL_SIZE, CELL_SIZE + (door.doorY + 1) * CELL_SIZE - 1); } else { g.drawLine( CELL_SIZE + door.doorX * CELL_SIZE + 1, CELL_SIZE + door.doorY * CELL_SIZE, CELL_SIZE + (door.doorX + 1) * CELL_SIZE - 1, CELL_SIZE + door.doorY * CELL_SIZE); } } pathIt = pathIt.next; } g.setColor(Color.ORANGE); g.fillRect( CELL_SIZE + sx * CELL_SIZE + 2, CELL_SIZE + sy * CELL_SIZE + 2, CELL_SIZE - 3, CELL_SIZE - 3); g.setColor(Color.RED); g.fillRect( CELL_SIZE + dx * CELL_SIZE + 2, CELL_SIZE + dy * CELL_SIZE + 2, CELL_SIZE - 3, CELL_SIZE - 3); }
public void paintComponent(Graphics g) { super.paintComponent(g); int x = getWidth() / 2 - 60; int y = getHeight() / 2; g.setColor(Color.blue); g.drawRect(x, y, 120, 20); g.setColor(Color.red); Font font = new Font("Courier", Font.BOLD, 14); g.setFont(font); g.drawString("Hello world!", x + 10, y + 15); }
public void paintIcon(Component c, Graphics g, int x, int y) { Color backgroundColor = c.getBackground(); if (backgroundColor != null) g.setColor(backgroundColor); else g.setColor(Color.white); g.fillRect(x, y, 8, 8); g.setColor(Color.gray); g.drawRect(x, y, 8, 8); g.setColor(Color.black); g.drawLine(x + 2, y + 4, x + (6), y + 4); }
// Borders for decoration public void drawSpecialLines(Graphics g) { for (int i = 0; i < 11; i++) { if (i % 2 == 0) { g.setColor(new Color(51, 51, 51)); } else { g.setColor(new Color(255, 193, 37)); } g.drawRect( 0 + i, 0 + i, box.length * Square.SIZE - i * 2, box[0].length * Square.SIZE - i * 2); } }
static void drawDefaultButtonPressedBorder(Graphics g, int x, int y, int w, int h) { drawPressed3DBorder(g, x + 1, y + 1, w - 1, h - 1); g.translate(x, y); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(0, 0, w - 3, h - 3); g.drawLine(w - 2, 0, w - 2, 0); g.drawLine(0, h - 2, 0, h - 2); g.setColor(MetalLookAndFeel.getControl()); g.drawLine(w - 1, 0, w - 1, 0); g.drawLine(0, h - 1, 0, h - 1); g.translate(-x, -y); }
/** Draws the panel. */ public void paintComponent(Graphics g) { super.paintComponent(g); Log.setTrace(true); // Log.trace(this, getBounds().toString()); // Log.trace(this, getInsets().toString()); // respect borders Insets insets = getInsets(); Rectangle r = getBounds(); r.x += insets.left; r.y += insets.top; r.width -= insets.left + insets.right; r.height -= insets.top + insets.bottom; // System.out.println("paintComponent" + count++); g.setColor(Color.black); DirectedGraph<LayoutNode, DirectedEdge<LayoutNode>> graph = fLayout.graph(); // draw edges Iterator<DirectedEdge<LayoutNode>> edgeIter = graph.edgeIterator(); while (edgeIter.hasNext()) { DirectedEdge<LayoutNode> edge = edgeIter.next(); // Log.trace(this, edge.toString()); LayoutNode source = (LayoutNode) edge.source(); LayoutNode target = (LayoutNode) edge.target(); int x1 = source.getX() * 80 + 30; int y1 = 50 + source.fLayer * 50; // if (source.isDummy() ) // x1 += 5; int x2 = target.getX() * 80 + 30; int y2 = 50 + target.fLayer * 50; // if (target.isDummy() ) // x2 += 5; g.drawLine(x1, y1, x2, y2); } // draw nodes Iterator<LayoutNode> nodeIter = graph.iterator(); while (nodeIter.hasNext()) { LayoutNode node = nodeIter.next(); if (node.isDummy()) continue; int x = node.getX() * 80 + 30; int y = 50 + node.fLayer * 50; g.setColor(Color.white); g.fillRect(x - 10, y - 10, 20, 20); g.setColor(Color.black); g.drawRect(x - 10, y - 10, 20, 20); g.drawString(node.toString(), x - 7, y + 8); } }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); if (myColorDescriptor != null) { final int size = getBounds().height; g.setColor(getBackground()); g.fillRect(0, 0, size + getIconTextGap() + 1, size); g.setColor(myColorDescriptor.getResolvedColor()); g.fillRect(2, 2, size - 4, size - 4); g.setColor(Color.BLACK); g.drawRect(2, 2, size - 4, size - 4); } }