use of net.osmand.data.QuadPoint in project Osmand by osmandapp.
the class MapMarkersLayer method onDraw.
@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
widgetsFactory.updateInfo(useFingerLocation ? fingerLocation : null, tileBox.getZoom());
OsmandSettings settings = map.getMyApplication().getSettings();
if (tileBox.getZoom() < 3) {
return;
}
int displayedWidgets = settings.DISPLAYED_MARKERS_WIDGETS_COUNT.get();
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
for (MapMarker marker : markersHelper.getMapMarkers()) {
if (isLocationVisible(tileBox, marker) && !overlappedByWaypoint(marker) && !isInMotion(marker) && !isSynced(marker)) {
Bitmap bmp = getMapMarkerBitmap(marker.colorIndex);
int marginX = bmp.getWidth() / 6;
int marginY = bmp.getHeight();
int locationX = tileBox.getPixXFromLonNoRot(marker.getLongitude());
int locationY = tileBox.getPixYFromLatNoRot(marker.getLatitude());
canvas.rotate(-tileBox.getRotate(), locationX, locationY);
canvas.drawBitmap(bmp, locationX - marginX, locationY - marginY, bitmapPaint);
canvas.rotate(tileBox.getRotate(), locationX, locationY);
}
}
if (settings.SHOW_ARROWS_TO_FIRST_MARKERS.get()) {
LatLon loc = tileBox.getCenterLatLon();
int i = 0;
for (MapMarker marker : markersHelper.getMapMarkers()) {
if (!isLocationVisible(tileBox, marker) && !isInMotion(marker)) {
canvas.save();
net.osmand.Location.distanceBetween(loc.getLatitude(), loc.getLongitude(), marker.getLatitude(), marker.getLongitude(), calculations);
float bearing = calculations[1] - 90;
float radiusBearing = DIST_TO_SHOW * tileBox.getDensity();
final QuadPoint cp = tileBox.getCenterPixelPoint();
canvas.rotate(bearing, cp.x, cp.y);
canvas.translate(-24 * tileBox.getDensity() + radiusBearing, -22 * tileBox.getDensity());
canvas.drawBitmap(arrowShadow, cp.x, cp.y, bitmapPaint);
canvas.drawBitmap(arrowToDestination, cp.x, cp.y, getMarkerDestPaint(marker.colorIndex));
canvas.drawBitmap(arrowLight, cp.x, cp.y, bitmapPaint);
canvas.restore();
}
i++;
if (i > displayedWidgets - 1) {
break;
}
}
}
if (contextMenuLayer.getMoveableObject() instanceof MapMarker) {
MapMarker objectInMotion = (MapMarker) contextMenuLayer.getMoveableObject();
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
Bitmap bitmap = getMapMarkerBitmap(objectInMotion.colorIndex);
int marginX = bitmap.getWidth() / 6;
int marginY = bitmap.getHeight();
float locationX = pf.x;
float locationY = pf.y;
canvas.rotate(-tileBox.getRotate(), locationX, locationY);
canvas.drawBitmap(bitmap, locationX - marginX, locationY - marginY, bitmapPaint);
}
}
use of net.osmand.data.QuadPoint in project Osmand by osmandapp.
the class OsmandMapTileView method refreshBaseMapInternal.
private void refreshBaseMapInternal(RotatedTileBox tileBox, DrawSettings drawSettings) {
if (tileBox.getPixHeight() == 0 || tileBox.getPixWidth() == 0) {
return;
}
if (bufferBitmapTmp == null || tileBox.getPixHeight() != bufferBitmapTmp.getHeight() || tileBox.getPixWidth() != bufferBitmapTmp.getWidth()) {
bufferBitmapTmp = Bitmap.createBitmap(tileBox.getPixWidth(), tileBox.getPixHeight(), Config.RGB_565);
}
long start = SystemClock.elapsedRealtime();
final QuadPoint c = tileBox.getCenterPixelPoint();
Canvas canvas = new Canvas(bufferBitmapTmp);
fillCanvas(canvas, drawSettings);
for (int i = 0; i < layers.size(); i++) {
try {
OsmandMapLayer layer = layers.get(i);
canvas.save();
// rotate if needed
if (!layer.drawInScreenPixels()) {
canvas.rotate(tileBox.getRotate(), c.x, c.y);
}
layer.onPrepareBufferImage(canvas, tileBox, drawSettings);
canvas.restore();
} catch (IndexOutOfBoundsException e) {
// skip it
canvas.restore();
}
}
Bitmap t = bufferBitmap;
synchronized (this) {
bufferImgLoc = tileBox;
bufferBitmap = bufferBitmapTmp;
bufferBitmapTmp = t;
}
long end = SystemClock.elapsedRealtime();
additional.calculateFPS(start, end);
}
use of net.osmand.data.QuadPoint in project Osmand by osmandapp.
the class RulerControlLayer method initLayer.
@Override
public void initLayer(final OsmandMapTileView view) {
app = mapActivity.getMyApplication();
this.view = view;
mapDensity = mapActivity.getMyApplication().getSettings().MAP_DENSITY;
cacheMapDensity = mapDensity.get();
cacheDistances = new ArrayList<>();
cacheCenter = new QuadPoint();
maxRadiusInDp = mapActivity.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
rightWidgetsPanel = mapActivity.findViewById(R.id.map_right_widgets_panel);
touchPoint = new PointF();
acceptableTouchRadius = mapActivity.getResources().getDimensionPixelSize(R.dimen.acceptable_touch_radius);
centerIconDay = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_ruler_center_day);
centerIconNight = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_ruler_center_night);
bitmapPaint = new Paint();
bitmapPaint.setAntiAlias(true);
bitmapPaint.setDither(true);
bitmapPaint.setFilterBitmap(true);
lineAttrs = new RenderingLineAttributes("rulerLine");
float circleTextSize = TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density;
float lineTextSize = DISTANCE_TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density;
lineFontAttrs = new RenderingLineAttributes("rulerLineFont");
lineFontAttrs.paint.setTextSize(lineTextSize);
lineFontAttrs.paint2.setTextSize(lineTextSize);
circleAttrs = new RenderingLineAttributes("rulerCircle");
circleAttrs.paint2.setTextSize(circleTextSize);
circleAttrs.paint3.setTextSize(circleTextSize);
circleAttrsAlt = new RenderingLineAttributes("rulerCircleAlt");
circleAttrsAlt.paint2.setTextSize(circleTextSize);
circleAttrsAlt.paint3.setTextSize(circleTextSize);
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
view.refreshMap();
}
};
}
use of net.osmand.data.QuadPoint in project Osmand by osmandapp.
the class RulerControlLayer method onDraw.
@Override
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
if (rulerModeOn()) {
lineAttrs.updatePaints(view, settings, tb);
lineFontAttrs.updatePaints(view, settings, tb);
lineFontAttrs.paint.setStyle(Style.FILL);
circleAttrs.updatePaints(view, settings, tb);
circleAttrs.paint2.setStyle(Style.FILL);
circleAttrsAlt.updatePaints(view, settings, tb);
circleAttrsAlt.paint2.setStyle(Style.FILL);
final QuadPoint center = tb.getCenterPixelPoint();
final RulerMode mode = app.getSettings().RULER_MODE.get();
final long currentTime = System.currentTimeMillis();
if (cacheMultiTouchEndTime != view.getMultiTouchEndTime()) {
cacheMultiTouchEndTime = view.getMultiTouchEndTime();
refreshMapDelayed();
}
if (touched && view.isMultiTouch()) {
touched = false;
touchEndTime = currentTime;
}
if (tb.isZoomAnimated()) {
wasZoom = true;
}
showTwoFingersDistance = !tb.isZoomAnimated() && !view.isWasZoomInMultiTouch() && currentTime - view.getMultiTouchStartTime() > DELAY_BEFORE_DRAW && (view.isMultiTouch() || currentTime - cacheMultiTouchEndTime < DRAW_TIME);
showDistBetweenFingerAndLocation = !wasZoom && !showTwoFingersDistance && !view.isMultiTouch() && !touchOutside && touchStartTime - view.getMultiTouchStartTime() > DELAY_BEFORE_DRAW && currentTime - touchStartTime > DELAY_BEFORE_DRAW && (touched || currentTime - touchEndTime < DRAW_TIME);
drawCenterIcon(canvas, tb, center, settings.isNightMode(), mode);
Location currentLoc = app.getLocationProvider().getLastKnownLocation();
if (showDistBetweenFingerAndLocation && currentLoc != null) {
drawDistBetweenFingerAndLocation(canvas, tb, currentLoc, settings.isNightMode());
} else if (showTwoFingersDistance) {
drawTwoFingersDistance(canvas, tb, view.getFirstTouchPointLatLon(), view.getSecondTouchPointLatLon(), settings.isNightMode());
}
if (mode == RulerMode.FIRST || mode == RulerMode.SECOND) {
updateData(tb, center);
RenderingLineAttributes attrs = mode == RulerMode.FIRST ? circleAttrs : circleAttrsAlt;
for (int i = 1; i <= cacheDistances.size(); i++) {
drawCircle(canvas, tb, i, center, attrs);
}
}
}
}
Aggregations