|
@ -821,48 +821,41 @@ public class QuestionService implements IQuestionService { |
|
|
int y = (maxY.value + minY.value) / 2; |
|
|
int y = (maxY.value + minY.value) / 2; |
|
|
String centreCoordinate = x + "," + y; |
|
|
String centreCoordinate = x + "," + y; |
|
|
parameter.setCentreCoordinate(centreCoordinate); |
|
|
parameter.setCentreCoordinate(centreCoordinate); |
|
|
parameter.setShowCentreCoordinate((x-centerX) + "," + (y-centerY)); |
|
|
|
|
|
// TODO 重心
|
|
|
// TODO 重心
|
|
|
parameter.setBarycenterCoordinate(centreCoordinate); |
|
|
parameter.setBarycenterCoordinate(centreCoordinate); |
|
|
//最小长方形面积
|
|
|
//最小长方形面积
|
|
|
double acreage = (maxX.value - minX.value) * (maxY.value - minY.value); |
|
|
double acreage = (maxX.value - minX.value) * (maxY.value - minY.value); |
|
|
parameter.setMinRectangleAcreage(acreage); |
|
|
parameter.setMinRectangleAcreage(acreage); |
|
|
|
|
|
// 最小圆面积 距离中心最远点-->最小长方形长宽一半的平均数
|
|
|
|
|
|
double radius = ((double)(maxX.value - minX.value + maxY.value - minY.value)) /2 /2; |
|
|
|
|
|
parameter.setMinCircleAcreage(new BigDecimal(Math.PI * radius * radius).setScale(2, BigDecimal.ROUND_HALF_UP)); |
|
|
|
|
|
|
|
|
// 计算四个边界点构成的长方形距离画板重心的距离
|
|
|
// 四个边界点 四舍五入 sqrt
|
|
|
|
|
|
setFourPoint(canvasPoints, minX, maxX, minY, maxY); |
|
|
|
|
|
log.info("half:{}",half); |
|
|
|
|
|
|
|
|
// 四个边界点 + 最小圆面积 四舍五入 sqrt
|
|
|
|
|
|
int radiusSqrt = setFourPoint(canvasPoints, minX, maxX, minY, maxY, x, y); |
|
|
|
|
|
parameter.setMinCircleAcreage(new BigDecimal(Math.PI * radiusSqrt).setScale(2, BigDecimal.ROUND_HALF_UP)); |
|
|
|
|
|
|
|
|
|
|
|
log.info("half:",half); |
|
|
|
|
|
|
|
|
|
|
|
if (half) { |
|
|
if (half) { |
|
|
|
|
|
parameter.setShowCentreCoordinate(new QuestionVo.Coordinate(y-centerY, x-centerX )); |
|
|
// x:-y, y:x
|
|
|
// x:y, y:x
|
|
|
parameter.setTop(new QuestionVo.Coordinate(maxY.y - centerY, maxY.x - centerX )); |
|
|
parameter.setTop(new QuestionVo.Coordinate(maxY.y - centerY, maxY.x - centerX )); |
|
|
parameter.setBottom(new QuestionVo.Coordinate(minY.y - centerY, minY.x - centerX)); |
|
|
parameter.setBottom(new QuestionVo.Coordinate(minY.y - centerY, minY.x - centerX)); |
|
|
parameter.setLeft(new QuestionVo.Coordinate(minX.y - centerY, minX.x - centerX)); |
|
|
parameter.setLeft(new QuestionVo.Coordinate(minX.y - centerY, minX.x - centerX)); |
|
|
parameter.setRight(new QuestionVo.Coordinate(maxX.y - centerY, maxX.x - centerX)); |
|
|
parameter.setRight(new QuestionVo.Coordinate(maxX.y - centerY, maxX.x - centerX)); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
parameter.setShowCentreCoordinate(new QuestionVo.Coordinate(centerX - x, y - centerY)); |
|
|
parameter.setTop(new QuestionVo.Coordinate(centerX - maxY.x , maxY.y - centerY)); |
|
|
parameter.setTop(new QuestionVo.Coordinate(centerX - maxY.x , maxY.y - centerY)); |
|
|
parameter.setBottom(new QuestionVo.Coordinate(centerX - minY.x, minY.y - centerY)); |
|
|
parameter.setBottom(new QuestionVo.Coordinate(centerX - minY.x, minY.y - centerY)); |
|
|
parameter.setLeft(new QuestionVo.Coordinate(centerX - minX.x , minX.y - centerY)); |
|
|
parameter.setLeft(new QuestionVo.Coordinate(centerX - minX.x , minX.y - centerY)); |
|
|
parameter.setRight(new QuestionVo.Coordinate(centerX - maxX.x , maxX.y - centerY)); |
|
|
parameter.setRight(new QuestionVo.Coordinate(centerX - maxX.x , maxX.y - centerY)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
log.info("上:{},{};{},{}",maxY.x, maxY.y, parameter.getTop().getX(), parameter.getTop().getY()); |
|
|
|
|
|
log.info("下:{},{};{},{}",minY.x, minY.y, parameter.getBottom().getX(), parameter.getBottom().getY()); |
|
|
|
|
|
log.info("左:{},{};{},{}",minX.x, minX.y, parameter.getLeft().getX(), parameter.getLeft().getY()); |
|
|
|
|
|
log.info("右:{},{};{},{}",maxX.x, maxX.y, parameter.getRight().getX(), parameter.getRight().getY()); |
|
|
|
|
|
//平均长度
|
|
|
//平均长度
|
|
|
BigDecimal aveLength = BigDecimal.valueOf(totalLength / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP); |
|
|
BigDecimal aveLength = BigDecimal.valueOf(totalLength / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP); |
|
|
BigDecimal aveReflectOnTime = BigDecimal.valueOf(reflectOnTime / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP); |
|
|
BigDecimal aveReflectOnTime = BigDecimal.valueOf(reflectOnTime / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP); |
|
|
parameter.setAveLength(aveLength.doubleValue()); |
|
|
parameter.setAveLength(aveLength.doubleValue()); |
|
|
parameter.setAveReflectOnTime(aveReflectOnTime.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
parameter.setAveReflectOnTime(aveReflectOnTime.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
//短笔画数量
|
|
|
//短笔画数量
|
|
|
// double coefficient = 1.00;
|
|
|
|
|
|
BigDecimal referenceLength = param.getReferenceLength() != null && param.getReferenceLength().compareTo(new BigDecimal(0)) > 0 ? param.getReferenceLength() : aveLength; |
|
|
BigDecimal referenceLength = param.getReferenceLength() != null && param.getReferenceLength().compareTo(new BigDecimal(0)) > 0 ? param.getReferenceLength() : aveLength; |
|
|
BigDecimal referenceReflectOnTime = param.getReferenceReflectOnTime() != null && param.getReferenceReflectOnTime().compareTo(new BigDecimal(0)) > 0 ? param.getReferenceReflectOnTime() : aveReflectOnTime; |
|
|
BigDecimal referenceReflectOnTime = param.getReferenceReflectOnTime() != null && param.getReferenceReflectOnTime().compareTo(new BigDecimal(0)) > 0 ? param.getReferenceReflectOnTime() : aveReflectOnTime; |
|
|
|
|
|
|
|
@ -884,12 +877,9 @@ public class QuestionService implements IQuestionService { |
|
|
* @param maxX 最右点 |
|
|
* @param maxX 最右点 |
|
|
* @param minY 最上点 |
|
|
* @param minY 最上点 |
|
|
* @param maxY 最下点 |
|
|
* @param maxY 最下点 |
|
|
* @param x 中心点 x |
|
|
|
|
|
* @param y 中心点 y |
|
|
|
|
|
* @return 点到中心点距离的平方的最大值 |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
private int setFourPoint(List<QuestionVo.Point> canvasPoints, PointPosition minX, PointPosition maxX, PointPosition minY, PointPosition maxY, int x, int y) { |
|
|
private void setFourPoint(List<QuestionVo.Point> canvasPoints, PointPosition minX, PointPosition maxX, PointPosition minY, PointPosition maxY) { |
|
|
int max = 0; |
|
|
// int max = 0;
|
|
|
for (int i = 0; i < canvasPoints.size(); i++) { |
|
|
for (int i = 0; i < canvasPoints.size(); i++) { |
|
|
QuestionVo.Point point = canvasPoints.get(i); |
|
|
QuestionVo.Point point = canvasPoints.get(i); |
|
|
if (StrUtil.isEmpty(point.getValue())) { |
|
|
if (StrUtil.isEmpty(point.getValue())) { |
|
@ -920,13 +910,13 @@ public class QuestionService implements IQuestionService { |
|
|
if (strArr == null || strArr.length < 2) { |
|
|
if (strArr == null || strArr.length < 2) { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
int pointX = Integer.parseInt(strArr[0]); |
|
|
// int pointX = Integer.parseInt(strArr[0]);
|
|
|
int pointY = Integer.parseInt(strArr[1]); |
|
|
// int pointY = Integer.parseInt(strArr[1]);
|
|
|
max = (int) Math.max(max, Math.pow(pointX-x, 2) + Math.pow(pointY - y, 2)); |
|
|
// max = (int) Math.max(max, Math.pow(pointX-x, 2) + Math.pow(pointY - y, 2));
|
|
|
} |
|
|
} |
|
|
point.setValue(StringUtils.join(pointArr, ";")); |
|
|
point.setValue(StringUtils.join(pointArr, ";")); |
|
|
} |
|
|
} |
|
|
return max; |
|
|
// return max;
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -938,44 +928,75 @@ public class QuestionService implements IQuestionService { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取短笔画的数量 |
|
|
* 获取短笔画的数量 |
|
|
* |
|
|
* 标志线条为长/短线条 快/慢思考 |
|
|
* |
|
|
* 计算最长、最短线条的速度 |
|
|
|
|
|
* 过渡时间(在所有短-长笔画序列中画出一个短笔划后开始一个长笔划的总时间) |
|
|
|
|
|
* 5个早期长笔画的经过时间(从点击开始绘图至前5个长笔画绘制完成) |
|
|
|
|
|
* 前5笔长笔画率(前5个笔画中长笔画所占比率) |
|
|
* @param aveLength 参考长度 |
|
|
* @param aveLength 参考长度 |
|
|
* @param referenceReflectOnTime 参考思考时间 |
|
|
* @param referenceReflectOnTime 参考思考时间 |
|
|
* @param lineParameterList 所有笔画的参数 |
|
|
* @param lineParameterList 所有笔画的参数 |
|
|
* @param longIndex |
|
|
* @param longIndex 长笔画序号 |
|
|
* @param shortIndex |
|
|
* @param shortIndex 短笔画序号 |
|
|
* @param parameter |
|
|
* @param parameter 参数 |
|
|
* @return 返回短笔画的数量 |
|
|
* @return 返回短笔画的数量 |
|
|
*/ |
|
|
*/ |
|
|
private Nums getShortNums(BigDecimal aveLength, BigDecimal referenceReflectOnTime, List<QuestionVo.LineParameter> lineParameterList, int longIndex, int shortIndex, QuestionVo.Parameter parameter) { |
|
|
private Nums getShortNums(BigDecimal aveLength, BigDecimal referenceReflectOnTime, List<QuestionVo.LineParameter> lineParameterList, int longIndex, int shortIndex, QuestionVo.Parameter parameter) { |
|
|
Nums nums = new Nums(); |
|
|
Nums nums = new Nums(); |
|
|
|
|
|
// 短笔画数
|
|
|
int shortNums = 0; |
|
|
int shortNums = 0; |
|
|
|
|
|
// 长笔画数
|
|
|
int quickNums = 0; |
|
|
int quickNums = 0; |
|
|
// double a = aveLength * coefficient;
|
|
|
// 前5个长笔画的时间
|
|
|
|
|
|
int longLineCount = 5; |
|
|
|
|
|
int longLineIndex = 0; |
|
|
|
|
|
// 统计前5条线中长笔画的数量
|
|
|
|
|
|
int lineCount = 5; |
|
|
|
|
|
int lineIndex = 0; |
|
|
if(CollectionUtil.isNotEmpty(lineParameterList)){ |
|
|
if(CollectionUtil.isNotEmpty(lineParameterList)){ |
|
|
for (int i = 0; i < lineParameterList.size(); i++) { |
|
|
for (int i = 0; i < lineParameterList.size(); i++) { |
|
|
|
|
|
|
|
|
QuestionVo.LineParameter lineParameter = lineParameterList.get(i); |
|
|
QuestionVo.LineParameter lineParameter = lineParameterList.get(i); |
|
|
|
|
|
// 长短笔画
|
|
|
if(aveLength.compareTo(new BigDecimal(lineParameter.getLength())) >= 0){ |
|
|
if(aveLength.compareTo(new BigDecimal(lineParameter.getLength())) >= 0){ |
|
|
lineParameter.setLengthStatus(Constant.LineColour.LENGTH_STATUS_SHORT); |
|
|
lineParameter.setLengthStatus(Constant.LineColour.LENGTH_STATUS_SHORT); |
|
|
shortNums++; |
|
|
shortNums++; |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
// 长笔画
|
|
|
lineParameter.setLengthStatus(Constant.LineColour.LENGTH_STATUS_LONG); |
|
|
lineParameter.setLengthStatus(Constant.LineColour.LENGTH_STATUS_LONG); |
|
|
|
|
|
// 判断前一笔是否是短笔画,如果是,计算过渡时间
|
|
|
|
|
|
if (i > 0 && lineParameterList.get(i-1).getLengthStatus() == Constant.LineColour.LENGTH_STATUS_SHORT) { |
|
|
|
|
|
parameter.setTransitionTime(parameter.getTransitionTime() + lineParameter.getIntervalDuration()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
longLineIndex++; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
// 计算前5个长笔画的耗时
|
|
|
|
|
|
if (longLineIndex <= longLineCount) { |
|
|
|
|
|
parameter.setFiveLongLinesTime(parameter.getFiveLongLinesTime() + lineParameter.getIntervalDuration() + lineParameter.getDuration()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 快慢思考
|
|
|
if(referenceReflectOnTime.compareTo(new BigDecimal(lineParameter.getIntervalDuration())) >= 0){ |
|
|
if(referenceReflectOnTime.compareTo(new BigDecimal(lineParameter.getIntervalDuration())) >= 0){ |
|
|
lineParameter.setReflectOnStatus(Constant.LineColour.REFLECT_ON_STATUS_QUICK); |
|
|
lineParameter.setReflectOnStatus(Constant.LineColour.REFLECT_ON_STATUS_QUICK); |
|
|
quickNums++; |
|
|
quickNums++; |
|
|
} else { |
|
|
} else { |
|
|
lineParameter.setReflectOnStatus(Constant.LineColour.REFLECT_ON_STATUS_SLOW); |
|
|
lineParameter.setReflectOnStatus(Constant.LineColour.REFLECT_ON_STATUS_SLOW); |
|
|
} |
|
|
} |
|
|
|
|
|
// 最长/短笔画速度
|
|
|
if (longIndex == i) { |
|
|
if (longIndex == i) { |
|
|
parameter.setLongSpeed(lineParameter.getSpeed()); |
|
|
parameter.setLongSpeed(lineParameter.getSpeed()); |
|
|
} |
|
|
} |
|
|
if (shortIndex == i) { |
|
|
if (shortIndex == i) { |
|
|
parameter.setShortSpeed(lineParameter.getSpeed()); |
|
|
parameter.setShortSpeed(lineParameter.getSpeed()); |
|
|
} |
|
|
} |
|
|
|
|
|
lineIndex++; |
|
|
|
|
|
// 第5条线时,计算长线段的比例
|
|
|
|
|
|
if (lineIndex == lineCount) { |
|
|
|
|
|
parameter.setLongLineRate(new BigDecimal(longLineIndex).divide(new BigDecimal(lineCount))); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
nums.shortNums = shortNums; |
|
|
nums.shortNums = shortNums; |
|
|