processing.app

## Class Base

- Object
- - Base

-     public class Base
      extends Object

  The base class for the main processing application. Primary role of this class is for platform identification and general interaction with the system (launching URLs, loading files and images, etc) that comes from that.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `DEBUG` True if heavy debugging error/log messages are enabled
    `static JMenu` | `defaultFileMenu` A lone file menu to be used when all sketch windows are closed.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Base(String[] args)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addSketches(DefaultMutableTreeNode node, File folder, boolean examples)`
    `void` | `changeMode(Mode mode)` The call has already checked to make sure this sketch is not modified, now change the mode.
    `void` | `checkFirstEditor(Editor editor)` Tools require an 'Editor' object when they're instantiated, but the activeEditor will be null when the first Editor that opens is creating its Tools menu.
    `void` | `clearToolMenus()`
    `Editor` | `getActiveEditor()` Returns the front most, active editor window.
    `List<ToolContribution>` | `getCoreTools()`
    `Mode` | `getDefaultMode()`
    `List<Editor>` | `getEditors()` Get the list of currently active editor windows.
    `List<ExamplesContribution>` | `getExampleContribs()`
    `byte[]` | `getInstalledContribsInfo()`
    `static File` | `getLibFile(String filename)` Return a File from inside the Processing 'lib' folder.
    `static InputStream` | `getLibStream(String filename)` Return an InputStream for a file inside the Processing lib folder.
    `List<ModeContribution>` | `getModeContribs()`
    `List<Mode>` | `getModeList()`
    `Mode` | `getNextMode()` Used by ThinkDifferent so that it can have a Sketchbook menu.
    `static int` | `getRevision()`
    `static File` | `getSettingsFile(String filename)` Convenience method to get a File object for the specified filename inside the settings folder.
    `static File` | `getSettingsFolder()` Get the directory that can store settings.
    `static File` | `getSketchbookExamplesFolder()`
    `static File` | `getSketchbookFolder()`
    `static File` | `getSketchbookLibrariesFolder()`
    `static File` | `getSketchbookModesFolder()`
    `static File` | `getSketchbookToolsFolder()`
    `List<ToolContribution>` | `getToolContribs()`
    `static File` | `getToolsFolder()`
    `static String` | `getVersionName()`
    `void` | `handleActivated(Editor whichEditor)` Called when a window is activated.
    `boolean` | `handleClose(Editor editor, boolean modeSwitch)` Close a sketch as specified by its editor window.
    `void` | `handleNew()` Create a new untitled document in a new sketch window.
    `Editor` | `handleOpen(String path)` Open a sketch from the path specified.
    `Editor` | `handleOpen(String path, boolean untitled)` Open a sketch in a new window.
    `void` | `handleOpenPrompt()` Prompt for a sketch to open, and open it in a new window.
    `void` | `handlePrefs()` Show the Preferences window.
    `boolean` | `handleQuit()` Handler for File → Quit.
    `static boolean` | `isCommandLine()`
    `static void` | `locateSketchbookFolder()`
    `static void` | `main(String[] args)`
    `void` | `populateSketchbookMenu(JMenu menu)`
    `void` | `populateToolsMenu(JMenu toolsMenu)`
    `void` | `rebuildToolList()`
    `void` | `refreshContribs(ContributionType ct)`
    `void` | `removeToolContrib(ToolContribution tc)`
    `static void` | `setCommandLine()`
    `void` | `setSketchbookFolder(File folder)`
    `void` | `thinkDifferentExamples()`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEBUG

          public static boolean DEBUG

      True if heavy debugging error/log messages are enabled

    - #### defaultFileMenu

          public static JMenu defaultFileMenu

      A lone file menu to be used when all sketch windows are closed.

  - ### Constructor Detail

    - #### Base

          public Base(String[] args)
               throws Exception

      Throws:
        `Exception`

  - ### Method Detail

    - #### main

          public static void main(String[] args)

    - #### getRevision

          public static int getRevision()

      Returns:
        the current revision number, safe to be used for update checks

    - #### getVersionName

          public static String getVersionName()

      Returns:
        something like 2.2.1 or 3.0b4 (or 0213 if it's not a release)

    - #### setCommandLine

          public static void setCommandLine()

    - #### isCommandLine

          public static boolean isCommandLine()

    - #### checkFirstEditor

          public void checkFirstEditor(Editor editor)

      Tools require an 'Editor' object when they're instantiated, but the activeEditor will be null when the first Editor that opens is creating its Tools menu. This will temporarily set the activeEditor to the one that's opening so that we don't go all NPE on startup. If there's already an active editor, then this does nothing.

    - #### getActiveEditor

          public Editor getActiveEditor()

      Returns the front most, active editor window.

    - #### getEditors

          public List<Editor> getEditors()

      Get the list of currently active editor windows.

    - #### handleActivated

          public void handleActivated(Editor whichEditor)

      Called when a window is activated. Because of variations in native windowing systems, no guarantees about changes to the focused and active Windows can be made. Never assume that this Window is the focused or active Window until this Window actually receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED event.

    - #### refreshContribs

          public void refreshContribs(ContributionType ct)

    - #### getCoreTools

          public List<ToolContribution> getCoreTools()

    - #### getToolContribs

          public List<ToolContribution> getToolContribs()

    - #### removeToolContrib

          public void removeToolContrib(ToolContribution tc)

    - #### rebuildToolList

          public void rebuildToolList()

    - #### clearToolMenus

          public void clearToolMenus()

    - #### populateToolsMenu

          public void populateToolsMenu(JMenu toolsMenu)

    - #### getModeContribs

          public List<ModeContribution> getModeContribs()

    - #### getModeList

          public List<Mode> getModeList()

    - #### getExampleContribs

          public List<ExamplesContribution> getExampleContribs()

    - #### getInstalledContribsInfo

          public byte[] getInstalledContribsInfo()

    - #### getDefaultMode

          public Mode getDefaultMode()

    - #### getNextMode

          public Mode getNextMode()

      Used by ThinkDifferent so that it can have a Sketchbook menu.

    - #### changeMode

          public void changeMode(Mode mode)

      The call has already checked to make sure this sketch is not modified, now change the mode.

    - #### handleNew

          public void handleNew()

      Create a new untitled document in a new sketch window.

    - #### handleOpenPrompt

          public void handleOpenPrompt()

      Prompt for a sketch to open, and open it in a new window.

    - #### handleOpen

          public Editor handleOpen(String path)

      Open a sketch from the path specified. Do not use for untitled sketches.

    - #### handleOpen

          public Editor handleOpen(String path,
                                   boolean untitled)

      Open a sketch in a new window.
      Parameters:
        `path` - Path to the pde file for the sketch in question
      Returns:
        the Editor object, so that properties (like 'untitled') can be set by the caller

    - #### handleClose

          public boolean handleClose(Editor editor,
                                     boolean modeSwitch)

      Close a sketch as specified by its editor window.
      Parameters:
        `editor` - Editor object of the sketch to be closed.
        `modeSwitch` - Whether this close is being done in the context of a mode switch.
      Returns:
        true if succeeded in closing, false if canceled.

    - #### handleQuit

          public boolean handleQuit()

      Handler for File → Quit.
      Returns:
        false if canceled, true otherwise.

    - #### thinkDifferentExamples

          public void thinkDifferentExamples()

    - #### populateSketchbookMenu

          public void populateSketchbookMenu(JMenu menu)

    - #### addSketches

          public boolean addSketches(DefaultMutableTreeNode node,
                                     File folder,
                                     boolean examples)
                              throws IOException

      Throws:
        `IOException`

    - #### handlePrefs

          public void handlePrefs()

      Show the Preferences window.

    - #### getLibFile

          public static File getLibFile(String filename)
                                 throws IOException

      Return a File from inside the Processing 'lib' folder.
      Throws:
        `IOException`

    - #### getLibStream

          public static InputStream getLibStream(String filename)
                                          throws IOException

      Return an InputStream for a file inside the Processing lib folder.
      Throws:
        `IOException`

    - #### getSettingsFolder

          public static File getSettingsFolder()

      Get the directory that can store settings. (Library on OS X, App Data or something similar on Windows, a dot folder on Linux.) Removed this as a preference for 3.0a3 because we need this to be stable.

    - #### getSettingsFile

          public static File getSettingsFile(String filename)

      Convenience method to get a File object for the specified filename inside the settings folder. Used to get preferences and recent sketch files.
      Parameters:
        `filename` - A file inside the settings folder.
      Returns:
        filename wrapped as a File object inside the settings folder

    - #### getToolsFolder

          public static File getToolsFolder()

    - #### locateSketchbookFolder

          public static void locateSketchbookFolder()

    - #### setSketchbookFolder

          public void setSketchbookFolder(File folder)

    - #### getSketchbookFolder

          public static File getSketchbookFolder()

    - #### getSketchbookLibrariesFolder

          public static File getSketchbookLibrariesFolder()

    - #### getSketchbookToolsFolder

          public static File getSketchbookToolsFolder()

    - #### getSketchbookModesFolder

          public static File getSketchbookModesFolder()

    - #### getSketchbookExamplesFolder

          public static File getSketchbookExamplesFolder()