public void mousePressed(MouseEvent e) { if (e.getButton() == e.BUTTON3) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); int index = list.locationToIndex(e.getPoint()); GetImageFile gif = new GetImageFile(files[index]); JTextArea area = new JTextArea( "File: " + gif.getImageString() + "\n" + "Score: " + nf.format(scores[index]) + "\n" + "Pairs: " + nrpairs[index]); area.setEditable(false); area.setBorder(BorderFactory.createLineBorder(Color.black)); area.setFont(new Font("times", Font.PLAIN, 12)); PopupFactory factory = PopupFactory.getSharedInstance(); popup = factory.getPopup( null, area, (int) e.getComponent().getLocationOnScreen().getX() + e.getX() + 25, (int) e.getComponent().getLocationOnScreen().getY() + e.getY()); popup.show(); } }
public SpotCloud( String forig, String ffound, Point2D _s1[], Point2D _s2[], int _pairs[], double _score) { s1 = new Point2D[_s1.length]; s2 = new Point2D[_s2.length]; for (int i = 0; i < _s1.length; i++) s1[i] = new Point2D(_s1[i].x, _s1[i].y); for (int i = 0; i < _s2.length; i++) s2[i] = new Point2D(_s2[i].x, _s2[i].y); pairs = _pairs; score = _score; GetImageFile gif = new GetImageFile(forig); orig = gif.getImageString(); gif = new GetImageFile(ffound); found = gif.getImageString(); scale(); }
public ShowResults(SharkPanel _sp, String _files[], double _scores[], int _nrpairs[]) { sp = _sp; files = _files; scores = _scores; nrpairs = _nrpairs; LogFile lf = new LogFile("SearchResults_"); DefaultListModel listModel = new DefaultListModel(); for (int i = 0; i < files.length; i++) { GetImageFile gif = new GetImageFile(files[i]); Integer ii = new Integer(_nrpairs[i]); int tmpval = (int) (1000.0 * _scores[i]); Double dd = new Double((double) tmpval / 1000.0); String tmp = gif.getImageString(); String s = tmp.substring(tmp.lastIndexOf('\\') + 1, tmp.length()) + "\t" + ii.toString() + "\t" + dd.toString(); String ddval = dd.toString(); while (ddval.length() < 5) ddval += "0"; if (i < 9) listModel.addElement( " " + (i + 1) + ". " + ddval + " " + tmp.substring(tmp.lastIndexOf('\\') + 1, tmp.length())); else listModel.addElement( (i + 1) + ". " + ddval + " " + tmp.substring(tmp.lastIndexOf('\\') + 1, tmp.length())); lf.write(s); } lf.close(); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setDragEnabled(false); list.addMouseListener(new MouseClickListener()); JScrollPane listView = new JScrollPane(list); listView.setPreferredSize(new Dimension(250, 250)); showButton = new JButton("Visual comparison"); showButton.addActionListener(this); showButton.setMnemonic('V'); showButton.setEnabled(false); JButton closeButton = new JButton("Close"); closeButton.addActionListener(this); closeButton.setMnemonic('C'); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.add(listView, BorderLayout.CENTER); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel panel2 = new JPanel(); panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS)); panel2.add(showButton); panel2.add(Box.createRigidArea(new Dimension(10, 1))); panel2.add(closeButton); add(panel); add(Box.createRigidArea(new Dimension(1, 10))); add(panel2); if (frame != null) frame.dispose(); frame = new JFrame("I3S: Search results"); frame.setContentPane(this); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { frame.dispose(); frame = null; } }); frame.setSize(new Dimension(400, 300)); frame.setLocation(200, 200); ImageIcon imageIcon = new ImageIcon(this.getClass().getResource("/Simages/icon.gif")); frame.setIconImage(imageIcon.getImage()); frame.pack(); frame.setVisible(true); }