Exemplo n.º 1
0
  @Override
  public int getValues(Sprite sprite, int i, float[] floats) {
    switch (Mode.values()[i]) {
      case SCALE:
        floats[0] = sprite.getScaleX();
        return 1;

      case ALPHA:
        floats[0] = sprite.getColor().a;
        return 1;

      case POSITION:
        floats[0] = sprite.getX();
        floats[1] = sprite.getY();
        return 2;

      case ROTATION:
        floats[0] = sprite.getRotation();
        return 1;

      default:
        assert false;
        return -1;
    }
  }
Exemplo n.º 2
0
  @Override
  public void setValues(Sprite sprite, int i, float[] floats) {
    switch (Mode.values()[i]) {
      case SCALE:
        sprite.setScale(floats[0]);
        break;

      case ALPHA:
        Color color = sprite.getColor();
        sprite.setColor(color.r, color.g, color.b, floats[0]);
        break;

      case POSITION:
        sprite.setX(floats[0]);
        sprite.setY(floats[1]);
        break;

      case ROTATION:
        sprite.setRotation(floats[0]);
        break;

      default:
        assert false;
    }
  }
Exemplo n.º 3
0
 public static List<String> modeNames() {
   List<String> modeNames = new ArrayList<String>();
   for (Mode mode : Mode.values()) {
     modeNames.add(mode.modeName);
   }
   return modeNames;
 }
Exemplo n.º 4
0
  private void init() {
    database.addObserver(this);

    for (final Mode currMode : Mode.values()) {
      getButton(currMode)
          .setOnClickListener(
              new View.OnClickListener() {
                public void onClick(View v) {
                  filters.clear();
                  filterListAdapter.clear();
                  for (Filter<? super Tables.Tracks> permanentFilter : permanentFilters) {
                    filterListAdapter.add(permanentFilter);
                  }
                  List<Filter<? super Tables.Tracks>> filtersToRemove =
                      new ArrayList<Filter<? super Tables.Tracks>>();
                  for (Filter<? super Tables.Tracks> filterAddedWithMode :
                      filtersAddWithMode.get(currMode)) {
                    if (!permanentFilters.contains(filterAddedWithMode)) {
                      filtersToRemove.add(filterAddedWithMode);
                    }
                  }

                  filtersAddWithMode.get(currMode).removeAll(filtersToRemove);

                  change(currMode, null, false);
                }
              });
    }
  }
        /** Parse XJC-specific options. */
        public int parseArgument(String[] args, int i) throws BadCommandLineException {
            if (args[i].equals("-noNS")) {
                noNS = true;
                return 1;
            }
            if (args[i].equals("-mode")) {
                i++;
                if (i == args.length)
                    throw new BadCommandLineException(
                        Messages.format(Messages.MISSING_MODE_OPERAND));

                String mstr = args[i].toLowerCase();

                for( Mode m : Mode.values() ) {
                    if(m.name().toLowerCase().startsWith(mstr) && mstr.length()>2) {
                        mode = m;
                        return 2;
                    }
                }

                throw new BadCommandLineException(
                    Messages.format(Messages.UNRECOGNIZED_MODE, args[i]));
            }
            if (args[i].equals("-help")) {
                usage(this,false);
                throw new WeAreDone();
            }
            if (args[i].equals("-private")) {
                usage(this,true);
                throw new WeAreDone();
            }

            return super.parseArgument(args, i);
        }
Exemplo n.º 6
0
 public Usr(byte[] data) {
   mMac = extractMac(Arrays.copyOfRange(data, 0, 6));
   mDestIp = BinaryConversion.bytesToIp(Arrays.copyOfRange(data, 7, 11));
   mDestPort = BinaryConversion.bytesToNumber(Arrays.copyOfRange(data, 11, 13));
   mHostIp = BinaryConversion.bytesToIp(Arrays.copyOfRange(data, 13, 17));
   mHostPort = BinaryConversion.bytesToNumber(Arrays.copyOfRange(data, 17, 19));
   mGatewayIp = BinaryConversion.bytesToIp(Arrays.copyOfRange(data, 19, 23));
   int mode = (data[23] & 0xFF);
   if (mode < Mode.values().length) mMode = Mode.values()[mode];
   else mMode = Mode.Unknown;
   mBaud = BinaryConversion.bytesToNumber(Arrays.copyOfRange(data, 24, 27));
   System.out.println("[FOUND] " + BinaryConversion.bytesToHex(data));
   if (!DEBUG) return;
   System.out.println("mac: " + mMac);
   System.out.println("dest: " + mDestIp + " " + Integer.toString(mDestPort));
   System.out.println("host: " + mHostIp + " " + Integer.toString(mHostPort));
   System.out.println("gateway: " + mGatewayIp);
   System.out.println("mode: " + mMode + " baud: " + Integer.toString(mBaud));
 }
Exemplo n.º 7
0
    /**
     * Maps an int to a specific mode. This is needed when saving state, or inflating the view from
     * XML where the mode is given through a attr int.
     *
     * @param modeInt - int to map a Mode to
     * @return Mode that modeInt maps to, or PULL_FROM_START by default.
     */
    static Mode mapIntToValue(final int modeInt) {
      for (Mode value : Mode.values()) {
        if (modeInt == value.getIntValue()) {
          return value;
        }
      }

      // If not, return default
      return getDefault();
    }
Exemplo n.º 8
0
  public ExtIntegrator() {
    super("Integrates individual results to experiment level results.");

    Argument arg = new Argument(OPT_INPUT, 'i', "input");
    arg.setParamName("ScoresInput1.tsv,ScoresInput2.tsv,...");
    arg.setDescription("Inputs TSV score files.");
    addOption(arg);

    arg = new Argument(OPT_MODE, 'm', "mode");
    arg.setChoices(Strings.fromArray(Mode.values()));
    arg.setDescription("Probabilities integration mode.");
    addOption(arg);

    arg = new Argument(OPT_OUTPUT, 'o', "output");
    arg.setParamName("ScoresOutput.tsv");
    arg.setDescription("Output TSV score file.");
    addOption(arg);
  }
Exemplo n.º 9
0
 @Override
 public void display(GLAutoDrawable drawable) {
   final GL3bc gl = drawable.getGL().getGL3bc();
   float color = ((float) currentMode.ordinal() + 1) / (Mode.values().length + 2);
   gl.glClearColor(color, color, color, 0);
   gl.glClear(GL3.GL_COLOR_BUFFER_BIT | GL3.GL_DEPTH_BUFFER_BIT);
   gl.glUseProgram(progID);
   final Mode newMode;
   {
     currentModeIdx = (currentModeIdx + 1) % allModes.length;
     newMode = allModes[currentModeIdx];
   }
   if (newMode != currentMode) {
     currentMode = newMode;
     System.out.println("Display mode: " + currentMode);
   }
   currentMode.display(this, gl);
   gl.glUseProgram(0);
 }
Exemplo n.º 10
0
  /**
   * @param toMode
   * @param filter - filter to add, can be null
   */
  public void change(Mode toMode, final Filter<? super Tables.Tracks> filter, boolean permanant) {
    if (filter != null) {
      filtersAddWithMode.get(currMode).add(filter);
      addFilter(filter, permanant);
    }

    currMode = toMode;
    for (final Mode aMode : Mode.values()) {
      final ImageView button = getButton(aMode);
      button.post(
          new Runnable() {
            public void run() {
              button.setImageResource(
                  aMode.equals(currMode) ? aMode.drawableActive : aMode.drawable);
            }
          });
    }
    update();
  }
Exemplo n.º 11
0
  /**
   * Tool main method.
   *
   * @param args the tool arguments
   * @throws Exception if an error occurs
   */
  public static void main(String[] args) throws Exception {
    final SequenceFileTool options = new SequenceFileTool();
    final CmdLineParser parser = new CmdLineParser(options);

    try {
      parser.parseArgument(args);
    } catch (final CmdLineException e) {
      System.err.println(e.getMessage());
      System.err.println("Usage: java -jar SequenceFileTool.jar [options...]");
      parser.printUsage(System.err);

      if (options.mode == null) {
        for (final Mode m : Mode.values()) {
          System.err.println();
          System.err.println(m + " options: ");
          new CmdLineParser(m.getOptions()).printUsage(System.err);
        }
      }
      return;
    }

    options.execute();
  }
Exemplo n.º 12
0
  @Override
  public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry)
      throws MappingNotFoundException {
    mode = Mode.values()[nbt.getByte("mode")];
    x = nbt.getInteger("x");
    y = nbt.getInteger("y");
    z = nbt.getInteger("z");

    if (nbt.hasKey("schematic")) {
      schematic =
          (SchematicBlockBase)
              SchematicFactory.createSchematicFromWorldNBT(
                  nbt.getCompoundTag("schematic"), registry);
    }

    stackConsumed = new LinkedList<ItemStack>();

    NBTTagList nbtStacks = nbt.getTagList("stackConsumed", Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < nbtStacks.tagCount(); ++i) {
      stackConsumed.add(ItemStack.loadItemStackFromNBT(nbtStacks.getCompoundTagAt(i)));
    }
  }
Exemplo n.º 13
0
 protected void test() {
   test("ArrayQueue", 1, Mode.values());
 }
Exemplo n.º 14
0
  public FileChooser(Mode currMode, final TurtlePlayer tp, Player listActivity) {
    for (Mode mode : Mode.values()) {
      filtersAddWithMode.put(mode, new ArrayList<Filter<? super Tables.Tracks>>());
    }

    this.currMode = currMode;
    this.database = tp.db;
    this.preferences = tp.playlist.preferences;
    this.listActivity = listActivity;

    tp.playlist.preferences.addObserver(
        new PreferencesObserver() {
          public void changed(AbstractKey<?, ?> key) {
            if (key.equals(Keys.MEDIA_DIR)) {
              final String mediaDir = tp.playlist.preferences.get(Keys.MEDIA_DIR);
              getFilter()
                  .accept(
                      new TurtleFilterVisitor<Tables.Tracks, Void>() {
                        public Void visit(DirFilter dirFilter) {
                          if (!dirFilter.filtersInPath(mediaDir)) {
                            removeFilter(dirFilter);
                            update();
                          }
                          return null;
                        }

                        public <T, Z> Void visit(
                            FieldFilter<? super Tables.Tracks, Z, T> fieldFilter) {
                          return null;
                        }

                        public Void visit(FilterSet<? super Tables.Tracks> filterSet) {
                          return null;
                        }

                        public Void visit(NotFilter<? super Tables.Tracks> notFilter) {
                          return null;
                        }
                      });
            }
          }

          public String getId() {
            return "OutdatedFilterUpdater";
          }
        });

    filterList = (ListView) listActivity.findViewById(R.id.filterlist);
    filterListAdapter =
        new FilterListAdapter(
            listActivity.getApplicationContext(),
            new ArrayList<Filter<? super Tables.Tracks>>(getFilters())) {
          @Override
          protected void removeFilter(final Filter<? super Tables.Tracks> filter) {
            FileChooser.this.removeFilter(filter);
            update();
          }

          @Override
          protected void chooseFilter(Filter<? super Tables.Tracks> filter) {
            filterChoosen(filter);
          }
        };

    filterList.setAdapter(filterListAdapter);

    listAdapter =
        new DefaultAdapter<Instance>(
            listActivity.getApplicationContext(),
            new ArrayList<Instance>(),
            listActivity,
            false,
            InstanceFormatter.SHORT);

    listActivity.setListAdapter(listAdapter);

    change(currMode, null, false);

    init();
  }