Search in sources :

Example 66 with Rectangle

use of java.awt.Rectangle in project PneumaticCraft by MineMaarten.

the class GuiPressureChamberInterface method initGui.

@Override
public void initGui() {
    super.initGui();
    int xStart = (width - xSize) / 2;
    int yStart = (height - ySize) / 2;
    statusStat = addAnimatedStat("Interface Status", new ItemStack(Blockss.pressureChamberInterface), 0xFFFFAA00, false);
    filterStat = addAnimatedStat("Filter", new ItemStack(net.minecraft.init.Blocks.hopper), 0xFF005500, false);
    filterStat.setTextWithoutCuttingString(getFilterText());
    Rectangle buttonRect = filterStat.getButtonScaledRectangle(5, 30, 170, 20);
    filterButton = new GuiButtonSpecial(1, buttonRect.x, buttonRect.y, buttonRect.width, buttonRect.height, "-");
    filterStat.addWidget(filterButton);
    creativeTabButton = new GuiButton(2, xStart + 91, yStart + 58, 78, 20, "-");
    nameFilterField = new GuiTextField(fontRendererObj, xStart + 91, yStart + 58, 78, 10);
    nameFilterField.setText(te.itemNameFilter);
    buttonList.add(creativeTabButton);
    if (te.filterMode != TileEntityPressureChamberInterface.EnumFilterMode.ITEM) {
        if (((Slot) inventorySlots.inventorySlots.get(5)).xDisplayPosition < 1000) {
            for (int i = 5; i < 14; i++) {
                ((Slot) inventorySlots.inventorySlots.get(i)).xDisplayPosition += 1000;
            }
        }
    } else {
        if (((Slot) inventorySlots.inventorySlots.get(5)).xDisplayPosition > 1000) {
            for (int i = 5; i < 14; i++) {
                ((Slot) inventorySlots.inventorySlots.get(i)).xDisplayPosition -= 1000;
            }
        }
    }
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) Rectangle(java.awt.Rectangle) ItemStack(net.minecraft.item.ItemStack) GuiTextField(net.minecraft.client.gui.GuiTextField) Point(java.awt.Point)

Example 67 with Rectangle

use of java.awt.Rectangle in project PneumaticCraft by MineMaarten.

the class GuiSecurityStationInventory method initGui.

@Override
public void initGui() {
    super.initGui();
    int xStart = (width - xSize) / 2;
    int yStart = (height - ySize) / 2;
    statusStat = addAnimatedStat("Security Status", new ItemStack(Blockss.securityStation), 0xFFFFAA00, false);
    accessStat = addAnimatedStat("Shared Users", new ItemStack(Items.skull, 1, 3), 0xFF005500, false);
    Rectangle accessButtonRectangle = accessStat.getButtonScaledRectangle(145, 10, 20, 20);
    addButton = getButtonFromRectangle(1, accessButtonRectangle, "+");
    rebootButton = new GuiButton(2, xStart + 110, yStart + 20, 60, 20, "Reboot");
    sharedUserTextField = getTextFieldFromRectangle(accessStat.getButtonScaledRectangle(20, 15, 120, 10));
    accessStat.addWidget(sharedUserTextField);
    accessStat.addWidget(addButton);
    buttonList.add(new GuiButton(3, guiLeft + 108, guiTop + 103, 64, 20, I18n.format("gui.securityStation.test")));
    buttonList.add(rebootButton);
    buttonList.add(new GuiButton(-1, guiLeft + 108, guiTop + 125, 64, 20, I18n.format("gui.universalSensor.button.showRange")));
    updateUserRemoveButtons();
    nodeHandler = new NetworkConnectionBackground(this, te, xStart + 25, yStart + 30, 18, 0xFF2222FF);
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) Rectangle(java.awt.Rectangle) ItemStack(net.minecraft.item.ItemStack) Point(java.awt.Point)

Example 68 with Rectangle

use of java.awt.Rectangle in project PneumaticCraft by MineMaarten.

the class GuiUnitProgrammer method render.

public void render(int x, int y, boolean showFlow, boolean showInfo, boolean translate) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int origX = x;
    int origY = y;
    x -= translatedX;
    y -= translatedY;
    float scale = getScale();
    x = (int) (x / scale);
    y = (int) (y / scale);
    if (scaleScroll.getState() != lastZoom) {
        float shift = SCALE_PER_STEP * (scaleScroll.getState() - lastZoom);
        if (new Rectangle(guiLeft + startX, guiTop + startY, areaWidth, areaHeight).contains(origX, origY)) {
            translatedX += shift * x;
            translatedY += shift * y;
        } else {
            translatedX += areaWidth / 2 * shift;
            translatedY += areaHeight / 2 * shift;
        }
    }
    lastZoom = scaleScroll.getState();
    ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
    GL11.glScissor((guiLeft + startX) * sr.getScaleFactor(), (sr.getScaledHeight() - areaHeight - (guiTop + startY)) * sr.getScaleFactor(), areaWidth * sr.getScaleFactor(), areaHeight * sr.getScaleFactor());
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glPushMatrix();
    GL11.glTranslated(translatedX, translatedY, 0);
    GL11.glScaled(scale, scale, 1);
    if (showFlow)
        showFlow();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    for (IProgWidget widget : progWidgets) {
        GL11.glPushMatrix();
        GL11.glTranslated(widget.getX() + guiLeft, widget.getY() + guiTop, 0);
        GL11.glScaled(0.5, 0.5, 1);
        widget.render();
        GL11.glPopMatrix();
    }
    for (IProgWidget widget : progWidgets) {
        List<String> errors = new ArrayList<String>();
        widget.addErrors(errors, progWidgets);
        if (errors.size() > 0) {
            drawBorder(widget, 0xFFFF0000);
        } else {
            List<String> warnings = new ArrayList<String>();
            widget.addWarnings(warnings, progWidgets);
            if (warnings.size() > 0) {
                drawBorder(widget, 0xFFFFFF00);
            }
        }
    }
    renderAdditionally();
    GL11.glColor4d(1, 1, 1, 1);
    if (showInfo) {
        for (IProgWidget widget : progWidgets) {
            GL11.glPushMatrix();
            GL11.glTranslated(widget.getX() + guiLeft, widget.getY() + guiTop, 0);
            GL11.glScaled(0.5, 0.5, 1);
            widget.renderExtraInfo();
            GL11.glPopMatrix();
        }
    }
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
    boolean isLeftClicking = Mouse.isButtonDown(0);
    if (translate && isLeftClicking && wasClicking && new Rectangle(guiLeft + startX, guiTop + startY, areaWidth, areaHeight).contains(origX, origY)) {
        translatedX += origX - lastMouseX;
        translatedY += origY - lastMouseY;
    }
    wasClicking = isLeftClicking;
    lastMouseX = origX;
    lastMouseY = origY;
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) IProgWidget(pneumaticCraft.common.progwidgets.IProgWidget) Rectangle(java.awt.Rectangle) ArrayList(java.util.ArrayList)

Example 69 with Rectangle

use of java.awt.Rectangle in project PneumaticCraft by MineMaarten.

the class WidgetAmadronOffer method addTooltip.

@Override
public void addTooltip(int mouseX, int mouseY, List<String> curTip, boolean shiftPressed) {
    super.addTooltip(mouseX, mouseY, curTip, shiftPressed);
    for (IGuiWidget widget : widgets) {
        if (widget.getBounds().contains(mouseX, mouseY)) {
            widget.addTooltip(mouseX, mouseY, curTip, shiftPressed);
        }
    }
    boolean isInBounds = false;
    for (Rectangle rect : tooltipRectangles) {
        if (rect.contains(mouseX, mouseY)) {
            isInBounds = true;
        }
    }
    if (!isInBounds) {
        curTip.add(I18n.format("gui.amadron.amadronWidget.selling", getStringForObject(offer.getOutput())));
        curTip.add(I18n.format("gui.amadron.amadronWidget.buying", getStringForObject(offer.getInput())));
        curTip.add(I18n.format("gui.amadron.amadronWidget.vendor", offer.getVendor()));
        curTip.add(I18n.format("gui.amadron.amadronWidget.inBasket", shoppingAmount));
        if (offer.getStock() >= 0)
            curTip.add(I18n.format("gui.amadron.amadronWidget.stock", offer.getStock()));
        if (offer.getVendor().equals(PneumaticCraft.proxy.getPlayer().getCommandSenderName())) {
            curTip.addAll(Arrays.asList(WordUtils.wrap(I18n.format("gui.amadron.amadronWidget.sneakRightClickToRemove"), 40).split(System.getProperty("line.separator"))));
        }
    }
}
Also used : Rectangle(java.awt.Rectangle)

Example 70 with Rectangle

use of java.awt.Rectangle in project PneumaticCraft by MineMaarten.

the class WidgetComboBox method onMouseClicked.

@Override
public void onMouseClicked(int mouseX, int mouseY, int button) {
    if (!fixedOptions || button != 1)
        super.onMouseClicked(mouseX, mouseY, button);
    if (enabled) {
        setFocused(true);
        List<String> applicableElements = getApplicableElements();
        for (int i = 0; i < applicableElements.size(); i++) {
            if (new Rectangle(xPosition - 1, yPosition + height + 2 + i * fontRenderer.FONT_HEIGHT, width, fontRenderer.FONT_HEIGHT).contains(mouseX, mouseY)) {
                setText(applicableElements.get(i));
                listener.onKeyTyped(this);
                setFocused(false);
                break;
            }
        }
    }
}
Also used : Rectangle(java.awt.Rectangle)

Aggregations

Rectangle (java.awt.Rectangle)809 Point (java.awt.Point)201 Dimension (java.awt.Dimension)81 BufferedImage (java.awt.image.BufferedImage)68 Graphics2D (java.awt.Graphics2D)65 Color (java.awt.Color)48 Insets (java.awt.Insets)47 ArrayList (java.util.ArrayList)37 Font (java.awt.Font)29 Test (org.junit.Test)28 IOException (java.io.IOException)27 GraphicsConfiguration (java.awt.GraphicsConfiguration)23 Paint (java.awt.Paint)23 GradientPaint (java.awt.GradientPaint)22 FontMetrics (java.awt.FontMetrics)21 Graphics (java.awt.Graphics)21 Rectangle2D (java.awt.geom.Rectangle2D)21 Robot (java.awt.Robot)19 File (java.io.File)19 PeakResult (gdsc.smlm.results.PeakResult)18