Refactor Screenshot examples 2
This commit is contained in:
parent
fd1a5796a9
commit
89754421a2
|
@ -7,14 +7,10 @@ import java.io.File;
|
||||||
|
|
||||||
public class Screenshot {
|
public class Screenshot {
|
||||||
|
|
||||||
private final String filePath;
|
private final String path;
|
||||||
private final String filenamePrefix;
|
|
||||||
private final String fileType;
|
|
||||||
|
|
||||||
public Screenshot(String filePath, String filenamePrefix, String fileType) {
|
public Screenshot(String path) {
|
||||||
this.filePath = filePath;
|
this.path = path;
|
||||||
this.filenamePrefix = filenamePrefix;
|
|
||||||
this.fileType = fileType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getScreenshot(int timeToWait) throws Exception {
|
public void getScreenshot(int timeToWait) throws Exception {
|
||||||
|
@ -22,14 +18,6 @@ public class Screenshot {
|
||||||
Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
|
Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
|
||||||
Robot robot = new Robot();
|
Robot robot = new Robot();
|
||||||
BufferedImage img = robot.createScreenCapture(rectangle);
|
BufferedImage img = robot.createScreenCapture(rectangle);
|
||||||
ImageIO.write(img, fileType, setupFileNamePath());
|
ImageIO.write(img, "jpg", new File(path));
|
||||||
}
|
|
||||||
|
|
||||||
private File setupFileNamePath() {
|
|
||||||
return new File(filePath + filenamePrefix + "." + fileType);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rectangle getScreenSizedRectangle(final Dimension d) {
|
|
||||||
return new Rectangle(0, 0, d.width, d.height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue