public class PlatformHookUnixoid extends Object implements PlatformHook
PlatformHook
base implementation.
Don't write (Main.platform instanceof PlatformHookUnixoid) because other platform
hooks are subclasses of this class.Modifier and Type | Class and Description |
---|---|
static class |
PlatformHookUnixoid.FontEntry
Simple data class to hold information about a font.
|
protected static class |
PlatformHookUnixoid.LinuxReleaseInfo |
Modifier and Type | Field and Description |
---|---|
private String |
osDescription |
Constructor and Description |
---|
PlatformHookUnixoid() |
Modifier and Type | Method and Description |
---|---|
void |
afterPrefStartupHook()
The afterPrefStartupHook will be called early, but after
the preferences have been loaded and basic processing of
command line arguments is finished.
|
protected void |
askUpdateJava(String version) |
protected void |
askUpdateJava(String version,
String url) |
protected String |
buildOSDescription() |
boolean |
canFullscreen()
Determines if the platform allows full-screen.
|
protected void |
extendFontconfig(String templateFileName)
Add more fallback fonts to the Java runtime, in order to get
support for more scripts.
|
Collection<PlatformHookUnixoid.FontEntry> |
getAdditionalFonts()
Get default list of additional fonts to add to the configuration.
|
File |
getDefaultCacheDirectory()
Returns the platform-dependent default cache directory.
|
File |
getDefaultPrefDirectory()
Returns the platform-dependent default preferences directory.
|
String |
getDefaultStyle()
Returns the default LAF to be used on this platform to look almost as a native application.
|
File |
getDefaultUserDataDirectory()
Returns the platform-dependent default user data directory.
|
Collection<String> |
getInstalledFonts()
Get a list of fonts that are installed on the system.
|
String |
getJavaPackageDetails()
Get the Java package name including detailed version.
|
String |
getOSDescription()
Returns a detailed OS description (at least family + version).
|
static String |
getPackageDetails(String... packageNames)
Get the package name including detailed version.
|
String |
getWebStartPackageDetails()
Get the Web Start package name including detailed version.
|
void |
initSystemShortcuts()
The initSystemShortcuts hook will be called by the
Shortcut class after the modifier groups have been read
from the config, but before any shortcuts are read from
it or registered from within the application.
|
static boolean |
isOpenJDK()
Determines if the JVM is OpenJDK-based.
|
String |
makeTooltip(String name,
Shortcut sc)
This should work for all platforms.
|
void |
openUrl(String url)
The openURL hook will be used to open an URL in the
default web browser.
|
void |
preStartupHook()
The preStartupHook will be called extremly early.
|
boolean |
rename(File from,
File to)
Renames a file.
|
boolean |
setupHttpsCertificate(String entryAlias,
KeyStore.TrustedCertificateEntry trustedCert)
Setup system keystore to add JOSM HTTPS certificate (for remote control).
|
void |
startupHook()
The startupHook will be called early, but after the GUI
setup has started.
|
private String osDescription
public PlatformHookUnixoid()
public void preStartupHook()
PlatformHook
preStartupHook
in interface PlatformHook
public void afterPrefStartupHook()
PlatformHook
afterPrefStartupHook
in interface PlatformHook
public void startupHook()
PlatformHook
startupHook
in interface PlatformHook
public void openUrl(String url) throws IOException
PlatformHook
openUrl
in interface PlatformHook
url
- The URL to openIOException
- if any I/O error occurspublic void initSystemShortcuts()
PlatformHook
initSystemShortcuts
in interface PlatformHook
public String makeTooltip(String name, Shortcut sc)
makeTooltip
in interface PlatformHook
name
- Tooltip text to displaysc
- Shortcut associated (to display accelerator between parenthesis)public String getDefaultStyle()
PlatformHook
getDefaultStyle
in interface PlatformHook
public boolean canFullscreen()
PlatformHook
canFullscreen
in interface PlatformHook
true
if full screen is allowed, false
otherwisepublic boolean rename(File from, File to)
PlatformHook
rename
in interface PlatformHook
from
- Source fileto
- Target filetrue
if the file has been renamed, false
otherwisepublic static boolean isOpenJDK()
true
if java.home
contains "openjdk", false
otherwisepublic static String getPackageDetails(String... packageNames)
packageNames
- The possible package names (when a package can have different names on different distributions)public String getJavaPackageDetails()
public String getWebStartPackageDetails()
null
if there's no separate package for Java WebStart.protected String buildOSDescription()
public String getOSDescription()
PlatformHook
getOSDescription
in interface PlatformHook
protected void askUpdateJava(String version)
protected void askUpdateJava(String version, String url)
public boolean setupHttpsCertificate(String entryAlias, KeyStore.TrustedCertificateEntry trustedCert) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException
PlatformHook
setupHttpsCertificate
in interface PlatformHook
entryAlias
- The entry alias to usetrustedCert
- the JOSM certificate for localhosttrue
if something has changed as a result of the call (certificate installation, etc.)KeyStoreException
- in case of errorNoSuchAlgorithmException
- in case of errorCertificateException
- in case of errorIOException
- in case of errorpublic File getDefaultCacheDirectory()
PlatformHook
getDefaultCacheDirectory
in interface PlatformHook
public File getDefaultPrefDirectory()
PlatformHook
getDefaultPrefDirectory
in interface PlatformHook
public File getDefaultUserDataDirectory()
PlatformHook
getDefaultUserDataDirectory
in interface PlatformHook
protected void extendFontconfig(String templateFileName)
Add more fallback fonts to the Java runtime, in order to get support for more scripts.
The font configuration in Java doesn't include some Indic scripts, even though MS Windows ships with fonts that cover these unicode ranges.
To fix this, the fontconfig.properties template is copied to the JOSM cache folder. Then, the additional entries are added to the font configuration. Finally the system property "sun.awt.fontconfig" is set to the customized fontconfig.properties file.
This is a crude hack, but better than no font display at all for these languages. There is no guarantee, that the template file ($JAVA_HOME/lib/fontconfig.properties.src) matches the default configuration (which is in a binary format). Furthermore, the system property "sun.awt.fontconfig" is undocumented and may no longer work in future versions of Java.
Related Java bug: JDK-8008572
templateFileName
- file name of the fontconfig.properties template filepublic Collection<String> getInstalledFonts()
extendFontconfig(java.lang.String)
, have to set system
property first, which is then read by sun.awt.FontConfiguration upon initialization.)public Collection<PlatformHookUnixoid.FontEntry> getAdditionalFonts()