Skip to content

Commit

Permalink
ArcgisToolManager新增放大缩小按钮的样式属性设置
Browse files Browse the repository at this point in the history
  • Loading branch information
roomanl committed Oct 14, 2019
1 parent 535c99c commit 76c2011
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 34 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,56 @@ MeasureToolView控件均由调用ArcGisMeasure开放接口实现
DrawEntity draw=arcgisMeasure.clearMeasure();
//结束测量,返回DrawEntity所有绘制的文字、点、线、面的集合
DrawEntity draw=arcgisMeasure.endMeasure();
```
## 放大缩小控件:
界面代码
```xml
<cn.sddman.arcgistool.view.ArcGisZoomView
android:id="@+id/arcgis_zoom_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:show_text="true"//是否显示文字;默认false
app:zoom_in_text="true"//放大按钮文字
app:zoom_out_text="true"//缩小按钮文字
app:zoom_font_color="@color/colorAccent"//设置文字颜色;默认gray
app:zoom_font_size="12"//设置文字大小;默认12dp
app:zoom_out_image="@drawable/zoomout"//设置缩小按钮图标
app:zoom_in_image="@drawable/zoomin"//设置放大按钮图标
app:isHorizontal="false"//是否水平显示,true水平,false垂直;默认false
app:zoom_bg="@drawable/round_corner"//设置整个控件背景,默认白色圆角矩形
app:button_width="35dp"//设置每一个按钮宽度;默认35
app:button_height="35dp"//设置每一个按钮高度;默认35
>
</cn.sddman.arcgistool.view.ArcGisZoomView>
```
java代码
```java
ArcGisZoomView zoomBtn=(ArcGisZoomView)findViewById(R.id.arcgis_zoom_btn);
ArcgisToolManager.create(this,mMapView).builderZoomView(zoomBtn);
```
java设置属性
```java
ArcgisToolManager.create(this,mMapView).builderZoomView(zoomBtn)
.setZoomHeight(35)//设置每一个按钮高度;默认35
.setZoomWidth(60)/设置每一个按钮宽度;默认35
.setZoomBackground(R.drawable.round_corner)//设置整个控件背景,默认白色圆角矩形
.isHorizontal(true)//是否水平显示,true水平,false垂直;默认false
.setZoomOutImage(R.drawable.sddman_zoomout)//设置缩小按钮图标
.setZoomInImage(R.drawable.sddman_zoomin)//设置放大按钮图标
.setShowText(true)//是否显示文字;默认false
.setZoomOutText("缩小")//缩小按钮文字
.setZoomInText("放大")//放大按钮文字
.setFontSize(12)//设置文字大小;默认12dp
.setFontColor(R.color.colorMain)//设置文字颜色;默认gray
.setZoomClickListener(new ZoomClickListener() {//按钮点击回调
@Override
public void zoomInClick(View view) {
Toast.makeText(MainActivity.this,"zoom in",Toast.LENGTH_SHORT).show();
}

@Override
public void zoomOutClick(View view) {
Toast.makeText(MainActivity.this,"zoom out",Toast.LENGTH_SHORT).show();
}
});
```
43 changes: 27 additions & 16 deletions app/src/main/java/cn/sddman/gis/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.Toast;

import com.esri.arcgisruntime.geometry.Envelope;
Expand All @@ -18,6 +19,7 @@
import cn.sddman.arcgistool.common.Variable;
import cn.sddman.arcgistool.entity.DrawEntity;
import cn.sddman.arcgistool.listener.MeasureClickListener;
import cn.sddman.arcgistool.listener.ZoomClickListener;
import cn.sddman.arcgistool.manager.ArcgisToolManager;
import cn.sddman.arcgistool.manager.MeasureToolManager;
import cn.sddman.arcgistool.view.ArcGisZoomView;
Expand All @@ -41,22 +43,6 @@ protected void onCreate(Bundle savedInstanceState) {
map.setInitialViewpoint(vp);
mMapView.setMap(map);

ArcGisZoomView zoomBtn=(ArcGisZoomView)findViewById(R.id.arcgis_zoom_btn);
zoomBtn.init(mMapView);
zoomBtn.setZoomHeight(35);
zoomBtn.setZoomWidth(60);
zoomBtn.setZoomBackground(R.drawable.round_corner);
zoomBtn.isHorizontal(true);
zoomBtn.setZoomInNum(2);
zoomBtn.setZoomOutNum(2);
zoomBtn.setZoomOutImage(R.drawable.sddman_zoomout);
zoomBtn.setZoomInImage(R.drawable.sddman_zoomin);
zoomBtn.setShowText(true);
zoomBtn.setZoomOutText("缩小");
zoomBtn.setZoomInText("放大");
zoomBtn.setFontSize(12);
zoomBtn.setFontColor(R.color.colorMain);

MapRotateView mapRotateView=(MapRotateView)findViewById(R.id.map_rotate_view);
mapRotateView.init(mMapView);

Expand Down Expand Up @@ -143,6 +129,31 @@ public void endClick(DrawEntity draw) {
Toast.makeText(MainActivity.this,"MeasureToolView endClick",Toast.LENGTH_SHORT).show();
}
});
ArcGisZoomView zoomBtn=(ArcGisZoomView)findViewById(R.id.arcgis_zoom_btn);
ArcgisToolManager.create(this,mMapView).builderZoomView(zoomBtn)
.setZoomHeight(35)
.setZoomWidth(60)
.setZoomBackground(R.drawable.round_corner)
.isHorizontal(true)
.setZoomOutImage(R.drawable.sddman_zoomout)
.setZoomInImage(R.drawable.sddman_zoomin)
.setShowText(true)
.setZoomOutText("缩小")
.setZoomInText("放大")
.setFontSize(12)
.setFontColor(R.color.colorMain)
.setZoomClickListener(new ZoomClickListener() {
@Override
public void zoomInClick(View view) {
Toast.makeText(MainActivity.this,"zoom in",Toast.LENGTH_SHORT).show();
}

@Override
public void zoomOutClick(View view) {
Toast.makeText(MainActivity.this,"zoom out",Toast.LENGTH_SHORT).show();
}
});

}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package cn.sddman.arcgistool.manager;

import com.esri.arcgisruntime.mapping.view.MapView;

import cn.sddman.arcgistool.listener.ZoomClickListener;
import cn.sddman.arcgistool.view.ArcGisZoomView;

public class ArcGisZoomManager {
private ArcGisZoomView arcGisZoomView;
private MapView mMapView;

public ArcGisZoomManager(ArcGisZoomView arcGisZoomView, MapView mMapView) {
this.arcGisZoomView = arcGisZoomView;
this.mMapView = mMapView;
arcGisZoomView.init(mMapView);
}
public ArcGisZoomManager setZoomClickListener(ZoomClickListener zoomClickListener) {
arcGisZoomView.setZoomClickListener(zoomClickListener);
return this;
}
public ArcGisZoomManager setZoomWidth(int w){
arcGisZoomView.setZoomWidth(w);
return this;
}

public ArcGisZoomManager setZoomHeight(int h){
arcGisZoomView.setZoomHeight(h);
return this;
}

public ArcGisZoomManager setZoomBackground(int bg){
arcGisZoomView.setZoomBackground(bg);
return this;
}

public ArcGisZoomManager isHorizontal(boolean horizontal) {
arcGisZoomView.isHorizontal(horizontal);
return this;
}


public ArcGisZoomManager setZoomInNum(int num){
arcGisZoomView.setZoomInNum(num);
return this;
}

public ArcGisZoomManager setZoomOutNum(int num){
arcGisZoomView.setZoomOutNum(num);
return this;
}

public ArcGisZoomManager setZoomInImage(int zoomInImage) {
arcGisZoomView.setZoomInImage(zoomInImage);
return this;
}

public ArcGisZoomManager setZoomOutImage(int zoomOutImage) {
arcGisZoomView.setZoomOutImage(zoomOutImage);
return this;
}

public ArcGisZoomManager setShowText(boolean showText) {
arcGisZoomView.setShowText(showText);
return this;
}

public ArcGisZoomManager setZoomInText(String zoomInText) {
arcGisZoomView.setZoomInText(zoomInText);
return this;
}

public ArcGisZoomManager setZoomOutText(String zoomOutText) {
arcGisZoomView.setZoomOutText(zoomOutText);
return this;
}

public ArcGisZoomManager setFontSize(int fontSize) {
arcGisZoomView.setFontSize(fontSize);
return this;
}

public ArcGisZoomManager setFontColor(int fontColor) {
arcGisZoomView.setFontColor(fontColor);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import com.esri.arcgisruntime.mapping.view.MapView;

import cn.sddman.arcgistool.common.Variable;
import cn.sddman.arcgistool.view.ArcGisZoomView;
import cn.sddman.arcgistool.view.MeasureToolView;

public class ArcgisToolManager {
private static MeasureToolManager measureToolManager=null;
private static ArcgisToolManager arcgisToolManager=null;
private ArcGisZoomManager arcGisZoomManager=null;
private MapView mMapView;
private Context context;
private DefaultMapViewOnTouchListener mapListener;
Expand Down Expand Up @@ -84,4 +86,10 @@ public MeasureToolManager builderMeasure(MeasureToolView measureToolView){
}
return measureToolManager;
}
public ArcGisZoomManager builderZoomView(ArcGisZoomView arcGisZoomView){
if(arcGisZoomManager==null){
arcGisZoomManager=new ArcGisZoomManager(arcGisZoomView,mMapView);
}
return arcGisZoomManager;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ public ArcGisZoomView(Context context, @Nullable AttributeSet attrs, int defStyl
public void init(MapView mMapView){
this.mMapView=mMapView;
}
public void init(MapView mMapView,ZoomClickListener zoomClickListener){
this.mMapView=mMapView;
this.zoomClickListener=zoomClickListener;
}

private void initAttr(TypedArray ta){
bgColor=ta.getResourceId(R.styleable.ViewAttr_view_background,R.drawable.sddman_shadow_bg);
Expand Down Expand Up @@ -132,18 +128,24 @@ private void setZoomDpHeight(int h){
linearParams.height = zoomHeight-20;
spiltLineView2.setLayoutParams(linearParams);
}
@Deprecated
public void setZoomClickListener(ZoomClickListener zoomClickListener) {
this.zoomClickListener = zoomClickListener;
}

@Deprecated
public void setZoomWidth(int w){
setZoomDpWidth(Util.valueToSp(getContext(),w));
}

@Deprecated
public void setZoomHeight(int h){
setZoomDpHeight(Util.valueToSp(getContext(),h));
}

@Deprecated
public void setZoomBackground(int bg){
zoomBgView.setBackground(getResources().getDrawable(bg));
}

@Deprecated
public void isHorizontal(boolean horizontal) {
isHorizontal=horizontal;
if(horizontal){
Expand All @@ -159,25 +161,25 @@ public void isHorizontal(boolean horizontal) {
}
}


@Deprecated
public void setZoomInNum(int num){
zoomInNum=num;
}

@Deprecated
public void setZoomOutNum(int num){
zoomOutNum=num;
}

@Deprecated
public void setZoomInImage(int zoomInImage) {
this.zoomInImage = zoomInImage;
zoomInView.setImageDrawable(getResources().getDrawable(zoomInImage));
}

@Deprecated
public void setZoomOutImage(int zoomOutImage) {
this.zoomOutImage = zoomOutImage;
zoomOutView.setImageDrawable(getResources().getDrawable(zoomOutImage));
}

@Deprecated
public void setShowText(boolean showText) {
this.showText = showText;
int padding=Util.valueToSp(getContext(),10);
Expand All @@ -193,36 +195,36 @@ public void setShowText(boolean showText) {
zoomOutView.setPadding(padding,padding,padding,padding);
}
}

@Deprecated
public void setZoomInText(String zoomInText) {
if(zoomInText==null) return;
this.zoomInText = zoomInText;
zoomInTextView.setText(zoomInText);
}

@Deprecated
public void setZoomOutText(String zoomOutText) {
if(zoomOutText==null) return;
this.zoomOutText = zoomOutText;
zoomOutTextView.setText(zoomOutText);
}

@Deprecated
public void setFontSize(int fontSize) {
this.fontSize = fontSize;
zoomInTextView.setTextSize(fontSize);
zoomOutTextView.setTextSize(fontSize);
}

@Deprecated
public void setFontColor(int fontColor) {
this.fontColor = fontColor;
int color = getResources().getColor(fontColor);
zoomInTextView.setTextColor(color);
zoomOutTextView.setTextColor(color);
}

@Deprecated
public void setZoomInNum(double zoomInNum) {
this.zoomInNum = zoomInNum;
}

@Deprecated
public void setZoomOutNum(double zoomOutNum) {
this.zoomOutNum = zoomOutNum;
}
Expand Down

0 comments on commit 76c2011

Please sign in to comment.