예제 #1
0
 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
 public boolean isNewline() {
   return tokenTextLabel.getText().equals("¶");
 }
예제 #3
0
 public void setFontSize(int fontSize) {
   Font f = tokenTextLabel.getFont();
   float nS = (float) fontSize;
   Font deriveFont = f.deriveFont(nS);
   tokenTextLabel.setFont(deriveFont);
 }
예제 #4
0
  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();
  }
예제 #5
0
 public void update(String newtext, boolean corrected) {
   tokenTextLabel.setText(newtext);
   this.setCorrected(corrected);
   this.calculateSizeNormMode();
   this.revalidate();
 }
예제 #6
0
 public void update(String newtext) {
   tokenTextLabel.setText(newtext);
   tvm.setTokenVisualizationStyle(instance);
   this.calculateSizeNormMode();
   this.revalidate();
 }
예제 #7
0
 public String getTokenTextLabelText() {
   return tokenTextLabel.getText();
 }
예제 #8
0
 public boolean isSpace() {
   return tokenTextLabel.getText().equals(" ");
 }