List of usage examples for java.awt Graphics drawImage
public abstract boolean drawImage(Image img, int x, int y, ImageObserver observer);
From source file:uk.co.modularaudio.mads.base.soundfile_player.ui.SoundfilePlayerWaveOverviewUiJComponent.java
@Override public void paintComponent(final Graphics g) { // log.trace("WaveOverview paint() called"); final int xWaveOffset = WAVE_OVERVIEW_BORDER_PIXELS + WAVE_OVERVIEW_INTRO_PIXELS; g.setColor(SoundfilePlayerColorDefines.WAVE_DISPLAY_BACKGROUND_COLOR); g.fillRect(1, 1, lastWidth - 1, lastHeight - 1); g.setColor(SoundfilePlayerColorDefines.WAVE_DISPLAY_BORDER_COLOR); g.drawRect(0, 0, lastWidth, lastHeight); if (staticThumbnail != null) { g.drawImage(staticThumbnail, xWaveOffset, WAVE_OVERVIEW_BORDER_PIXELS, null); } else {// ww w .ja v a2s .c o m g.setColor(SoundfilePlayerColorDefines.WAVE_DISPLAY_WAVE_BG_COLOR); g.fillRect(xWaveOffset, WAVE_OVERVIEW_BORDER_PIXELS, lastOverviewWidth, lastOverviewHeight); if (internalPercentComplete >= 0) { g.setColor(SoundfilePlayerColorDefines.WAVE_DISPLAY_WAVE_FG_COLOR); final int yOffset = WAVE_OVERVIEW_BORDER_PIXELS + (lastOverviewHeight / 2); final int widthOfLine = (lastOverviewWidth * internalPercentComplete) / 100; g.drawLine(xWaveOffset, yOffset, xWaveOffset + widthOfLine, yOffset); } } g.setColor(SoundfilePlayerColorDefines.WAVE_DISPLAY_CURRENT_POSITION_COLOUR); final int actualPos = xWaveOffset + desiredNormalisedPositionPixel; g.drawLine(actualPos, WAVE_OVERVIEW_BORDER_PIXELS, actualPos, lastOverviewHeight); displayedNormalisedPositionPixel = desiredNormalisedPositionPixel; }
From source file:Bouncer.java
protected void render() { Graphics g = getGraphics(); if (g != null) { Dimension d = getSize();// w w w . ja va 2 s . co m if (checkImage(d)) { Graphics imageGraphics = image.getGraphics(); imageGraphics.setColor(getBackground()); imageGraphics.fillRect(0, 0, d.width, d.height); imageGraphics.setColor(getForeground()); paint(imageGraphics); g.drawImage(image, 0, 0, null); imageGraphics.dispose(); } g.dispose(); } }
From source file:de.betterform.agent.betty.Betty.java
public void paint(Graphics g) { tr = new MediaTracker(this); img = getImage(getCodeBase(), "../resources/images/betterform_icon16x16.png"); tr.addImage(img, 0);// w w w .j av a 2s .c om g.drawImage(img, 0, 0, this); }
From source file:it.geosolutions.opensdi2.mvc.BaseFileManager.java
/** * Generate a image thumb/* www. j a v a 2 s .c o m*/ * * @param toServeUp * @param thumbPath * @return * @throws IOException */ protected InputStream getImageThumb(File toServeUp, String thumbPath) throws IOException { BufferedImage image = ImageIO.read(toServeUp); ImageIcon img = new ImageIcon( new ImageIcon(image).getImage().getScaledInstance(THUMB_W, THUMB_H, Image.SCALE_FAST)); BufferedImage bimage = new BufferedImage(THUMB_W, THUMB_H, BufferedImage.TYPE_INT_RGB); // Copy image to buffered image Graphics g = bimage.createGraphics(); g.drawImage(img.getImage(), 0, 0, null); g.dispose(); ImageIO.write(bimage, "jpg", new File(thumbPath)); return new java.io.FileInputStream(thumbPath); }
From source file:javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer.java
public void paintComponent(Graphics pGraphics) { if (displayMode == DISPLAY_MODE_OFF) return;//from w w w . jav a 2s .co m if (dspStarted) { pGraphics.drawImage(getDoubleBuffer(), 0, 0, null); } else { super.paintComponent(pGraphics); } }
From source file:se.llbit.chunky.resources.Texture.java
public void setTexture(BufferedImage newImage) { if (newImage.getType() == BufferedImage.TYPE_INT_ARGB) { image = newImage;/* ww w . j a va 2s .com*/ } else { // convert to ARGB image = new BufferedImage(newImage.getWidth(), newImage.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = image.createGraphics(); g.drawImage(newImage, 0, 0, null); g.dispose(); } // gamma correct the texture avgColorLinear = new float[] { 0, 0, 0, 0 }; DataBufferInt dataBuffer = (DataBufferInt) image.getRaster().getDataBuffer(); int[] data = dataBuffer.getData(); width = image.getWidth(); height = image.getHeight(); linear = new float[width * height][4]; for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { int index = width * y + x; Color.getRGBAComponents(data[index], linear[index]); linear[index][0] = (float) FastMath.pow(linear[index][0], Scene.DEFAULT_GAMMA); linear[index][1] = (float) FastMath.pow(linear[index][1], Scene.DEFAULT_GAMMA); linear[index][2] = (float) FastMath.pow(linear[index][2], Scene.DEFAULT_GAMMA); avgColorLinear[0] += linear[index][3] * linear[index][0]; avgColorLinear[1] += linear[index][3] * linear[index][1]; avgColorLinear[2] += linear[index][3] * linear[index][2]; avgColorLinear[3] += linear[index][3]; } } if (PersistentSettings.getSingleColorTextures()) { float[] avgColorFlat = { 0, 0, 0 }; if (avgColorLinear[3] > 0.001) { avgColorFlat[0] = avgColorLinear[0] / avgColorLinear[3]; avgColorFlat[1] = avgColorLinear[1] / avgColorLinear[3]; avgColorFlat[2] = avgColorLinear[2] / avgColorLinear[3]; } for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { int index = width * y + x; linear[index][0] = avgColorFlat[0]; linear[index][1] = avgColorFlat[1]; linear[index][2] = avgColorFlat[2]; linear[index][3] = 1; } } } avgColorLinear[0] /= width * height; avgColorLinear[1] /= width * height; avgColorLinear[2] /= width * height; avgColorLinear[3] /= width * height; avgColor = Color.getRGBA(FastMath.pow(avgColorLinear[0], 1 / Scene.DEFAULT_GAMMA), FastMath.pow(avgColorLinear[1], 1 / Scene.DEFAULT_GAMMA), FastMath.pow(avgColorLinear[2], 1 / Scene.DEFAULT_GAMMA), avgColorLinear[3]); }
From source file:width.java
/** * Paint it.//from w ww .j av a 2 s.c o m */ public void paint(Graphics g) { Dimension d = getSize(); g.setColor(Color.black); int xoff = d.width / 3; int yoff = d.height / 3; g.drawLine(xoff, 0, xoff, d.height); g.drawLine(2 * xoff, 0, 2 * xoff, d.height); g.drawLine(0, yoff, d.width, yoff); g.drawLine(0, 2 * yoff, d.width, 2 * yoff); int i = 0; for (int r = 0; r < 3; r++) { for (int c = 0; c < 3; c++, i++) { if ((white & (1 << i)) != 0) { g.drawImage(notImage, c * xoff + 1, r * yoff + 1, this); } else if ((black & (1 << i)) != 0) { g.drawImage(crossImage, c * xoff + 1, r * yoff + 1, this); } } } }
From source file:edu.ku.brc.specify.utilapps.ERDTable.java
public void paint(Graphics g) { if (!ERDVisualizer.isDoShadow()) { super.paint(g); } else {//from w w w . j av a 2 s. c o m if (shadowBuffer == null) { getBackgroundImageBuffer(); Graphics gg = shadowBuffer.createGraphics(); //gg.translate(5, 5); inner.paint(gg); gg.dispose(); } g.drawImage(shadowBuffer, 0, 0, null); } }
From source file:TextBouncer.java
protected void render() { Graphics g = getGraphics(); if (g != null) { Dimension d = getSize();/* w ww . j a v a2 s. co m*/ if (checkImage(d)) { Graphics imageGraphics = image.getGraphics(); // Clear the image background. imageGraphics.setColor(getBackground()); imageGraphics.fillRect(0, 0, d.width, d.height); imageGraphics.setColor(getForeground()); // Draw this component offscreen. paint(imageGraphics); // Now put the offscreen image on the screen. g.drawImage(image, 0, 0, null); // Clean up. imageGraphics.dispose(); } g.dispose(); } }
From source file:uk.co.modularaudio.service.guicompfactory.impl.RealComponentFront.java
@Override public void paintComponent(final Graphics g) { super.paintComponent(g); final int imageWidth = frontBufferedImage.getWidth(); final int imageHeight = frontBufferedImage.getHeight(); final int width = getWidth(); // Hack since I duffed up the heights due to border. final int height = getHeight() + 8; if (imageWidth != width || imageHeight != height) { final StringBuilder sb = new StringBuilder("Component "); sb.append(rc.getInstance().getDefinition().getId()); sb.append(" has badly sized front image: ("); sb.append(imageWidth);// www. java 2 s.c o m sb.append(", "); sb.append(imageHeight); sb.append(") - component size("); sb.append(width); sb.append(", "); sb.append(height); sb.append(")"); final String msg = sb.toString(); log.warn(msg); } g.drawImage(frontBufferedImage, 0, 0, null); }