Example usage for java.awt Image getGraphics

List of usage examples for java.awt Image getGraphics

Introduction

In this page you can find the example usage for java.awt Image getGraphics.

Prototype

public abstract Graphics getGraphics();

Source Link

Document

Creates a graphics context for drawing to an off-screen image.

Usage

From source file:javazoom.jlgui.player.amp.skin.Skin.java

/**
 * Instantiate PosBar Panel with ActiveComponent.
 *//*from w ww .j  a v a2  s. com*/
protected void setPosBarPanel() {
    int l = 0;
    Image posBackground = new BufferedImage(248, 10, BufferedImage.TYPE_INT_RGB);
    posBackground.getGraphics().drawImage(imPosBar, 0, 0, 248, 10, 0, 0, 248, 10, null);
    acPosBar = new ActiveJSlider();
    acPosBar.setMinimum(0);
    acPosBar.setMaximum(POSBARMAX);
    acPosBar.setValue(0);
    acPosBar.setOrientation(JSlider.HORIZONTAL);
    acPosBar.setConstraints(new AbsoluteConstraints(posBarLocation[l++], posBarLocation[l++], 248,
            releasedPosIm[0].getHeight(null)));
    ActiveSliderUI sUI = new ActiveSliderUI(acPosBar);
    Image[] back = { posBackground };
    sUI.setBackgroundImages(back);
    sUI.setThumbXOffset(0);
    sUI.setThumbYOffset(0);
    sUI.setThumbImage(releasedPosIm[0]);
    sUI.setThumbPressedImage(pressedPosIm[0]);
    acPosBar.setUI(sUI);
    acPosBar.setToolTipText(getResource("slider.seek"));
}

From source file:javazoom.jlgui.player.amp.skin.Skin.java

/**
 * Instantiate Volume/Balance Panel with ActiveComponent.
 * @param vheight/*w ww.  j  a  v a  2  s .com*/
 * @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.skin.Skin.java

/**
 * Create Playlist buttons./*from   w w  w  .j  a va 2s  .c  o m*/
 * @param sx
 * @param sy
 * @return
 */
private ActiveJButton createPLButton(int sx, int sy) {
    Image normal = new BufferedImage(22, 18, BufferedImage.TYPE_INT_RGB);
    Image clicked = new BufferedImage(22, 18, BufferedImage.TYPE_INT_RGB);
    Graphics g = normal.getGraphics();
    g.drawImage(imPlaylist, 0, 0, 22, 18, sx, sy, sx + 22, sy + 18, null);
    sx += 23;
    g = clicked.getGraphics();
    g.drawImage(imPlaylist, 0, 0, 22, 18, sx, sy, sx + 22, sy + 18, null);
    ActiveJButton comp = new ActiveJButton();
    comp.setIcon(new ImageIcon(normal));
    comp.setPressedIcon(new ImageIcon(clicked));
    comp.setRolloverIcon(new ImageIcon(clicked));
    comp.setRolloverEnabled(true);
    return comp;
}

From source file:javazoom.jlgui.player.amp.skin.Skin.java

/**
 * Instantiate playlist panel.// w  w  w .  j a  va  2 s  . com
 */
public void setPlaylistPanel() {
    playlist = new PlaylistUIDelegate();
    Image titleCenter = new BufferedImage(100, 20, BufferedImage.TYPE_INT_RGB);
    titleCenter.getGraphics().drawImage(imPlaylist, 0, 0, 100, 20, 26, 0, 126, 20, null);
    playlist.setTitleCenterImage(titleCenter);
    Image titleLeft = new BufferedImage(25, 20, BufferedImage.TYPE_INT_RGB);
    titleLeft.getGraphics().drawImage(imPlaylist, 0, 0, 25, 20, 0, 0, 25, 20, null);
    playlist.setTitleLeftImage(titleLeft);
    Image titleStretch = new BufferedImage(25, 20, BufferedImage.TYPE_INT_RGB);
    titleStretch.getGraphics().drawImage(imPlaylist, 0, 0, 25, 20, 127, 0, 152, 20, null);
    playlist.setTitleStretchImage(titleStretch);
    Image titleRight = new BufferedImage(25, 20, BufferedImage.TYPE_INT_RGB);
    titleRight.getGraphics().drawImage(imPlaylist, 0, 0, 25, 20, 153, 0, 178, 20, null);
    playlist.setTitleRightImage(titleRight);
    Image btmLeft = new BufferedImage(125, 38, BufferedImage.TYPE_INT_RGB);
    btmLeft.getGraphics().drawImage(imPlaylist, 0, 0, 125, 38, 0, 72, 125, 110, null);
    playlist.setBottomLeftImage(btmLeft);
    Image btmRight = new BufferedImage(150, 38, BufferedImage.TYPE_INT_RGB);
    btmRight.getGraphics().drawImage(imPlaylist, 0, 0, 150, 38, 126, 72, 276, 110, null);
    playlist.setBottomRightImage(btmRight);
    Image bodyLeft = new BufferedImage(12, 28, BufferedImage.TYPE_INT_RGB);
    bodyLeft.getGraphics().drawImage(imPlaylist, 0, 0, 12, 28, 0, 42, 12, 70, null);
    playlist.setLeftImage(bodyLeft);
    Image bodyRight = new BufferedImage(20, 28, BufferedImage.TYPE_INT_RGB);
    bodyRight.getGraphics().drawImage(imPlaylist, 0, 0, 20, 28, 31, 42, 51, 70, null);
    playlist.setRightImage(bodyRight);
    // Parse color
    plEdit = plEdit.toLowerCase();
    ByteArrayInputStream in = new ByteArrayInputStream(plEdit.getBytes());
    BufferedReader lin = new BufferedReader(new InputStreamReader(in));
    try {
        for (;;) {
            String line = lin.readLine();
            if (line == null)
                break;
            if ((line.toLowerCase()).startsWith("normalbg"))
                playlist.setBackgroundColor(parsePlEditColor(line));
            else if ((line.toLowerCase()).startsWith("normal"))
                playlist.setNormalColor(parsePlEditColor(line));
            else if ((line.toLowerCase()).startsWith("current"))
                playlist.setCurrentColor(parsePlEditColor(line));
            else if ((line.toLowerCase()).startsWith("selectedbg"))
                playlist.setSelectedBackgroundColor(parsePlEditColor(line));
        }
    } catch (Exception e) {
        log.debug(e);
    } finally {
        try {
            if (in != null)
                in.close();
        } catch (IOException e) {
        }
    }
    // Playlist slider.
    acPlSlider = new ActiveJSlider();
    acPlSlider.setOrientation(JSlider.VERTICAL);
    acPlSlider.setMinimum(0);
    acPlSlider.setMaximum(100);
    acPlSlider.setValue(100);
    ActiveSliderUI sUI = new ActiveSliderUI(acPlSlider);
    Image scrollBarReleased = new BufferedImage(8, 18, BufferedImage.TYPE_INT_RGB);
    scrollBarReleased.getGraphics().drawImage(imPlaylist, 0, 0, 8, 18, 52, 53, 52 + 8, 53 + 18, null);
    sUI.setThumbImage(scrollBarReleased);
    Image scrollBarClicked = new BufferedImage(8, 18, BufferedImage.TYPE_INT_RGB);
    scrollBarClicked.getGraphics().drawImage(imPlaylist, 0, 0, 8, 18, 61, 53, 61 + 8, 53 + 18, null);
    sUI.setThumbPressedImage(scrollBarClicked);
    Image sliderBackground = new BufferedImage(20, 58, BufferedImage.TYPE_INT_RGB);
    sliderBackground.getGraphics().drawImage(bodyRight, 0, 0, null);
    sliderBackground.getGraphics().drawImage(bodyRight, 0, 28, null);
    sliderBackground.getGraphics().drawImage(bodyRight, 0, 30, null);
    Image[] background = { sliderBackground };
    sUI.setBackgroundImages(background);
    sUI.setThumbXOffset(5);
    acPlSlider.setUI(sUI);
    acPlSlider.setConstraints(new AbsoluteConstraints(plSliderLocation[0], plSliderLocation[1], 20, 58));
    // Up/Down scroll buttons
    acPlUp = new ActiveJButton();
    Image upScrollButton = new BufferedImage(8, 4, BufferedImage.TYPE_INT_RGB);
    upScrollButton.getGraphics().drawImage(imPlaylist, 0, 0, 8, 4, 261, 75, 269, 79, null);
    acPlUp.setIcon(new ImageIcon(upScrollButton));
    acPlUp.setPressedIcon(new ImageIcon(upScrollButton));
    acPlUp.setConstraints(new AbsoluteConstraints(WinWidth - 15, WinHeight - 35, 8, 4));
    acPlUp.setActionCommand(PlayerActionEvent.ACPLUP);
    acPlDown = new ActiveJButton();
    Image downScrollButton = new BufferedImage(8, 4, BufferedImage.TYPE_INT_RGB);
    downScrollButton.getGraphics().drawImage(imPlaylist, 0, 0, 8, 4, 261, 80, 269, 84, null);
    acPlDown.setIcon(new ImageIcon(downScrollButton));
    acPlDown.setPressedIcon(new ImageIcon(downScrollButton));
    acPlDown.setConstraints(new AbsoluteConstraints(WinWidth - 15, WinHeight - 30, 8, 4));
    acPlDown.setActionCommand(PlayerActionEvent.ACPLDOWN);
    // Playlist AddFile/AddDir/AddURL buttons
    int w = 22;
    int h = 18;
    Image addButtonImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    addButtonImage.getGraphics().drawImage(imPlaylist, 0, 0, w, h, 14, 80, 14 + w, 80 + h, null);
    acPlAdd = new ActiveJButton();
    acPlAdd.setIcon(new ImageIcon(addButtonImage));
    acPlAdd.setPressedIcon(new ImageIcon(addButtonImage));
    acPlAdd.setActionCommand(PlayerActionEvent.ACPLADDPOPUP);
    acPlAdd.setConstraints(new AbsoluteConstraints(plAddLocation[0], plAddLocation[1], w, h));
    ActiveJButton acPlAddFile = createPLButton(0, 149);
    acPlAddFile.setActionCommand(PlayerActionEvent.ACPLADDFILE);
    ActiveJButton acPlAddDir = createPLButton(0, 130);
    acPlAddDir.setActionCommand(PlayerActionEvent.ACPLADDDIR);
    ActiveJButton acPlAddURL = createPLButton(0, 111);
    acPlAddURL.setActionCommand(PlayerActionEvent.ACPLADDURL);
    acPlAddPopup = new ActiveJPopup();
    ActiveJButton[] addbuttons = { acPlAddURL, acPlAddDir, acPlAddFile };
    acPlAddPopup.setItems(addbuttons);
    acPlAddPopup.setConstraints(new AbsoluteConstraints(plAddPopupArea[0], plAddPopupArea[1], plAddPopupArea[2],
            plAddPopupArea[3]));
    // Playlist RemoveMisc/RemoveSelection/Crop/RemoveAll buttons
    Image removeButtonImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    removeButtonImage.getGraphics().drawImage(imPlaylist, 0, 0, w, h, 14 + 30, 80, 14 + 30 + w, 80 + h, null);
    acPlRemove = new ActiveJButton();
    acPlRemove.setIcon(new ImageIcon(removeButtonImage));
    acPlRemove.setPressedIcon(new ImageIcon(removeButtonImage));
    acPlRemove.setActionCommand(PlayerActionEvent.ACPLREMOVEPOPUP);
    acPlRemove.setConstraints(new AbsoluteConstraints(plRemoveLocation[0], plRemoveLocation[1], w, h));
    ActiveJButton acPlRemoveMisc = createPLButton(54, 168);
    acPlRemoveMisc.setActionCommand(PlayerActionEvent.ACPLREMOVEMISC);
    ActiveJButton acPlRemoveSel = createPLButton(54, 149);
    acPlRemoveSel.setActionCommand(PlayerActionEvent.ACPLREMOVESEL);
    ActiveJButton acPlRemoveCrop = createPLButton(54, 130);
    acPlRemoveCrop.setActionCommand(PlayerActionEvent.ACPLREMOVECROP);
    ActiveJButton acPlRemoveAll = createPLButton(54, 111);
    acPlRemoveAll.setActionCommand(PlayerActionEvent.ACPLREMOVEALL);
    acPlRemovePopup = new ActiveJPopup();
    ActiveJButton[] rembuttons = { acPlRemoveMisc, acPlRemoveAll, acPlRemoveCrop, acPlRemoveSel };
    acPlRemovePopup.setItems(rembuttons);
    acPlRemovePopup.setConstraints(new AbsoluteConstraints(plRemovePopupArea[0], plRemovePopupArea[1],
            plRemovePopupArea[2], plRemovePopupArea[3]));
    // Playlist SelAll/SelZero/SelInv buttons
    Image selButtonImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    selButtonImage.getGraphics().drawImage(imPlaylist, 0, 0, w, h, 14 + 60, 80, 14 + 60 + w, 80 + h, null);
    acPlSelect = new ActiveJButton();
    acPlSelect.setIcon(new ImageIcon(selButtonImage));
    acPlSelect.setPressedIcon(new ImageIcon(selButtonImage));
    acPlSelect.setActionCommand(PlayerActionEvent.ACPLSELPOPUP);
    acPlSelect.setConstraints(new AbsoluteConstraints(plSelectLocation[0], plSelectLocation[1], w, h));
    ActiveJButton acPlSelectAll = createPLButton(104, 149);
    acPlSelectAll.setActionCommand(PlayerActionEvent.ACPLSELALL);
    ActiveJButton acPlSelectZero = createPLButton(104, 130);
    acPlSelectZero.setActionCommand(PlayerActionEvent.ACPLSELZERO);
    ActiveJButton acPlSelectInv = createPLButton(104, 111);
    acPlSelectInv.setActionCommand(PlayerActionEvent.ACPLSELINV);
    acPlSelectPopup = new ActiveJPopup();
    ActiveJButton[] selbuttons = { acPlSelectInv, acPlSelectZero, acPlSelectAll };
    acPlSelectPopup.setItems(selbuttons);
    acPlSelectPopup.setConstraints(new AbsoluteConstraints(plSelectPopupArea[0], plSelectPopupArea[1],
            plSelectPopupArea[2], plSelectPopupArea[3]));
    // Playlist MiscOpts/MiscFile/MiscSort buttons
    Image miscButtonImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    miscButtonImage.getGraphics().drawImage(imPlaylist, 0, 0, w, h, 14 + 89, 80, 14 + 89 + w, 80 + h, null);
    acPlMisc = new ActiveJButton();
    acPlMisc.setIcon(new ImageIcon(miscButtonImage));
    acPlMisc.setPressedIcon(new ImageIcon(miscButtonImage));
    acPlMisc.setActionCommand(PlayerActionEvent.ACPLMISCPOPUP);
    acPlMisc.setConstraints(new AbsoluteConstraints(plMiscLocation[0], plMiscLocation[1], w, h));
    ActiveJButton acPlMiscOpts = createPLButton(154, 149);
    acPlMiscOpts.setActionCommand(PlayerActionEvent.ACPLMISCOPTS);
    ActiveJButton acPlMiscFile = createPLButton(154, 130);
    acPlMiscFile.setActionCommand(PlayerActionEvent.ACPLMISCFILE);
    ActiveJButton acPlMiscSort = createPLButton(154, 111);
    acPlMiscSort.setActionCommand(PlayerActionEvent.ACPLMISCSORT);
    acPlMiscPopup = new ActiveJPopup();
    ActiveJButton[] miscbuttons = { acPlMiscSort, acPlMiscFile, acPlMiscOpts };
    acPlMiscPopup.setItems(miscbuttons);
    acPlMiscPopup.setConstraints(new AbsoluteConstraints(plMiscPopupArea[0], plMiscPopupArea[1],
            plMiscPopupArea[2], plMiscPopupArea[3]));
    // Playlist ListLoad/ListSave/ListNew buttons
    Image listButtonImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    listButtonImage.getGraphics().drawImage(imPlaylist, 0, 0, w, h, 14 + 215, 80, 14 + 215 + w, 80 + h, null);
    acPlList = new ActiveJButton();
    acPlList.setIcon(new ImageIcon(listButtonImage));
    acPlList.setPressedIcon(new ImageIcon(listButtonImage));
    acPlList.setActionCommand(PlayerActionEvent.ACPLLISTPOPUP);
    acPlList.setConstraints(new AbsoluteConstraints(plListLocation[0], plListLocation[1], w, h));
    ActiveJButton acPlListLoad = createPLButton(204, 149);
    acPlListLoad.setActionCommand(PlayerActionEvent.ACPLLISTLOAD);
    ActiveJButton acPlListSave = createPLButton(204, 130);
    acPlListSave.setActionCommand(PlayerActionEvent.ACPLLISTSAVE);
    ActiveJButton acPlListNew = createPLButton(204, 111);
    acPlListNew.setActionCommand(PlayerActionEvent.ACPLLISTNEW);
    acPlListPopup = new ActiveJPopup();
    ActiveJButton[] listbuttons = { acPlListNew, acPlListSave, acPlListLoad };
    acPlListPopup.setItems(listbuttons);
    acPlListPopup.setConstraints(new AbsoluteConstraints(plListPopupArea[0], plListPopupArea[1],
            plListPopupArea[2], plListPopupArea[3]));
}

From source file:neg.JRViewer.java

protected Image getPageErrorImage() {
    Image image = new BufferedImage((int) (jasperPrint.getPageWidth() * realZoom) + 1,
            (int) (jasperPrint.getPageHeight() * realZoom) + 1, BufferedImage.TYPE_INT_RGB);

    Graphics2D grx = (Graphics2D) image.getGraphics();
    AffineTransform transform = new AffineTransform();
    transform.scale(realZoom, realZoom);
    grx.transform(transform);//w  w  w  .j  a v  a 2s.c  o  m

    drawPageError((Graphics2D) grx);

    return image;
}

From source file:cn.pholance.datamanager.common.components.JRViewer.java

protected Image getPageErrorImage() {
    Image image = new BufferedImage((int) (jasperPrint.getPageWidth() * realZoom) + 1,
            (int) (jasperPrint.getPageHeight() * realZoom) + 1, BufferedImage.TYPE_INT_RGB);

    Graphics2D grx = (Graphics2D) image.getGraphics();
    AffineTransform transform = new AffineTransform();
    transform.scale(realZoom, realZoom);
    grx.transform(transform);//from   w  w w. ja v  a2 s  .  c o m

    drawPageError(grx);

    return image;
}

From source file:forseti.JUtil.java

public static synchronized Image generarImagenMensaje(String mensaje, String nombreFuente, int tamanioFuente) {
    Frame f = new Frame();
    f.addNotify();/*from w  ww .  ja  v a  2s  . c om*/
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    env.getAvailableFontFamilyNames();
    Font fuente = new Font(nombreFuente, Font.PLAIN, tamanioFuente);
    FontMetrics medidas = f.getFontMetrics(fuente);
    int anchoMensaje = medidas.stringWidth(mensaje);
    int lineaBaseX = anchoMensaje / 10;
    int ancho = anchoMensaje + 2 * (lineaBaseX + tamanioFuente);
    int alto = tamanioFuente * 7 / 2;
    int lineaBaseY = alto * 8 / 10;
    Image imagenMensaje = f.createImage(ancho, alto);
    Graphics2D g2d = (Graphics2D) imagenMensaje.getGraphics();
    g2d.setFont(fuente);
    g2d.translate(lineaBaseX, lineaBaseY);
    g2d.setPaint(Color.lightGray);
    AffineTransform origTransform = g2d.getTransform();
    g2d.shear(-0.95, 0);
    g2d.scale(1, 3);
    g2d.drawString(mensaje, 0, 0);
    g2d.setTransform(origTransform);
    g2d.setPaint(Color.black);
    g2d.drawString(mensaje, 0, 0);

    return (imagenMensaje);
}

From source file:com.openbravo.pos.util.JRViewer400.java

protected Image getPageErrorImage() {
    PrintPageFormat pageFormat = getPageFormat();
    Image image = new BufferedImage((int) (pageFormat.getPageWidth() * realZoom) + 1,
            (int) (pageFormat.getPageHeight() * realZoom) + 1, BufferedImage.TYPE_INT_RGB);

    Graphics2D grx = (Graphics2D) image.getGraphics();
    AffineTransform transform = new AffineTransform();
    transform.scale(realZoom, realZoom);
    grx.transform(transform);/*from w  ww .j  a v  a  2s. c o  m*/

    drawPageError(grx);

    return image;
}

From source file:javazoom.jlgui.player.amp.Player.java

/**
 * Instantiate Volume/Balance Panel with ActiveComponent.
 * Add them to window and ActionListener.
 *//*from   w w w.  j av  a  2  s.c  o  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);
}

From source file:FourByFour.java

public void setBuffer(Image backbuffer) {
    this.backbuffer = backbuffer;
    gc = backbuffer.getGraphics();
}