use of net.osmand.data.FavouritePoint.BackgroundType in project Osmand by osmandapp.
the class OsmBugsLayer method onPrepareBufferImage.
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
OsmandApplication app = getApplication();
startZoom = plugin.SHOW_OSM_BUGS_MIN_ZOOM.get();
if (tileBox.getZoom() >= startZoom) {
// request to load
data.queryNewData(tileBox);
List<OpenStreetNote> objects = data.getResults();
if (objects != null) {
float textScale = getTextScale();
float iconSize = getIconSize(app);
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
List<OpenStreetNote> fullObjects = new ArrayList<>();
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
boolean showClosed = plugin.SHOW_CLOSED_OSM_BUGS.get();
for (OpenStreetNote o : objects) {
if (!o.isOpened() && !showClosed) {
continue;
}
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
int backgroundColorRes;
if (o.isOpened()) {
backgroundColorRes = R.color.osm_bug_unresolved_icon_color;
} else {
backgroundColorRes = R.color.osm_bug_resolved_icon_color;
}
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(ctx, ContextCompat.getColor(ctx, backgroundColorRes), true, false, DEFAULT_UI_ICON_ID, BackgroundType.COMMENT);
pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
} else {
fullObjects.add(o);
fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
}
}
for (OpenStreetNote o : fullObjects) {
if (!o.isOpened() && !showClosed) {
continue;
}
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
int iconId;
int backgroundColorRes;
if (o.isOpened()) {
iconId = R.drawable.mx_special_symbol_remove;
backgroundColorRes = R.color.osm_bug_unresolved_icon_color;
} else {
iconId = R.drawable.mx_special_symbol_check_mark;
backgroundColorRes = R.color.osm_bug_resolved_icon_color;
}
BackgroundType backgroundType = BackgroundType.COMMENT;
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(ctx, ContextCompat.getColor(ctx, backgroundColorRes), true, false, iconId, backgroundType);
int offsetY = backgroundType.getOffsetY(ctx, textScale);
pointImageDrawable.drawPoint(canvas, x, y - offsetY, textScale, false);
}
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
}
}
}
use of net.osmand.data.FavouritePoint.BackgroundType in project Osmand by osmandapp.
the class OsmEditsLayer method drawPoint.
private void drawPoint(Canvas canvas, OsmPoint osmPoint, float x, float y) {
float textScale = getTextScale();
int iconId = getIconId(osmPoint);
BackgroundType backgroundType = DEFAULT_BACKGROUND_TYPE;
if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
backgroundType = BackgroundType.COMMENT;
}
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(ctx, ContextCompat.getColor(ctx, R.color.created_poi_icon_color), true, false, iconId, backgroundType);
pointImageDrawable.setAlpha(0.8f);
int offsetY = backgroundType.getOffsetY(ctx, textScale);
pointImageDrawable.drawPoint(canvas, x, y - offsetY, textScale, false);
}
use of net.osmand.data.FavouritePoint.BackgroundType in project Osmand by osmandapp.
the class ContextMenuLayer method onDraw.
@Override
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings nightMode) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
boolean markerCustomized = false;
if (selectedObject != null) {
TIntArrayList x = null;
TIntArrayList y = null;
if (selectedObject instanceof Amenity) {
Amenity a = (Amenity) selectedObject;
x = a.getX();
y = a.getY();
} else if (selectedObject instanceof RenderedObject) {
RenderedObject r = (RenderedObject) selectedObject;
x = r.getX();
y = r.getY();
} else if (selectedObject instanceof AidlMapPointWrapper) {
markerCustomized = true;
}
if (x != null && y != null && x.size() > 2) {
float px, py, prevX, prevY;
prevX = box.getPixXFrom31(x.get(0), y.get(0));
prevY = box.getPixYFrom31(x.get(0), y.get(0));
for (int i = 1; i < x.size(); i++) {
px = box.getPixXFrom31(x.get(i), y.get(i));
py = box.getPixYFrom31(x.get(i), y.get(i));
canvas.drawLine(prevX, prevY, px, py, outlinePaint);
prevX = px;
prevY = py;
}
}
}
float textScale = 1f;
if (!pressedLatLonSmall.isEmpty() || !pressedLatLonFull.isEmpty()) {
textScale = getTextScale();
}
for (Entry<LatLon, BackgroundType> entry : pressedLatLonSmall.entrySet()) {
LatLon latLon = entry.getKey();
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
BackgroundType background = entry.getValue();
Bitmap pressedBitmapSmall = background.getTouchBackground(mapActivity, true);
Rect destRect = getIconDestinationRect(x, y, pressedBitmapSmall.getWidth(), pressedBitmapSmall.getHeight(), textScale);
canvas.drawBitmap(pressedBitmapSmall, null, destRect, paint);
}
for (Entry<LatLon, BackgroundType> entry : pressedLatLonFull.entrySet()) {
LatLon latLon = entry.getKey();
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
BackgroundType background = entry.getValue();
Bitmap pressedBitmap = background.getTouchBackground(mapActivity, false);
int offsetY = background.getOffsetY(mapActivity, textScale);
Rect destRect = getIconDestinationRect(x, y - offsetY, pressedBitmap.getWidth(), pressedBitmap.getHeight(), textScale);
canvas.drawBitmap(pressedBitmap, null, destRect, paint);
}
boolean movingMarker = mapQuickActionLayer != null && mapQuickActionLayer.isInMovingMarkerMode();
boolean downloadingTiles = mapActivity.getDownloadTilesFragment() != null;
if (movingMarker || downloadingTiles) {
return;
}
if (mInChangeMarkerPositionMode) {
if (menu != null && menu.getObject() == null) {
canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
contextMarker.draw(canvas);
}
if (mMoveMarkerBottomSheetHelper != null) {
mMoveMarkerBottomSheetHelper.onDraw(box);
}
} else if (mInAddGpxPointMode) {
canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
contextMarker.draw(canvas);
if (mAddGpxPointBottomSheetHelper != null) {
mAddGpxPointBottomSheetHelper.onDraw(box);
}
} else if (!markerCustomized) {
LatLon latLon = null;
if (menu != null && menu.isActive()) {
latLon = menu.getLatLon();
} else if (mapActivity.getTrackMenuFragment() != null) {
latLon = mapActivity.getTrackMenuFragment().getLatLon();
}
if (latLon != null) {
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight());
contextMarker.draw(canvas);
}
}
}
use of net.osmand.data.FavouritePoint.BackgroundType in project Osmand by osmandapp.
the class PointEditorFragmentNew method onCardPressed.
@Override
public void onCardPressed(@NonNull BaseCard card) {
if (card instanceof IconsCard) {
setIcon(iconsCard.getSelectedIconId());
updateNameIcon();
} else if (card instanceof ColorsCard) {
int color = ((ColorsCard) card).getSelectedColor();
updateColorSelector(color);
} else if (card instanceof ShapesCard) {
BackgroundType selectedShape = shapesCard.getSelectedShape();
setBackgroundType(selectedShape);
updateNameIcon();
updateSelectedShapeText();
((TextView) view.findViewById(R.id.shape_name)).setText(selectedShape.getNameId());
}
}
use of net.osmand.data.FavouritePoint.BackgroundType in project Osmand by osmandapp.
the class ShapesCard method updateContent.
@Override
protected void updateContent() {
FlowLayout flowLayout = ((FlowLayout) view);
flowLayout.setHorizontalAutoSpacing(true);
LayoutInflater inflater = UiUtilities.getInflater(view.getContext(), nightMode);
int width = getDimen(R.dimen.favorites_select_icon_button_right_padding);
for (BackgroundType shape : BackgroundType.values()) {
if (shape.isSelected()) {
FlowLayout.LayoutParams layoutParams = new FlowLayout.LayoutParams(width, 0);
flowLayout.addView(createShapeItemView(inflater, shape), layoutParams);
}
}
}
Aggregations