List of usage examples for java.awt Graphics drawImage
public abstract boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer);
From source file:javazoom.jlgui.player.amp.skin.Skin.java
/** * Instantiate Volume/Balance Panel with ActiveComponent. * @param vheight/*from www. jav a2 s . c o m*/ * @param bheight */ private void setVolumeBalancePanel(int vheight, int bheight) { // Volume. acVolume = new ActiveJSlider(); acVolume.setMinimum(0); acVolume.setMaximum(VOLUMEMAX); int volumeValue = config.getVolume(); if (volumeValue < 0) volumeValue = (int) VOLUMEMAX / 2; acVolume.setValue(volumeValue); acVolume.setToolTipText(getResource("slider.volume")); int l = 0; for (int k = 0; k < volumeImage.length; k++) { //volumeImage[k] = (new Taftb(fakeIndex, imVolume, 68, 13, 2, "" + fakeIndex.charAt(k))).getBanner(); volumeImage[k] = (new Taftb(fakeIndex, imVolume, imVolume.getWidth(null), 13, 2, "" + fakeIndex.charAt(k))).getBanner(); } if (volumeImage[0].getHeight(null) > releasedVolumeImage[0].getHeight(null)) { acVolume.setConstraints(new AbsoluteConstraints(volumeBarLocation[l++], volumeBarLocation[l++], volumeImage[0].getWidth(null), volumeImage[0].getHeight(null))); } else { acVolume.setConstraints(new AbsoluteConstraints(volumeBarLocation[l++], volumeBarLocation[l++], volumeImage[0].getWidth(null), releasedVolumeImage[0].getHeight(null))); } ActiveSliderUI sUI = new ActiveSliderUI(acVolume); sUI.setThumbImage(releasedVolumeImage[0]); sUI.setThumbPressedImage(pressedVolumeImage[0]); sUI.setBackgroundImages(volumeImage); if (vheight < 0) vheight = 0; sUI.forceThumbHeight(vheight); sUI.setThumbXOffset(0); sUI.setThumbYOffset(1); acVolume.setUI(sUI); // Balance acBalance = new ActiveJSlider(); acBalance.setMinimum(-BALANCEMAX); acBalance.setMaximum(BALANCEMAX); acBalance.setValue(0); acBalance.setToolTipText(getResource("slider.balance")); Image cropBalance = new BufferedImage(38, 418, BufferedImage.TYPE_INT_RGB); Graphics g = cropBalance.getGraphics(); g.drawImage(imBalance, 0, 0, 38, 418, 9, 0, 9 + 38, 0 + 418, null); for (int k = 0; k < balanceImage.length; k++) { balanceImage[k] = (new Taftb(fakeIndex, cropBalance, 38, 13, 2, "" + fakeIndex.charAt(k))).getBanner(); } l = 0; if (balanceImage[0].getHeight(null) > releasedBalanceImage[0].getHeight(null)) { acBalance.setConstraints(new AbsoluteConstraints(balanceBarLocation[l++], balanceBarLocation[l++], balanceImage[0].getWidth(null), balanceImage[0].getHeight(null))); } else { acBalance.setConstraints(new AbsoluteConstraints(balanceBarLocation[l++], balanceBarLocation[l++], balanceImage[0].getWidth(null), releasedBalanceImage[0].getHeight(null))); } sUI = new ActiveSliderUI(acBalance); sUI.setThumbImage(releasedBalanceImage[0]); sUI.setThumbPressedImage(pressedBalanceImage[0]); sUI.setBackgroundImages(balanceImage); if (bheight < 0) bheight = 0; sUI.forceThumbHeight(bheight); sUI.setThumbXOffset(1); sUI.setThumbYOffset(1); acBalance.setUI(sUI); }
From source file:javazoom.jlgui.player.amp.Player.java
/** * Instantiate Volume/Balance Panel with ActiveComponent. * Add them to window and ActionListener. *//*ww w. j a v a 2 s . co m*/ protected void setVolumeBalancePanel(int vheight, int bheight) { // Volume. int l = 0; if (vheight > 0) acVolume = new ActiveComponent(releasedVolumeImage[0], pressedVolumeImage[0], AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK); else acVolume = new InvisibleActiveComponent(releasedVolumeImage[0], pressedVolumeImage[0], AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK); acVolume.setLocation(volumeLocation[l++], volumeLocation[l++]); add((Component) acVolume); acVolume.setActionCommand("Volume"); acVolume.addActionListener(this); for (int k = 0; k < volumeImage.length; k++) { volumeImage[k] = (new Taftb(fakeIndex, imVolume, 68, 13, 2, "" + fakeIndex.charAt(k))).getBanner(); } offScreenGraphics.drawImage( volumeImage[(int) Math.round(((double) gainValue / (double) maxGain) * (volumeImage.length - 1))], volumeBarLocation[0], volumeBarLocation[1], this); // Balance Image cropBalance = createImage(37, 418); Graphics g = cropBalance.getGraphics(); g.drawImage(imBalance, 0, 0, 37, 418, 9, 0, 9 + 37, 0 + 418, null); l = 0; if (bheight > 0) acBalance = new ActiveComponent(releasedBalanceImage[0], pressedBalanceImage[0], AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK); else acBalance = new InvisibleActiveComponent(releasedBalanceImage[0], pressedBalanceImage[0], AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK); acBalance.setLocation(balanceLocation[l++], balanceLocation[l++]); add((Component) acBalance); acBalance.setActionCommand("Balance"); acBalance.addActionListener(this); for (int k = 0; k < balanceImage.length; k++) { balanceImage[k] = (new Taftb(fakeIndex, cropBalance, 37, 13, 2, "" + fakeIndex.charAt(k))).getBanner(); } offScreenGraphics.drawImage( balanceImage[(int) Math .round(((double) Math.abs(balanceValue) / (double) 1) * (balanceImage.length - 1))], balanceBarLocation[0], balanceBarLocation[1], this); }