3333/**
3434 * Used by Base for platform-specific tweaking, for instance finding the
3535 * sketchbook location using the Windows registry, or OS X event handling.
36- *
37- * The methods in this implementation are used by default, and can be
38- * overridden by a subclass, if loaded by Base.main().
39- *
36+ *
37+ * The methods in this implementation are used by default, and can be
38+ * overridden by a subclass, if loaded by Base.main().
39+ *
4040 * These methods throw vanilla-flavored Exceptions, so that error handling
41- * occurs inside Base.
42- *
43- * There is currently no mechanism for adding new platforms, as the setup is
44- * not automated. We could use getProperty("os.arch") perhaps, but that's
45- * debatable (could be upper/lowercase, have spaces, etc.. basically we don't
41+ * occurs inside Base.
42+ *
43+ * There is currently no mechanism for adding new platforms, as the setup is
44+ * not automated. We could use getProperty("os.arch") perhaps, but that's
45+ * debatable (could be upper/lowercase, have spaces, etc.. basically we don't
4646 * know if name is proper Java package syntax.)
4747 */
4848public class Platform {
4949 Base base ;
50-
51-
50+
51+
5252 /**
5353 * Set the default L & F. While I enjoy the bounty of the sixteen possible
54- * exception types that this UIManager method might throw, I feel that in
54+ * exception types that this UIManager method might throw, I feel that in
5555 * just this one particular case, I'm being spoiled by those engineers
5656 * at Sun, those Masters of the Abstractionverse. It leaves me feeling sad
5757 * and overweight. So instead, I'll pretend that I'm not offered eleven dozen
5858 * ways to report to the user exactly what went wrong, and I'll bundle them
59- * all into a single catch-all "Exception". Because in the end, all I really
59+ * all into a single catch-all "Exception". Because in the end, all I really
6060 * care about is whether things worked or not. And even then, I don't care.
61- *
61+ *
6262 * @throws Exception Just like I said.
6363 */
6464 public void setLookAndFeel () throws Exception {
6565 UIManager .setLookAndFeel (UIManager .getSystemLookAndFeelClassName ());
6666 }
67-
68-
67+
68+
6969 public void init (Base base ) {
7070 this .base = base ;
7171 }
72-
73-
72+
73+
7474 public File getSettingsFolder () throws Exception {
7575 // otherwise make a .processing directory int the user's home dir
7676 File home = new File (System .getProperty ("user.home" ));
@@ -92,32 +92,32 @@ public File getSettingsFolder() throws Exception {
9292 }
9393 */
9494 }
95-
95+
9696
9797 /**
98- * @return null if not overridden, which will cause a prompt to show instead.
98+ * @return null if not overridden, which will cause a prompt to show instead.
9999 * @throws Exception
100100 */
101101 public File getDefaultSketchbookFolder () throws Exception {
102- return null ;
102+ return new File ( System . getProperty ( "user.dir" ), "sketchbook" ) ;
103103 }
104-
105-
104+
105+
106106 public void openURL (String url ) throws Exception {
107107 String launcher = Preferences .get ("launcher" );
108108 if (launcher != null ) {
109109 Runtime .getRuntime ().exec (new String [] { launcher , url });
110110 } else {
111111 showLauncherWarning ();
112- }
112+ }
113113 }
114114
115115
116116 public boolean openFolderAvailable () {
117117 return Preferences .get ("launcher" ) != null ;
118118 }
119-
120-
119+
120+
121121 public void openFolder (File file ) throws Exception {
122122 String launcher = Preferences .get ("launcher" );
123123 if (launcher != null ) {
@@ -127,11 +127,11 @@ public void openFolder(File file) throws Exception {
127127 showLauncherWarning ();
128128 }
129129 }
130-
131-
132- // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
133-
134-
130+
131+
132+ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
133+
134+
135135 public interface CLibrary extends Library {
136136 CLibrary INSTANCE = (CLibrary )Native .loadLibrary ("c" , CLibrary .class );
137137 int setenv (String name , String value , int overwrite );
@@ -140,13 +140,13 @@ public interface CLibrary extends Library {
140140 int putenv (String string );
141141 }
142142
143-
143+
144144 public void setenv (String variable , String value ) {
145145 CLibrary clib = CLibrary .INSTANCE ;
146146 clib .setenv (variable , value , 1 );
147147 }
148148
149-
149+
150150 public String getenv (String variable ) {
151151 CLibrary clib = CLibrary .INSTANCE ;
152152 return clib .getenv (variable );
@@ -158,15 +158,15 @@ public int unsetenv(String variable) {
158158 return clib .unsetenv (variable );
159159 }
160160
161-
162- // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
161+
162+ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
163163
164164
165165 protected void showLauncherWarning () {
166- Base .showWarning ("No launcher available" ,
167- "Unspecified platform, no launcher available.\n " +
166+ Base .showWarning ("No launcher available" ,
167+ "Unspecified platform, no launcher available.\n " +
168168 "To enable opening URLs or folders, add a \n " +
169- "\" launcher=/path/to/app\" line to preferences.txt" ,
169+ "\" launcher=/path/to/app\" line to preferences.txt" ,
170170 null );
171171 }
172172}
0 commit comments