Esempio n. 1
0
  private JComponent createGraphScore() {
    GraphData graph = new GraphData();
    graph.setAddJScrollPane(false);

    GraphDataItem item = null;
    Map<Object, Object> datas = null;

    if (this.result.getDistance() != null) {
      item = new GraphDataItem();
      item.setTitle(BundleUtil.getString(BundleUtil.Metrics_D));
      item.setType(GraphDataItem.PIE);
      datas = new HashMap<Object, Object>();
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_Score),
          this.result.getDistance() / result.getDistanceScale());
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_ScoreDifference),
          1F - this.result.getDistance() / result.getDistanceScale());
      item.setDatas(datas);
      graph.addItem(item);
    }

    if (this.result.getBalance() != null) {
      item = new GraphDataItem();
      item.setTitle(BundleUtil.getString(BundleUtil.Metrics_Balance));
      item.setType(GraphDataItem.PIE);
      datas = new HashMap<Object, Object>();
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_Score),
          this.result.getBalance() / result.getBalanceScale());
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_ScoreDifference),
          1F - this.result.getBalance() / result.getBalanceScale());
      item.setDatas(datas);
      graph.addItem(item);
    }

    if (this.result.getEncapsulation() != null) {
      item = new GraphDataItem();
      item.setTitle(BundleUtil.getString(BundleUtil.Metrics_Encapsulation));
      item.setType(GraphDataItem.PIE);
      datas = new HashMap<Object, Object>();
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_Score),
          this.result.getEncapsulation() / result.getEncapsulationScale());
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_ScoreDifference),
          1F - this.result.getEncapsulation() / result.getEncapsulationScale());
      item.setDatas(datas);
      graph.addItem(item);
    }

    if (this.result.getRelationRationality() != null) {
      item = new GraphDataItem();
      item.setTitle(BundleUtil.getString(BundleUtil.Metrics_RelationRationality));
      item.setType(GraphDataItem.PIE);
      datas = new HashMap<Object, Object>();
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_Score),
          this.result.getRelationRationality() / result.getRelationRationalityScale());
      datas.put(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_ScoreDifference),
          1F - this.result.getRelationRationality() / result.getRelationRationalityScale());
      item.setDatas(datas);
      graph.addItem(item);
    }

    JPanel contentPanel = new JPanel(new BorderLayout());
    contentPanel.setBackground(new java.awt.Color(255, 255, 255));
    try {
      contentPanel.add(GraphUtil.createGraph(graph));
    } catch (JDependException e) {
      e.printStackTrace();
    }

    return contentPanel;
  }
Esempio n. 2
0
  private JPanel createItem(String itemName, final Float scoreValue) {

    JPanel itemPanel = new JPanel(new BorderLayout());
    itemPanel.setBackground(new java.awt.Color(255, 255, 255));
    itemPanel.setBorder(new EmptyBorder(2, 2, 2, 2));

    JPanel scorePanel = new JPanel(new GridLayout(2, 1));
    scorePanel.setBackground(new java.awt.Color(255, 255, 255));

    JPanel scoreItemPanel = new JPanel(new GridLayout(1, 4, 4, 0));
    scoreItemPanel.setBackground(new java.awt.Color(255, 255, 255));
    JLabel scoreTitle = new JLabel();
    scoreTitle.setFont(new java.awt.Font("宋体", 1, 18));
    String title = BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_Score) + ":";
    scoreTitle.setText(title);
    scoreItemPanel.add(scoreTitle);

    JLabel score = new JLabel();
    score.setFont(new java.awt.Font("宋体", 1, 18));

    if (scoreValue != null) {
      score.setText(MetricsFormat.toFormattedMetrics(scoreValue).toString());
    } else {
      score.setText(Scored.NoValue);
    }

    scoreItemPanel.add(score);
    JLabel scoreCompareLabel = this.getComparedLabel(scoreValue, itemName);
    if (scoreCompareLabel != null) {
      scoreItemPanel.add(scoreCompareLabel);
    }
    if (itemName.equals(AnalysisResult.Metrics_TotalScore)) {

      score.addMouseListener(
          new java.awt.event.MouseAdapter() {
            @Override
            public void mouseClicked(java.awt.event.MouseEvent evt) {
              ScoreSummaryDialog d = new ScoreSummaryDialog(frame);
              d.setVisible(true);
            }
          });
      JDependUIUtil.addClickTipEffect(score);

      JLabel mm = new JLabel("MM");
      mm.addMouseListener(
          new java.awt.event.MouseAdapter() {
            @Override
            public void mouseClicked(java.awt.event.MouseEvent evt) {
              MMDialog motive = new MMDialog();
              motive.setModal(true);
              motive.setVisible(true);
            }
          });
      JDependUIUtil.addClickTipEffect(mm);

      scoreItemPanel.add(mm);
    }
    scorePanel.add(scoreItemPanel);

    JLabel fullScore = new JLabel();
    fullScore.setBackground(new java.awt.Color(153, 153, 153));
    fullScore.setFont(new java.awt.Font("宋体", 0, 10));
    fullScore.setForeground(new java.awt.Color(204, 204, 204));
    if (itemName.equals(AnalysisResult.Metrics_TotalScore)) {
      fullScore.setText(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_FullScore)
              + ":"
              + result.getFullScore());
    } else if (itemName.equals(AnalysisResult.Metrics_RelationRationality)) {
      fullScore.setText(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_FullScore)
              + ":"
              + result.getRelationRationalityScale());
    } else if (itemName.equals(AnalysisResult.Metrics_D)) {
      fullScore.setText(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_FullScore)
              + ":"
              + result.getDistanceScale());
    } else if (itemName.equals(AnalysisResult.Metrics_Balance)) {
      fullScore.setText(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_FullScore)
              + ":"
              + result.getBalanceScale());
    } else if (itemName.equals(AnalysisResult.Metrics_Encapsulation)) {
      fullScore.setText(
          BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_FullScore)
              + ":"
              + result.getEncapsulationScale());
    }

    scorePanel.add(fullScore);

    itemPanel.add(BorderLayout.WEST, scorePanel);

    JPanel scoreScope = new JPanel();
    if (scorelist.size() > 0) {
      ScoreFacade.sort(scorelist, itemName);
      final ScoreInfo lScore = scorelist.get(0);
      final ScoreInfo hScore = scorelist.get(scorelist.size() - 1);

      scoreScope = this.createScope(lScore, hScore, itemName);
    }

    itemPanel.add(BorderLayout.EAST, scoreScope);

    itemPanel.add(BorderLayout.SOUTH, this.createAdvisePanel(itemName));

    return itemPanel;
  }