public void update(float dt) {
    if (this.state == EDIT_SHAPE) {
      if (es.vertexCount() > 0) {
        int i = es.findClosestLineStrip(Mouse.getX(), Mouse.getY());
        if (i != -1) {
          int next = (i + 1 > es.vertexCount()) ? 0 : i + 1;
          tgl.reshape(es.getVertex(i), es.getVertex(next), Mouse.getX(), Mouse.getY());
          if (!tgl.isLocked()) vertex = next;
        } else {
          if (!tgl.isLocked()) vertex = -1;
        }
      }
    } else if (this.state == MOVE_SHAPE) {

    }
  }
 public void keyBoardEvent(int key, boolean state) {
   if (state) {
     switch (key) {
       case Keyboard.KEY_LCONTROL:
         if (vertex != -1 && this.state == EDIT_SHAPE) tgl.setLocked(true);
         break;
     }
   } else {
     switch (key) {
       case Keyboard.KEY_LCONTROL:
         tgl.setLocked(false);
         break;
       case Keyboard.KEY_RETURN:
         setState(NULL_STATE);
         break;
       case Keyboard.KEY_E:
         setState(EDIT_SHAPE);
         break;
       case Keyboard.KEY_M:
         setState(MOVE_SHAPE);
     }
   }
 }
 public void mouseEvent(int mouseButton, boolean state, int x, int y) {
   if (state) {
     switch (mouseButton) {
       case 0:
         break;
     }
   } else {
     switch (mouseButton) {
       case 0:
         if (this.state == NEW_SHAPE) {
           es.add(new Vertex2DPosition(x, y));
         } else if (this.state == EDIT_SHAPE) {
           if (vertex != -1) {
             es.add(vertex, new Vertex2DPosition(x, y));
           }
         }
         tgl.setLocked(false);
         break;
     }
   }
 }
 public void render() {
   if (state == EDIT_SHAPE && vertex != -1) tgl.render();
 }