private void initGUI() {
   try {
     setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
     setTitle("Die BSC der HTL Spengergasse");
     {
       jMenuBar1 = new JMenuBar();
       setJMenuBar(jMenuBar1);
       {
         jMenu1 = new JMenu();
         jMenuBar1.add(jMenu1);
         jMenu1.setText("Eigene Einstellungen");
         jMenu1.setPreferredSize(new java.awt.Dimension(131, 21));
         {
           mi_PasswortÄndern = new JMenuItem();
           jMenu1.add(mi_PasswortÄndern);
           mi_PasswortÄndern.setText("Passwort ändern");
         }
       }
     }
     pack();
     this.setSize(620, 400);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Esempio n. 2
0
  /** @param args the command line arguments */
  public static void main(String[] args) {
    JFrame frame = new JFrame("Editing and Mouse Menu Demo");
    SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge> g =
        new SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge>();
    // Layout<V, E>, VisualizationViewer<V,E>
    //        Map<GraphElements.MyVertex,Point2D> vertexLocations = new
    // HashMap<GraphElements.MyVertex, Point2D>();
    Layout<GraphElements.MyVertex, GraphElements.MyEdge> layout = new StaticLayout(g);
    layout.setSize(new Dimension(300, 300));
    VisualizationViewer<GraphElements.MyVertex, GraphElements.MyEdge> vv =
        new VisualizationViewer<GraphElements.MyVertex, GraphElements.MyEdge>(layout);
    vv.setPreferredSize(new Dimension(350, 350));
    // Show vertex and edge labels
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
    // Create a graph mouse and add it to the visualization viewer
    EditingModalGraphMouse gm =
        new EditingModalGraphMouse(
            vv.getRenderContext(),
            GraphElements.MyVertexFactory.getInstance(),
            GraphElements.MyEdgeFactory.getInstance());
    // Set some defaults for the Edges...
    GraphElements.MyEdgeFactory.setDefaultCapacity(192.0);
    GraphElements.MyEdgeFactory.setDefaultWeight(5.0);
    // Trying out our new popup menu mouse plugin...
    PopupVertexEdgeMenuMousePlugin myPlugin = new PopupVertexEdgeMenuMousePlugin();
    // Add some popup menus for the edges and vertices to our mouse plugin.
    JPopupMenu edgeMenu = new MyMouseMenus.EdgeMenu(frame);
    JPopupMenu vertexMenu = new MyMouseMenus.VertexMenu();
    myPlugin.setEdgePopup(edgeMenu);
    myPlugin.setVertexPopup(vertexMenu);
    gm.remove(gm.getPopupEditingPlugin()); // Removes the existing popup editing plugin

    gm.add(myPlugin); // Add our new plugin to the mouse

    vv.setGraphMouse(gm);

    // JFrame frame = new JFrame("Editing and Mouse Menu Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(vv);

    // Let's add a menu for changing mouse modes
    JMenuBar menuBar = new JMenuBar();
    JMenu modeMenu = gm.getModeMenu();
    modeMenu.setText("Mouse Mode");
    modeMenu.setIcon(null); // I'm using this in a main menu
    modeMenu.setPreferredSize(new Dimension(80, 20)); // Change the size so I can see the text

    menuBar.add(modeMenu);
    frame.setJMenuBar(menuBar);
    gm.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode
    frame.pack();
    frame.setVisible(true);
  }
  private void setMouseSettings() {
    // mouse interaction
    EditingModalGraphMouse<VertexNode, EdgeLink> gm =
        new EditingModalGraphMouse<VertexNode, EdgeLink>(getRenderContext(), vFactory, eFactory);

    // Trying out our new popup menu mouse plugin...
    PopupMousePlugin<VertexNode, EdgeLink> myPlugin = new PopupMousePlugin<VertexNode, EdgeLink>();

    gm.remove(gm.getPopupEditingPlugin()); // Removes the existing popup editing plugin
    gm.add(myPlugin); // Add our new plugin to the mouse

    // need an editing mouse that will notify when an edge is potentially created
    EditingNotifyingMousePlugin<VertexNode, EdgeLink> myEditor =
        new EditingNotifyingMousePlugin<VertexNode, EdgeLink>();

    gm.add(myEditor);

    setGraphMouse(gm);

    // menu bar
    JMenuBar bar = new JMenuBar();
    JMenu modeMenu = gm.getModeMenu();
    modeMenu.setText("Mouse Mode");
    modeMenu.setIcon(null); // I'm using this in a main menu
    modeMenu.setPreferredSize(new Dimension(200, 20)); // Change the size so I can see the text
    gm.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode

    JMenuItem refresh = new JMenuItem("Refresh Screen");
    refresh.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            stateChanged(null);
          }
        });

    bar.add(modeMenu);
    bar.add(refresh);
    add(bar);
  }
  public Dockabletest() {
    JTutorialFrame frame = new JTutorialFrame(Dockabletest.class);
    CControl control = new CControl(frame);
    frame.destroyOnClose(control);
    frame.add(control.getContentArea());
    frame.setBounds(260, 80, 900, 700);

    /*
     * We need to install our EditorFactory early on, otherwise the
     * framework will not allow us to register the EditorDockables.
     */
    control.addMultipleDockableFactory("file-editor", factory);

    /* We now create some dockables and drop them onto the content-area */
    CGrid grid = new CGrid(control);
    grid.add(0, 0, 1, 0.6, editorDockable1);
    grid.add(0, 0.6, 1, 0.4, editorDockable4);
    grid.add(1, 0, 1, 0.2, editorDockable2);
    grid.add(1, 0.2, 1, 0.3, editorDockable5);
    grid.add(1, 0.6, 1, 0.5, editorDockable3);
    control.getContentArea().deploy(grid);

    /*
     * The CLayoutChoiceMenuPiece creates a dynamic menu which allows us to
     * save and load the layout. In doing so we will use the EditorFactory.
     */
    // 给菜单栏添加菜单
    menuFile1.setFont(font);
    menuFile1.setPreferredSize(new Dimension(50, 25));
    menuFile2.setFont(font);
    menuFile2.setPreferredSize(new Dimension(80, 25));
    menuFile3.setFont(font);
    menuFile3.setPreferredSize(new Dimension(80, 25));
    menuFile4.setFont(font);
    menuFile4.setPreferredSize(new Dimension(100, 25));
    menuFile5.setFont(font);
    menuFile5.setPreferredSize(new Dimension(60, 25));
    menuFile6.setFont(font);
    menuFile6.setPreferredSize(new Dimension(50, 25));
    menubar.add(menuFile1);
    menubar.add(menuFile2);
    menubar.add(menuFile3);
    menubar.add(menuFile4);
    menubar.add(menuFile6);
    menubar.add(menuFile5);

    // 给菜单1添加子菜单
    newFile.setFont(font);
    menuFile1.add(newFile);
    newFile.addActionListener(this);
    menuFile1.add(openFile);
    openFile.addActionListener(this);
    openFile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
    menuFile1.addSeparator();
    menuFile1.add(saveFile);
    saveFile.addActionListener(this);
    menuFile1.add(readFile);
    readFile.addActionListener(this);
    menuFile1.add(deleteFile);
    deleteFile.addActionListener(this);
    // 给菜单2添加子菜单
    menuFile2.add(tagging);
    tagging.addActionListener(this);
    tagging.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_MASK));
    menuFile2.add(keyword);
    keyword.addActionListener(this);
    keyword.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.CTRL_MASK));
    menuFile2.add(keysentence);
    keysentence.addActionListener(this);
    keysentence.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));
    menuFile2.add(summary);
    summary.addActionListener(this);
    summary.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
    menuFile2.addSeparator();
    menuFile2.add(all);
    all.addActionListener(this);
    // 给菜单3添加子菜单
    menuFile3.add(noun);
    noun.addActionListener(this);
    noun.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile3.add(adjective);
    adjective.addActionListener(this);
    adjective.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile3.add(adverb);
    adverb.addActionListener(this);
    adverb.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile3.add(verb);
    verb.addActionListener(this);
    verb.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile3.add(ncs);
    ncs.addActionListener(this);
    // 给菜单4添加子菜单
    menuFile4.add(mKeyword);
    mKeyword.addActionListener(this);
    mKeyword.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile4.add(mSentence);
    mSentence.addActionListener(this);
    mSentence.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile4.add(mSummary);
    mSummary.addActionListener(this);
    mSummary.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    // 给菜单5添加子菜单
    menuFile5.add(wtCollection);
    wtCollection.addActionListener(this);
    menuFile5.add(addCharacteristic);
    addCharacteristic.addActionListener(this);
    menuFile5.add(clearData);
    clearData.addActionListener(this);
    menuFile5.addSeparator();
    menuFile5.add(showAll);
    showAll.addActionListener(this);
    menuFile5.addSeparator();
    menuFile5.add(test);
    test.addActionListener(this);
    menuFile5.add(setWordCol);
    setWordCol.addActionListener(this);
    menuFile5.addSeparator();
    menuFile5.add(setCorpusType);
    setCorpusType.addActionListener(this);
    // 给菜单6添加子菜单
    menuFile6.add(revokeKeyword);
    revokeKeyword.addActionListener(this);
    menuFile6.add(revokeSentence);
    revokeSentence.addActionListener(this);
    menuFile6.add(revokeSummary);
    revokeSummary.addActionListener(this);
    menuFile6.add(revokeTagging);
    revokeTagging.addActionListener(this);
    // 设置fileContent文本字体
    editorDockable1.text.setFont(font1);
    editorDockable2.text.setFont(font1);
    editorDockable3.text.setFont(font1);
    editorDockable4.text.setFont(font1);
    editorDockable5.text.setFont(font1);
    frame.setJMenuBar(menubar);

    UIManager.put("OptionPane.messageFont", font);
    UIManager.put("OptionPane.buttonFont", font);

    editorDockable2.text.setEditable(false);
    editorDockable3.text.setEditable(false);
    editorDockable4.text.setEditable(false);
    /* and finally we can start the application */
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
  @SuppressWarnings({"unchecked", "rawtypes"})
  public static void main(String[] args) {

    final EditingGraphViewer sgv = new EditingGraphViewer();

    // Layout<V, E>, VisualizationViewer<V,E>
    final Layout<Integer, String> layout = new StaticLayout<Integer, String>(g);
    layout.setSize(new Dimension(300, 300));
    final VisualizationViewer<Integer, String> vv =
        new VisualizationViewer<Integer, String>(layout);
    vv.setBackground(Color.white);
    vv.setPreferredSize(new Dimension(350, 350));

    Transformer<Integer, Paint> vertexPaint =
        new Transformer<Integer, Paint>() {
          public Paint transform(Integer i) {
            return (Paint) Color.WHITE;
          }
        };
    vv.getRenderContext()
        .setVertexFillPaintTransformer((Transformer<Integer, java.awt.Paint>) vertexPaint);

    // Show vertex and edge labels
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Integer>());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<String>());

    // Create a graph mouse and add it to the visualization viewer
    // Our Vertices are going to be Integer objects so we need an Integer factory
    EditingModalGraphMouse gm =
        new EditingModalGraphMouse(vv.getRenderContext(), sgv.vertexFactory, sgv.edgeFactory);
    vv.setGraphMouse(gm);

    JFrame frame = new JFrame("Editing Graph");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(vv);

    // ===========================================================================
    // Menu for changing mouse modes

    JMenuBar menuBar = new JMenuBar();
    JMenu modeMenu = gm.getModeMenu();
    modeMenu.setText("Mode");
    modeMenu.setIcon(null);
    modeMenu.setPreferredSize(new Dimension(80, 20));
    menuBar.add(modeMenu);

    // ---------------------------------------------------------------------------
    // Menu Item to compute Centrality Measures

    JMenu centrality = new JMenu("Centrality");
    JMenuItem execB = new JMenuItem("Betweenness C.");
    execB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Betweenness.compute(g);
          }
        });
    centrality.add(execB);

    JMenuItem execC = new JMenuItem("Closeness C");
    execC.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Closeness.compute(g);
          }
        });
    centrality.add(execC);

    menuBar.add(centrality);

    // ---------------------------------------------------------------------------
    // Menu Item to change Vertices Color
    colorArray.add(2);

    JMenu selColor = new JMenu("NodeColor");

    JMenuItem selBlack = new JMenuItem("black");
    selBlack.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {

            colorArray.add(1);
            int v = g.getVertexCount();
            for (int j = 0; j < nodeArray.size(); j++) v = v - nodeArray.get(j);
            int vC = g.getVertexCount();
            nodeArray.add(v);
            SelectColor.choiceColor(1, vv, nodeArray, colorArray, vC);
          }
        });
    selColor.add(selBlack);

    JMenuItem selGray = new JMenuItem("gray");
    selGray.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {

            colorArray.add(0);
            int v = g.getVertexCount();
            for (int j = 0; j < nodeArray.size(); j++) v = v - nodeArray.get(j);
            nodeArray.add(v);
            int vC = g.getVertexCount();
            SelectColor.choiceColor(0, vv, nodeArray, colorArray, vC);
          }
        });
    selColor.add(selGray);

    JMenuItem selWhite = new JMenuItem("white");
    selWhite.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {

            colorArray.add(2);
            int v = g.getVertexCount();
            for (int j = 0; j < nodeArray.size(); j++) v = v - nodeArray.get(j);
            nodeArray.add(v);
            int vC = g.getVertexCount();
            SelectColor.choiceColor(2, vv, nodeArray, colorArray, vC);
          }
        });
    selColor.add(selWhite);

    JMenuItem selYellow = new JMenuItem("yellow");
    selYellow.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {

            colorArray.add(3);
            int v = g.getVertexCount();
            for (int j = 0; j < nodeArray.size(); j++) v = v - nodeArray.get(j);
            nodeArray.add(v);
            int vC = g.getVertexCount();
            SelectColor.choiceColor(3, vv, nodeArray, colorArray, vC);
          }
        });
    selColor.add(selYellow);

    menuBar.add(selColor);

    // ------------------------------------------------------------------------------------
    // MenuItem to save the graph as jpeg ,or eps, or to save code generation graph

    JMenu saveImg = new JMenu("Save");

    JMenuItem saveJPG = new JMenuItem("Save as jpeg");
    saveJPG.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            Save.saveJpeg(vv);
          }
        });

    saveImg.add(saveJPG);

    JMenuItem saveEPS = new JMenuItem("Save as eps");
    saveEPS.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            Save.saveEps(vv);
          }
        });

    saveImg.add(saveEPS);

    JMenuItem saveCode = new JMenuItem("Save Graph Code");
    saveCode.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            Save.saveCode(g, colorArray, nodeArray);
          }
        });

    saveImg.add(saveCode);

    menuBar.add(saveImg);

    // -------------------------------------------------------------------------------------

    frame.setJMenuBar(menuBar);
    gm.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode

    frame.pack();
    frame.setVisible(true);
  }