You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.5 KiB

package com.example.jmacro.wjdr;
import com.example.jmacro.wjdr.base.Legend;
import com.example.jmacro.wjdr.base.ViewRect;
import com.example.jmacro.wjdr.tool.PickLegend;
import com.example.jmacro.wjdr.tool.PickPoint;
import com.example.jmacro.wjdr.tool.PickRect;
import com.example.jmacro.wjdr.util.DialogUtil;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.image.ImageView;
import java.awt.*;
/**
* UI控制器
*
* @author wangbing
* @version 0.0.1
* @since 1.8
*/
public class JMainController {
@FXML
private Button start;
@FXML
private Button stop;
@FXML
private Button capture;
@FXML
private ImageView preview;
/**
* 采点
*/
@FXML
public void pickPoint() {
ViewRect screen = JMainService.getInstance().getMacro().getFocusRect();
if (screen == null) {
DialogUtil.alert("未定位到视口,请稍后再试!");
return;
}
try {
new PickPoint(screen.getLeft(), screen.getTop());
} catch (AWTException awtException) {
awtException.printStackTrace();
}
}
/**
* 采区
*/
@FXML
public void pickRect() {
ViewRect screen = JMainService.getInstance().getMacro().getFocusRect();
if (screen == null) {
DialogUtil.alert("未定位到视口,请稍后再试!");
return;
}
try {
new PickRect(screen.getLeft(), screen.getTop());
} catch (AWTException awtException) {
awtException.printStackTrace();
}
}
/**
* 采图
*/
@FXML
public void pickLegend() {
ViewRect screen = JMainService.getInstance().getMacro().getFocusRect();
if (screen == null) {
DialogUtil.alert("未定位到视口,请稍后再试!");
return;
}
try {
new PickLegend(screen.getLeft(), screen.getTop(), Legend.getDefaultBase());
} catch (AWTException awtException) {
awtException.printStackTrace();
}
}
/**
* 运行服务
*/
@FXML
public void onStart() {
boolean start = JMainService.start();
this.start.setDisable(start);
this.stop.setDisable(!start);
}
/**
* 停止服务
*/
@FXML
public void onStop() {
boolean stop = JMainService.stop();
this.start.setDisable(!stop);
this.stop.setDisable(stop);
}
public ImageView getPreview() {
return preview;
}
}

Powered by TurnKey Linux.