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

📄 abstractmainview.java~2~

📁 具有不同语法高亮的编辑器实例
💻 JAVA~2~
📖 第 1 页 / 共 5 页
字号:
   * @see #setMarkAllHighlightColor
   */
  public Color getMarkAllHighlightColor() {
    return markAllHighlightColor;
  }

      /*****************************************************************************/

  /**
   * Gets the color used to highlight modified documents' display names.
   *
   * @return color The color used.
   * @see #setModifiedDocumentDisplayNamesColor
   * @see #highlightModifiedDocumentDisplayNames
   * @see #setHighlightModifiedDocumentDisplayNames
   */
  public Color getModifiedDocumentDisplayNamesColor() {
    return modifiedDocumentDisplayNameColor;
  }

      /*****************************************************************************/

  /**
   * Returns the number of documents open in this container.
   *
   * @return The number of open documents.
   */
  public abstract int getNumDocuments();

      /*****************************************************************************/

  /**
   * Returns all of the files opened in this main view.
   *
   * @return An array of files representing the files being edited in this
   *         main view.  If no documents are open, <code>null</code> is
   *         returned.
   */
  public File[] getOpenFiles() {

    int num = getNumDocuments();
    if (num == 0) {
      return null;
    }
    File[] files = new File[num];

    for (int i = 0; i < num; i++) {
      files[i] = new File(getRTextEditorPaneAt(i).getFileFullPath());
    }

    return files;

  }

      /*****************************************************************************/

  /**
   * Returns the <code>java.awt.Font</code> currently used to print documents.
   *
   * @return The font used to print documents.  If <code>null</code> is
   *         returned, that means the current RText font is being used to
   *         print documents.
   * @see #setPrintFont
   */
  public Font getPrintFont() {
    return printFont;
  }

      /*****************************************************************************/

  /**
   * Returns whether selection edges are rounded in text areas.
   *
   * @return Whether selection edges are rounded.
   * @see #setRoundedSelectionEdges
   */
  public boolean getRoundedSelectionEdges() {
    return roundedSelectionEdges;
  }

      /*****************************************************************************/

  /**
   * Returns the <code>RTextEditorPane</code> at the given index.
   *
   * @param index The tab for which you want to get the
   *              <code>RTextEditorPane</code>.
   * @return The corresponding <code>RTextEditorPane</code>.
   */
  public abstract RTextEditorPane getRTextEditorPaneAt(int index);

      /*****************************************************************************/

  /**
   * Returns the <code>org.fife.rtext.RTextScrollPane</code> at the given
   * index.
   *
   * @param index The tab for which you want to get the
   *              <code>org.fife.rtext.RTextScrollPane</code>.
   * @return The scroll pane.
   */
  public abstract RTextScrollPane getRTextScrollPaneAt(int index);

      /*****************************************************************************/

  /**
   * Returns the currently active component.
   *
   * @return The component.
   */
  public abstract Component getSelectedComponent();

      /*****************************************************************************/

  /**
   * Returns the currently selected document's index.
   *
   * @return The index of the currently selected document.
   */
  public abstract int getSelectedIndex();

      /*****************************************************************************/

  /**
   * Returns the color being used for selections in all text areas in this
   * main view.
   *
   * @return The <code>java.awt.Color</code> being used for all selections in
   *         all text areas.
   */
  public Color getSelectionColor() {
    return selectionColor;
  }

      /*****************************************************************************/

  /**
   * Returns the syntax filters being used to open documents (i.e., to decide
   * what syntax highlighting color scheme, if any, to use when opening
   * documents).
   *
   * @return The filters being used.
   */
  public SyntaxFilters getSyntaxFilters() {
    return syntaxFilters;
  }

      /*****************************************************************************/

  /**
   * Returns the size of a tab, in spaces.
   *
   * @return The tab size (in spaces) currently being used by all documents
   *         in this tabbed pane.
   */
  public int getTabSize() {
    return tabSize;
  }

      /*****************************************************************************/

  /**
   * Returns the text mode we're in.
   *
   * @return <code>RTextEditorPane.INSERT_MODE</code>
   *         or <code>RTextEditorPane.OVERWRITE_MODE</code>.
   * @see #setTextMode
   */
  public int getTextMode() {
    return textMode;
  }

      /*****************************************************************************/

  /**
   * Returns a translucent version of a given <code>java.awt.Image</code>.
   *
   * @param image The <code>java.awt.Image</code> on which to apply the alpha
   *              filter.
   * @param alpha The alpha value to use when defining how translucent you
   *              want the image to be. This should be in the range 0.0f to
   *              1.0f.
   */
  private BufferedImage getTranslucentImage(Image image, float alpha) {

    BufferedImage buffer = null;

    int width = image.getWidth(null);
    int height = image.getHeight(null);
    MediaTracker tracker = new MediaTracker(this);
    buffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE);
    tracker.addImage(buffer, 0);
    Graphics2D g2d = buffer.createGraphics();
    g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
    g2d.drawImage(image, 0, 0, null);
    try {
      tracker.waitForID(0);
    }
    catch (InterruptedException e) {
      JOptionPane.showMessageDialog(this,
          "Exception caught in AbstractMainView.getTranslucentImage:\n" + e,
          owner.getResourceBundle().getString("ErrorDialogTitle"),
          JOptionPane.ERROR_MESSAGE);
    }
    tracker.removeImage(buffer, 0);
    g2d.dispose();

    return buffer;

  }

      /*****************************************************************************/

  /**
   * Returns whether this panel is highlighting modified documents' display
   * names with a different color.
   *
   * @see #setHighlightModifiedDocumentDisplayNames
   * @see #getModifiedDocumentDisplayNamesColor
   * @see #setModifiedDocumentDisplayNamesColor
   */
  public boolean highlightModifiedDocumentDisplayNames() {
    return highlightModifiedDocumentDisplayNames;
  }

      /*****************************************************************************/

  /**
   * Initializes this component.
   *
   * @param owner The <code>RText</code> that this tabbed pane sits in.
   * @param filesToOpen Array of strings representing files to open.  If
   *        this parameter is null, a single file with a default name is
   *        opened.
   * @param prefs A properties object used to initialize some fields on
   *        this main view.
   */
  protected void initialize(RText owner, String[] filesToOpen,
                            RTextPreferences prefs) {

    // Remember the owner of this tabbed pane.
    this.owner = owner;

    // Initialize some stuff from prefs.
    printFont = prefs.printFont;
    tabSize = prefs.tabSize;
    textMode = prefs.textMode;
    emulateTabsWithWhitespace = prefs.emulateTabsWithSpaces;
    setDocumentSelectionPlacement(prefs.tabPlacement);
    lineNumbersEnabled = prefs.lineNumbersVisible;
    setBackgroundImageAlpha(prefs.imageAlpha);
    Object prefsBackgroundObject = prefs.backgroundObject;
    if (prefsBackgroundObject instanceof String) {
      Image image = RTextUtilities.getImageFromFile(
          (String) prefsBackgroundObject);
      if (image != null) {
        setBackgroundObject(image);
        setBackgroundImageFileName( (String) prefsBackgroundObject);
      }
      else { // This is when the file passed in no longer exists.
        setBackgroundObject(Color.WHITE);
        setBackgroundImageFileName(null);
      }
    }
    else { // It must be a color here.
      setBackgroundObject(prefsBackgroundObject);
      setBackgroundImageFileName(null);
    }
    setCaretColor(prefs.caretColor);
    setSelectionColor(prefs.selectionColor);
    setLineWrap(prefs.wordWrap);
    setCurrentLineHighlightEnabled(prefs.currentLineHighlightEnabled);
    setCurrentLineHighlightColor(prefs.currentLineHighlightColor);
    setBracketMatchingEnabled(prefs.bracketMatchingEnabled);
    setMatchedBracketBGColor(prefs.matchedBracketBGColor);
    setMatchedBracketBorderColor(prefs.matchedBracketBorderColor);
    setMarginLineEnabled(prefs.marginLineEnabled);
    setMarginLinePosition(prefs.marginLinePosition);
    setMarginLineColor(prefs.marginLineColor);

    syntaxFilters = new SyntaxFilters(prefs.syntaxFiltersString);

    searchStrings = new Vector(0);
    searchingForward = true; // Default to searching forward.
    searchMatchCase = false; // Default is don't match case.
    searchWholeWord = false; // Default is not whole word.
    searchMarkAll = false; // Default is not to mark all.

    // 1.5.2004/pwy: The default modifier key in Windows and others is
    // Command but for Mac's it is the Apple key. We get the default from
    // the toolkit to make sure it works on all platforms the way the
    // user expects it.
    int defaultModifier = java.awt.Toolkit.getDefaultToolkit().
        getMenuShortcutKeyMask();

    // Initialize this main view's actions.
    createActions(prefs);

    setHighlightModifiedDocumentDisplayNames(prefs.highlightModifiedDocNames);
    setModifiedDocumentDisplayNamesColor(prefs.modifiedDocumentNamesColor);
    setWhitespaceVisible(prefs.visibleWhitespace);
    setSmoothTextEnabled(prefs.smoothTextEnabled);
    setFractionalFontMetricsEnabled(prefs.fractionalMetricsEnabled);
    setMarkAllHighlightColor(prefs.markAllHighlightColor);
    setRoundedSelectionEdges(prefs.roundedSelectionEdges);
    carets = new int[2];
    setCaretStyle(RTextArea.INSERT_CARET, prefs.carets[0]);
    setCaretStyle(RTextArea.OVERWRITE_CARET, prefs.carets[1]);
    setCaretBlinkRate(prefs.caretBlinkRate);

    // Start us out with whatever files they passed in.
    if (filesToOpen == null) {
      addNewEmptyUntitledTextFile();
    }
    else {
      for (int i = 0; i < filesToOpen.length; i++) {
        try {
          // FIXME:  We really should use a UnicodeReader to
          // check the encoding of these files instead of
          // assuming they're the default.
          addOldTextFile(filesToOpen[i],
                         RTextFileChooser.getDefaultEncoding());
        }
        catch (FileNotFoundException e) {}
      }
    }
    setSelectedIndex(0);

    // Update the title of the RText window.
    owner.setMessages(currentTextArea.getFileFullPath(), null);

  }

      /*****************************************************************************/

  /**
   * Returns whether or not bracket matching is enabled.
   *
   * @return <code>true</code> iff bracket matching is enabled.
   * @see #setBracketMatchingEnabled
   */
  public boolean isBracketMatchingEnabled() {
    return bracketMatchingEnabled;
  }

      /*****************************************************************************/

  /**
   * Returns whether or not

⌨️ 快捷键说明

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