* $Id$\r
*/\r
\r
+import java.util.Arrays;\r
import java.util.Iterator;\r
+import java.util.List;\r
\r
/**\r
* Concrete class for ComparisonResultSet. This instance compare class files by round robin.\r
* @version $Revision$ $Date$\r
*/\r
public class RoundRobinComparisonResultSet implements ComparisonResultSet{\r
- private BirthmarkSet[] holders1;\r
- private BirthmarkSet[] holders2;\r
+ private List<BirthmarkSet> holders1;\r
+ private List<BirthmarkSet> holders2;\r
private BirthmarkContext context;\r
\r
private int compareCount;\r
* samePair is false.\r
*/\r
public RoundRobinComparisonResultSet(BirthmarkSet[] holders1, BirthmarkContext context,\r
- boolean samePair){\r
- this.holders1 = holders1;\r
- this.holders2 = holders1;\r
+ boolean samePair){\r
+ this.holders1 = Arrays.asList(holders1);\r
+ this.holders2 = Arrays.asList(holders1);\r
this.context = context;\r
\r
tablePair = false;\r
* y, z, } as holders2, then the instance compares { a<->x, a<->y,\r
* a<->z, b<->x, b<->y, b<->z, c<->x, c<->y, c<->z, }.\r
*/\r
- public RoundRobinComparisonResultSet(BirthmarkSet[] holders1, BirthmarkSet[] holders2,\r
- BirthmarkContext context){\r
- this.holders1 = holders1;\r
- this.holders2 = holders2;\r
+ public RoundRobinComparisonResultSet(final BirthmarkSet[] holders1, final BirthmarkSet[] holders2,\r
+ BirthmarkContext context){\r
+ this.holders1 = Arrays.asList(holders1);\r
+ this.holders2 = Arrays.asList(holders2);\r
this.context = context;\r
tablePair = true;\r
\r
public void setCompareSamePair(boolean flag){\r
samePair = flag;\r
if(samePair){\r
- compareCount = holders1.length * (holders1.length + 1) / 2;\r
+ compareCount = holders1.size() * (holders1.size() + 1) / 2;\r
}\r
else{\r
- compareCount = holders1.length * (holders1.length - 1) / 2;\r
+ compareCount = holders1.size() * (holders1.size() - 1) / 2;\r
}\r
}\r
\r
}\r
\r
public ComparisonPair next(){\r
- if((tablePair && i == holders1.length) || (!tablePair && !samePair && i == j)\r
+ if((tablePair && i == holders1.size()) || (!tablePair && !samePair && i == j)\r
|| (!tablePair && samePair && i > j)){\r
i = 0;\r
j++;\r
}\r
- ComparisonPair pair = new ComparisonPair(holders1[i], holders2[j], context);\r
+ ComparisonPair pair = new ComparisonPair(holders1.get(i), holders2.get(j), context);\r
count++;\r
i++;\r
return pair;\r
* $Id$\r
*/\r
\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
import jp.naist.se.stigmata.ComparisonPair;\r
import jp.naist.se.stigmata.spi.ComparisonPairFilterSpi;\r
\r
* @version $Revision$ $Date$\r
*/\r
public class BirthmarkElementCountComparisonPairFilter extends AbstractComparisonPairFilter{\r
- public static final Criterion[] CRITERIA = new Criterion[] {\r
- Criterion.GREATER_EQUALS, Criterion.GREATER_THAN,\r
- Criterion.LESS_EQUALS, Criterion.LESS_THAN,\r
- Criterion.EQUALS_AS, Criterion.NOT_EQUALS_AS, \r
- };\r
- \r
+ private static final List<Criterion> CRITERIA = new ArrayList<Criterion>();\r
+\r
private int threshold = 0;\r
private Target target;\r
private String birthmarkType;\r
\r
+ static{\r
+ CRITERIA.add(Criterion.GREATER_EQUALS);\r
+ CRITERIA.add(Criterion.GREATER_THAN);\r
+ CRITERIA.add(Criterion.LESS_EQUALS);\r
+ CRITERIA.add(Criterion.LESS_THAN);\r
+ CRITERIA.add(Criterion.EQUALS_AS);\r
+ CRITERIA.add(Criterion.NOT_EQUALS_AS);\r
+ }\r
+\r
public BirthmarkElementCountComparisonPairFilter(ComparisonPairFilterSpi service){\r
super(service);\r
}\r
this.birthmarkType = birthmarkType;\r
}\r
\r
+ public static Criterion[] getValidCriteria(){\r
+ return CRITERIA.toArray(new Criterion[CRITERIA.size()]);\r
+ }\r
+\r
public Criterion[] getAcceptableCriteria(){\r
- return CRITERIA;\r
+ return getValidCriteria();\r
}\r
\r
private boolean isFilteredTwo(ComparisonPair pair){\r
* $Id$\r
*/\r
\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
import jp.naist.se.stigmata.ComparisonPair;\r
import jp.naist.se.stigmata.spi.ComparisonPairFilterSpi;\r
\r
public class SimilarityComparisonPairFilter extends AbstractComparisonPairFilter{\r
private static final double EQUALS_THRESHOLD = 5E-5;\r
\r
- public static Criterion[] CRITERIA = new Criterion[] {\r
- Criterion.GREATER_EQUALS, Criterion.GREATER_THAN,\r
- Criterion.LESS_EQUALS, Criterion.LESS_THAN,\r
- Criterion.EQUALS_AS, Criterion.NOT_EQUALS_AS, \r
+ private static List<Criterion> CRITERIA = new ArrayList<Criterion>();\r
+ static{\r
+ CRITERIA.add(Criterion.GREATER_EQUALS);\r
+ CRITERIA.add(Criterion.GREATER_THAN);\r
+ CRITERIA.add(Criterion.LESS_EQUALS);\r
+ CRITERIA.add(Criterion.LESS_THAN);\r
+ CRITERIA.add(Criterion.EQUALS_AS);\r
+ CRITERIA.add(Criterion.NOT_EQUALS_AS); \r
};\r
\r
-\r
private double threshold;\r
\r
public SimilarityComparisonPairFilter(ComparisonPairFilterSpi service){\r
return flag;\r
}\r
\r
+ public static Criterion[] getValidCriteria(){\r
+ return CRITERIA.toArray(new Criterion[CRITERIA.size()]);\r
+ }\r
+\r
public Criterion[] getAcceptableCriteria(){\r
- return CRITERIA;\r
+ return getValidCriteria();\r
}\r
\r
public double getThreshold(){\r
* $Id$\r
*/\r
\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
import jp.naist.se.stigmata.ComparisonPair;\r
import jp.naist.se.stigmata.spi.ComparisonPairFilterSpi;\r
\r
* @version $Revision$ $Date$\r
*/\r
public class TargetNameComparisonPairFilter extends AbstractComparisonPairFilter{\r
- public static final Criterion[] CRITERIA = new Criterion[] {\r
- Criterion.STARTS_WITH, Criterion.NOT_STARTS_WITH, \r
- Criterion.ENDS_WITH, Criterion.NOT_ENDS_WITH,\r
- Criterion.EQUALS_AS, Criterion.NOT_EQUALS_AS,\r
- Criterion.MATCH, Criterion.NOT_MATCH,\r
+ private static final List<Criterion> CRITERIA = new ArrayList<Criterion>();\r
+\r
+ static{\r
+ CRITERIA.add(Criterion.STARTS_WITH);\r
+ CRITERIA.add(Criterion.NOT_STARTS_WITH); \r
+ CRITERIA.add(Criterion.ENDS_WITH);\r
+ CRITERIA.add(Criterion.NOT_ENDS_WITH);\r
+ CRITERIA.add(Criterion.EQUALS_AS);\r
+ CRITERIA.add(Criterion.NOT_EQUALS_AS);\r
+ CRITERIA.add(Criterion.MATCH);\r
+ CRITERIA.add(Criterion.NOT_MATCH);\r
};\r
private Target target = Target.BOTH_TARGET;\r
private String value;\r
}\r
\r
public Criterion[] getAcceptableCriteria(){\r
- return CRITERIA;\r
+ return getValidCriteria();\r
+ }\r
+\r
+ public static Criterion[] getValidCriteria(){\r
+ return CRITERIA.toArray(new Criterion[CRITERIA.size()]);\r
}\r
\r
public boolean isFiltered(ComparisonPair pair){\r
* $Id$\r
*/\r
\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
import jp.naist.se.stigmata.ComparisonPair;\r
import jp.naist.se.stigmata.spi.ComparisonPairFilterSpi;\r
\r
* @version $Revision$ $Date$\r
*/\r
public class TotalElementCountComparisonPairFilter extends AbstractComparisonPairFilter{\r
- public static final Criterion[] CRITERIA = new Criterion[] {\r
- Criterion.GREATER_EQUALS, Criterion.GREATER_THAN,\r
- Criterion.LESS_EQUALS, Criterion.LESS_THAN,\r
- Criterion.EQUALS_AS, Criterion.NOT_EQUALS_AS, \r
- Criterion.MATCH, Criterion.NOT_MATCH, \r
+ private static final List<Criterion> CRITERIA = new ArrayList<Criterion>();\r
+ static{\r
+ CRITERIA.add(Criterion.GREATER_EQUALS);\r
+ CRITERIA.add(Criterion.GREATER_THAN);\r
+ CRITERIA.add(Criterion.LESS_EQUALS);\r
+ CRITERIA.add(Criterion.LESS_THAN);\r
+ CRITERIA.add(Criterion.EQUALS_AS);\r
+ CRITERIA.add(Criterion.NOT_EQUALS_AS); \r
+ CRITERIA.add(Criterion.MATCH);\r
+ CRITERIA.add(Criterion.NOT_MATCH);\r
};\r
\r
private int threshold = 0;\r
}\r
\r
public Criterion[] getAcceptableCriteria(){\r
- return CRITERIA;\r
+ return getValidCriteria();\r
+ }\r
+\r
+ public static Criterion[] getValidCriteria(){\r
+ return CRITERIA.toArray(new Criterion[CRITERIA.size()]);\r
}\r
\r
public boolean isFiltered(ComparisonPair pair){\r
import java.awt.event.ActionEvent;\r
import java.awt.event.ActionListener;\r
import java.io.PrintWriter;\r
+import java.util.Arrays;\r
+import java.util.List;\r
\r
import javax.swing.Box;\r
import javax.swing.JButton;\r
public class BirthmarkExtractionResultPane extends JPanel implements BirthmarkDataWritable{\r
private static final long serialVersionUID = 239084365756236543L;\r
\r
- private BirthmarkSet[] holders;\r
+ private List<BirthmarkSet> birthmarks;\r
private StigmataFrame frame;\r
\r
- public BirthmarkExtractionResultPane(StigmataFrame stigmataFrame, BirthmarkContext context, BirthmarkSet[] holders){\r
+ public BirthmarkExtractionResultPane(StigmataFrame stigmataFrame, BirthmarkContext context, BirthmarkSet[] sets){\r
this.frame = stigmataFrame;\r
- this.holders = holders;\r
+ this.birthmarks = Arrays.asList(sets);\r
\r
JComponent southPanel = Box.createHorizontalBox(); \r
// JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));\r
JButton saveButton = Utility.createButton("savebirthmark");\r
JScrollPane scroll = new JScrollPane();\r
\r
- scroll.setViewportView(new BirthmarkTree(holders));\r
+ scroll.setViewportView(new BirthmarkTree(birthmarks.toArray(new BirthmarkSet[birthmarks.size()])));\r
\r
setLayout(new BorderLayout());\r
add(scroll, BorderLayout.CENTER);\r
public void writeData(PrintWriter out, ResultFormatSpi service){\r
BirthmarkExtractionResultFormat list = service.getExtractionResultFormat();\r
\r
- list.printResult(new PrintWriter(out), holders);\r
+ list.printResult(new PrintWriter(out), birthmarks.toArray(new BirthmarkSet[birthmarks.size()]));\r
}\r
}\r
import java.io.File;\r
import java.io.IOException;\r
import java.io.PrintWriter;\r
+import java.util.Arrays;\r
import java.util.HashMap;\r
+import java.util.List;\r
import java.util.Map;\r
\r
import javax.swing.Box;\r
public class RoundRobinComparisonResultPane extends JPanel implements BirthmarkDataWritable{\r
private static final long serialVersionUID = 2134574576543623L;\r
\r
- private BirthmarkSet[] birthmarksX;\r
- private BirthmarkSet[] birthmarksY;\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
BirthmarkSet[] birthmarksX, BirthmarkSet[] birthmarksY){\r
this.stigmataFrame = stigmata;\r
this.context = context;\r
- this.birthmarksX = birthmarksX;\r
- this.birthmarksY = birthmarksY;\r
+ this.birthmarksX = Arrays.asList(birthmarksX);\r
+ this.birthmarksY = Arrays.asList(birthmarksY);\r
\r
initialize();\r
compare(model);\r
\r
public void writeData(PrintWriter out, ResultFormatSpi service){\r
service.getComparisonResultFormat().printResult(out,\r
- new RoundRobinComparisonResultSet(birthmarksX, birthmarksY, context));\r
+ new RoundRobinComparisonResultSet(\r
+ birthmarksX.toArray(new BirthmarkSet[birthmarksX.size()]), \r
+ birthmarksY.toArray(new BirthmarkSet[birthmarksY.size()]), context\r
+ )\r
+ );\r
}\r
\r
private void compare(DefaultTableModel model){\r
- int comparison = birthmarksX.length * birthmarksY.length;\r
+ int comparison = birthmarksX.size() * birthmarksY.size();\r
\r
- classCount.setText(Integer.toString(birthmarksX.length + birthmarksY.length));\r
+ classCount.setText(Integer.toString(birthmarksX.size() + birthmarksY.size()));\r
comparisonCount.setText(Integer.toString(comparison));\r
int correct = 0;\r
double avg = 0d;\r
for(BirthmarkSet x: birthmarksX){\r
model.addColumn(x.getClassName());\r
}\r
- for(int j = 0; j < birthmarksY.length; j++){\r
- Object[] rows = new Object[birthmarksX.length + 1];\r
- rows[0] = birthmarksY[j].getClassName();\r
+ for(int j = 0; j < birthmarksY.size(); j++){\r
+ Object[] rows = new Object[birthmarksX.size() + 1];\r
+ rows[0] = birthmarksY.get(j).getClassName();\r
\r
- for(int i = 0; i < birthmarksX.length; i++){\r
- double similarity = compare(context, birthmarksX[i], birthmarksY[j]);\r
+ for(int i = 0; i < birthmarksX.size(); i++){\r
+ double similarity = compare(context, birthmarksX.get(i), birthmarksY.get(j));\r
rows[i + 1] = new Double(similarity);\r
\r
if(Math.abs(similarity - 1) < 1E-8){\r
int col = table.columnAtPoint(e.getPoint());\r
if(col >= 1 && col < table.getColumnCount() && row >= 0\r
&& row < table.getRowCount()){\r
- BirthmarkSet b1 = birthmarksX[col - 1];\r
- BirthmarkSet b2 = birthmarksY[row];\r
+ BirthmarkSet b1 = birthmarksX.get(col - 1);\r
+ BirthmarkSet b2 = birthmarksY.get(row);\r
\r
stigmataFrame.compareDetails(b1, b2, context);\r
}\r
}\r
\r
private void compareGuessedPair(){\r
- ComparisonResultSet resultset = new CertainPairComparisonResultSet(birthmarksX, birthmarksY, context);\r
+ ComparisonResultSet resultset = new CertainPairComparisonResultSet(\r
+ birthmarksX.toArray(new BirthmarkSet[birthmarksX.size()]), \r
+ birthmarksY.toArray(new BirthmarkSet[birthmarksY.size()]),\r
+ context\r
+ );\r
stigmataFrame.showComparisonResultSet(resultset);\r
}\r
\r
if(file != null){\r
Map<String, String> mapping = stigmataFrame.constructMapping(file);\r
\r
- ComparisonResultSet resultset = new CertainPairComparisonResultSet(birthmarksX, birthmarksY, mapping, context); \r
+ ComparisonResultSet resultset = new CertainPairComparisonResultSet(\r
+ birthmarksX.toArray(new BirthmarkSet[birthmarksX.size()]), \r
+ birthmarksY.toArray(new BirthmarkSet[birthmarksY.size()]),\r
+ mapping, context\r
+ ); \r
stigmataFrame.showComparisonResultSet(resultset);\r
}\r
}\r
private void obfuscateClassNames(){\r
ClassNameObfuscator obfuscator = new ClassNameObfuscator();\r
\r
- for(int i = 0; i < birthmarksX.length; i++){\r
- birthmarksX[i] = obfuscator.obfuscateClassName(birthmarksX[i]);\r
+ for(int i = 0; i < birthmarksX.size(); i++){\r
+ birthmarksX.set(i, obfuscator.obfuscateClassName(birthmarksX.get(i)));\r
}\r
- for(int i = 0; i < birthmarksY.length; i++){\r
- birthmarksY[i] = obfuscator.obfuscateClassName(birthmarksY[i]);\r
+ for(int i = 0; i < birthmarksY.size(); i++){\r
+ birthmarksY.set(i, obfuscator.obfuscateClassName(birthmarksY.get(i)));\r
}\r
\r
try{\r
private void initLayouts(){\r
JLabel label = new JLabel(Messages.getString("filter.elementcount.label"));\r
threshold = new JTextField();\r
- criterionType = createCriteriaBox(BirthmarkElementCountComparisonPairFilter.CRITERIA);\r
+ criterionType = createCriteriaBox(BirthmarkElementCountComparisonPairFilter.getValidCriteria());\r
birthmarks = new JComboBox();\r
birthmarks.setRenderer(new BirthmarkServiceListCellRenderer(new Dimension(200, 20), 60));\r
JLabel label2 = new JLabel(Messages.getString("filter.elementcount.label.next"));\r
private void initLayouts(){\r
JLabel label = new JLabel(Messages.getString("filter.similarity.label"));\r
threshold = new JTextField();\r
- criterionType = createCriteriaBox(SimilarityComparisonPairFilter.CRITERIA);\r
+ criterionType = createCriteriaBox(SimilarityComparisonPairFilter.getValidCriteria());\r
\r
setLayout(new GridLayout(3, 1));\r
add(label);\r
private void initLayouts(){\r
JLabel label = new JLabel(Messages.getString("filter.name.label"));\r
value = new JTextField();\r
- criterionType = createCriteriaBox(TargetNameComparisonPairFilter.CRITERIA);\r
+ criterionType = createCriteriaBox(TargetNameComparisonPairFilter.getValidCriteria());\r
targetType = createTargetBox();\r
\r
setLayout(new GridLayout(4, 1));\r
private void initLayouts(){\r
JLabel label = new JLabel(Messages.getString("filter.totalelementcount.label"));\r
threshold = new JTextField();\r
- criterionType = createCriteriaBox(TotalElementCountComparisonPairFilter.CRITERIA);\r
+ criterionType = createCriteriaBox(TotalElementCountComparisonPairFilter.getValidCriteria());\r
targetType = createTargetBox();\r
\r
setLayout(new GridLayout(4, 1));\r