Package org.nlogo.api

Examples of org.nlogo.api.AgentException


  }

  @Override
  public void setLinkVariable(int vn, Object value)
      throws AgentException {
    throw new AgentException
        ("a turtle can't set a link variable without specifying which link");
  }
View Full Code Here


  }

  @Override
  public void setLinkVariable(int vn, double value)
      throws AgentException {
    throw new AgentException
        ("a turtle can't set a link variable without specifying which link");
  }
View Full Code Here

  }

  @Override
  public void setLinkBreedVariable(String name, Object value)
      throws AgentException {
    throw new AgentException
        ("a turtle can't set a link variable without specifying which link");
  }
View Full Code Here

    } else if (otherAgent instanceof Patch) {
      Patch p = (Patch) otherAgent;
      x = p.pxcor;
      y = p.pycor;
    } else {
      throw new AgentException("you can't move-to a link");
    }

    xandycor(shortestPathX(x), shortestPathY(y));
  }
View Full Code Here

          break;

        case VAR_PXCOR3D:
        case VAR_PYCOR3D:
        case VAR_PZCOR3D:
          throw new AgentException("you can't change a patch's coordinates");

        default:
          return;
      }
    }
View Full Code Here

  @Override
  public void setPatchVariable(int vn, double value)
      throws AgentException {
    switch (vn) {
      case VAR_PXCOR3D:
        throw new AgentException("you can't change a patch's coordinates");
      case VAR_PYCOR3D:
        throw new AgentException("you can't change a patch's coordinates");
      case VAR_PZCOR3D:
        throw new AgentException("you can't change a patch's coordinates");
      default:
        throw new IllegalArgumentException
            (vn + " is not a double variable");
    }
  }
View Full Code Here

  @Override
  public Patch getPatchAtOffsets(double dx, double dy)
      throws AgentException {
    Patch target = ((World3D) world).getPatchAt(pxcor + dx, pycor + dy, pzcor);
    if (target == null) {
      throw new AgentException("Cannot get patch beyond limits of current world.");
    }
    return target;
  }
View Full Code Here

  public Patch3D getPatchAtOffsets(double dx, double dy, double dz)
      throws AgentException {
    Patch3D target = ((World3D) world).getPatchAt(pxcor + dx, pycor + dy, pzcor + dz);
    if (target == null) {
      throw new AgentException("Cannot get patch beyond limits of current world.");
    }
    return target;
  }
View Full Code Here

          break;
        case VAR_BREED:
          if (value instanceof AgentSet) {
            AgentSet breed = (AgentSet) value;
            if (breed != world.links() && !world.isLinkBreed(breed)) {
              throw new AgentException(I18N.errorsJ().get("org.nlogo.agent.Link.cantSetBreedToNonLinkBreedAgentSet"));
            }
            if (world.getLink(end1.agentKey(), end2.agentKey(), breed) != null) {
              throw new AgentException("there is already a "
                  + world.getLinkBreedSingular(breed)
                  + " with endpoints "
                  + end1.toString() + " and " + end2.toString());
            }
            if (!world.linkManager.checkBreededCompatibility(breed == world.links())) {
              throw new AgentException
                  (I18N.errorsJ().get("org.nlogo.agent.Link.cantHaveBreededAndUnbreededLinks"));
            }
            setBreed(breed);
          } else {
            wrongTypeForVariable(AgentVariables.getImplicitLinkVariables()[vn],
                AgentSet.class, value);
          }
          break;
        case VAR_THICKNESS:
          if (value instanceof Double) {
            lineThickness((Double) value);
          } else {
            wrongTypeForVariable(AgentVariables.getImplicitLinkVariables()[vn],
                Double.class, value);
          }
          break;
        case VAR_SHAPE:
          if (value instanceof String) {
            String newShape = world.checkLinkShapeName((String) value);
            if (newShape == null) {
              throw new AgentException(I18N.errorsJ().getN("org.nlogo.agent.Agent.shapeUndefined", value));
            }
            shape(newShape);
          } else {
            wrongTypeForVariable(AgentVariables.getImplicitLinkVariables()[vn],
                String.class, value);
          }
          break;
        case VAR_TIEMODE:
          if (value instanceof String) {
            mode((String) value);
          } else {
            wrongTypeForVariable(AgentVariables.getImplicitLinkVariables()[vn],
                String.class, value);
          }
          break;
        case VAR_END1:
        case VAR_END2:
          throw new AgentException("you can't change a link's endpoints");
        default:
          break;
      }
    }
    world.notifyWatchers(this, vn, value);
View Full Code Here

  }

  @Override
  public Object getTurtleVariable(int vn)
      throws AgentException {
    throw new AgentException
        ("a link can't access a turtle variable without specifying which turtle");
  }
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.