Package org.nlogo.api

Examples of org.nlogo.api.LogoListBuilder


  }

  private LogoList randomSubset(LogoList list, int n,
                                org.nlogo.util.MersenneTwisterFast random) {
    int size = list.size();
    LogoListBuilder result = new LogoListBuilder();
    int i = 0;
    int j = 0;
    for (Iterator<Object> it = list.iterator();
         it.hasNext() && j < n;
         i++) {
      Object elt = it.next();
      if (random.nextInt(size - i) < n - j) {
        result.add(elt);
        j++;
      }
    }
    return result.toLogoList();
  }
View Full Code Here


  public Object report(final org.nlogo.nvm.Context context) throws LogoException {
    Object value = args[0].report(context);
    Object obj = args[1].report(context);
    if (obj instanceof LogoList) {
      LogoList list = (LogoList) obj;
      LogoListBuilder listCopy = new LogoListBuilder();
      for (Iterator<Object> it = list.iterator(); it.hasNext();) {
        Object elt = it.next();
        if (!Equality.equals(value, elt)) {
          listCopy.add(elt);
        }
      }
      return listCopy.toLogoList();
    } else if (obj instanceof String) {
      if (!(value instanceof String)) {
        throw new ArgumentTypeException(context, this, 0, Syntax.StringType(), value);
      }
      String string = (String) obj;
View Full Code Here

      try {
        int argb = java.awt.Color.HSBtoRGB
            (StrictMath.max(0, StrictMath.min(255, ((Double) list.get(0)).intValue())) / 255,
                StrictMath.max(0, StrictMath.min(255, ((Double) list.get(1)).intValue())) / 255,
                StrictMath.max(0, StrictMath.min(255, ((Double) list.get(2)).intValue())) / 255);
        LogoListBuilder hsbList = new LogoListBuilder();
        hsbList.add(Double.valueOf((argb >> 16) & 0xff));
        hsbList.add(Double.valueOf((argb >> 8) & 0xff));
        hsbList.add(Double.valueOf(argb & 0xff));
        return hsbList.toLogoList();
      } catch (ClassCastException e) {
        throw new org.nlogo.nvm.EngineException
            (context, this, displayName() + " an rgb list must contain only numbers");
      }
    } else if (obj instanceof Double) {
View Full Code Here

    try {
      int argb = java.awt.Color.HSBtoRGB
          (StrictMath.max(0, StrictMath.min(255, ((Double) list.get(0)).intValue())) / 255,
              StrictMath.max(0, StrictMath.min(255, ((Double) list.get(1)).intValue())) / 255,
              StrictMath.max(0, StrictMath.min(255, ((Double) list.get(2)).intValue())) / 255);
      LogoListBuilder hsbList = new LogoListBuilder();
      hsbList.add(Double.valueOf((argb >> 16) & 0xff));
      hsbList.add(Double.valueOf((argb >> 8) & 0xff));
      hsbList.add(Double.valueOf(argb & 0xff));
      return hsbList.toLogoList();
    } catch (ClassCastException e) {
      throw new org.nlogo.nvm.EngineException
          (context, this, displayName() + " an rgb list must contain only numbers");
    }
  }
View Full Code Here

        argEvalDoubleValue(context, 1),
        argEvalDoubleValue(context, 2));
  }

  public LogoList report_1(final Context context, double r, double g, double b) {
    LogoListBuilder rgbList = new LogoListBuilder();
    rgbList.add(Double.valueOf(StrictMath.max(0, StrictMath.min(255, r))));
    rgbList.add(Double.valueOf(StrictMath.max(0, StrictMath.min(255, g))));
    rgbList.add(Double.valueOf(StrictMath.max(0, StrictMath.min(255, b))));
    return rgbList.toLogoList();
  }
View Full Code Here

        currMaxCount = currVal;
      }
    }

    keys = counts.keySet().iterator();
    LogoListBuilder modes = new LogoListBuilder();
    while (keys.hasNext()) {
      LogoHashObject currKey = keys.next();
      int currVal = counts.get(currKey).value();
      if (currVal == currMaxCount) {
        modes.add(currKey.getSourceObject());
      }
    }
    return modes.toLogoList();
  }
View Full Code Here

public final strictfp class _basecolors
    extends Reporter {
  private static final LogoList colors = cache();

  private static LogoList cache() {
    LogoListBuilder result = new LogoListBuilder();
    for (int i = 0; i < 14; i++) {
      result.add(Double.valueOf(i * 10 + 5));
    }
    return result.toLogoList();
  }
View Full Code Here

TOP

Related Classes of org.nlogo.api.LogoListBuilder

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.