Java Androidplot-在打印区域内定位范围标签
我试图在我的图形上设置范围标签的格式,使它们位于绘图区域内,以最大化我的不动产 我遇到的问题是,我不知道如何将范围标签垂直放置,这样标签就会被切掉: 为了得到图,我使用以下方法:Java Androidplot-在打印区域内定位范围标签,java,android,androidplot,Java,Android,Androidplot,我试图在我的图形上设置范围标签的格式,使它们位于绘图区域内,以最大化我的不动产 我遇到的问题是,我不知道如何将范围标签垂直放置,这样标签就会被切掉: 为了得到图,我使用以下方法: plot.setRangeBoundaries(-300, 300, BoundaryMode.FIXED); plot.getGraph().setMargins(-100,0,0,-80); plot.getGraph().getLineLabelInsets().setLeft(PixelUtils.dpToPi
plot.setRangeBoundaries(-300, 300, BoundaryMode.FIXED);
plot.getGraph().setMargins(-100,0,0,-80);
plot.getGraph().getLineLabelInsets().setLeft(PixelUtils.dpToPix(60));
在内部定位标签的最佳方式是什么?因此,我一直无法正确设置标签的格式,作为一种解决方法,我添加了自己的自定义标签 有一种方法可以通过LineLabelStyle设置自定义标签,但如果我们使用该方法,最终也会出现相同的情况 因此,我们使用带有xml属性android:elevation=“1dp”的TextView。因为我实现了PanZoom,所以我们必须截获触摸事件,并根据PanZoom更改相应地更新标签 以下是在用户窗格缩放时更新TextView标签的基本实现:
PanZoom.attach(plot).setDelegate(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN: {
//Update graph labels with plot.getBounds().asRectF();
rangeLabel1.setText("My TextView rangeLabel gets updated here!");
rangeLabel2.setText("You have to calculate value for each label")
domainLabel1.setText("Do the same for domain labels also");
domainLabel2.setText("etc...");
break;
}
case MotionEvent.ACTION_MOVE: {
//Update graph labels with plot.getBounds().asRectF();
rangeLabel1.setText("My TextView rangeLabel gets updated here!");
rangeLabel2.setText("You have to calculate value for each label")
domainLabel1.setText("Do the same for domain labels also");
domainLabel2.setText("etc...");
break;
}
case MotionEvent.ACTION_UP: {
//Update graph labels with plot.getBounds().asRectF();
rangeLabel1.setText("My TextView rangeLabel gets updated here!");
rangeLabel2.setText("You have to calculate value for each label")
domainLabel1.setText("Do the same for domain labels also");
domainLabel2.setText("etc...");
break;
}
}
//Return false to allow PanZoom to receive control
return false;
}
});