import java.io.IOException;\r
import java.io.PrintWriter;\r
import java.util.ArrayList;\r
+import java.util.Iterator;\r
import java.util.List;\r
\r
import javax.swing.Box;\r
import javax.swing.border.TitledBorder;\r
import javax.swing.table.DefaultTableModel;\r
\r
-import jp.naist.se.stigmata.BirthmarkEnvironment;\r
+import jp.naist.se.stigmata.BirthmarkContext;\r
import jp.naist.se.stigmata.BirthmarkSet;\r
-import jp.naist.se.stigmata.CertainPairComparisonResultSet;\r
import jp.naist.se.stigmata.ComparisonPair;\r
import jp.naist.se.stigmata.ComparisonResultSet;\r
import jp.naist.se.stigmata.format.FormatManager;\r
+import jp.naist.se.stigmata.result.CertainPairComparisonResultSet;\r
import jp.naist.se.stigmata.spi.ResultFormatSpi;\r
import jp.naist.se.stigmata.ui.swing.actions.SaveAction;\r
import jp.naist.se.stigmata.ui.swing.actions.UpdateBirthmarkCellColorAction;\r
private static final long serialVersionUID = 3298346465652354302L;\r
\r
private StigmataFrame frame;\r
- private BirthmarkEnvironment environment;\r
+ private ComparisonResultSet comparison;\r
private DefaultTableModel model = new PairComparisonResultSetTableModel();\r
private JTable table = new JTable(model);\r
private JLabel averageLabel, maximumLabel, minimumLabel;\r
- private List<ComparisonPair> list = new ArrayList<ComparisonPair>();\r
private double average, maximum, minimum;\r
\r
public PairComparisonResultSetPane(StigmataFrame frame, ComparisonResultSet resultset){\r
this.frame = frame;\r
- this.environment = resultset.getEnvironment();\r
-\r
- for(ComparisonPair pair: resultset){\r
- list.add(pair);\r
- }\r
+ this.comparison = resultset;\r
\r
initComponent();\r
- initData(model, list);\r
+ initData(model, resultset);\r
}\r
\r
private void obfuscateClassNames(){\r
ClassNameObfuscator obfuscator = new ClassNameObfuscator();\r
List<ComparisonPair> newList = new ArrayList<ComparisonPair>();\r
- for(ComparisonPair pair: list){\r
+ BirthmarkContext context = comparison.getContext();\r
+\r
+ for(Iterator<ComparisonPair> i = comparison.iterator(); i.hasNext(); ){\r
+ ComparisonPair pair = i.next();\r
BirthmarkSet set1 = obfuscator.obfuscateClassName(pair.getTarget1());\r
BirthmarkSet set2 = obfuscator.obfuscateClassName(pair.getTarget2());\r
\r
- newList.add(new ComparisonPair(set1, set2, environment));\r
+ context = comparison.getContext();\r
+ newList.add(new ComparisonPair(set1, set2, context));\r
}\r
\r
try{\r
}\r
\r
DefaultTableModel newModel = new PairComparisonResultSetTableModel();\r
- initData(newModel, newList);\r
- list = newList;\r
+ initData(newModel, new CertainPairComparisonResultSet(newList.toArray(new ComparisonPair[newList.size()]), context));\r
model = newModel;\r
table.setModel(newModel);\r
}\r
\r
- private void initData(DefaultTableModel model, List<ComparisonPair> list){\r
+ private void initData(DefaultTableModel model, ComparisonResultSet comparison){\r
maximum = 0d;\r
minimum = 1d;\r
average = 0d;\r
model.setColumnIdentifiers(Messages.getStringArray("comparepair.table.columns"));\r
\r
- for(ComparisonPair pair: list){\r
+ for(Iterator<ComparisonPair> i = comparison.iterator(); i.hasNext(); ){\r
+ ComparisonPair pair = i.next();\r
double similarity = pair.calculateSimilarity();\r
if(similarity > maximum) maximum = similarity;\r
if(similarity < minimum) minimum = similarity;\r
model.addRow(new Object[] { pair.getTarget1().getName(),\r
pair.getTarget2().getName(), new Double(similarity) });\r
}\r
- average = average / list.size();\r
+ average = average / comparison.getPairCount();\r
\r
averageLabel.setText(Double.toString(average));\r
maximumLabel.setText(Double.toString(maximum));\r
if(service == null){\r
service = FormatManager.getDefaultFormatService();\r
}\r
- service.getComparisonResultFormat().printResult(\r
- out, new CertainPairComparisonResultSet(\r
- list.toArray(new ComparisonPair[list.size()]), environment\r
- )\r
- );\r
+ service.getComparisonResultFormat().printResult(out, comparison);\r
}\r
})\r
);\r
JButton updateColorButton = Utility.createButton(\r
- "updatecellcolor", new UpdateBirthmarkCellColorAction(this, environment)\r
+ "updatecellcolor", new UpdateBirthmarkCellColorAction(this, comparison.getEnvironment())\r
);\r
JButton obfuscateButton = Utility.createButton("obfuscate");\r
JScrollPane scroll = new JScrollPane();\r
minimumLabel = new JLabel(Double.toString(minimum), JLabel.RIGHT);\r
\r
scroll.setViewportView(table);\r
- table.setDefaultRenderer(Double.class, new CompareTableCellRenderer(environment));\r
+ table.setDefaultRenderer(Double.class, new CompareTableCellRenderer(comparison.getEnvironment()));\r
similarityPane.setBorder(new TitledBorder(Messages.getString("similarity.border")));\r
averageLabel.setBorder(new TitledBorder(Messages.getString("average.border")));\r
maximumLabel.setBorder(new TitledBorder(Messages.getString("maximum.border")));\r
int col = table.columnAtPoint(e.getPoint());\r
if(col >= 1 && col < table.getColumnCount() && row >= 0\r
&& row < table.getRowCount()){\r
- ComparisonPair pair = list.get(row);\r
+ ComparisonPair pair = comparison.getPairAt(row);\r
\r
- frame.compareDetails(pair.getTarget1(), pair.getTarget2(), environment);\r
+ frame.compareDetails(pair.getTarget1(), pair.getTarget2(), comparison.getContext());\r
}\r
}\r
}\r