code: public static int computeAttributeLength(String value, int whole) throws NumberFormatException
      {
          String sval = value.trim().toLowerCase();
          if (sval.endsWith("%"))
          {
              double val = Double.parseDouble(sval.substring(0, sval.length() - 1));
              return (int) Math.round(val * whole / 100.0);
          }
          else if (sval.endsWith("px"))
          {
              return (int) Math.rint(Double.parseDouble(sval.substring(0, sval.length() - 2)));
          }
          else
          {
              return (int) Math.rint(Double.parseDouble(sval));
          }
      }
docs: Computes a length defined using an HTML attribute (e.g. width for tables).
  @param value The attribute value
  @param whole the value used as 100% when value is a percentage
  @return the computed length