⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 retrievalframe.java

📁 基于MPEG 7 标准,符合未来语义网架构,很值得参考
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * This file is part of Caliph & Emir.
 *
 * 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-2005 by Mathias Lux (mathias@juggle.at)
 * http://www.juggle.at, http://caliph-emir.sourceforge.net
 */
package at.lux.fotoretrieval;

import at.lux.components.StatusBar;
import at.lux.fotoannotation.AnnotationToolkit;
import at.lux.fotoretrieval.dialogs.AboutDialog;
import at.lux.fotoretrieval.dialogs.HelpDialog;
import at.lux.fotoretrieval.dialogs.IndexLocationDialog;
import at.lux.fotoretrieval.dialogs.IndexingWizardDialog;
import at.lux.fotoretrieval.lucene.IndexerThread;
import at.lux.fotoretrieval.panels.*;
import at.lux.fotoretrieval.retrievalengines.LucenePathIndexRetrievalEngine;
import at.lux.fotoretrieval.retrievalengines.LuceneRetrievalEngine;
import at.lux.imageanalysis.VisualDescriptor;
import at.lux.splash.SplashScreen;
import org.apache.lucene.index.IndexReader;
import org.jdom.Element;

import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.Vector;

/**
 * Main class for retrieval ...
 */
public class RetrievalFrame extends JFrame implements ActionListener, RetrievalOperations, StatusBar {
    public static final boolean DEBUG = false;
    public static final String CONFIGURATION_FILE = "emir.properties";
    public static String BASE_DIRECTORY = ".";
    private JPanel statusPanel;
    private JProgressBar garbageBar;
    private JLabel status;
    private JTabbedPane tabs;
    private ContentBasedImageRetrievalPanel cbPanel;
    private GarbageTracker gTracker;
    private TextInputSearchPanel searchPanel;
    private XPathSearchPanel xpathInputPanel;
    private LuceneSearchPanel luceneInputPanel;
    private Properties props;
    private SemanticSearchPanel semanticSearchPanel;
    private GraphSearchPanel graphSearchPanel;

    private final String windowSizeX = "window.size.x";
    private final String windowSizeY = "window.size.y";
    private final String windowLocationX = "window.location.x";
    private final String windowLocationY = "window.location.y";
    private final String dataRepositoryBaseDirectory = "data.base.directory";

    public RetrievalFrame() {
        super();
        try {
            this.setIconImage(ImageIO.read(RetrievalFrame.class.getResource("data/find.gif")));
        } catch (Exception e) {
            debug("Couldn't set Icon: " + e.toString() + " " + e.getMessage());
        }
        init();
    }

    private void init() {
        setTitle(RetrievalToolkit.PROGRAM_NAME + " " + AnnotationToolkit.PROGRAM_VERSION);

        // ----------------------------
        // Setting Emir props
        // ----------------------------
        props = new Properties();
        File conf = new File("./" + CONFIGURATION_FILE);
        debug("./" + CONFIGURATION_FILE);
        if (conf.exists()) {
            try {
                props.load(new FileInputStream(conf));
            } catch (IOException e) {
                System.err.println("Error loading config file: " + e.toString());
            }
            BASE_DIRECTORY = props.getProperty(dataRepositoryBaseDirectory, ".");
        } else {
            props.setProperty(dataRepositoryBaseDirectory, BASE_DIRECTORY);
        }
        // creating a base configuration from saved properties
        EmirConfiguration.getInstance(props);
        // ----------------------------
        // Setting Frame props
        // ----------------------------
        int xwidth = Integer.parseInt(props.getProperty(windowSizeX, "640"));
        int ywidth = Integer.parseInt(props.getProperty(windowSizeY, "480"));
        setSize(xwidth, ywidth);
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        int xloc = Integer.parseInt(props.getProperty(windowLocationX, "" + ((d.width - this.getWidth()) / 2)));
        int yloc = Integer.parseInt(props.getProperty(windowLocationY, "" + ((d.height - this.getHeight()) / 2)));
        setLocation(xloc, yloc);
        this.setJMenuBar(RetrievalToolkit.createRetrievalMenuBar(this));

        // ----------------------------
        // Setting Frame Listeners ...
        // ----------------------------
        this.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                exitApplikation();
            }
        });


        // ----------------------------
        // Creating Components
        // ----------------------------
        cbPanel = new ContentBasedImageRetrievalPanel(this);
        searchPanel = new TextInputSearchPanel(this);
        xpathInputPanel = new XPathSearchPanel(this);
        luceneInputPanel = new LuceneSearchPanel(this);
        semanticSearchPanel = new SemanticSearchPanel(this);
        graphSearchPanel = new GraphSearchPanel(this);

        statusPanel = new JPanel(new BorderLayout());
        status = new JLabel(RetrievalToolkit.PROGRAM_NAME + " " + AnnotationToolkit.PROGRAM_VERSION);
        status.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
        garbageBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 16);
        garbageBar.setStringPainted(true);
        garbageBar.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        garbageBar.setToolTipText("This bar shows how much memory is allocated by the VM and how much of it isalready in use.");
//        garbageBar.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
        gTracker = new GarbageTracker(garbageBar);
        statusPanel.add(status, BorderLayout.CENTER);
        statusPanel.add(garbageBar, BorderLayout.EAST);

        tabs = new JTabbedPane(JTabbedPane.NORTH);
        tabs.add("Index", luceneInputPanel);
        tabs.add("Graph", graphSearchPanel);
        tabs.add("Image", cbPanel);
//        tabs.add("Keywords", searchPanel);
//        tabs.add("XPath", xpathInputPanel);
//        tabs.add("Semantics", semanticSearchPanel);

        this.getContentPane().add(tabs, BorderLayout.CENTER);
        this.getContentPane().add(statusPanel, BorderLayout.SOUTH);

        gTracker.start();
    }

    public static void main(String[] args) {
        RetrievalFrame rf = new RetrievalFrame();
        boolean showSplash = true;

        // get config file from splashscreen class
        File splashProps = new File(SplashScreen.LICENSE_ACCEPTED_FILENAME);
        // look if exists
        if (splashProps.exists()) {
            // load props
            try {
                Properties licenseAcceptedProps = new Properties();
                licenseAcceptedProps.load(new FileInputStream(splashProps));
                // if property is set we do not have to show the splashscreen:
                String tmp = licenseAcceptedProps.getProperty("license.accepted");
                if (tmp != null && tmp.equals("true")) {
                    showSplash = false;
                }
            } catch (IOException e) {
                System.err.println("Warn: Could not read license properties file.");
            }
        }

        if (showSplash) {
            // now show the splash screen if this has not been done before.
            SplashScreen splash = new SplashScreen(rf);
            splash.setVisible(true);
        }

        rf.setVisible(true);
    }

    /**
     * Overides method defined in Interface ActionListener
     */
    public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand().equals("exit")) {
            exitApplikation();
        } else if (e.getActionCommand().equals("index")) {
            createIndex();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -