Пример #1
0
 /**
  * This method computes the central moment of a specifed order.
  *
  * @param n the order
  * @return the central moment of order n
  */
 public double getCentralMoment(int n) {
   if (n == 2 * (n / 2))
     return Functions.factorial(n)
         * Math.pow(scale, n)
         / (Functions.factorial(n / 2) * Math.pow(2, n / 2));
   else return 0;
 }
Пример #2
0
 private void CreateComStructureSmallworld() {
   // TODO Auto-generated method stub
   for (int i = 0; i < Agents.size(); i++) {
     for (int j = 0; j < para_ComStructure; j++) {
       int temp = (i + j + 1) % Agents.size();
       Agents.get(i).ComNeighbours.add(Agents.get(temp));
       Agents.get(temp).ComNeighbours.add(Agents.get(i));
       // System.out.println("i: "+i+" temp: "+temp);
     }
   }
   // System.exit(0);
   for (int i = 0; i < Agents.size(); i++) {
     for (int j = 0; j < Agents.get(i).ComNeighbours.size(); j++) {
       int range = 10;
       if (Functions.getRandom(0, Agents.size() - 1) < range) {
         Agent agent = Agents.get(Functions.getRandom(0, Agents.size() - 1));
         while (Agents.get(i).ComNeighbours.contains(agent) || agent == Agents.get(i)) {
           agent = Agents.get(Functions.getRandom(0, Agents.size() - 1));
         }
         // System.out.println("small world");
         // System.exit(0);
         Agents.get(i).ComNeighbours.get(j).ComNeighbours.remove(Agents.get(i));
         Agents.get(i).ComNeighbours.set(j, agent);
         agent.ComNeighbours.add(Agents.get(i));
       }
     }
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main_history);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
      ActionBar actionBar = getActionBar();
      actionBar.setDisplayHomeAsUpEnabled(true);
    }

    if (Functions.GetHistoryCount() == 0) {
      setTitle(R.string.history_none_text);
    } else {
      listview = (ListView) findViewById(R.id.history_list);
      listview.setOnItemClickListener(
          new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapter, View v, int position, long arg3) {
              String[] value = (String[]) adapter.getItemAtPosition(position);
              String[] searchText = value[1].split("#");
              Intent results = new Intent(HistoryActivity.this, ResultsActivity.class);
              results.putExtra(ResultsActivity.ARG_SEARCH_TEXT, searchText[1]);
              results.putExtra(ResultsActivity.ARG_LOG_SEARCH, false);
              HistoryActivity.this.startActivity(results);
            }
          });
      listview.setAdapter(new CustomListAdapter(this, Functions.GetHistoryList()));
    }
  }
Пример #4
0
 @Test
 public void sortByExample4() {
   List<Integer> example = asList(1, 3, 5, 2, 4, 6);
   final List<String> expected = asList("1", "3", "5", "2", "4", "6");
   assertEquals(
       expected,
       Algorithms.sortByExample(
           example,
           Strings.<Integer>string(),
           asList("6", "5", "4", "3", "2", "1"),
           Functions.<String>identity()));
   assertEquals(
       asList("3", "5", "4"),
       Algorithms.sortByExample(
           example,
           Strings.<Integer>string(),
           asList("5", "4", "3"),
           Functions.<String>identity()));
   assertEquals(
       expected,
       Algorithms.sortByExample(
           example,
           Strings.<Integer>string(),
           asList("1", "2", "3", "4", "5", "6", "7", "8", "9"),
           Functions.<String>identity()));
 }
Пример #5
0
 @Test
 public void attributeGreaterThan() {
   Integer one = 1;
   Assert.assertTrue(Predicates2.attributeGreaterThan(Functions.getToString()).accept(one, "0"));
   Assert.assertFalse(Predicates2.attributeGreaterThan(Functions.getToString()).accept(one, "1"));
   Assert.assertNotNull(Predicates2.attributeGreaterThan(Functions.getToString()).toString());
 }
Пример #6
0
 public String getNewBarcode() {
   if (barcode == null) {
     barcode = project + Functions.createCountString(barcodeID, 3) + "A";
     barcode = barcode + Functions.checksum(barcode);
   }
   barcode = Functions.incrementSampleCode(barcode);
   return barcode;
 }
  public void buttonClicked(View v) {
    TextView t = (TextView) findViewById(R.id.text);
    switch (v.getId()) {
      case R.id.buttonClear:
        StringBuffer sb = new StringBuffer(t.getText());
        if (sb.length() != 0) {
          sb.deleteCharAt(sb.length() - 1);
          t.setText(sb);
        }
        break;
      case R.id.buttonAdd:
        numbers.add(t.getText().toString());
        operators.add("+");
        t.setText("0");
        break;
      case R.id.buttonSubtract:
        numbers.add(t.getText().toString());
        operators.add("-");
        t.setText("0");
        break;
      case R.id.buttonMultiply:
        numbers.add(t.getText().toString());
        operators.add("*");
        t.setText("0");
        break;
      case R.id.buttonDivide:
        numbers.add(t.getText().toString());
        operators.add("/");
        t.setText("0");
        break;
      case R.id.buttonEquals:
        numbers.add(t.getText().toString());
        for (String s : numbers) {
          Log.i("MyActivitty", s);
        }
        for (String s : operators) Log.i("MyActivitty", s);
        double d = Double.parseDouble(numbers.get(0));
        for (int i = 0; i < numbers.size() - 1; i++) {
          switch (operators.get(i)) {
            case "+":
              d = Functions.add(d, Double.parseDouble(numbers.get(i + 1)));
              break;
            case "-":
              d = Functions.minus(d, Double.parseDouble(numbers.get(i + 1)));
              break;
            case "*":
              d = Functions.multiply(d, Double.parseDouble(numbers.get(i + 1)));
              break;
            case "/":
              d = Functions.divide(d, Double.parseDouble(numbers.get(i + 1)));
              break;
          }
        }
        t.setText(Double.toString(d));

        clearLists();
    }
  }
Пример #8
0
  public static void main(String[] args) {

    // Declare classes
    Functions functions = new Functions();
    Scanner keyboard = new Scanner(System.in);

    // Input data from keyboard
    System.out.print("Enter length: ");
    functions.length = keyboard.nextInt();

    System.out.print("Enter width: ");
    functions.width = keyboard.nextInt();

    System.out.print("Enter height: ");
    functions.height = keyboard.nextInt();

    System.out.print("Enter radius: ");
    functions.radius = keyboard.nextInt();

    // Call the Functions class
    functions.areaLength();
    functions.areaTriangle();
    functions.areaCircle();
    functions.volumeCube();
  }
Пример #9
0
 @Test
 public void attributeLessThanOrEqualTo() {
   Assert.assertFalse(
       Predicates2.attributeLessThanOrEqualTo(Functions.getToString()).accept(1, "0"));
   Assert.assertTrue(
       Predicates2.attributeLessThanOrEqualTo(Functions.getToString()).accept(1, "1"));
   Assert.assertTrue(
       Predicates2.attributeLessThanOrEqualTo(Functions.getToString()).accept(1, "2"));
   Assert.assertNotNull(
       Predicates2.attributeLessThanOrEqualTo(Functions.getToString()).toString());
 }
  public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {

    if (Functions.isSimulation()) {

      Functions.ChattoPlayer(entityplayer, ":-) Wait for Beta 6");
      Functions.ChattoPlayer(
          entityplayer, Functions.getTAGfromItemstack(itemstack).getString("name"));
    }

    return itemstack;
  }
 public void draw(Graphics g) {
   if (System.currentTimeMillis() - start_time > DURATION) {
     client.other_graphics.remove(this);
   } else {
     g.setColor(col);
     g.drawLine(
         this.rect.x - Client.view.x_pos,
         this.rect.y - Client.view.y_pos,
         x2 - Client.view.x_pos + Functions.rnd(-FX_RADIUS, FX_RADIUS),
         y2 - Client.view.y_pos + Functions.rnd(-FX_RADIUS, FX_RADIUS));
   }
 }
Пример #12
0
 @Test
 public void attributeIn_MultiTypes() {
   MutableList<String> stringInts = Lists.fixedSize.of("1", "2");
   Assert.assertTrue(Predicates2.attributeIn(Functions.getToString()).accept(1, stringInts));
   Assert.assertFalse(Predicates2.attributeIn(Functions.getToString()).accept(3, stringInts));
   Assert.assertFalse(Predicates2.attributeIn(Functions.getToString()).accept(3, stringInts));
   MutableList<Integer> intList = Lists.fixedSize.of(1, 3);
   MutableList<Integer> newList =
       ListIterate.filterWith(
           intList, Predicates2.attributeIn(Functions.getToString()), stringInts);
   Assert.assertEquals(FastList.newListWith(1), newList);
 }
Пример #13
0
 public static <T, V extends Comparable<? super V>> SerializableComparator<T> byFunction(
     Function<? super T, ? extends V> function) {
   if (function instanceof IntFunction) {
     return Functions.toIntComparator((IntFunction<T>) function);
   }
   if (function instanceof DoubleFunction) {
     return Functions.toDoubleComparator((DoubleFunction<T>) function);
   }
   if (function instanceof LongFunction) {
     return Functions.toLongComparator((LongFunction<T>) function);
   }
   return Comparators.byFunction(function, naturalOrder());
 }
Пример #14
0
  public void login(View view) {
    editText = (EditText) findViewById(R.id.editText);
    textView = (TextView) findViewById(R.id.textView);
    textView2 = (TextView) findViewById(R.id.textView2);
    textView3 = (TextView) findViewById(R.id.textView3);
    user = editText.getText().toString();
    textView.setText(user);
    functions.count_roses(
        Home.this,
        user,
        new Functions.VolleyCallback() {
          @Override
          public void onSuccess(int[] result) {
            textView2.setText("" + result[0]);
            textView3.setText("" + result[1]);
          }
        });

    functions.get_users(
        Home.this,
        new Functions.VolleyCallback1() {
          @Override
          public void onSuccess(String[] result) {
            arrayAdapter =
                new ArrayAdapter<String>(
                    getApplicationContext(), R.layout.support_simple_spinner_dropdown_item, result);
            autoCompleteTextView.setAdapter(arrayAdapter);
          }
        });
    autoCompleteTextView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            receiver = arrayAdapter.getItem(position).toString();
          }
        });
    autoCompleteTextView.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            receiver = null;
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
  public void LoadInfos() {
    mProgress =
        ProgressDialog.show(
            this, this.getText(R.string.loading), this.getText(R.string.loadingtext), true, false);

    int catid = getIntent().getExtras().getInt("id");
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    String terminal = pref.getString("terminal", "phone");
    String sdk = Build.VERSION.SDK;
    String lang =
        getApplicationContext().getResources().getConfiguration().locale.getISO3Language();
    try {
      Tools.queryWeb(
          Functions.getHost(getApplicationContext())
              + "/categories/applications.php?page="
              + pageFree
              + "&order="
              + order
              + "&catid="
              + catid
              + "&lang="
              + lang
              + "&sdk="
              + URLEncoder.encode(sdk, "UTF-8")
              + "&paid=0&terminal="
              + URLEncoder.encode(terminal, "UTF-8")
              + "&ypass="******"/categories/applications.php?page="
              + pagePaid
              + "&order="
              + order
              + "&catid="
              + catid
              + "&lang="
              + lang
              + "&sdk="
              + URLEncoder.encode(sdk, "UTF-8")
              + "&paid=1&terminal="
              + URLEncoder.encode(terminal, "UTF-8")
              + "&ypass="
              + Functions.getPassword(getApplicationContext()),
          parserPaid);
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
  }
Пример #16
0
  /* Resizing sampling modes */
  private BufferedImage nearestNeighbourSampling(
      int originalWidth,
      int originalHeight,
      int newWidth,
      int newHeight,
      int slice,
      int direction) {
    BufferedImage newImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_3BYTE_BGR);
    int i, j, c, k;

    byte[] newData = Functions.getImageData(newImage);
    double col;
    short datum;
    int I, J;

    for (j = 0; j < newHeight; j++) {
      for (i = 0; i < newWidth; i++) {
        J = (int) (j * (double) originalHeight / (double) newHeight);
        I = (int) (i * (double) originalWidth / (double) newWidth);

        switch (direction) {
          case 1:
            datum = volume[slice][J][I];
            break;

          case 2:
            datum = volume[J][I][slice];
            break;

          case 3:
            datum = volume[J][slice][I];
            break;

          default:
            datum = 0;
        }

        // calculate the colour by performing a mapping from [min,max] -> [0,255]
        col = Functions.equalizeColourTo255(this, datum);
        for (c = 0; c < 3; c++) {
          // and now we are looping through the bgr components of the pixel
          // set the colour component c of pixel (i,j)
          newData[c + 3 * i + 3 * j * newWidth] = (byte) col;
        } // colour loop
      } // column loop
    } // row loop

    return newImage;
  }
Пример #17
0
 public static boolean win_res(Pos position) {
   if (Functions.pieceCount("STONE") == 0) {
     return true;
   } else {
     return false;
   }
 }
 /**
  * This method recursively process the directory folder
  *
  * @param dataDir directory of the data to be preprocessed
  * @throws java.lang.Exception
  */
 public void process(String dataDir) throws Exception {
   TextFilesFilter filter = new TextFilesFilter();
   File f = new File(dataDir);
   File[] listFiles = f.listFiles();
   for (File listFile : listFiles) {
     if (listFile.isDirectory()) {
       process(listFile.toString());
     } else {
       if (!listFile.isHidden()
           && listFile.exists()
           && listFile.canRead()
           && filter.accept(listFile)) {
         nbrDocs++;
         long start = System.currentTimeMillis();
         File unZippedFile = new File(listFile.getAbsolutePath().replaceFirst("[.][^.]+$", ""));
         unZipIt(listFile, unZippedFile);
         int total = parseFile(unZippedFile);
         long end = System.currentTimeMillis();
         long millis = (end - start);
         System.err.println(
             "A total of "
                 + total
                 + " lines were parsed from the file "
                 + listFile.getName()
                 + " in "
                 + Functions.getTimer(millis)
                 + ".");
         unZippedFile.delete();
       }
     }
   }
 }
 /**
  * @param args the command line arguments
  * @throws java.lang.Exception
  */
 public static void main(String[] args) throws Exception {
   // TODO code application logic here
   String dataDir;
   if (args.length == 0) {
     System.err.println(
         "ERROR: incorrect parameters for eecs.oregonstate.edu.preproccessing.preproccessing! "
             + "only "
             + args.length
             + " parameters :-(");
     System.err.println("Usage: java -jar PatentSearch.jar [options]");
     System.err.println("[options] have to be defined in the following order:");
     System.err.println("[-dataDir]: directory of the data");
     System.err.println("[-outDir]: output directory.");
   } else {
     //            args = new String[1];
     //            args[0] = "/Users/rbouadjenek/Documents/SocialMediaAnalysis/dataset/";
     dataDir = args[0];
     AddingIds pre = new AddingIds(args[1], Integer.parseInt(args[2]));
     long start = System.currentTimeMillis();
     pre.process(dataDir);
     long end = System.currentTimeMillis();
     long millis = (end - start);
     System.err.println(
         "------------------------------------------------------------------------");
     System.err.println(
         "There are "
             + pre.getNbrDocs()
             + " documents processed in "
             + Functions.getTimer(millis)
             + ".");
     System.err.println(
         "------------------------------------------------------------------------");
   }
 }
  public void addfreqcard() {

    if (getStackInSlot(0) != null) {

      if (getStackInSlot(0).getItem() == mod_ModularForceFieldSystem.MFFSitemsclc) {

        if (linkMonitor_ID
            != Functions.getTAGfromItemstack(getStackInSlot(0)).getInteger("RMonitorID")) {
          linkMonitor_ID =
              Functions.getTAGfromItemstack(getStackInSlot(0)).getInteger("RMonitorID");
        }
      }
    } else {
      linkMonitor_ID = 0;
    }
  }
Пример #21
0
  /**
   * Returns the string representation of CK_SLOT_INFO.
   *
   * @return the string representation of CK_SLOT_INFO
   */
  public String toString() {
    StringBuffer buffer = new StringBuffer();

    buffer.append(Constants.INDENT);
    buffer.append("slotDescription: ");
    buffer.append(new String(slotDescription));
    buffer.append(Constants.NEWLINE);

    buffer.append(Constants.INDENT);
    buffer.append("manufacturerID: ");
    buffer.append(new String(manufacturerID));
    buffer.append(Constants.NEWLINE);

    buffer.append(Constants.INDENT);
    buffer.append("flags: ");
    buffer.append(Functions.slotInfoFlagsToString(flags));
    buffer.append(Constants.NEWLINE);

    buffer.append(Constants.INDENT);
    buffer.append("hardwareVersion: ");
    buffer.append(hardwareVersion.toString());
    buffer.append(Constants.NEWLINE);

    buffer.append(Constants.INDENT);
    buffer.append("firmwareVersion: ");
    buffer.append(firmwareVersion.toString());
    // buffer.append(Constants.NEWLINE);

    return buffer.toString();
  }
Пример #22
0
 RealtimMultiSync(String _myurl, String _code) {
   myurl = _myurl;
   code = Functions.getFormattedSHSZ(_code);
   // default is true
   saveHistory = true;
   voltmp = 0;
 }
Пример #23
0
 RealtimMultiSync(String _myurl, String _code, String _saveHistoryType) {
   myurl = _myurl;
   code = Functions.getFormattedSHSZ(_code);
   saveHistoryType = _saveHistoryType;
   voltmp = 0;
   sv = new ServerDataRetriever();
 }
Пример #24
0
 public static boolean remove_res(Pos position) {
   if (Functions.getPiece(position) != null) {
     return true;
   } else {
     return false;
   }
 }
Пример #25
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    // Actual logic goes here.

    // System.out.print("Test");

    StringBuilder sb = new StringBuilder();
    try (BufferedReader reader = request.getReader()) {
      String line;
      while ((line = reader.readLine()) != null) {
        sb.append(line).append('\n');
      }
    }

    try {
      JSONObject jsonObject = new JSONObject(sb.toString());

      JSONObject message = jsonObject.getJSONObject("message");
      String command = message.getString("text");
      if (BotHelper.command(command, "/echo")) {
        functions.echo(jsonObject);
      } else if (BotHelper.command(command, "/engage")) {
        functions.engage(jsonObject);
      } else if (BotHelper.command(command, "/debug")) {
        functions.debugjson(jsonObject);
      } else if (BotHelper.command(command, "/amazon")) {
        functions.searchAmazon(jsonObject);
      } else if (BotHelper.command(command, "/decide")) {
        functions.decide(jsonObject);
      } else if (BotHelper.command(command, "/ohkadsewasessenwirheute")) {
        functions.ohkadsewasessenwirheute(jsonObject);
      } else if (BotHelper.command(command, "/ohmagischekadse")) {
        functions.ohmagischekadse(jsonObject);
      } else if (BotHelper.command(command, "/otherchat")) {
        functions.otherChat(jsonObject);
      } else if ((BotHelper.command(command, "/help")) || (BotHelper.command(command, "/?"))) {
        functions.help(jsonObject);
      } else {
        functions.unknown(jsonObject);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #26
0
  private BufferedImage cropScaleGrayscale(Rectangle visibleRect, RenderedImage image) {
    int minX = image.getMinX();
    int minY = image.getMinY();
    int width = image.getWidth();
    int height = image.getHeight();

    Rectangle bounds = new Rectangle(minX, minY, width, height);

    visibleRect = bounds.intersection(visibleRect);

    if (bounds.contains(visibleRect)) {
      ParameterBlock pb = new ParameterBlock();
      pb.addSource(image);
      pb.add((float) visibleRect.x);
      pb.add((float) visibleRect.y);
      pb.add((float) visibleRect.width);
      pb.add((float) visibleRect.height);
      image = JAI.create("Crop", pb, JAIContext.noCacheHint);
    }
    Dimension previewSize = getSize();

    if ((visibleRect.width > previewSize.width) || (visibleRect.height > previewSize.height)) {
      float scale =
          Math.min(
              previewSize.width / (float) visibleRect.width,
              previewSize.height / (float) visibleRect.height);

      image = ConvolveDescriptor.create(image, Functions.getGaussKernel(.25 / scale), null);
      ParameterBlock pb = new ParameterBlock();
      pb.addSource(image);
      pb.add(scale);
      pb.add(scale);
      image = JAI.create("Scale", pb, JAIContext.noCacheHint);
    }
    image = Functions.toColorSpace(image, JAIContext.systemColorSpace, null);

    if (image.getSampleModel().getDataType() == DataBuffer.TYPE_USHORT) {
      image = Functions.fromUShortToByte(image, null);
    }
    return Functions.toFastBufferedImage(image);
  }
  public void updateEntity() {

    if (Functions.isSimulation()) {

      addfreqcard();

      if (this.getLinkMonitor_ID() != 0) {
        this.setLinkMonitor(true);
        try {

          channel =
              Linkgrid.getWorldMap(worldObj)
                  .getRMonitor()
                  .get(this.getLinkMonitor_ID())
                  .getChannel();
          Montorname =
              Linkgrid.getWorldMap(worldObj)
                  .getRMonitor()
                  .get(this.getLinkMonitor_ID())
                  .getMontorname();
          setConectet_ID(getLinkMonitor_ID());

        } catch (java.lang.NullPointerException ex) {
          this.setLinkMonitor(false);
          this.setLinkMonitor_ID(0);
          this.setMontorname("null");
          this.setConectet_ID(0);
          // System.out.println("!!ERROR!!!");
        }
      } else {
        this.setLinkMonitor(false);
        this.setConectet_ID(0);
        this.setMontorname("null");
      }

      if (this.isLinkMonitor()) {

        if (channel[usechannel]) {
          if (this.isSignal() != true) {
            this.setSignal(true);
            worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
            this.notifyNeighbors(worldObj, xCoord, yCoord, zCoord);
          }
        } else {
          if (this.isSignal() != false) {
            this.setSignal(false);
            worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
            this.notifyNeighbors(worldObj, xCoord, yCoord, zCoord);
          }
        }
      }
    }
  }
  @Override
  public boolean onMenuItemSelected(int featureId, MenuItem item) {
    super.onMenuItemSelected(featureId, item);
    if (item.getItemId() == R.id.action_clearhistory) {
      Log.d(TAG, "Clear history");
      Functions.ClearHistory();
      finish();
      startActivity(getIntent());
    }

    return true;
  }
Пример #29
0
  public BufferedImage maximumIntensityProjection(int direction) {
    int w = X, h = (direction == 1) ? Y : Z;
    int z = (direction == 1) ? Z : Y;
    short maximum;

    BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR);

    int i, j, c, k;
    // Obtain pointer to data for fast processing
    byte[] data = Functions.getImageData(image);

    // System.out.println(data);

    double col;
    short datum;
    // Shows how to loop through each pixel and colour
    // Try to always use j for loops in y, and i for loops in x
    // as this makes the code more readable
    for (j = 0; j < h; j++) {
      for (i = 0; i < w; i++) {
        maximum = this.min;

        for (k = 0; k < z; k++)
          switch (direction) {
            case 1:
              maximum = (volume[k][j][i] > maximum) ? volume[k][j][i] : maximum;
              break;

            case 2:
              maximum = (volume[j][i][k] > maximum) ? volume[j][i][k] : maximum;
              break;

            case 3:
              maximum = (volume[j][k][i] > maximum) ? volume[j][k][i] : maximum;
              break;

            default:
              maximum = 0;
          }

        // calculate the colour by performing a mapping from [min,max] -> [0,255]
        col = (255.0f * ((double) maximum - (double) min) / ((double) (max - min)));
        for (c = 0; c < 3; c++) {
          // and now we are looping through the bgr components of the pixel
          // set the colour component c of pixel (i,j)
          data[c + 3 * i + 3 * j * w] = (byte) col;
        } // colour loop
      } // column loop
    } // row loop

    return image;
  }
Пример #30
0
 @SuppressWarnings("unused")
 private void addRandomCooperation() {
   // TODO Auto-generated method stub
   for (int i = 0; i < Agents.size(); i++) {
     boolean newCooperation = false;
     while (!newCooperation) {
       int random = Functions.getRandom(0, Agents.size() - 1);
       if (!Agents.get(i).CoopNeighbours.contains(Agents.get(random))) {
         newCooperation = true;
         Agents.get(i).CoopNeighbours.add(Agents.get(random));
       }
     }
   }
 }