feat(control): 增加双面扫描和系统UI选项
- 在 Operational 类中添加了双面扫描 (duple) 和系统UI (systemUI) 的支持 - 更新了 startScan 方法以支持系统UI选项 - 优化了 IconUtil 类中的图标加载逻辑 - 将项目版本号从 0.1.6.2 升级到 0.1.6.6
This commit is contained in:
parent
0bd6f83a44
commit
5cee6f61e9
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>org.aohe</groupId>
|
||||
<artifactId>twain-service</artifactId>
|
||||
<version>0.1.6.2</version>
|
||||
<version>0.1.6.6</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
|
|
@ -16,6 +16,9 @@ import java.util.*;
|
|||
@Slf4j
|
||||
public class Operational {
|
||||
|
||||
//是否使用系统UI
|
||||
private static Boolean isSystemUI = false;
|
||||
|
||||
public static String selectOperational(String path) {
|
||||
JSONObject json = JSONObject.parse(path);
|
||||
|
||||
|
@ -149,7 +152,6 @@ public class Operational {
|
|||
TwainSource twainSource = openTwSource();
|
||||
TwainCapability[] capabilities = twainSource.getCapabilities();
|
||||
|
||||
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
for (TwainCapability cap : capabilities){
|
||||
List<String> list = new ArrayList<>();
|
||||
|
@ -166,11 +168,6 @@ public class Operational {
|
|||
}finally {
|
||||
closeTwSource();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,6 +176,7 @@ public class Operational {
|
|||
* DPI --> double
|
||||
* 色彩模式 color 0,1,2 -> 黑白,灰度,彩色
|
||||
* 进纸模式 paper true,false -> 自动,手动
|
||||
* 双面扫描 duple true,false -> 双面,单面
|
||||
* @param map 参数和值
|
||||
* @return R
|
||||
*/
|
||||
|
@ -195,6 +193,13 @@ public class Operational {
|
|||
if(map.get("paper") !=null){
|
||||
twainSource.setCapability(Twain.CAP_FEEDERENABLED, map.getBooleanValue("paper"));
|
||||
}
|
||||
if(map.get("duple") != null){
|
||||
twainSource.setCapability(Twain.CAP_DUPLEXENABLED, map.getBooleanValue("duple"));
|
||||
}
|
||||
if(map.get("systemUI") != null){
|
||||
isSystemUI = map.getBooleanValue("systemUI");
|
||||
}
|
||||
|
||||
} catch (TwainException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -209,7 +214,7 @@ public class Operational {
|
|||
* @throws TwainException default error
|
||||
*/
|
||||
public static R startScan(String name) throws TwainException {
|
||||
return startScan(name, false);
|
||||
return startScan(name, isSystemUI);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.aohe.show;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.resource.ClassPathResource;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
@ -10,18 +9,20 @@ import java.awt.*;
|
|||
@Slf4j
|
||||
public class IconUtil {
|
||||
public static Image getIcon() {
|
||||
ClassPathResource resource = new ClassPathResource("ah.png");
|
||||
if(FileUtil.exist(resource.getFile())){
|
||||
return Toolkit.getDefaultToolkit().getImage(resource.getPath());
|
||||
}
|
||||
String iconPath = "..\\ah.png";
|
||||
String iconPath = getProgramPathIcon();
|
||||
log.info("当前查找路径为外部:{}", FileUtil.getAbsolutePath(iconPath));
|
||||
if(!FileUtil.exist("ah.png")){
|
||||
if(!FileUtil.exist(iconPath)){
|
||||
iconPath = ResourceUtil.getResource("ah.png").getFile();
|
||||
log.info("当前查找路径为内部:{}", FileUtil.getAbsolutePath(iconPath));
|
||||
}
|
||||
|
||||
log.info("当前程序图标最终路径路径为:{}", getProgramPathIcon());
|
||||
|
||||
return Toolkit.getDefaultToolkit().getImage(iconPath);
|
||||
}
|
||||
|
||||
public static String getProgramPathIcon(){
|
||||
String resource = ResourceUtil.getResource("ah.png").getFile();
|
||||
String absolutePath = FileUtil.getAbsolutePath(resource);
|
||||
return absolutePath.replace("twain-service.exe!/", "");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue