我正在尝试围绕屏幕中心旋转画布,以获得右下角的(0,0)坐标.
我是这样做的:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
canvas.rotate(180, width/2, height/2);
Run Code Online (Sandbox Code Playgroud)
它确实正确旋转,并且ARE的所有内容都是完美的,API级别为17.但是在API级别为8的AVD上,(0,0)坐标出现在错误的位置.在旋转之前,图片也适合整个屏幕在这个设备,但现在它看起来像这样:

是什么导致了这个问题?
*编辑!
通过围绕自己的中间点旋转画布来解决问题:
canvas.rotate(180,canvas.getWidth()/2,canvas.getHeight()/2);
Run Code Online (Sandbox Code Playgroud)
但是,为什么以前的版本不适用于较旧的API?
如何在python中获取checkbutton的状态?我有这个:
def doSomething():
if #code goes here, if checkbutton is selected
...
check = Checkbutton(window, text="Add both", onvalue = 1, offvalue = 0)
check.pack(side="right")
Run Code Online (Sandbox Code Playgroud) 我正在使用maven构建我的包(运行没有问题),然后我尝试为一个类进行Mockito测试.
pom.xml中的依赖关系如下:
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
mockito测试看起来像这样:
package Person;
import static org.mockito.Mockito.*;
import java.io.IOException;
public class AppTest {
public void test() throws IOException{
PersonManagement mockedPM = mock(PersonManagement.class);
//automatically creates an instance variable of type person
mockedPM.updatePerson("test","test");
//updates this.person
verify(mockedPM).updatePerson("test","test");
}
}
Run Code Online (Sandbox Code Playgroud)
在启动mvn包之后,测试结果显示,没有运行测试(包含测试的文件被找到并被识别,因为当我把语法错误放在那里时,编译器会识别这些)
我要感谢任何帮助,谢谢
我需要读取我写的另一个java程序生成的byte [].众所周知,java中的main只能返回一个void.这是否意味着我需要使用返回类型为byte []的静态方法编写程序?如果是的话,我怎么能在我的程序中运行这个方法并在程序中保存它的返回值?这就是我在程序中的含义:
ProcessBuilder pb = new ProcessBuilder("java.exe","viewer.java","pathToViewer.java");
Process process = pb.start();
InputStream is = process.getInputStream();
byte[] bytes = IOUtils.toByteArray(is);
Run Code Online (Sandbox Code Playgroud)
什么是正确的方法?