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);