Package org.nlogo.api

Examples of org.nlogo.api.AgentException


  public abstract Patch getPatchAtOffsets(double dx, double dy) throws AgentException;

  void wrongTypeForVariable(String name, Class<?> expectedClass, Object value)
      throws AgentException {
    throw new AgentException(I18N.errorsJ().getN("org.nlogo.agent.Agent.wrongTypeOnSetError",
        classDisplayName(), name, Dump.typeName(expectedClass), Dump.logoObject(value)));
  }
View Full Code Here


    }
    String key =
        allowAlpha
            ? "org.nlogo.agent.Agent.rgbListSizeError.3or4"
            : "org.nlogo.agent.Agent.rgbListSizeError.3";
    throw new AgentException(I18N.errorsJ().get(key));
  }
View Full Code Here

  }

  private void validRGB(int c)
      throws AgentException {
    if (c < 0 || c > 255) {
      throw new AgentException(I18N.errorsJ().get("org.nlogo.agent.Agent.rgbValueError"));
    }
  }
View Full Code Here

  public Patch getPatchAtOffsets(double dx, double dy)
      throws AgentException {
    Patch target = world.getTopology().getPatchAt(xcor + dx, ycor + dy);
    if (target == null) {
      // Cannot get patch beyond limits of current world.
      throw new AgentException(I18N.errorsJ().get("org.nlogo.agent.Turtle.patchBeyondLimits"));
    }
    return target;
  }
View Full Code Here

  }

  private void mustOwn(String name)
      throws AgentException {
    if (name != null && !world.breedOwns(getBreed(), name)) {
      throw new AgentException(I18N.errorsJ().getN("org.nlogo.agent.Agent.breedDoesNotOwnVariable",
          getBreed().printName(), name));
    }
  }
View Full Code Here

  }

  @Override
  public Object getLinkBreedVariable(String name)
      throws AgentException {
    throw new AgentException
        (I18N.errorsJ().get("org.nlogo.agent.Turtle.cantAccessLinkWithoutSpecifyingLink"));
  }
View Full Code Here

      vn = world.turtlesOwnIndexOf(name);
    }
    if (vn != -1) {
      return getTurtleVariable(vn);
    }
    throw new AgentException(I18N.errorsJ().getN("org.nlogo.agent.Agent.breedDoesNotOwnVariable", this.toString(), name));
  }
View Full Code Here

  }

  @Override
  public Object getLinkVariable(int vn)
      throws AgentException {
    throw new AgentException
        (I18N.errorsJ().get("org.nlogo.agent.Turtle.cantAccessLinkWithoutSpecifyingLink"));
  }
View Full Code Here

        break;
      case VAR_PENSIZE:
        penSize(value);
        break;
      case VAR_WHO:
        throw new AgentException(I18N.errorsJ().get("org.nlogo.agent.Turtle.cantChangeWho"));
      default:
        throw new IllegalArgumentException(I18N.errorsJ().getN("org.nlogo.agent.Agent.notADoubleVariable", vn));
    }
  }
View Full Code Here

          break;
        case VAR_SHAPE:
          if (value instanceof String) {
            String newShape = world.checkTurtleShapeName((String) value);
            if (newShape == null) {
              throw new AgentException
                  (I18N.errorsJ().getN("org.nlogo.agent.Agent.shapeUndefined", value));
            }
            shape(newShape);
          } else {
            wrongTypeForVariable
                (AgentVariables.getImplicitTurtleVariables(false)[vn], String.class, value);
          }
          break;
        case VAR_LABEL:
          label(value);
          break;
        case VAR_LABELCOLOR:
          if (value instanceof Double) {
            labelColor(((Double) value).doubleValue());
          } else if (value instanceof LogoList) {
            labelColor((LogoList) value, VAR_LABELCOLOR);
          } else {
            wrongTypeForVariable
                (AgentVariables.getImplicitTurtleVariables(false)[vn], Double.class, value);
          }
          break;
        case VAR_BREED:
          if (value instanceof AgentSet) {
            AgentSet breed = (AgentSet) value;
            if (breed != world.turtles() && !world.isBreed(breed)) {
              throw new AgentException(I18N.errorsJ().get("org.nlogo.agent.Turtle.cantSetBreedToNonBreedAgentSet"));
            }
            setBreed(breed);
          } else {
            wrongTypeForVariable
                (AgentVariables.getImplicitTurtleVariables(false)[vn], AgentSet.class, value);
          }
          break;
        case VAR_HIDDEN:
          if (value instanceof Boolean) {
            hidden(((Boolean) value).booleanValue());
          } else {
            wrongTypeForVariable
                (AgentVariables.getImplicitTurtleVariables(false)[vn], Boolean.class, value);
          }
          break;
        case VAR_SIZE:
          if (value instanceof Double) {
            size(((Double) value).doubleValue());
          } else {
            wrongTypeForVariable
                (AgentVariables.getImplicitTurtleVariables(false)[vn],
                    Double.class, value);
          }
          break;
        case VAR_PENMODE:
          if (value instanceof String) {
            penMode((String) value);
          } else {
            wrongTypeForVariable(AgentVariables.getImplicitTurtleVariables(false)[vn],
                String.class, value);
          }
          break;

        case VAR_PENSIZE:
          if (value instanceof Double) {
            penSize(((Double) value).doubleValue());
          } else {
            wrongTypeForVariable(AgentVariables.getImplicitTurtleVariables(false)[vn],
                Double.class, value);
          }
          break;

        case VAR_WHO:
          throw new AgentException(I18N.errorsJ().get("org.nlogo.agent.Turtle.cantChangeWho"));
        default:
          throw new IllegalStateException(I18N.errorsJ().getN("org.nlogo.agent.Agent.cantSetUnknownVariable", vn));
      }
    }
    world.notifyWatchers(this, vn, value);
View Full Code Here

TOP

Related Classes of org.nlogo.api.AgentException

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.