gt:             maxWidth = (int)(maxWidth * textSize);
context: package pneumaticCraft.client.gui.widget;
  
  import java.awt.Rectangle;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  import net.minecraft.client.Minecraft;
  import net.minecraft.client.gui.FontRenderer;
  import net.minecraft.client.gui.Gui;
  import net.minecraft.client.gui.GuiScreen;
  import net.minecraft.client.gui.ScaledResolution;
  import net.minecraft.client.renderer.RenderHelper;
  import net.minecraft.client.renderer.Tessellator;
  import net.minecraft.client.renderer.entity.RenderItem;
  import net.minecraft.client.resources.I18n;
  import net.minecraft.item.ItemBlock;
  import net.minecraft.item.ItemStack;
  import net.minecraft.util.EnumChatFormatting;
  import net.minecraft.util.MathHelper;
  
  import org.lwjgl.input.Mouse;
  import org.lwjgl.opengl.GL11;
  import org.lwjgl.opengl.GL12;
  
  import pneumaticCraft.api.client.IGuiAnimatedStat;
  import pneumaticCraft.client.gui.GuiPneumaticContainerBase;
  import pneumaticCraft.common.util.PneumaticCraftUtils;
  import pneumaticCraft.lib.GuiConstants;
  import pneumaticCraft.lib.Textures;
  import cpw.mods.fml.client.FMLClientHandler;
  
  /**
   *  IMPORTANT: WHEN CHANGING THE PACKAGE OF THIS CLASS, ALSO EDIT GUIANIMATEDSTATSUPPLIER.JAVA!!
   */
  
  public class GuiAnimatedStat implements IGuiAnimatedStat, IGuiWidget, IWidgetListener{
  
      public static final int ANIMATED_STAT_SPEED = 10;
      private IGuiAnimatedStat affectingStat;
      private ItemStack iStack;
      private String texture = "";
      private final GuiScreen gui;
      private final List<String> textList = new ArrayList<String>();
      private final List<IGuiWidget> widgets = new ArrayList<IGuiWidget>();
      private int baseX;
      private int baseY;
      private int affectedY;
      private int width;
      private int height;
  
      private int oldBaseX;
      private int oldAffectedY;
      private int oldWidth;
      private int oldHeight;
      private boolean isClicked = false;
      private int minWidth = 17;
      private int minHeight = 17;
      private final int backGroundColor;
      private String title;
      private boolean leftSided; // this boolean determines if the stat is going
      // to expand to the left or right.
      private boolean doneExpanding;
      private RenderItem itemRenderer;
      private float textSize;
      private float textScale = 1F;
      private IWidgetListener listener;
      private int curScroll;
      private static final int MAX_LINES = 12;
      private int lastMouseX, lastMouseY;
  
      public GuiAnimatedStat(GuiScreen gui, String title, int xPos, int yPos, int backGroundColor,
              IGuiAnimatedStat affectingStat, boolean leftSided){
          this.gui = gui;
          baseX = xPos;
          baseY = yPos;
          this.affectingStat = affectingStat;
          width = minWidth;
          height = minHeight;
          this.backGroundColor = backGroundColor;
          setTitle(title);
          texture = "";
          this.leftSided = leftSided;
          if(gui != null) {
              ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
              if(sr.getScaledWidth() < 520) {
                  textSize = (sr.getScaledWidth() - 220) * 0.0033F;
              } else {
                  textSize = 1F;
              }
          } else {
              textSize = 1;
          }
  
          affectedY = baseY;
          if(affectingStat != null) {
              affectedY += affectingStat.getAffectedY() + affectingStat.getHeight();
          }
      }
  
      public GuiAnimatedStat(GuiScreen gui, int backgroundColor){
          this(gui, "", 0, 0, backgroundColor, null, false);
      }
  
      public GuiAnimatedStat(GuiScreen gui, int backgroundColor, ItemStack icon){
          this(gui, backgroundColor);
          iStack = icon;
      }
  
      public GuiAnimatedStat(GuiScreen gui, int backgroundColor, String texture){
          this(gui, backgroundColor);
          this.texture = texture;
      }
  
      public GuiAnimatedStat(GuiScreen gui, String title, ItemStack icon, int xPos, int yPos, int backGroundColor,
              IGuiAnimatedStat affectingStat, boolean leftSided){
          this(gui, title, xPos, yPos, backGroundColor, affectingStat, leftSided);
          iStack = icon;
      }
  
      public GuiAnimatedStat(GuiScreen gui, String title, String texture, int xPos, int yPos, int backGroundColor,
              IGuiAnimatedStat affectingStat, boolean leftSided){
          this(gui, title, xPos, yPos, backGroundColor, affectingStat, leftSided);
          this.texture = texture;
      }
  
      @Override
      public void setParentStat(IGuiAnimatedStat stat){
          affectingStat = stat;
      }
  
      public void addWidget(IGuiWidget widget){
          widgets.add(widget);
          widget.setListener(this);
      }
  
      public void removeWidget(IGuiWidget widget){
          widgets.remove(widget);
      }
  
      @Override
      public Rectangle getButtonScaledRectangle(int origX, int origY, int width, int height){
          int scaledX = (int)(origX * textSize);
          int scaledY = (int)(origY * textSize);
  
          //scaledX = (int)(origX * textSize);
          //scaledY = (int)(origY * textSize);
          return new Rectangle(scaledX, scaledY, (int)(width * textSize), (int)(height * textSize));
      }
  
      @Override
      public void scaleTextSize(float scale){
          textSize *= scale;
          textScale = scale;
  
          for(IGuiWidget widget : widgets) {
              if(widget.getID() == -1000) {
                  widgets.remove(widget);
                  break;
              }
          }
          onTextChange();
      }
  
      @Override
      public boolean isLeftSided(){
          return leftSided;
      }
  
      @Override
      public void setLeftSided(boolean leftSided){
          this.leftSided = leftSided;
      }
  
      @Override
      public IGuiAnimatedStat setText(List<String> text){
          textList.clear();
          for(String line : text) {
              textList.addAll(PneumaticCraftUtils.convertStringIntoList(I18n.format(line), (int)(GuiConstants.maxCharPerLineLeft / textScale)));
          }
          onTextChange();
          return this;
      }
  
      @Override
      public IGuiAnimatedStat setText(String text){
          textList.clear();
          textList.addAll(PneumaticCraftUtils.convertStringIntoList(I18n.format(text), (int)(GuiConstants.maxCharPerLineLeft / textScale)));
          onTextChange();
          return this;
      }
  
      @Override
      public void setTextWithoutCuttingString(List<String> text){
          textList.clear();
          textList.addAll(text);
          onTextChange();
      }
  
      public void onTextChange(){
          if(textList.size() > MAX_LINES) {
              for(IGuiWidget widget : widgets) {
                  if(widget.getID() == -1000) return;
              }
              curScroll = 0;
              /*Rectangle upRect = getButtonScaledRectangle(2, 24, 20, 20);
              addWidget(new GuiButtonSpecial(-1000, upRect.x, upRect.y, upRect.width, upRect.height, "^"));
              Rectangle downRect = getButtonScaledRectangle(2, 44, 20, 20);
              addWidget(new GuiButtonSpecial(-1001, downRect.x, downRect.y, downRect.width, downRect.height, "V"));
               */
              addWidget(new WidgetVerticalScrollbar(-1000, leftSided ? -16 : 2, 20, (int)((MAX_LINES * 10 - 20) * textSize)).setStates(textList.size() - MAX_LINES));
          } else {
              Iterator<IGuiWidget> iterator = widgets.iterator();
              while(iterator.hasNext()) {
                  IGuiWidget widget = iterator.next();
                  if(widget.getID() == -1000) {
                      iterator.remove();
                      curScroll = 0;
                  }
              }
          }
      }
  
      @Override
      public void setMinDimensionsAndReset(int minWidth, int minHeight){
          this.minWidth = minWidth;
          this.minHeight = minHeight;
          width = minWidth;
          height = minHeight;
      }
  
      @Override
      public void update(){
          oldBaseX = baseX;
          oldAffectedY = affectedY;
          oldWidth = width;
          oldHeight = height;
  
          FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer;
          doneExpanding = true;
          if(isClicked) {
              // calculate the width and height needed for the box to fit the
              // strings.
              int maxWidth = fontRenderer.getStringWidth(title);
              int maxHeight = 12;
              if(textList.size() > 0) {
                  maxHeight += 4 + Math.min(MAX_LINES, textList.size()) * 10;
              }
              maxHeight = (int)(maxHeight * textSize);
              for(String line : textList) {
                  if(fontRenderer.getStringWidth(line) > maxWidth) maxWidth = fontRenderer.getStringWidth(line);
              }
  