Java tutorial
/* * * LIMITED USE SOFTWARE LICENSE AGREEMENT * This Limited Use Software License Agreement (the "Agreement") is a legal agreement between you, the end-user, and the FlatstoneTech Team ("FlatstoneTech"). By downloading or purchasing the software material, which includes source code (the "Source Code"), artwork data, music and software tools (collectively, the "Software"), you are agreeing to be bound by the terms of this Agreement. If you do not agree to the terms of this Agreement, promptly destroy the Software you may have downloaded or copied. * FlatstoneTech SOFTWARE LICENSE * 1. Grant of License. FlatstoneTech grants to you the right to use the Software. You have no ownership or proprietary rights in or to the Software, or the Trademark. For purposes of this section, "use" means loading the Software into RAM, as well as installation on a hard disk or other storage device. The Software, together with any archive copy thereof, shall be destroyed when no longer used in accordance with this Agreement, or when the right to use the Software is terminated. You agree that the Software will not be shipped, transferred or exported into any country in violation of the U.S. Export Administration Act (or any other law governing such matters) and that you will not utilize, in any other manner, the Software in violation of any applicable law. * 2. Permitted Uses. For educational purposes only, you, the end-user, may use portions of the Source Code, such as particular routines, to develop your own software, but may not duplicate the Source Code, except as noted in paragraph 4. The limited right referenced in the preceding sentence is hereinafter referred to as "Educational Use." By so exercising the Educational Use right you shall not obtain any ownership, copyright, proprietary or other interest in or to the Source Code, or any portion of the Source Code. You may dispose of your own software in your sole discretion. With the exception of the Educational Use right, you may not otherwise use the Software, or an portion of the Software, which includes the Source Code, for commercial gain. * 3. Prohibited Uses: Under no circumstances shall you, the end-user, be permitted, allowed or authorized to commercially exploit the Software. Neither you nor anyone at your direction shall do any of the following acts with regard to the Software, or any portion thereof: * Rent; * Sell; * Lease; * Offer on a pay-per-play basis; * Distribute for money or any other consideration; or * In any other manner and through any medium whatsoever commercially exploit or use for any commercial purpose. * Notwithstanding the foregoing prohibitions, you may commercially exploit the software you develop by exercising the Educational Use right, referenced in paragraph 2. hereinabove. * 4. Copyright. The Software and all copyrights related thereto (including all characters and other images generated by the Software or depicted in the Software) are owned by FlatstoneTech and is protected by United States copyright laws and international treaty provisions. FlatstoneTech shall retain exclusive ownership and copyright in and to the Software and all portions of the Software and you shall have no ownership or other proprietary interest in such materials. You must treat the Software like any other copyrighted material. You may not otherwise reproduce, copy or disclose to others, in whole or in any part, the Software. You may not copy the written materials accompanying the Software. You agree to use your best efforts to see that any user of the Software licensed hereunder complies with this Agreement. * 5. NO WARRANTIES. FLATSTONETECH DISCLAIMS ALL WARRANTIES, BOTH EXPRESS IMPLIED, INCLUDING BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE WITH RESPECT TO THE SOFTWARE. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS. YOU MAY HAVE OTHER RIGHTS WHICH VARY FROM JURISDICTION TO JURISDICTION. FlatstoneTech DOES NOT WARRANT THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED, ERROR FREE OR MEET YOUR SPECIFIC REQUIREMENTS. THE WARRANTY SET FORTH ABOVE IS IN LIEU OF ALL OTHER EXPRESS WARRANTIES WHETHER ORAL OR WRITTEN. THE AGENTS, EMPLOYEES, DISTRIBUTORS, AND DEALERS OF FlatstoneTech ARE NOT AUTHORIZED TO MAKE MODIFICATIONS TO THIS WARRANTY, OR ADDITIONAL WARRANTIES ON BEHALF OF FlatstoneTech. * Exclusive Remedies. The Software is being offered to you free of any charge. You agree that you have no remedy against FlatstoneTech, its affiliates, contractors, suppliers, and agents for loss or damage caused by any defect or failure in the Software regardless of the form of action, whether in contract, tort, includinegligence, strict liability or otherwise, with regard to the Software. Copyright and other proprietary matters will be governed by United States laws and international treaties. IN ANY CASE, FlatstoneTech SHALL NOT BE LIABLE FOR LOSS OF DATA, LOSS OF PROFITS, LOST SAVINGS, SPECIAL, INCIDENTAL, CONSEQUENTIAL, INDIRECT OR OTHER SIMILAR DAMAGES ARISING FROM BREACH OF WARRANTY, BREACH OF CONTRACT, NEGLIGENCE, OR OTHER LEGAL THEORY EVEN IF FLATSTONETECH OR ITS AGENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so the above limitation or exclusion may not apply to you. */ package tech.flatstone.appliedlogistics.client.gui.machines; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import org.apache.commons.lang3.time.DurationFormatUtils; import org.lwjgl.opengl.GL11; import tech.flatstone.appliedlogistics.client.gui.GuiBase; import tech.flatstone.appliedlogistics.common.container.machines.ContainerPulverizer; import tech.flatstone.appliedlogistics.common.items.Items; import tech.flatstone.appliedlogistics.common.tileentities.machines.TileEntityPulverizer; import tech.flatstone.appliedlogistics.common.util.EnumOres; import tech.flatstone.appliedlogistics.common.util.GuiHelper; import tech.flatstone.appliedlogistics.common.util.LanguageHelper; import java.awt.*; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; public class GuiPulverizer extends GuiBase { private TileEntityPulverizer tileEntity; private GuiHelper guiHelper = new GuiHelper(); private HashMap<Rectangle, List<String>> tooltips = new HashMap<Rectangle, List<String>>(); public GuiPulverizer(InventoryPlayer inventoryPlayer, TileEntityPulverizer tileEntity) { super(new ContainerPulverizer(inventoryPlayer, tileEntity)); this.xSize = 218; this.ySize = 186; this.tileEntity = tileEntity; } @Override public void initGui() { super.initGui(); tooltips.put(new Rectangle(190, 20, 16, 16), Collections.singletonList("Simultaneous processing")); tooltips.put(new Rectangle(190, 49, 16, 16), Collections.singletonList("Speed")); tooltips.put(new Rectangle(190, 78, 16, 16), Collections.singletonList("test")); } @Override public void drawBG(int paramInt1, int paramInt2, int paramInt3, int paramInt4) { bindTexture("gui/machines/pulverizer.png"); drawTexturedModalRect(paramInt1, paramInt2, 0, 0, this.xSize, this.ySize); } @Override public void drawFG(int paramInt1, int paramInt2, int paramInt3, int paramInt4) { this.fontRendererObj.drawString(tileEntity.hasCustomName() ? tileEntity.getCustomName() : LanguageHelper.NONE.translateMessage(tileEntity.getUnlocalizedName()), 8, 6, 4210752); this.fontRendererObj.drawString(LanguageHelper.NONE.translateMessage("container.inventory"), 8, 58, 4210752); /** * Draw Machine Details */ GL11.glPushMatrix(); // Bronze Gear :: number of ores that can be processed at one time guiHelper.drawItemStack(new ItemStack(Items.ITEM_MATERIAL_GEAR.getItem(), 1, EnumOres.BRONZE.getMeta()), 190, 20); // x = 190 to 206 // y = 20 to 36 guiHelper.drawCenteredString(190, 38, 16, tileEntity.getMaxProcessCount() + "x", 4210752); // Stone Gear :: Chance Percent guiHelper.drawItemStack( new ItemStack(Items.ITEM_MATERIAL_GEAR.getItem(), 1, EnumOres.COBBLESTONE.getMeta()), 190, 49); // x = 190 to 206 // y = 49 to 65 guiHelper.drawCenteredString(190, 67, 16, "160%", 4210752); // Wood Gear :: Speed Percent guiHelper.drawItemStack(new ItemStack(Items.ITEM_MATERIAL_GEAR.getItem(), 1, EnumOres.WOOD.getMeta()), 190, 78); // x = 190 to 206 // y = 78 to 94 guiHelper.drawCenteredString(190, 96, 16, "0%", 4210752); GL11.glPopMatrix(); /** * Draw Progress Bar */ if (tileEntity.getTicksRemaining() > 0) { int timeTotal = tileEntity.getTotalProcessTime(); int timeCurrent = tileEntity.getTicksRemaining(); float timePercent = ((((float) timeTotal - (float) timeCurrent) / (float) timeTotal)) * 100; int secondsLeft = (timeCurrent / 20) * 1000; guiHelper.drawHorizontalProgressBar(40, 26, 126, 8, Math.round(timePercent), colorBackground, colorBorder, colorProgressBackground); String progressLabel = String.format("%s: %s (%d%%)", LanguageHelper.LABEL.translateMessage("time_left"), DurationFormatUtils.formatDuration(secondsLeft, "mm:ss"), Math.round(timePercent)); guiHelper.drawCenteredStringWithShadow(40, 26, 126, progressLabel, colorFont); } } @Override public void drawScreen(int mouse_x, int mouse_y, float btn) { super.drawScreen(mouse_x, mouse_y, btn); Point currentMouse = new Point(mouse_x - guiLeft, mouse_y - guiTop); for (Rectangle rectangle : tooltips.keySet()) { if (rectangle.contains(currentMouse)) { ArrayList<String> messages = new ArrayList<String>(tooltips.get(rectangle)); renderToolTip(messages, mouse_x, mouse_y); } } } }