import java.io.IOException;\r
import java.io.PrintWriter;\r
import java.net.URL;\r
-import java.util.Arrays;\r
import java.util.HashMap;\r
-import java.util.List;\r
+import java.util.Iterator;\r
import java.util.Map;\r
\r
import javax.swing.Box;\r
import jp.naist.se.stigmata.BirthmarkComparator;\r
import jp.naist.se.stigmata.BirthmarkEnvironment;\r
import jp.naist.se.stigmata.BirthmarkSet;\r
-import jp.naist.se.stigmata.CertainPairComparisonResultSet;\r
import jp.naist.se.stigmata.ComparisonResultSet;\r
-import jp.naist.se.stigmata.RoundRobinComparisonResultSet;\r
+import jp.naist.se.stigmata.ExtractionResultSet;\r
+import jp.naist.se.stigmata.ExtractionTarget;\r
import jp.naist.se.stigmata.filter.FilteredComparisonResultSet;\r
import jp.naist.se.stigmata.format.FormatManager;\r
+import jp.naist.se.stigmata.result.CertainPairComparisonResultSet;\r
+import jp.naist.se.stigmata.result.MemoryExtractionResultSet;\r
+import jp.naist.se.stigmata.result.RoundRobinComparisonResultSet;\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
public class RoundRobinComparisonResultPane extends JPanel{\r
private static final long serialVersionUID = 2134574576543623L;\r
\r
- private List<BirthmarkSet> birthmarksX;\r
- private List<BirthmarkSet> birthmarksY;\r
+ private ExtractionResultSet extraction;\r
+ // private List<BirthmarkSet> birthmarksX;\r
+ // private List<BirthmarkSet> birthmarksY;\r
private JTable table;\r
private DefaultTableModel model;\r
private JLabel classCount, comparisonCount, distinctionRatio;\r
private JLabel average, minimum, maximum;\r
private StigmataFrame stigmataFrame;\r
- private BirthmarkEnvironment environment;\r
+ // private BirthmarkEnvironment environment;\r
\r
+ public RoundRobinComparisonResultPane(StigmataFrame stigmata, ExtractionResultSet resultset){\r
+ this.stigmataFrame = stigmata;\r
+ this.extraction = resultset;\r
+ initialize();\r
+ compare(model);\r
+ }\r
+\r
+ @Deprecated\r
public RoundRobinComparisonResultPane(StigmataFrame stigmata, BirthmarkEnvironment environment,\r
BirthmarkSet[] birthmarksX, BirthmarkSet[] birthmarksY){\r
this.stigmataFrame = stigmata;\r
- this.environment = environment;\r
- this.birthmarksX = Arrays.asList(birthmarksX);\r
- this.birthmarksY = Arrays.asList(birthmarksY);\r
\r
initialize();\r
compare(model);\r
}\r
\r
private void compare(DefaultTableModel model){\r
- int comparison = birthmarksX.size() * birthmarksY.size();\r
+ int countX = extraction.getBirthmarkSetSize(ExtractionTarget.TARGET_X);\r
+ int countY = extraction.getBirthmarkSetSize(ExtractionTarget.TARGET_Y);\r
+ int comparisonCount = countX * countY;\r
\r
- classCount.setText(Integer.toString(birthmarksX.size() + birthmarksY.size()));\r
- comparisonCount.setText(Integer.toString(comparison));\r
+ classCount.setText(Integer.toString(countX + countY));\r
+ this.comparisonCount.setText(Integer.toString(comparisonCount));\r
int correct = 0;\r
double avg = 0d;\r
double max = 0d;\r
double min = 100d;\r
model.addColumn("");\r
- for(BirthmarkSet x: birthmarksX){\r
+ for(Iterator<BirthmarkSet> i = extraction.birthmarkSets(ExtractionTarget.TARGET_X); i.hasNext(); ){\r
+ BirthmarkSet x = i.next();\r
model.addColumn(x.getName());\r
}\r
- for(int j = 0; j < birthmarksY.size(); j++){\r
- Object[] rows = new Object[birthmarksX.size() + 1];\r
- rows[0] = birthmarksY.get(j).getName();\r
-\r
- for(int i = 0; i < birthmarksX.size(); i++){\r
- double similarity = compare(environment, birthmarksX.get(i), birthmarksY.get(j));\r
- rows[i + 1] = new Double(similarity);\r
+ int sizeX = extraction.getBirthmarkSetSize(ExtractionTarget.TARGET_X);\r
+ for(Iterator<BirthmarkSet> i = extraction.birthmarkSets(ExtractionTarget.TARGET_Y); i.hasNext(); ){\r
+ Object[] rows = new Object[sizeX + 1];\r
+ BirthmarkSet setY = i.next();\r
+ rows[0] = setY.getName();\r
+\r
+ int index = 0;\r
+ for(Iterator<BirthmarkSet> j = extraction.birthmarkSets(ExtractionTarget.TARGET_X); j.hasNext(); ){\r
+ BirthmarkSet setX = j.next();\r
+ double similarity = compare(setX, setY, extraction.getEnvironment());\r
+ rows[index + 1] = new Double(similarity);\r
\r
if(Math.abs(similarity - 1) < 1E-8){\r
correct += 1;\r
avg += similarity;\r
if(max < similarity) max = similarity;\r
if(min > similarity) min = similarity;\r
+ index++;\r
}\r
model.addRow(rows);\r
}\r
distinctionRatio.setText(\r
- Double.toString((double)(comparison - correct) / (double)comparison)\r
+ Double.toString((double)(comparisonCount - correct) / (double)comparisonCount)\r
);\r
- avg = avg / comparison;\r
+ avg = avg / comparisonCount;\r
average.setText(Double.toString(avg));\r
minimum.setText(Double.toString(min));\r
maximum.setText(Double.toString(max));\r
}\r
\r
- private double compare(BirthmarkEnvironment environment, BirthmarkSet x, BirthmarkSet y){\r
+ private double compare(BirthmarkSet x, BirthmarkSet y, BirthmarkEnvironment environment){\r
double similarity = 0d;\r
int count = 0;\r
\r
if(b1 != null && b2 != null){\r
BirthmarkComparator comparator = environment.getService(type).getComparator();\r
double result = comparator.compare(b1, b2);\r
- if(result != Double.NaN){\r
+ if(!Double.isNaN(result)){\r
similarity += result;\r
count++;\r
}\r
\r
model = new RoundRobinComparisonResultSetTableModel();\r
table = new JTable(model);\r
- table.setDefaultRenderer(Double.class, new CompareTableCellRenderer(environment));\r
+ table.setDefaultRenderer(Double.class, new CompareTableCellRenderer(extraction.getEnvironment()));\r
table.addMouseListener(new MouseAdapter(){\r
public void mouseClicked(MouseEvent e){\r
if(e.getClickCount() == 2){\r
int col = table.columnAtPoint(e.getPoint());\r
if(col >= 1 && col < table.getColumnCount() && row >= 0\r
&& row < table.getRowCount()){\r
- BirthmarkSet b1 = birthmarksX.get(col - 1);\r
- BirthmarkSet b2 = birthmarksY.get(row);\r
+ BirthmarkSet b1 = extraction.getBirthmarkSet(ExtractionTarget.TARGET_X, col - 1);\r
+ BirthmarkSet b2 = extraction.getBirthmarkSet(ExtractionTarget.TARGET_Y, row);\r
\r
- stigmataFrame.compareDetails(b1, b2, environment);\r
+ stigmataFrame.compareDetails(b1, b2, extraction.getContext());\r
}\r
}\r
}\r
\r
private void mdsButtonActionPerformed(ActionEvent e){\r
Map<URL, BirthmarkSet> map = new HashMap<URL, BirthmarkSet>();\r
- for(BirthmarkSet bs: birthmarksX){\r
+ for(Iterator<BirthmarkSet> i = extraction.birthmarkSets(ExtractionTarget.TARGET_X); i.hasNext(); ){\r
+ BirthmarkSet bs = i.next();\r
map.put(bs.getLocation(), bs);\r
}\r
- for(BirthmarkSet bs: birthmarksY){\r
+ for(Iterator<BirthmarkSet> i = extraction.birthmarkSets(ExtractionTarget.TARGET_Y); i.hasNext(); ){\r
+ BirthmarkSet bs = i.next();\r
map.put(bs.getLocation(), bs);\r
}\r
int index = 0;\r
set[index] = entry.getValue();\r
index++;\r
}\r
-\r
- stigmataFrame.showMDSGraph(set);\r
+ \r
+ stigmataFrame.showMDSGraph(set, extraction.getContext());\r
}\r
\r
private void graphButtonActionPerformed(ActionEvent e){\r
service = FormatManager.getDefaultFormatService();\r
}\r
\r
- service.getComparisonResultFormat().printResult(out,\r
- new RoundRobinComparisonResultSet(\r
- birthmarksX.toArray(new BirthmarkSet[birthmarksX.size()]), \r
- birthmarksY.toArray(new BirthmarkSet[birthmarksY.size()]), environment\r
- )\r
+ service.getComparisonResultFormat().printResult(\r
+ out, new RoundRobinComparisonResultSet(extraction)\r
);\r
}\r
}\r
JButton obfuscate = Utility.createButton("obfuscate");\r
JButton compare = Utility.createButton("guessedpair");\r
JButton updateColor = Utility.createButton(\r
- "updatecellcolor", new UpdateBirthmarkCellColorAction(this, environment)\r
+ "updatecellcolor", new UpdateBirthmarkCellColorAction(this, extraction.getEnvironment())\r
);\r
JMenuItem mdsMenu = Utility.createJMenuItem("mdsmap");\r
\r
\r
private void compareRoundRobinWithFiltering(){\r
FilterSelectionPane pane = new FilterSelectionPane(\r
- environment.getFilterManager()\r
+ extraction.getEnvironment().getFilterManager()\r
);\r
int returnValue = JOptionPane.showConfirmDialog(\r
stigmataFrame, pane, Messages.getString("filterselection.dialog.title"),\r
if(returnValue == JOptionPane.OK_OPTION){\r
String[] filterSetList = pane.getSelectedFilters();\r
\r
- ComparisonResultSet resultset = new RoundRobinComparisonResultSet(\r
- birthmarksX.toArray(new BirthmarkSet[birthmarksX.size()]),\r
- birthmarksY.toArray(new BirthmarkSet[birthmarksY.size()]),\r
- environment\r
- );\r
+ ComparisonResultSet rs = new RoundRobinComparisonResultSet(extraction);\r
\r
ComparisonResultSet filterResultSet = new FilteredComparisonResultSet(\r
- resultset,\r
- environment.getFilterManager().getFilterSets(filterSetList)\r
+ rs, extraction.getEnvironment().getFilterManager().getFilterSets(filterSetList)\r
);\r
stigmataFrame.showComparisonResultSet(filterResultSet);\r
}\r
}\r
\r
private void compareGuessedPair(){\r
- ComparisonResultSet resultset = new CertainPairComparisonResultSet(\r
- birthmarksX.toArray(new BirthmarkSet[birthmarksX.size()]),\r
- birthmarksY.toArray(new BirthmarkSet[birthmarksY.size()]),\r
- environment\r
- );\r
- stigmataFrame.showComparisonResultSet(resultset);\r
+ ComparisonResultSet rs = new CertainPairComparisonResultSet(extraction);\r
+ stigmataFrame.showComparisonResultSet(rs);\r
}\r
\r
private void compareSpecifiedPair(){\r
if(file != null){\r
Map<String, String> mapping = stigmataFrame.constructMapping(file);\r
\r
- ComparisonResultSet resultset = new CertainPairComparisonResultSet(\r
- birthmarksX.toArray(new BirthmarkSet[birthmarksX.size()]),\r
- birthmarksY.toArray(new BirthmarkSet[birthmarksY.size()]),\r
- mapping, environment\r
- );\r
- stigmataFrame.showComparisonResultSet(resultset);\r
+ ComparisonResultSet comparison = new CertainPairComparisonResultSet(extraction, mapping);\r
+ stigmataFrame.showComparisonResultSet(comparison);\r
}\r
}\r
\r
Messages.getString("obfuscationmapping.description")\r
);\r
if(file != null){\r
- for(int i = 0; i < birthmarksX.size(); i++){\r
- birthmarksX.set(i, obfuscator.obfuscateClassName(birthmarksX.get(i)));\r
+ ExtractionResultSet ers = new MemoryExtractionResultSet(extraction.getContext(), extraction.isTableType());\r
+ for(Iterator<BirthmarkSet> i = extraction.birthmarkSets(ExtractionTarget.TARGET_X); i.hasNext(); ){\r
+ BirthmarkSet bs = i.next();\r
+ ers.addBirthmarkSet(ExtractionTarget.TARGET_X, obfuscator.obfuscateClassName(bs));\r
}\r
- for(int i = 0; i < birthmarksY.size(); i++){\r
- birthmarksY.set(i, obfuscator.obfuscateClassName(birthmarksY.get(i)));\r
+ for(Iterator<BirthmarkSet> i = extraction.birthmarkSets(ExtractionTarget.TARGET_Y); i.hasNext(); ){\r
+ BirthmarkSet bs = i.next();\r
+ ers.addBirthmarkSet(ExtractionTarget.TARGET_Y, obfuscator.obfuscateClassName(bs));\r
}\r
-\r
+ this.extraction = ers;\r
obfuscator.outputNameMappings(file);\r
}\r
}catch(IOException e){\r