/*
* LireDemoFrame.java
*
* Created on 20. Februar 2007, 10:37
*/
package liredemo;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.io.File;
import net.semanticmetadata.lire.ImageSearchHits;
import net.semanticmetadata.lire.ImageSearcher;
import net.semanticmetadata.lire.ImageSearcherFactory;
import net.semanticmetadata.lire.utils.ImageUtils;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import edu.uniklu.itec.mosaix.ImageFunctions;
import edu.uniklu.itec.mosaix.engine.Engine;
/*
* This file is part of the Caliph and Emir project: http://www.SemanticMetadata.net.
*
* Caliph & Emir is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Caliph & Emir is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Caliph & Emir; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Copyright statement:
* --------------------
* (c) 2002-2008 by Mathias Lux (mathias@juggle.at)
* http://www.juggle.at, http://www.SemanticMetadata.net
*/
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.SystemFlavorMap;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetListener;
import java.io.FilenameFilter;
import java.net.URL;
import javax.swing.filechooser.FileNameExtensionFilter;
import liredemo.flickr.FlickrIndexingThread;
/**
* This file is part of the Caliph and Emir project: http://www.SemanticMetadata.net
*
* @author Mathias Lux, mathias@juggle.at
*/
public class LireDemoFrame extends javax.swing.JFrame {
private Color highlightHoverColor = Color.decode("#dddddd");
private Color highlightSelectColor = Color.decode("#eeeeee");
private SearchResultsTableModel tableModel = new SearchResultsTableModel();
private IndexReader browseReader = null;
/**
* Creates new form LireDemoFrame
*/
public LireDemoFrame() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
initComponents();
try {
Image icon = ImageIO.read(getClass().getResource("/resources/viewmag16.png"));
if (icon!=null) setIconImage(icon);
} catch (IOException ex) {
Logger.getLogger(LireDemoFrame.class.getName()).log(Level.SEVERE, null, ex);
}
selectboxDocumentBuilder.setSelectedIndex(5);
buttonSwitchIndex.setBackground(highlightSelectColor);
DropTarget t = new DropTarget(searchPanel, new DropTargetListener() {
public void dragEnter(DropTargetDragEvent dtde) {
}
public void dragOver(DropTargetDragEvent dtde) {
}
public void dropActionChanged(DropTargetDragEvent dtde) {
}
public void dragExit(DropTargetEvent dte) {
}
public void drop(DropTargetDropEvent dtde) {
try {
Transferable tr = dtde.getTransferable();
DataFlavor[] flavors = tr.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++) {
System.out.println("Possible flavor: " + flavors[i].getMimeType());
if (flavors[i].isFlavorJavaFileListType()) {
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
java.util.List list = (java.util.List) tr.getTransferData(flavors[i]);
textfieldSearchImage.setText(list.get(0).toString());
dtde.dropComplete(true);
return;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
sameSearchMenu = new javax.swing.JMenu();
searchMpeg7Descriptors = new javax.swing.JMenuItem();
searchColorLayout = new javax.swing.JMenuItem();
searchEdgeHistogram = new javax.swing.JMenuItem();
searchScalableColor = new javax.swing.JMenuItem();
searchAutoColorCorrelation = new javax.swing.JMenuItem();
mosaicButtons = new javax.swing.ButtonGroup();
topPane = new javax.swing.JPanel();
controlPane = new javax.swing.JPanel();
switchButtonsPanel = new javax.swing.JPanel();
jPanel5 = new javax.swing.JPanel();
buttonSwitchIndex = new javax.swing.JButton();
buttonSwitchSearch = new javax.swing.JButton();
buttonSwitchBrowse = new javax.swing.JButton();
buttonSwitchMosaic = new javax.swing.JButton();
buttonSwitchOptions = new javax.swing.JButton();
buttonSwitchAbout = new javax.swing.JButton();
cardPanel = new javax.swing.JPanel();
indexPanel = new javax.swing.JPanel();
textfieldIndexDir = new javax.swing.JTextField();
buttonOpenDir = new javax.swing.JButton();
buttonStartIndexing = new javax.swing.JButton();
progressBarIndexing = new javax.swing.JProgressBar();
jLabel6 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
checkBoxAddToExisintgIndex = new javax.swing.JCheckBox();
searchPanel = new javax.swing.JPanel();
textfieldSearchImage = new javax.swing.JTextField();
buttonOpenImage = new javax.swing.JButton();
buttonStartSearch = new javax.swing.JButton();
progressSearch = new javax.swing.JProgressBar();
jLabel5 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
browsePanel = new javax.swing.JPanel();
jLabel10 = new javax.swing.JLabel();
labelDocCount = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
spinnerCurrentDocNum = new javax.swing.JSpinner();
spinnerMaxDocCount = new javax.swing.JSpinner();
imageLabel = new javax.swing.JLabel();
buttonSearchFromBrowse = new javax.swing.JButton();
mosaicPanel = new javax.swing.JPanel();
textfieldMosaicImage = new javax.swing.JTextField();
buttonOpenMosaicImage = new javax.swing.JButton();
buttonStartMosaicing = new javax.swing.JButton();
progressMosaic = new javax.swing.JProgressBar();
labelMosaicTitle = new javax.swing.JLabel();
mosaicTileCountSlider = new javax.swing.JSlider();
jLabel12 = new javax.swing.JLabel();
mosaicImageLable = new javax.swing.JLabel();
buttonMosaicSave = new javax.swing.JButton();
jLabel13 = new javax.swing.JLabel();
mosaicAdvanceOptionsPanel = new javax.swing.JPanel();
pan