private String getBalance(JavaClass unit) { StringBuilder info = new StringBuilder(); info.append("内聚性指数("); info.append(MetricsFormat.toFormattedMetrics(unit.balance())); info.append(")=内聚值("); info.append(MetricsFormat.toFormattedMetrics(unit.cohesion())); info.append(")/内聚值("); info.append(MetricsFormat.toFormattedMetrics(unit.cohesion())); info.append(")+分组耦合最大顺序差值("); info.append(MetricsFormat.toFormattedMetrics(unit.getGroupCouplingInfo().getMaxDifference())); info.append(");\n"); info.append("分组耦合顺序值为:\n"); for (GroupCouplingItem groupCouplingInfo : unit.getGroupCouplingInfo().getGroupCouplingItems()) { info.append(groupCouplingInfo); info.append("\n"); } info.append("分组耦合顺序差值为:\n"); for (Float difference : unit.getGroupCouplingInfo().getDifferences()) { info.append(MetricsFormat.toFormattedMetrics(difference)); info.append("\n"); } info.append("分组耦合最大顺序差值为:"); info.append(MetricsFormat.toFormattedMetrics(unit.getGroupCouplingInfo().getMaxDifference())); return info.toString(); }
private JPanel createAdvisePanel(String itemName) { JPanel advisePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); advisePanel.setBackground(new java.awt.Color(255, 255, 255)); WisdomAnalysisResult wisdomAnalysisResult = new WisdomAnalysisResult(result); JLabel adviseLabel = null; JLabel descLabel = null; if (itemName.equals(AnalysisResult.Metrics_TotalScore)) { adviseLabel = new JLabel(); try { AdviseInfo advise = wisdomAnalysisResult.getAdvise(StructureCategory.LowScoreItemIdentifier); if (advise != null) { adviseLabel.setText( advise.getDesc() + ReportConstant.toMetricsName(advise.getComponentNameInfo())); advisePanel.add(adviseLabel); } } catch (JDependException e) { e.printStackTrace(); } } else if (itemName.equals(AnalysisResult.Metrics_D)) { try { AdviseInfo advise = wisdomAnalysisResult.getAdvise(StructureCategory.DDomainAnalysis); if (advise != null) { descLabel = new JLabel(); descLabel.setText(advise.getDesc()); adviseLabel = new JLabel(); adviseLabel.setFont(new java.awt.Font("宋体", 1, 15)); // NOI18N adviseLabel.setText(advise.getComponentNameInfo()); JDependUIUtil.addClickTipEffect(adviseLabel); adviseLabel.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jdepend.model.Component component = result.getTheComponent(((JLabel) evt.getSource()).getText()); ComponentDetailDialog d = new ComponentDetailDialog(component); d.setModal(true); d.setVisible(true); } }); advisePanel.add(adviseLabel); advisePanel.add(descLabel); } } catch (JDependException e) { e.printStackTrace(); } } else if (itemName.equals(AnalysisResult.Metrics_Balance)) { try { AdviseInfo advise = wisdomAnalysisResult.getAdvise(StructureCategory.CohesionDomainAnalysis); if (advise != null) { descLabel = new JLabel(); descLabel.setText(advise.getDesc()); adviseLabel = new JLabel(); adviseLabel.setFont(new java.awt.Font("宋体", 1, 15)); // NOI18N adviseLabel.setText(advise.getComponentNameInfo()); JDependUIUtil.addClickTipEffect(adviseLabel); adviseLabel.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jdepend.model.Component component = result.getTheComponent(((JLabel) evt.getSource()).getText()); BalanceComponentDialog d = new BalanceComponentDialog(frame, component); d.setModal(true); d.setVisible(true); } }); advisePanel.add(descLabel); advisePanel.add(adviseLabel); } } catch (JDependException e) { e.printStackTrace(); } } else if (itemName.equals(AnalysisResult.Metrics_Encapsulation)) { try { final AdviseInfo advise = wisdomAnalysisResult.getAdvise(StructureCategory.EncapsulationDomainAnalysis); if (advise != null) { descLabel = new JLabel(); descLabel.setText(advise.getDesc()); adviseLabel = new JLabel(); adviseLabel.setFont(new java.awt.Font("宋体", 1, 15)); // NOI18N adviseLabel.setText(advise.getComponentNameInfo()); JDependUIUtil.addClickTipEffect(adviseLabel); adviseLabel.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jdepend.model.Component component = result.getTheComponent(advise.getComponentNameInfo()); ClassListDialog d = new ClassListDialog(frame, component); d.setModal(true); d.setVisible(true); } }); advisePanel.add(descLabel); advisePanel.add(adviseLabel); } } catch (JDependException e) { e.printStackTrace(); } } else if (itemName.equals(AnalysisResult.Metrics_RelationRationality)) { Float rs = result.getAttentionRelationScale(); adviseLabel = new JLabel(); if (MathUtil.isZero(rs)) { adviseLabel.setText(BundleUtil.getString(BundleUtil.ClientWin_ScorePanel_RelationNormal)); } else { adviseLabel.setText( BundleUtil.getString(BundleUtil.Metrics_AttentionRelationScale) + ":" + MetricsFormat.toFormattedPercent(rs)); JDependUIUtil.addClickTipEffect(adviseLabel); adviseLabel.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { frame.getResultPanel().setTab(1, 1); } }); } advisePanel.add(adviseLabel); } return advisePanel; }
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; }