Add platform identification (#286)
This commit is contained in:
parent
bc7c55b1f8
commit
980e9d5e54
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@ -23,6 +24,7 @@ import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.Platform;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
@ -36,6 +38,7 @@ public final class AndroidGraphics extends CanvasAdapter {
|
||||
|
||||
public static void init() {
|
||||
CanvasAdapter.init(new AndroidGraphics());
|
||||
CanvasAdapter.platform = Platform.ANDROID;
|
||||
}
|
||||
|
||||
public static android.graphics.Paint getAndroidPaint(Paint paint) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@ -18,6 +19,7 @@
|
||||
package org.oscim.awt;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.Platform;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
@ -34,6 +36,12 @@ public class AwtGraphics extends CanvasAdapter {
|
||||
|
||||
public static void init() {
|
||||
CanvasAdapter.init(new AwtGraphics());
|
||||
|
||||
String os = System.getProperty("os.name").toLowerCase();
|
||||
|
||||
if(os.contains("win")) CanvasAdapter.platform = Platform.WINDOWS;
|
||||
else if(os.contains("mac")) CanvasAdapter.platform = Platform.MAC_OS;
|
||||
else CanvasAdapter.platform = Platform.LINUX;
|
||||
}
|
||||
|
||||
public static BufferedImage getBitmap(Bitmap bitmap) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2016 Longri
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@ -16,6 +17,7 @@
|
||||
package org.oscim.ios.backend;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.Platform;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
@ -34,6 +36,7 @@ public class IosGraphics extends CanvasAdapter {
|
||||
|
||||
public static void init() {
|
||||
CanvasAdapter.init(new IosGraphics());
|
||||
CanvasAdapter.platform = Platform.IOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@ -22,6 +23,7 @@ import com.google.gwt.canvas.dom.client.Context2d;
|
||||
import com.google.gwt.canvas.dom.client.TextMetrics;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.Platform;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
@ -82,5 +84,6 @@ public class GwtGdxGraphics extends CanvasAdapter {
|
||||
|
||||
public static void init() {
|
||||
CanvasAdapter.init(new GwtGdxGraphics());
|
||||
CanvasAdapter.platform = Platform.WEB;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@ -53,6 +54,11 @@ public abstract class CanvasAdapter {
|
||||
*/
|
||||
public static float dpi = DEFAULT_DPI;
|
||||
|
||||
/**
|
||||
* The used platform.
|
||||
*/
|
||||
public static Platform platform = Platform.UNKNOWN;
|
||||
|
||||
/**
|
||||
* The scale.
|
||||
*/
|
||||
|
@ -43,5 +43,6 @@ public class GLAdapter {
|
||||
|
||||
public static void init(GL gl20) {
|
||||
gl = gl20;
|
||||
GDX_DESKTOP_QUIRKS = CanvasAdapter.platform.GDX_DESKTOP_QUIRKS;
|
||||
}
|
||||
}
|
||||
|
46
vtm/src/org/oscim/backend/Platform.java
Normal file
46
vtm/src/org/oscim/backend/Platform.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2017 Longri
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.backend;
|
||||
|
||||
|
||||
public enum Platform {
|
||||
ANDROID(false, false),
|
||||
IOS(true, false),
|
||||
MAC_OS(true, true),
|
||||
LINUX(false, true),
|
||||
WINDOWS(false, true),
|
||||
WEB(false, false),
|
||||
UNKNOWN(false, false);
|
||||
|
||||
|
||||
Platform(boolean buildingLayerTranslucent, boolean desktopQuirks) {
|
||||
this.BUILDING_LAYER_TRANSLUCENT = buildingLayerTranslucent;
|
||||
this.GDX_DESKTOP_QUIRKS = desktopQuirks;
|
||||
}
|
||||
|
||||
|
||||
public boolean BUILDING_LAYER_TRANSLUCENT;
|
||||
|
||||
public boolean GDX_DESKTOP_QUIRKS;
|
||||
|
||||
/**
|
||||
* Returns true when This is WINDOWS, LINUX or MAC_OS other, false
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isAnyDesktop() {
|
||||
return this == LINUX || this == WINDOWS || this == MAC_OS;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user