processing.app

## Class Mode

- Object
- - Mode

- Direct Known Subclasses:
    JavaMode

      public abstract class Mode
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `ArrayList<Library>` | `contribLibraries`
    `ArrayList<Library>` | `coreLibraries`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Mode(Base base, File folder)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `JTree` | `buildExamplesTree()`
    `abstract Editor` | `createEditor(Base base, String path, EditorState state)` Create a new editor associated with this mode.
    `void` | `drawBackground(Graphics g, int offset)`
    `boolean` | `getBoolean(String attribute)`
    `ClassLoader` | `getClassLoader()`
    `Color` | `getColor(String attribute)`
    `File` | `getContentFile(String path)`
    `InputStream` | `getContentStream(String path)`
    `Library` | `getCoreLibrary()`
    `abstract String` | `getDefaultExtension()` Returns the default extension for this editor setup.
    `File[]` | `getExampleCategoryFolders()` Override this to control the order of the first set of example folders and how they appear in the examples window.
    `File` | `getExamplesFolder()`
    `abstract String[]` | `getExtensions()` Returns a String[] array of proper extensions.
    `Font` | `getFont(String attribute)`
    `String` | `getIdentifier()` Get an identifier that can be used to resurrect this mode and connect it to a sketch.
    `abstract String[]` | `getIgnorable()` Get array of file/directory names that needn't be copied during "Save As".
    `JMenu` | `getImportMenu()`
    `int` | `getInteger(String attribute)`
    `File[]` | `getKeywordFiles()` To add additional keywords, or to grab them from another mode, override this function.
    `File` | `getLibrariesFolder()`
    `Library` | `getLibrary(String pkgName)`
    `File` | `getReferenceFolder()`
    `SyntaxStyle` | `getStyle(String attribute)`
    `abstract String` | `getTitle()` Return the pretty/printable/menu name for this mode.
    `TokenMarker` | `getTokenMarker()`
    `JMenu` | `getToolbarMenu()`
    `boolean` | `hideExtension(String what)` True if the specified extension should be hidden when shown on a tab.
    `void` | `insertToolbarRecentMenu()`
    `boolean` | `isDefaultExtension(SketchCode code)` True if the specified code has the default file extension.
    `boolean` | `isDefaultExtension(String what)` True if the specified extension is the default file extension.
    `Image` | `loadImage(String filename)` Get an image object from the theme folder.
    `String` | `lookupReference(String keyword)` Returns the HTML filename (including path prefix if necessary) for this keyword, or null if it doesn't exist.
    `void` | `prepareExportFolder(File targetFolder)` Create a fresh applet/application folder if the 'delete target folder' pref has been set in the preferences.
    `void` | `rebuildImportMenu()`
    `void` | `rebuildLibraryList()`
    `void` | `removeToolbarRecentMenu()`
    `void` | `resetExamples()`
    `void` | `setClassLoader(ClassLoader loader)`
    `void` | `setupGUI()` Setup additional elements that are only required when running with a GUI, rather than from the command-line.
    `void` | `showExamplesFrame()`
    `boolean` | `validExtension(String what)` Check this extension (no dots, please) against the list of valid extensions.

    - ### Methods inherited from class Object

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

- - ### Field Detail

    - #### coreLibraries

          public ArrayList<Library> coreLibraries

    - #### contribLibraries

          public ArrayList<Library> contribLibraries

  - ### Constructor Detail

    - #### Mode

          public Mode(Base base,
              File folder)

  - ### Method Detail

    - #### getKeywordFiles

          public File[] getKeywordFiles()

      To add additional keywords, or to grab them from another mode, override this function. If your mode has no keywords, return a zero length array.

    - #### setClassLoader

          public void setClassLoader(ClassLoader loader)

    - #### getClassLoader

          public ClassLoader getClassLoader()

    - #### setupGUI

          public void setupGUI()

      Setup additional elements that are only required when running with a GUI, rather than from the command-line. Note that this will not be called when the Mode is used from the command line (because Base will be null).

    - #### drawBackground

          public void drawBackground(Graphics g,
                            int offset)

    - #### getContentFile

          public File getContentFile(String path)

    - #### getContentStream

          public InputStream getContentStream(String path)
                                       throws FileNotFoundException

      Throws:
        `FileNotFoundException`

    - #### getTitle

          public abstract String getTitle()

      Return the pretty/printable/menu name for this mode. This is separate from the single word name of the folder that contains this mode. It could even have spaces, though that might result in sheer madness or total mayhem.

    - #### getIdentifier

          public String getIdentifier()

      Get an identifier that can be used to resurrect this mode and connect it to a sketch. Using this instead of getTitle() because there might be name clashes with the titles, but there should not be once the actual package, et al. is included.
      Returns:
        full name (package + class name) for this mode.

    - #### createEditor

          public abstract Editor createEditor(Base base,
                            String path,
                            EditorState state)

      Create a new editor associated with this mode.

    - #### getExamplesFolder

          public File getExamplesFolder()

    - #### getLibrariesFolder

          public File getLibrariesFolder()

    - #### getReferenceFolder

          public File getReferenceFolder()

    - #### rebuildLibraryList

          public void rebuildLibraryList()

    - #### getCoreLibrary

          public Library getCoreLibrary()

    - #### getLibrary

          public Library getLibrary(String pkgName)
                             throws SketchException

      Throws:
        `SketchException`

    - #### getToolbarMenu

          public JMenu getToolbarMenu()

    - #### insertToolbarRecentMenu

          public void insertToolbarRecentMenu()

    - #### removeToolbarRecentMenu

          public void removeToolbarRecentMenu()

    - #### getImportMenu

          public JMenu getImportMenu()

    - #### rebuildImportMenu

          public void rebuildImportMenu()

    - #### getExampleCategoryFolders

          public File[] getExampleCategoryFolders()

      Override this to control the order of the first set of example folders and how they appear in the examples window.

    - #### buildExamplesTree

          public JTree buildExamplesTree()

    - #### resetExamples

          public void resetExamples()

    - #### showExamplesFrame

          public void showExamplesFrame()

    - #### loadImage

          public Image loadImage(String filename)

      Get an image object from the theme folder.

    - #### lookupReference

          public String lookupReference(String keyword)

      Returns the HTML filename (including path prefix if necessary) for this keyword, or null if it doesn't exist.

    - #### getTokenMarker

          public TokenMarker getTokenMarker()

    - #### getBoolean

          public boolean getBoolean(String attribute)

    - #### getInteger

          public int getInteger(String attribute)

    - #### getColor

          public Color getColor(String attribute)

    - #### getFont

          public Font getFont(String attribute)

    - #### getStyle

          public SyntaxStyle getStyle(String attribute)

    - #### hideExtension

          public boolean hideExtension(String what)

      True if the specified extension should be hidden when shown on a tab. For Processing, this is true for .pde files. (Broken out for subclasses.) You can override this in your Mode subclass to handle it differently.

    - #### isDefaultExtension

          public boolean isDefaultExtension(SketchCode code)

      True if the specified code has the default file extension.

    - #### isDefaultExtension

          public boolean isDefaultExtension(String what)

      True if the specified extension is the default file extension.

    - #### validExtension

          public boolean validExtension(String what)

      Check this extension (no dots, please) against the list of valid extensions.

    - #### getDefaultExtension

          public abstract String getDefaultExtension()

      Returns the default extension for this editor setup.

    - #### getExtensions

          public abstract String[] getExtensions()

      Returns a String[] array of proper extensions.

    - #### getIgnorable

          public abstract String[] getIgnorable()

      Get array of file/directory names that needn't be copied during "Save As".

    - #### prepareExportFolder

          public void prepareExportFolder(File targetFolder)

      Create a fresh applet/application folder if the 'delete target folder' pref has been set in the preferences.