Example usage for org.lwjgl.opengl GL11 glScaled

List of usage examples for org.lwjgl.opengl GL11 glScaled

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glScaled.

Prototype

public static native void glScaled(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y,
        @NativeType("GLdouble") double z);

Source Link

Document

Double version of #glScalef Scalef .

Usage

From source file:adrianton.gloptat.plotter.Displayer.java

License:Open Source License

private void surface() {
    GL11.glLoadIdentity();//from ww  w .  java 2  s .com

    GL11.glTranslatef(posx, posy, posz);

    GL11.glRotatef(roty, 1, 0, 0);
    GL11.glRotatef(rotz, 0, 0, 1);

    GL11.glScaled(0.3, 0.3, 0.3);
    GL11.glScaled(pasz, pasz, pasz);

    Surface.call();
}

From source file:adrianton.gloptat.plotter.Displayer.java

License:Open Source License

private void pointers() {
    if (pointers != null) {
        float spx = -rezx / 2f;
        float spy = -rezy / 2f;
        float tmpx, tmpy;
        float rapx, rapy;
        int tmpi, tmpj;

        rapx = rezx / (float) (dom.d[0].r - dom.d[0].l);
        rapy = rezy / (float) (dom.d[1].r - dom.d[1].l);

        int i;// w  w  w .j  av a  2s.  c  om
        for (i = 0; i < pointers.length; i++) {
            tmpx = spx + (float) (pointers[i][0] - dom.d[0].l) * rapx;
            tmpy = spy + (float) (pointers[i][1] - dom.d[1].l) * rapy;

            tmpi = (int) ((pointers[i][0] - dom.d[0].l) * rapx); // should interpolate
            tmpj = (int) ((pointers[i][1] - dom.d[1].l) * rapy);

            tmpi = Math.min(Math.max(0, tmpi), rezx - 1);
            tmpj = Math.min(Math.max(0, tmpj), rezy - 1);

            if (dom.in(pointers[i])) {
                GL11.glPushMatrix();
                GL11.glTranslatef(tmpx, tmpy, (float) (val[tmpi][tmpj]));
                GL11.glScaled(1.1, 1.1, 0.5);
                Pointer.call();
                GL11.glPopMatrix();
            }
        }
    }
}

From source file:allout58.mods.techtree.client.elements.GuiButtonEditNode.java

License:Open Source License

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
    if (this.visible) {
        FontRenderer fontRenderer = mc.fontRenderer;
        boolean mouseOver = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width
                && mouseY < yPosition + height;

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + height,
                Config.INSTANCE.client.colorBtnUnlocked1, Config.INSTANCE.client.colorBtnUnlocked2);

        if (isSelected) {
            drawRect(xPosition - 1, yPosition - 1, xPosition + width + 1, yPosition + height + 1, 0x99101010);
        }//from   ww w  . j a v a 2s .  c  o  m

        if (mouseOver) {
            drawRect(xPosition - 2, yPosition - 2, xPosition + width + 2, yPosition + height + 2, 0x30FFFFFF);
        }

        GL11.glPushMatrix();

        GL11.glScaled(0.75, 0.75, 0.75);
        GL11.glTranslated(xPosition * .33, yPosition * .33, 0);
        fontRenderer.drawString(node.getName(), xPosition + 2, yPosition + 2,
                Config.INSTANCE.client.colorBtnText, true);

        GL11.glPopMatrix();

        this.mouseDragged(mc, mouseX, mouseY);
    }
}

From source file:allout58.mods.techtree.client.elements.GuiButtonTechNode.java

License:Open Source License

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
    if (this.visible) {
        try {/*from w  w  w  . j av  a 2 s.  co  m*/
            bar.setMax((float) (ResearchClient.getInstance().getResearch(node.getId()))
                    / (float) (node.getScienceRequired()));
        } catch (Exception e) {
            e.printStackTrace();
        }

        FontRenderer fontRenderer = mc.fontRenderer;
        boolean mouseOver = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width
                && mouseY < yPosition + height;

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        String playerUUID = FMLClientHandler.instance().getClient().thePlayer.getUniqueID().toString();

        switch (ResearchClient.getInstance(playerUUID).getMode(node.getId())) {
        case Locked:
            drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + height,
                    Config.INSTANCE.client.colorBtnLocked1, Config.INSTANCE.client.colorBtnLocked2);
            break;
        case Unlocked:
            drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + height,
                    Config.INSTANCE.client.colorBtnUnlocked1, Config.INSTANCE.client.colorBtnUnlocked2);
            try {
                bar.setEnabled(ResearchClient.getInstance().getResearch(node.getId()) > 0);
            } catch (Exception e) {
                e.printStackTrace();
            }
            break;
        case Researching:
            drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + height,
                    Config.INSTANCE.client.colorBtnResearch1, Config.INSTANCE.client.colorBtnResearch2);
            bar.setEnabled(true);
            break;
        case Completed:
            drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + height,
                    Config.INSTANCE.client.colorBtnCompleted1, Config.INSTANCE.client.colorBtnCompleted2);
            bar.setEnabled(false);
            break;
        default:
            System.err.println("ERROR! Invalid button state! o.O");
        }

        if (mouseOver) {
            drawRect(xPosition - 1, yPosition - 1, xPosition + width + 1, yPosition + height + 1, 0x30FFFFFF);
        }

        GL11.glPushMatrix();

        GL11.glScaled(0.75, 0.75, 0.75);
        GL11.glTranslated(xPosition * .33, yPosition * .33, 0);
        fontRenderer.drawString(node.getName(), xPosition + 2, yPosition + 2,
                Config.INSTANCE.client.colorBtnText, true);

        GL11.glPopMatrix();

        GL11.glPushMatrix();
        GL11.glScaled(.5, .5, .5);
        GL11.glTranslated(xPosition, yPosition, 0);
        fontRenderer.drawString(ResearchClient.getInstance(playerUUID).getMode(node.getId()).name(),
                xPosition + 2, yPosition + 10 + fontRenderer.FONT_HEIGHT, Config.INSTANCE.client.colorBtnText,
                false);
        GL11.glPopMatrix();

        GL11.glPushMatrix();
        GL11.glScaled(1, 1, 1);
        bar.doRender();
        GL11.glPopMatrix();

        this.mouseDragged(mc, mouseX, mouseY);
    }
}

From source file:allout58.mods.techtree.client.GuiEditTree2.java

License:Open Source License

@SuppressWarnings("unchecked")
protected void drawOverlay(int mouseX, int mouseY) {
    for (AbstractGuiButtonNode btn : buttons.values()) {
        if (btn.mousePressed(this.mc, mouseX, mouseY)) {
            int w = Math.max(fontRendererObj.getStringWidth(btn.getNode().getName()) + 20, 100);
            int h = (int) ((fontRendererObj.listFormattedStringToWidth(btn.getNode().getDescription(), w).size()
                    + 1) * fontRendererObj.FONT_HEIGHT * 0.5 + fontRendererObj.FONT_HEIGHT + 35);
            if (mouseX > width / 2) {
                mouseX -= w;// ww  w . java  2  s .  c  o  m
            }

            try {
                RenderingHelper.drawRoundedRectangle(mouseX + 2, mouseY + 2, w, h, 7,
                        Config.INSTANCE.client.colorOverlayBackground);
                fontRendererObj.drawString(btn.getNode().getName(), mouseX + 2 + 6, mouseY + 2 + 6,
                        Config.INSTANCE.client.colorOverlayText, true);
                drawHorizontalLine(mouseX + 7, mouseX + w - 7, mouseY + 10 + fontRendererObj.FONT_HEIGHT,
                        Config.INSTANCE.client.colorOverlayOther);

                GL11.glPushMatrix();
                GL11.glScaled(0.5, 0.5, 0);
                GL11.glTranslated(mouseX, mouseY, 0);
                fontRendererObj.drawString(
                        StatCollector.translateToLocalFormatted("gui.scienceRequired",
                                btn.getNode().getScienceRequired()),
                        mouseX + 14, mouseY + 17 + fontRendererObj.FONT_HEIGHT * 3,
                        Config.INSTANCE.client.colorOverlayText);
                fontRendererObj.drawSplitString(btn.getNode().getDescription(), mouseX + 14,
                        mouseY + 22 + fontRendererObj.FONT_HEIGHT * 4, w * 2 - 10,
                        Config.INSTANCE.client.colorOverlayText);
                GL11.glPopMatrix();

                for (int i = 0; i < btn.getNode().getLockedItems().length; i++) {
                    GL11.glDisable(GL11.GL_ALPHA_TEST);
                    GL11.glDisable(GL11.GL_LIGHTING);
                    drawRect(mouseX + 14 + 18 * i, mouseY + h - 18, mouseX + 30 + 18 * i, mouseY + h - 2,
                            0xFFB0B0B0);
                    itemRender.renderItemIntoGUI(fontRendererObj, Minecraft.getMinecraft().renderEngine,
                            btn.getNode().getLockedItems()[i], mouseX + 14 + 18 * i, mouseY + h - 18);
                }

            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:allout58.mods.techtree.client.GuiTree.java

License:Open Source License

@SuppressWarnings("unchecked")
protected void drawOverlay(int mouseX, int mouseY) {
    for (AbstractGuiButtonNode btn : buttons.values()) {
        if (btn.mousePressed(this.mc, mouseX, mouseY)) {
            int w = Math.max(fontRendererObj.getStringWidth(btn.getNode().getName()) + 20, 100);
            int h = (int) ((fontRendererObj.listFormattedStringToWidth(btn.getNode().getDescription(), w).size()
                    + 1) * fontRendererObj.FONT_HEIGHT * 0.5 + fontRendererObj.FONT_HEIGHT + 35);
            if (mouseX < width / 2) {
                mouseX -= w;/*from   www. j a  v  a  2 s.c  o  m*/
            }

            try {
                RenderingHelper.drawRoundedRectangle(mouseX + 2, mouseY + 2, w, h, 7,
                        Config.INSTANCE.client.colorOverlayBackground);
                fontRendererObj.drawString(btn.getNode().getName(), mouseX + 2 + 6, mouseY + 2 + 6,
                        Config.INSTANCE.client.colorOverlayText, true);
                drawHorizontalLine(mouseX + 7, mouseX + w - 7, mouseY + 10 + fontRendererObj.FONT_HEIGHT,
                        Config.INSTANCE.client.colorOverlayOther);

                GL11.glPushMatrix();
                GL11.glScaled(0.5, 0.5, 0);
                GL11.glTranslated(mouseX, mouseY, 0);
                fontRendererObj.drawString(
                        StatCollector.translateToLocalFormatted("gui.scienceRequired",
                                btn.getNode().getScienceRequired()),
                        mouseX + 14, mouseY + 17 + fontRendererObj.FONT_HEIGHT * 3,
                        Config.INSTANCE.client.colorOverlayText);
                fontRendererObj.drawSplitString(btn.getNode().getDescription(), mouseX + 14,
                        mouseY + 22 + fontRendererObj.FONT_HEIGHT * 4, w * 2 - 10,
                        Config.INSTANCE.client.colorOverlayText);
                GL11.glPopMatrix();

                for (int i = 0; i < btn.getNode().getLockedItems().length; i++) {
                    GL11.glDisable(GL11.GL_ALPHA_TEST);
                    GL11.glDisable(GL11.GL_LIGHTING);
                    drawRect(mouseX + 14 + 18 * i, mouseY + h - 18, mouseX + 30 + 18 * i, mouseY + h - 2,
                            0xFFB0B0B0);
                    itemRender.renderItemIntoGUI(fontRendererObj, Minecraft.getMinecraft().renderEngine,
                            btn.getNode().getLockedItems()[i], mouseX + 14 + 18 * i, mouseY + h - 18);
                }

            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:appeng.client.gui.implementations.GuiCraftConfirm.java

License:Open Source License

@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
    final long BytesUsed = this.ccc.getUsedBytes();
    final String byteUsed = NumberFormat.getInstance().format(BytesUsed);
    final String Add = BytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal())
            : GuiText.CalculatingWait.getLocal();
    this.fontRendererObj.drawString(GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752);

    String dsp = null;//  w  ww  .  j av  a  2s .  co  m

    if (this.isSimulation()) {
        dsp = GuiText.Simulation.getLocal();
    } else {
        dsp = this.ccc.getCpuAvailableBytes() > 0
                ? (GuiText.Bytes.getLocal() + ": " + this.ccc.getCpuAvailableBytes() + " : "
                        + GuiText.CoProcessors.getLocal() + ": " + this.ccc.getCpuCoProcessors())
                : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
    }

    final int offset = (219 - this.fontRendererObj.getStringWidth(dsp)) / 2;
    this.fontRendererObj.drawString(dsp, offset, 165, 4210752);

    final int sectionLength = 67;

    int x = 0;
    int y = 0;
    final int xo = 9;
    final int yo = 22;
    final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
    final int viewEnd = viewStart + 3 * this.rows;

    String dspToolTip = "";
    final List<String> lineList = new LinkedList<String>();
    int toolPosX = 0;
    int toolPosY = 0;

    final int offY = 23;

    for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) {
        final IAEItemStack refStack = this.visual.get(z);// repo.getReferenceItem( z );
        if (refStack != null) {
            GL11.glPushMatrix();
            GL11.glScaled(0.5, 0.5, 0.5);

            final IAEItemStack stored = this.storage.findPrecise(refStack);
            final IAEItemStack pendingStack = this.pending.findPrecise(refStack);
            final IAEItemStack missingStack = this.missing.findPrecise(refStack);

            int lines = 0;

            if (stored != null && stored.getStackSize() > 0) {
                lines++;
            }
            if (pendingStack != null && pendingStack.getStackSize() > 0) {
                lines++;
            }
            if (pendingStack != null && pendingStack.getStackSize() > 0) {
                lines++;
            }

            final int negY = ((lines - 1) * 5) / 2;
            int downY = 0;

            if (stored != null && stored.getStackSize() > 0) {
                String str = Long.toString(stored.getStackSize());
                if (stored.getStackSize() >= 10000) {
                    str = Long.toString(stored.getStackSize() / 1000) + 'k';
                }
                if (stored.getStackSize() >= 10000000) {
                    str = Long.toString(stored.getStackSize() / 1000000) + 'm';
                }

                str = GuiText.FromStorage.getLocal() + ": " + str;
                final int w = 4 + this.fontRendererObj.getStringWidth(str);
                this.fontRendererObj.drawString(str,
                        (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
                        (y * offY + yo + 6 - negY + downY) * 2, 4210752);

                if (this.tooltip == z - viewStart) {
                    lineList.add(GuiText.FromStorage.getLocal() + ": " + Long.toString(stored.getStackSize()));
                }

                downY += 5;
            }

            boolean red = false;
            if (missingStack != null && missingStack.getStackSize() > 0) {
                String str = Long.toString(missingStack.getStackSize());
                if (missingStack.getStackSize() >= 10000) {
                    str = Long.toString(missingStack.getStackSize() / 1000) + 'k';
                }
                if (missingStack.getStackSize() >= 10000000) {
                    str = Long.toString(missingStack.getStackSize() / 1000000) + 'm';
                }

                str = GuiText.Missing.getLocal() + ": " + str;
                final int w = 4 + this.fontRendererObj.getStringWidth(str);
                this.fontRendererObj.drawString(str,
                        (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
                        (y * offY + yo + 6 - negY + downY) * 2, 4210752);

                if (this.tooltip == z - viewStart) {
                    lineList.add(
                            GuiText.Missing.getLocal() + ": " + Long.toString(missingStack.getStackSize()));
                }

                red = true;
                downY += 5;
            }

            if (pendingStack != null && pendingStack.getStackSize() > 0) {
                String str = Long.toString(pendingStack.getStackSize());
                if (pendingStack.getStackSize() >= 10000) {
                    str = Long.toString(pendingStack.getStackSize() / 1000) + 'k';
                }
                if (pendingStack.getStackSize() >= 10000000) {
                    str = Long.toString(pendingStack.getStackSize() / 1000000) + 'm';
                }

                str = GuiText.ToCraft.getLocal() + ": " + str;
                final int w = 4 + this.fontRendererObj.getStringWidth(str);
                this.fontRendererObj.drawString(str,
                        (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
                        (y * offY + yo + 6 - negY + downY) * 2, 4210752);

                if (this.tooltip == z - viewStart) {
                    lineList.add(
                            GuiText.ToCraft.getLocal() + ": " + Long.toString(pendingStack.getStackSize()));
                }
            }

            GL11.glPopMatrix();
            final int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
            final int posY = y * offY + yo;

            final ItemStack is = refStack.copy().getItemStack();

            if (this.tooltip == z - viewStart) {
                dspToolTip = Platform.getItemDisplayName(is);

                if (lineList.size() > 0) {
                    dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
                }

                toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
                toolPosY = y * offY + yo;
            }

            this.drawItem(posX, posY, is);

            if (red) {
                final int startX = x * (1 + sectionLength) + xo;
                final int startY = posY - 4;
                drawRect(startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000);
            }

            x++;

            if (x > 2) {
                y++;
                x = 0;
            }
        }
    }

    if (this.tooltip >= 0 && dspToolTip.length() > 0) {
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        this.drawTooltip(toolPosX, toolPosY + 10, 0, dspToolTip);
        GL11.glPopAttrib();
    }
}

From source file:appeng.client.gui.implementations.GuiCraftingCPU.java

License:Open Source License

@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
    String title = this.getGuiDisplayName(GuiText.CraftingStatus.getLocal());

    if (this.craftingCpu.getEstimatedTime() > 0 && !this.visual.isEmpty()) {
        final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert(this.craftingCpu.getEstimatedTime(),
                TimeUnit.NANOSECONDS);
        final String etaTimeText = DurationFormatUtils.formatDuration(etaInMilliseconds,
                GuiText.ETAFormat.getLocal());
        title += " - " + etaTimeText;
    }/*from w  ww.  ja v a2 s  .  co  m*/

    this.fontRendererObj.drawString(title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR);

    int x = 0;
    int y = 0;
    final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
    final int viewEnd = viewStart + 3 * 6;

    String dspToolTip = "";
    final List<String> lineList = new LinkedList<String>();
    int toolPosX = 0;
    int toolPosY = 0;

    final int offY = 23;

    final ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE;
    for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) {
        final IAEItemStack refStack = this.visual.get(z);// repo.getReferenceItem( z );
        if (refStack != null) {
            GL11.glPushMatrix();
            GL11.glScaled(0.5, 0.5, 0.5);

            final IAEItemStack stored = this.storage.findPrecise(refStack);
            final IAEItemStack activeStack = this.active.findPrecise(refStack);
            final IAEItemStack pendingStack = this.pending.findPrecise(refStack);

            int lines = 0;

            if (stored != null && stored.getStackSize() > 0) {
                lines++;
            }
            boolean active = false;
            if (activeStack != null && activeStack.getStackSize() > 0) {
                lines++;
                active = true;
            }
            boolean scheduled = false;
            if (pendingStack != null && pendingStack.getStackSize() > 0) {
                lines++;
                scheduled = true;
            }

            if (AEConfig.instance.useColoredCraftingStatus && (active || scheduled)) {
                final int bgColor = (active ? AEColor.Green.blackVariant : AEColor.Yellow.blackVariant)
                        | BACKGROUND_ALPHA;
                final int startX = (x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET) * 2;
                final int startY = ((y * offY + ITEMSTACK_TOP_OFFSET) - 3) * 2;
                drawRect(startX, startY, startX + (SECTION_LENGTH * 2), startY + (offY * 2) - 2, bgColor);
            }

            final int negY = ((lines - 1) * 5) / 2;
            int downY = 0;

            if (stored != null && stored.getStackSize() > 0) {
                final String str = GuiText.Stored.getLocal() + ": "
                        + converter.toWideReadableForm(stored.getStackSize());
                final int w = 4 + this.fontRendererObj.getStringWidth(str);
                this.fontRendererObj.drawString(str,
                        (int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19
                                - (w * 0.5)) * 2),
                        (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);

                if (this.tooltip == z - viewStart) {
                    lineList.add(GuiText.Stored.getLocal() + ": " + Long.toString(stored.getStackSize()));
                }

                downY += 5;
            }

            if (activeStack != null && activeStack.getStackSize() > 0) {
                final String str = GuiText.Crafting.getLocal() + ": "
                        + converter.toWideReadableForm(activeStack.getStackSize());
                final int w = 4 + this.fontRendererObj.getStringWidth(str);

                this.fontRendererObj.drawString(str,
                        (int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19
                                - (w * 0.5)) * 2),
                        (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);

                if (this.tooltip == z - viewStart) {
                    lineList.add(
                            GuiText.Crafting.getLocal() + ": " + Long.toString(activeStack.getStackSize()));
                }

                downY += 5;
            }

            if (pendingStack != null && pendingStack.getStackSize() > 0) {
                final String str = GuiText.Scheduled.getLocal() + ": "
                        + converter.toWideReadableForm(pendingStack.getStackSize());
                final int w = 4 + this.fontRendererObj.getStringWidth(str);

                this.fontRendererObj.drawString(str,
                        (int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19
                                - (w * 0.5)) * 2),
                        (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);

                if (this.tooltip == z - viewStart) {
                    lineList.add(
                            GuiText.Scheduled.getLocal() + ": " + Long.toString(pendingStack.getStackSize()));
                }
            }

            GL11.glPopMatrix();
            final int posX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
            final int posY = y * offY + ITEMSTACK_TOP_OFFSET;

            final ItemStack is = refStack.copy().getItemStack();

            if (this.tooltip == z - viewStart) {
                dspToolTip = Platform.getItemDisplayName(is);

                if (lineList.size() > 0) {
                    dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
                }

                toolPosX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8;
                toolPosY = y * offY + ITEMSTACK_TOP_OFFSET;
            }

            this.drawItem(posX, posY, is);

            x++;

            if (x > 2) {
                y++;
                x = 0;
            }
        }
    }

    if (this.tooltip >= 0 && dspToolTip.length() > 0) {
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        this.drawTooltip(toolPosX, toolPosY + 10, 0, dspToolTip);
        GL11.glPopAttrib();
    }
}

From source file:appeng.client.gui.implementations.GuiNetworkStatus.java

License:Open Source License

@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
    final ContainerNetworkStatus ns = (ContainerNetworkStatus) this.inventorySlots;

    this.fontRendererObj.drawString(GuiText.NetworkDetails.getLocal(), 8, 6, 4210752);

    this.fontRendererObj.drawString(
            GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong(ns.getCurrentPower(), false), 13,
            16, 4210752);//from ww w  .  j  a  va2s . c  o m
    this.fontRendererObj.drawString(
            GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong(ns.getMaxPower(), false), 13, 26,
            4210752);

    this.fontRendererObj.drawString(
            GuiText.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong(ns.getAverageAddition(), true),
            13, 143 - 10, 4210752);
    this.fontRendererObj.drawString(
            GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong(ns.getPowerUsage(), true), 13,
            143 - 20, 4210752);

    final int sectionLength = 30;

    int x = 0;
    int y = 0;
    final int xo = 12;
    final int yo = 42;
    final int viewStart = 0;// myScrollBar.getCurrentScroll() * 5;
    final int viewEnd = viewStart + 5 * 4;

    String toolTip = "";
    int toolPosX = 0;
    int toolPosY = 0;

    for (int z = viewStart; z < Math.min(viewEnd, this.repo.size()); z++) {
        final IAEItemStack refStack = this.repo.getReferenceItem(z);
        if (refStack != null) {
            GL11.glPushMatrix();
            GL11.glScaled(0.5, 0.5, 0.5);

            String str = Long.toString(refStack.getStackSize());
            if (refStack.getStackSize() >= 10000) {
                str = Long.toString(refStack.getStackSize() / 1000) + 'k';
            }

            final int w = this.fontRendererObj.getStringWidth(str);
            this.fontRendererObj.drawString(str,
                    (int) ((x * sectionLength + xo + sectionLength - 19 - (w * 0.5)) * 2),
                    (y * 18 + yo + 6) * 2, 4210752);

            GL11.glPopMatrix();
            final int posX = x * sectionLength + xo + sectionLength - 18;
            final int posY = y * 18 + yo;

            if (this.tooltip == z - viewStart) {
                toolTip = Platform.getItemDisplayName(this.repo.getItem(z));

                toolTip += ('\n' + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
                if (refStack.getCountRequestable() > 0) {
                    toolTip += ('\n' + GuiText.EnergyDrain.getLocal() + ": "
                            + Platform.formatPowerLong(refStack.getCountRequestable(), true));
                }

                toolPosX = x * sectionLength + xo + sectionLength - 8;
                toolPosY = y * 18 + yo;
            }

            this.drawItem(posX, posY, this.repo.getItem(z));

            x++;

            if (x > 4) {
                y++;
                x = 0;
            }
        }
    }

    if (this.tooltip >= 0 && toolTip.length() > 0) {
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        this.drawTooltip(toolPosX, toolPosY + 10, 0, toolTip);
        GL11.glPopAttrib();
    }
}

From source file:appeng.client.render.AppEngRenderItem.java

License:Open Source License

@Override
public void renderItemOverlayIntoGUI(final FontRenderer fontRenderer, final TextureManager textureManager,
        final ItemStack is, final int par4, final int par5, final String par6Str) {
    if (is != null) {
        final float scaleFactor = AEConfig.instance.useTerminalUseLargeFont() ? 0.85f : 0.5f;
        final float inverseScaleFactor = 1.0f / scaleFactor;
        final int offset = AEConfig.instance.useTerminalUseLargeFont() ? 0 : -1;

        final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
        fontRenderer.setUnicodeFlag(false);

        if (is.getItem().showDurabilityBar(is)) {
            final double health = is.getItem().getDurabilityForDisplay(is);
            final int j1 = (int) Math.round(13.0D - health * 13.0D);
            final int k = (int) Math.round(255.0D - health * 255.0D);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_ALPHA_TEST);
            GL11.glDisable(GL11.GL_BLEND);
            final Tessellator tessellator = Tessellator.instance;
            final int l = 255 - k << 16 | k << 8;
            final int i1 = (255 - k) / 4 << 16 | 16128;
            this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0);
            this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, i1);
            this.renderQuad(tessellator, par4 + 2, par5 + 13, j1, 1, l);
            GL11.glEnable(GL11.GL_ALPHA_TEST);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_DEPTH_TEST);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        }//  ww  w . jav a2 s .c o m

        if (is.stackSize == 0) {
            final String craftLabelText = AEConfig.instance.useTerminalUseLargeFont()
                    ? GuiText.LargeFontCraft.getLocal()
                    : GuiText.SmallFontCraft.getLocal();
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glPushMatrix();
            GL11.glScaled(scaleFactor, scaleFactor, scaleFactor);
            final int X = (int) (((float) par4 + offset + 16.0f
                    - fontRenderer.getStringWidth(craftLabelText) * scaleFactor) * inverseScaleFactor);
            final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor);
            fontRenderer.drawStringWithShadow(craftLabelText, X, Y, 16777215);
            GL11.glPopMatrix();
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_DEPTH_TEST);
        }

        final long amount = this.aeStack != null ? this.aeStack.getStackSize() : is.stackSize;
        if (amount != 0) {
            final String stackSize = this.getToBeRenderedStackSize(amount);

            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glPushMatrix();
            GL11.glScaled(scaleFactor, scaleFactor, scaleFactor);
            final int X = (int) (((float) par4 + offset + 16.0f
                    - fontRenderer.getStringWidth(stackSize) * scaleFactor) * inverseScaleFactor);
            final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor);
            fontRenderer.drawStringWithShadow(stackSize, X, Y, 16777215);
            GL11.glPopMatrix();
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_DEPTH_TEST);
        }

        fontRenderer.setUnicodeFlag(unicodeFlag);
    }
}