Refine search
public synchronized void update(Graphics g) { Dimension d=getSize(); if((offscreen == null) || (d.width != offscreensize.width) || (d.height != offscreensize.height)) { offscreen=createImage(d.width, d.height); offscreensize=d; offgraphics=offscreen.getGraphics(); offgraphics.setFont(default_font); } offgraphics.setColor(getBackground()); offgraphics.fillRect(0, 0, d.width, d.height); FontMetrics fm=offgraphics.getFontMetrics(); for(int i=0; i < nodes.size(); i++) { paintNode(offgraphics, nodes.get(i), fm); } g.drawImage(offscreen, 0, 0, null); }
Image myImage = new BufferedImage(...); Graphics graphImage = myImage.getGraphics(); graphImage.setColor(Color.BLUE); graphImage.fillPolygon(...); // set some blue pixels inside the BufferedImage
/** * Set up the off screen bitmap for rendering to */ protected void initialize() { int iwidth = m_plotPanel.getWidth(); int iheight = m_plotPanel.getHeight(); // System.err.println(iwidth+" "+iheight); m_osi = m_plotPanel.createImage(iwidth, iheight); Graphics m = m_osi.getGraphics(); m.fillRect(0, 0, iwidth, iheight); }
public void update(Graphics g) { Dimension d=getSize(); if(off_graphics == null || d.width != off_dimension.width || d.height != off_dimension.height) { off_dimension=d; off_image=createImage(d.width, d.height); off_graphics=off_image.getGraphics(); } //Erase the previous image. off_graphics.setColor(getBackground()); off_graphics.fillRect(0, 0, d.width, d.height); off_graphics.setColor(Color.black); off_graphics.setFont(def_font); drawEmptyBoard(off_graphics); drawNumbers(off_graphics); g.drawImage(off_image, 0, 0, this); }
static private Image createTestImage(final int resolution) { final Image image = new BufferedImage(resolution, resolution, BufferedImage.TYPE_INT_ARGB); final Graphics g = image.getGraphics(); final int points = (resolution * 72) / 96; g.setColor(new Color(.42f, .42f, 1.0f, .5242f)); g.setFont(new Font("Dialog", Font.BOLD, points)); g.drawString("!X!", 2, points); g.setColor(Color.BLACK); g.drawOval(0, 0, image.getWidth(null) - 1, image.getHeight(null) - 1); g.drawOval(11, 11, image.getWidth(null) - 23, image.getHeight(null) - 23); g.drawOval(22, 22, image.getWidth(null) - 45, image.getHeight(null) - 45); return image; }
/** * Set up the off screen bitmap for rendering to */ protected void initialize() { int iwidth = m_plotPanel.getWidth(); int iheight = m_plotPanel.getHeight(); // System.err.println(iwidth+" "+iheight); m_osi = m_plotPanel.createImage(iwidth, iheight); Graphics m = m_osi.getGraphics(); m.fillRect(0, 0, iwidth, iheight); }
final Graphics2D graphics2d = (Graphics2D) image.getGraphics(); graphics.setColor(Color.BLACK); graphics.fillRect(0, 0, client.getCanvas().getWidth(), client.getCanvas().getHeight());
Graphics gr = image.getGraphics(); int toy = (int) point.getY(); gr.setColor(Color.pink);//line gr.drawLine(startx,starty,tox,toy); gr.setColor(Color.green); //height gr.drawLine(tox, toy, tox, MAP_HEIGHT); gr.setColor(Color.yellow); //base gr.drawLine(tox, MAP_HEIGHT-1, startx, MAP_HEIGHT-1); gr.drawLine(tox, MAP_HEIGHT-2, startx, MAP_HEIGHT-2);
class DoubleBufferedCanvas extends Canvas { public void update(Graphics g) { Graphics offgc; Image offscreen = null; Dimension d = size(); // create the offscreen buffer and associated Graphics offscreen = createImage(d.width, d.height); offgc = offscreen.getGraphics(); // clear the exposed area offgc.setColor(getBackground()); offgc.fillRect(0, 0, d.width, d.height); offgc.setColor(getForeground()); // do normal redraw paint(offgc); // transfer offscreen to window g.drawImage(offscreen, 0, 0, this); } }
public void GenerateIcons() { icons = new ImageIcon[1]; icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR)); Graphics g; try { g = icons[0].getImage().getGraphics(); } catch (NullPointerException e) { System.out.println("Could not get Graphics pointer to " + getClass() + " Image"); return; } Graphics2D g2 = (Graphics2D) g; Color transparent = new Color(0, 0, 0, 0); g2.setBackground(transparent); g2.clearRect(0, 0, width, height); g.setColor(color); int[] xp = {27, 0, 27}; int[] yp = {0, 14, 27}; g.fillPolygon(xp, yp, 3); currentIcon = icons[0].getImage(); }
public void paint(Graphics g) { Image image = createImage(size + 1, size + 1); Graphics offG = image.getGraphics(); offG.setColor(Color.BLACK); offG.fillRect(0, 0, getWidth(), getHeight()); // etc
public void GenerateIcons() { icons = new ImageIcon[1]; icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR)); Graphics g; try { g = icons[0].getImage().getGraphics(); } catch (NullPointerException e) { System.out.println("Could not get Graphics pointer to " + getClass() + " Image"); return; } Graphics2D g2 = (Graphics2D) g; Color transparent = new Color(0, 0, 0, 0); g2.setBackground(transparent); g2.clearRect(0, 0, width, height); g.setColor(color); int[] xp = {7, 21, 27, 21, 7, 0}; int[] yp = {0, 0, 14, 27, 27, 14}; g.fillPolygon(xp, yp, 6); currentIcon = icons[0].getImage(); }
class graphPanel extends JPanel{ Image img; public void paintComponent(Graphics g){ super.paintComponent(g); if(img == null) { img = new BufferedImage( getWidth(), getHeight(), BufferedImage.TYPE_3BYTE_BGR ); img.getGraphics().setColor( getBackground() ); img.getGraphics().fillRect( 0, 0, getWidth(), getHeight() ); } int locX = MouseInfo.getPointerInfo().getLocation().x - 10; int locY = MouseInfo.getPointerInfo().getLocation().y - 30; Graphics imgG = img.getGraphics(); imgG.setColor(Color.ORANGE); imgG.fillRect(locX, locY, 10, 10); g.drawImage( img, 0, 0, this ); } }
/** * Draws the LUT of the currently displayed channel into a rectangle. */ void drawLUT() { final Graphics g = lutImage.getGraphics(); final int[] rgb = new int[256]; final ColorModel currentLUT = i5d.getChannelDisplayProperties(cColorChooser.cControl.currentChannel) .getColorModel(); if (!(currentLUT instanceof IndexColorModel)) throw new IllegalArgumentException( "Color Model has to be IndexColorModel."); for (int i = 0; i < 256; i++) { rgb[i] = ((IndexColorModel) currentLUT).getRGB(i); } g.setColor(Color.black); g.drawRect(0, 0, lutWidth + 2, lutHeight + 2); // check consistency with lutHeight! g.setColor(new Color(rgb[255])); g.drawLine(1, 1, lutWidth, 1); for (int i = 0; i < 128; i++) { g.setColor(new Color(rgb[255 - i * 2])); g.drawLine(1, i + 2, lutWidth, i + 2); } }
public final static ImageIcon getEmptyIcon(int width, int height) { String code = "EMPTY_" + width + "x" + height; ImageIcon icon = cache.get(code); if (icon != null) { return icon; } Image img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); img.getGraphics().setColor(Color.WHITE); img.getGraphics().fillRect(0, 0, width, height); icon = new ImageIcon(img); cache.put(code, icon); return icon; }
/** * It draws the grid. * * @param color the color in which the grid should be drawn. */ public void drawGrid(Color color) { Graphics g = bufferImage.getGraphics(); g.setColor(color); int height = this.getContentPane().getHeight() - 10; int width = this.getContentPane().getWidth(); int i = 10; int j = 0; while (i < width) { g.drawLine(i, 0, i, height); i += pixelsPerUnit; } while (j < height) { g.drawLine(0, j, width, j); j += pixelsPerUnit; } }
private void drawCrits(Image im, int crits) { int w = im.getWidth(null); int h = im.getHeight(null); Graphics g = im.getGraphics(); g.setColor(Color.black); g.fillRect(0, 0, w, h); for (int i = 0; i < crits; i++) { g.setColor(Color.red.darker()); g.fillRect(i * (squareSize + 1), 0, squareSize, squareSize); } }
/** * It draws the grid. * * @param color the color in which the grid should be drawn. */ public void drawGrid(Color color) { Graphics g = bufferImage.getGraphics(); g.setColor(color); int height = this.getContentPane().getHeight() - 10; int width = this.getContentPane().getWidth(); int i = 10; int j = 0; while (i < width) { g.drawLine(i, 0, i, height); i += pixelsPerUnit; } while (j < height) { g.drawLine(0, j, width, j); j += pixelsPerUnit; } }
private void drawCrits(Image im, int crits) { int w = im.getWidth(null); int h = im.getHeight(null); Graphics g = im.getGraphics(); g.setColor(Color.black); g.fillRect(0, 0, w, h); for (int i = 0; i < crits; i++) { g.setColor(Color.red.darker()); g.fillRect(i * (squareSize + 1), 0, squareSize, squareSize); } }
/** * It displays a 2D point given its coordinates and color. * * @param point point coordinates. * @param color color the point should be painted with. */ public void display2DPoint(int[] point, Color color) { Graphics g = bufferImage.getGraphics(); int height = this.getContentPane().getHeight() - 10; g.setColor(color); g.fillOval(10 + point[0] * pixelsPerUnit, height - (point[1] + 1) * pixelsPerUnit, pixelsPerUnit / 2, pixelsPerUnit / 2); repaint(); }