Java源码示例:processing.app.Base
示例1
/**
* @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;
}
}
示例2
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;
}
示例3
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);
}
});
}
示例4
public RLangMode(final Base base, final File folder) {
super(base, folder);
log("DEBUG the RLangMode");
sketchServiceManager = new SketchServiceManager(this);
}