|
|
|
@ -7,11 +7,7 @@ import xyz.wbsite.jmacro.base.Legend;
|
|
|
|
|
import xyz.wbsite.jmacro.base.ViewColor;
|
|
|
|
|
import xyz.wbsite.jmacro.base.ViewPoint;
|
|
|
|
|
import xyz.wbsite.jmacro.base.ViewRect;
|
|
|
|
|
import xyz.wbsite.jmacro.util.ValueUtil;
|
|
|
|
|
import xyz.wbsite.jmacro.util.ColorUtil;
|
|
|
|
|
import xyz.wbsite.jmacro.util.ImageUtil;
|
|
|
|
|
import xyz.wbsite.jmacro.util.Logger;
|
|
|
|
|
import xyz.wbsite.jmacro.util.TaskUtil;
|
|
|
|
|
import xyz.wbsite.jmacro.util.*;
|
|
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.awt.event.InputEvent;
|
|
|
|
@ -537,6 +533,82 @@ public abstract class JMacro {
|
|
|
|
|
}, seconds, TimeUnit.SECONDS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 聚焦区域查找图例并点击
|
|
|
|
|
*
|
|
|
|
|
* @param legend 图例
|
|
|
|
|
* @param minSimilar 最低相似度
|
|
|
|
|
* @return 匹配区域
|
|
|
|
|
*/
|
|
|
|
|
public boolean findLegendAndClick(String legend, double minSimilar) {
|
|
|
|
|
ViewRect matchLegend = matchLegend(legend, minSimilar);
|
|
|
|
|
if (matchLegend != null) {
|
|
|
|
|
Logger.info("点击【{}】", legend);
|
|
|
|
|
mouseLeftClick(matchLegend);
|
|
|
|
|
delay(500);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 聚焦区域查找图例并点击
|
|
|
|
|
*
|
|
|
|
|
* @param legend 图例
|
|
|
|
|
* @param minSimilar 最低相似度
|
|
|
|
|
* @return 匹配区域
|
|
|
|
|
*/
|
|
|
|
|
public boolean findLegendAndClick(Legend legend, double minSimilar) {
|
|
|
|
|
ViewRect matchLegend = matchLegend(legend, minSimilar);
|
|
|
|
|
if (matchLegend != null) {
|
|
|
|
|
Logger.info("点击【{}】", legend);
|
|
|
|
|
mouseLeftClick(matchLegend);
|
|
|
|
|
delay(500);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 指定区域查找图例并点击
|
|
|
|
|
*
|
|
|
|
|
* @param legend 图例
|
|
|
|
|
* @param minSimilar 最低相似度
|
|
|
|
|
* @return 匹配区域
|
|
|
|
|
*/
|
|
|
|
|
public boolean findLegendAndClick(ViewRect rect, String legend, double minSimilar) {
|
|
|
|
|
ViewRect matchLegend = findLegend(rect, legend, minSimilar);
|
|
|
|
|
if (matchLegend != null) {
|
|
|
|
|
Logger.info("点击【{}】", legend);
|
|
|
|
|
mouseLeftClick(matchLegend);
|
|
|
|
|
delay(500);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 指定区域查找图例并点击
|
|
|
|
|
*
|
|
|
|
|
* @param legend 图例
|
|
|
|
|
* @param minSimilar 最低相似度
|
|
|
|
|
* @return 匹配区域
|
|
|
|
|
*/
|
|
|
|
|
public boolean findLegendAndClick(ViewRect rect, Legend legend, double minSimilar) {
|
|
|
|
|
ViewRect matchLegend = findLegend(rect, legend, minSimilar);
|
|
|
|
|
if (matchLegend != null) {
|
|
|
|
|
Logger.info("点击【{}】", legend);
|
|
|
|
|
mouseLeftClick(matchLegend);
|
|
|
|
|
delay(500);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查找图片
|
|
|
|
|
*
|
|
|
|
@ -562,6 +634,7 @@ public abstract class JMacro {
|
|
|
|
|
/**
|
|
|
|
|
* 查找图例
|
|
|
|
|
*
|
|
|
|
|
* @param rect 范围
|
|
|
|
|
* @param legend 图例
|
|
|
|
|
* @param minSimilar 最低相似度
|
|
|
|
|
* @return 匹配区域
|
|
|
|
@ -573,6 +646,7 @@ public abstract class JMacro {
|
|
|
|
|
/**
|
|
|
|
|
* 查找图例
|
|
|
|
|
*
|
|
|
|
|
* @param rect 范围
|
|
|
|
|
* @param legend 图例
|
|
|
|
|
* @param minSimilar 最低相似度
|
|
|
|
|
* @return 匹配区域
|
|
|
|
@ -854,7 +928,7 @@ public abstract class JMacro {
|
|
|
|
|
return new ViewRect[0];
|
|
|
|
|
}
|
|
|
|
|
Logger.info("等待并匹配图例组合:{}", String.join(",", legends));
|
|
|
|
|
return TaskUtil.timeTask(() -> {
|
|
|
|
|
ViewRect[] result = TaskUtil.timeTask(() -> {
|
|
|
|
|
while (JMainService.getInstance().run) {
|
|
|
|
|
ViewRect[] viewRects = matchLegends(legends, minSimilar);
|
|
|
|
|
for (ViewRect viewRect : viewRects) {
|
|
|
|
@ -865,6 +939,10 @@ public abstract class JMacro {
|
|
|
|
|
}
|
|
|
|
|
return new ViewRect[legends.length];
|
|
|
|
|
}, seconds, TimeUnit.SECONDS);
|
|
|
|
|
if (result == null) {
|
|
|
|
|
result = new ViewRect[legends.length];
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|