Exemplo n.º 1
0
 /**
  * Computes the empirical distribution using data read from a URL.
  *
  * @param url url of the input file
  * @throws IOException if an IO error occurs
  */
 public void load(URL url) throws IOException {
   BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
   try {
     DataAdapter da = new StreamDataAdapter(in);
     try {
       da.computeStats();
     } catch (IOException ioe) {
       // don't wrap exceptions which are already IOException
       throw ioe;
     } catch (RuntimeException rte) {
       // don't wrap RuntimeExceptions
       throw rte;
     } catch (Exception e) {
       throw MathRuntimeException.createIOException(e);
     }
     if (sampleStats.getN() == 0) {
       throw MathRuntimeException.createEOFException("URL {0} contains no data", url);
     }
     in = new BufferedReader(new InputStreamReader(url.openStream()));
     fillBinStats(in);
     loaded = true;
   } finally {
     try {
       in.close();
     } catch (IOException ex) {
       // ignore
     }
   }
 }
Exemplo n.º 2
0
  private void initView(View layout) {
    lamp = layout.findViewById(R.id.v_lamp);
    menuLv = (ListView) layout.findViewById(R.id.lv_menu);
    subjectLv = (ListView) layout.findViewById(R.id.lv_subject);
    foldBtn = layout.findViewById(R.id.ll_title_sp);
    foldContent = layout.findViewById(R.id.ll_lv_sp);
    RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) foldBtn.getLayoutParams();
    lp.leftMargin = location[0];
    lp.topMargin = location[1];
    foldBtn.setLayoutParams(lp);
    foldBtn.setOnClickListener(this);
    lamp.setOnClickListener(this);
    menuAdapter = new DataAdapter(getActivity().getBaseContext());

    menuAdapter.setData(allocateData());
    menuLv.setAdapter(menuAdapter);
    menuLv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            menuAdapter.checked(i);
            subjectAdapter.setData(allocateSubject());
            subjectAdapter.notifyDataSetChanged();
          }
        });
    subjectAdapter = new DataAdapter(getActivity().getBaseContext());
    subjectAdapter.checked(-1);
    subjectAdapter.setData(allocateSubject());
    subjectLv.setAdapter(subjectAdapter);
  }
Exemplo n.º 3
0
 /**
  * Computes the empirical distribution from the input file.
  *
  * @param file the input file
  * @throws IOException if an IO error occurs
  */
 public void load(File file) throws IOException {
   BufferedReader in = new BufferedReader(new FileReader(file));
   try {
     DataAdapter da = new StreamDataAdapter(in);
     try {
       da.computeStats();
     } catch (IOException ioe) {
       // don't wrap exceptions which are already IOException
       throw ioe;
     } catch (RuntimeException rte) {
       // don't wrap RuntimeExceptions
       throw rte;
     } catch (Exception e) {
       throw MathRuntimeException.createIOException(e);
     }
     in = new BufferedReader(new FileReader(file));
     fillBinStats(in);
     loaded = true;
   } finally {
     try {
       in.close();
     } catch (IOException ex) {
       // ignore
     }
   }
 }
Exemplo n.º 4
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (ACTIVITY_EDIT == requestCode) {
      if (RESULT_OK == resultCode) {
        //  			Toast.makeText(getApplicationContext(), "result", Toast.LENGTH_LONG).show();

        NoteItem noteItem = new NoteItem();
        String strAction = data.getStringExtra("ACTION");
        noteItem.m_nLocalId = data.getIntExtra("NOTE_LOCAL_ID", -1);

        // delete
        if (strAction.equalsIgnoreCase("DELETE")) {
          m_itemAdapter.deleteNoteItem(noteItem.m_nLocalId);
          return;
        }

        noteItem.m_nId = data.getIntExtra("NOTE_ID", -1);
        noteItem.m_nType = data.getIntExtra("NOTE_TYPE", 1);
        noteItem.m_strTitle = data.getStringExtra("NOTE_TITLE");
        noteItem.setSetAt(data.getStringExtra("NOTE_SET_AT"));
        noteItem.setUpdatedAt(data.getStringExtra("NOTE_UPDATED_AT"));

        // new
        if (strAction.equalsIgnoreCase("NEW")) {
          // created at
          noteItem.setCreatedAt(data.getStringExtra("NOTE_CREATED_AT"));
          m_itemAdapter.addNoteItem(noteItem);
          // update
        } else if (strAction.equalsIgnoreCase("UPDATE")) {
          m_itemAdapter.updateNoteItem(noteItem);
        }
      }
    }
  }
Exemplo n.º 5
0
 /**
  * Computes the empirical distribution from the provided array of numbers.
  *
  * @param in the input data array
  */
 public void load(double[] in) {
   DataAdapter da = new ArrayDataAdapter(in);
   try {
     da.computeStats();
     fillBinStats(in);
   } catch (Exception e) {
     throw new MathRuntimeException(e);
   }
   loaded = true;
 }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.homecall_list);

    // 선언한 리스트뷰에 사용할 리스뷰연결
    listview = (ListView) findViewById(R.id.nurselist);
    // 객체를 생성합니다
    alist = new ArrayList<CData>();
    // 데이터를 받기위해 데이터어댑터 객체 선언
    adapter = new DataAdapter(this, alist);
    // 리스트뷰에 어댑터 연결
    listview.setAdapter(adapter);

    // ArrayAdapter를 통해서 ArrayList에 자료 저장
    // 하나의 String값을 저장하던 것을 CData클래스의 객체를 저장하던것으로 변경
    // CData 객체는 생성자에 리스트 표시 텍스트뷰1의 내용과 텍스트뷰2의 내용 그리고 사진이미지값을 어댑터에 연결

    // CData클래스를 만들때의 순서대로 해당 인수값을 입력
    // 한줄 한줄이 리스트뷰에 뿌려질 한줄 한줄이라고 생각하면 됨
    adapter.add(
        new CData(
            getApplicationContext(), "경영대학", "http://biz.pusan.ac.kr/", R.drawable.ic_launcher));
  }
 /** Requests the list of all lost packages */
 private void buttonShowLostActionPerformed(ActionEvent event) {
   this.packages = DataAdapter.getLostPackages();
   this.jListPackages.setListData(new Vector(this.packages));
   jButtonSetLost.setEnabled(false);
   jButtonSetFound.setEnabled(this.packages.size() > 0);
   jListScans.setListData(new Vector());
 }
Exemplo n.º 8
0
  /**
   * Fills binStats array (second pass through data file).
   *
   * @param in object providing access to the data
   * @throws IOException if an IO error occurs
   */
  private void fillBinStats(Object in) throws IOException {
    // Load array of bin upper bounds -- evenly spaced from min - max
    double min = sampleStats.getMin();
    double max = sampleStats.getMax();
    double delta = (max - min) / (Double.valueOf(binCount)).doubleValue();
    double[] binUpperBounds = new double[binCount];
    binUpperBounds[0] = min + delta;
    for (int i = 1; i < binCount - 1; i++) {
      binUpperBounds[i] = binUpperBounds[i - 1] + delta;
    }
    binUpperBounds[binCount - 1] = max;

    // Initialize binStats ArrayList
    if (!binStats.isEmpty()) {
      binStats.clear();
    }
    for (int i = 0; i < binCount; i++) {
      SummaryStatistics stats = new SummaryStatistics();
      binStats.add(i, stats);
    }

    // Filling data in binStats Array
    DataAdapterFactory aFactory = new DataAdapterFactory();
    DataAdapter da = aFactory.getAdapter(in);
    try {
      da.computeBinStats(min, delta);
    } catch (IOException ioe) {
      // don't wrap exceptions which are already IOException
      throw ioe;
    } catch (RuntimeException rte) {
      // don't wrap RuntimeExceptions
      throw rte;
    } catch (Exception e) {
      throw MathRuntimeException.createIOException(e);
    }

    // Assign upperBounds based on bin counts
    upperBounds = new double[binCount];
    upperBounds[0] = ((double) binStats.get(0).getN()) / (double) sampleStats.getN();
    for (int i = 1; i < binCount - 1; i++) {
      upperBounds[i] =
          upperBounds[i - 1] + ((double) binStats.get(i).getN()) / (double) sampleStats.getN();
    }
    upperBounds[binCount - 1] = 1.0d;
  }
 /** Requests and displays all packages older than the date in the text field */
 private void buttonOldPackagesActionPerformed(ActionEvent event) {
   try {
     queryTime.setTime(dateFormatter.parse(jTextDate.getText().replace("-", "") + "2359"));
     this.packages = DataAdapter.getOlderPackages(queryTime);
     jListPackages.setListData(new Vector(this.packages));
     jButtonSetLost.setEnabled(this.packages.size() > 0);
     jButtonSetFound.setEnabled(false);
     jListScans.setListData(new Vector());
   } catch (Exception ex) {
     JOptionPane.showMessageDialog(this, "Invalid date entered");
   }
 }
Exemplo n.º 10
0
 /*
  * Gets all the packages in the drivers vehicle to be delivered and picked up
  */
 public ArrayList<Package> getVehicleManifest() {
   try {
     // Creates a list of type packages
     ArrayList<Package> packages = new ArrayList<>();
     ArrayList<Package> temp;
     // Gets all the bins that are in the drivers vehicle
     ArrayList<PackageBin> bins = DataAdapter.getBinByVehicle(vehicleID);
     // checks if there is any bins in the vehicle
     if (bins == null || bins.isEmpty()) {
       return null;
     } else {
       /*
        * Cycles through all packages in the bins
        * Adds them to our list of packages
        */
       for (PackageBin b : bins) {
         assert (b.contents.size() > 0);
         temp = b.contents;
         for (Package p : temp) {
           packages.add(p);
         }
       }
     }
     /*
      * Gets a list of packages requiring pick up
      * And adds them to our list of packages
      */
     temp = DataAdapter.getPackagePickUp();
     if (temp != null && !temp.isEmpty()) {
       for (Package p : temp) {
         packages.add(p);
       }
     }
     // returns the list of packages
     return packages;
   } catch (Exception e) {
     System.err.println(e.getMessage());
     return null;
   }
 }
Exemplo n.º 11
0
  @Override
  public boolean onMenuItemSelected(int featureId, MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    // context menu
    if (null != info) {
      if (!m_connectionDetector.isConnectingToInternet()) {
        Toast.makeText(this, getString(R.string.str_error_no_network), Toast.LENGTH_LONG).show();
        return true;
      }

      NoteItem noteItem = (NoteItem) m_itemAdapter.getItem((int) info.id);
      switch (item.getItemId()) {
        case R.id.item_edit:
          Intent intent = new Intent(NoteListActivity.this, NoteEditActivity.class);
          intent.putExtra("USER_ID", m_strUserId);
          intent.putExtra("USER_NAME", m_strUserName);
          intent.putExtra("LOGIN_TOKEN", m_strLoginToken);
          intent.putExtra("START_EDITING", true);
          intent.putExtra("NOTE_ID", noteItem.m_nId);
          intent.putExtra("NOTE_LOCAL_ID", noteItem.m_nLocalId);
          startActivityForResult(intent, ACTIVITY_EDIT);
          break;
        case R.id.item_del:
          if (m_progressDialog != null) m_progressDialog.dismiss();
          m_progressDialog =
              new ProgressDialog(this) {
                @Override
                public void onStop() {
                  if (m_taskDelNote != null) m_taskDelNote.cancel(true);
                  m_taskDelNote = null;
                }
              };
          m_progressDialog.setTitle("Delete note");
          m_progressDialog.setMessage("Please waiting...");
          m_progressDialog.show();
          m_taskDelNote = new TaskDelNote();
          m_taskDelNote.m_currentNoteItem = noteItem;
          m_taskDelNote.execute((Void) null);
          break;
        default:
          break;
      }

      return true;
    }

    // options menu
    switch (item.getItemId()) {
      case R.id.item_options:
        {
          Intent intent = new Intent(NoteListActivity.this, OptionActivity.class);
          startActivity(intent);
          break;
        }
      case R.id.item_logout:
        {
          Intent intent = new Intent(NoteListActivity.this, LoginActivity.class);
          intent.putExtra("DONT_AUTO_LOGIN", true);
          startActivity(intent);
          finish();
          break;
        }
      case R.id.item_exit:
        finish();
        break;
      default:
        break;
    }
    /*
    AdapterView.AdapterContextMenuInfo info;
    try {
        info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
        Log.e(TAG, "bad menuInfo", e);
        return false;
    }

    switch (item.getItemId()) {
        case DO_SOMETHING:
            /* Do sothing with the id */
    //         Something something = getListAdapter().getItem(info.position);
    //          return true;
    //   }
    return true;
  }