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

📄 retrievalframe.java

📁 基于MPEG 7 标准,符合未来语义网架构,很值得参考
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        } else if (e.getActionCommand().equals("closeTab")) {
            if (tabs.getSelectedIndex() > 2) {
                tabs.remove(tabs.getSelectedIndex());
            }
        } else if (e.getActionCommand().equals("about")) {
            AboutDialog adialog = new AboutDialog(this);
            adialog.pack();
            Dimension ss = Toolkit.getDefaultToolkit().getScreenSize();
            adialog.setLocation((ss.width - adialog.getWidth()) / 2, (ss.height - adialog.getHeight()) / 2);
            adialog.setVisible(true);
        } else if (e.getActionCommand().equals("k-tab")) {
            tabs.add("Keywords", searchPanel);
            tabs.setSelectedComponent(searchPanel);
        } else if (e.getActionCommand().equals("s-tab")) {
            tabs.add("Semantics", semanticSearchPanel);
            tabs.setSelectedComponent(semanticSearchPanel);
        } else if (e.getActionCommand().equals("x-tab")) {
            tabs.add("XPath", xpathInputPanel);
            tabs.setSelectedComponent(xpathInputPanel);
        } else if (e.getActionCommand().equals("wizardIndex")) {
            IndexingWizardDialog wizardDialog = new IndexingWizardDialog(this);
        } else if (e.getActionCommand().equals("createIndex")) {
            createIndex();
        } else if (e.getActionCommand().equals("indexPath")) {
            IndexLocationDialog dg = new IndexLocationDialog(this);
            dg.pack();
            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
            dg.setLocation(((int) d.getWidth() - dg.getWidth()) >> 1, ((int) d.getHeight() - dg.getHeight()) >> 1);
            dg.setVisible(true);
        } else if (e.getActionCommand().equals("viCl")) {
            // visualize current repository using ColorLayout:
            JProgressBar pbar = new JProgressBar(JProgressBar.HORIZONTAL);
            pbar.setStringPainted(true);
            VisualDescriptorVisualizationThread vt = new VisualDescriptorVisualizationThread(BASE_DIRECTORY, this, pbar, VisualDescriptor.Type.ColorLayout);
            vt.start();
        } else if (e.getActionCommand().equals("viSc")) {
            // visualize current repository using ScalableColor:
            JProgressBar pbar = new JProgressBar(JProgressBar.HORIZONTAL);
            pbar.setStringPainted(true);
            VisualDescriptorVisualizationThread vt = new VisualDescriptorVisualizationThread(BASE_DIRECTORY, this, pbar, VisualDescriptor.Type.ScalableColor);
            vt.start();
        } else if (e.getActionCommand().equals("viEh")) {
            // visualize current repository using EdgeHistogram:
            JProgressBar pbar = new JProgressBar(JProgressBar.HORIZONTAL);
            pbar.setStringPainted(true);
            VisualDescriptorVisualizationThread vt = new VisualDescriptorVisualizationThread(BASE_DIRECTORY, this, pbar, VisualDescriptor.Type.EdgeHistogram);
            vt.start();
        } else if (e.getActionCommand().equals("viSg")) {
            // visualize current repository using semantic graphs:
            // TODO: make it work
            if (true) {
                JProgressBar pbar = new JProgressBar(JProgressBar.HORIZONTAL);
                pbar.setStringPainted(true);
                GraphDistanceVisualizationThread vt = new GraphDistanceVisualizationThread(BASE_DIRECTORY, this, pbar);
                vt.start();
            } else {
                JOptionPane.showMessageDialog(this, "Visualization not available.\nNot fully implemented with new index structure!");
            }
        } else if (e.getActionCommand().equals("showIndexPath")) {
            JOptionPane.showMessageDialog(this, "Current data repository:\n " + BASE_DIRECTORY);
            setStatus("Current data repository: " + BASE_DIRECTORY);
        } else if (e.getActionCommand().equals("help")) {
            HelpDialog adialog = new HelpDialog(this);
            // adialog.pack();
            Dimension ss = Toolkit.getDefaultToolkit().getScreenSize();
            adialog.setLocation((ss.width - adialog.getWidth()) / 2, (ss.height - adialog.getHeight()) / 2);
            adialog.setVisible(true);

        } else {
            JOptionPane.showMessageDialog(this, "Not implemented yet!");
        }
    }

    public void createIndex() {
        int answer = JOptionPane.showConfirmDialog(this, "Do you really want to create an index?");
        if (answer == JOptionPane.OK_OPTION) {
            Thread indexer = new Thread(new IndexerThread(this, BASE_DIRECTORY));
            indexer.start();
        }
    }

    /**
     * is called before program is exited.
     */
    private void exitApplikation() {
        debug("Exiting applikation");
        props.setProperty(dataRepositoryBaseDirectory, BASE_DIRECTORY);
        props.setProperty(windowSizeX, this.getWidth() + "");
        props.setProperty(windowSizeY, this.getHeight() + "");
        props.setProperty(windowLocationX, this.getLocation().x + "");
        props.setProperty("yloc", this.getLocation().y + "");

        props = EmirConfiguration.getInstance().saveProperties(props);

        try {
            props.store(new FileOutputStream("./" + CONFIGURATION_FILE, false), "Emir configuration file (automatically generated)");
            debug("Saved configuration to " + "./" + CONFIGURATION_FILE);
        } catch (IOException e) {
            debug("Couldn't store " + "./" + CONFIGURATION_FILE);
        }
        System.exit(0);
    }

    private void debug(String message) {
        if (RetrievalFrame.DEBUG) {
            System.out.println("[at.lux.fotoretrieval.RetrievalFrame] " + message);
        }
    }

    public void searchForImage(Element ColorLayoutDescriptor, String directory, boolean descendIntoSubdirs) {
        debug("Starting search for similar image");
        JProgressBar pbar = new JProgressBar(JProgressBar.HORIZONTAL);
        pbar.setStringPainted(true);

        Thread t = new SimilarImageSearchThread(ColorLayoutDescriptor, directory, descendIntoSubdirs, this, pbar);
        t.start();
    }

    public void searchForImage(String xPath, String directory, boolean descendIntoSubdirs) {
        debug("Starting search for keywords ... ");
        JProgressBar pbar = new JProgressBar(JProgressBar.HORIZONTAL);
        pbar.setStringPainted(true);

        Thread t = new SearchThroughXPathThread(xPath, directory, descendIntoSubdirs, this, pbar);
        t.start();
    }

    public void searchForImageInIndex(String xPath, String directory, boolean descendIntoSubdirs) {
        if (IndexReader.indexExists(LuceneRetrievalEngine.parseFulltextIndexDirectory(BASE_DIRECTORY)) &&
                IndexReader.indexExists(LuceneRetrievalEngine.parseSemanticIndexDirectory(BASE_DIRECTORY))) {

            debug("Starting search for keywords ... ");
            JProgressBar pbar = new JProgressBar(JProgressBar.HORIZONTAL);
            pbar.setStringPainted(true);

            Thread t = new SearchThroughLuceneThread(xPath, directory, descendIntoSubdirs, this, pbar);
            t.start();
        } else {
            setStatus("Using index from " + BASE_DIRECTORY);
            JOptionPane.showMessageDialog(this, "Given directory ("+BASE_DIRECTORY+") contains no index, please \ncreate one first (see menu).");
        }

    }

    public void searchForImage(String xPath, Vector objects, String directory, boolean descendIntoSubdirs) {
        debug("Starting search for semantic description ... ");
        JProgressBar pbar = new JProgressBar(JProgressBar.HORIZONTAL);
        pbar.setStringPainted(true);

        Thread t = new SearchSemanticDescriptionThread(xPath, objects, directory, descendIntoSubdirs, this, pbar);
        t.start();
    }

    public void setStatus(String message) {
        status.setText(message);
    }

    public void addResult(ResultsPanel rp) {
        tabs.add("Results", rp);
        tabs.setSelectedIndex(tabs.getTabCount() - 1);
    }

    public void addVisualization(JPanel p) {
        tabs.add("Vis", p);
        tabs.setSelectedIndex(tabs.getTabCount() - 1);
    }

    public QualityConstraintPanel getQualityConstraints() {
        return searchPanel.getQualityConstraints();
    }

    public void searchForSemanticsInIndex(String xPath, String directory, boolean descendIntoSubdirs) {
        if (IndexReader.indexExists(LuceneRetrievalEngine.parseFulltextIndexDirectory(BASE_DIRECTORY)) &&
                IndexReader.indexExists(LuceneRetrievalEngine.parseSemanticIndexDirectory(BASE_DIRECTORY))) {

            debug("Starting search for semantic annotations ... ");
            JProgressBar pbar = new JProgressBar(JProgressBar.HORIZONTAL);
            pbar.setStringPainted(true);

            Thread t = new SearchSemanticInIndexThread(xPath, directory, descendIntoSubdirs, this, pbar);
            t.start();
        } else {
            setStatus("Using index from " + BASE_DIRECTORY);
            JOptionPane.showMessageDialog(this, "Given directory ("+BASE_DIRECTORY+") contains no index, please \ncreate one first (see menu).");
        }

    }
    public void searchForSemanticsInPathIndex(String xPath, String directory, boolean descendIntoSubdirs) {
        if (IndexReader.indexExists(LucenePathIndexRetrievalEngine.parsePathIndexDirectory(BASE_DIRECTORY)) &&
                IndexReader.indexExists(LuceneRetrievalEngine.parseSemanticIndexDirectory(BASE_DIRECTORY))) {

            debug("Starting search for semantic annotations ... ");
            JProgressBar pbar = new JProgressBar(JProgressBar.HORIZONTAL);
            pbar.setStringPainted(true);

            Thread t = new SearchSemanticInPathIndexThread(xPath, directory, descendIntoSubdirs, this, pbar);
            t.start();
        } else {
            setStatus("Using index from " + BASE_DIRECTORY);
            JOptionPane.showMessageDialog(this, "Given directory ("+BASE_DIRECTORY+") contains no index, please \ncreate one first (see menu).");
        }

    }
}


⌨️ 快捷键说明

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