Package org.nlogo.nvm

Examples of org.nlogo.nvm.EngineException


    Object obj = args[0].report(context);
    if (obj instanceof LogoList) {
      LogoList list = (LogoList) obj;
      int size = list.size();
      if (size == 0) {
        throw new EngineException(context, this,
            I18N.errorsJ().getN("org.nlogo.prim.etc.$common.emptyListInput", displayName()));
      }
      return list.get(context.job.random.nextInt(size));
    } else if (obj instanceof AgentSet) {
      AgentSet agents = (AgentSet) obj;
View Full Code Here


  }

  public Object report_2(Context context, LogoList list) throws LogoException {
    int size = list.size();
    if (size == 0) {
      throw new EngineException(context, this,
          I18N.errorsJ().getN("org.nlogo.prim.etc.$common.emptyListInput", displayName()));
    }
    return list.get(context.job.random.nextInt(size));
  }
View Full Code Here

  public Object report_3(Context context, Object obj) throws LogoException {
    if (obj instanceof LogoList) {
      LogoList list = (LogoList) obj;
      int size = list.size();
      if (size == 0) {
        throw new EngineException(context, this,
            I18N.errorsJ().getN("org.nlogo.prim.etc.$common.emptyListInput", displayName()));
      }
      return list.get(context.job.random.nextInt(size));
    } else if (obj instanceof AgentSet) {
      AgentSet agents = (AgentSet) obj;
View Full Code Here

  public AgentSet report_1(final org.nlogo.nvm.Context context, AgentSet sourceSet,
                           double radius, double angle)
      throws LogoException {
    if (sourceSet.type() == org.nlogo.agent.Link.class) {
      throw new EngineException
          (context, this, I18N.errorsJ().get("org.nlogo.prim.etc.$common.expectedTurtleOrPatchButGotLink"));
    }
    if (radius < 0) {
      throw new EngineException(context, this,
          I18N.errorsJ().getN("org.nlogo.prim.etc.$common.noNegativeRadius", displayName()));
    }
    if (angle < 0) {
      throw new EngineException(context, this,
          I18N.errorsJ().getN("org.nlogo.prim.etc.$common.noNegativeAngle", displayName()));
    }
    if (angle > 360) {
      throw new EngineException(context, this,
          I18N.errorsJ().getN("org.nlogo.prim.etc.$common.noAngleGreaterThan360", displayName()));
    }

    List<Agent> result =
        world.inRadiusOrCone.inCone((Turtle) context.agent, sourceSet, radius, angle, false);
View Full Code Here

    workspace.waitFor
        (new org.nlogo.api.CommandRunnable() {
          public void run() throws LogoException {
            if (!workspace.getHubNetManager().addNarrowcastPlot(name)) {
              throw new EngineException
                  (context, _hubnetmakeplotnarrowcast.this,
                      "no such plot: \"" + name + "\"");
            }
          }
        });
View Full Code Here

    Link link;
    Turtle node;
    if (context.agent instanceof Link) {
      link = (Link) context.agent;
      if (!(context.myself() instanceof Turtle)) {
        throw new EngineException(context, this,
            I18N.errorsJ().get("org.nlogo.prim.etc._otherend.onlyTurtleCanGetLinkEnd"));
      }
      node = (Turtle) context.myself();
    } else {
      node = (Turtle) context.agent;
      if (!(context.myself() instanceof Link)) {
        throw new EngineException(context, this,
            I18N.errorsJ().get("org.nlogo.prim.etc._otherend.onlyLinkCanGetTurtleEnd"));
      }
      link = (Link) context.myself();
    }

    Turtle dest = link.end2();
    Turtle src = link.end1();
    if (dest == node) {
      return src;
    }
    if (src == node) {
      return dest;
    }

    throw new EngineException(context, this,
        I18N.errorsJ().getN("org.nlogo.prim.etc._otherend.incorrectLink", node.toString(), link.toString()));
  }
View Full Code Here

      if (obj instanceof Link) {
        result.add((Link) obj);
      } else if (obj instanceof AgentSet) {
        AgentSet tempSet = (AgentSet) obj;
        if (tempSet.type() != org.nlogo.agent.Link.class) {
          throw new EngineException(context, this,
              I18N.errorsJ().getN("org.nlogo.prim.etc._linkset.invalidLAgentsetTypeInputToList",
                  this.displayName(), Dump.logoObject(tempList, true, false), Dump.logoObject(obj, true, false)));
        }
        for (AgentSet.Iterator iter2 = tempSet.iterator();
             iter2.hasNext();) {
          result.add((Link) iter2.next());
        }
      } else if (obj instanceof LogoList) {
        descendList(context, (LogoList) obj, result);
      } else if (obj != org.nlogo.api.Nobody$.MODULE$) {
        throw new EngineException(context, this,
            I18N.errorsJ().getN("org.nlogo.prim.etc._linkset.invalidListInputs",
                this.displayName(), Dump.logoObject(tempList, true, false), Dump.logoObject(obj, true, false)));
      }
    }
  }
View Full Code Here

    return report_1(context, argEvalDoubleValue(context, 0));
  }

  public double report_1(Context context, double d) throws LogoException {
    if (d <= 0) {
      throw new EngineException(context, this,
          I18N.errorsJ().getN("org.nlogo.prim.etc.$common.cantTakeLogarithmOf", d));
    }
    return validDouble(StrictMath.log(d));
  }
View Full Code Here

        argEvalDoubleValue(context, 1));
  }

  public double report_1(Context context, double mean, double sdev) throws LogoException {
    if (sdev < 0) {
      throw new EngineException(
          context, this, I18N.errorsJ().get("org.nlogo.prim.etc._randomNormal.secondInputNotNegative"));

    }
    return validDouble(mean + sdev * context.job.random.nextGaussian());
  }
View Full Code Here

    Object agentOrSet = args[0].report(context);
    List<Turtle> resultList = new ArrayList<Turtle>();
    if (agentOrSet instanceof Turtle) {
      Turtle turtle = (Turtle) agentOrSet;
      if (turtle.id == -1) {
        throw new EngineException(context, this,
          I18N.errorsJ().getN("org.nlogo.$common.thatAgentIsDead", turtle.classDisplayName()));
      }
      addAll(resultList, turtle.getPatchHere().turtlesHere());
    } else if (agentOrSet instanceof Patch) {
      addAll(resultList, ((Patch) agentOrSet).turtlesHere());
View Full Code Here

TOP

Related Classes of org.nlogo.nvm.EngineException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.