Esempio n. 1
0
  /**
   * @param status status 0 means search button is clicked status 1 menas redo button is clicked
   * @throws Exception The event when the search button or redo button is clicked
   */
  private void searchClickEvent(int status) throws Exception {
    if (status == 0) { // If search button is clicked
      String str = new String();
      str = getSqlStmtForMLX(); // New SQL statement according to search criteria defined
      System.out.println(str);

      // Search from database and generate CSV result
      marketAnalyzer = new MarketAnalyzer(str);
      // Initialize the MarketAnalyzer with the SQL statement defined
      // A new ResultSet will be generated
    } else if (status == 1) { // If redo button is clicked
      // do nothing, use the old marketAnalyzer
    }

    Addition addition = new Addition();
    int bchmkIndex = comboBchmkIndex.getSelectionIndex();
    if (bchmkIndex == 0 || bchmkIndex == -1) {
      addition.indexName = "caseshiller";
    } else if (bchmkIndex == 1) {
      addition.indexName = "zillow";
    }

    // Calculate average prices
    marketAnalyzer.doAnalysis(addition);
    text1MAvg.setText(Formater.toCurrency(marketAnalyzer.getAvg1MSPSqft()));
    text6MAvg.setText(Formater.toCurrency(marketAnalyzer.getAvg6MSPSqft()));
    text1YAvg.setText(Formater.toCurrency(marketAnalyzer.getAvg1YSPSqft()));

    text1MStd.setText(Formater.toCurrency(marketAnalyzer.getStd1MSPSqft()));
    text6MStd.setText(Formater.toCurrency(marketAnalyzer.getStd6MSPSqft()));
    text1YStd.setText(Formater.toCurrency(marketAnalyzer.getStd1YSPSqft()));

    text1MCounter.setText(new Integer(marketAnalyzer.getCounter1M()).toString());
    text6MCounter.setText(new Integer(marketAnalyzer.getCounter6M()).toString());
    text1YCounter.setText(new Integer(marketAnalyzer.getCounter1Y()).toString());

    // Calculate Price-Index regression
    reg1M = marketAnalyzer.getReg1MSPSqft();
    reg6M = marketAnalyzer.getReg6MSPSqft();
    reg1Y = marketAnalyzer.getReg1YSPSqft();

    text1MRegA.setText(Formater.toShortDouble(reg1M.getA(), 3));
    text1MRegB.setText(Formater.toShortDouble(reg1M.getB(), 3));
    text1MRegR.setText(Formater.toShortDouble(reg1M.getR2(), 3));

    textRegPrice1M.setText(Formater.toCurrency(reg1M.getY0()));

    text6MRegA.setText(Formater.toShortDouble(reg6M.getA(), 3));
    text6MRegB.setText(Formater.toShortDouble(reg6M.getB(), 3));
    text6MRegR.setText(Formater.toShortDouble(reg6M.getR2(), 3));

    textRegPrice6M.setText(Formater.toCurrency(reg6M.getY0()));
    System.out.println(reg6M.getR2());
    text1YRegA.setText(Formater.toShortDouble(reg1Y.getA(), 3));
    text1YRegB.setText(Formater.toShortDouble(reg1Y.getB(), 3));
    text1YRegR.setText(Formater.toShortDouble(reg1Y.getR2(), 3));
    System.out.println(reg1Y.getR2());
    textRegPrice1Y.setText(Formater.toCurrency(reg1Y.getY0()));

    text1MExtpoPrice.setText(Formater.toCurrency(marketAnalyzer.getExtpoResultPrice1M()));
    text6MExtpoPrice.setText(Formater.toCurrency(marketAnalyzer.getExtpoResultPrice6M()));
    text1YExtpoPrice.setText(Formater.toCurrency(marketAnalyzer.getExtpoResultPrice1Y()));

    ArrayList<String> finalEstText = new ArrayList<String>();
    finalEstText = getFinalEstimation();
    updateMiddlePanel(finalEstText);
  }