processing.app.Base Java Examples

The following examples show how to use processing.app.Base. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RLangMode.java    From Processing.R with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see processing.app.Mode#createEditor(processing.app.Base, java.lang.String,
 *      processing.app.ui.EditorState)
 */
@Override
public Editor createEditor(Base base, final String path, final EditorState state)
    throws EditorException {
  // Lazily start the sketch running service only when an editor is required.
  if (!sketchServiceManager.isStarted()) {
    sketchServiceManager.start();
  }

  try {
    return new RLangEditor(base, path, state, this);
  } catch (EditorException exception) {
    Messages.showError("Editor Exception", "Issue Creating Editor", exception);
    return null;
  }
}
 
Example #2
Source File: PdeSketch.java    From Processing.R with GNU General Public License v3.0 6 votes vote down vote up
public PdeSketch(final Sketch sketch, final File sketchPath, final DisplayType displayType,
    final Point location, final LocationType locationType) {

  this.displayType = displayType;
  this.location = location;
  this.locationType = locationType;

  this.mainFile = sketchPath.getAbsoluteFile();
  this.mainCode = sketch.getMainProgram();
  this.sketchHome = sketch.getFolder().getAbsoluteFile();
  this.realSketchPath = sketchPath;

  final String[] codeFileNames = new String[sketch.getCodeCount()];
  for (int i = 0; i < codeFileNames.length; i++) {
    codeFileNames[i] = sketch.getCode(i).getFile().getName();
  }
  this.codeFileNames = codeFileNames;

  final List<File> libraryDirs = new ArrayList<>();
  libraryDirs.add(Platform.getContentFile("modes/java/libraries"));
  libraryDirs.add(Base.getSketchbookLibrariesFolder());
  libraryDirs.add(sketchPath);
  this.libraryDirs = libraryDirs;
}
 
Example #3
Source File: RLangEditor.java    From Processing.R with GNU General Public License v3.0 5 votes vote down vote up
protected RLangEditor(Base base, String path, EditorState state, Mode mode)
    throws EditorException {
  super(base, path, state, mode);
  log("Initialize RLangEditor now.");

  id = UUID.randomUUID().toString();

  rMode = (RLangMode) mode;
  // Create a sketch service affiliated with this editor.
  final SketchServiceManager sketchServiceManager = rMode.getSketchServiceManager();
  sketchService = sketchServiceManager.createSketchService(this);

  // Ensure that the sketch service gets properly destroyed when either the
  // JVM terminates or this editor closes, whichever comes first.
  final Thread cleanup = new Thread(new Runnable() {
    @Override
    public void run() {
      sketchServiceManager.destroySketchService(RLangEditor.this);
    }
  });
  Runtime.getRuntime().addShutdownHook(cleanup);
  addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(final WindowEvent e) {
      cleanup.start();
      Runtime.getRuntime().removeShutdownHook(cleanup);
    }
  });
}
 
Example #4
Source File: RLangMode.java    From Processing.R with GNU General Public License v3.0 4 votes vote down vote up
public RLangMode(final Base base, final File folder) {
  super(base, folder);
  log("DEBUG the RLangMode");
  sketchServiceManager = new SketchServiceManager(this);
}