Exemplo n.º 1
0
 public List retrieveAttachmentsByCustomerId(long customerId) throws RemoteException {
   List attachments = new ArrayList();
   AttachmentDAO attachmentDAO = new AttachmentDAO(conn);
   attachments = attachmentDAO.retrieveAttachmentsByCustomerId(customerId);
   USFEnv.getLog().writeDebug("attachments size is......" + attachments.size(), this, null);
   return attachments;
 }
Exemplo n.º 2
0
  private void updateLocalVersions() {
    if (NavigineApp.Navigation == null) return;

    for (int i = 0; i < mInfoList.size(); ++i) {
      LocationInfo info = mInfoList.get(i);
      String versionStr = LocationLoader.getLocalVersion(NavigineApp.AppContext, info.title);
      if (versionStr != null) {
        // Log.d(TAG, info.title + ": " + versionStr);
        info.localModified = versionStr.endsWith("+");
        if (info.localModified) versionStr = versionStr.substring(0, versionStr.length() - 1);
        try {
          info.localVersion = Integer.parseInt(versionStr);
        } catch (Throwable e) {
        }
      } else {
        info.localVersion = -1;

        String mapFile = NavigineApp.Settings.getString("map_file", "");
        if (mapFile.equals(info.archiveFile)) {
          NavigineApp.Navigation.loadArchive(null);
          SharedPreferences.Editor editor = NavigineApp.Settings.edit();
          editor.putString("map_file", "");
          editor.commit();
        }
      }
    }
    mAdapter.updateList();
  }
Exemplo n.º 3
0
 public void scaleBy(double factor) throws Exception {
   for (int i = 0; i < points.size(); i++) {
     Point point = points.get(i);
     point.x *= factor;
     point.y *= factor;
   }
 }
Exemplo n.º 4
0
  public void drawOn(Page page) throws Exception {
    if (fill_shape) {
      page.setBrushColor(color[0], color[1], color[2]);
    } else {
      page.setPenColor(color[0], color[1], color[2]);
    }
    page.setPenWidth(width);
    page.setLinePattern(pattern);

    for (int i = 0; i < points.size(); i++) {
      Point point = points.get(i);
      point.x += box_x;
      point.y += box_y;
    }

    if (fill_shape) {
      page.drawPath(points, 'f');
    } else {
      if (close_path) {
        page.drawPath(points, 's');
      } else {
        page.drawPath(points, 'S');
      }
    }

    for (int i = 0; i < points.size(); i++) {
      Point point = points.get(i);
      point.x -= box_x;
      point.y -= box_y;
    }
  }
Exemplo n.º 5
0
  private static void connectCallbackHandler(String moduleName, boolean isConnect) {
    Iterator iter = (isConnect ? connectHandlers.iterator() : disconnectHandlers.iterator());

    while (iter.hasNext()) {
      CONNECT_HANDLE_TYPE handler = (CONNECT_HANDLE_TYPE) iter.next();
      handler.handle(moduleName);
    }
  }
Exemplo n.º 6
0
  /**
   * Finds which word in uniqueWordsVec that each word from wordVecs is closest to, also saves the
   * index (friend) in uniqueWords that corresponds to this word
   *
   * @param wordVecs Word vectors of sentence
   * @param uniqueWordVecs Word vectors of all unique words
   * @param cs Cosine similarity object for calculations
   * @return Similarity vectors, distance to closest word, alonside that words index
   */
  public List<double[]> similarityVectors(
      List<double[]> wordVecs, List<double[]> uniqueWordVecs, CosSim cs) {
    double[] shortestDistances = new double[uniqueWordVecs.size()];
    double[] bestFriends = new double[uniqueWordVecs.size()]; // Index of all closest words
    int friend = 0;
    for (int i = 0; i < uniqueWordVecs.size(); i++) // For all unique words
    {
      double currentShortest = Double.NEGATIVE_INFINITY;
      for (int j = 0; j < wordVecs.size(); j++) // Finds closest word in wordVecs
      {
        double tmpDist = cs.CosSim(wordVecs.get(j), uniqueWordVecs.get(i));
        if (tmpDist > currentShortest) {
          currentShortest = tmpDist;
          friend = j;
        }
      }
      shortestDistances[i] = currentShortest;
      bestFriends[i] = friend;
    }

    List<double[]> results = new ArrayList<>();
    results.add(shortestDistances);
    results.add(bestFriends);
    return results;
  }
Exemplo n.º 7
0
 /**
  * Finds the word vectors for all words in a sentence.
  *
  * @param sent sentence
  * @return Word vectors for sentence
  */
 public List<double[]> CreateWordVector(String sent) {
   List<double[]> wordVecs = new ArrayList<double[]>();
   String[] splitSent = sent.split(" ");
   for (int i = 0; i < splitSent.length; i++) // For each word
   {
     double[] wordVector = allWordsVec.getVectorOfWord(splitSent[i]);
     if (wordVector[0] != -100) {
       wordVecs.add(wordVector);
     }
   }
   return wordVecs;
 }
Exemplo n.º 8
0
  private static void changeCallbackHandler(String msgName, int numHandlers) {
    List handlerList = (List) handlerChangeHashTable.get(msgName);
    if (handlerList == null) {
      System.out.println("Ooops -- no change handlers for message " + msgName);
      return;
    }
    Iterator iter = handlerList.iterator();

    while (iter.hasNext()) {
      ((CHANGE_HANDLE_TYPE) iter.next()).handle(msgName, numHandlers);
    }
  }
Exemplo n.º 9
0
 {
     //create out of bounds exception emailList.get(-1)
     if (emailList.get(i) == emailList.get(i-1))
     {
         dupEmailCount++;
     }
     else
     {
         //insert domain email, dupEmailCount into hashtable
         domainCount.put(emailList.get(i), dupEmailCount);
         dupEmailCount = 0;
     }
 }
Exemplo n.º 10
0
 public static int unsubscribeHandlerChange(String msgName, Class handlerChangeHandlerClass) {
   List handlerList = (List) handlerChangeHashTable.get(msgName);
   if (handlerList == null) {
     return IPC_Error;
   } else if (!removeFromHandlerList(handlerList, handlerChangeHandlerClass)) {
     System.out.println(
         "No change handler found for message "
             + msgName
             + " of class "
             + handlerChangeHandlerClass.getName());
     return IPC_Error;
   } else if (handlerList.size() == 0) {
     return IPC_unsubscribeHandlerChange(msgName);
   } else {
     return IPC_OK;
   }
 }
Exemplo n.º 11
0
  public static int subscribeHandlerChange(
      String msgName, CHANGE_HANDLE_TYPE handlerChangeHandler) {
    /* Do it this way because multiple handlers can be subscribed
    for same message */
    List list = (List) handlerChangeHashTable.get(msgName);
    if (list == null) {
      list = new LinkedList();
      handlerChangeHashTable.put(msgName, list);
    }
    list.add(0, handlerChangeHandler);

    if (list.size() == 1) {
      return IPC_subscribeHandlerChange(msgName);
    } else {
      return IPC_OK;
    }
  }
Exemplo n.º 12
0
  /**
   * Calculates word similarity between the sentences, with weighted words.
   *
   * @param vec1 Word vector of sentence 1
   * @param vec2 Word vector of sentence 2
   * @param weights1 weights of sentence 1
   * @param weights2 weights of sentence 2
   * @return Word similarity value
   */
  public double wordSimilarity(
      double[] vec1, double[] vec2, List<double[]> weights1, List<double[]> weights2) {
    double simSum = 0;
    double vec1Sum = 0;
    double vec2Sum = 0;
    double w1;
    double w2;
    for (int i = 0; i < vec1.length; i++) {
      if (vec1[i] != Double.NEGATIVE_INFINITY && vec2[i] != Double.NEGATIVE_INFINITY) {
        w1 = weights1.get(0)[i] * weights1.get(1)[i];
        w2 = weights2.get(0)[i] * weights2.get(1)[i];
        simSum += vec1[i] * vec2[i] * w1 * w2;
        vec1Sum += vec1[i] * vec1[i] * w1 * w1;
        vec2Sum += vec2[i] * vec2[i] * w2 * w2;
      }
    }

    return simSum / (Math.sqrt(vec1Sum) * Math.sqrt(vec2Sum));
  }
Exemplo n.º 13
0
  private static boolean removeFromHandlerList(List list, Class handlerClass) {
    boolean found = false;
    Iterator iter = list.iterator();

    /* Do it this way because multiple handlers can be subscribed  */
    while (iter.hasNext() && !found) {
      found = (iter.next().getClass() == handlerClass);
      if (found) iter.remove();
    }
    return found;
  }
  public void test(List<Datum> testData) {
    File file = new File("../baseline.out");

    // if file doesnt exists, then create it
    try {
      if (!file.exists()) {
        file.createNewFile();
      }

      FileWriter fw = new FileWriter(file.getAbsoluteFile());
      BufferedWriter bw = new BufferedWriter(fw);

      for (int i = 0; i < testData.size(); i++) {
        String testWord = testData.get(i).word;
        String trueLabel = testData.get(i).label;
        String predictedLabel = "O";
        for (int j = 0; j < trainData.size(); j++) {
          if (testWord.equals(trainData.get(j).word)) {
            predictedLabel = trainData.get(j).label;
            break;
          }
        }
        // write result to text file
        bw.write(testWord + "\t" + trueLabel + "\t" + predictedLabel + "\n");
      }
      bw.close();
    } catch (Exception e) {
    }
  }
Exemplo n.º 15
0
  /**
   * Calculates word order similarity between the sentences, with weighted words
   *
   * @param s1 sentence 1
   * @param s2 sentence 2
   * @param weights1 of sentence 1
   * @param weights2 of sentence 2
   * @return Word order similarity value
   */
  public double orderSimilarity(
      List<double[]> s1,
      List<double[]> s2,
      List<double[]> weights1,
      List<double[]> weights2,
      String sent2,
      String unique) {
    double[] s1Dist = s1.get(0);
    double[] s1Friend = s1.get(1);
    double[] s2Dist = s2.get(0);
    double[] s2Friend = s2.get(1);
    double[] r1 = new double[s1Dist.length];
    double[] r2 = new double[s2Dist.length];
    String[] sent = sent2.split(" ");
    String[] un = unique.split(" ");
    String word;

    // Specifies word order vectors for either sentence.
    // Threshold specifies that words can be seen as the same if similar enough
    // If same word not found in unique sentence, the order value is 0
    for (int i = 0; i < r1.length; i++) {
      if (s1Dist[i] == 1.0) {
        r1[i] = i + 1;
      } else if (s1Dist[i] >= threshold) {
        r1[i] = s1Friend[i] + 1;

      } else {
        r1[i] = 0;
      }
    }
    for (int i = 0; i < r2.length; i++) {
      if (s2Dist[i] == 1.0) {
        word = un[i];
        r2[i] = Arrays.asList(sent).indexOf(word) + 1;
      } else if (s2Dist[i] >= threshold) {
        r2[i] = s2Friend[i] + 1;

      } else {
        r2[i] = 0.0;
      }
    }
    double numerator = 0.0;
    double denominator = 0.0;
    // Calculate order similarity while avoiding division by 0
    for (int i = 0; i < r1.length; i++) {
      numerator = numerator + Math.pow((r1[i] - r2[i]) * weights1.get(0)[i], 2);
      denominator = denominator + Math.pow((r1[i] + r2[i]) * weights1.get(0)[i], 2);
    }
    numerator = Math.sqrt(numerator);
    denominator = Math.sqrt(denominator);
    if (denominator == 0.0) {
      numerator = 1;
      denominator = 1;
    }

    return numerator / denominator;
  }
Exemplo n.º 16
0
  /**
   * CalculateSimilarity calculates a similarity value between two sentences dependant on word
   * similarity and word order similarity.
   *
   * @param sentWithJunk1 When the sentences (sentenceWithJunk1/2) are added they may contain non
   *     existent words that will then be removed
   * @param sentWithJunk2 When the sentences (sentenceWithJunk1/2) are added they may contain non
   *     existent words that will then be removed
   * @param wordFreqs contains the word frequencies of all words in all the available sentences.
   * @param allWordsVec contains a vector of all the words' vectors (2D), and wordVecs1/2 contains
   *     only the word vectors for either sentence
   * @param wordVecs1
   * @param wordVecs2
   * @return
   */
  public double[] CalculateSimilarity(
      String sentWithJunk1,
      String sentWithJunk2,
      List<WordFreq> wordFreqs,
      WordVec allWordsVec,
      List<double[]> wordVecs1,
      List<double[]> wordVecs2) {
    this.allWordsVec = allWordsVec;
    CosSim cs = new CosSim();
    double sim[] = {0, 0};

    String uniqueWords = uniqueWordSentence(sentWithJunk1, sentWithJunk2);
    List<double[]> uniqueWordVecs = CreateWordVector(uniqueWords);
    uniqueWords = getFoundWords(uniqueWords);
    String sent1 = getFoundWords(sentWithJunk1);
    String sent2 = getFoundWords(sentWithJunk2);

    if (sent1.length() == 0
        | sent2.length() == 0) { // One or both sentences are filled only with nonsensical words
      sim[1] = 1;
      return sim;
    }

    List<double[]> wordSim1 = similarityVectors(wordVecs1, uniqueWordVecs, cs);
    List<double[]> wordSim2 = similarityVectors(wordVecs2, uniqueWordVecs, cs);
    List<double[]> weights1 = WordWeights(wordFreqs, sent1, uniqueWords, wordSim1, sentWithJunk1);
    List<double[]> weights2 = WordWeights(wordFreqs, sent2, uniqueWords, wordSim2, sentWithJunk2);

    double wordSimilarityScore =
        wordSimilarity(wordSim1.get(0), wordSim2.get(0), weights1, weights2);
    double orderSimilarityScore =
        orderSimilarity(wordSim1, wordSim2, weights1, weights2, sent2, uniqueWords);

    sim[0] = wordSimilarityScore;
    sim[1] = orderSimilarityScore;
    return sim;
  }
Exemplo n.º 17
0
  private void updateLoader() {
    if (NavigineApp.Navigation == null) return;

    // Log.d(TAG, String.format(Locale.ENGLISH, "Update loader: %d", mLoader));

    long timeNow = DateTimeUtils.currentTimeMillis();
    if (mLoader < 0) return;

    int status = LocationLoader.checkLocationLoader(mLoader);
    if (status < 100) {
      if ((Math.abs(timeNow - mLoaderTime) > LOADER_TIMEOUT / 3 && status == 0)
          || (Math.abs(timeNow - mLoaderTime) > LOADER_TIMEOUT)) {
        mListView.setVisibility(View.GONE);
        mStatusLabel.setVisibility(View.VISIBLE);
        mStatusLabel.setText("Loading timeout!\nPlease, check your internet connection!");
        Log.d(TAG, String.format(Locale.ENGLISH, "Load stopped on timeout!"));
        LocationLoader.stopLocationLoader(mLoader);
        mLoader = -1;
      } else {
        mListView.setVisibility(View.GONE);
        mStatusLabel.setVisibility(View.VISIBLE);
        mStatusLabel.setText(String.format(Locale.ENGLISH, "Loading content (%d%%)", status));
      }
    } else {
      Log.d(TAG, String.format(Locale.ENGLISH, "Load finished with result: %d", status));
      LocationLoader.stopLocationLoader(mLoader);
      mLoader = -1;

      if (status == 100) {
        parseMapsXml();
        if (mInfoList.isEmpty()) {
          mListView.setVisibility(View.GONE);
          mStatusLabel.setVisibility(View.VISIBLE);
          mStatusLabel.setText("No locations available");
        } else {
          mListView.setVisibility(View.VISIBLE);
          mStatusLabel.setVisibility(View.GONE);
        }
      } else {
        mListView.setVisibility(View.GONE);
        mStatusLabel.setVisibility(View.VISIBLE);
        mStatusLabel.setText("Error loading!\nPlease, check your ID!");
      }
    }
  }
Exemplo n.º 18
0
  private void startUpload(int index) {
    if (NavigineApp.Navigation == null) return;

    String userHash = NavigineApp.Settings.getString("user_hash", "");
    if (userHash.length() == 0) return;

    LocationInfo info = mInfoList.get(index);
    String location = new String(info.title);
    Log.d(TAG, String.format(Locale.ENGLISH, "Start upload: %s", location));

    synchronized (mLoaderMap) {
      if (!mLoaderMap.containsKey(location)) {
        LoaderState loader = new LoaderState();
        loader.location = location;
        loader.type = UPLOAD;
        loader.id = LocationLoader.startLocationUploader(location, info.archiveFile, true);
        mLoaderMap.put(location, loader);
      }
    }
    mAdapter.updateList();
  }
Exemplo n.º 19
0
  private void selectItem(int index) {
    _info = mInfoList.get(index);
    if (!(new File(_info.archiveFile)).exists()) {
      String text =
          String.format(
              Locale.ENGLISH,
              "Location '%s' cannot be selected!\n" + "Please, download location first!",
              _info.title);
      Toast.makeText(mContext, text, Toast.LENGTH_LONG).show();
      return;
    }

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);
    alertBuilder.setTitle(String.format(Locale.ENGLISH, "Location '%s'", _info.title));

    alertBuilder.setNegativeButton(
        "Delete location",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            deleteLocation(_info);
          }
        });
    alertBuilder.setPositiveButton(
        "Select location",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            selectLocation(_info);
          }
        });

    AlertDialog dialog = alertBuilder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }
Exemplo n.º 20
0
  /**
   * Finds the weights of a word, both concerning the weight of the word itself, but also its
   * closest friend in the unique words. Note that if the word in the sentence exists in unique
   * words these will be the same The weights are inversely proportional to the frequency of the
   * word Frequencies of words are found in wordFreqs
   *
   * @param wordFreqs of word weights
   * @param sent sentence
   * @param unique all unique words in both sentences to be compared
   * @param sim Values of distances, and closest words to unique words for the sentence
   * @param sentJunk Sentence with nonsense words included
   * @return Word weights for all words in sentence/unique sentence
   */
  public List<double[]> WordWeights(
      List<WordFreq> wordFreqs, String sent, String unique, List<double[]> sim, String sentJunk) {
    String[] sentWordsJunk = sentJunk.split(" ");
    String[] sentWords = sent.split(" ");
    String[] uniqueWords = unique.split(" ");
    String friendWord = null;

    double[] weightsSent =
        new double[uniqueWords.length]; // Weights of closest words in sent to words in uniqueWords
    double[] weightsUnique = new double[uniqueWords.length]; // Weights of words in uniqueWords

    for (int j = 0; j < wordFreqs.size(); j++) {
      /* For each existing word in the listof words,
      check if it corresponds to the current word, then checks frequency value */
      for (int i = 0; i < uniqueWords.length; i++) {
        if ((wordFreqs.get(j).getWord()).equals(uniqueWords[i])) {
          weightsUnique[i] = 1 / wordFreqs.get(j).getFreq();
        }
      }
    }

    for (int i = 0; i < uniqueWords.length; i++) {
      int index = Arrays.asList(sentWords).indexOf(uniqueWords[i]);
      if (index >= 0) {
        weightsSent[i] = weightsUnique[i];
      } else { // if(sim.get(0)[i]>=threshold){
        friendWord = sentWordsJunk[(int) sim.get(1)[i]];
        index = Arrays.asList(uniqueWords).indexOf(friendWord);
        weightsSent[i] = weightsUnique[index]; // gets friend in sent
      }
    }

    List<double[]> results = new ArrayList<double[]>();
    results.add(weightsUnique);
    results.add(weightsSent);
    return results;
  }
Exemplo n.º 21
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");

      String path = request.getContextPath();
      String basePath =
          request.getScheme()
              + "://"
              + ("xsaqjy".equals(request.getServerName())
                  ? "xsaqjy.ljgps.net"
                  : request.getServerName())
              + (request.getServerPort() == 80 ? "" : ":" + request.getServerPort())
              + path
              + "/";
      Long userno = (Long) session.getAttribute("userno"); // 获得当前登录用户的id用户号
      if (userno == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
        return;
      }
      Long admin = (Long) session.getAttribute("adminflag"); // 获得标记当前登录用户是否为数据管理员
      if (admin == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
      }
      Long dwtype = (Long) session.getAttribute("dwtype"); // 获得当前登录用户所在单位类型 0代表交警  1代表货运公司
      if (dwtype == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
      }
      String username = (String) request.getSession().getAttribute("username");
      if (username == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
      }
      List<String> list = (List<String>) session.getAttribute("list"); // 获得权限的集合
      if (list == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
      }
      Long userid = (long) Integer.parseInt((String) request.getSession().getAttribute("driverid"));
      if (userid == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
        return;
      }
      Object u = request.getSession().getAttribute("onlineuser"); // 获得当前登录用户的对象
      if (u == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
      } // 假如获得不到用户,就重新定向到登录页面
      session.setAttribute("basePath", basePath); // 把basepath放到session中以便所有的页面使用

      out.write("\r\n");
      out.write("\r\n");
      out.write("<!-- 获取当前日期,时间,星期 -->\r\n");

      String week = "";
      if (new Date().getDay() == 0) week = "星期日";
      if (new Date().getDay() == 1) week = "星期一";
      if (new Date().getDay() == 2) week = "星期二";
      if (new Date().getDay() == 3) week = "星期三";
      if (new Date().getDay() == 4) week = "星期四";
      if (new Date().getDay() == 5) week = "星期五";
      if (new Date().getDay() == 6) week = "星期六";
      java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      java.util.Date currentTime = new java.util.Date(); // 得到当前系统时间
      String date1 = formatter.format(currentTime); // 将日期时间格式化
      String date2 = currentTime.toString(); // 将Date型日期时间转换成字符串形式

      out.write("\r\n");
      out.write(
          "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("<base href=\"");
      out.print(basePath);
      out.write("\" />\r\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\r\n");
      out.write("<title>机动车网上交通安全宣传教育监管平台</title>\r\n");
      out.write(
          "<link href=\"page/admin/css/style.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n");
      out.write(
          "<script type=\"text/javascript\" src=\"page/admin/javascript/jquery.min.js\"></script>\r\n");
      out.write("<script type=\"text/javascript\">\r\n");
      out.write("\t$(function() {\r\n");
      out.write("\t\t//setMenuHeight\r\n");
      out.write("\t\t$('.menu').height($(window).height() - 56 - 27 - 26);\r\n");
      out.write("\t\t$('.sidebar').height($(window).height() - 56 - 27 - 26);\r\n");
      out.write("\t\t$('.page').height($(window).height() - 56 - 27 - 26);\r\n");
      out.write("\t\t$('.page iframe').width($(window).width() - 15 - 168);\r\n");
      out.write("\t\t$('.subMenu a[href=\"#\"]').next('ul').toggle();\r\n");
      out.write("\t\t//menu on and off\r\n");
      out.write("\t\t$('.btn').click(function() {\r\n");
      out.write("\t\t\t$('.menu').toggle();\r\n");
      out.write("\r\n");
      out.write("\t\t\tif ($(\".menu\").is(\":hidden\")) {\r\n");
      out.write("\t\t\t\t$('iframe').width($(window).width() - 15 + 5);\r\n");
      out.write("\t\t\t} else {\r\n");
      out.write("\t\t\t\t$('iframe').width($(window).width() - 15 - 168);\r\n");
      out.write("\t\t\t}\r\n");
      out.write("\t\t});\r\n");
      out.write(" \r\n");
      out.write("\t\t//\r\n");
      out.write("\t\t$('.subMenu a[href=\"#\"]').click(function() {\r\n");
      out.write("\t\t\t$(this).next('ul').toggle();\r\n");
      out.write("\t\t\treturn false;\r\n");
      out.write("\t\t});\r\n");
      out.write("\t});\r\n");
      out.write("\t\r\n");
      out.write("\tfunction clickmenu(topage){\r\n");
      out.write("\t\t $('iframe')[0].src = topage;\r\n");
      out.write("\t}\r\n");
      out.write("</script>\r\n");
      out.write("\r\n");
      out.write("<!-- 后台页面权限的分配 -->\r\n");
      out.write("<script type=\"text/javascript\">\r\n");
      out.write("//页面初始化进行\r\n");
      out.write("window.onload = function() \r\n");
      out.write("{\r\n");
      out.write("\tif(\"");
      out.print(admin);
      out.write("\" == \"1\")//数据管理员的id号设置为0,当id号为0时,拥有一切权限\r\n");
      out.write("\t\t{\r\n");
      out.write("\t\t\t$(\"li\").show();\r\n");
      out.write("\t\t\t$(\"#otherreprimand\").remove();\r\n");
      out.write("\t\t\t$(\"#driverreprimand\").remove();\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t\t}\r\n");
      out.write("\telse\r\n");
      out.write("\t\t{\r\n");
      out.write("\t\t$(\"li\").hide();\r\n");
      out.write("\t\t$(\"#subMenu\").show();\r\n");
      out.write("\t\t");

      if (dwtype == 0) // 当登录的账号为交警部门时,默认的显示前台页面的8个模块对应的后台数据管理
      {

        out.write("\r\n");
        out.write("\t\t    $(\"#firstpage\").show();\r\n");
        out.write("\t\t\t$(\"#rulenmanage\").show();\r\n");
        out.write("\t\t\t$(\"#edunmanage\").show();\r\n");
        out.write("\t\t\t$(\"#baseinfo\").show();\r\n");
        out.write("\t\t\t$(\"#policeorgmanage\").show();\r\n");
        out.write("\t\t\t$(\"#companymanage\").show();\r\n");
        out.write("\t\t\t$(\"#carmanage\").show();\r\n");
        out.write("\t\t\t$(\"#drivermanage\").show();\r\n");
        out.write("\t\t\t$(\"#rulenmanage\").show();\r\n");
        out.write("\t\t\t$(\"#branchmanage\").show();\r\n");
        out.write("\t\t\t$(\"#safenoticemanage\").show();\r\n");
        out.write("\t\t\t$(\"#meetnoticemanage\").show();\r\n");
        out.write("\t\t\t$(\"#interchangemanage\").show();\r\n");
        out.write("\t\t\t$(\"#micromessagemanage\").show();\r\n");
        out.write("\t\t\t$(\"#editpassword\").show();\r\n");
        out.write("\t\t\t$(\"#reprimand\").show();\r\n");
        out.write("\t\t\t$(\"#carlist\").show();\r\n");
        out.write("\t");
      }
      out.write("\r\n");
      out.write("\t\r\n");
      out.write("\t");

      if (dwtype == 1) // 当登录的账号为货运部门时,默认显示货运公司对应的后台数据管理
      {

        out.write("\r\n");
        out.write("\t    $(\"#firstpage\").show();\r\n");
        out.write("\t\t$(\"#baseinfo\").show();\r\n");
        out.write("\t\t$(\"#interchangemanage\").show();\r\n");
        out.write("\t\t$(\"#editpassword\").show();\r\n");
        out.write("\t\t$(\"#safelearn\").show();\r\n");
        out.write("\t\t$(\"#otherreprimand\").show();\r\n");
        out.write("\t\t$(\"#drivermanage\").show();\r\n");
        out.write("\t\t$(\"#micromessagemanage\").show();\r\n");
        out.write("\t\t$(\"#carmanage\").show();\r\n");
        out.write("\t\t$(\"#companymanage\").show();\r\n");
      }
      out.write("\r\n");
      out.write("\r\n");

      if (dwtype == 2) // 当登录的账号为货运部门的驾驶员时,默认显示货运公司驾驶员对应的后台数据管理
      {

        out.write("\r\n");
        out.write("    $(\"#firstpage\").show();\r\n");
        out.write("\t$(\"#baseinfo\").show();\r\n");
        out.write("\t$(\"#drivermanage\").show();\r\n");
        out.write("\t$(\"#editpassword\").show();\r\n");
        out.write("\t$(\"#interchangemanage\").show();\r\n");
        out.write("\t$(\"#safelearn\").show();\r\n");
        out.write("\t$(\"#micromessagemanage\").show();\r\n");
        out.write("\t$(\"#driverreprimand\").show();\r\n");
      }
      out.write("\r\n");
      out.write("\t\t");

      if (u != null) {
        String string = "";
        for (int i = 0; i < list.size(); i++) {
          string = list.get(i);

          out.write("\r\n");
          out.write("\t\t$(\"#");
          out.print(string);
          out.write("\").show();\r\n");
          out.write("\t\t");
        }
      }
      out.write("\r\n");
      out.write("      }\r\n");
      out.write("}\r\n");
      out.write("</script>\r\n");
      out.write("</head>\r\n");
      out.write("<body>\r\n");
      out.write(
          "\t<table border=\"0\" width=\"100%\" height=\"100%\"style=\"margin: 0; padding: 0; background-color: #198bc9\">\r\n");
      out.write("\t\t<tr>\r\n");
      out.write("\t\t\t<td colspan=\"3\">\r\n");
      out.write("\t\t\t\t<div id=\"header\">\r\n");
      out.write(
          "\t\t\t\t<table border=\"0\" width=\"100%\" height=\"100%\" style=\"margin: 0; padding: 0;\">\r\n");
      out.write("\t\t\t\t<tr>\r\n");
      out.write("\t\t\t\t<td width=\"50%\" style=\"text-align:left\">\r\n");
      out.write("\t\t\t\t<div class=\"logo fleft\">&nbsp;</div>\r\n");
      out.write("\t\t\t\t</td>\r\n");
      out.write("\t\t\t\t<td width=\"30%\"></td>\r\n");
      out.write("\t\t\t\t<td width=\"20%\" style=\"text-align:right\">\r\n");
      out.write("\t\t\t\t<div  class=\"logoright fleft\" align=\"right\">&nbsp;</div>\r\n");
      out.write("\t\t\t\t</td>\r\n");
      out.write("\t\t\t\t</tr>\r\n");
      out.write("\t\t\t\t</table>\r\n");
      out.write("\t\t\t\t\t</div>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t\t\r\n");
      out.write("\t\t<tr>\r\n");
      out.write("\t\t\t<td colspan=\"3\" align=\"left\">\r\n");
      out.write("\t\t\t<div class=\"logofont\" style=\"margin-left:25px\">\r\n");
      out.write(
          "\t\t\t<table border=\"0\" width=\"100%\" height=\"100%\" style=\"margin: 0; padding: 0;\">\r\n");
      out.write("\t\t\t<tr><td align=\"left\">\r\n");
      out.write("\t\t\t<font>用户:");
      out.print(username);
      out.write("&nbsp;&nbsp;时间:");
      out.print(date1);
      out.write("&nbsp;&nbsp;");
      out.print(week);
      out.write("&nbsp;&nbsp;</font>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t\t<td align=\"right\">\r\n");
      out.write(
          "\t\t\t<a href=\"loginout.action\"><font color=\"#FFFFF0\">退出&nbsp;&nbsp;</font></a>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t\t</tr>\r\n");
      out.write("\t\t\t</table>\r\n");
      out.write("\t\t\t</div>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t\t\r\n");
      out.write("\t\t<tr>\r\n");
      out.write("\t\t\t<td width=\"168px\">\r\n");
      out.write("\t\t\t\t<div class=\"menu fleft\">\r\n");
      out.write("\t\t\t\t\t<ul>\r\n");
      out.write("\t\t\t\t\t\t<li class=\"subMenuTitle\" id=\"subMenu\">机动车网安教后台管理</li>\r\n");
      out.write("\t\t\t\t\t\t<li class=\"subMenu\" id=\"firstpage\">首页设置</li>\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"stationmanage\"><a href=\"#\">参数配置</a>\r\n");
      out.write("\t\t\t\t\t\t\t<ul>\r\n");
      out.write(
          "\t\t\t\t\t\t\t\t<li><a href=\"javascript:clickmenu('page/admin/page/config_viewConfigList.action')\">网站信息</a>\r\n");
      out.write("\t\t\t\t\t\t\t\t</li>\r\n");
      out.write("\t\t\t\t\t\t\t</ul></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"accountmanage\"><a href=\"#\">系统管理</a>\r\n");
      out.write("\t\t\t\t\t\t\t<ul>\r\n");
      out.write(
          "\t\t\t\t\t\t\t\t<li id=\"rolemanage\"><a href=\"javascript:clickmenu('page/admin/page/role_viewRoleList.action')\">角色管理</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t\t<li id=\"accountmanage\"><a href=\"javascript:clickmenu('page/admin/page/account_viewAccountList.action')\">账号管理</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t\t<li id=\"permisionmanage\"><a href=\"javascript:clickmenu('page/admin/page/permission_viewPermissionList.action')\">权限管理</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t\t<li  id=\"areamanage\"><a href=\"javascript:clickmenu('page/admin/page/areaback_viewAreaList.action')\">地域管理</a></li>\r\n");
      out.write("\t\t\t\t\t\t\t</ul>\r\n");
      out.write("\t\t\t\t\t\t</li>\r\n");
      out.write("\t\t\t\t\t\t\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"rulenmanage\"><a href=\"javascript:clickmenu('page/admin/page/ruleback_viewRuleList.action')\">交通法规</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"edunmanage\"><a href=\"javascript:clickmenu('page/admin/page/eduback_viewEduList.action')\">宣教中心</a></li>\r\n");
      out.write("\r\n");
      out.write("\t\t\t\t\t <li class=\"subMenu\" id=\"baseinfo\"><a href=\"#\">基本信息</a>\r\n");
      out.write("\t\t\t\t\t\t <ul>\r\n");
      out.write(
          "\t\t\t\t\t\t    <!-- <li id=\"policeorgmanage\"><a href=\"javascript:clickmenu('page/admin/page/orgback_viewPoliceOrgList.action')\">交警部门</a></li> -->\r\n");
      out.write(
          "\t\t\t\t\t\t    <li  id=\"orgmanage\"><a href=\"javascript:clickmenu('page/admin/page/policeorgback_viewPoliceOrgList.action')\">交警部门</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t    <li class=\"subMenu\" id=\"carlist\"><a href=\"javascript:clickmenu('page/admin/page/policeback_viewPoliceList.action')\">交警信息</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t<li id=\"companymanage\"><a href=\"javascript:clickmenu('page/admin/page/companyback_viewCompanyList.action')\">企业安全组</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t<li id=\"carmanage\"><a href=\"javascript:clickmenu('page/admin/page/carback_viewCarList.action')\">车辆管理</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t<li id=\"drivermanage\"><a href=\"javascript:clickmenu('page/admin/page/driverback_viewDriverList.action')\">驾驶员管理</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t  \t<li class=\"subMenu\" id=\"editpassword\"><a href=\"javascript:clickmenu('page/admin/page/account_viewPassword.action?id=");
      out.print(userid);
      out.write("')\">修改密码</a></li>\r\n");
      out.write("\t\t\t\t\t\t  </ul>\r\n");
      out.write("\t\t\t\t\t </li>\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"rulenmanage\"><a href=\"javascript:clickmenu('page/admin/page/illegalback_viewIllegalList.action')\">违法查询</a></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"branchmanage\"><a href=\"javascript:clickmenu('page/admin/page/branchback_viewBranchList.action')\">快速处理点</a></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"safenoticemanage\"><a href=\"javascript:clickmenu('page/admin/page/safenoticeback_viewSafeNoticeList.action')\">安全提醒</a></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"meetnoticemanage\"><a href=\"javascript:clickmenu('page/admin/page/meetnoticeback_viewMeetNoticeList.action')\">会议通知</a></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"safelearn\"><a href=\"javascript:clickmenu('page/admin/page/safelearnback_viewEduList.action')\">安全教育学习</a></li>\r\n");
      out.write("\t\t\t\t\t\t\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"reprimand\"><a href=\"javascript:clickmenu('page/admin/page/reprimandback_viewReprimandList.action')\">通报批评</a></li>\r\n");
      out.write("\t\t\t\t\t\r\n");
      out.write(
          "\t\t\t\t\t    <li class=\"subMenu\" id=\"otherreprimand\"><a href=\"javascript:clickmenu('page/admin/page/otherreprimandback_viewReprimandList.action')\">通报批评</a></li>\r\n");
      out.write("\t\t\t\t\t    \r\n");
      out.write(
          "\t\t\t\t\t    <li class=\"subMenu\" id=\"driverreprimand\"><a href=\"javascript:clickmenu('page/admin/page/otherreprimandback_showDriverReprimand.action')\">通报批评</a></li>\r\n");
      out.write("\t\t\t\t\t   \r\n");
      out.write(
          "\t\t\t\t\t    <li class=\"subMenu\" id=\"interchangemanage\"><a href=\"javascript:clickmenu('page/admin/page/interchangeback_viewInterchangeList.action')\">问题答疑</a></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"micromessagemanage\"><a href=\"javascript:clickmenu('page/admin/page/micromessage/micromessagelist.jsp')\">微博互动</a></li>\r\n");
      out.write("\t\t\t\t\t\r\n");
      out.write("\t\t\t\t\t</ul>\r\n");
      out.write("\t\t\t\t\t\r\n");
      out.write("\t\t\t\t</div>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t\t<td width=\"5px\">\r\n");
      out.write("\t\t\t\t<div class=\"sidebar fleft\">\r\n");
      out.write("\t\t\t\t\t<div class=\"btn\"></div>\r\n");
      out.write("\t\t\t\t</div>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t\t<td class=\"page\"><iframe width=\"100%\" scrolling=\"auto\"\r\n");
      out.write("\t\t\t\t\theight=\"100%\" FRAMEBORDER=0 style=\"border: medium none;\"\r\n");
      out.write(
          "\t\t\t\t\tsrc=\"/TrafficPolice/page/admin/page/Startpage.jsp\" id=\"rightMain\"\r\n");
      out.write("\t\t\t\t\tname=\"right\"></iframe>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t\t<tr>\r\n");
      out.write("\t\t\t<td colspan=\"3\"><div id=\"footer\"></div></td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t</table>\r\n");
      out.write("</body>\r\n");
      out.write("\r\n");
      out.write("</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            out.clearBuffer();
          } catch (java.io.IOException e) {
          }
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Exemplo n.º 22
0
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String line = null;
    while ((line = reader.readLine()) != null) {
      StringTokenizer token = new StringTokenizer(line);
      int n = Integer.parseInt(token.nextToken());
      int m = Integer.parseInt(token.nextToken());

      if (n == 0 && m == 0) {
        break;
      }

      for (int i = 0; i < n; i++) {
        parentRank[i][0] = i;
        parentRank[i][1] = 0;
      }

      edgeList.clear();

      for (int i = 0; i < m; i++) {
        token = new StringTokenizer(reader.readLine());
        int x = Integer.parseInt(token.nextToken());
        int y = Integer.parseInt(token.nextToken());
        int w = Integer.parseInt(token.nextToken());

        edgeList.add(new Edge(x, y, w));
      }

      List<Integer> maxWeights = new ArrayList<Integer>();

      Collections.sort(edgeList);

      int maxWeight = 0;

      for (int i = 0; i < edgeList.size(); i++) {
        Edge edge = edgeList.get(i);
        int x = find(edge.a);
        int y = find(edge.b);

        if (x != y) {
          maxWeight = Math.max(maxWeight, edge.weight);
          union(x, y);
        } else {
          maxWeights.add(Math.max(maxWeight, edge.weight));
        }
      }

      if (maxWeights.size() > 0) {
        for (int i = 0; i < maxWeights.size(); i++) {
          if (i + 1 != maxWeights.size()) {
            System.out.print(maxWeights.get(i) + " ");
          } else {
            System.out.print(maxWeights.get(i));
          }
        }

        System.out.println();
      } else {
        System.out.println("forest");
      }
    }
  }
Exemplo n.º 23
0
 public void add(Point point) {
   points.add(point);
 }
Exemplo n.º 24
0
  public static void main(String[] args) {
    File file = new File("./shapesInput.txt");
    int ch;
    StringBuffer strContent = new StringBuffer("");
    FileInputStream fin = null;
    try {
      fin = new FileInputStream(file);
      while ((ch = fin.read()) != -1) {
        strContent.append((char) ch);
      }
      fin.close();
    } catch (FileNotFoundException e) {
      System.out.println("File" + file.getAbsolutePath() + " could not be found on filesystem");
    } catch (IOException ioe) {
      System.out.println("Exception while reading the file" + ioe);
    }
    String fileOutput = strContent.toString();
    String[] commands = fileOutput.split(";");
    List<Shape> shapes = new ArrayList<Shape>();
    List<Double> areas = new ArrayList<Double>();
    List<Double> areasD = new ArrayList<Double>();
    for (int i = 0; i <= commands.length - 1; i++) {
      String codeLine = commands[i];
      String shapeType = codeLine.substring(17, 20);
      switch (shapeType) {
        case "Cir":
          String rad = codeLine.substring(23, codeLine.length());
          rad = rad.replace("(", "");
          rad = rad.replace(")", "");
          int radius;
          radius = Integer.parseInt(rad);
          shapes.add(new Circle(radius));
          break;
        case "Rec":
          String len = codeLine.substring(26, codeLine.length());
          len = len.replace("(", "");
          len = len.replace(")", "");
          String[] params = len.split(",");
          String h = params[0];
          String l = params[1];
          int height = Integer.parseInt(h);
          int length = Integer.parseInt(l);
          shapes.add(new Rectangle(height, length));
          break;
        case "Rho":
          String stuff = codeLine.substring(24, codeLine.length());
          stuff = stuff.replace("(", "");
          stuff = stuff.replace(")", "");
          String[] parame = stuff.split(",");
          String first = parame[0];
          String second = parame[1];
          int fir = Integer.parseInt(first);
          int sec = Integer.parseInt(second);
          shapes.add(new Rhombus(fir, sec));
          break;
        case "Tra":
          String total = codeLine.substring(26, codeLine.length());
          total = total.replace("(", "");
          total = total.replace(")", "");
          String[] seperated = total.split(",");
          String onep = seperated[0];
          String twop = seperated[1];
          String threep = seperated[2];
          int op = Integer.parseInt(onep);
          int tp = Integer.parseInt(twop);
          int thp = Integer.parseInt(threep);
          shapes.add(new Trapezoid(op, tp, thp));
          break;
        case "Tri":
          String measures = codeLine.substring(25, codeLine.length());
          measures = measures.replace("(", "");
          measures = measures.replace(")", "");
          String[] listp = measures.split(",");
          String aaa = listp[0];
          String bbb = listp[1];
          int aa = Integer.parseInt(aaa);
          int bb = Integer.parseInt(bbb);
          shapes.add(new Triangle(aa, bb));
          break;
      }
    }
    for (int q = 0; q <= shapes.size(); q++) {
      for (int i = 0; i <= shapes.size() - 2; i++) {
        if (shapes.get(i).getArea() > shapes.get(i + 1).getArea()) {
          Shape temp;
          temp = shapes.get(i);
          shapes.set(i, shapes.get(i + 1));
          shapes.set(i + 1, temp);
        } else {

        }
      }
    }
    for (Shape s : shapes) {
      System.out.println("\nCalculating " + s.getShapeName() + " area:");
      System.out.println("Area = " + s.getArea());
      System.out.println("Printing " + s.getShapeName() + " description:");
      s.printDescription();
    }
  }
Exemplo n.º 25
0
 //execute SQL statement, SELECT * FROM mailing
 //rs = ...
 while (rs.next())
 {
     strRS = rs.getString(table1C1);
     strRS = strRS.substring(strRS.lastIndexOf("@")+1);
     emailList.add(strRS);
 }
Exemplo n.º 26
0
 public static List<Integer> mergeTwoLists(List<Integer> listOne, List<Integer> listTwo) {
   List<Integer> outputList = new ArrayList<Integer>();
   int i = 0;
   int j = 0;
   while (i < listOne.size() || j < listTwo.size()) {
     if (i == listOne.size()) {
       outputList.add(listTwo.get(j));
       j++;
     } else if (j == listTwo.size()) {
       outputList.add(listOne.get(i));
       i++;
     } else {
       if (listOne.get(i) <= listTwo.get(j)) {
         outputList.add(listOne.get(i));
         i++;
       } else {
         outputList.add(listTwo.get(j));
         j++;
       }
     }
   }
   return outputList;
 }