Example #1
0
  public Option() {
    selection_ = StateMEnuEnum.OPTION;
    values_ = GlobalValues.getInstance();

    // creation zone affichage du menu
    stage = new Stage(new ScreenViewport());

    // boutons et label
    layout_table = new Table();
    layout_table.setSize(values_.get_width(), values_.get_width());
    retour_ = new TextButton("Retour", values_.get_Skin()); // init du bouton retour

    retour_.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            selection_ = StateMEnuEnum.MENU;
          }
        });

    layout_table.add(retour_).width(values_.get_width()).pad(10);
    stage.addActor(layout_table);
    // Gdx.input.setInputProcessor(stage);

  }
  /** evaluates the operator */
  public OperandToken evaluate(Token[] operands, GlobalValues globals) {
    if (breakHit || continueHit) return null;

    ErrorLogger.debugLine("DotOperatorToken: evaluate");

    //  syntax is <left><dot><right>  (e.g. a.b)
    Token left = operands[0];
    Token right = operands[1];

    left = left.evaluate(null, globals);

    // not needed. is done by variable token
    // check if left is a variable (e.g. a.abc, where "a" is a structure)
    // if(operands[0] instanceof VariableToken)
    // {
    //    String objName      = ((VariableToken)operands[0]).getName();
    //    String fieldName    = operands[1].toString();
    //
    //    MathLibObject obj   = (MathLibObject)(getVariables().getVariable(objName).getData());
    //    OperandToken  op    = obj.getFieldData(fieldName);
    //
    //    ErrorLogger.debugLine("DotOperatorToken getting object " + objName);
    //    return op.evaluate(null);
    // }

    // (e.g. a.sin() or a.getColor() or 2.sin or 3.sin() )
    String name = "";

    if (right instanceof FunctionToken) {
      name = ((FunctionToken) right).getName();
    }

    if (!name.equals("")) {
      try {
        // check if a function with this name exists
        if (globals.getFunctionManager().findFunctionByName(name) != null) {
          ErrorLogger.debugLine("parser value.function");
          FunctionToken func = new FunctionToken(name, (OperandToken) left);

          return func.evaluate(null, globals);
        }
      } catch (Exception e) {
      }
    }

    // if(function != null)
    // {
    // }
    // else
    // {
    //    String firstParam = operandStack.pop().toString();
    //    ErrorLogger.debugLine("parser value.field");
    //    OperandToken tree = new VariableToken(token.toString(), firstParam);
    //    return tree;
    // }

    return null;
  }
Example #3
0
  public Quitter() {
    selection_ = StateMEnuEnum.QUITTER;
    values_ = GlobalValues.getInstance();
    skin_bouton = values_.get_Skin();

    layout_table = new Table();
    layout_table.setSize(values_.get_width(), values_.get_width());

    // creation zone affichage du menu
    stage = new Stage(new ScreenViewport());

    // boutons et label
    oui_bouton = new TextButton("Oui", skin_bouton); // init du bouton Jeu
    non_bouton = new TextButton("Non", skin_bouton); // init du bouton Option
    label_quitter = new Label("Voulez vous quitter?", skin_bouton);

    // création des listenners
    oui_bouton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
          }
        });

    non_bouton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            selection_ = StateMEnuEnum.MENU;
          }
        });

    // placement des boutons
    layout_table.add(label_quitter).width(values_.get_width()).pad(10);
    layout_table.row();
    layout_table.add(oui_bouton).width(values_.get_width()).pad(10);
    layout_table.row();
    layout_table.add(non_bouton).width(values_.get_width()).pad(10);
    stage.addActor(layout_table);

    // activation de la zone
    // Gdx.input.setInputProcessor(stage);
  }
 public String BitMapToString(Bitmap bitmap) {
   ByteArrayOutputStream baos;
   byte[] b;
   String temp = null;
   try {
     System.gc();
     baos = new ByteArrayOutputStream();
     bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
     b = baos.toByteArray();
     temp = Base64.encodeToString(b, Base64.DEFAULT);
   } catch (Exception e) {
     e.printStackTrace();
   } catch (OutOfMemoryError e) {
     baos = new ByteArrayOutputStream();
     bitmap.compress(Bitmap.CompressFormat.JPEG, 50, baos);
     b = baos.toByteArray();
     temp = Base64.encodeToString(b, Base64.DEFAULT);
     GlobalValues.showAlert(ChatActivity.this, "Out of Memory");
     System.gc();
   }
   return temp;
 }