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

📄 retrievaltoolkit.java

📁 基于MPEG 7 标准,符合未来语义网架构,很值得参考
💻 JAVA
字号:
/*
 * 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 org.jaxen.XPath;
import org.jaxen.jdom.JDOMXPath;
import org.jdom.Namespace;

import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;

public class RetrievalToolkit {
    public static String PROGRAM_NAME = "Emir";
    public static String PROGRAM_VERSION = "v 0.9b";

    public static List xpathQuery(org.jdom.Element document, String xpathQuery1, Namespace xNs) {
        List returnValue = new Vector();
        String xpathQuery = xpathQuery1;
        XPath xPath;
        try {
            Namespace ns = document.getNamespace();
            if (ns.getPrefix().length() == 0) {
                StringTokenizer tokens = new StringTokenizer(xpathQuery, "/", true);
                xpathQuery = "";
                while (tokens.hasMoreTokens()) {
                    String token = tokens.nextToken();
                    if (!token.equalsIgnoreCase("/")) {
                        token = "x:" + token;
                    }
                    xpathQuery += token;
                }
                xPath = new JDOMXPath(xpathQuery);
                xPath.addNamespace("x", ns.getURI());
            } else {
                xPath = new JDOMXPath(xpathQuery);
            }
            if (xNs != null) {
                xPath.addNamespace(xNs.getPrefix(), xNs.getURI());
            }
            Object jdomNode = document;
            returnValue = xPath.selectNodes(jdomNode);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return returnValue;
    }

    public static JMenuBar createRetrievalMenuBar(ActionListener al) {
        JMenu file, help, view, index, vis;
        file = new JMenu("File");
        help = new JMenu("Help");
        view = new JMenu("View");
        index = new JMenu("Index");
        vis = new JMenu("Repository visualization");
        file.setMnemonic(KeyEvent.VK_F);
        help.setMnemonic(KeyEvent.VK_H);
        view.setMnemonic(KeyEvent.VK_V);
        index.setMnemonic(KeyEvent.VK_I);
        vis.setMnemonic(KeyEvent.VK_V);

//        file.add(createMenuItem("Create index", "index", "alt F12", al, KeyEvent.VK_I));
//        file.addSeparator();
        file.add(createMenuItem("Exit", "exit", "alt F4", al, KeyEvent.VK_E));
        view.add(createMenuItem("Close active Tab", "closeTab", "alt X", al, KeyEvent.VK_C));
        view.addSeparator();
        view.add(createMenuItem("Keyword Tab", "k-tab", "alt F5", al, KeyEvent.VK_K));
        view.add(createMenuItem("Semantics Tab", "s-tab", "alt F6", al, KeyEvent.VK_S));
        view.add(createMenuItem("XPath Tab", "x-tab", "alt F7", al, KeyEvent.VK_X));

        vis.add(createMenuItem("ColorLayout", "viCl", "ctrl 1", al, KeyEvent.VK_C));
        vis.add(createMenuItem("ScalableColor", "viSc", "ctrl 2", al, KeyEvent.VK_S));
        vis.add(createMenuItem("EdgeHistogram", "viEh", "ctrl 3", al, KeyEvent.VK_E));
        vis.addSeparator();
        vis.add(createMenuItem("Semantic graphs", "viSg", "ctrl 4", al, KeyEvent.VK_G));

        index.add(createMenuItem("Indexing wizard", "wizardIndex", "ctrl W", al, KeyEvent.VK_W));
        index.addSeparator();
        index.add(createMenuItem("Create/Update index", "createIndex", "ctrl I", al, KeyEvent.VK_C));
        index.add(createMenuItem("Change data repository location", "indexPath", "ctrl O", al, KeyEvent.VK_D));
        index.add(createMenuItem("Show current data repository location", "showIndexPath", "ctrl V", al, KeyEvent.VK_S));

        help.add(createMenuItem("Help", "help", "F1", al, KeyEvent.VK_H));
        help.add(createMenuItem("About", "about", "alt A", al, KeyEvent.VK_A));

        JMenuBar bar = new JMenuBar();
        bar.add(file);
        bar.add(view);
        bar.add(vis);
        bar.add(index);
        bar.add(help);

        return bar;
    }

    public static JMenuItem createMenuItem(String label, String command, String Mnemonic, ActionListener al, int mnem) {
        JMenuItem i = new JMenuItem(label);
        if (Mnemonic != null) {
            i.setAccelerator(KeyStroke.getKeyStroke(Mnemonic));
        }
        i.setMnemonic(mnem);
        i.setActionCommand(command);
        i.addActionListener(al);
        return i;
    }

}

⌨️ 快捷键说明

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