public void paintComponent(Graphics g) { if (name == "" && serialport == "") { Map<String, String> boardPreferences = Base.getBoardPreferences(); if (boardPreferences != null) setBoardName(boardPreferences.get("name")); else setBoardName("-"); setSerialPort(Preferences.get("serial.port")); } g.setColor(background); Dimension size = getSize(); g.fillRect(0, 0, size.width, size.height); g.setFont(font); g.setColor(foreground); int baseline = (high + g.getFontMetrics().getAscent()) / 2; g.drawString(text, 6, baseline); g.setColor(messageForeground); String tmp = name + " on " + serialport; Rectangle2D bounds = g.getFontMetrics().getStringBounds(tmp, null); g.drawString(tmp, size.width - (int) bounds.getWidth() - 20, baseline); if (Base.isMacOS()) { g.drawImage(resize, size.width - 20, 0, this); } }
public boolean avrdude(Collection params) throws RunnerException { List commandDownloader = new ArrayList(); commandDownloader.add("avrdude"); // Point avrdude at its config file since it's in a non-standard location. if (Base.isMacOS()) { commandDownloader.add("-C" + "hardware/tools/avr/etc/avrdude.conf"); } else if (Base.isWindows()) { String userdir = System.getProperty("user.dir") + File.separator; commandDownloader.add("-C" + userdir + "hardware/tools/avr/etc/avrdude.conf"); } else { // ???: is it better to have Linux users install avrdude themselves, in // a way that it can find its own configuration file? commandDownloader.add("-C" + "hardware/tools/avrdude.conf"); } if (Preferences.getBoolean("upload.verbose")) { commandDownloader.add("-v"); commandDownloader.add("-v"); commandDownloader.add("-v"); commandDownloader.add("-v"); } else { commandDownloader.add("-q"); commandDownloader.add("-q"); } // XXX: quick hack to chop the "atmega" off of "atmega8" and "atmega168", // then shove an "m" at the beginning. won't work for attiny's, etc. commandDownloader.add( "-pm" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu").substring(6)); commandDownloader.addAll(params); return executeUploadCommand(commandDownloader); }
public static void applyLAF() { try { if (Base.isMacOS()) { System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "UECIDE"); } UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { Base.error(e); } }
public EditorLineStatus(JEditTextArea textarea) { this.textarea = textarea; textarea.editorLineStatus = this; background = Theme.getColor("linestatus.bgcolor"); font = Theme.getFont("linestatus.font"); foreground = Theme.getColor("linestatus.color"); high = Theme.getInteger("linestatus.height"); if (Base.isMacOS()) { resize = Base.getThemeImage("resize.gif", this); } // linestatus.bgcolor = #000000 // linestatus.font = SansSerif,plain,10 // linestatus.color = #FFFFFF }
public Runner(JavaBuild build, RunnerListener listener) throws SketchException { this.listener = listener; // this.sketch = sketch; this.build = build; if (listener instanceof Editor) { this.editor = (Editor) listener; sketchErr = editor.getConsole().getErr(); sketchOut = editor.getConsole().getOut(); } else { sketchErr = System.err; sketchOut = System.out; } // Make sure all the imported libraries will actually run with this setup. int bits = Base.getNativeBits(); for (Library library : build.getImportedLibraries()) { if (!library.supportsArch(PApplet.platform, bits)) { sketchErr.println(library.getName() + " does not run in " + bits + "-bit mode."); int opposite = (bits == 32) ? 64 : 32; if (Base.isMacOS()) { // if (library.supportsArch(PConstants.MACOSX, opposite)) { // should always be true throw new SketchException( "To use " + library.getName() + ", " + "switch to " + opposite + "-bit mode in Preferences."); // } } else { throw new SketchException( library.getName() + " is only compatible " + "with the " + opposite + "-bit download of Processing."); // throw new SketchException(library.getName() + " does not run in " + bits + "-bit // mode."); // "To use this library, switch to 32-bit mode in Preferences." (OS X) // "To use this library, you must use the 32-bit version of Processing." } } } }
public long computeSize() throws RunnerException { String userdir = System.getProperty("user.dir") + File.separator; String avrBasePath; if (Base.isMacOS()) { avrBasePath = new String("tools/avr/bin/"); } else if (Base.isLinux()) { avrBasePath = new String(""); } else { avrBasePath = new String(userdir + "tools/avr/bin/"); } String commandSize[] = new String[] {avrBasePath + "avr-size", " "}; commandSize[1] = buildPath + File.separator + sketchName + ".hex"; try { exception = null; size = -1; firstLine = null; Process process = Runtime.getRuntime().exec(commandSize); new MessageSiphon(process.getInputStream(), this); new MessageSiphon(process.getErrorStream(), this); boolean running = true; while (running) { try { process.waitFor(); running = false; } catch (InterruptedException intExc) { } } } catch (Exception e) { exception = new RunnerException(e.toString()); } if (exception != null) throw exception; if (size == -1) throw new RunnerException(firstLine); return size; }
protected String[] getMachineParams() { ArrayList<String> params = new ArrayList<String>(); // params.add("-Xint"); // interpreted mode // params.add("-Xprof"); // profiler // params.add("-Xaprof"); // allocation profiler // params.add("-Xrunhprof:cpu=samples"); // old-style profiler // TODO change this to use run.args = true, run.args.0, run.args.1, etc. // so that spaces can be included in the arg names String options = Preferences.get("run.options"); if (options.length() > 0) { String pieces[] = PApplet.split(options, ' '); for (int i = 0; i < pieces.length; i++) { String p = pieces[i].trim(); if (p.length() > 0) { params.add(p); } } } // params.add("-Djava.ext.dirs=nuffing"); if (Preferences.getBoolean("run.options.memory")) { params.add("-Xms" + Preferences.get("run.options.memory.initial") + "m"); params.add("-Xmx" + Preferences.get("run.options.memory.maximum") + "m"); } if (Base.isMacOS()) { params.add("-Xdock:name=" + build.getSketchClassName()); // params.add("-Dcom.apple.mrj.application.apple.menu.about.name=" + // sketch.getMainClassName()); } // sketch.libraryPath might be "" // librariesClassPath will always have sep char prepended params.add( "-Djava.library.path=" + build.getJavaLibraryPath() + File.pathSeparator + System.getProperty("java.library.path")); params.add("-cp"); params.add(build.getClassPath()); // params.add(sketch.getClassPath() + // File.pathSeparator + // Base.librariesClassPath); // enable assertions // http://dev.processing.org/bugs/show_bug.cgi?id=1188 params.add("-ea"); // PApplet.println(PApplet.split(sketch.classPath, ':')); String outgoing[] = new String[params.size()]; params.toArray(outgoing); // PApplet.println(outgoing); // PApplet.println(PApplet.split(outgoing[0], ":")); // PApplet.println(); // PApplet.println("class path"); // PApplet.println(PApplet.split(outgoing[2], ":")); return outgoing; // return (String[]) params.toArray(); // System.out.println("sketch class path"); // PApplet.println(PApplet.split(sketch.classPath, ';')); // System.out.println(); // System.out.println("libraries class path"); // PApplet.println(PApplet.split(Base.librariesClassPath, ';')); // System.out.println(); }
public JMenu buildHelpMenu() { // To deal with a Mac OS X 10.5 bug, add an extra space after the name // so that the OS doesn't try to insert its slow help menu. JMenu menu = new JMenu("Help "); JMenuItem item; // macosx already has its own about menu if (!Base.isMacOS()) { item = new JMenuItem("About Processing"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new About(JavaEditor.this); } }); menu.add(item); } item = new JMenuItem("Environment"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { showReference("environment" + File.separator + "index.html"); } }); menu.add(item); item = new JMenuItem("Reference"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { showReference("index.html"); } }); menu.add(item); item = Toolkit.newJMenuItemShift("Find in Reference", 'F'); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (textarea.isSelectionActive()) { handleFindReference(); } } }); menu.add(item); menu.addSeparator(); item = new JMenuItem("Online"); item.setEnabled(false); menu.add(item); item = new JMenuItem("Getting Started"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Base.openURL("http://processing.org/learning/gettingstarted/"); } }); menu.add(item); item = new JMenuItem("Troubleshooting"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Base.openURL("http://wiki.processing.org/w/Troubleshooting"); } }); menu.add(item); item = new JMenuItem("Frequently Asked Questions"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Base.openURL("http://wiki.processing.org/w/FAQ"); } }); menu.add(item); item = new JMenuItem("Visit Processing.org"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Base.openURL("http://processing.org/"); } }); menu.add(item); return menu; }