Package org.nlogo.prim

Source Code of org.nlogo.prim._patchrow

// (C) Uri Wilensky. https://github.com/NetLogo/NetLogo

package org.nlogo.prim;

import org.nlogo.agent.AgentSet;
import org.nlogo.agent.ArrayAgentSet;
import org.nlogo.agent.Patch;
import org.nlogo.api.LogoException;
import org.nlogo.api.Syntax;
import org.nlogo.nvm.Context;
import org.nlogo.nvm.Reporter;

public final strictfp class _patchrow
    extends Reporter {
  @Override
  public Object report(Context context) throws LogoException {
    AgentSet result =
        new ArrayAgentSet(Patch.class, world.worldWidth(),
            false, world);
    double yDouble = argEvalDoubleValue(context, 0);
    int y = (int) yDouble;
    if (y == yDouble && y >= world.minPycor() && y <= world.maxPycor()) {
      int xMax = world.maxPxcor();
      for (int x = world.minPxcor(); x <= xMax; x++) {
        result.add(world.fastGetPatchAt(x, y));
      }
    }
    return result;
  }

  @Override
  public Syntax syntax() {
    int[] right = {Syntax.NumberType()};
    int ret = Syntax.PatchsetType();
    return Syntax.reporterSyntax(right, ret);
  }
}
TOP

Related Classes of org.nlogo.prim._patchrow

TOP
Copyright © 2018 www.massapi.com. 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.