aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/cycling74/max/MaxSystem.java
blob: dd8fe4810d2de3afc823e0315edbc53f424060d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package com.cycling74.max;

import com.e1.pdj.*;

/**
 * MXJ System utilities.
 */
public class MaxSystem {
	static private PriorityQueue low = new PriorityQueue(Thread.MIN_PRIORITY);	
	
	/**
	 * Shows a message to the pd console
	 * @param message the string to show
	 */
	static native public void post(String message); 
	
	/**
	 * Shows a error message to the pd console
	 * @param message the string to show
	 */
	static native public void error(String message);
	
	/**
	 * Shows a message in the pd console and kill PD afterwards.
	 * @param message the string to show
	 */
	static native public void ouch(String message);
	
	/**
	 * Sends a message to a bound object (IEM object or a receiver)
	 * @param name the destination of the message
	 * @param msg the symbol message ("bang", "float", "list")
	 * @param args the array of Atoms
	 * @return true if successfull
	 */
	static native public boolean sendMessageToBoundObject(String name, String msg, Atom[] args);

	/**
	 * Tries to locate file in pure-data search path.
	 * @param filename of the file to search in path
	 * @return the full path of this file
	 */
	static native public String locateFile(String filename);

	/**
	 * Will schedule the executable to a low priority thread
	 * @param fn the executable
	 */
	static synchronized public void deferLow(Executable fn) {
		low.defer(fn);
	}

	/**
	 * Will schedule the executable to a medium priority thread
	 * @param fn the executable
	 */
	static synchronized public void deferMedium(Executable fn) {
		low.defer(fn);
	}
	
	/**
	 * Returns the user classpath.
	 * @return Array of strings of each entries in the user classpath
	 */
	static public String[] getClassPath() {
		return PDJClassLoader.getCurrentClassPath();
	}

	// implemented but not fully supported...
	static public void defer(Executable fn) {
		fn.execute();
	}
	static public void deferFront(Executable fn) {
		fn.execute();
	}
	
	static public String[] getSystemClassPath() {
		return null;
	}
	
	static boolean inMainThread() {
		return false;
	}
	
	static boolean inMaxThread() {
		return false;
	}
	
	static boolean inTimerThread() {
		return false;
	}
	
	static boolean isOsMacOsX() {
        String osname = System.getProperty("os.name");
        if ( osname.indexOf("OS X") != -1 ) {
            return true;
        }
		return false;
	}
	
	static boolean isOsWindows() {
        String osname = System.getProperty("os.name");
        if ( osname.indexOf("Windows") != -1 ) {
            return true;
        }
		return false;
	}
	
	/**
	 * <b>Not supported in PD</b>
	 */
	static void registerCommandAccelerator(char c) {
	}

	/**
	 * <b>Not supported in PD</b>
	 */
	static void registerCommandAccelerators(char c[]) {
	}

	/**
	 * <b>Not supported in PD</b>
	 */
	static void unRegisterCommandAccelerator(char c) {
	}
	/**
	 * <b>Not supported in PD</b>
	 */	
	static void unRegisterCommandAccelerators(char c[]) {
	}
	
	// not compatible Max methods :
	////////////////////////////////////////////////////////
	/**
	 * <b>Not supported in PD</b>
	 */
	static public boolean isStandAlone() {
		return false;
	}
	
	static public short getMaxVersion() {
		return 0;
	}
	
	static public int[] getMaxVersionInts() {
		int ret[] = new int[3];
		
		ret[0] = 0;
		ret[1] = 99;
		ret[2] = 0;
		
		return ret;
	}

	/**
	 * <b>Not supported in PD</b>
	 */
	static public void hideCursor() {
	}

	/**
	 * <b>Not supported in PD</b>
	 */
	static public void showCursor() {		
	}

	/**
	 * <b>Not supported in PD</b>
	 */
	static public void nextWindowIsModal() {
	}
	
	// constants
	public static String MXJ_VERSION = "pdj 0.8.4";
	
	public static final int PATH_STYLE_COLON		= 2;
	public static final int PATH_STYLE_MAX			= 0;
	public static final int PATH_STYLE_NATIVE		= 1;
	public static final int PATH_STYLE_NATIVE_WIN	= 4;
	public static final int PATH_STYLE_SLASH		= 3;
	public static final int PATH_TYPE_ABSOLUTE		= 1;
	public static final int PATH_TYPE_BOOT			= 3;
	public static final int PATH_TYPE_C74			= 4;
	public static final int PATH_TYPE_IGNORE		= 0;
	public static final int PATH_TYPE_RELATIVE		= 2;	
}