Skip to content

Commit 7ff6747

Browse files
Source code maintenance
*New Dijkstra *New HammeringDistance *New EditDistance *The Route22DDrawingLauncher2 second generation 2D image interface is added. The integrator will automatically determine whether your initiator is the second generation and start the corresponding logic function. *Modify the document and reconstruct the interface *Insert 2D coordinate interface *Insert 3D coordinate interface *DoubleRoute2DNet has implemented Route22DDrawingLauncher2 can implement multi color annotation *ZhaoCoordinatenet2D algorithm has been implemented Route22DDrawingLauncher2 can implement multi color annotation
1 parent 153c90c commit 7ff6747

39 files changed

+1915
-173
lines changed

src_code/src/main/java/zhao/algorithmMagic/Integrator/Route2DDrawingIntegrator.java

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package zhao.algorithmMagic.Integrator;
22

3+
import org.apache.log4j.Logger;
34
import zhao.algorithmMagic.Integrator.launcher.Route2DDrawingLauncher;
5+
import zhao.algorithmMagic.Integrator.launcher.Route2DDrawingLauncher2;
46
import zhao.algorithmMagic.algorithm.OperationAlgorithm;
57
import zhao.algorithmMagic.algorithm.OperationAlgorithmManager;
68
import zhao.algorithmMagic.exception.OperatorOperationException;
79
import zhao.algorithmMagic.exception.TargetNotRealizedException;
8-
import zhao.algorithmMagic.operands.coordinate.DoubleCoordinateTwo;
9-
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
10+
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinateTwo;
11+
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute2D;
1012
import zhao.algorithmMagic.utils.ASClass;
1113
import zhao.algorithmMagic.utils.ASIO;
1214

@@ -28,6 +30,7 @@
2830
*/
2931
public class Route2DDrawingIntegrator implements AlgorithmIntegrator<Route2DDrawingIntegrator> {
3032

33+
private final Logger logger;
3134
private final String IntegratorName;
3235
private final Route2DDrawingLauncher route2DDrawingStarter;
3336
private String imageOutPath = "image.jpg";
@@ -49,6 +52,9 @@ public class Route2DDrawingIntegrator implements AlgorithmIntegrator<Route2DDraw
4952
*/
5053
public Route2DDrawingIntegrator(String integratorName, String AlgorithmLauncherName) {
5154
IntegratorName = integratorName;
55+
logger = Logger.getLogger(integratorName);
56+
logger.info("+======================================= << " + this.IntegratorName + " >> started =============================================+");
57+
logger.info("+--------------------------------------- << Extract the algorithm required by the integrator >> ---------------------------------------+");
5258
OperationAlgorithm operationAlgorithm = OperationAlgorithmManager.getInstance().get(AlgorithmLauncherName);
5359
if (operationAlgorithm instanceof Route2DDrawingLauncher) {
5460
this.route2DDrawingStarter = ASClass.transform(operationAlgorithm);
@@ -65,6 +71,7 @@ public Route2DDrawingIntegrator(String integratorName, String AlgorithmLauncherN
6571
public Route2DDrawingIntegrator(String integratorName, Route2DDrawingLauncher route2DDrawingLauncher) {
6672
this.IntegratorName = integratorName;
6773
this.route2DDrawingStarter = route2DDrawingLauncher;
74+
logger = Logger.getLogger(integratorName);
6875
}
6976

7077
/**
@@ -117,7 +124,7 @@ public int getDiscreteThreshold() {
117124
/**
118125
* 设置离散阈值,该阈值越大,路线显示越清晰,该阈值可以扩大整个2维空间的显示,默认是 1
119126
* <p>
120-
* Set the discrete threshold, the larger the threshold, the clearer the route display, the threshold can expand the display of the entire 2-dimensional space, the default is 1
127+
* Set the discrete threshold, the larger the threshold, the clearer the route display, the threshold can extend the display of the entire 2-dimensional space, the default is 1
121128
*
122129
* @param discreteThreshold 新的离散阈值
123130
* @return 链式
@@ -145,6 +152,7 @@ public void setBackColor(Color backColor) {
145152

146153
@Override
147154
public boolean run() {
155+
logger.info("+--------------------------------------- << Build Picture >> ---------------------------------------+");
148156
// 创建一个图片
149157
BufferedImage image = new BufferedImage(this.imageWidth, this.imageHeight, BufferedImage.TYPE_INT_RGB);
150158
// 准备绘图工具
@@ -153,16 +161,50 @@ public boolean run() {
153161
g.setBackground(backColor);
154162
g.clearRect(0, 0, this.imageWidth, this.imageHeight);
155163
g.translate(this.imageWidth >> 1, this.imageHeight >> 1);
164+
// 集成第二版接口
165+
run1(g);
156166
// 迭代每一个坐标点
157-
for (DoubleConsanguinityRoute2D value : this.route2DDrawingStarter.AcquireImageDataSet().values()) {
167+
for (IntegerConsanguinityRoute2D value : this.route2DDrawingStarter.AcquireImageDataSet().values()) {
158168
// 获取一个路线的起始坐标与终止坐标对象
159169
drawARoute(g, value.getStartingCoordinateName(), value.getEndPointCoordinateName(), value.getStartingCoordinate(), value.getEndPointCoordinate());
160170
}
171+
// 集成第二版接口
172+
run2(g);
161173
// 将图片对象输出到指定的路径下!
162174
ASIO.outImage(image, this.imageOutPath);
175+
logger.info("+--------------------------------------- << output Picture >> ---------------------------------------+");
176+
logger.info("+======================================= << " + this.IntegratorName + " >> stopped =============================================+");
163177
return true;
164178
}
165179

180+
/**
181+
* 附加任务函数执行题,为了弥补绘图器不够灵活的缺陷,2022年10月16日新增了一个附加任务接口,该接口将会在旧接口的任务执行之前调用
182+
*
183+
* @param graphics2D 画笔对象
184+
*/
185+
private void run1(Graphics2D graphics2D) {
186+
// 第二版接口的附加任务启动
187+
if (this.route2DDrawingStarter instanceof Route2DDrawingLauncher2) {
188+
logger.info("+ >>> Start the first task (unique to the second version interface)");
189+
Route2DDrawingLauncher2 dDrawingStarter = (Route2DDrawingLauncher2) this.route2DDrawingStarter;
190+
dDrawingStarter.AdditionalTasks1(graphics2D, this);
191+
}
192+
}
193+
194+
/**
195+
* 附加任务函数执行题,为了弥补绘图器不够灵活的缺陷,2022年10月16日新增了一个附加任务接口,该接口将会在旧接口的任务执行之后调用
196+
*
197+
* @param graphics2D 画笔对象
198+
*/
199+
private void run2(Graphics2D graphics2D) {
200+
// 第二版接口的附加任务启动
201+
if (this.route2DDrawingStarter instanceof Route2DDrawingLauncher2) {
202+
logger.info("+ >>> Start the second task (unique to the second version interface)");
203+
Route2DDrawingLauncher2 dDrawingStarter = (Route2DDrawingLauncher2) this.route2DDrawingStarter;
204+
dDrawingStarter.AdditionalTasks2(graphics2D, this);
205+
}
206+
}
207+
166208
/**
167209
* 绘制一个路线
168210
*
@@ -172,12 +214,13 @@ public boolean run() {
172214
* @param startingCoordinate 起始坐标对象
173215
* @param endPointCoordinate 终止坐标对象
174216
*/
175-
private void drawARoute(Graphics2D graphics2D, String startName, String endName, DoubleCoordinateTwo startingCoordinate, DoubleCoordinateTwo endPointCoordinate) {
217+
public void drawARoute(Graphics2D graphics2D, String startName, String endName, IntegerCoordinateTwo startingCoordinate, IntegerCoordinateTwo endPointCoordinate) {
218+
logger.info("+ Draw a circuit " + startName + " -> " + endName);
176219
// 开始绘制
177-
int startX = startingCoordinate.getX().intValue() << this.discreteThreshold;
178-
int startY = -startingCoordinate.getY().intValue() << this.discreteThreshold;
179-
int endX = endPointCoordinate.getX().intValue() << this.discreteThreshold;
180-
int endY = -endPointCoordinate.getY().intValue() << this.discreteThreshold;
220+
int startX = startingCoordinate.getX() << this.discreteThreshold;
221+
int startY = -startingCoordinate.getY() << this.discreteThreshold;
222+
int endX = endPointCoordinate.getX() << this.discreteThreshold;
223+
int endY = -endPointCoordinate.getY() << this.discreteThreshold;
181224
graphics2D.drawLine(startX, startY, endX, endY);
182225
graphics2D.drawString(startName, startX + 1, startY + 1);
183226
graphics2D.drawString(endName, endX + 1, endY + 1);

src_code/src/main/java/zhao/algorithmMagic/Integrator/launcher/Route2DDrawingLauncher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package zhao.algorithmMagic.Integrator.launcher;
22

3-
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
3+
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute2D;
44

55
import java.util.HashMap;
66

@@ -22,7 +22,7 @@ public interface Route2DDrawingLauncher extends Launcher<Route2DDrawingLauncher>
2222
*
2323
* @return 图像数据集 image dataset
2424
*/
25-
HashMap<String, DoubleConsanguinityRoute2D> AcquireImageDataSet();
25+
HashMap<String, IntegerConsanguinityRoute2D> AcquireImageDataSet();
2626

2727
/**
2828
* 如果您在这里设置支持绘图,那么请您在"AcquireImageDataSet"中进行数据集的返回,如果您设置的是false,那么您的"AcquireImageDataSet"只需要返回一个null即可.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package zhao.algorithmMagic.Integrator.launcher;
2+
3+
import zhao.algorithmMagic.Integrator.Route2DDrawingIntegrator;
4+
5+
import java.awt.*;
6+
7+
/**
8+
* Java类于 2022/10/16 12:38:20 创建
9+
* <p>
10+
* 路线绘图 2D 集成器,实现此集成器的类,可以给予给Route2DDrawingIntegrator去进行后期处理,生成需要的图像。
11+
* <p>
12+
* The route drawing 2D integrator, the class that implements this integrator, can be given to Route2DDrawingIntegrator for post-processing to generate the required images.
13+
*
14+
* @author zhao
15+
*/
16+
public interface Route2DDrawingLauncher2 extends Route2DDrawingLauncher {
17+
18+
/**
19+
* 附加任务函数执行题,为了弥补绘图器不够灵活的缺陷,2022年10月16日新增了一个附加任务接口,该接口将会在旧接口的任务执行之前调用
20+
* <p>
21+
* Additional task function execution question, in order to make up for the inflexibility of the plotter, an additional task interface was added on October 16, 2022, which will be called before the task execution of the old interface
22+
*
23+
* @param graphics2D 绘图时的画笔对象,由绘图器传递,您可以在这里准备绘图器的更多设置与操作.
24+
* @param route2DDrawingIntegrator 绘图集成器对象,您可以再附加任务中对集成器进行灵活操作!
25+
* <p>
26+
* Drawing integrator object, you can flexibly operate the integrator in additional tasks!
27+
* @apiNote 第二版启动器接口中的特有函数, 允许用户在实现2维绘图接口的时候获取到绘图笔对象, 用户将此接口当作父类去使用, 绘图器会自动分析您的接口版本.
28+
* <p>
29+
* The unique function in the second version of the launcher interface allows the user to obtain the drawing pen object when implementing the 2D drawing interface. The user uses this interface as a parent class, and the drawer will automatically analyze your interface version.
30+
*/
31+
void AdditionalTasks1(Graphics2D graphics2D, Route2DDrawingIntegrator route2DDrawingIntegrator);
32+
33+
/**
34+
* 附加任务函数执行题,为了弥补绘图器不够灵活的缺陷,2022年10月16日新增了一个附加任务接口,该接口将会在旧接口的任务执行完调用.
35+
* <p>
36+
* Additional task function execution question, in order to make up for the inflexibility of the plotter, an additional task interface was added on October 16, 2022, which will be called after the task execution of the old interface.
37+
*
38+
* @param graphics2D 绘图时的画笔对象,由绘图器传递,您可以在这里准备绘图器的更多设置与操作.
39+
* @param route2DDrawingIntegrator 绘图集成器对象,您可以再附加任务中对集成器进行灵活操作!
40+
* <p>
41+
* Drawing integrator object, you can flexibly operate the integrator in additional tasks!
42+
* @apiNote 第二版启动器接口中的特有函数, 允许用户在实现2维绘图接口的时候获取到绘图笔对象, 用户将此接口当作父类去使用, 绘图器会自动分析您的接口版本.
43+
* <p>
44+
* The unique function in the second version of the launcher interface allows the user to obtain the drawing pen object when implementing the 2D drawing interface. The user uses this interface as a parent class, and the drawer will automatically analyze your interface version.
45+
*/
46+
void AdditionalTasks2(Graphics2D graphics2D, Route2DDrawingIntegrator route2DDrawingIntegrator);
47+
}

src_code/src/main/java/zhao/algorithmMagic/MAIN.scala

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,5 @@ package zhao.algorithmMagic
55
*/
66
object MAIN {
77
def main(args: Array[String]): Unit = {
8-
// 构建人员坐标(二维)
9-
val A = new DoubleCoordinateMany(10, 10)
10-
val B = new DoubleCoordinateMany(-10, 4)
11-
val C = new DoubleCoordinateMany(1, 0)
12-
val E = new DoubleCoordinateMany(6, 1)
13-
val Z = new DoubleCoordinateMany(1, 21)
14-
15-
// 获取关系网络,该算法是我实现出来,用于推断人员关系网的,这里的名称您可以自定义,需要注意的是下面集成器的实例化需要您将该名称传进去
16-
// 将所有人员的关系添加到关系网络中
17-
val zhaoCoordinateNet = ZhaoCoordinateNet.getInstance("Z")
18-
// 将人员的关系添加到关系网络中,请注意,该算法的关系网络已经包含了您的数据,所以您在下面集成其中一定要传入相同名称,以便集成器能获取到您算法中的临时网格数据
19-
zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute.parse("A -> B", A, B))
20-
zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute.parse("A -> C", A, C))
21-
zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute.parse("E -> Z", E, Z))
22-
zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute.parse("A -> Z", A, Z))
23-
zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute.parse("B -> Z", B, Z))
24-
25-
// 使用2维路线绘制集成器,输出上面所有人员之间的关系网络图片
26-
val r: Route2DDrawingIntegrator = new Route2DDrawingIntegrator("Z", "A")
27-
// 设置图片输出路径
28-
r.setImageOutPath("D:\\out\\image.jpg")
29-
.setImageWidth(1000) // 设置图片宽度
30-
.setImageHeight(1000) // 设置图片高度
31-
.setDiscreteThreshold(3) // 设置离散阈值,用来放大微小的变化
32-
.run // 运行集成器!
33-
34-
// 清理关系网络中的数据
35-
zhaoCoordinateNet.clear()
368
}
379
}
Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,44 @@
11
package zhao.algorithmMagic;
22

3-
//import zhao.algorithmMagic.Integrator.Route2DDrawingIntegrator;
4-
//import zhao.algorithmMagic.algorithm.generatingAlgorithm.ZhaoCoordinatenet2D;
5-
//import zhao.algorithmMagic.operands.coordinate.DoubleCoordinateTwo;
6-
//import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
3+
import zhao.algorithmMagic.Integrator.Route2DDrawingIntegrator;
4+
import zhao.algorithmMagic.algorithm.generatingAlgorithm.ZhaoCoordinateNet2D;
5+
import zhao.algorithmMagic.operands.coordinate.DoubleCoordinateTwo;
6+
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
77

88
/**
99
* 示例代码文件
1010
*/
1111
public class MAIN1 {
1212
public static void main(String[] args) {
13-
// // 构建人员坐标(二维)
14-
// DoubleCoordinateTwo A = new DoubleCoordinateTwo(10, 10);
15-
// DoubleCoordinateTwo B = new DoubleCoordinateTwo(-10, 4);
16-
// DoubleCoordinateTwo C = new DoubleCoordinateTwo(1, 0);
17-
// DoubleCoordinateTwo E = new DoubleCoordinateTwo(6, 1);
18-
// DoubleCoordinateTwo Z = new DoubleCoordinateTwo(1, 21);
19-
// DoubleCoordinateTwo ZHAO = new DoubleCoordinateTwo(-10, -30);
20-
//
21-
// // 获取关系网络,该算法是我实现出来,用于推断人员关系网的,这里的名称您可以自定义,需要注意的是下面集成器的实例化需要您将该名称传进去
22-
// ZhaoCoordinatenet2D zhaoCoordinateNet = ZhaoCoordinatenet2D.getInstance("Z");
23-
// zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute2D.parse("A -> B", A, B)); // Representing A takes the initiative to know B
24-
// zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute2D.parse("A -> C", A, C));
25-
// zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute2D.parse("E -> Z", E, Z));
26-
// zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute2D.parse("A -> Z", A, Z));
27-
// zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute2D.parse("B -> Z", B, Z));
28-
// zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute2D.parse("B -> ZHAO", B, ZHAO));
29-
//
30-
// // 使用2维路线绘制集成器,输出上面所有人员之间的关系网络图片
31-
// Route2DDrawingIntegrator a = new Route2DDrawingIntegrator("A", "Z");
32-
// // 设置图片输出路径
33-
// a.setImageOutPath("D:\\out\\image.jpg")
34-
// // 设置图片宽度
35-
// .setImageWidth(1000)
36-
// // 设置图片高度
37-
// .setImageHeight(1000)
38-
// // 设置离散阈值,用来放大微小的变化
39-
// .setDiscreteThreshold(4)
40-
// // 运行集成器!
41-
// .run();
42-
//
43-
// // 清理关系网络中的数据
44-
// zhaoCoordinateNet.clear();
13+
// 构建人员坐标(二维)
14+
DoubleCoordinateTwo A = new DoubleCoordinateTwo(10, 10);
15+
DoubleCoordinateTwo B = new DoubleCoordinateTwo(-10, 4);
16+
DoubleCoordinateTwo C = new DoubleCoordinateTwo(1, 0);
17+
DoubleCoordinateTwo E = new DoubleCoordinateTwo(6, 1);
18+
DoubleCoordinateTwo Z = new DoubleCoordinateTwo(1, 21);
19+
20+
// 获取关系网络,该算法是我实现出来,用于推断人员关系网的,这里的名称您可以自定义,需要注意的是下面集成器的实例化需要您将该名称传进去
21+
ZhaoCoordinateNet2D zhaoCoordinateNet = ZhaoCoordinateNet2D.getInstance("Z");
22+
zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute2D.parse("A -> B", A, B)); // Representing A takes the initiative to know B
23+
zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute2D.parse("A -> C", A, C));
24+
zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute2D.parse("E -> Z", E, Z));
25+
zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute2D.parse("A -> Z", A, Z));
26+
zhaoCoordinateNet.addRoute(DoubleConsanguinityRoute2D.parse("B -> Z", B, Z));
27+
28+
// 使用2维路线绘制集成器,输出上面所有人员之间的关系网络图片
29+
Route2DDrawingIntegrator a = new Route2DDrawingIntegrator("A", "Z");
30+
// 设置图片输出路径
31+
a.setImageOutPath("D:\\out\\image.jpg")
32+
// 设置图片宽度
33+
.setImageWidth(1000)
34+
// 设置图片高度
35+
.setImageHeight(1000)
36+
// 设置离散阈值,用来放大微小的变化
37+
.setDiscreteThreshold(4)
38+
// 运行集成器!
39+
.run();
40+
41+
// 清理关系网络中的数据
42+
zhaoCoordinateNet.clear();
4543
}
46-
}
44+
}

0 commit comments

Comments
 (0)