示例#1
0
  private void onProfileChange(String oldProfileName) {

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);

    mProfile.getProfile(settings);
    Editor ed = settings.edit();
    ed.putString(oldProfileName, mProfile.toString());
    ed.commit();

    String profileString = settings.getString(profile, "");

    if (profileString.equals("")) {
      mProfile.init();
      mProfile.setName(getProfileName(profile));
    } else {
      mProfile.decodeJson(profileString);
    }

    hostText.setText(mProfile.getHost());
    userText.setText(mProfile.getUser());
    passwordText.setText(mProfile.getPassword());
    domainText.setText(mProfile.getDomain());
    certificateText.setText(mProfile.getCertificate());
    proxyTypeList.setValue(mProfile.getProxyType());
    ssidList.setValue(mProfile.getSsid());

    isAuthCheck.setChecked(mProfile.isAuth());
    isNTLMCheck.setChecked(mProfile.isNTLM());
    isAutoConnectCheck.setChecked(mProfile.isAutoConnect());
    isAutoSetProxyCheck.setChecked(mProfile.isAutoSetProxy());
    isBypassAppsCheck.setChecked(mProfile.isBypassApps());
    isDNSProxyCheck.setChecked(mProfile.isDNSProxy());
    isPACCheck.setChecked(mProfile.isPAC());

    portText.setText(Integer.toString(mProfile.getPort()));

    Log.d(TAG, mProfile.toString());

    mProfile.setProfile(settings);
  }
 private void loadList(JList list) {
   list.removeAll();
   List<Profile> profiles = getProfiles();
   DefaultListModel model = new DefaultListModel();
   int i = 0;
   int foundLastProfile = -1;
   for (Profile p : profiles) {
     model.addElement(p);
     if (p.toString().equals(Base.preferences.get("lastGeneratorProfileSelected", "---"))) {
       Base.logger.fine("Selecting last used element: " + p);
       foundLastProfile = i;
     }
     i++;
   }
   list.setModel(model);
   list.clearSelection();
   if (foundLastProfile != -1) {
     list.setSelectedIndex(foundLastProfile);
     generate.setEnabled(true);
     generate.requestFocusInWindow();
     generate.setFocusPainted(true);
   }
 }
示例#3
0
 void save(Profile profile)
 {
     Validate.notNull(profile, "profile");
     profile = profile.toJSONObject();
     if (profile != null)
     {
         sharedPreferences.edit().putString("com.facebook.ProfileManager.CachedProfile", profile.toString()).apply();
     }
 }
示例#4
0
  private void computeCorrelations() {
    log.info("Filling repository with most correlated profiles");

    List<String> referenceProfile;

    for (AssayType assayType : AssayType.values()) {

      referenceProfile = getReferenceProfile(assayType);
      List<Profile> profiles = profileRepository.findByAssayType(assayType);

      String[] profileNames = new String[profiles.size()];
      double[][] distanceMatrix = new double[profiles.size()][profiles.size()];

      int i = 0;

      for (Profile profileA : profiles) {

        profileNames[i] = profileA.getId().toString();

        Double maxPearson = Double.MIN_VALUE;
        Profile maxProfile = profileA;

        int j = 0;

        for (Profile profileB : profiles) {
          if (profileA.equals(profileB)) {
            distanceMatrix[i][j] = 0;
            j++;
            continue;
          }

          double[] vectorA = profileA.getVector();
          double[] vectorB = profileB.getVector();

          PearsonsCorrelation pearson = new PearsonsCorrelation();
          Double pearsonCorrelation = pearson.correlation(vectorA, vectorB);

          if (pearsonCorrelation >= maxPearson) {
            maxPearson = pearsonCorrelation;
            maxProfile = profileB;
          }

          double[] profileAasDouble = UtilsTransform.intArrayToDouble(profileA.getColors());
          double[] profileBasDouble = UtilsTransform.intArrayToDouble(profileB.getColors());

          Double pearsonOfColors = pearson.correlation(profileAasDouble, profileBasDouble);
          distanceMatrix[i][j] = pearsonOfColors;
          j++;
        }

        profileA.setCorrelatedVector(maxProfile.getListWrapper());

        SortedSet<StringDouble> positivePeptides =
            UtilsStatistics.influentialPeptides(
                profileA.getVector(), maxProfile.getVector(), referenceProfile, true);

        profileA.setPositivePeptides(UtilsTransform.SortedSetToHTML(positivePeptides, false));

        DecimalFormat df = new DecimalFormat("0.0000");
        String peptideCorrelation = " <br/><br/><b style=\"color: #23527c;\">%s</b>";

        profileA.setPositiveCorrelation(
            maxProfile.toString() + String.format(peptideCorrelation, df.format(maxPearson)));

        profileRepository.save(profileA);
        i++;
      }
    }
  }
 @Override
 public String toString() {
   return "P: " + profile.toString() + " L: " + level.toString();
 }