public MultiLabelToggle(Collection<E> c, Function<E, String> stringer, E initialElement) {
    super("multi-label-toggle");
    Validate.argument(c.size() > 1, "a multilabeltoggle requires at least 2 element");
    Validate.argument(
        c.contains(initialElement),
        "initialElement(%s) must be a part of the supplied collection(%s)",
        initialElement,
        c);

    elements = new ArrayList<>(c);
    labels = makeLabels(elements, stringer);

    selectedBackground.setHeight(labels.get(0).Height.get() + 2 * selectionBackgroundPadding);
    selectedBackground.setWidth(labels.get(elements.indexOf(initialElement)).Width.get());
    selectedBackground.setX(calculateInitialX(initialElement));

    addChildren(selectedBackground, box);

    CurrentSelection =
        new SimpleObjectProperty<E>(initialElement) {
          @Override
          protected void invalidated() {
            final E value = get();
            final int index = elements.indexOf(value);
            Validate.argument(
                index >= 0,
                "the supplied value(%s) is not part of the valid values(%s)",
                value,
                elements);

            setValueInternal(labels.get(index));
          };
        };
  }
示例#2
0
  /**
   * The doPost method of the servlet. <br>
   * This method is called when a form has its tag value method equals to post.
   *
   * @param request the request send by the client to the server
   * @param response the response send by the server to the client
   * @throws ServletException if an error occurred
   * @throws IOException if an error occurred
   */
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html;charset=gb2312");
    request.setCharacterEncoding("gb2312");

    InsertUpdateDelBean ib = new InsertUpdateDelBean();
    String args[] = {"name", "addsubtract", "score", "reason"};
    String row = "";
    String val = "";
    Validate v = new Validate();
    HttpSession session = request.getSession();
    ArrayList adminlogin = (ArrayList) session.getAttribute("adminlogin");
    for (int i = 0; i < args.length; i++) {
      if (i == args.length - 1) {
        row += args[i] + ",student,dates";
        val +=
            "'"
                + request.getParameter(args[i])
                + "',"
                + adminlogin.get(0)
                + ",'"
                + v.getSystemDate().substring(0, 10)
                + "'";
      } else {
        row += args[i] + ",";
        val += "'" + request.getParameter(args[i]) + "',";
      }
    }
    String sql = "insert into verify(" + row + ") values(" + val + ")";
    ib.insertANDupdateANDdel(sql);
    request.setAttribute("message", "'ÆÀ²âÌá½»³É¹¦£¡'");
    request
        .getRequestDispatcher("/admin/verify.jsp?verifyType=" + request.getParameter("name"))
        .forward(request, response);
  }
示例#3
0
  /**
   * Set value of pixel value at coordinates (<code>x</code>, <code>y</code>).
   *
   * @param x x is the width
   * @param y y is the height
   * @param v is the pixel value (and array fo floating features)
   */
  public void set(final int x, final int y, float[] v) {

    /* If the values of x and y are not legal */
    if (x < 0 || x >= width || y < 0 || y >= height) {
      throw new IllegalArgumentException("Value of coordinates (x,y) is out of range.");
    }

    /* Check if the value vector v is not null and has a proper lenght */
    Validate.argumentNotNull(v, "v");

    if (v.length != numberOfValues) {
      throw new IllegalArgumentException(
          "Invalid size of argument 'v' expecting " + numberOfValues + ", got " + v.length + ".");
    }

    /* Computing the row position in pixels and copying the array into v */
    final int offset = x + y * width;
    final float[] s = pixels[offset];
    System.arraycopy(v, 0, s, 0, v.length);
  }