summaryrefslogtreecommitdiff
path: root/java/src/org/singinst/uf/view/ViewUtil.java
blob: a8619ef2a324b3fdcff2c6cd11b1677d5bd9ba4a (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
package org.singinst.uf.view;

import java.net.MalformedURLException;
import java.net.URL;

import org.singinst.uf.common.LogUtil;

public class ViewUtil {
	private static Boolean isApple = null;
	
	public static boolean renderExponentsAsSuperscript() {
		return !runningOnApple();
	}
	
	private static URL getAppleUrl() throws MalformedURLException {
		return new URL("http://www.apple.com/");
	}
	
	public static boolean runningOnApple() {
		if (isApple == null) {
			try {
				// this seems surprisingly slow on FireFox, try to only call it once
				String vendorUrlString = System.getProperty("java.vendor.url");
				LogUtil.info("Vendor URL: " + vendorUrlString);
				isApple = getAppleUrl().equals(new URL(vendorUrlString));
			} catch (MalformedURLException e) {
				e.printStackTrace();
				isApple = false;
				//			throw new RuntimeException(e);
			}
		}
		return isApple;
	}
}