コード例 #1
0
ファイル: TokenVisualization.java プロジェクト: cneud/PoCoTo
 public void zoomFont(int newSize) {
   if (!tokenTextLabel.isSpace()) {
     Font f = tokenTextLabel.getFont();
     float nS = (float) newSize;
     Font deriveFont = f.deriveFont(nS);
     tokenTextLabel.setFont(deriveFont);
     tokenTextLabel.revalidate();
     if (this.hasImage) {
       this.calculateSizeNormMode();
       this.revalidate();
     }
   }
 }
コード例 #2
0
ファイル: TokenVisualization.java プロジェクト: cneud/PoCoTo
 public void setFontSize(int fontSize) {
   Font f = tokenTextLabel.getFont();
   float nS = (float) fontSize;
   Font deriveFont = f.deriveFont(nS);
   tokenTextLabel.setFont(deriveFont);
 }
コード例 #3
0
ファイル: TokenVisualization.java プロジェクト: cneud/PoCoTo
  public void startTokenEditing() {

    this.isEditing = true;

    LinkedHashSet<ComboBoxEntry> cands = new LinkedHashSet<>();

    temptoken = MainController.findInstance().getDocument().getTokenByID(tokenID);

    cands.add(new ComboBoxEntry(this.getTokenTextLabelText(), ComboBoxEntryType.NORMAL));

    Iterator<Candidate> iterator =
        MainController.findInstance().getDocument().candidateIterator(tokenID);
    int maxcands = 5;
    while (iterator.hasNext() && maxcands > 1) {
      maxcands--;
      cands.add(new ComboBoxEntry(iterator.next().getSuggestion(), ComboBoxEntryType.NORMAL));
    }

    cands.add(new ComboBoxEntry(setcorrect, ComboBoxEntryType.SETCORRECTED));
    cands.add(new ComboBoxEntry(delete, ComboBoxEntryType.DELETE));
    cands.add(new ComboBoxEntry(merger, ComboBoxEntryType.MERGE));

    if (tvm.getClass().getSimpleName().equals("TokenVisualizationConcordanceMode")) {
      cands.add(new ComboBoxEntry(focusInMain, ComboBoxEntryType.FOCUS_IN_MAIN));
    }

    JButton submitButton = new JButton("↵");
    submitButton.setFocusable(false);
    submitButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent ae) {
            endTokenEditing(box.getEditor().getItem().toString());
          }
        });

    box =
        new MyEditCustomComboBox(
            cands,
            tokenTextLabel.getFont(),
            new Dimension(
                tokenTextLabel.getPreferredSize().width, tokenTextLabel.getPreferredSize().height),
            temptoken.getNumberOfCandidates(),
            submitButton);
    box.setWide(true);
    ((JPanel) box.getEditor().getEditorComponent()).getComponent(0).addKeyListener(keyListener);
    //        box.getEditor().getEditorComponent().addKeyListener(keyListener);

    fl =
        new FocusListener() {

          @Override
          public void focusGained(FocusEvent e) {
            if (e.getComponent()
                .getParent()
                .getParent()
                .getClass()
                .getName()
                .equals("jav.gui.token.edit.MyEditCustomComboBox")) {
              JComboBox b = (JComboBox) e.getComponent().getParent().getParent();
              if (!b.isPopupVisible()) {
                b.showPopup();
                b.setPopupVisible(true);
                b.getEditor().selectAll();
              }
            }
          }

          @Override
          public void focusLost(FocusEvent e) {
            abortTokenEditing();
          }
        };
    ((JPanel) box.getEditor().getEditorComponent()).getComponent(0).addFocusListener(fl);

    //        box.getEditor().getEditorComponent().addFocusListener(fl);

    //        BoundsPopupMenuListener lis = new BoundsPopupMenuListener( false , true ) {
    //            @Override
    //            public void popupMenuCanceled(PopupMenuEvent e) {
    //                abortTokenEditing();
    //            }
    //        };
    //        box.addPopupMenuListener( lis );

    //        box.addPopupMenuListener(new PopupMenuListener() {
    //
    //            @Override
    //            public void popupMenuWillBecomeVisible(PopupMenuEvent pme) {
    //                JComboBox comboBox = (JComboBox) pme.getSource();
    //		if (comboBox.getItemCount() == 0) return;
    //		Object child = comboBox.getAccessibleContext().getAccessibleChild(0);
    //            }
    //
    //            @Override
    //            public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) {
    //            }
    //
    //            @Override
    //            public void popupMenuCanceled(PopupMenuEvent pme) {
    ////                abortTokenEditing();
    //            }
    //        });
    this.remove(tokenTextLabel);
    this.add(box);
    this.calculateSizeEditMode();
    this.repaint();
    this.revalidate();
    ((JTextField) ((JPanel) box.getEditor().getEditorComponent()).getComponent(0)).grabFocus();
  }