mirror of
https://github.com/rememberber/MooTool.git
synced 2026-09-19 10:46:38 +08:00
增加文件格式化工具、PDF拆分/合并工具
This commit is contained in:
Generated
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -1,3 +0,0 @@
|
||||
-Dswing.aatext=true
|
||||
-XX:+UseZGC
|
||||
-XX:+ZGenerational
|
||||
@@ -15,10 +15,10 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
|
||||
<java.version>21</java.version>
|
||||
<java.version>17</java.version>
|
||||
<logback.version>1.4.11</logback.version>
|
||||
<emoji-java.version>5.1.1</emoji-java.version>
|
||||
<hutool-all.version>5.8.22</hutool-all.version>
|
||||
@@ -46,6 +46,9 @@
|
||||
<jfa.version>1.2.0</jfa.version>
|
||||
<versioncompare.version>1.5.0</versioncompare.version>
|
||||
<groovy.version>4.0.15</groovy.version>
|
||||
<jsoup.version>1.16.2</jsoup.version>
|
||||
<jalopy.version>1.5rc3</jalopy.version>
|
||||
<itextpdf.version>5.5.1</itextpdf.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
@@ -268,6 +271,25 @@
|
||||
<version>${groovy.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>${jsoup.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jalopy</groupId>
|
||||
<artifactId>jalopy</artifactId>
|
||||
<version>${jalopy.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>${itextpdf.version}</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -163,6 +163,26 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="5c883" binding="reformattingPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<tabbedpane title="格式化"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<toolTipText value="格式化"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="70f20" binding="pdfPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<tabbedpane title="PDF"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</tabbedpane>
|
||||
</children>
|
||||
|
||||
@@ -40,6 +40,8 @@ public class MainWindow {
|
||||
private JPanel regexPanel;
|
||||
private JPanel imagePanel;
|
||||
private JPanel javaConsolePanel;
|
||||
private JPanel reformattingPanel;
|
||||
private JPanel pdfPanel;
|
||||
|
||||
private static MainWindow mainWindow;
|
||||
|
||||
@@ -78,6 +80,8 @@ public class MainWindow {
|
||||
mainWindow.getTabbedPane().setIconAt(13, new FlatSVGIcon("icon/schedule.svg", 15, 15));
|
||||
mainWindow.getTabbedPane().setIconAt(14, new FlatSVGIcon("icon/reg.svg"));
|
||||
mainWindow.getTabbedPane().setIconAt(15, new FlatSVGIcon("icon/java.svg"));
|
||||
mainWindow.getTabbedPane().setIconAt(16, new FlatSVGIcon("icon/gear.svg", 15, 15));
|
||||
mainWindow.getTabbedPane().setIconAt(17, new FlatSVGIcon("icon/pdf.svg", 15, 15));
|
||||
|
||||
mainWindow.getQuickNotePanel().add(QuickNoteForm.getInstance().getQuickNotePanel(), gridConstraints);
|
||||
mainWindow.getJsonBeautyPanel().add(JsonBeautyForm.getInstance().getJsonBeautyPanel(), gridConstraints);
|
||||
@@ -95,6 +99,8 @@ public class MainWindow {
|
||||
mainWindow.getRegexPanel().add(RegexForm.getInstance().getRegexPanel(), gridConstraints);
|
||||
mainWindow.getImagePanel().add(ImageForm.getInstance().getImagePanel(), gridConstraints);
|
||||
mainWindow.getJavaConsolePanel().add(JavaConsoleForm.getInstance().getJavaConsolePanel(), gridConstraints);
|
||||
mainWindow.getReformattingPanel().add(FileReformattingForm.getInstance().getReformattingPanel(), gridConstraints);
|
||||
mainWindow.getPdfPanel().add(PdfForm.getInstance().getPdfPanel(), gridConstraints);
|
||||
mainWindow.getMainPanel().updateUI();
|
||||
|
||||
TabListener.addListeners();
|
||||
@@ -168,6 +174,13 @@ public class MainWindow {
|
||||
javaConsolePanel = new JPanel();
|
||||
javaConsolePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
tabbedPane.addTab("Java", javaConsolePanel);
|
||||
reformattingPanel = new JPanel();
|
||||
reformattingPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
reformattingPanel.setToolTipText("格式化");
|
||||
tabbedPane.addTab("格式化", reformattingPanel);
|
||||
pdfPanel = new JPanel();
|
||||
pdfPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
tabbedPane.addTab("PDF", pdfPanel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.luoboduner.moo.tool.ui.form.func.FileReformattingForm">
|
||||
<grid id="27dc6" binding="reformattingPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="15" left="15" bottom="15" right="15"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="582" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="34b0f" layout-manager="GridLayoutManager" row-count="2" column-count="8" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="97b7d" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="文件类型"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="83726">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="665f3" class="javax.swing.JComboBox" binding="fileType">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<model>
|
||||
<item value="XML"/>
|
||||
<item value="HTML"/>
|
||||
<item value="JAVA"/>
|
||||
</model>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="21970" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="空格数量"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="8990a" class="javax.swing.JComboBox" binding="spaceNum">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<model>
|
||||
<item value="2"/>
|
||||
<item value="3"/>
|
||||
<item value="4"/>
|
||||
<item value="5"/>
|
||||
<item value="6"/>
|
||||
</model>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7434d" class="javax.swing.JButton" binding="uploadFile">
|
||||
<constraints>
|
||||
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="选择文件"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="edad6" class="javax.swing.JButton" binding="reformat">
|
||||
<constraints>
|
||||
<grid row="0" column="7" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="格式化"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="19c7d" class="javax.swing.JLabel" binding="selectFileName">
|
||||
<constraints>
|
||||
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="f4893">
|
||||
<constraints>
|
||||
<grid row="0" column="6" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
<scrollpane id="22e83">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="7daec" class="javax.swing.JTextArea" binding="resultArea">
|
||||
<constraints/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
package com.luoboduner.moo.tool.ui.form.func;
|
||||
|
||||
import com.intellij.uiDesigner.core.GridConstraints;
|
||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||
import com.intellij.uiDesigner.core.Spacer;
|
||||
import com.luoboduner.moo.tool.ui.listener.func.FileReformatListener;
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@Getter
|
||||
public class FileReformattingForm {
|
||||
private JPanel reformattingPanel;
|
||||
private JComboBox fileType;
|
||||
private JComboBox spaceNum;
|
||||
private JTextArea resultArea;
|
||||
private JButton uploadFile;
|
||||
private JButton reformat;
|
||||
private JLabel selectFileName;
|
||||
|
||||
private static FileReformattingForm fileReformattingForm;
|
||||
|
||||
public static FileReformattingForm getInstance() {
|
||||
if (null == fileReformattingForm) {
|
||||
fileReformattingForm = new FileReformattingForm();
|
||||
}
|
||||
return fileReformattingForm;
|
||||
}
|
||||
|
||||
private FileReformattingForm() {
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
FileReformatListener.ParameterBuilder.builder()
|
||||
.buildFileType(this.fileType)
|
||||
.buildSpaceNum(this.spaceNum)
|
||||
.buildResultPanel(this.resultArea)
|
||||
.buildUploadBtn(this.uploadFile)
|
||||
.buildReformatBtn(this.reformat)
|
||||
.buildSelectFileLabel(this.selectFileName)
|
||||
.start();
|
||||
}
|
||||
|
||||
{
|
||||
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||
// >>> IMPORTANT!! <<<
|
||||
// DO NOT EDIT OR ADD ANY CODE HERE!
|
||||
$$$setupUI$$$();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method generated by IntelliJ IDEA GUI Designer
|
||||
* >>> IMPORTANT!! <<<
|
||||
* DO NOT edit this method OR call it in your code!
|
||||
*
|
||||
* @noinspection ALL
|
||||
*/
|
||||
private void $$$setupUI$$$() {
|
||||
reformattingPanel = new JPanel();
|
||||
reformattingPanel.setLayout(new GridLayoutManager(2, 1, new Insets(15, 15, 15, 15), -1, -1));
|
||||
final JPanel panel1 = new JPanel();
|
||||
panel1.setLayout(new GridLayoutManager(2, 8, new Insets(0, 0, 0, 0), -1, -1));
|
||||
reformattingPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
||||
final JLabel label1 = new JLabel();
|
||||
label1.setText("文件类型");
|
||||
panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final Spacer spacer1 = new Spacer();
|
||||
panel1.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||
fileType = new JComboBox();
|
||||
final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
|
||||
defaultComboBoxModel1.addElement("XML");
|
||||
defaultComboBoxModel1.addElement("HTML");
|
||||
defaultComboBoxModel1.addElement("JAVA");
|
||||
fileType.setModel(defaultComboBoxModel1);
|
||||
panel1.add(fileType, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final JLabel label2 = new JLabel();
|
||||
label2.setText("空格数量");
|
||||
panel1.add(label2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
spaceNum = new JComboBox();
|
||||
final DefaultComboBoxModel defaultComboBoxModel2 = new DefaultComboBoxModel();
|
||||
defaultComboBoxModel2.addElement("2");
|
||||
defaultComboBoxModel2.addElement("3");
|
||||
defaultComboBoxModel2.addElement("4");
|
||||
defaultComboBoxModel2.addElement("5");
|
||||
defaultComboBoxModel2.addElement("6");
|
||||
spaceNum.setModel(defaultComboBoxModel2);
|
||||
panel1.add(spaceNum, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
uploadFile = new JButton();
|
||||
uploadFile.setText("选择文件");
|
||||
panel1.add(uploadFile, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
reformat = new JButton();
|
||||
reformat.setText("格式化");
|
||||
panel1.add(reformat, new GridConstraints(0, 7, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
selectFileName = new JLabel();
|
||||
selectFileName.setText("");
|
||||
panel1.add(selectFileName, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final Spacer spacer2 = new Spacer();
|
||||
panel1.add(spacer2, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
|
||||
final JScrollPane scrollPane1 = new JScrollPane();
|
||||
reformattingPanel.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||
resultArea = new JTextArea();
|
||||
scrollPane1.setViewportView(resultArea);
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection ALL
|
||||
*/
|
||||
public JComponent $$$getRootComponent$$$() {
|
||||
return reformattingPanel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.luoboduner.moo.tool.ui.form.func.PdfForm">
|
||||
<grid id="27dc6" binding="pdfPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="1066" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<tabbedpane id="cfcbe" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="200" height="200"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<tabPlacement value="2"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="2077f" binding="splitPane" layout-manager="GridLayoutManager" row-count="2" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="15" left="15" bottom="15" right="15"/>
|
||||
<constraints>
|
||||
<tabbedpane title="PDF拆分"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="aaaf8" class="javax.swing.JButton" binding="startTask">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="开始拆分"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="31eb">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<grid id="254de" binding="taskPane" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="line">
|
||||
<color color="-2500135"/>
|
||||
</border>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="cd0c4" class="javax.swing.JButton" binding="newTask">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="50" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="新增处理任务"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="1ed65" class="javax.swing.JLabel" binding="helpBtn">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="2db58" binding="mergePane" layout-manager="GridLayoutManager" row-count="2" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="15" left="15" bottom="15" right="15"/>
|
||||
<constraints>
|
||||
<tabbedpane title="PDF合并"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<hspacer id="6b991">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="777a1" class="javax.swing.JButton" binding="startMerge">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="开始合并"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e162" class="javax.swing.JButton" binding="addFile">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="新增合并文件"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d46dc" class="javax.swing.JLabel" binding="helpMerge">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="ac239" binding="filePane" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="line">
|
||||
<color color="-2500135"/>
|
||||
</border>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</tabbedpane>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,752 @@
|
||||
package com.luoboduner.moo.tool.ui.form.func;
|
||||
|
||||
import com.formdev.flatlaf.extras.FlatSVGIcon;
|
||||
import com.intellij.uiDesigner.core.GridConstraints;
|
||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||
import com.intellij.uiDesigner.core.Spacer;
|
||||
import com.luoboduner.moo.tool.ui.listener.func.PDFMergerListener;
|
||||
import com.luoboduner.moo.tool.ui.listener.func.PDFSplitterListener;
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.table.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public class PdfForm {
|
||||
private JPanel pdfPanel;
|
||||
private JButton startTask;
|
||||
private JButton newTask;
|
||||
private JPanel taskPane;
|
||||
private JPanel splitPane;
|
||||
private JLabel helpBtn;
|
||||
private JPanel mergePane;
|
||||
private JButton startMerge;
|
||||
private JButton addFile;
|
||||
private JLabel helpMerge;
|
||||
private JPanel filePane;
|
||||
|
||||
private static PdfForm instance;
|
||||
private PDFSplitterListener listener;
|
||||
private PDFMergerListener mergerListener;
|
||||
|
||||
private PdfForm() {
|
||||
$$$setupUI$$$();
|
||||
initSplitContent();
|
||||
initMergeContent();
|
||||
}
|
||||
|
||||
public static PdfForm getInstance() {
|
||||
if (null == instance) {
|
||||
synchronized (PdfForm.class) {
|
||||
if (null == instance) {
|
||||
instance = new PdfForm();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void initMergeContent() {
|
||||
FileTableModel fileTableModel = new FileTableModel(10);
|
||||
JTable table = new JTable(fileTableModel);
|
||||
PDFTableModel.CommonComponentRenderer componentRenderer = fileTableModel.new CommonComponentRenderer();
|
||||
table.setDefaultRenderer(JCheckBox.class, componentRenderer);
|
||||
table.setDefaultRenderer(JButton.class, componentRenderer);
|
||||
table.setDefaultRenderer(JTextField.class, componentRenderer);
|
||||
table.setDefaultRenderer(JProgressBar.class, componentRenderer);
|
||||
table.setDefaultRenderer(JLabel.class, componentRenderer);
|
||||
|
||||
table.setDefaultEditor(JTextField.class, fileTableModel.new CommonTextFieldEditor());
|
||||
table.setDefaultEditor(JCheckBox.class, fileTableModel.new CommonCheckBoxEditor());
|
||||
table.setDefaultEditor(JButton.class, fileTableModel.new CommonUploadEditor());
|
||||
|
||||
table.setRowHeight(30);
|
||||
table.setRowMargin(5);
|
||||
JTableHeader jTableHeader = table.getTableHeader();
|
||||
|
||||
table.getColumnModel().getColumn(0).setMaxWidth(100);
|
||||
table.getColumnModel().getColumn(1).setMaxWidth(250);
|
||||
table.getColumnModel().getColumn(1).setMinWidth(250);
|
||||
table.getColumnModel().getColumn(5).setMaxWidth(200);
|
||||
|
||||
getFilePane().add(jTableHeader, BorderLayout.NORTH);
|
||||
getFilePane().add(table, BorderLayout.CENTER);
|
||||
|
||||
mergerListener = new PDFMergerListener(getFilePane(), fileTableModel);
|
||||
mergerListener.setComponents(fileTableModel.getComps());
|
||||
mergerListener.setStartMerge(getStartMerge());
|
||||
mergerListener.setHelpMerge(getHelpMerge());
|
||||
mergerListener.setAddFile(getAddFile());
|
||||
mergerListener.startListener();
|
||||
|
||||
getHelpMerge().setIcon(new FlatSVGIcon("icon/help.svg"));
|
||||
}
|
||||
|
||||
private void initSplitContent() {
|
||||
SplitTableModel taskTableModel = new SplitTableModel(10);
|
||||
JTable table = new JTable(taskTableModel);
|
||||
SplitTableModel.CommonComponentRenderer testRenderer = taskTableModel.new CommonComponentRenderer();
|
||||
table.setDefaultRenderer(JCheckBox.class, testRenderer);
|
||||
table.setDefaultRenderer(JButton.class, testRenderer);
|
||||
table.setDefaultRenderer(JTextField.class, testRenderer);
|
||||
table.setDefaultRenderer(JComboBox.class, testRenderer);
|
||||
table.setDefaultRenderer(JProgressBar.class, testRenderer);
|
||||
table.setDefaultRenderer(JLabel.class, testRenderer);
|
||||
|
||||
table.setDefaultEditor(JCheckBox.class, taskTableModel.new CommonCheckBoxEditor());
|
||||
table.setDefaultEditor(JButton.class, taskTableModel.new CommonUploadEditor());
|
||||
table.setDefaultEditor(JTextField.class, taskTableModel.new CommonTextFieldEditor());
|
||||
table.setDefaultEditor(JComboBox.class, taskTableModel.new CommonComboBoxEditor());
|
||||
|
||||
table.setRowHeight(30);
|
||||
table.setRowMargin(5);
|
||||
JTableHeader jTableHeader = table.getTableHeader();
|
||||
|
||||
table.getColumnModel().getColumn(0).setMaxWidth(50);
|
||||
table.getColumnModel().getColumn(4).setMaxWidth(150);
|
||||
table.getColumnModel().getColumn(7).setMaxWidth(150);
|
||||
|
||||
getTaskPane().add(jTableHeader, BorderLayout.NORTH);
|
||||
getTaskPane().add(table, BorderLayout.CENTER);
|
||||
|
||||
listener = new PDFSplitterListener(taskPane, taskTableModel);
|
||||
listener.setNewTask(getNewTask());
|
||||
listener.setStartTask(getStartTask());
|
||||
listener.setHelpBtn(getHelpBtn());
|
||||
listener.setComponents(taskTableModel.getComps());
|
||||
listener.startListener();
|
||||
|
||||
getHelpBtn().setIcon(new FlatSVGIcon("icon/help.svg"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method generated by IntelliJ IDEA GUI Designer
|
||||
* >>> IMPORTANT!! <<<
|
||||
* DO NOT edit this method OR call it in your code!
|
||||
*
|
||||
* @noinspection ALL
|
||||
*/
|
||||
private void $$$setupUI$$$() {
|
||||
pdfPanel = new JPanel();
|
||||
pdfPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
final JTabbedPane tabbedPane1 = new JTabbedPane();
|
||||
tabbedPane1.setTabPlacement(2);
|
||||
pdfPanel.add(tabbedPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, 0, false));
|
||||
splitPane = new JPanel();
|
||||
splitPane.setLayout(new GridLayoutManager(2, 4, new Insets(15, 15, 15, 15), -1, -1));
|
||||
tabbedPane1.addTab("PDF拆分", splitPane);
|
||||
startTask = new JButton();
|
||||
startTask.setText("开始拆分");
|
||||
splitPane.add(startTask, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final Spacer spacer1 = new Spacer();
|
||||
splitPane.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
|
||||
taskPane = new JPanel();
|
||||
taskPane.setLayout(new BorderLayout(0, 0));
|
||||
splitPane.add(taskPane, new GridConstraints(1, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
||||
taskPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-2500135)), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
|
||||
newTask = new JButton();
|
||||
newTask.setText("新增处理任务");
|
||||
splitPane.add(newTask, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, 30), null, 0, false));
|
||||
helpBtn = new JLabel();
|
||||
helpBtn.setText("");
|
||||
splitPane.add(helpBtn, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
mergePane = new JPanel();
|
||||
mergePane.setLayout(new GridLayoutManager(2, 4, new Insets(15, 15, 15, 15), -1, -1));
|
||||
tabbedPane1.addTab("PDF合并", mergePane);
|
||||
final Spacer spacer2 = new Spacer();
|
||||
mergePane.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
|
||||
startMerge = new JButton();
|
||||
startMerge.setText("开始合并");
|
||||
mergePane.add(startMerge, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
addFile = new JButton();
|
||||
addFile.setText("新增合并文件");
|
||||
mergePane.add(addFile, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
helpMerge = new JLabel();
|
||||
helpMerge.setText("");
|
||||
mergePane.add(helpMerge, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
filePane = new JPanel();
|
||||
filePane.setLayout(new BorderLayout(0, 0));
|
||||
mergePane.add(filePane, new GridConstraints(1, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
||||
filePane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-2500135)), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection ALL
|
||||
*/
|
||||
public JComponent $$$getRootComponent$$$() {
|
||||
return pdfPanel;
|
||||
}
|
||||
|
||||
public abstract class PDFTableModel extends AbstractTableModel {
|
||||
|
||||
protected String[] COLUMN_NAMES = new String[]{};
|
||||
|
||||
protected Class<?>[] COLUMN_TYPES = new Class<?>[]{};
|
||||
|
||||
protected List<Object[]> comps;
|
||||
|
||||
protected int count;
|
||||
|
||||
private int maxRow = 20;
|
||||
|
||||
private int rowCount;
|
||||
|
||||
public PDFTableModel(int rowCount) {
|
||||
this.comps = new LinkedList<>();
|
||||
this.rowCount = rowCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
if (COLUMN_NAMES.length == 0) {
|
||||
this.COLUMN_NAMES = this.initColumns();
|
||||
}
|
||||
return COLUMN_NAMES.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
if (COLUMN_NAMES.length == 0) {
|
||||
this.COLUMN_NAMES = this.initColumns();
|
||||
}
|
||||
return COLUMN_NAMES[columnIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
if (COLUMN_TYPES.length == 0) {
|
||||
this.COLUMN_TYPES = this.initColumnTypes();
|
||||
}
|
||||
return COLUMN_TYPES[columnIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
if (comps.isEmpty() || comps.size() <= rowIndex) {
|
||||
comps.add(newRow());
|
||||
}
|
||||
return comps.get(rowIndex)[columnIndex];
|
||||
}
|
||||
|
||||
public void add() {
|
||||
if (count >= maxRow) {
|
||||
JOptionPane.showMessageDialog(taskPane, "最大为20个!", "警告", JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
rowCount++;
|
||||
getComps().add(newRow());
|
||||
this.fireTableRowsUpdated(count - 1, count - 1);
|
||||
}
|
||||
|
||||
protected List<Object[]> getComps() {
|
||||
return comps;
|
||||
}
|
||||
|
||||
protected abstract Object[] newRow();
|
||||
|
||||
protected abstract String[] initColumns();
|
||||
|
||||
protected abstract Class<?>[] initColumnTypes();
|
||||
|
||||
protected void selectEditor(boolean isSelected, int row) {
|
||||
}
|
||||
|
||||
protected void uploadEditor(File file, int row) {
|
||||
}
|
||||
|
||||
protected void textChange(String text, int row, int column) {
|
||||
}
|
||||
|
||||
protected void comboBoxChange(String text, int row) {
|
||||
}
|
||||
|
||||
protected class CommonComponentRenderer extends DefaultTableCellRenderer {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Class<?> columnType = getColumnClass(column);
|
||||
return (Component) columnType.cast(value);
|
||||
}
|
||||
}
|
||||
|
||||
protected class CommonCheckBoxEditor extends DefaultCellEditor {
|
||||
|
||||
public CommonCheckBoxEditor() {
|
||||
super(new JTextField());
|
||||
this.setClickCountToStart(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
JCheckBox checkBox = (JCheckBox) value;
|
||||
if (checkBox.getActionListeners().length == 0) {
|
||||
checkBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
selectEditor(checkBox.isSelected(), row);
|
||||
}
|
||||
});
|
||||
}
|
||||
return checkBox;
|
||||
}
|
||||
}
|
||||
|
||||
protected class CommonUploadEditor extends DefaultCellEditor {
|
||||
private static final long serialVersionUID = -6546334664166791132L;
|
||||
|
||||
public CommonUploadEditor() {
|
||||
super(new JTextField());
|
||||
this.setClickCountToStart(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
JButton button = (JButton) value;
|
||||
if (button.getActionListeners().length == 0) {
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
int option = fileChooser.showOpenDialog(getTaskPane());
|
||||
if (option == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fileChooser.getSelectedFile();
|
||||
uploadEditor(file, row);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return button;
|
||||
}
|
||||
}
|
||||
|
||||
protected class CommonTextFieldEditor extends DefaultCellEditor {
|
||||
|
||||
public CommonTextFieldEditor() {
|
||||
super(new JTextField());
|
||||
this.setClickCountToStart(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
JTextField textField = (JTextField) value;
|
||||
textField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
textChange(textField.getText(), row, column);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
}
|
||||
});
|
||||
return textField;
|
||||
}
|
||||
}
|
||||
|
||||
protected class CommonComboBoxEditor extends DefaultCellEditor {
|
||||
public CommonComboBoxEditor() {
|
||||
super(new JTextField());
|
||||
this.setClickCountToStart(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
JComboBox comboBox = (JComboBox) value;
|
||||
comboBox.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
JComboBox<String> combo = (JComboBox<String>) e.getSource();
|
||||
String selectedItem = (String) combo.getSelectedItem();
|
||||
comboBoxChange(selectedItem, row);
|
||||
}
|
||||
}
|
||||
});
|
||||
return comboBox;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FileTableModel extends PDFTableModel {
|
||||
|
||||
public FileTableModel(int rowCount) {
|
||||
super(rowCount);
|
||||
}
|
||||
|
||||
protected Object[] newRow() {
|
||||
Object[] components = new Object[7];
|
||||
JCheckBox jCheckBox = new JCheckBox();
|
||||
jCheckBox.setHorizontalAlignment(JLabel.CENTER);
|
||||
jCheckBox.setText(++count + "");
|
||||
components[0] = jCheckBox;
|
||||
components[1] = new JButton(COLUMN_NAMES[1]);
|
||||
components[2] = new JLabel();
|
||||
components[3] = new JTextField();
|
||||
JProgressBar progressBar = new JProgressBar();
|
||||
progressBar.setPreferredSize(new Dimension(150, 2));
|
||||
progressBar.setValue(0);
|
||||
progressBar.setStringPainted(true);
|
||||
progressBar.setBounds(0, 0, 150, 2);
|
||||
components[4] = progressBar;
|
||||
JLabel label = new JLabel("未开始");
|
||||
label.setHorizontalAlignment(JLabel.CENTER);
|
||||
components[5] = label;
|
||||
return components;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] initColumns() {
|
||||
return new String[]{"#", "选择文件", "文件名", "PDF合并范围", "合并进度", "状态"};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] initColumnTypes() {
|
||||
return new Class<?>[]{JCheckBox.class, JButton.class, JLabel.class, JTextField.class, JProgressBar.class, JLabel.class};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 3:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void uploadEditor(File file, int row) {
|
||||
mergerListener.selectFile(file, row);
|
||||
}
|
||||
|
||||
protected void textChange(String text, int row, int column) {
|
||||
if (3 == column) {
|
||||
mergerListener.changeMergeRange(text, row);
|
||||
}
|
||||
}
|
||||
|
||||
protected void selectEditor(boolean isSelected, int row) {
|
||||
mergerListener.setMerge(isSelected, row);
|
||||
}
|
||||
}
|
||||
|
||||
public class SplitTableModel extends PDFTableModel {
|
||||
|
||||
public SplitTableModel(int rowCount) {
|
||||
super(rowCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[] newRow() {
|
||||
Object[] components = new Object[9];
|
||||
JCheckBox jCheckBox = new JCheckBox();
|
||||
jCheckBox.setHorizontalAlignment(JLabel.CENTER);
|
||||
jCheckBox.setText(++count + "");
|
||||
components[0] = jCheckBox;
|
||||
components[1] = new JButton(COLUMN_NAMES[1]);
|
||||
components[2] = new JLabel();
|
||||
components[3] = new JTextField();
|
||||
|
||||
JComboBox<String> comboBox = new JComboBox<>();
|
||||
final DefaultComboBoxModel<String> comboBoxModel = new DefaultComboBoxModel<>();
|
||||
comboBoxModel.addElement("奇数");
|
||||
comboBoxModel.addElement("偶数");
|
||||
comboBoxModel.addElement("自定义");
|
||||
comboBox.setModel(comboBoxModel);
|
||||
|
||||
components[4] = comboBox;
|
||||
JTextField jTextField = new JTextField();
|
||||
jTextField.setEnabled(false);
|
||||
components[5] = jTextField;
|
||||
JProgressBar progressBar = new JProgressBar();
|
||||
progressBar.setPreferredSize(new Dimension(150, 2));
|
||||
progressBar.setValue(0);
|
||||
progressBar.setStringPainted(true);
|
||||
progressBar.setBounds(0, 0, 150, 2);
|
||||
components[6] = progressBar;
|
||||
JLabel label = new JLabel("未开始");
|
||||
label.setHorizontalAlignment(JLabel.CENTER);
|
||||
components[7] = label;
|
||||
return components;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] initColumns() {
|
||||
return new String[]{"#", "选择文件", "文件名", "PDF拆分范围", "拆分规则", "自定义规则", "拆分进度", "状态"};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] initColumnTypes() {
|
||||
return new Class<?>[]{JCheckBox.class, JButton.class, JLabel.class, JTextField.class, JComboBox.class, JTextField.class, JProgressBar.class, JLabel.class};
|
||||
}
|
||||
|
||||
protected void selectEditor(boolean isSelected, int row) {
|
||||
listener.setSplit(row, isSelected);
|
||||
}
|
||||
|
||||
protected void uploadEditor(File file, int row) {
|
||||
listener.selectFile(file, row);
|
||||
}
|
||||
|
||||
protected void textChange(String text, int row, int column) {
|
||||
if (3 == column) {
|
||||
listener.changeSplitRange(text, row);
|
||||
} else if (5 == column) {
|
||||
listener.changeSplitRule(text, row);
|
||||
}
|
||||
}
|
||||
|
||||
protected void comboBoxChange(String text, int row) {
|
||||
listener.changeSplitRuleType(text, row);
|
||||
}
|
||||
}
|
||||
|
||||
/*public class TaskTableModel extends AbstractTableModel {
|
||||
|
||||
private static final String[] COLUMN_NAMES = new String[]{"#", "选择文件", "文件名", "PDF拆分范围", "拆分规则", "自定义规则", "拆分进度", "状态"};
|
||||
|
||||
private static final Class<?>[] COLUMN_TYPES = new Class<?>[]{JCheckBox.class, JButton.class, JLabel.class, JTextField.class, JComboBox.class, JTextField.class, JProgressBar.class, JLabel.class};
|
||||
|
||||
private List<Object[]> comps = new LinkedList<>();
|
||||
|
||||
private int count = 0;
|
||||
|
||||
private int maxRow = 10;
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return maxRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return COLUMN_NAMES.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
return COLUMN_NAMES[columnIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
return COLUMN_TYPES[columnIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
if (comps.isEmpty() || comps.size() <= rowIndex) {
|
||||
comps.add(newRow());
|
||||
}
|
||||
return comps.get(rowIndex)[columnIndex];
|
||||
}
|
||||
|
||||
private Object[] newRow() {
|
||||
Object[] components = new Object[9];
|
||||
JCheckBox jCheckBox = new JCheckBox();
|
||||
jCheckBox.setHorizontalAlignment(JLabel.CENTER);
|
||||
jCheckBox.setText(++count + "");
|
||||
components[0] = jCheckBox;
|
||||
components[1] = new JButton(COLUMN_NAMES[1]);
|
||||
components[2] = new JLabel();
|
||||
components[3] = new JTextField();
|
||||
|
||||
JComboBox<String> comboBox = new JComboBox<>();
|
||||
final DefaultComboBoxModel<String> comboBoxModel = new DefaultComboBoxModel<>();
|
||||
comboBoxModel.addElement("奇数");
|
||||
comboBoxModel.addElement("偶数");
|
||||
comboBoxModel.addElement("自定义");
|
||||
comboBox.setModel(comboBoxModel);
|
||||
|
||||
components[4] = comboBox;
|
||||
JTextField jTextField = new JTextField();
|
||||
jTextField.setEnabled(false);
|
||||
components[5] = jTextField;
|
||||
JProgressBar progressBar = new JProgressBar();
|
||||
progressBar.setPreferredSize(new Dimension(150, 2));
|
||||
progressBar.setValue(0);
|
||||
progressBar.setStringPainted(true);
|
||||
progressBar.setBounds(0, 0, 150, 2);
|
||||
components[6] = progressBar;
|
||||
JLabel label = new JLabel("未开始");
|
||||
label.setHorizontalAlignment(JLabel.CENTER);
|
||||
components[7] = label;
|
||||
return components;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class CommonRenderer extends DefaultTableCellRenderer {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Class<?> columnType = COLUMN_TYPES[column];
|
||||
return (Component) columnType.cast(value);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object[]> getComps() {
|
||||
return comps;
|
||||
}
|
||||
|
||||
public void addTask() {
|
||||
if (count >= 20) {
|
||||
JOptionPane.showMessageDialog(taskPane, "任务最大能为20个!", "警告", JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
maxRow++;
|
||||
getComps().add(newRow());
|
||||
this.fireTableRowsUpdated(count - 1, count - 1);
|
||||
}
|
||||
|
||||
private class CheckBoxEditor extends DefaultCellEditor {
|
||||
|
||||
public CheckBoxEditor() {
|
||||
super(new JTextField());
|
||||
this.setClickCountToStart(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
JCheckBox checkBox = (JCheckBox) value;
|
||||
if (checkBox.getActionListeners().length == 0) {
|
||||
checkBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
listener.setSplit(row, checkBox.isSelected());
|
||||
}
|
||||
});
|
||||
}
|
||||
return checkBox;
|
||||
}
|
||||
}
|
||||
|
||||
private class TextFieldEditor extends DefaultCellEditor {
|
||||
|
||||
public TextFieldEditor() {
|
||||
super(new JTextField());
|
||||
this.setClickCountToStart(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
JTextField textField = (JTextField) value;
|
||||
textField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
if (3 == column) {
|
||||
listener.changeSplitRange(textField.getText(), row, column);
|
||||
} else if (5 == column) {
|
||||
listener.changeSplitRule(textField.getText(), row, column);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
System.out.println("removeUpdate:" + textField.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
System.out.println("changedUpdate:" + textField.getText());
|
||||
}
|
||||
});
|
||||
return textField;
|
||||
}
|
||||
}
|
||||
|
||||
private class ComboBoxEditor extends DefaultCellEditor {
|
||||
public ComboBoxEditor() {
|
||||
super(new JTextField());
|
||||
this.setClickCountToStart(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
JComboBox comboBox = (JComboBox) value;
|
||||
comboBox.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
JComboBox<String> combo = (JComboBox<String>) e.getSource();
|
||||
String selectedItem = (String) combo.getSelectedItem();
|
||||
listener.changeSplitRuleType(selectedItem, row, column);
|
||||
}
|
||||
}
|
||||
});
|
||||
return comboBox;
|
||||
}
|
||||
}
|
||||
|
||||
private class UploadEditor extends DefaultCellEditor {
|
||||
private static final long serialVersionUID = -6546334664166791132L;
|
||||
|
||||
public UploadEditor() {
|
||||
super(new JTextField());
|
||||
this.setClickCountToStart(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
JButton button = (JButton) value;
|
||||
if (button.getActionListeners().length == 0) {
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
int option = fileChooser.showOpenDialog(getTaskPane());
|
||||
if (option == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fileChooser.getSelectedFile();
|
||||
listener.selectFile(file, row, column);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return button;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
package com.luoboduner.moo.tool.ui.listener.func;
|
||||
|
||||
import com.luoboduner.moo.tool.ui.form.MainWindow;
|
||||
import com.luoboduner.moo.tool.ui.frame.MainFrame;
|
||||
import com.luoboduner.moo.tool.util.FileReformatUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.*;
|
||||
|
||||
@Slf4j
|
||||
public class FileReformatListener {
|
||||
|
||||
private JComboBox fileType;
|
||||
private JComboBox spaceNum;
|
||||
private JTextArea resultArea;
|
||||
private JButton uploadFileBtn;
|
||||
private JButton reformatBtn;
|
||||
|
||||
private JLabel selectFileLabel;
|
||||
|
||||
private File selectFile;
|
||||
|
||||
private FileReformatListener() {
|
||||
}
|
||||
|
||||
public static class ParameterBuilder {
|
||||
private JComboBox fileType;
|
||||
private JComboBox spaceNum;
|
||||
private JTextArea resultArea;
|
||||
private JButton uploadFileBtn;
|
||||
private JButton reformatBtn;
|
||||
|
||||
private JLabel selectFileLabel;
|
||||
|
||||
private ParameterBuilder() {}
|
||||
|
||||
public static ParameterBuilder builder() {
|
||||
return new ParameterBuilder();
|
||||
}
|
||||
|
||||
public ParameterBuilder buildFileType(JComboBox type) {
|
||||
this.fileType = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ParameterBuilder buildSpaceNum(JComboBox number) {
|
||||
this.spaceNum = number;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ParameterBuilder buildResultPanel(JTextArea resultArea) {
|
||||
this.resultArea = resultArea;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ParameterBuilder buildUploadBtn(JButton uploadFile) {
|
||||
this.uploadFileBtn = uploadFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ParameterBuilder buildReformatBtn(JButton reformatBtn) {
|
||||
this.reformatBtn = reformatBtn;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ParameterBuilder buildSelectFileLabel(JLabel selectFile) {
|
||||
this.selectFileLabel = selectFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
FileReformatListener fileReformatListener = new FileReformatListener();
|
||||
fileReformatListener.fileType = this.fileType;
|
||||
fileReformatListener.spaceNum = this.spaceNum;
|
||||
fileReformatListener.resultArea = this.resultArea;
|
||||
fileReformatListener.uploadFileBtn = this.uploadFileBtn;
|
||||
fileReformatListener.reformatBtn = this.reformatBtn;
|
||||
fileReformatListener.selectFileLabel = this.selectFileLabel;
|
||||
fileReformatListener.init();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
this.initOpenFileDialog();
|
||||
this.initReformatListener();
|
||||
}
|
||||
|
||||
private void initReformatListener() {
|
||||
this.reformatBtn.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
try {
|
||||
String fileTypeValue = fileType.getModel().getSelectedItem().toString();
|
||||
String spaceNumValue = spaceNum.getModel().getSelectedItem().toString();
|
||||
FileType fileType = FileType.valueOf(fileTypeValue);
|
||||
if (fileType.canReformat(selectFile.getName())) {
|
||||
String reformat = fileType.reformat(selectFile, Integer.valueOf(spaceNumValue));
|
||||
resultArea.setText(reformat);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "错误:文件类型错误!", "错误", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initOpenFileDialog() {
|
||||
this.uploadFileBtn.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
int option = fileChooser.showOpenDialog(resultArea);
|
||||
if (option == JFileChooser.APPROVE_OPTION){
|
||||
File file = fileChooser.getSelectedFile();
|
||||
selectFile = file;
|
||||
selectFileLabel.setText(file.getName());
|
||||
resultArea.setText(readContent(file));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void logException(Throwable throwable) {
|
||||
try (StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter)) {
|
||||
throwable.printStackTrace(printWriter);
|
||||
resultArea.setText(stringWriter.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("打印log异常!", e);
|
||||
}
|
||||
}
|
||||
|
||||
private String readContent(File file) {
|
||||
StringBuilder content = new StringBuilder();
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
|
||||
bufferedReader.lines().forEach(content::append);
|
||||
} catch (Exception e) {
|
||||
log.error("读取文件内容异常!", e);
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
public enum FileType implements FileReformat {
|
||||
XML {
|
||||
@Override
|
||||
public String reformat(File file, int spaceNum) throws Exception {
|
||||
return FileReformatUtil.reformatXML(file, spaceNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReformat(String name) {
|
||||
return name.toLowerCase().endsWith(".xml");
|
||||
}
|
||||
},
|
||||
HTML {
|
||||
@Override
|
||||
public String reformat(File file, int spaceNum) throws Exception {
|
||||
return FileReformatUtil.reformatHTML(file, spaceNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReformat(String name) {
|
||||
return name.toLowerCase().endsWith(".html") || name.toLowerCase().endsWith(".htm");
|
||||
}
|
||||
},
|
||||
JAVA {
|
||||
@Override
|
||||
public String reformat(File file, int spaceNum) throws Exception {
|
||||
return FileReformatUtil.reformatJAVA(file, spaceNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReformat(String name) {
|
||||
return name.toLowerCase().endsWith(".java");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public interface FileReformat {
|
||||
String reformat(File file, int spaceNum) throws Exception;
|
||||
|
||||
boolean canReformat(String name);
|
||||
}
|
||||
}
|
||||
+379
@@ -0,0 +1,379 @@
|
||||
package com.luoboduner.moo.tool.ui.listener.func;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.pdf.BadPdfFormatException;
|
||||
import com.itextpdf.text.pdf.PdfCopy;
|
||||
import com.itextpdf.text.pdf.PdfReader;
|
||||
import com.itextpdf.text.pdf.parser.PdfTextExtractor;
|
||||
import com.luoboduner.moo.tool.ui.UiConsts;
|
||||
import com.luoboduner.moo.tool.ui.dialog.CommonTipsDialog;
|
||||
import com.luoboduner.moo.tool.ui.form.func.PdfForm;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Slf4j
|
||||
public class PDFMergerListener {
|
||||
|
||||
private static Pattern rangeCompile = Pattern.compile("^\\d+([-;]\\d+?)*?$");
|
||||
private JPanel jPanel;
|
||||
private AbstractTableModel model;
|
||||
private List<Object[]> components;
|
||||
private JButton startMerge;
|
||||
private JLabel helpMerge;
|
||||
private JButton addFile;
|
||||
|
||||
private String outputDir;
|
||||
|
||||
public PDFMergerListener(JPanel jPanel, AbstractTableModel model) {
|
||||
this.jPanel = jPanel;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public void setComponents(List<Object[]> components) {
|
||||
this.components = components;
|
||||
}
|
||||
|
||||
public void startListener() {
|
||||
startMerge.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
super.mouseClicked(e);
|
||||
startMerge();
|
||||
}
|
||||
});
|
||||
|
||||
addFile.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
super.mouseClicked(e);
|
||||
((PdfForm.PDFTableModel) model).add();
|
||||
}
|
||||
});
|
||||
|
||||
helpMerge.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
CommonTipsDialog dialog = new CommonTipsDialog();
|
||||
|
||||
StringBuilder tipsBuilder = new StringBuilder();
|
||||
tipsBuilder.append("<h1>关于PDF合并</h1>");
|
||||
tipsBuilder.append("<p>1. 该合并功能默认可并行同时拆分10个PDF,可增加最大任务上线为20个。</p>");
|
||||
tipsBuilder.append("<p>2. 当勾选了待合并的任务后,该任务才会生效。</p>");
|
||||
tipsBuilder.append("<p>3. PDF合并范围默认1-最大页(PDF最大页),不可设置1-最大页以外的页数。</p>");
|
||||
tipsBuilder.append("<p>4. 合并范围可设置“范围”、“指定页”。<br/>");
|
||||
tipsBuilder.append("<ul>");
|
||||
tipsBuilder.append("<li>范围:1-5;6-7</li>");
|
||||
tipsBuilder.append("<li>指定页:1;5;9;10</li>");
|
||||
tipsBuilder.append("<li>范围与指定页(指定页与指定页,范围与范围)之间,需要用英文分号“;”隔开</li>");
|
||||
tipsBuilder.append("</ul></p>");
|
||||
tipsBuilder.append("<p>5. 合并后的文件在桌面目录下,文件名为“merge.pdf”。<br/>");
|
||||
tipsBuilder.append("<p>6. 本功能仅支持未加密的PDF。<br/>");
|
||||
|
||||
dialog.setHtmlText(tipsBuilder.toString());
|
||||
dialog.pack();
|
||||
dialog.setVisible(true);
|
||||
|
||||
super.mousePressed(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
JLabel label = (JLabel) e.getComponent();
|
||||
label.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
label.setIcon(UiConsts.HELP_FOCUSED_ICON);
|
||||
super.mouseEntered(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
JLabel label = (JLabel) e.getComponent();
|
||||
label.setIcon(UiConsts.HELP_ICON);
|
||||
super.mouseExited(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void selectFile(File file, int row) {
|
||||
String fileName = file.getName().toLowerCase();
|
||||
if (!fileName.endsWith(".pdf")) {
|
||||
showErrorMessage("错误:文件类型错误,该功能仅支持PDF格式文件。");
|
||||
} else {
|
||||
getPdfReader(file, reader -> {
|
||||
JLabel label = get(row, 2, JLabel.class);
|
||||
label.setText(file.getName());
|
||||
|
||||
int pages = reader.getNumberOfPages();
|
||||
JTextField jTextField = get(row, 3, JTextField.class);
|
||||
jTextField.setText("1-" + pages);
|
||||
|
||||
JProgressBar progressBar = get(row, 4, JProgressBar.class);
|
||||
JLabel statusLabel = get(row, 5, JLabel.class);
|
||||
progressBar.setValue(0);
|
||||
progressBar.updateUI();
|
||||
statusLabel.setText("未开始");
|
||||
|
||||
PdfParam param = getPdfParam(row);
|
||||
param.setFile(file);
|
||||
param.setPageRange("1-" + pages);
|
||||
param.setMaxPage(pages);
|
||||
});
|
||||
model.fireTableRowsUpdated(row, row);
|
||||
}
|
||||
}
|
||||
|
||||
public void setStartMerge(JButton startMerge) {
|
||||
this.startMerge = startMerge;
|
||||
}
|
||||
|
||||
public void setHelpMerge(JLabel helpMerge) {
|
||||
this.helpMerge = helpMerge;
|
||||
}
|
||||
|
||||
public void setAddFile(JButton addFile) {
|
||||
this.addFile = addFile;
|
||||
}
|
||||
|
||||
private void startMerge() {
|
||||
Document document= null;
|
||||
PdfCopy pdfCopy = null;
|
||||
int i = 0;
|
||||
try {
|
||||
checker();
|
||||
document = new Document();
|
||||
pdfCopy = new PdfCopy(document, new FileOutputStream(getOutputDir() + File.separator + "merge.pdf"));
|
||||
document.open();
|
||||
for (; i < this.components.size(); i++) {
|
||||
PdfParam pdfParam = getPdfParam(i);
|
||||
if (pdfParam.isMerge) {
|
||||
copyPdf(pdfParam, document, pdfCopy);
|
||||
|
||||
JProgressBar progressBar = get(i, 4, JProgressBar.class);
|
||||
progressBar.setValue(100);
|
||||
JLabel label = get(i, 5, JLabel.class);
|
||||
label.setText("已完成");
|
||||
model.fireTableRowsUpdated(i, i);
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
showErrorMessage("错误:" + e.getMessage());
|
||||
JTextField jTextField = get(i, 3, JTextField.class);
|
||||
PdfParam pdfParam = getPdfParam(i);
|
||||
ThreadUtil.execute(() -> jTextField.setText("1-" + pdfParam.getMaxPage()));
|
||||
} catch (Exception e) {
|
||||
log.error("合并文件错误!", e);
|
||||
} finally {
|
||||
if (null != document) {
|
||||
document.close();
|
||||
}
|
||||
if (null != pdfCopy) {
|
||||
pdfCopy.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T get(int row, int column, Class<T> tClass) {
|
||||
Object o = this.components.get(row)[column];
|
||||
return tClass.cast(o);
|
||||
}
|
||||
|
||||
private String getOutputDir() {
|
||||
if (StringUtils.isBlank(this.outputDir)) {
|
||||
synchronized (this) {
|
||||
if (StringUtils.isBlank(this.outputDir)) {
|
||||
this.outputDir = System.getProperty("user.home") + File.separator + "Desktop";
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.outputDir;
|
||||
}
|
||||
|
||||
private PdfParam getPdfParam(int row) {
|
||||
PdfParam param = get(row, 6, PdfParam.class);
|
||||
if (null == param) {
|
||||
param = initParam();
|
||||
this.components.get(row)[6] = param;
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
private PdfParam initParam() {
|
||||
PdfParam param = new PdfParam();
|
||||
param.setFile(null);
|
||||
param.setPageRange(null);
|
||||
param.setMaxPage(0);
|
||||
return param;
|
||||
}
|
||||
|
||||
private void showMessageDialog(String message, String title, int type) {
|
||||
JOptionPane.showMessageDialog(jPanel, message, title, type);
|
||||
}
|
||||
|
||||
private void showErrorMessage(String message) {
|
||||
showMessageDialog(message, "错误", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
private void getPdfReader(File file, Consumer<PdfReader> consumer) {
|
||||
PdfReader reader = null;
|
||||
try {
|
||||
reader = new PdfReader(file.getAbsolutePath());
|
||||
consumer.accept(reader);
|
||||
} catch (Exception e) {
|
||||
log.error("获取PDFReader出错!", e);
|
||||
} finally {
|
||||
if (null != reader) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void changeMergeRange(String text, int row) {
|
||||
PdfParam pdfParam = getPdfParam(row);
|
||||
pdfParam.setPageRange(text);
|
||||
}
|
||||
|
||||
private void checker() throws IllegalArgumentException {
|
||||
int mergeCount = 0;
|
||||
for (int i = 0; i < this.components.size(); i++) {
|
||||
PdfParam pdfParam = getPdfParam(i);
|
||||
if (pdfParam.isMerge) {
|
||||
if (null == pdfParam.getFile()) {
|
||||
throw new IllegalArgumentException(String.format("第%d个没有选择PDF文件!", i + 1));
|
||||
}
|
||||
if (!rangeCompile.matcher(pdfParam.getPageRange()).find()) {
|
||||
throw new IllegalArgumentException("PDF合并范围格式输入错误!");
|
||||
}
|
||||
validRange(pdfParam.getPageRange());
|
||||
if (pdfParam.outOfRange()) {
|
||||
throw new IllegalArgumentException(String.format("第%d个PDF文件合并范围有误,该PDF最大页数是%d!", i + 1, pdfParam.getMaxPage()));
|
||||
}
|
||||
mergeCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (mergeCount < 2) {
|
||||
throw new IllegalArgumentException("待合并的PDF最少是2个!");
|
||||
}
|
||||
}
|
||||
|
||||
public void setMerge(boolean isSelected, int row) {
|
||||
PdfParam pdfParam = getPdfParam(row);
|
||||
pdfParam.setMerge(isSelected);
|
||||
}
|
||||
|
||||
public void copyPdf(PdfParam param, Document document, PdfCopy pdfCopy) throws Exception {
|
||||
getPdfReader(param.getFile(), reader -> {
|
||||
int pages = reader.getNumberOfPages();
|
||||
if (0 == pages) {
|
||||
return;
|
||||
}
|
||||
Predicate<Integer> predicate = num -> {
|
||||
String[] ranges = param.pageRange.split(";");
|
||||
for (String range : ranges) {
|
||||
if (range.contains("-")) {
|
||||
String[] split = range.split("-");
|
||||
if (Integer.valueOf(split[0]) <= num && num <= Integer.valueOf(split[1])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
for (int i = 1; i <= pages; i++) {
|
||||
if (predicate.test(i)) {
|
||||
document.newPage();
|
||||
try {
|
||||
pdfCopy.addPage(pdfCopy.getImportedPage(reader, i));
|
||||
} catch (Exception e) {
|
||||
log.error("PDF拷贝出错!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void validRange(String pageRange) {
|
||||
String[] ranges = pageRange.split(";");
|
||||
for (String range : ranges) {
|
||||
if (range.contains("-")) {
|
||||
String[] split = range.split("-");
|
||||
if (Integer.valueOf(split[0]) > Integer.valueOf(split[1])) {
|
||||
throw new IllegalArgumentException("PDF合并范围格式输入错误!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PdfParam {
|
||||
/**
|
||||
* 待合并PDF页面范围
|
||||
*/
|
||||
private String pageRange;
|
||||
|
||||
private int maxPage;
|
||||
|
||||
private File file;
|
||||
|
||||
private boolean isMerge;
|
||||
|
||||
public String getPageRange() {
|
||||
return pageRange;
|
||||
}
|
||||
|
||||
public void setPageRange(String pageRange) {
|
||||
this.pageRange = pageRange;
|
||||
}
|
||||
|
||||
public int getMaxPage() {
|
||||
return maxPage;
|
||||
}
|
||||
|
||||
public void setMaxPage(int maxPage) {
|
||||
this.maxPage = maxPage;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public boolean isMerge() {
|
||||
return isMerge;
|
||||
}
|
||||
|
||||
public void setMerge(boolean merge) {
|
||||
isMerge = merge;
|
||||
}
|
||||
|
||||
private boolean outOfRange() {
|
||||
String[] ranges = this.pageRange.split(";");
|
||||
for (String range : ranges) {
|
||||
if (range.contains("-")) {
|
||||
String[] split = range.split("-");
|
||||
for (int i = Integer.valueOf(split[0]); i <= Integer.valueOf(split[1]); i++) {
|
||||
if (i < 1 || maxPage < i) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+495
@@ -0,0 +1,495 @@
|
||||
package com.luoboduner.moo.tool.ui.listener.func;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.pdf.PdfCopy;
|
||||
import com.itextpdf.text.pdf.PdfImportedPage;
|
||||
import com.itextpdf.text.pdf.PdfReader;
|
||||
import com.luoboduner.moo.tool.ui.UiConsts;
|
||||
import com.luoboduner.moo.tool.ui.dialog.CommonTipsDialog;
|
||||
import com.luoboduner.moo.tool.ui.form.func.PdfForm;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Slf4j
|
||||
public class PDFSplitterListener {
|
||||
|
||||
private JPanel jPanel;
|
||||
private AbstractTableModel model;
|
||||
private List<Object[]> components;
|
||||
|
||||
private JButton newTask;
|
||||
private JLabel helpBtn;
|
||||
private JButton startTask;
|
||||
|
||||
private static Pattern compile = Pattern.compile("^[0-9]+-[0-9]+$");
|
||||
private static Pattern ruleCompile = Pattern.compile("^\\d+([-;]\\d+?)*?$");
|
||||
|
||||
public PDFSplitterListener(JPanel jPanel, AbstractTableModel model) {
|
||||
this.jPanel = jPanel;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public void selectFile(File file, int row) {
|
||||
String fileName = file.getName().toLowerCase();
|
||||
if (!fileName.endsWith(".pdf")) {
|
||||
showErrorMessage("错误:文件类型错误,该功能仅支持PDF格式文件。");
|
||||
} else {
|
||||
JLabel label = get(row, 2, JLabel.class);
|
||||
label.setText(file.getName());
|
||||
getPdfReader(file, reader -> {
|
||||
int pages = reader.getNumberOfPages();
|
||||
JTextField jTextField = get(row, 3, JTextField.class);
|
||||
jTextField.setText("1-" + pages);
|
||||
|
||||
JProgressBar progressBar = get(row, 6, JProgressBar.class);
|
||||
JLabel statusLabel = get(row, 7, JLabel.class);
|
||||
progressBar.setValue(0);
|
||||
progressBar.updateUI();
|
||||
statusLabel.setText("未开始");
|
||||
|
||||
PdfParam param = getPdfParam(row);
|
||||
param.setFile(file);
|
||||
param.setPageRange("1-" + pages);
|
||||
param.setRule("");
|
||||
param.setMaxPage(pages);
|
||||
param.setSplitType(SplitType.ODD);
|
||||
});
|
||||
model.fireTableDataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private PdfParam initParam() {
|
||||
PdfParam param = new PdfParam();
|
||||
param.setFile(null);
|
||||
param.setPageRange(null);
|
||||
param.setRule("");
|
||||
param.setMaxPage(0);
|
||||
param.setSplitType(SplitType.ODD);
|
||||
return param;
|
||||
}
|
||||
|
||||
private PdfParam getPdfParam(int row) {
|
||||
PdfParam param = get(row, 8, PdfParam.class);
|
||||
if (null == param) {
|
||||
param = initParam();
|
||||
this.components.get(row)[8] = param;
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
public void changeSplitRange(String range, int row) {
|
||||
PdfParam param = this.getPdfParam(row);
|
||||
JTextField jTextField = get(row, 3, JTextField.class);
|
||||
if (null == param.getFile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(range)) {
|
||||
showErrorMessage("错误:拆分范围不能为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!compile.matcher(range).find()) {
|
||||
showErrorMessage("错误:拆分范围内容输入错误,例如(1-20或15-15)!");
|
||||
asyncRun(() -> jTextField.setText("1-" + param.getMaxPage()));
|
||||
} else {
|
||||
String[] split = range.split("-");
|
||||
Integer start = NumberUtils.createInteger(split[0]);
|
||||
Integer end = NumberUtils.createInteger(split[1]);
|
||||
if (start > end) {
|
||||
showErrorMessage("错误:拆分范围内容输入错误,例如(1-20或15-15)!");
|
||||
asyncRun(() -> jTextField.setText("1-" + param.getMaxPage()));
|
||||
return;
|
||||
}
|
||||
if (start < 1 || param.getMaxPage() < start) {
|
||||
showErrorMessage("错误:拆分范围内容输入错误,拆分起始页只能是1-" + param.getMaxPage() + "中任一一个数字。");
|
||||
asyncRun(() -> jTextField.setText("1-" + param.getMaxPage()));
|
||||
return;
|
||||
} else if (param.maxPage < end) {
|
||||
showErrorMessage("错误:拆分范围内容输入错误,拆分终止页只能是1-" + param.getMaxPage() + "中任一一个数字。");
|
||||
asyncRun(() -> jTextField.setText("1-" + param.getMaxPage()));
|
||||
return;
|
||||
}
|
||||
param.setPageRange(range);
|
||||
model.fireTableDataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void changeSplitRuleType(String type, int row) {
|
||||
SplitType splitType = SplitType.valueOfDesc(type);
|
||||
PdfParam param = this.getPdfParam(row);
|
||||
param.setSplitType(splitType);
|
||||
JTextField customRule = this.get(row, 5, JTextField.class);
|
||||
if (SplitType.CUSTOM == splitType) {
|
||||
customRule.setEnabled(true);
|
||||
} else {
|
||||
customRule.setEnabled(false);
|
||||
customRule.setText(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeSplitRule(String rule, int row) {
|
||||
if (StringUtils.isBlank(rule)) {
|
||||
showErrorMessage("错误:自定义规则不能为空!");
|
||||
return;
|
||||
}
|
||||
PdfParam param = this.getPdfParam(row);
|
||||
param.setRule(rule);
|
||||
}
|
||||
|
||||
public void setSplit(int row, boolean split) {
|
||||
PdfParam param = this.getPdfParam(row);
|
||||
param.setSplit(split);
|
||||
}
|
||||
|
||||
private <T> T get(int row, int column, Class<T> tClass) {
|
||||
Object o = this.components.get(row)[column];
|
||||
return tClass.cast(o);
|
||||
}
|
||||
|
||||
private void getPdfReader(File file, Consumer<PdfReader> consumer) {
|
||||
PdfReader reader = null;
|
||||
try {
|
||||
reader = new PdfReader(file.getAbsolutePath());
|
||||
consumer.accept(reader);
|
||||
} catch (Exception e) {
|
||||
log.error("获取PDFReader出错!", e);
|
||||
} finally {
|
||||
if (null != reader) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String ruleChecker(String rule) {
|
||||
if (StringUtils.isBlank(rule)) {
|
||||
return "自定义规则不能为空!";
|
||||
}
|
||||
if (!ruleCompile.matcher(rule).find()) {
|
||||
return "自定义规则格式输入错误!";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void startSplit() {
|
||||
List<String> errs = new ArrayList<>(1);
|
||||
forEachComponents((param, i) -> {
|
||||
if (SplitType.CUSTOM == param.getSplitType()) {
|
||||
String errorMsg = ruleChecker(param.getRule());
|
||||
if (StringUtils.isNotBlank(errorMsg)) {
|
||||
errs.add(0, "错误:" + param.getFile().getName() + errorMsg);
|
||||
}
|
||||
}
|
||||
if (param.isSplit && null == param.getFile()) {
|
||||
errs.add(0, String.format("错误:第%d个任务未选择文件!" , i + 1));
|
||||
}
|
||||
});
|
||||
|
||||
if (!errs.isEmpty()) {
|
||||
showErrorMessage(errs.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
forEachComponents((param, i) -> {
|
||||
JProgressBar progressBar = get(i, 6, JProgressBar.class);
|
||||
progressBar.setValue(0);
|
||||
model.fireTableCellUpdated(i, 6);
|
||||
JLabel label = get(i, 7, JLabel.class);
|
||||
label.setText("未开始");
|
||||
model.fireTableCellUpdated(i, 7);
|
||||
});
|
||||
|
||||
forEachComponents((param, n) -> {
|
||||
PdfReader reader = null;
|
||||
Document document = null;
|
||||
PdfCopy pdfCopy = null;
|
||||
try {
|
||||
JProgressBar progressBar = get(n, 6, JProgressBar.class);
|
||||
JLabel label = get(n, 7, JLabel.class);
|
||||
label.setText("拆分中");
|
||||
String filePath = param.getFile().getAbsolutePath();
|
||||
String parent = param.getFile().getParent();
|
||||
document = new Document();
|
||||
pdfCopy = new PdfCopy(document, new FileOutputStream(parent + File.separator + newFileName(param.getFile().getName())));
|
||||
reader = new PdfReader(filePath);
|
||||
int numberOfPages = reader.getNumberOfPages();
|
||||
document.open();
|
||||
String pageRange = param.getPageRange();
|
||||
String[] split = pageRange.split("-");
|
||||
for (int i = 1; i <= numberOfPages; i++) {
|
||||
if (Integer.valueOf(split[0]) <= i && i <= Integer.valueOf(split[1])) {
|
||||
if (param.getSplitType().canSplit(i, param.getRule())) {
|
||||
document.newPage();
|
||||
PdfImportedPage page = pdfCopy.getImportedPage(reader, i);
|
||||
pdfCopy.addPage(page);
|
||||
}
|
||||
}
|
||||
progressBar.setValue((int)((float) i / (float) numberOfPages * 100));
|
||||
progressBar.updateUI();
|
||||
model.fireTableDataChanged();
|
||||
}
|
||||
label.setText("已完成");
|
||||
model.fireTableDataChanged();
|
||||
} catch (Exception e) {
|
||||
log.error("拆分文件出错!", e);
|
||||
} finally {
|
||||
if (null != document) {
|
||||
document.close();
|
||||
}
|
||||
if (null != pdfCopy) {
|
||||
pdfCopy.close();
|
||||
}
|
||||
if (null != reader) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void asyncRun(Runnable runnable) {
|
||||
ThreadUtil.execute(runnable);
|
||||
}
|
||||
|
||||
private String newFileName(String fileName) {
|
||||
String lowerCaseName = fileName.toLowerCase();
|
||||
lowerCaseName = lowerCaseName.replace(".pdf", "");
|
||||
return lowerCaseName + "_split.pdf";
|
||||
}
|
||||
|
||||
private void forEachComponents(BiConsumer<PdfParam, Integer> consumer) {
|
||||
for (int i = 0; i < this.components.size(); i++) {
|
||||
Object[] objects = this.components.get(i);
|
||||
Object obj = objects[8];
|
||||
if (null == obj) {
|
||||
continue;
|
||||
}
|
||||
PdfParam param = (PdfParam) obj;
|
||||
if (param.isSplit) {
|
||||
consumer.accept(param, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startListener() {
|
||||
startTask.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
super.mouseClicked(e);
|
||||
startSplit();
|
||||
}
|
||||
});
|
||||
|
||||
newTask.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
super.mouseClicked(e);
|
||||
((PdfForm.PDFTableModel) model).add();
|
||||
}
|
||||
});
|
||||
|
||||
helpBtn.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
CommonTipsDialog dialog = new CommonTipsDialog();
|
||||
|
||||
StringBuilder tipsBuilder = new StringBuilder();
|
||||
tipsBuilder.append("<h1>关于PDF拆分</h1>");
|
||||
tipsBuilder.append("<p>1. 该拆分功能默认可并行同时拆分10个PDF,可增加最大任务上线为20个。</p>");
|
||||
tipsBuilder.append("<p>2. 当勾选了待拆分的任务后,该任务才会生效。</p>");
|
||||
tipsBuilder.append("<p>3. PDF拆分范围默认1-最大页(PDF最大页),不可设置1-最大页以外的页数。</p>");
|
||||
tipsBuilder.append("<p>4. 拆分规则为“奇数”、“偶数”、“自定义”三种规则,都依托于前面的拆分范围,当设定拆分范围后,拆分器按照“奇数”、“偶数”、“自定义”进行拆分。</p>");
|
||||
tipsBuilder.append("<p>5. 拆分规则为“自定义”规则时,需要设定自定义规则,该规则可设置“范围”、“指定页”。<br/>");
|
||||
tipsBuilder.append("<ul>");
|
||||
tipsBuilder.append("<li>范围:1-5;6-7</li>");
|
||||
tipsBuilder.append("<li>指定页:1;5;9;10</li>");
|
||||
tipsBuilder.append("<li>范围与指定页(指定页与指定页,范围与范围)之间,需要用英文分号“;”隔开</li>");
|
||||
tipsBuilder.append("</ul></p>");
|
||||
tipsBuilder.append("<p>6. 拆分后的文件在源文件的同级目录下,后缀为“_split.pdf”。<br/>");
|
||||
tipsBuilder.append("<p>7. 本功能仅支持未加密的PDF。<br/>");
|
||||
|
||||
dialog.setHtmlText(tipsBuilder.toString());
|
||||
dialog.pack();
|
||||
dialog.setVisible(true);
|
||||
|
||||
super.mousePressed(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
JLabel label = (JLabel) e.getComponent();
|
||||
label.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
label.setIcon(UiConsts.HELP_FOCUSED_ICON);
|
||||
super.mouseEntered(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
JLabel label = (JLabel) e.getComponent();
|
||||
label.setIcon(UiConsts.HELP_ICON);
|
||||
super.mouseExited(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showMessageDialog(String message, String title, int type) {
|
||||
JOptionPane.showMessageDialog(jPanel, message, title, type);
|
||||
}
|
||||
|
||||
private void showErrorMessage(String message) {
|
||||
showMessageDialog(message, "错误", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
public static class PdfParam {
|
||||
/** 待拆分PDF页面范围 */
|
||||
private String pageRange;
|
||||
/** 拆分类型 */
|
||||
private SplitType splitType;
|
||||
/** 拆分规则 */
|
||||
private String rule;
|
||||
|
||||
private int maxPage;
|
||||
|
||||
private File file;
|
||||
|
||||
private boolean isSplit;
|
||||
|
||||
public String getPageRange() {
|
||||
return pageRange;
|
||||
}
|
||||
|
||||
public void setPageRange(String pageRange) {
|
||||
this.pageRange = pageRange;
|
||||
}
|
||||
|
||||
public SplitType getSplitType() {
|
||||
return splitType;
|
||||
}
|
||||
|
||||
public void setSplitType(SplitType splitType) {
|
||||
this.splitType = splitType;
|
||||
}
|
||||
|
||||
public String getRule() {
|
||||
return rule;
|
||||
}
|
||||
|
||||
public void setRule(String rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public int getMaxPage() {
|
||||
return maxPage;
|
||||
}
|
||||
|
||||
public void setMaxPage(int maxPage) {
|
||||
this.maxPage = maxPage;
|
||||
}
|
||||
|
||||
public boolean isSplit() {
|
||||
return isSplit;
|
||||
}
|
||||
|
||||
public void setSplit(boolean split) {
|
||||
isSplit = split;
|
||||
}
|
||||
}
|
||||
|
||||
public interface SplitRule {
|
||||
boolean canSplit(Integer num, String rule);
|
||||
}
|
||||
|
||||
public enum SplitType implements SplitRule {
|
||||
EVEN("偶数") {
|
||||
@Override
|
||||
public boolean canSplit(Integer num, String rule) {
|
||||
return num % 2 == 0;
|
||||
}
|
||||
},
|
||||
ODD("奇数") {
|
||||
@Override
|
||||
public boolean canSplit(Integer num, String rule) {
|
||||
return num % 2 != 0;
|
||||
}
|
||||
},
|
||||
CUSTOM("自定义") {
|
||||
@Override
|
||||
public boolean canSplit(Integer num, String rule) {
|
||||
String[] args = rule.split(";");
|
||||
for (String elem : args) {
|
||||
if (elem.contains("-")) {
|
||||
String[] split = elem.split("-");
|
||||
if (Integer.valueOf(split[0]) <= num && num <= Integer.valueOf(split[1])) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (Integer.valueOf(elem).compareTo(num) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
private String desc;
|
||||
|
||||
SplitType(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public static SplitType valueOfDesc(String desc) {
|
||||
return Stream.of(SplitType.values())
|
||||
.filter(item -> item.getDesc().equals(desc))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
|
||||
public void setComponents(List<Object[]> components) {
|
||||
this.components = components;
|
||||
}
|
||||
|
||||
public void setNewTask(JButton newTask) {
|
||||
this.newTask = newTask;
|
||||
}
|
||||
|
||||
public void setHelpBtn(JLabel helpBtn) {
|
||||
this.helpBtn = helpBtn;
|
||||
}
|
||||
|
||||
public void setStartTask(JButton startTask) {
|
||||
this.startTask = startTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.luoboduner.moo.tool.util;
|
||||
|
||||
import de.hunsicker.jalopy.Jalopy;
|
||||
import de.hunsicker.jalopy.storage.Convention;
|
||||
import de.hunsicker.jalopy.storage.ConventionKeys;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import java.io.File;
|
||||
import java.io.StringWriter;
|
||||
|
||||
public class FileReformatUtil {
|
||||
|
||||
private static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
private static TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
private static Jalopy jalopy = new Jalopy();
|
||||
|
||||
public static String reformatXML(File file, int spaceNum) throws Exception {
|
||||
StringWriter res = new StringWriter();
|
||||
try {
|
||||
// 创建DocumentBuilder对象
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
// 解析XML文件并返回Document对象
|
||||
Document document = builder.parse(file);
|
||||
// 获取文档的根元素
|
||||
Element rootElement = document.getDocumentElement();
|
||||
|
||||
// 设置格式化属性,这里使用缩进和换行
|
||||
document.setXmlStandalone(true);
|
||||
document.setXmlVersion("1.0");
|
||||
rootElement.normalize();
|
||||
|
||||
// 创建Transformer对象
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
|
||||
// 设置输出格式化属性,这里使用缩进和换行
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING,"UTF-8");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", String.valueOf(spaceNum));
|
||||
|
||||
// 创建DOMSource对象
|
||||
DOMSource source = new DOMSource(document);
|
||||
|
||||
// 创建StreamResult对象,指定输出位置
|
||||
StreamResult result = new StreamResult(res);
|
||||
|
||||
// 格式化XML并输出结果
|
||||
transformer.transform(source, result);
|
||||
|
||||
return res.toString();
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
res.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static String reformatHTML(File file, int spaceNum) throws Exception {
|
||||
return Jsoup.parse(file, "UTF-8")
|
||||
.outputSettings(new org.jsoup.nodes.Document.OutputSettings().indentAmount(spaceNum))
|
||||
.outerHtml();
|
||||
}
|
||||
|
||||
public static String reformatJAVA(File file, int spaceNum) throws Exception {
|
||||
Convention instance = Convention.getInstance();
|
||||
instance.put(ConventionKeys.SPACE_BEFORE_BRACES, "true");
|
||||
instance.put(ConventionKeys.SPACE_BEFORE_BRACKETS, "true");
|
||||
instance.put(ConventionKeys.INDENT_SIZE, String.valueOf(spaceNum));
|
||||
|
||||
try (StringWriter stringWriter = new StringWriter()) {
|
||||
jalopy.setInput(file);
|
||||
jalopy.setOutput(stringWriter);
|
||||
jalopy.format();
|
||||
return stringWriter.toString();
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.luoboduner.moo.tool.util;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import java.io.File;
|
||||
import java.io.StringWriter;
|
||||
|
||||
public class XmlReformatUtil {
|
||||
|
||||
private static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
private static TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
|
||||
public static String reformat(File file, int spaceNum) throws Exception {
|
||||
StringWriter res = new StringWriter();
|
||||
try {
|
||||
// 创建DocumentBuilder对象
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
// 解析XML文件并返回Document对象
|
||||
Document document = builder.parse(file);
|
||||
// 获取文档的根元素
|
||||
Element rootElement = document.getDocumentElement();
|
||||
|
||||
// 设置格式化属性,这里使用缩进和换行
|
||||
document.setXmlStandalone(true);
|
||||
document.setXmlVersion("1.0");
|
||||
rootElement.normalize();
|
||||
|
||||
// 创建Transformer对象
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
|
||||
// 设置输出格式化属性,这里使用缩进和换行
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING,"UTF-8");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", String.valueOf(spaceNum));
|
||||
|
||||
// 创建DOMSource对象
|
||||
DOMSource source = new DOMSource(document);
|
||||
|
||||
// 创建StreamResult对象,指定输出位置
|
||||
StreamResult result = new StreamResult(res);
|
||||
|
||||
// 格式化XML并输出结果
|
||||
transformer.transform(source, result);
|
||||
|
||||
return res.toString();
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
res.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="26px" height="26px" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g><path style="opacity:0.063" fill="#0c0c0c" d="M 14.5,-0.5 C 16.1667,-0.5 17.8333,-0.5 19.5,-0.5C 19.5,0.166667 19.8333,0.5 20.5,0.5C 20.1667,1.16667 19.8333,1.83333 19.5,2.5C 18.391,2.44312 17.391,2.10978 16.5,1.5C 15.5084,1.67158 14.8417,1.33825 14.5,0.5C 14.5,0.166667 14.5,-0.166667 14.5,-0.5 Z"/></g>
|
||||
<g><path style="opacity:0.555" fill="#191919" d="M 14.5,0.5 C 14.8417,1.33825 15.5084,1.67158 16.5,1.5C 16.1667,2.16667 15.8333,2.83333 15.5,3.5C 14.5041,3.41423 13.6708,3.74756 13,4.5C 12.2917,3.61947 11.4584,2.9528 10.5,2.5C 11.287,0.895779 12.6203,0.229113 14.5,0.5 Z"/></g>
|
||||
<g><path style="opacity:0.945" fill="#1a1a1a" d="M 20.5,0.5 C 23.2974,0.966592 24.6308,2.63326 24.5,5.5C 23.609,4.89022 22.609,4.55688 21.5,4.5C 20.8333,3.83333 20.1667,3.16667 19.5,2.5C 19.8333,1.83333 20.1667,1.16667 20.5,0.5 Z"/></g>
|
||||
<g><path style="opacity:0.707" fill="#090909" d="M 10.5,2.5 C 11.4584,2.9528 12.2917,3.61947 13,4.5C 13.6708,3.74756 14.5041,3.41423 15.5,3.5C 15.1667,4.16667 14.8333,4.83333 14.5,5.5C 14.2648,6.09674 13.7648,6.43007 13,6.5C 11.9889,5.94442 11.1556,5.27775 10.5,4.5C 9.83333,4.5 9.16667,4.5 8.5,4.5C 8.5,3.16667 9.16667,2.5 10.5,2.5 Z"/></g>
|
||||
<g><path style="opacity:0.818" fill="#171717" d="M 15.5,3.5 C 17.8552,4.52178 19.5218,6.18844 20.5,8.5C 19.8333,8.83333 19.1667,9.16667 18.5,9.5C 17.7611,9.63101 17.0944,9.46434 16.5,9C 15.9152,7.69762 15.2485,6.53095 14.5,5.5C 14.8333,4.83333 15.1667,4.16667 15.5,3.5 Z"/></g>
|
||||
<g><path style="opacity:0.647" fill="#1f1f1f" d="M 8.5,4.5 C 9.16667,4.5 9.83333,4.5 10.5,4.5C 8.91903,6.30256 6.91903,7.63589 4.5,8.5C 4.5,7.16667 4.5,5.83333 4.5,4.5C 5.7054,3.31434 7.03874,3.31434 8.5,4.5 Z"/></g>
|
||||
<g><path style="opacity:0.79" fill="#0b0b0b" d="M 21.5,4.5 C 22.609,4.55688 23.609,4.89022 24.5,5.5C 24.8333,5.5 25.1667,5.5 25.5,5.5C 25.5,7.16667 25.5,8.83333 25.5,10.5C 25.1667,10.5 24.8333,10.5 24.5,10.5C 23.8333,10.5 23.1667,10.5 22.5,10.5C 22.5774,9.25025 23.244,8.41691 24.5,8C 22.9443,7.27985 21.9443,6.11318 21.5,4.5 Z"/></g>
|
||||
<g><path style="opacity:0.966" fill="#060606" d="M 4.5,4.5 C 4.5,5.83333 4.5,7.16667 4.5,8.5C 2.80072,8.52709 1.46739,9.19376 0.5,10.5C 0.166667,10.5 -0.166667,10.5 -0.5,10.5C -0.5,10.1667 -0.5,9.83333 -0.5,9.5C 0.316435,7.85639 1.64977,6.68972 3.5,6C 2.2881,4.89318 2.62143,4.39318 4.5,4.5 Z"/></g>
|
||||
<g><path style="opacity:0.438" fill="#030303" d="M 12.5,8.5 C 12.5,8.83333 12.5,9.16667 12.5,9.5C 10.302,9.12012 8.63535,9.78679 7.5,11.5C 6.83333,11.5 6.5,11.8333 6.5,12.5C 6.16667,12.5 5.83333,12.5 5.5,12.5C 6.44458,9.01319 8.77791,7.67986 12.5,8.5 Z"/></g>
|
||||
<g><path style="opacity:0.729" fill="#1f1f1f" d="M 12.5,9.5 C 11.7375,10.2679 10.7375,10.7679 9.5,11C 10.4158,11.2784 11.0825,11.7784 11.5,12.5C 10.391,12.5569 9.39105,12.8902 8.5,13.5C 8.67158,12.5084 8.33825,11.8417 7.5,11.5C 8.63535,9.78679 10.302,9.12012 12.5,9.5 Z"/></g>
|
||||
<g><path style="opacity:0.698" fill="#0a0a0a" d="M 12.5,8.5 C 13.8333,9.16667 14.8333,10.1667 15.5,11.5C 14.0687,12.7804 13.4021,14.4471 13.5,16.5C 12.8333,16.5 12.1667,16.5 11.5,16.5C 12.6857,15.0387 12.6857,13.7054 11.5,12.5C 11.0825,11.7784 10.4158,11.2784 9.5,11C 10.7375,10.7679 11.7375,10.2679 12.5,9.5C 12.5,9.16667 12.5,8.83333 12.5,8.5 Z"/></g>
|
||||
<g><path style="opacity:0.58" fill="#0a0a0a" d="M 20.5,8.5 C 21.3382,8.84171 21.6716,9.50838 21.5,10.5C 20.6236,10.3691 19.9569,10.7025 19.5,11.5C 19.8457,12.6956 20.3457,12.6956 21,11.5C 21.5133,12.5266 22.0133,13.5266 22.5,14.5C 22.2178,15.7777 21.5511,16.7777 20.5,17.5C 19.8333,17.5 19.5,17.8333 19.5,18.5C 19.1667,18.5 18.8333,18.5 18.5,18.5C 18.2267,16.549 18.8934,15.049 20.5,14C 18.8934,12.951 18.2267,11.451 18.5,9.5C 19.1667,9.16667 19.8333,8.83333 20.5,8.5 Z"/></g>
|
||||
<g><path style="opacity:0.975" fill="#171717" d="M 4.5,8.5 C 3.62896,10.0582 2.62896,11.7249 1.5,13.5C 0.596028,14.209 0.262695,15.209 0.5,16.5C 0.166667,16.5 -0.166667,16.5 -0.5,16.5C -0.5,14.8333 -0.5,13.1667 -0.5,11.5C 0.166667,11.5 0.5,11.1667 0.5,10.5C 1.46739,9.19376 2.80072,8.52709 4.5,8.5 Z"/></g>
|
||||
<g><path style="opacity:0.718" fill="#191919" d="M 21.5,10.5 C 21.8333,10.5 22.1667,10.5 22.5,10.5C 23.1667,10.5 23.8333,10.5 24.5,10.5C 24.7709,12.3797 24.1042,13.713 22.5,14.5C 22.0133,13.5266 21.5133,12.5266 21,11.5C 20.3457,12.6956 19.8457,12.6956 19.5,11.5C 19.9569,10.7025 20.6236,10.3691 21.5,10.5 Z"/></g>
|
||||
<g><path style="opacity:0.778" fill="#191919" d="M 15.5,11.5 C 16.8333,13.5 16.8333,15.5 15.5,17.5C 14.5084,17.6716 13.8417,17.3382 13.5,16.5C 13.4021,14.4471 14.0687,12.7804 15.5,11.5 Z"/></g>
|
||||
<g><path style="opacity:0.843" fill="#080808" d="M 5.5,12.5 C 5.83333,12.5 6.16667,12.5 6.5,12.5C 6.17798,14.7224 6.84464,16.5557 8.5,18C 8.27155,18.3988 7.93822,18.5654 7.5,18.5C 4.65109,17.0804 3.98442,15.0804 5.5,12.5 Z"/></g>
|
||||
<g><path style="opacity:0.688" fill="#101010" d="M 7.5,11.5 C 8.33825,11.8417 8.67158,12.5084 8.5,13.5C 8.55688,14.609 8.89022,15.609 9.5,16.5C 9.91753,17.2216 10.5842,17.7216 11.5,18C 10.5842,18.2784 9.91753,18.7784 9.5,19.5C 8.50838,19.6716 7.84171,19.3382 7.5,18.5C 7.93822,18.5654 8.27155,18.3988 8.5,18C 6.84464,16.5557 6.17798,14.7224 6.5,12.5C 6.5,11.8333 6.83333,11.5 7.5,11.5 Z"/></g>
|
||||
<g><path style="opacity:0.792" fill="#2d2d2d" d="M 1.5,13.5 C 2.94183,14.8195 3.60849,16.4862 3.5,18.5C 2.83333,18.5 2.5,18.8333 2.5,19.5C 1.83333,18.5 1.16667,17.5 0.5,16.5C 0.262695,15.209 0.596028,14.209 1.5,13.5 Z"/></g>
|
||||
<g><path style="opacity:0.878" fill="#272727" d="M 9.5,16.5 C 10.1667,16.5 10.8333,16.5 11.5,16.5C 12.1667,16.5 12.8333,16.5 13.5,16.5C 13.8417,17.3382 14.5084,17.6716 15.5,17.5C 13.9148,19.9817 11.9148,20.6484 9.5,19.5C 9.91753,18.7784 10.5842,18.2784 11.5,18C 10.5842,17.7216 9.91753,17.2216 9.5,16.5 Z"/></g>
|
||||
<g><path style="opacity:0.638" fill="#090909" d="M 0.5,16.5 C 1.16667,17.5 1.83333,18.5 2.5,19.5C 2.83333,19.5 3.16667,19.5 3.5,19.5C 3.16667,20.1667 2.83333,20.8333 2.5,21.5C 1.5,20.8333 0.5,20.1667 -0.5,19.5C -0.5,18.8333 -0.5,18.1667 -0.5,17.5C 0.166667,17.5 0.5,17.1667 0.5,16.5 Z"/></g>
|
||||
<g><path style="opacity:0.292" fill="#202020" d="M 20.5,17.5 C 21.5735,18.2506 21.7401,19.2506 21,20.5C 19.6412,21.365 18.4745,22.365 17.5,23.5C 17.5,22.1667 17.5,20.8333 17.5,19.5C 17.5,18.8333 17.8333,18.5 18.5,18.5C 18.8333,19.8333 19.1667,19.8333 19.5,18.5C 19.5,17.8333 19.8333,17.5 20.5,17.5 Z"/></g>
|
||||
<g><path style="opacity:0.727" fill="#161616" d="M 3.5,18.5 C 4.92203,19.925 6.5887,20.925 8.5,21.5C 7.89022,22.391 7.55688,23.391 7.5,24.5C 7.5,24.8333 7.5,25.1667 7.5,25.5C 6.83333,25.5 6.16667,25.5 5.5,25.5C 3.63694,24.2739 2.63694,22.9406 2.5,21.5C 2.83333,20.8333 3.16667,20.1667 3.5,19.5C 3.5,19.1667 3.5,18.8333 3.5,18.5 Z"/></g>
|
||||
<g><path style="opacity:0.778" fill="#1d1d1d" d="M 8.5,21.5 C 9.5,21.8333 10.1667,22.5 10.5,23.5C 12.0502,23.4921 13.7168,23.8254 15.5,24.5C 15.5,24.8333 15.5,25.1667 15.5,25.5C 13.1667,25.5 10.8333,25.5 8.5,25.5C 8.5,24.8333 8.16667,24.5 7.5,24.5C 7.55688,23.391 7.89022,22.391 8.5,21.5 Z"/></g>
|
||||
<g><path style="opacity:1" fill="#0c0c0c" d="M 17.5,19.5 C 17.5,20.8333 17.5,22.1667 17.5,23.5C 17.1583,24.3382 16.4916,24.6716 15.5,24.5C 13.7168,23.8254 12.0502,23.4921 10.5,23.5C 11.684,21.5901 13.184,21.2568 15,22.5C 15.2355,20.8807 16.0689,19.8807 17.5,19.5 Z"/></g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 7.4 KiB |
Executable
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="22px" height="27px" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g><path style="opacity:0.638" fill="#212121" d="M 0.5,0.5 C 0.5,0.166667 0.5,-0.166667 0.5,-0.5C 3.83333,-0.5 7.16667,-0.5 10.5,-0.5C 8.93966,1.12936 9.27299,2.29602 11.5,3C 9.19018,3.49665 6.85684,3.66331 4.5,3.5C 4.5,3.16667 4.5,2.83333 4.5,2.5C 4.02694,1.09368 3.02694,0.427017 1.5,0.5C 1.16667,0.5 0.833333,0.5 0.5,0.5 Z"/></g>
|
||||
<g><path style="opacity:0.699" fill="#242424" d="M -0.5,0.5 C -0.166667,0.5 0.166667,0.5 0.5,0.5C 0.833333,0.5 1.16667,0.5 1.5,0.5C 0.866013,7.59992 0.199346,14.5999 -0.5,21.5C -0.5,14.5 -0.5,7.5 -0.5,0.5 Z"/></g>
|
||||
<g><path style="opacity:0.731" fill="#323232" d="M 1.5,0.5 C 3.02694,0.427017 4.02694,1.09368 4.5,2.5C 3.83333,2.5 3.5,2.83333 3.5,3.5C 2.83333,3.5 2.5,3.83333 2.5,4.5C 2.8235,11.0221 2.49016,17.3554 1.5,23.5C 1.15829,22.6618 0.491622,22.3284 -0.5,22.5C -0.5,22.1667 -0.5,21.8333 -0.5,21.5C 0.199346,14.5999 0.866013,7.59992 1.5,0.5 Z"/></g>
|
||||
<g><path style="opacity:0.223" fill="#3d3d3d" d="M 2.5,4.5 C 2.83333,4.5 3.16667,4.5 3.5,4.5C 3.5,11.1667 3.5,17.8333 3.5,24.5C 2.50838,24.6716 1.84171,24.3382 1.5,23.5C 2.49016,17.3554 2.8235,11.0221 2.5,4.5 Z"/></g>
|
||||
<g><path style="opacity:0.761" fill="#262626" d="M 10.5,-0.5 C 10.8333,-0.5 11.1667,-0.5 11.5,-0.5C 12.1667,0.5 12.8333,1.5 13.5,2.5C 12.6618,2.84171 12.3284,3.50838 12.5,4.5C 10.1432,4.33669 7.80982,4.50335 5.5,5C 4.94404,5.38258 4.61071,5.88258 4.5,6.5C 4.5,9.5 4.5,12.5 4.5,15.5C 4.5,16.5 4.5,17.5 4.5,18.5C 4.20528,20.7354 4.53862,22.7354 5.5,24.5C 6.5,24.5 7.5,24.5 8.5,24.5C 12.2984,25.4834 16.2984,25.8168 20.5,25.5C 20.5,25.8333 20.5,26.1667 20.5,26.5C 14.8333,26.5 9.16667,26.5 3.5,26.5C 3.5,25.8333 3.5,25.1667 3.5,24.5C 3.5,17.8333 3.5,11.1667 3.5,4.5C 3.5,4.16667 3.5,3.83333 3.5,3.5C 3.83333,3.5 4.16667,3.5 4.5,3.5C 6.85684,3.66331 9.19018,3.49665 11.5,3C 9.27299,2.29602 8.93966,1.12936 10.5,-0.5 Z"/></g>
|
||||
<g><path style="opacity:0.623" fill="#252525" d="M 13.5,2.5 C 16.1667,4.83333 18.8333,7.16667 21.5,9.5C 21.5,14.8333 21.5,20.1667 21.5,25.5C 21.1667,25.5 20.8333,25.5 20.5,25.5C 20.8195,20.6367 20.4861,15.97 19.5,11.5C 14.1667,12.1667 11.8333,9.83333 12.5,4.5C 12.3284,3.50838 12.6618,2.84171 13.5,2.5 Z M 14.5,6.5 C 15.6266,7.12167 16.6266,7.95501 17.5,9C 15.5106,9.51922 14.5106,8.68588 14.5,6.5 Z"/></g>
|
||||
<g><path style="opacity:0.746" fill="#474747" d="M 4.5,6.5 C 5.3171,8.96864 5.8171,11.6353 6,14.5C 9.03958,13.7919 12.2062,13.7919 15.5,14.5C 17.099,14.2322 18.4324,14.5655 19.5,15.5C 16.9487,20.7101 13.2821,21.7101 8.5,18.5C 7.89333,18.6236 7.55999,18.9569 7.5,19.5C 6.50838,19.6716 5.84171,19.3382 5.5,18.5C 5.73731,17.209 5.40397,16.209 4.5,15.5C 4.5,12.5 4.5,9.5 4.5,6.5 Z"/></g>
|
||||
<g><path style="opacity:0.027" fill="#ededed" d="M 4.5,18.5 C 4.83333,18.5 5.16667,18.5 5.5,18.5C 5.84171,19.3382 6.50838,19.6716 7.5,19.5C 6.03201,20.7791 5.36534,22.4458 5.5,24.5C 4.53862,22.7354 4.20528,20.7354 4.5,18.5 Z"/></g>
|
||||
<g><path style="opacity:0.056" fill="#101010" d="M 19.5,11.5 C 20.4861,15.97 20.8195,20.6367 20.5,25.5C 16.2984,25.8168 12.2984,25.4834 8.5,24.5C 12.1667,24.5 15.8333,24.5 19.5,24.5C 19.5,21.5 19.5,18.5 19.5,15.5C 18.4324,14.5655 17.099,14.2322 15.5,14.5C 17.2191,13.9779 18.5525,12.9779 19.5,11.5 Z"/></g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.5 KiB |
Reference in New Issue
Block a user