/**\r
* class name.\r
*/\r
- private String className;\r
+ private String name;\r
\r
/**\r
* location of class file is loaded from.\r
/**\r
* constructor.\r
*/\r
- public BirthmarkSet(String className, URL location){\r
- this.className = className;\r
+ public BirthmarkSet(String name, URL location){\r
+ this.name = name;\r
this.location = location;\r
}\r
\r
/**\r
* return the class name.\r
*/\r
- public String getClassName(){\r
- return className;\r
+ public String getName(){\r
+ return name;\r
}\r
\r
/**\r
public CertainPairComparisonResultSet(BirthmarkSet[] targetX, BirthmarkSet[] targetY, BirthmarkContext context){\r
this.context = context;\r
for(int i = 0; i < targetX.length; i++){\r
- BirthmarkSet target2 = findTarget(targetX[i].getClassName(), targetY);\r
+ BirthmarkSet target2 = findTarget(targetX[i].getName(), targetY);\r
\r
if(target2 != null){\r
pairList.add(new ComparisonPair(targetX[i], target2, context));\r
*/\r
private BirthmarkSet findTarget(String className, BirthmarkSet[] target){\r
for(int i = 0; i < target.length; i++){\r
- if(className.equals(target[i].getClassName())){\r
+ if(className.equals(target[i].getName())){\r
return target[i];\r
}\r
}\r
if(v == null) v = "";\r
boolean flag;\r
if(getTarget() == Target.TARGET_1){\r
- flag = checkMatch(pair.getTarget1().getClassName(), v);\r
+ flag = checkMatch(pair.getTarget1().getName(), v);\r
}\r
else if(getTarget() == Target.TARGET_2){\r
- flag = checkMatch(pair.getTarget2().getClassName(), v);\r
+ flag = checkMatch(pair.getTarget2().getName(), v);\r
}\r
else{\r
- flag = checkMatch(pair.getTarget1().getClassName(), pair.getTarget2().getClassName(), v);\r
+ flag = checkMatch(pair.getTarget1().getName(), pair.getTarget2().getName(), v);\r
}\r
return flag;\r
}\r
\r
private void printResultImpl(PrintWriter out, CertainPairComparisonResultSet resultset){\r
for(ComparisonPair pair: resultset){\r
- out.print(pair.getTarget1().getClassName());\r
+ out.print(pair.getTarget1().getName());\r
out.print(",");\r
- out.print(pair.getTarget1().getClassName());\r
+ out.print(pair.getTarget1().getName());\r
out.print(",");\r
out.println(pair.calculateSimilarity());\r
}\r
List<String> names = new ArrayList<String>();\r
\r
for(ComparisonPair pair: resultset){\r
- Map<String, Double> val = map.get(pair.getTarget1().getClassName());\r
+ Map<String, Double> val = map.get(pair.getTarget1().getName());\r
if(val == null){\r
val = new HashMap<String, Double>();\r
}\r
- val.put(pair.getTarget2().getClassName(), new Double(pair.calculateSimilarity()));\r
- if(!names.contains(pair.getTarget2().getClassName())){\r
- names.add(pair.getTarget2().getClassName());\r
+ val.put(pair.getTarget2().getName(), new Double(pair.calculateSimilarity()));\r
+ if(!names.contains(pair.getTarget2().getName())){\r
+ names.add(pair.getTarget2().getName());\r
}\r
- map.put(pair.getTarget1().getClassName(), val);\r
+ map.put(pair.getTarget1().getName(), val);\r
}\r
\r
for(String name: names){\r
\r
protected void printBirthmarkHolder(PrintWriter out, BirthmarkSet holder){\r
for(String type: holder.getBirthmarkTypes()){\r
- out.print(holder.getClassName());\r
+ out.print(holder.getName());\r
out.print(",");\r
out.print(holder.getLocation());\r
\r
\r
private void printTarget(PrintWriter out, BirthmarkSet set, int index){\r
out.printf(" <target%d>%n", index);\r
- out.printf(" <class-name>%s</class-name>%n", list.escapeToXmlString(set.getClassName()));\r
+ out.printf(" <class-name>%s</class-name>%n", list.escapeToXmlString(set.getName()));\r
out.printf(" <location>%s</location>%n", list.escapeToXmlString(set.getLocation()));\r
out.printf(" </target%d>%n", index);\r
\r
\r
protected void printBirthmarkHolder(PrintWriter out, BirthmarkSet set){\r
out.println(" <extracted-birthmark>");\r
- out.printf(" <class-name>%s</class-name>%n", escapeToXmlString(set.getClassName()));\r
+ out.printf(" <class-name>%s</class-name>%n", escapeToXmlString(set.getName()));\r
out.printf(" <location>%s</location>%n", escapeToXmlString(set.getLocation()));\r
for(Iterator<String> i = set.birthmarkTypes(); i.hasNext(); ){\r
String type = i.next();\r
}
public BirthmarkTreeNode(BirthmarkSet birthmark){
- super(birthmark.getClassName() + "(" +
+ super(birthmark.getName() + "(" +
+ birthmark.getSumOfElementCount() + ")");
setBirthmark(birthmark);
}
}\r
\r
public BirthmarkSet obfuscateClassName(BirthmarkSet orig){\r
- String newName = nameMapping.get(orig.getClassName());\r
+ String newName = nameMapping.get(orig.getName());\r
if(newName == null){\r
newName = String.format("C%04d", new Object[] { new Integer(nameMapping.size() + 1), });\r
- nameMapping.put(orig.getClassName(), newName);\r
+ nameMapping.put(orig.getName(), newName);\r
}\r
\r
BirthmarkSet newSet = new BirthmarkSet(newName, orig.getLocation());\r
if(similarity < minimum) minimum = similarity;\r
average += similarity;\r
\r
- model.addRow(new Object[] { pair.getTarget1().getClassName(),\r
- pair.getTarget2().getClassName(), new Double(similarity) });\r
+ model.addRow(new Object[] { pair.getTarget1().getName(),\r
+ pair.getTarget2().getName(), new Double(similarity) });\r
}\r
average = average / list.size();\r
\r
double min = 100d;\r
model.addColumn("");\r
for(BirthmarkSet x: birthmarksX){\r
- model.addColumn(x.getClassName());\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).getClassName();\r
+ rows[0] = birthmarksY.get(j).getName();\r
\r
for(int i = 0; i < birthmarksX.size(); i++){\r
double similarity = compare(context, birthmarksX.get(i), birthmarksY.get(j));\r
*/\r
\r
import java.awt.BorderLayout;\r
-import java.awt.Dimension;\r
-import java.awt.Font;\r
import java.awt.event.ActionEvent;\r
import java.awt.event.ActionListener;\r
-import java.awt.event.WindowAdapter;\r
-import java.awt.event.WindowEvent;\r
import java.io.BufferedReader;\r
import java.io.File;\r
import java.io.FileReader;\r
import java.io.FileWriter;\r
import java.io.IOException;\r
-import java.io.InputStreamReader;\r
import java.io.PrintWriter;\r
import java.io.StringWriter;\r
-import java.net.URL;\r
import java.text.MessageFormat;\r
import java.util.ArrayList;\r
import java.util.HashMap;\r
import jp.naist.se.stigmata.filter.FilteredComparisonResultSet;\r
import jp.naist.se.stigmata.format.FormatManager;\r
import jp.naist.se.stigmata.spi.ResultFormatSpi;\r
+import jp.naist.se.stigmata.ui.swing.actions.AboutAction;\r
+import jp.naist.se.stigmata.ui.swing.actions.LicenseAction;\r
import jp.naist.se.stigmata.ui.swing.graph.SimilarityDistributionGraphPane;\r
import jp.naist.se.stigmata.ui.swing.mds.MDSGraphPanel;\r
\r
new Object[] { new Integer(compareDetail), },\r
new Object[] {\r
Utility.array2String(target1.getBirthmarkTypes()),\r
- target1.getClassName(),\r
- target2.getClassName(),\r
+ target1.getName(),\r
+ target2.getName(),\r
}\r
);\r
tabPane.setSelectedIndex(tabPane.getTabCount() - 1);\r
setJMenuBar(menubar);\r
\r
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);\r
- addWindowListener(new WindowAdapter(){\r
- public void windowClosed(WindowEvent evt){\r
- formWindowClosed(evt);\r
- }\r
- });\r
}\r
\r
private JMenu createFileMenu(){\r
\r
private JMenu createHelpMenu(){\r
JMenu menu = Utility.createJMenu("helpmenu");\r
- JMenuItem about = Utility.createJMenuItem("about");\r
- JMenuItem license = Utility.createJMenuItem("license");\r
+ JMenuItem about = Utility.createJMenuItem("about", new AboutAction(this));\r
+ JMenuItem license = Utility.createJMenuItem("license", new LicenseAction(this));\r
JMenuItem help = Utility.createJMenuItem("helpmenu");\r
JMenu laf = Utility.createJMenu("lookandfeel");\r
expertmodeMenu = Utility.createJCheckBoxMenuItem("expertmenu");\r
menu.add(new JSeparator());\r
menu.add(expertmodeMenu);\r
\r
- about.addActionListener(new ActionListener(){\r
- public void actionPerformed(ActionEvent e){\r
- aboutMenuActionPerformed();\r
- }\r
- });\r
-\r
- license.addActionListener(new ActionListener(){\r
- public void actionPerformed(ActionEvent e){\r
- licenseMenuActionPerformed();\r
- }\r
- });\r
expertmodeMenu.addActionListener(new ActionListener(){\r
public void actionPerformed(ActionEvent e){\r
expertMenuActionPerformed(((JCheckBoxMenuItem)e.getSource()).getState());\r
control.setExpertMode(status);\r
}\r
\r
- private void aboutMenuActionPerformed(){\r
- Package p = getClass().getPackage();\r
- JPanel panel = new JPanel(new BorderLayout());\r
- JLabel logo = new JLabel(Utility.getIcon("stigmata.logo"));\r
- panel.add(logo, BorderLayout.NORTH);\r
-\r
- String aboutMessage = loadString("/resources/about.txt");\r
- aboutMessage = aboutMessage.replace("${implementation.version}", p.getImplementationVersion());\r
- aboutMessage = aboutMessage.replace("${implementation.vendor}", p.getImplementationVendor());\r
- aboutMessage = aboutMessage.replace("${implementation.title}", p.getImplementationTitle());\r
-\r
- JTextArea text = new JTextArea(aboutMessage);\r
- text.setEditable(false);\r
- text.setCaretPosition(0);\r
- JScrollPane scroll = new JScrollPane();\r
- scroll.setViewportView(text);\r
- panel.add(scroll, BorderLayout.CENTER);\r
-\r
- JOptionPane.showMessageDialog(\r
- this, panel, Messages.getString("about.dialog.title"),\r
- JOptionPane.INFORMATION_MESSAGE\r
- );\r
- }\r
-\r
- private void licenseMenuActionPerformed(){\r
- JTextArea area = new JTextArea();\r
- area.setText(loadString("/META-INF/license.txt"));\r
- Font f = area.getFont();\r
- area.setFont(new Font("Monospaced", f.getStyle(), f.getSize()));\r
- area.setEditable(false);\r
- area.setCaretPosition(0);\r
-\r
- JScrollPane scroll = new JScrollPane();\r
- scroll.setViewportView(area);\r
- scroll.setPreferredSize(new Dimension(500, 300));\r
-\r
- JOptionPane.showMessageDialog(\r
- this, scroll, Messages.getString("license.dialog.title"),\r
- JOptionPane.INFORMATION_MESSAGE\r
- );\r
- }\r
-\r
private void showExceptionMessage(Exception e){\r
- if(e instanceof BirthmarkElementClassNotFoundException){\r
- showClassNotFoundMessage((BirthmarkElementClassNotFoundException)e);\r
- return;\r
- }\r
- JTextArea area = new JTextArea(20, 60);\r
+ if(e instanceof BirthmarkElementClassNotFoundException){\r
+ showClassNotFoundMessage((BirthmarkElementClassNotFoundException)e);\r
+ return;\r
+ }\r
+ JTextArea area = new JTextArea(20, 60);\r
StringWriter writer = new StringWriter();\r
PrintWriter out = new PrintWriter(writer);\r
e.printStackTrace(out);\r
if(e instanceof BirthmarkExtractionException){\r
- out.println("Causes:");\r
- for(Throwable t: ((BirthmarkExtractionException)e).getCauses()){\r
- t.printStackTrace(out);\r
- }\r
+ out.println("Causes:");\r
+ for(Throwable t: ((BirthmarkExtractionException)e).getCauses()){\r
+ t.printStackTrace(out);\r
+ }\r
}\r
out.close();\r
area.setText(writer.toString());\r
}\r
\r
private void showClassNotFoundMessage(BirthmarkElementClassNotFoundException e){\r
- StringBuffer sb = new StringBuffer();\r
- sb.append("<html><body><p>");\r
- sb.append(Messages.getString("error.message.classpath"));\r
- sb.append("</p><ul>");\r
- for(String name: e.getClassNames()){\r
- sb.append("<li>").append(name).append("</li>");\r
- }\r
- sb.append("</ul></body></html>");\r
+ StringBuffer sb = new StringBuffer();\r
+ sb.append("<html><body><p>");\r
+ sb.append(Messages.getString("error.message.classpath"));\r
+ sb.append("</p><ul>");\r
+ for(String name: e.getClassNames()){\r
+ sb.append("<li>").append(name).append("</li>");\r
+ }\r
+ sb.append("</ul></body></html>");\r
JOptionPane.showMessageDialog(\r
this, new String(sb), Messages.getString("error.dialog.title"),\r
JOptionPane.WARNING_MESSAGE\r
);\r
}\r
\r
- private String loadString(String loadFrom){\r
- try{\r
- String line;\r
- URL url = getClass().getResource(loadFrom);\r
- BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));\r
- StringWriter writer = new StringWriter();\r
- PrintWriter out = new PrintWriter(writer);\r
- while((line = in.readLine()) != null){\r
- out.println(line);\r
- }\r
- out.close();\r
- in.close();\r
-\r
- return writer.toString();\r
- }catch(IOException e){\r
- e.printStackTrace();\r
- }\r
- return null;\r
- }\r
-\r
- private void formWindowClosed(WindowEvent evt){\r
- frameList.remove(this);\r
- if(frameList.size() == 0){\r
- System.exit(1);\r
- }\r
- }\r
-\r
private void closeTabMenuActionPerformed(){\r
int index = tabPane.getSelectedIndex();\r
if(index == 0){\r
private Utility(){\r
}\r
\r
- public static Action createAction(String key, final ActionListener listener){\r
+ public static Action createAction2(String key, final ActionListener listener){\r
final Icon icon = getIcon(key + ".icon");\r
final String label = Messages.getString(key + ".label");\r
\r
\r
public static JButton createButton(String label, Action action){\r
JButton button = new JButton(action);\r
+ button.setText(Messages.getString(label + ".button.label"));\r
button.setActionCommand(label);\r
if(Messages.hasString(label + ".button.tooltip")){\r
button.setToolTipText(Messages.getString(label + ".button.tooltip"));\r
}\r
+ Icon icon = getIcon(label + ".button.icon");\r
+ if(icon != null){\r
+ button.setIcon(icon);\r
+ }\r
+\r
return button;\r
}\r
\r
\r
public static JMenuItem createJMenuItem(String label, Action action){\r
JMenuItem item = new JMenuItem(action);\r
+ item.setText(Messages.getString(label + ".menuitem.label"));\r
item.setActionCommand(label);\r
if(Messages.hasString(label + ".menuitem.tooltip")){\r
item.setToolTipText(Messages.getString(label + ".menuitem.tooltip"));\r
}\r
+ Icon icon = getIcon(label + ".menuitem.icon");\r
+ if(icon != null){\r
+ item.setIcon(icon);\r
+ }\r
return item;\r
}\r
\r
import java.util.Iterator;\r
\r
import javax.imageio.ImageIO;\r
+import javax.swing.AbstractAction;\r
import javax.swing.Action;\r
import javax.swing.Box;\r
import javax.swing.JCheckBox;\r
matrix[j][i] = matrix[i][j];\r
}\r
}\r
- String className = set[i].getClassName();\r
+ String className = set[i].getName();\r
labels.addLabel(className);\r
String groupName = getGroupName(set[i].getLocation());\r
labels.setGroup(className, groupName);\r
public void actionPerformed(ActionEvent e){\r
String c = e.getActionCommand();\r
for(int i = 0; i < set.length; i++){\r
- if(c.equals(set[i].getClassName())){\r
+ if(c.equals(set[i].getName())){\r
stigmata.showExtractionResult(new BirthmarkSet[] { set[i], }, stigmata.getContext());\r
}\r
}\r
}\r
});\r
- final JCheckBox check = new JCheckBox(Messages.getString("showlabel.button.label"), true);\r
+ JCheckBox check = new JCheckBox(Messages.getString("showlabel.button.label"), true);\r
check.addActionListener(new ActionListener(){\r
public void actionPerformed(ActionEvent e){\r
- viewer.setShowLabel(check.isSelected());\r
+ JCheckBox c = (JCheckBox)e.getSource();\r
+ viewer.setShowLabel(c.isSelected());\r
}\r
});\r
\r
}\r
}\r
);\r
- Action saveMDSAction = Utility.createAction("savemds", new ActionListener(){\r
+ Action saveMDSAction = new AbstractAction(){\r
+ private static final long serialVersionUID = 3314135350231965216L;\r
+\r
public void actionPerformed(ActionEvent e){\r
saveMDSImage();\r
}\r
- });\r
- Action saveCoordinate = Utility.createAction("savelocation", new ActionListener(){\r
+ };\r
+ Action saveCoordinate = new AbstractAction(){\r
+ private static final long serialVersionUID = 1956405328339468706L;\r
+\r
public void actionPerformed(ActionEvent e){\r
saveCoordinate();\r
}\r
- });\r
+ };\r
PopupButton colorButton = new PopupButton(Utility.createButton("updatecolor", pointColorAction));\r
colorButton.addMenuItem(Utility.createJMenuItem("updateovercolor", overColorAction));\r
PopupButton saveButton = new PopupButton(Utility.createButton("savemds", saveMDSAction));\r