/*
* Copyright (C) 2015 Baidu, Inc. All Rights Reserved.
*/
package com.baidu.mapapi.clusterutil.clustering.view;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.MessageQueue;
import android.util.SparseArray;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import com.baidu.mapapi.clusterutil.MarkerManager;
import com.baidu.mapapi.clusterutil.clustering.Cluster;
import com.baidu.mapapi.clusterutil.clustering.ClusterItem;
import com.baidu.mapapi.clusterutil.clustering.ClusterManager;
import com.baidu.mapapi.clusterutil.projection.Point;
import com.baidu.mapapi.clusterutil.projection.SphericalMercatorProjection;
import com.baidu.mapapi.clusterutil.ui.IconGenerator;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.Marker;
import com.baidu.mapapi.map.MarkerOptions;
import com.baidu.mapapi.map.Projection;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.model.LatLngBounds;
import com.venjee.speed.R;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import static com.baidu.mapapi.clusterutil.clustering.algo.NonHierarchicalDistanceBasedAlgorithm.MAX_DISTANCE_AT_ZOOM;
/**
* The default view for a ClusterManager. Markers are animated in and out of clusters.
*/
public class DefaultClusterRenderer<T extends ClusterItem> implements
com.baidu.mapapi.clusterutil.clustering.view.ClusterRenderer<T> {
private static final boolean SHOULD_ANIMATE = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
private final BaiduMap mMap;
private final IconGenerator mIconGenerator;
private final ClusterManager<T> mClusterManager;
private final float mDensity;
private static final int[] BUCKETS = {10, 20, 50, 100, 200, 500, 1000};
private ShapeDrawable mColoredCircleBackground;
/**
* Markers that are currently on the map.
*/
private Set<MarkerWithPosition> mMarkers = Collections.newSetFromMap(
new ConcurrentHashMap<MarkerWithPosition, Boolean>());
/**
* Icons for each bucket.
*/
private SparseArray<BitmapDescriptor> mIcons = new SparseArray<BitmapDescriptor>();
/**
* Markers for single ClusterItems.
*/
private MarkerCache<T> mMarkerCache = new MarkerCache<T>();
/**
* If cluster size is less than this size, display individual markers.
*/
private static final int MIN_CLUSTER_SIZE = 4;
/**
* The currently displayed set of clusters.
*/
private Set<? extends Cluster<T>> mClusters;
/**
* Lookup between markers and the associated cluster.
*/
private Map<Marker, Cluster<T>> mMarkerToCluster = new HashMap<Marker, Cluster<T>>();
private Map<Cluster<T>, Marker> mClusterToMarker = new HashMap<Cluster<T>, Marker>();
/**
* The target zoom level for the current set of clusters.
*/
private float mZoom;
private final ViewModifier mViewModifier = new ViewModifier();
private ClusterManager.OnClusterClickListener<T> mClickListener;
private ClusterManager.OnClusterInfoWindowClickListener<T> mInfoWindowClickListener;
private ClusterManager.OnClusterItemClickListener<T> mItemClickListener;
private ClusterManager.OnClusterItemInfoWindowClickListener<T> mItemInfoWindowClickListener;
public DefaultClusterRenderer(Context context, BaiduMap map, ClusterManager<T> clusterManager) {
mMap = map;
mDensity = context.getResources().getDisplayMetrics().density;
mIconGenerator = new IconGenerator(context);
mIconGenerator.setContentView(makeSquareTextView(context));
mIconGenerator.setTextAppearance(R.style.ClusterIcon_TextAppearance);
mIconGenerator.setBackground(makeClusterBackground());
mClusterManager = clusterManager;
}
@Override
public void onAdd() {
mClusterManager.getMarkerCollection().setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
return mItemClickListener != null && mItemClickListener.onClusterItemClick(mMarkerCache.get(marker));
}
});
mClusterManager.getClusterMarkerCollection().setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
return mClickListener != null && mClickListener.onClusterClick(mMarkerToCluster.get(marker));
}
});
}
@Override
public void onRemove() {
mClusterManager.getMarkerCollection().setOnMarkerClickListener(null);
mClusterManager.getClusterMarkerCollection().setOnMarkerClickListener(null);
}
private LayerDrawable makeClusterBackground() {
mColoredCircleBackground = new ShapeDrawable(new OvalShape());
ShapeDrawable outline = new ShapeDrawable(new OvalShape());
outline.getPaint().setColor(0x80ffffff); // Transparent white.
LayerDrawable background = new LayerDrawable(new Drawable[] {outline, mColoredCircleBackground});
int strokeWidth = (int) (mDensity * 3);
background.setLayerInset(1, strokeWidth, strokeWidth, strokeWidth, strokeWidth);
return background;
}
private com.baidu.mapapi.clusterutil.ui.SquareTextView makeSquareTextView(Context context) {
com.baidu.mapapi.clusterutil.ui.SquareTextView squareTextView =
new com.baidu.mapapi.clusterutil.ui.SquareTextView(context);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
squareTextView.setLayoutParams(layoutParams);
squareTextView.setId(R.id.text);
int twelveDpi = (int) (12 * mDensity);
squareTextView.setPadding(twelveDpi, twelveDpi, twelveDpi, twelveDpi);
return squareTextView;
}
private int getColor(int clusterSize) {
final float hueRange = 220;
final float sizeRange = 300;
final float size = Math.min(clusterSize, sizeRange);
final float hue = (sizeRange - size) * (sizeRange - size) / (sizeRange * sizeRange) * hueRange;
return Color.HSVToColor(new float[] {
hue, 1f, .6f
});
}
protected String getClusterText(int bucket) {
if (bucket < BUCKETS[0]) {
return String.valueOf(bucket);
}
return String.valueOf(bucket) + "+";
}
/**
* Gets the "bucket" for a particular cluster. By default, uses the number of points within the
* cluster, bucketed to some set points.
*/
protected int getBucket(Cluster<T> cluster) {
int size = cluster.getSize();
if (size <= BUCKETS[0]) {
return size;
}
for (int i = 0; i < BUCKETS.length - 1; i++) {
if (size < BUCKETS[i + 1]) {
return BUCKETS[i];
}
}
return BUCKETS[BUCKETS.length - 1];
没有合适的资源?快使用搜索试试~ 我知道了~
一款实时监测汽车运行速度的app开发源码.zip
共155个文件
png:49个
xml:48个
java:47个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 14 浏览量
2023-10-17
00:20:38
上传
评论
收藏 950KB ZIP 举报
温馨提示
1、该资源内项目代码经过严格调试,下载即用确保可以运行! 2、该资源适合计算机相关专业(如计科、人工智能、大数据、数学、电子信息等)正在做课程设计、期末大作业和毕设项目的学生、或者相关技术学习者作为学习资料参考使用。 3、该资源包括全部源码,需要具备一定基础才能看懂并调试代码。 一款实时监测汽车运行速度的app开发源码.zip
资源推荐
资源详情
资源评论
收起资源包目录
一款实时监测汽车运行速度的app开发源码.zip (155个子文件)
.gitignore 131B
.gitignore 14B
build.gradle 618B
build.gradle 532B
settings.gradle 15B
gradlew 5KB
gradle-wrapper.jar 52KB
DefaultClusterRenderer.java 35KB
FenceActivity.java 31KB
TrackQueryActivity.java 25KB
TracingActivity.java 22KB
SystemBarTintManager.java 19KB
BosActivity.java 11KB
MapUtil.java 11KB
ClusterManager.java 9KB
TrackQueryOptionsActivity.java 9KB
IconGenerator.java 8KB
TrackApplication.java 8KB
NonHierarchicalDistanceBasedAlgorithm.java 8KB
FenceSettingDialog.java 7KB
MainActivity.java 7KB
ViewUtil.java 6KB
CommonUtil.java 6KB
PointQuadTree.java 6KB
TracingOptionsActivity.java 6KB
FenceCreateDialog.java 5KB
MarkerManager.java 5KB
DateDialog.java 4KB
PreCachingAlgorithmDecorator.java 3KB
FenceOperateDialog.java 3KB
TrackAnalysisDialog.java 2KB
CacheManageActivity.java 2KB
BaseActivity.java 2KB
TrackAnalysisInfoLayout.java 2KB
RotationLayout.java 2KB
BitmapUtil.java 2KB
SplashActivity.java 1KB
TrackReceiver.java 1KB
SquareTextView.java 1KB
Bounds.java 1KB
StaticCluster.java 1KB
ClusterRenderer.java 1KB
Constants.java 1KB
SphericalMercatorProjection.java 1KB
NetUtil.java 841B
ExampleInstrumentedTest.java 606B
Algorithm.java 589B
ClusterItem.java 571B
ItemInfo.java 507B
FAQActivity.java 436B
Point.java 432B
Cluster.java 425B
ExampleUnitTest.java 394B
CurrentLocation.java 346B
keystore.jks 2KB
bg_splash.png 307KB
bg_splash.png 186KB
bg_splash.png 124KB
bg_splash.png 79KB
icon_app.png 34KB
icon_app.png 23KB
icon_app.png 19KB
ic_launcher.png 10KB
icon_app.png 8KB
ic_launcher.png 8KB
icon_geo.png 5KB
ic_launcher.png 5KB
icon_end.png 5KB
icon_start.png 5KB
icon_markx.png 4KB
icon_gcoding.png 4KB
icon_point.png 4KB
bg_btn_close.png 3KB
ic_launcher.png 3KB
bg_btn_cancel.png 3KB
bg_btn_common.png 3KB
bg_btn_sure.png 3KB
ic_launcher.png 2KB
icon_cache_manage.png 2KB
bg_rdo_disable.png 1KB
bg_rdo_enable.png 1KB
bg_chk_enable.png 1KB
icon_mark8.png 1KB
icon_mark6.png 1KB
icon_mark10.png 1KB
icon_mark9.png 1KB
icon_mark3.png 1KB
icon_mark5.png 1KB
icon_mark2.png 1KB
icon_mark7.png 1KB
icon_mark4.png 1KB
bg_chk_disable.png 1KB
bg_btn_all_control.png 1KB
icon_mark1.png 1KB
icon_tracing.png 743B
icon_track_query.png 728B
icon_fag.png 682B
icon_fence.png 586B
icon_settings.png 528B
icon_bos.png 478B
共 155 条
- 1
- 2
资源评论
辣椒种子
- 粉丝: 3420
- 资源: 5723
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功