Skip to content

Commit dbb7708

Browse files
1.26版本发布
# ![image](https://user-images.githubusercontent.com/113756063/194830221-abe24fcc-484b-4769-b3b7-ec6d8138f436.png) 算法之星-机器大脑 - Switch to [English Document](https://github.com/BeardedManZhao/algorithmStar/blob/Zhao-develop/src_code/README.md) - knowledge base <a href="https://github.com/BeardedManZhao/algorithmStar/blob/main/KnowledgeDocument/knowledge%20base-Chinese.md"> <img src = "https://user-images.githubusercontent.com/113756063/194838003-7ad14dac-b38c-4b57-a942-ba58f00baaf7.png"/> </a> ### 更新日志 * 框架版本:1.25 - 1.26 * 针对诸多的序列化操作,可以通过组件的方式来实现序列化,在IO组件库中已经集成了针对序列化对象IO的组件,下面就是一个示例。 ```java package zhao.algorithmMagic; import zhao.algorithmMagic.io.*; import zhao.algorithmMagic.operands.table.FDataFrame; import zhao.algorithmMagic.operands.table.FinalCell; import zhao.algorithmMagic.operands.table.SFDataFrame; import zhao.algorithmMagic.operands.table.SingletonSeries; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; public class MAIN1 { public static void main(String[] args) throws IOException { // System.out.println(OperationAlgorithmManager.VERSION); // if (args.length > 0) { // ASDynamicLibrary.addDllDir(new File(args[0])); // System.out.println(OperationAlgorithmManager.getAlgorithmStarUrl()); // } else { // System.out.println("感谢您的使用。"); // } // 创建一个对象输出组件 TODO 首先需要创建对应的数据输出流 final OutputStream outputStream = new FileOutputStream("C:\\Users\\zhao\\Downloads\\test\\res"); // 然后开始构建组件 final OutputComponent outputComponent = OutputObject.builder() // 在这里将数据流装载进去 .addOutputArg(OutputObjectBuilder.OUT_STREAM, new FinalCell<>(outputStream)) .create(); // 启动组件 if (outputComponent.open()) { // 如果启动成功就创建一个 DF 对象 final FDataFrame select = SFDataFrame.select( SingletonSeries.parse("name", "age"), 1 ); select.insert("zhao", "20").insert("tang", "22") // 使用组件将 DF 对象输出 .into_outComponent(outputComponent); } // 使用完毕就关闭组件 outputComponent.close(); // 当然,TODO 您也可以通过 InputObject 对象来实现反序列化。 // 如果您不习惯通过组件实现,也可以通过Java中的序列化方式来实现。 final InputComponent inputObject = InputObject.builder() .addInputArg(InputObjectBuilder.IN_STREAM, new FinalCell<>(new FileInputStream(""))) .create(); } } ``` * 通过简单的函数实现序列化,在 DF 对象中的 into_file 系列函数中,做了一些优化,其可以在最后接收一个布尔类型的参数来代表是否使用序列化输出。 ```java package zhao.algorithmMagic; import zhao.algorithmMagic.io.InputComponent; import zhao.algorithmMagic.io.InputObject; import zhao.algorithmMagic.io.InputObjectBuilder; import zhao.algorithmMagic.operands.table.DataFrame; import zhao.algorithmMagic.operands.table.FinalCell; import zhao.algorithmMagic.operands.table.SFDataFrame; import java.io.FileInputStream; import java.io.IOException; public class MAIN1 { public static void main(String[] args) throws IOException { // 创建一个序列化数据输入组件 final InputComponent inputObject = InputObject.builder() .addInputArg(InputObjectBuilder.IN_STREAM, new FinalCell<>(new FileInputStream("C:\\Users\\zhao\\Downloads\\test\\res"))) .create(); // 从其中获取到 DF 对象 final DataFrame dataFrame = SFDataFrame.builder(inputObject); // 查看其中的数据 并通过最新的 简洁函数来实现序列化输出 dataFrame // TODO into 函数的结尾参数为 true 代表二进制输出 .into_outfile("C:\\Users\\zhao\\Downloads\\test\\res1", true) // 查看内容 .show(); // TODO 当然 into 函数的使用方式与之前一样,只是可以选择性的在结尾加上 true / false // 如果最后不加布尔数值或者为 false 代表就是使用文本的方式来输出 dataFrame .into_outfile("C:\\Users\\zhao\\Downloads\\test\\res2") .into_outfile("C:\\Users\\zhao\\Downloads\\test\\res3", ",") .into_outfile("C:\\Users\\zhao\\Downloads\\test\\res4", false); } } ``` * 新增颜色替换函数 ```java package zhao.algorithmMagic; import zhao.algorithmMagic.operands.coordinate.IntegerCoordinateTwo; import zhao.algorithmMagic.operands.matrix.ColorMatrix; import zhao.algorithmMagic.operands.matrix.ImageMatrix; import zhao.algorithmMagic.utils.transformation.Transformation; import java.awt.*; public class MAIN1 { public static void main(String[] args) { Color color = new Color(239, 216, 194); // 实例化图片 ColorMatrix parse = ImageMatrix.parse("C:\\Users\\zhao\\Desktop\\Test\\无标题.jpg"); parse.show("原图"); // 进行颜色替换 将 标记的颜色做为被替换的颜色 parse = parse.colorReplace( // 设置需要被替换的颜色 color, // 设置替换操作进行时候的颜色转换逻辑 (Transformation<ColorMatrix, Color>) colors -> { // 使用 RGB 的均值做为替换颜色 return new Color( (int) colors.avg(ColorMatrix._R_), (int) colors.avg(ColorMatrix._G_), (int) colors.avg(ColorMatrix._B_) ); }, // 设置替换操作回调函数中接收到的范围 1024, // 设置颜色阈值 与 color 颜色值的差小于此值代表需要替换 此值为 [0, 255] 32, new IntegerCoordinateTwo(453, 195), // 不使用拷贝,性能更好 false ); parse.show("替换之后的结果"); } } ``` ### Version update date : 2023-12-15
1 parent 81fe06b commit dbb7708

36 files changed

+1633
-371
lines changed

README-Chinese.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AS库目录有多个版本,如果希望查询不同版本的更新日志以及
2323
<dependency>
2424
<groupId>io.github.BeardedManZhao</groupId>
2525
<artifactId>algorithmStar</artifactId>
26-
<version>1.25</version>
26+
<version>1.26</version>
2727
</dependency>
2828
</dependencies>
2929
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ can add it to your maven project, or you can download it from Releases and manua
2929
<dependency>
3030
<groupId>io.github.BeardedManZhao</groupId>
3131
<artifactId>algorithmStar</artifactId>
32-
<version>1.25</version>
32+
<version>1.26</version>
3333
</dependency>
3434
</dependencies>
3535
```

src_code/README-Chinese.md

Lines changed: 109 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -8,182 +8,148 @@
88

99
### 更新日志
1010

11-
* 框架版本:1.24 - 1.25
12-
* 更新版本号。
13-
* 移除 RouteNet 接口中“不支持操作异常”针对外部项目的依赖,避免出现下面所列出的异常信息,此版本中无需获取“javax.ws.rs”的第三方依赖。
14-
15-
```
16-
Exception in thread "main" java.lang.NoClassDefFoundError: javax/ws/rs/NotSupportedException
17-
at zhao.algorithmMagic.MAIN1.main(MAIN1.java:38)
18-
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.NotSupportedException
19-
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
20-
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
21-
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
22-
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
23-
... 1 more
24-
```
25-
26-
* 新增 Graphx 类,能够在基于线路网络类的前提下通过节点与边表进行图的构造,后期将会对此类新增诸多的操作函数。
11+
* 框架版本:1.25 - 1.26
12+
* 针对诸多的序列化操作,可以通过组件的方式来实现序列化,在IO组件库中已经集成了针对序列化对象IO的组件,下面就是一个示例。
2713

2814
```java
2915
package zhao.algorithmMagic;
3016

31-
import zhao.algorithmMagic.integrator.Route2DDrawingIntegrator;
32-
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinateTwo;
33-
import zhao.algorithmMagic.operands.coordinateNet.Graph;
34-
import zhao.algorithmMagic.operands.table.SingletonCell;
17+
import zhao.algorithmMagic.io.*;
18+
import zhao.algorithmMagic.operands.table.FDataFrame;
19+
import zhao.algorithmMagic.operands.table.FinalCell;
20+
import zhao.algorithmMagic.operands.table.SFDataFrame;
21+
import zhao.algorithmMagic.operands.table.SingletonSeries;
3522

23+
import java.io.FileInputStream;
24+
import java.io.FileOutputStream;
25+
import java.io.IOException;
26+
import java.io.OutputStream;
3627

3728
public class MAIN1 {
38-
public static void main(String[] args) {
39-
// 首先创建出两个节点的坐标
40-
final IntegerCoordinateTwo c1 = new IntegerCoordinateTwo(-10, 2);
41-
final IntegerCoordinateTwo c2 = new IntegerCoordinateTwo(20, 20);
42-
// 然后创建两个节点数据的表
43-
final Graph.GraphNodeDF nodeDF = Graph.GraphNodeDF.create(
44-
Graph.GraphNodeSeries.create(c1, SingletonCell.$("zhao"), SingletonCell.$("20")),
45-
Graph.GraphNodeSeries.create(c2, SingletonCell.$("TY"), SingletonCell.$("22"))
46-
);
47-
// 然后创建出两个节点之间的边
48-
final Graph.GraphEdgeDF edgeDF = Graph.GraphEdgeDF.create(
49-
// C1 <- 前任 -> C2 代表 C1的前任是C2 C2的前任是C1
50-
Graph.GraphEdgeSeries.create(c1, c2, SingletonCell.$("前任"))
51-
);
52-
// 最后创建图对象
53-
final Graph parse = Graph.create(nodeDF, edgeDF);
54-
55-
// 开始绘制图 首先准备线路绘图器
56-
final Route2DDrawingIntegrator draw = new Route2DDrawingIntegrator("draw", parse);
57-
if (draw.setImageOutPath("C:\\Users\\zhao\\Desktop\\fsdownload\\res.jpg").run()) {
58-
System.out.println("ok!!!");
29+
public static void main(String[] args) throws IOException {
30+
// System.out.println(OperationAlgorithmManager.VERSION);
31+
// if (args.length > 0) {
32+
// ASDynamicLibrary.addDllDir(new File(args[0]));
33+
// System.out.println(OperationAlgorithmManager.getAlgorithmStarUrl());
34+
// } else {
35+
// System.out.println("感谢您的使用。");
36+
// }
37+
38+
39+
// 创建一个对象输出组件 TODO 首先需要创建对应的数据输出流
40+
final OutputStream outputStream = new FileOutputStream("C:\\Users\\zhao\\Downloads\\test\\res");
41+
// 然后开始构建组件
42+
final OutputComponent outputComponent = OutputObject.builder()
43+
// 在这里将数据流装载进去
44+
.addOutputArg(OutputObjectBuilder.OUT_STREAM, new FinalCell<>(outputStream))
45+
.create();
46+
// 启动组件
47+
if (outputComponent.open()) {
48+
// 如果启动成功就创建一个 DF 对象
49+
final FDataFrame select = SFDataFrame.select(
50+
SingletonSeries.parse("name", "age"), 1
51+
);
52+
select.insert("zhao", "20").insert("tang", "22")
53+
// 使用组件将 DF 对象输出
54+
.into_outComponent(outputComponent);
5955
}
56+
// 使用完毕就关闭组件
57+
outputComponent.close();
58+
59+
// 当然,TODO 您也可以通过 InputObject 对象来实现反序列化。
60+
// 如果您不习惯通过组件实现,也可以通过Java中的序列化方式来实现。
61+
final InputComponent inputObject = InputObject.builder()
62+
.addInputArg(InputObjectBuilder.IN_STREAM, new FinalCell<>(new FileInputStream("")))
63+
.create();
6064
}
6165
}
66+
67+
6268
```
6369

64-
* 针对 Graph 类,我们可以通过 get 函数获取到 node 和 edge 的映射表
70+
* 通过简单的函数实现序列化,在 DF 对象中的 into_file 系列函数中,做了一些优化,其可以在最后接收一个布尔类型的参数来代表是否使用序列化输出
6571

6672
```java
6773
package zhao.algorithmMagic;
6874

69-
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinateTwo;
70-
import zhao.algorithmMagic.operands.coordinateNet.Graph;
71-
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute2D;
72-
import zhao.algorithmMagic.operands.table.SingletonCell;
75+
import zhao.algorithmMagic.io.InputComponent;
76+
import zhao.algorithmMagic.io.InputObject;
77+
import zhao.algorithmMagic.io.InputObjectBuilder;
78+
import zhao.algorithmMagic.operands.table.DataFrame;
79+
import zhao.algorithmMagic.operands.table.FinalCell;
80+
import zhao.algorithmMagic.operands.table.SFDataFrame;
7381

74-
import java.util.Collection;
75-
import java.util.HashMap;
82+
import java.io.FileInputStream;
83+
import java.io.IOException;
7684

7785
public class MAIN1 {
78-
public static void main(String[] args) {
79-
// 首先创建出两个节点的坐标
80-
final IntegerCoordinateTwo c1 = new IntegerCoordinateTwo(-10, 2), c2 = new IntegerCoordinateTwo(20, 20);
81-
// 然后创建图对象
82-
final Graph parse = Graph.create(
83-
// 创建两个节点数据的表
84-
Graph.GraphNodeDF.create(
85-
Graph.GraphNodeSeries.create(c1, SingletonCell.$("zhao"), SingletonCell.$("20")),
86-
Graph.GraphNodeSeries.create(c2, SingletonCell.$("TY"), SingletonCell.$("22"))
87-
),
88-
// 创建出两个节点之间的边
89-
Graph.GraphEdgeDF.create(
90-
// C1 <- 前任 -> C2 代表 C1的前任是C2 C2的前任是C1
91-
Graph.GraphEdgeSeries.create(c1, c2, SingletonCell.$("前任"))
92-
)
93-
);
94-
// TODO 获取到图对象中的所有节点数据映射表
95-
final HashMap<String, Graph.GraphNodeSeries> nodes = parse.getNodes();
96-
// TODO 获取到图对象中的所有边数据映射表
97-
final HashMap<String, Graph.GraphEdgeSeries> edges = parse.getEdges();
98-
// TODO 获取到图中的所有边数据线路对象
99-
final Collection<IntegerConsanguinityRoute2D> edgesRoute = parse.getEdgesRoute();
100-
// 我们在这里打印其中的每个线路的信息 TODO 我们将通过线路中的数据从映射表中取出详细数据
101-
/*
102-
* nodes映射表中的数据
103-
* +----------+------------+
104-
* | key | value |
105-
* +----------+------------+
106-
* | (-10,2) | zhao |
107-
* | (20,20) | TY |
108-
* +----------+------------+
109-
*
110-
*
111-
* edges映射表中的数据
112-
* +----------------------------------+------------------------------------+
113-
* | key | value |
114-
* +----------------------------------+------------------------------------+
115-
* | (-10,2)(-10,2) -> (20,20)(20,20) | series [(-10,2), (20,20), 前任] |
116-
* +----------------------------------+------------------- ----------------+
117-
* */
118-
edgesRoute.forEach(edge -> {
119-
// 通过坐标名称 从节点映射表中 获取到起始节点与终止节点的数据Series
120-
final Graph.GraphNodeSeries start = nodes.get(edge.getStartingCoordinateName());
121-
final Graph.GraphNodeSeries end = nodes.get(edge.getEndPointCoordinateName());
122-
System.out.println(
123-
"当前线路:" + edge + '\n' +
124-
"起始点:" + edge.getStartingCoordinate() +
125-
// 由于上面构建节点Series的时候 第一个是坐标 第二个是名字 第三个是age
126-
// 所以在这里也是相同的格式
127-
"\t名称:" + start.getCell(1).getValue() + '\n' +
128-
"终止点:" + edge.getEndPointCoordinate() + "\t名称:" + end.getCell(1) + '\n' +
129-
"两个点之间的关系: " + edges.get(edge.toString())
130-
);
131-
});
86+
public static void main(String[] args) throws IOException {
87+
// 创建一个序列化数据输入组件
88+
final InputComponent inputObject = InputObject.builder()
89+
.addInputArg(InputObjectBuilder.IN_STREAM, new FinalCell<>(new FileInputStream("C:\\Users\\zhao\\Downloads\\test\\res")))
90+
.create();
91+
// 从其中获取到 DF 对象
92+
final DataFrame dataFrame = SFDataFrame.builder(inputObject);
93+
// 查看其中的数据 并通过最新的 简洁函数来实现序列化输出
94+
dataFrame
95+
// TODO into 函数的结尾参数为 true 代表二进制输出
96+
.into_outfile("C:\\Users\\zhao\\Downloads\\test\\res1", true)
97+
// 查看内容
98+
.show();
99+
// TODO 当然 into 函数的使用方式与之前一样,只是可以选择性的在结尾加上 true / false
100+
// 如果最后不加布尔数值或者为 false 代表就是使用文本的方式来输出
101+
dataFrame
102+
.into_outfile("C:\\Users\\zhao\\Downloads\\test\\res2")
103+
.into_outfile("C:\\Users\\zhao\\Downloads\\test\\res3", ",")
104+
.into_outfile("C:\\Users\\zhao\\Downloads\\test\\res4", false);
132105
}
133106
}
134107
```
135108

136-
* 针对 Graphx 系列的 Series 类的构造中,如果配置项全是字符串,那么我们就可以不显式的指定 Cell 单元格构造,是的构造操作更加简洁。
109+
* 新增颜色替换函数
137110

138111
```java
139112
package zhao.algorithmMagic;
140113

141114
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinateTwo;
142-
import zhao.algorithmMagic.operands.coordinateNet.Graph;
115+
import zhao.algorithmMagic.operands.matrix.ColorMatrix;
116+
import zhao.algorithmMagic.operands.matrix.ImageMatrix;
117+
import zhao.algorithmMagic.utils.transformation.Transformation;
118+
119+
import java.awt.*;
143120

144121
public class MAIN1 {
145122
public static void main(String[] args) {
146-
// 首先创建出两个节点的坐标
147-
final IntegerCoordinateTwo c1 = new IntegerCoordinateTwo(-10, 2), c2 = new IntegerCoordinateTwo(20, 20);
148-
// 然后创建图对象
149-
final Graph parse = Graph.create(
150-
// 创建两个节点数据的表 TODO 在这里使用的是字符串,因此不需要使用 Cell 类的构造包装。
151-
Graph.GraphNodeDF.create(
152-
Graph.GraphNodeSeries.create(c1, "zhao", "20"),
153-
Graph.GraphNodeSeries.create(c2, "TY", "22")
154-
),
155-
// 创建出两个节点之间的边 TODO 在这里使用的是字符串,因此不需要使用 Cell 类的构造包装。
156-
Graph.GraphEdgeDF.create(
157-
// C1 <- 前任 -> C2 代表 C1的前任是C2 C2的前任是C1
158-
Graph.GraphEdgeSeries.create(c1, c2, "前任")
159-
)
123+
Color color = new Color(239, 216, 194);
124+
125+
// 实例化图片
126+
ColorMatrix parse = ImageMatrix.parse("C:\\Users\\zhao\\Desktop\\Test\\无标题.jpg");
127+
parse.show("原图");
128+
129+
// 进行颜色替换 将 标记的颜色做为被替换的颜色
130+
parse = parse.colorReplace(
131+
// 设置需要被替换的颜色
132+
color,
133+
// 设置替换操作进行时候的颜色转换逻辑
134+
(Transformation<ColorMatrix, Color>) colors -> {
135+
// 使用 RGB 的均值做为替换颜色
136+
return new Color(
137+
(int) colors.avg(ColorMatrix._R_),
138+
(int) colors.avg(ColorMatrix._G_),
139+
(int) colors.avg(ColorMatrix._B_)
140+
);
141+
},
142+
// 设置替换操作回调函数中接收到的范围
143+
1024,
144+
// 设置颜色阈值 与 color 颜色值的差小于此值代表需要替换 此值为 [0, 255]
145+
32,
146+
new IntegerCoordinateTwo(453, 195),
147+
// 不使用拷贝,性能更好
148+
false
160149
);
150+
parse.show("替换之后的结果");
161151
}
162152
}
163153
```
164154

165-
* 针对 DataFrame 以及其有关的模块,在此次更新中,将使用统一的序列化版本号来实现序列化操作数对象在不同版本的AS库被重复解析和读取的能力,拓展灵活性。
166-
167-
```java
168-
package zhao.algorithmMagic;
169-
170-
import zhao.algorithmMagic.algorithm.OperationAlgorithmManager;
171-
import zhao.algorithmMagic.operands.table.DataFrame;
172-
import zhao.algorithmMagic.operands.table.FDataFrame;
173-
174-
import java.io.File;
175-
import java.io.FileInputStream;
176-
import java.io.IOException;
177-
import java.io.ObjectInputStream;
178-
179-
public class MAIN1 {
180-
public static void main(String[] args) throws IOException, ClassNotFoundException {
181-
System.out.println(OperationAlgorithmManager.VERSION);
182-
final ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("path"));
183-
final DataFrame sfDataFrame = (FDataFrame) objectInputStream.readObject();
184-
sfDataFrame.show();
185-
}
186-
}
187-
```
188-
189-
### Version update date : xx xx-xx-xx
155+
### Version update date : 2023-12-15

0 commit comments

Comments
 (0)