First Commit

This commit is contained in:
2024-03-15 10:14:00 +01:00
commit a55f32a72c
56 changed files with 1863 additions and 0 deletions

3
Datenblatt/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@@ -0,0 +1,18 @@
<component name="ArtifactManager">
<artifact type="jar" name="Datenblatt:jar">
<output-path>$PROJECT_DIR$/out/artifacts/Datenblatt_jar</output-path>
<root id="archive" name="Datenblatt.jar">
<element id="module-output" name="Datenblatt" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/pdfbox-tools-2.0.27.jar" path-in-jar="/" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/pdfbox-2.0.27.jar" path-in-jar="/" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/fontbox-2.0.27.jar" path-in-jar="/" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/preflight-2.0.27.jar" path-in-jar="/" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/xmpbox-2.0.27.jar" path-in-jar="/" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/commons-logging-1.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/org.eclipse.swt-3.1.jar/org.eclipse.swt-3.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/iText7-pdfHtml-4.0.5-only-jars/html2pdf-4.0.5.jar" path-in-jar="/" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/itextpdf-5.5.13.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$USER_HOME$/Downloads/pdf-renderer.jar/pdf-renderer.jar" path-in-jar="/" />
</root>
</artifact>
</component>

13
Datenblatt/.idea/compiler.xml generated Normal file
View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="Datenblatt" />
</profile>
</annotationProcessing>
</component>
</project>

7
Datenblatt/.idea/encodings.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

View File

@@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaDocConfiguration">
<GENERAL>
<MODE>UPDATE</MODE>
<OVERRIDDEN_METHODS>false</OVERRIDDEN_METHODS>
<SPLITTED_CLASS_NAME>true</SPLITTED_CLASS_NAME>
<LEVELS>
<LEVEL>TYPE</LEVEL>
<LEVEL>METHOD</LEVEL>
<LEVEL>FIELD</LEVEL>
</LEVELS>
<VISIBILITIES>
<VISIBILITY>DEFAULT</VISIBILITY>
<VISIBILITY>PROTECTED</VISIBILITY>
<VISIBILITY>PUBLIC</VISIBILITY>
</VISIBILITIES>
</GENERAL>
<TEMPLATES>
<CLASSES>
<CLASS>
<KEY>^.*(public|protected|private)*.+interface\s+\w+.*</KEY>
<VALUE>/**\n
* The interface ${name}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
*/</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+enum\s+\w+.*</KEY>
<VALUE>/**\n
* The enum ${name}.\n
*/</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+class\s+\w+.*</KEY>
<VALUE>/**\n
* The type ${name}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
*/</VALUE>
</CLASS>
<CLASS>
<KEY>.+</KEY>
<VALUE>/**\n
* The type ${name}.\n
*/</VALUE>
</CLASS>
</CLASSES>
<CONSTRUCTORS>
<CONSTRUCTOR>
<KEY>.+</KEY>
<VALUE>/**\n
* Instantiates a new ${name}.\n
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</CONSTRUCTOR>
</CONSTRUCTORS>
<METHODS>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(\w(\s*&lt;.+&gt;)*)+\s+get\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* Gets ${partName}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${partName}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(void|\w(\s*&lt;.+&gt;)*)+\s+set\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* Sets ${partName}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${partName}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+</KEY>
<VALUE>/**\n
* The entry point of application.\n
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
* @param ${element.parameterList.parameters[0].name} the input arguments\n
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>.+</KEY>
<VALUE>/**\n
* ${name}&lt;#if isNotVoid&gt; ${return}&lt;/#if&gt;.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${return}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
</METHODS>
<FIELDS>
<FIELD>
<KEY>^.*(public|protected|private)*.+static.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
* The constant ${element.getName()}.\n
*/</VALUE>
</FIELD>
<FIELD>
<KEY>^.*(public|protected|private)*.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
&lt;#if element.parent.isInterface()&gt;
* The constant ${element.getName()}.\n
&lt;#else&gt;
* The ${name}.\n
&lt;/#if&gt; */</VALUE>
</FIELD>
<FIELD>
<KEY>.+</KEY>
<VALUE>/**\n
&lt;#if element.parent.isEnum()&gt;
*${name} ${typeName}.\n
&lt;#else&gt;
* The ${name}.\n
&lt;/#if&gt;*/</VALUE>
</FIELD>
</FIELDS>
</TEMPLATES>
</component>
</project>

20
Datenblatt/.idea/jarRepositories.xml generated Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

View File

@@ -0,0 +1,18 @@
<component name="libraryTable">
<library name="commons-logging-1.2">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../JAR-Libs/commons-logging-1.2.jar!/" />
<root url="jar://$PROJECT_DIR$/../JAR-Libs/fontbox-2.0.27.jar!/" />
<root url="jar://$PROJECT_DIR$/../JAR-Libs/html2pdf-4.0.5.jar!/" />
<root url="jar://$PROJECT_DIR$/../JAR-Libs/itextpdf-5.5.13.2.jar!/" />
<root url="jar://$PROJECT_DIR$/../JAR-Libs/org.eclipse.swt-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/../JAR-Libs/pdf-renderer.jar!/" />
<root url="jar://$PROJECT_DIR$/../JAR-Libs/pdfbox-2.0.27.jar!/" />
<root url="jar://$PROJECT_DIR$/../JAR-Libs/pdfbox-tools-2.0.27.jar!/" />
<root url="jar://$PROJECT_DIR$/../JAR-Libs/preflight-2.0.27.jar!/" />
<root url="jar://$PROJECT_DIR$/../JAR-Libs/xmpbox-2.0.27.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="kenai.nbpwr.sun.pdfview" type="repository">
<properties maven-id="com.kenai.nbpwr:com-sun-pdfview:1.0.5-201003191900" />
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/com-sun-pdfview-1.0.5-201003191900.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/pdf-renderer-1.0.5.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

14
Datenblatt/.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

124
Datenblatt/.idea/uiDesigner.xml generated Normal file
View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

6
Datenblatt/.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

BIN
Datenblatt/Datenblatt.pdf Normal file

Binary file not shown.

BIN
Datenblatt/Datenblatt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

13
Datenblatt/TODO.txt Normal file
View File

@@ -0,0 +1,13 @@
TODO:
- Vorschau lässt sich nur einmal aktualisieren
> kein Dateizugriff
- Einzeiligen freien Text hinzufügen
> Besonderheiten / Extras (z.B.: Office-Paket)
- Displaygrößen angeben
- Erkennen, ob bereits eine Instanz läuft, und dann nicht starten, um Fehler zu vermeiden
> https://blog.bigbasti.com/prufen-ob-ein-eigenes-programm-bereits-geoffnet-ist/
- Benutzerdefinierte Listen:
> Datenträgertypen
> Dynamische Datenträgergrößen, usw...
- Druck in andere Formate
> z.B.: A5, A6, 10x15

Binary file not shown.

Binary file not shown.

BIN
Datenblatt/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

18
Datenblatt/pom.xml Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.dejan_hopp</groupId>
<artifactId>Datenblatt</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

2
Datenblatt/settings.conf Normal file
View File

@@ -0,0 +1,2 @@
#Tue Feb 14 14:34:42 CET 2023
printerName=LAGER

View File

@@ -0,0 +1,15 @@
package de.dejan_hopp;
import java.util.Properties;
public class Datenblatt {
public static Properties cpu=new Properties();
public static Properties gpu=new Properties();
public static Properties storage=new Properties();
public static Properties memory=new Properties();
public static Properties os=new Properties();
public static Properties price =new Properties();
public static int storageAnzahl=1;
}

View File

@@ -0,0 +1,149 @@
package de.dejan_hopp;
import de.dejan_hopp.io.Kbd;
import java.io.IOException;
public class Features {
public static void cpu(){
System.out.println("--------------------");
System.out.println("CPU-Eigenschaften:");
System.out.print("Hersteller:");
Datenblatt.cpu.setProperty("manufacturer", Kbd.readString());
System.out.print("CPU-Name:");
Datenblatt.cpu.setProperty("name",Kbd.readString());
System.out.print("Anzahl der Kerne:");
Datenblatt.cpu.setProperty("cores",Kbd.readString());
System.out.print("Anzahl der Threads:");
Datenblatt.cpu.setProperty("threads",Kbd.readString());
System.out.print("Taktfrequenz in MHz:");
Datenblatt.cpu.setProperty("mhz",Kbd.readString());
}
public static void gpu(){
System.out.println("--------------------");
System.out.println("Grafik-Eigenschaften:");
System.out.print("Hersteller:");
Datenblatt.gpu.setProperty("manufacturer",Kbd.readString());
System.out.print("GPU-Name:");
Datenblatt.gpu.setProperty("name",Kbd.readString());
System.out.print("Taktfrequenz in MHz:");
Datenblatt.gpu.setProperty("mhz",Kbd.readString());
}
public static void storage(){
System.out.println("--------------------");
System.out.println("Datenträger:");
System.out.print("Anzahl:");
try {
Datenblatt.storageAnzahl=Kbd.readInt();
}catch (IOException ioe){
System.out.println("FEHLER!: Es wurde keine Zahl eingegeben!");
}
if(Datenblatt.storageAnzahl==1){
System.out.print("Datenträgertyp(SSD oder HDD):");
Datenblatt.storage.setProperty("drive1Type",Kbd.readString());
System.out.print("Kapazität in GB:");
Datenblatt.storage.setProperty("drive1Capacity",Kbd.readString());
} else if (Datenblatt.storageAnzahl==2) {
//Datenträger 1
System.out.print("1. Datenträgertyp(SSD oder HDD):");
Datenblatt.storage.setProperty("drive1Type",Kbd.readString());
System.out.print("Kapazität in GB:");
Datenblatt.storage.setProperty("drive1Capacity",Kbd.readString());
//Datenträger 2
System.out.print("2. Datenträgertyp(SSD oder HDD):");
Datenblatt.storage.setProperty("drive2Type",Kbd.readString());
System.out.print("Kapazität in GB:");
Datenblatt.storage.setProperty("drive2Capacity",Kbd.readString());
} else if (Datenblatt.storageAnzahl==3) {
//Datenträger 1
System.out.print("1. Datenträgertyp(SSD oder HDD):");
Datenblatt.storage.setProperty("drive1Type",Kbd.readString());
System.out.print("Kapazität in GB:");
Datenblatt.storage.setProperty("drive1Capacity",Kbd.readString());
//Datenträger 2
System.out.print("2. Datenträgertyp(SSD oder HDD):");
Datenblatt.storage.setProperty("drive2Type",Kbd.readString());
System.out.print("Kapazität in GB:");
Datenblatt.storage.setProperty("drive2Capacity",Kbd.readString());
//Datenträger 3
System.out.print("3. Datenträgertyp(SSD oder HDD):");
Datenblatt.storage.setProperty("drive3Type",Kbd.readString());
System.out.print("Kapazität in GB:");
Datenblatt.storage.setProperty("drive3Capacity",Kbd.readString());
} else if (Datenblatt.storageAnzahl==4) {
//Datenträger 1
System.out.print("1. Datenträgertyp(SSD oder HDD):");
Datenblatt.storage.setProperty("drive1Type",Kbd.readString());
System.out.print("Kapazität in GB:");
Datenblatt.storage.setProperty("drive1Capacity",Kbd.readString());
//Datenträger 2
System.out.print("2. Datenträgertyp(SSD oder HDD):");
Datenblatt.storage.setProperty("drive2Type",Kbd.readString());
System.out.print("Kapazität in GB:");
Datenblatt.storage.setProperty("drive2Capacity",Kbd.readString());
//Datenträger 3
System.out.print("3. Datenträgertyp(SSD oder HDD):");
Datenblatt.storage.setProperty("drive3Type",Kbd.readString());
System.out.print("Kapazität in GB:");
Datenblatt.storage.setProperty("drive3Capacity",Kbd.readString());
//Datenträger 4
System.out.print("1. Datenträgertyp(SSD oder HDD):");
Datenblatt.storage.setProperty("drive4Type",Kbd.readString());
System.out.print("Kapazität in GB:");
Datenblatt.storage.setProperty("drive4Capacity",Kbd.readString());
} else System.out.println("Falsche Eingabe!");
}
public static void memory(){
System.out.println("--------------------");
System.out.println("RAM:");
System.out.print("Kapazität in GB:");
Datenblatt.memory.setProperty("capacity",Kbd.readString());
System.out.print("DDR-Version(\"DDRx\"):");
Datenblatt.memory.setProperty("ddrVersion",Kbd.readString());
}
public static void os(){
System.out.println("--------------------");
System.out.print("Welches Betreibssystem ist installiert?:");
Datenblatt.os.setProperty("name",Kbd.readString());
}
public static void clearFeatures(){
System.out.println("--------------------");
System.out.print("Datenblatt zurücksetzen?(y/n)");
if(Kbd.readString().equals("y")||Kbd.readString().equals("Y")){
Datenblatt.cpu.clear();
Datenblatt.gpu.clear();
Datenblatt.storage.clear();
Datenblatt.memory.clear();
Datenblatt.os.clear();
Datenblatt.price.clear();
Datenblatt.storageAnzahl=1;
} else System.out.println("Abgebrochen");
}
public static void setPrice(){
System.out.println("--------------------");
System.out.print("Wieviel kostet dieser PC/dieses Notebook(in EURO)?: ");
Datenblatt.price.setProperty("EUR",Kbd.readString());
}
}

View File

@@ -0,0 +1,542 @@
package de.dejan_hopp;
import de.dejan_hopp.io.Delay;
import de.dejan_hopp.io.Print;
import de.dejan_hopp.io.pdf2PNG;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
public class GUI extends javax.swing.JFrame implements ActionListener {
private static String programVersion="1.0";
// Menü
private JMenuBar menuBar=new JMenuBar();
private JMenu menuDatei=new JMenu("Datei"); //Datei-Menü
private JMenuItem menuDateiPrint=new JMenuItem("Drucken");
private JMenuItem menuDateiReset=new JMenuItem("Zurücksetzen");
private JMenuItem menuDateiSettings=new JMenuItem("Einstellungen");
private JMenuItem menuDateiAbout=new JMenuItem("Über");
private JMenuItem menuDateiClose=new JMenuItem("Schließen");
// Logo
private String logoPfad="logo.png";
// Tabs mit den einzelnen PC-Komponenten:
private JTabbedPane tabPane=new JTabbedPane(JTabbedPane.TOP);
private JPanel panelTabCPU=new JPanel(null);
private JPanel panelTabGPU=new JPanel(null);
private JPanel panelTabStorage=new JPanel(null);
private JPanel panelTabMemory=new JPanel(null);
private JPanel panelTabOS=new JPanel(null);
private JPanel panelTabPrice=new JPanel(null);
private JPanel panelTabVorschau=new JPanel(null);
// CPU-Eingabefelder und Beschriftungen:
private JLabel labelCPUManufacturer=new JLabel("Hersteller:");
private String cpuManufacturerList[]={"AMD", "Intel"};
private JComboBox inputComboCPUManufacturer =new JComboBox(cpuManufacturerList);
private JLabel labelCPUName=new JLabel("CPU-Name:");
private JTextField inputCPUName=new JTextField();
private JLabel labelCPUCores=new JLabel("Anzahl der Kerne:");
private JTextField inputCPUCores=new JTextField();
private JLabel labelCPUThreads=new JLabel("Anzahl der Threads:");
private JTextField inputCPUThreads=new JTextField();
private JLabel labelCPUFrequency=new JLabel("Frequenz in MHz:");
private JTextField inputCPUFrequency=new JTextField();
// GPU-Eingabefelder und Beschriftungen:
private JLabel labelGPUManufacturer=new JLabel("Hersteller:");
private String gpuManufacturerList[]={"NVIDIA","AMD", "Intel"};
private JComboBox inputComboGPUManufacturer =new JComboBox(gpuManufacturerList);
private JLabel labelGPUName=new JLabel("GPU-Name:");
private JTextField inputGPUName=new JTextField();
private JLabel labelGPUFrequency=new JLabel("Frequenz in MHz:");
private JTextField inputGPUFrequency=new JTextField();
// Datenträger-Eingabefelder und Beschriftungen:
private String driveCapacities[]={"120","128","240","250","256","480","500","512","750","1000","1024","2000","3000","4000","5000"};
private String driveTypes[]={"SSD","HDD","SSHD"};
// 1
private JLabel labelDrive1=new JLabel("Datenträger 1:");
private JLabel labelDrive1Capacity=new JLabel("Kapazität in GB");
private JComboBox inputDrive1Capacity=new JComboBox(driveCapacities);
private JComboBox inputDrive1Type=new JComboBox(driveTypes);
// 2
private JCheckBox inputDrive2Check=new JCheckBox();
private JLabel labelDrive2=new JLabel("Datenträger 2:");
private JLabel labelDrive2Capacity=new JLabel("Kapazität in GB");
private JComboBox inputDrive2Capacity=new JComboBox(driveCapacities);
private JComboBox inputDrive2Type=new JComboBox(driveTypes);
// 3
private JCheckBox inputDrive3Check=new JCheckBox();
private JLabel labelDrive3=new JLabel("Datenträger 3:");
private JLabel labelDrive3Capacity=new JLabel("Kapazität in GB");
private JComboBox inputDrive3Capacity=new JComboBox(driveCapacities);
private JComboBox inputDrive3Type=new JComboBox(driveTypes);
// 4
private JCheckBox inputDrive4Check=new JCheckBox();
private JLabel labelDrive4=new JLabel("Datenträger 4:");
private JLabel labelDrive4Capacity=new JLabel("Kapazität in GB");
private JComboBox inputDrive4Capacity=new JComboBox(driveCapacities);
private JComboBox inputDrive4Type=new JComboBox(driveTypes);
// RAM-Eingabefelder und Beschriftungen:
private JLabel labelRAMVersion=new JLabel("Version:");
private String ramVersions[]={"DDR3","DDR4","DDR5"};
private JComboBox inputRAMVersion=new JComboBox(ramVersions);
private JLabel labelRAMCapacity=new JLabel("Kapazität in GB");
private JTextField inputRAMCapacity=new JTextField();
// OS-Eingabefelder und Beschriftungen:
private JLabel labelOSName=new JLabel("Betriebssystem:");
private JTextField inputOSName=new JTextField();
// Price-Eingabefelder und Beschriftungen:
private JLabel labelPrice =new JLabel("Preis in €:");
private JTextField inputPrice =new JTextField();
// Vorschau-Eingabefelder und Beschriftungen:
private static JLabel labelVorschau=new JLabel();
private JButton buttonVorschau=new JButton("Aktualisieren");
public GUI(){
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setSize(600,400);
setResizable(false);
setTitle("Computer-Datenblatt-Ersteller Pro");
setLocationRelativeTo(null);
ImageIcon img=new ImageIcon(logoPfad);
setIconImage(img.getImage());
setJMenuBar(menuBar);
menuBar.add(menuDatei);
menuDatei.add(menuDateiPrint);
menuDatei.add(menuDateiReset);
menuDatei.add(menuDateiSettings);
menuDatei.add(menuDateiAbout);
menuDatei.add(menuDateiClose);
menuDatei.setMnemonic('D');
menuDateiClose.setMnemonic('S');
menuDateiSettings.setMnemonic('E');
menuDateiPrint.setMnemonic('D');
menuDateiReset.setMnemonic('r');
menuDateiAbout.setMnemonic('Ü');
menuDateiClose.addActionListener(this);
menuDateiSettings.addActionListener(this);
menuDateiPrint.addActionListener(this);
menuDateiReset.addActionListener(this);
menuDateiAbout.addActionListener(this);
KeyStroke keyStrokeMenuPrint=KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK);
menuDateiPrint.setAccelerator(keyStrokeMenuPrint);
KeyStroke keyStrokeMenuClose=KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.ALT_DOWN_MASK);
menuDateiClose.setAccelerator(keyStrokeMenuClose);
KeyStroke keyStrokeMenuSettings=KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, KeyEvent.CTRL_DOWN_MASK);
menuDateiSettings.setAccelerator(keyStrokeMenuSettings);
KeyStroke keyStrokeMenuReset=KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.CTRL_DOWN_MASK);
menuDateiReset.setAccelerator(keyStrokeMenuReset);
KeyStroke keyStrokeMenuAbout=KeyStroke.getKeyStroke(KeyEvent.VK_F1, KeyEvent.CTRL_DOWN_MASK);
menuDateiAbout.setAccelerator(keyStrokeMenuAbout);
add(tabPane);
tabPane.addTab("CPU", panelTabCPU);
tabPane.addTab("Grafik", panelTabGPU);
tabPane.addTab("Datenträger", panelTabStorage);
tabPane.addTab("RAM", panelTabMemory);
tabPane.addTab("Betriebssystem", panelTabOS);
tabPane.addTab("Preis", panelTabPrice);
tabPane.addTab("Vorschau", panelTabVorschau);
panelTabCPU.setFocusCycleRoot(true);
panelTabGPU.setFocusCycleRoot(true);
panelTabStorage.setFocusCycleRoot(true);
panelTabMemory.setFocusCycleRoot(true);
panelTabOS.setFocusCycleRoot(true);
panelTabPrice.setFocusCycleRoot(true);
setupTabTraversalKeys(tabPane);
int labelWidth=120;
int labelHeight=15;
int labelRow=10;
int inputRow=labelWidth+labelRow+2;
int addRow2=300;
// CPU-Eingabefelder und Beschriftungen:
panelTabCPU.add(labelCPUManufacturer);
labelCPUManufacturer.setBounds(labelRow,10,labelWidth,labelHeight);
panelTabCPU.add(inputComboCPUManufacturer);
inputComboCPUManufacturer.setBounds(inputRow,6,100,20);
panelTabCPU.add(labelCPUName);
labelCPUName.setBounds(labelRow,30,labelWidth,labelHeight);
panelTabCPU.add(inputCPUName);
inputCPUName.setBounds(inputRow,27,100,20);
panelTabCPU.add(labelCPUCores);
labelCPUCores.setBounds(labelRow,50,labelWidth,labelHeight);
panelTabCPU.add(inputCPUCores);
inputCPUCores.setBounds(inputRow,47,30,20);
panelTabCPU.add(labelCPUThreads);
labelCPUThreads.setBounds(labelRow,70,labelWidth,labelHeight);
panelTabCPU.add(inputCPUThreads);
inputCPUThreads.setBounds(inputRow,67,30,20);
panelTabCPU.add(labelCPUFrequency);
labelCPUFrequency.setBounds(labelRow,90,labelWidth,labelHeight);
panelTabCPU.add(inputCPUFrequency);
inputCPUFrequency.setBounds(inputRow,87,50,20);
// GPU-Eingabefelder und Beschriftungen:
panelTabGPU.add(labelGPUManufacturer);
labelGPUManufacturer.setBounds(labelRow,10,labelWidth,labelHeight);
panelTabGPU.add(inputComboGPUManufacturer);
inputComboGPUManufacturer.setBounds(inputRow,6,100,20);
panelTabGPU.add(labelGPUName);
labelGPUName.setBounds(labelRow,30,labelWidth,labelHeight);
panelTabGPU.add(inputGPUName);
inputGPUName.setBounds(inputRow,27,100,20);
panelTabGPU.add(labelGPUFrequency);
labelGPUFrequency.setBounds(labelRow,50,labelWidth,labelHeight);
panelTabGPU.add(inputGPUFrequency);
inputGPUFrequency.setBounds(inputRow,47,50,20);
// Datenträger-Eingabefelder und Beschriftungen:
inputDrive2Check.addActionListener(this);
inputDrive3Check.addActionListener(this);
inputDrive4Check.addActionListener(this);
buttonVorschau.addActionListener(this);
inputDrive3Check.setEnabled(false);
inputDrive4Check.setEnabled(false);
// 1
panelTabStorage.add(labelDrive1);
labelDrive1.setBounds(labelRow+50,10,labelWidth,labelHeight);
panelTabStorage.add(labelDrive1Capacity);
labelDrive1Capacity.setBounds(labelRow,30,labelWidth,labelHeight);
panelTabStorage.add(inputDrive1Capacity);
inputDrive1Capacity.setBounds(inputRow-30,27,100,20);
panelTabStorage.add(inputDrive1Type);
inputDrive1Type.setBounds(inputRow-30,48,60,20);
// 2
panelTabStorage.add(labelDrive2);
labelDrive2.setBounds(labelRow+50,100,labelWidth,labelHeight);
panelTabStorage.add(inputDrive2Check);
inputDrive2Check.setBounds(labelRow+180,95,20,20);
panelTabStorage.add(labelDrive2Capacity);
labelDrive2Capacity.setBounds(labelRow,120,labelWidth,labelHeight);
panelTabStorage.add(inputDrive2Capacity);
inputDrive2Capacity.setBounds(inputRow-30,120,100,20);
panelTabStorage.add(inputDrive2Type);
inputDrive2Type.setBounds(inputRow-30,141,60,20);
// 3
panelTabStorage.add(labelDrive3);
labelDrive3.setBounds(labelRow+50+addRow2,10,labelWidth,labelHeight);
panelTabStorage.add(inputDrive3Check);
inputDrive3Check.setBounds(labelRow+180+addRow2,5,20,20);
panelTabStorage.add(labelDrive3Capacity);
labelDrive3Capacity.setBounds(labelRow+addRow2,27,labelWidth,labelHeight);
panelTabStorage.add(inputDrive3Capacity);
inputDrive3Capacity.setBounds(inputRow-30+addRow2,27,100,20);
panelTabStorage.add(inputDrive3Type);
inputDrive3Type.setBounds(inputRow-30+addRow2,48,60,20);
// 4
panelTabStorage.add(labelDrive4);
labelDrive4.setBounds(labelRow+50+addRow2,100,labelWidth,labelHeight);
panelTabStorage.add(inputDrive4Check);
inputDrive4Check.setBounds(labelRow+180+addRow2,95,20,20);
panelTabStorage.add(labelDrive4Capacity);
labelDrive4Capacity.setBounds(labelRow+addRow2,120,labelWidth,labelHeight);
panelTabStorage.add(inputDrive4Capacity);
inputDrive4Capacity.setBounds(inputRow-30+addRow2,120,100,20);
panelTabStorage.add(inputDrive4Type);
inputDrive4Type.setBounds(inputRow-30+addRow2,141,60,20);
// RAM-Eingabefelder und Beschriftungen:
panelTabMemory.add(labelRAMVersion);
labelRAMVersion.setBounds(labelRow,10,labelWidth,labelHeight);
panelTabMemory.add(inputRAMVersion);
inputRAMVersion.setBounds(inputRow,6,100,20);
panelTabMemory.add(labelRAMCapacity);
labelRAMCapacity.setBounds(labelRow,30,labelWidth,labelHeight);
panelTabMemory.add(inputRAMCapacity);
inputRAMCapacity.setBounds(inputRow,27,30,20);
// OS-Eingabefelder und Beschriftungen:
panelTabOS.add(labelOSName);
labelOSName.setBounds(labelRow,10,labelWidth,labelHeight);
panelTabOS.add(inputOSName);
inputOSName.setBounds(inputRow,6,200,20);
//Price-Eingabefelder und Beschriftungen:
panelTabPrice.add(labelPrice);
labelPrice.setBounds(labelRow,10,labelWidth,labelHeight);
panelTabPrice.add(inputPrice);
inputPrice.setBounds(inputRow-45,6,50,20);
// Vorschau-Eingabefelder und Beschriftungen:
panelTabVorschau.add(buttonVorschau);
buttonVorschau.setMnemonic('A');
buttonVorschau.setBounds(labelRow,10,labelWidth-5,labelHeight+10);
panelTabVorschau.add(labelVorschau);
labelVorschau.setBounds(150,5,300,300);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource()==menuDateiClose){
dispose();
} else if (e.getSource()==menuDateiSettings) {
System.out.println("Einstellungsfenster ploppt auf...");
new SettingsWindow(this).setVisible(true);
} else if (e.getSource()==menuDateiPrint) {
inputToProperty();
Print.createPDF();
Print.toPrint(false, this);
} else if (e.getSource()==menuDateiReset) {
clearFeatures();
} else if (e.getSource()==menuDateiAbout) {
System.out.println("Ein Fenster öffnet sich, in dem angezeigt wird, von wem das Programm ist...");
aboutDialog(this);
} else if (e.getSource()==inputDrive2Check) {
if (inputDrive2Check.isSelected()){
inputDrive3Check.setEnabled(true);
inputDrive3Check.setSelected(false);
inputDrive4Check.setEnabled(false);
inputDrive4Check.setSelected(false);
} else {
inputDrive3Check.setEnabled(false);
inputDrive3Check.setSelected(false);
inputDrive4Check.setEnabled(false);
inputDrive4Check.setSelected(false);
}
} else if (e.getSource()==inputDrive3Check) {
if (inputDrive3Check.isSelected()){
inputDrive4Check.setEnabled(true);
inputDrive4Check.setSelected(false);
} else {
inputDrive4Check.setEnabled(false);
inputDrive4Check.setSelected(false);
}
} else if (e.getSource()==buttonVorschau) {
view();
Print.printerList();
}
}
public void view(){
inputToProperty();
Print.createPDF();
Delay.delay(100);
pdf2PNG.convert();
BufferedImage img=null;
try {
img=ImageIO.read(new File("Datenblatt.png"));
} catch (IOException e) {
System.out.println("Fehler");
}
Image image= img.getScaledInstance(labelVorschau.getWidth(), labelVorschau.getHeight(), Image.SCALE_SMOOTH);
labelVorschau.setIcon(new ImageIcon(image));
labelVorschau.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
File x=new File("Datenblatt.pdf");
File y=new File("Datenblatt.png");
}
public static void aboutDialog(JFrame positionParent) {
JLabel aboutLabel=new JLabel("<html><center>Datenblatt-Ersteller<br>für PCs und Notebooks<br><br>Version: " + programVersion + "<br><br>Programmiert von<br>Dejan Hopp<br>\u00a92023");
aboutLabel.setHorizontalAlignment(SwingConstants.CENTER);
JOptionPane.showMessageDialog(positionParent, aboutLabel, "Über", JOptionPane.PLAIN_MESSAGE);
}
// Inhalte der Textfelder in die Properties schreiben
public void inputToProperty(){
Datenblatt.cpu.setProperty("manufacturer", inputComboCPUManufacturer.getSelectedItem().toString());
Datenblatt.cpu.setProperty("name", inputCPUName.getText());
Datenblatt.cpu.setProperty("cores", inputCPUCores.getText());
Datenblatt.cpu.setProperty("threads", inputCPUThreads.getText());
Datenblatt.cpu.setProperty("mhz", inputCPUFrequency.getText());
Datenblatt.gpu.setProperty("manufacturer", inputComboGPUManufacturer.getSelectedItem().toString());
Datenblatt.gpu.setProperty("name", inputGPUName.getText());
Datenblatt.gpu.setProperty("mhz", inputGPUFrequency.getText());
Datenblatt.storage.setProperty("drive1Type", inputDrive1Type.getSelectedItem().toString());
Datenblatt.storage.setProperty("drive1Capacity", inputDrive1Capacity.getSelectedItem().toString());
if (inputDrive2Check.isSelected()){
Datenblatt.storageAnzahl=2;
}
if (inputDrive3Check.isSelected()){
Datenblatt.storageAnzahl=3;
}
if (inputDrive4Check.isSelected()){
Datenblatt.storageAnzahl=4;
}
if (inputDrive2Check.isSelected()){
Datenblatt.storage.setProperty("drive2Type", inputDrive2Type.getSelectedItem().toString());
Datenblatt.storage.setProperty("drive2Capacity", inputDrive2Capacity.getSelectedItem().toString());
}
if (inputDrive3Check.isSelected()){
Datenblatt.storage.setProperty("drive3Type", inputDrive3Type.getSelectedItem().toString());
Datenblatt.storage.setProperty("drive3Capacity", inputDrive3Capacity.getSelectedItem().toString());
}
if (inputDrive4Check.isSelected()){
Datenblatt.storage.setProperty("drive4Type", inputDrive4Type.getSelectedItem().toString());
Datenblatt.storage.setProperty("drive4Capacity", inputDrive4Capacity.getSelectedItem().toString());
}
Datenblatt.memory.setProperty("ddrVersion", inputRAMVersion.getSelectedItem().toString());
Datenblatt.memory.setProperty("capacity", inputRAMCapacity.getText());
Datenblatt.os.setProperty("name", inputOSName.getText());
Datenblatt.price.setProperty("EUR", inputPrice.getText());
}
// Folgende Funktion wurde von https://www.davidc.net/programming/java/how-make-ctrl-tab-switch-tabs-jtabbedpane kopiert:
// Die Funktion sorgt dafür, dass man mit STRG+Tab und STRG+Shift+Tab durch die Tabs Navigieren kann.
private void setupTabTraversalKeys(JTabbedPane tabbedPane)
{
KeyStroke ctrlTab = KeyStroke.getKeyStroke("ctrl TAB");
KeyStroke ctrlShiftTab = KeyStroke.getKeyStroke("ctrl shift TAB");
// Remove ctrl-tab from normal focus traversal
Set<AWTKeyStroke> forwardKeys = new HashSet<AWTKeyStroke>(tabbedPane.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
forwardKeys.remove(ctrlTab);
tabbedPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeys);
// Remove ctrl-shift-tab from normal focus traversal
Set<AWTKeyStroke> backwardKeys = new HashSet<AWTKeyStroke>(tabbedPane.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
backwardKeys.remove(ctrlShiftTab);
tabbedPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardKeys);
// Add keys to the tab's input map
InputMap inputMap = tabbedPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(ctrlTab, "navigateNext");
inputMap.put(ctrlShiftTab, "navigatePrevious");
}
public void clearFeatures(){
// Features aus Properties löschen:
Datenblatt.cpu.clear();
Datenblatt.gpu.clear();
Datenblatt.storage.clear();
Datenblatt.memory.clear();
Datenblatt.os.clear();
Datenblatt.price.clear();
Datenblatt.storageAnzahl=1;
// Features aus Textfeldern löschen:
inputCPUName.setText("");
inputCPUCores.setText("");
inputCPUThreads.setText("");
inputCPUFrequency.setText("");
inputGPUName.setText("");
inputGPUFrequency.setText("");
inputDrive2Check.setSelected(false);
inputDrive3Check.setSelected(false);
inputDrive4Check.setSelected(false);
inputDrive3Check.setEnabled(false);
inputDrive4Check.setEnabled(false);
inputRAMCapacity.setText("");
inputOSName.setText("");
inputPrice.setText("");
}
@Override
public void dispose(){
System.exit(0);
}
}

View File

@@ -0,0 +1,130 @@
package de.dejan_hopp;
import de.dejan_hopp.io.*;
public class Main {
public static void main(String[] args) {
try{
if (args[0].equals("nogui")){
System.out.println("Programm ohne GUI gestartet");
} else {
System.out.println("FEHLER: Kein gültiger Startparameter!");
}
} catch(ArrayIndexOutOfBoundsException aioE){
System.out.println("Programm ohne Startparameter gestartet");
new GUI().setVisible(true);
}
System.out.println(" Datenblatt-Editor");
System.out.println("<#################>\n");
while(true){
//Menu
System.out.println("Menü:");
System.out.println("[1]Datenblatt erstellen ]");
System.out.println("[2]Datenblatt bearbeiten]");
System.out.println("[3]Drucken ]");
System.out.println("[4]Datenblatt anzeigen ]");
System.out.println("[5]Beenden ]");
System.out.print(">");
int in=0;
try {
in=Integer.parseInt(Kbd.readString());
if (in<1||in>5) throw new Exception();
} catch(Exception e) {
System.out.println("Bitte eine Zahl von 1-5 eingeben");
}
switch (in) {
case 1: create(); break;
case 2: edit(); break;
case 3: Print.createPDF();Print.toPrint(true,null); break;
case 4: show(); break;
case 5: exit(); break;
}
}
}
public static void create(){
System.out.println("\n\nFeature hinzufügen:");
System.out.println("[1]CPU ]");
System.out.println("[2]Grafik ]");
System.out.println("[3]Datenträger ]");
System.out.println("[4]RAM ]");
System.out.println("[5]Betriebssystem]");
System.out.println("[6]Preis ]");
System.out.println("[7]RESET ]");
System.out.print(">");
int in=0;
try {
in=Integer.parseInt(Kbd.readString());
if (in<1||in>5) throw new Exception();
} catch(Exception e) {
System.out.println("Bitte eine Zahl von 1-5 eingeben");
}
System.out.println();
switch (in){
case 1: Features.cpu(); break;
case 2: Features.gpu(); break;
case 3: Features.storage(); break;
case 4: Features.memory(); break;
case 5: Features.os(); break;
case 6: Features.setPrice(); break;
case 7: Features.clearFeatures(); break;
}
}
public static void edit(){
System.out.println("\n\nFeature bearbeiten:");
System.out.println("[1]CPU ]");
System.out.println("[2]Grafik ]");
System.out.println("[3]Datenträger ]");
System.out.println("[4]RAM ]");
System.out.println("[5]Betriebssystem]");
System.out.println("[6]Preis ]");
System.out.println("[7]RESET ]");
System.out.print(">");
int in=0;
try {
in=Integer.parseInt(Kbd.readString());
if (in<1||in>5) throw new Exception();
} catch(Exception e) {
System.out.println("Bitte eine Zahl von 1-5 eingeben");
}
System.out.println();
switch (in){
case 1: Features.cpu(); break;
case 2: Features.gpu(); break;
case 3: Features.storage(); break;
case 4: Features.memory(); break;
case 5: Features.os(); break;
case 6: Features.setPrice(); break;
case 7: Features.clearFeatures(); break;
}
}
public static void show(){
DisplayConsole.show(Datenblatt.cpu, Datenblatt.gpu, Datenblatt.storage, Datenblatt.memory, Datenblatt.os, Datenblatt.price);
}
public static void exit(){
System.out.println("Beenden...");
System.exit(0);
}
}

View File

@@ -0,0 +1,58 @@
package de.dejan_hopp;
import de.dejan_hopp.io.Print;
import de.dejan_hopp.io.RWConfigFile;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class SettingsWindow extends JDialog implements ActionListener {
private JComboBox inputPrinterList=new JComboBox(Print.printerList());
private JLabel labelPrinterSelect=new JLabel("Drucker:");
private JButton buttonSave=new JButton("Speichern");
private JButton buttonCancle=new JButton("Abbrechen");
public SettingsWindow(JFrame frame){
setLocationRelativeTo(frame);
setTitle("Einstellungen");
setLayout(null);
setModal(true);
setSize(400,300);
buttonSave.addActionListener(this);
buttonCancle.addActionListener(this);
// logo
Image img = new ImageIcon("logo.png").getImage();
setIconImage(img);
add(labelPrinterSelect).setBounds(5,10,70,20);
labelPrinterSelect.setDisplayedMnemonic('D');
labelPrinterSelect.setLabelFor(inputPrinterList);
add(inputPrinterList).setBounds(80,10,250,20);
inputPrinterList.setSelectedItem(RWConfigFile.getPrinterName());
add(buttonCancle).setBounds(5,230,110,30);
buttonCancle.setMnemonic('A');
add(buttonSave).setBounds(120,230,110,30);
buttonSave.setMnemonic('S');
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource()==buttonSave){
System.out.println("Speichern und Einstellungsfenster schließen");
RWConfigFile.setPrinter(inputPrinterList.getSelectedItem().toString());
dispose();
} else if (e.getSource()==buttonCancle) {
System.out.println("Abbrechen und Einstellungsfenster schließen");
dispose();
}
}
}

View File

@@ -0,0 +1,14 @@
package de.dejan_hopp.io;
import java.util.Date;
public class Delay {
//https://javabeginners.de/Grundlagen/Zeitsteuerung_ohne_Threads.php#:~:text=Nach%20jedem%20Durchlauf%20wird%20die,der%20aktuellen%20Unix%2DZeit%20beginnt.
public static void delay(int milliseconds){
long ende=(new Date()).getTime() + milliseconds;
while ((new Date()).getTime() < ende){
// abwarten und Tee trinken
}
}
}

View File

@@ -0,0 +1,75 @@
package de.dejan_hopp.io;
import de.dejan_hopp.Datenblatt;
import java.util.Properties;
public class DisplayConsole {
public static void show(Properties cpu, Properties gpu, Properties storage, Properties memory, Properties os, Properties price){
System.out.println("Prozessor:");
System.out.println("+"+cpu.getProperty("manufacturer"));
System.out.println("+"+cpu.getProperty("name"));
System.out.println("+"+cpu.getProperty("cores")+" Kerne - "+cpu.getProperty("threads")+" Threads");
System.out.println("+"+cpu.getProperty("mhr")+" MHz");
System.out.println("--------------------");
System.out.println("Grafik:");
System.out.println("+"+gpu.getProperty("manufacturer"));
System.out.println("+"+gpu.getProperty("name"));
System.out.println("+"+gpu.getProperty("mhz")+" MHz");
System.out.println("--------------------");
System.out.println("Datenträger:");
if(Datenblatt.storageAnzahl==1){
System.out.print("Datenträger 1:");
System.out.println(storage.getProperty("drive1Capacity")+" GB "+storage.getProperty("drive1Type"));
} else if (Datenblatt.storageAnzahl==2) {
//Datenträger 1
System.out.print("Datenträger 1:");
System.out.println(storage.getProperty("drive1Capacity")+" GB "+storage.getProperty("drive1Type"));
//Datenträger 2
System.out.print("Datenträger 2:");
System.out.println(storage.getProperty("drive2Capacity")+" GB "+storage.getProperty("drive2Type"));
} else if (Datenblatt.storageAnzahl==3) {
//Datenträger 1
System.out.print("Datenträger 1:");
System.out.println(storage.getProperty("drive1Capacity")+" GB "+storage.getProperty("drive1Type"));
//Datenträger 2
System.out.print("Datenträger 2:");
System.out.println(storage.getProperty("drive2Capacity")+" GB "+storage.getProperty("drive2Type"));
//Datenträger 3
System.out.print("Datenträger 3:");
System.out.println(storage.getProperty("drive3Capacity")+" GB "+storage.getProperty("drive3Type"));
} else if (Datenblatt.storageAnzahl==4) {
//Datenträger 1
System.out.print("Datenträger 1:");
System.out.println(storage.getProperty("drive1Capacity")+" GB "+storage.getProperty("drive1Type"));
//Datenträger 2
System.out.print("Datenträger 2:");
System.out.println(storage.getProperty("drive2Capacity")+" GB "+storage.getProperty("drive2Type"));
//Datenträger 3
System.out.print("Datenträger 3:");
System.out.println(storage.getProperty("drive3Capacity")+" GB "+storage.getProperty("drive3Type"));
//Datenträger 4
System.out.print("Datenträger 4:");
System.out.println(storage.getProperty("drive4Capacity")+" GB "+storage.getProperty("drive4Type"));
}
System.out.println("--------------------");
System.out.println("Arbeitsspeicher:");
System.out.println("+"+memory.getProperty("capacity")+" GB "+memory.getProperty("ddrVersion"));
System.out.println("--------------------");
System.out.println("Betriebssystem:");
System.out.println(os.getProperty("name"));
System.out.println("--------------------");
System.out.println("Preis:");
System.out.println(price.getProperty("EUR"));
System.out.println("--------------------\n\n");
}
}

View File

@@ -0,0 +1,23 @@
package de.dejan_hopp.io;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Kbd {
public static String readString(){
try {
BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
return r.readLine();
} catch (IOException ioe) {
System.out.println(ioe);
return "FEHLER BEIM EINLESEN!";
}
}
public static int readInt() throws IOException{
BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
return Integer.parseInt(r.readLine());
}
}

View File

@@ -0,0 +1,257 @@
package de.dejan_hopp.io;
import com.itextpdf.text.Document;
import com.itextpdf.text.Font;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.*;
import de.dejan_hopp.Datenblatt;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.printing.PDFPageable;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.swing.*;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
public class Print {
private static final String pdfPathName ="Datenblatt.pdf";
public static void createPDF(){
System.out.println("Erstelle PDF-Datei...");
File file = null;
try {
Document doc=new Document();
file=new File(pdfPathName);
PdfWriter writer=PdfWriter.getInstance(doc, Files.newOutputStream(file.toPath()));
Rectangle etikett = new Rectangle(228,228); // entspricht 8cm x 8cm
doc.setPageSize(etikett);
doc.setMargins(0,0,40,10);
doc.open();
PdfContentByte cb=writer.getDirectContent();
BaseFont bf= BaseFont.createFont(BaseFont.HELVETICA_BOLD,BaseFont.CP1250,true);
BaseFont bf2= BaseFont.createFont(BaseFont.HELVETICA_BOLDOBLIQUE,BaseFont.CP1250,true);
cb.beginText();
cb.setFontAndSize(bf, 20);
cb.moveText(50,210);
cb.showText("Überschrift");
cb.endText();
cb.beginText();
cb.setFontAndSize(bf, 12);
cb.moveText(85,190);
cb.showText("Datenblatt:");
cb.endText();
cb.beginText();
cb.setFontAndSize(bf, 12);
cb.moveText(145,5);
cb.showText("Preis: "+Datenblatt.price.get("EUR").toString()+"");
cb.endText();
cb.beginText();
cb.setFontAndSize(bf, 12);
cb.moveText(10,5);
cb.showText("Inkl. Windows");
cb.endText();
Font tableFont = new Font(Font.FontFamily.HELVETICA,9, Font.BOLDITALIC);
Font tableFontHead = new Font(Font.FontFamily.HELVETICA,9, Font.BOLD);
PdfPTable tabelleCPU=new PdfPTable(1);
int tableWidth=100;
tabelleCPU.setTotalWidth(tableWidth);
tabelleCPU.setLockedWidth(true);
tabelleCPU.addCell(new PdfPCell(new Phrase("Prozessor:",tableFontHead))).setBorderWidth(1);
tabelleCPU.addCell(new PdfPCell(new Phrase(Datenblatt.cpu.getProperty("manufacturer"),tableFont))).setBorderWidth(1);
tabelleCPU.addCell(new PdfPCell(new Phrase(Datenblatt.cpu.getProperty("name") +" ",tableFont))).setBorderWidth(1);
tabelleCPU.addCell(new PdfPCell(new Phrase(Datenblatt.cpu.getProperty("cores") +" Kerne - "+ Datenblatt.cpu.getProperty("threads") +" Threads",tableFont))).setBorderWidth(1);
tabelleCPU.addCell(new PdfPCell(new Phrase(Datenblatt.cpu.getProperty("mhz") +" MHz",tableFont))).setBorderWidth(1);
tabelleCPU.setHeaderRows(1);
PdfPTable tabelleGPU=new PdfPTable(1);
tabelleGPU.setTotalWidth(tableWidth);
tabelleGPU.setLockedWidth(true);
tabelleGPU.addCell(new PdfPCell(new Phrase("Grafik:",tableFontHead))).setBorderWidth(1);
tabelleGPU.addCell(new PdfPCell(new Phrase(Datenblatt.gpu.getProperty("manufacturer"),tableFont))).setBorderWidth(1);
tabelleGPU.addCell(new PdfPCell(new Phrase(Datenblatt.gpu.getProperty("name") +" ",tableFont))).setBorderWidth(1);
tabelleGPU.addCell(new PdfPCell(new Phrase(Datenblatt.gpu.getProperty("mhz") +" MHz",tableFont))).setBorderWidth(1);
tabelleGPU.setHeaderRows(1);
PdfPTable tabelleRAM=new PdfPTable(1);
tabelleRAM.setTotalWidth(tableWidth);
tabelleRAM.setLockedWidth(true);
tabelleRAM.addCell(new PdfPCell(new Phrase("Arbeitsspeicher:",tableFontHead))).setBorderWidth(1);
tabelleRAM.addCell(new PdfPCell(new Phrase(Datenblatt.memory.getProperty("capacity")+" GB - "+Datenblatt.memory.getProperty("ddrVersion"),tableFont))).setBorderWidth(1);
tabelleRAM.setHeaderRows(1);
// Betriebssystem:
cb.beginText();
cb.setFontAndSize(bf2, 12);
cb.moveText(10,20);
cb.showText(Datenblatt.os.getProperty("name"));
cb.endText();
PdfPTable tabelleStorage=new PdfPTable(1);
if (Datenblatt.storageAnzahl==1){
tabelleStorage.setTotalWidth(tableWidth);
tabelleStorage.setLockedWidth(true);
tabelleStorage.addCell(new PdfPCell(new Phrase("Datenträger:",tableFontHead))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase(Datenblatt.storage.getProperty("drive1Capacity")+" GB "+Datenblatt.storage.getProperty("drive1Type"),tableFont))).setBorderWidth(1);
} else if (Datenblatt.storageAnzahl==2) {
tabelleStorage.setTotalWidth(tableWidth);
tabelleStorage.setLockedWidth(true);
tabelleStorage.addCell(new PdfPCell(new Phrase("Datenträger 1:",tableFontHead))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase(Datenblatt.storage.getProperty("drive1Capacity")+" GB "+Datenblatt.storage.getProperty("drive1Type"),tableFont))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase("Datenträger 2:",tableFontHead))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase(Datenblatt.storage.getProperty("drive2Capacity")+" GB "+Datenblatt.storage.getProperty("drive2Type"),tableFont))).setBorderWidth(1);
} else if (Datenblatt.storageAnzahl==3) {
tabelleStorage.setTotalWidth(tableWidth);
tabelleStorage.setLockedWidth(true);
tabelleStorage.addCell(new PdfPCell(new Phrase("Datenträger 1:",tableFontHead))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase(Datenblatt.storage.getProperty("drive1Capacity")+" GB "+Datenblatt.storage.getProperty("drive1Type"),tableFont))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase("Datenträger 2:",tableFontHead))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase(Datenblatt.storage.getProperty("drive2Capacity")+" GB "+Datenblatt.storage.getProperty("drive2Type"),tableFont))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase("Datenträger 3:",tableFontHead))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase(Datenblatt.storage.getProperty("drive3Capacity")+" GB "+Datenblatt.storage.getProperty("drive3Type"),tableFont))).setBorderWidth(1);
} else if (Datenblatt.storageAnzahl==4) {
tabelleStorage.setTotalWidth(tableWidth);
tabelleStorage.setLockedWidth(true);
tabelleStorage.addCell(new PdfPCell(new Phrase("Datenträger 1:",tableFontHead))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase(Datenblatt.storage.getProperty("drive1Capacity")+" GB "+Datenblatt.storage.getProperty("drive1Type"),tableFont))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase("Datenträger 2:",tableFontHead))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase(Datenblatt.storage.getProperty("drive2Capacity")+" GB "+Datenblatt.storage.getProperty("drive2Type"),tableFont))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase("Datenträger 3:",tableFontHead))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase(Datenblatt.storage.getProperty("drive3Capacity")+" GB "+Datenblatt.storage.getProperty("drive3Type"),tableFont))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase("Datenträger 4:",tableFontHead))).setBorderWidth(1);
tabelleStorage.addCell(new PdfPCell(new Phrase(Datenblatt.storage.getProperty("drive4Capacity")+" GB "+Datenblatt.storage.getProperty("drive4Type"),tableFont))).setBorderWidth(1);
}
PdfPTable alles=new PdfPTable(2);
alles.setTotalWidth(200);
alles.setLockedWidth(true);
alles.addCell(new PdfPCell(tabelleCPU));
alles.addCell(new PdfPCell(tabelleStorage));
alles.addCell(new PdfPCell(tabelleGPU));
alles.addCell(new PdfPCell(tabelleRAM));
doc.add(alles);
writer.close();
doc.close();
} catch (Exception e) {
System.out.println("Die Datei wird bereits verwendet!");
}
}
// Der Großteil des Codes der folgenden Funktion ist von hier(https://www.java-forum.org/thema/drucken-einer-pdf-datei.176174/) kopiert.
public static void toPrint(boolean direct, JFrame positionParent){
if (!direct) {
int n = JOptionPane.showConfirmDialog(positionParent, "<html><center>Soll das Datenblatt gedruckt werden?", "Drucken?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (n == JOptionPane.YES_OPTION) {
System.out.println("Drucken...");
File datei = new File(pdfPathName);
if (datei.exists()) {
try {
PDDocument doc = PDDocument.load(datei);
PrintService myPrintService = findPrintService(RWConfigFile.getPrinterName());
PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(doc));
job.setPrintService(myPrintService);
job.print();
doc.close();
} catch (IOException | PrinterException e) {
System.out.println("Datei- oder Druckerfehler!");
JOptionPane.showConfirmDialog(positionParent, "<html><center>Bitte wählen Sie in den Programmeinstellungen([STRG]+[KOMMA]) einen Drucker aus!", "Drucken?", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
}
}
}
}else{
System.out.println("Drucken...");
File datei = new File(pdfPathName);
if (datei.exists()) {
try {
PDDocument doc = PDDocument.load(datei);
System.out.print("Druckername: ");
String printer=Kbd.readString();
PrintService myPrintService = findPrintService(printer);
while (true){
System.out.println("Soll immer dieser Drucker verwendet werden?(y/n)");
if (Kbd.readString().equals("y")||Kbd.readString().equals("Y")){
RWConfigFile.setPrinter(printer);
break;
} else if (Kbd.readString().equals("n")||Kbd.readString().equals("N")) {
}else System.out.println("Bitte 'y'/'Y' für \"Ja\" oder 'n'/'N' für \"Nein\" eingeben!");
}
PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(doc));
job.setPrintService(myPrintService);
job.print();
doc.close();
} catch (IOException | PrinterException e) {
System.out.println("Datei- oder Druckerfehler!");
}
}
}
}
// https://stackoverflow.com/questions/18636622/pdfbox-how-to-print-pdf-with-specified-printer
public static PrintService findPrintService(String printerName){
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
for (PrintService printService : printServices) {
if (printService.getName().trim().equals(printerName)) {
return printService;
}
}
return null;
}
public static String[] printerList(){
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
System.out.println("Number of print services: " + printServices.length);
String[] printerList=new String[printServices.length];
for (int i=0;i<printServices.length;i++){
printerList[i]=printServices[i].getName();
}
return printerList;
}
}

View File

@@ -0,0 +1,66 @@
package de.dejan_hopp.io;
import java.io.*;
import java.util.Properties;
public class RWConfigFile {
public static String getPrinterName(){
Properties settings=new Properties();
String printerName="Kein Drucker Ausgewählt";
try {
FileInputStream in=new FileInputStream("settings.conf");
settings.load(in);
printerName=settings.getProperty("printerName");
} catch (IOException e) {
//throw new RuntimeException(e);
File config=new File("settings.conf");
if (!config.exists()){
try{
boolean created=config.createNewFile();
if (created){
getPrinterName();
} else {
new File("settings.conf");
getPrinterName();
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
}
return printerName;
}
public static void setPrinter(String printerName){
Properties settings=new Properties();
try {
FileOutputStream out=new FileOutputStream("settings.conf");
settings.setProperty("printerName",printerName);
settings.store(out,null);
} catch (FileNotFoundException e) {
File config=new File("settings.conf");
if (!config.exists()){
try {
boolean created=config.createNewFile();
if (created){
setPrinter(printerName);
} else {
new File("settings.conf");
setPrinter(printerName);
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,57 @@
package de.dejan_hopp.io;
import com.sun.pdfview.PDFFile;
import com.sun.pdfview.PDFPage;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
public class pdf2PNG {
public static void convert(){
try {
File sourceFile = new File("Datenblatt.pdf");
if (sourceFile.exists()) {
RandomAccessFile raf = new RandomAccessFile(sourceFile, "r");
FileChannel channel = raf.getChannel();
ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
PDFFile pdf = new PDFFile(buf);
int pageNumber = 1;// which PDF page to be converted
PDFPage page = pdf.getPage(pageNumber);
// image dimensions
int width = 800;
int height = 800;
// create the image
Rectangle rect = new Rectangle(0, 0, (int) page.getBBox().getWidth(), (int) page.getBBox().getHeight());
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// width & height, // clip rect, // null for the ImageObserver, // fill background with white, // block until drawing is done
Image image = page.getImage(width, height, rect, null, true, true );
Graphics2D bufImageGraphics = bufferedImage.createGraphics();
bufImageGraphics.drawImage(image, 0, 0, null);
File imageFile = new File("Datenblatt.png" );// change file format here. Ex: .png, .jpg, .jpeg, .gif, .bmp
ImageIO.write(bufferedImage, "png", imageFile);
} else {
System.err.println(sourceFile.getName() +" File not exists");
}
if(sourceFile.delete()){System.out.println("PDF gelöscht!");}
} catch (Exception e) {
e.printStackTrace();
}
//JOptionPane.showMessageDialog(null, "Es kann nicht gedruckt werden. Ein anderer Prozess verwendet die Datei!","Fehler!",JOptionPane.INFORMATION_MESSAGE);
}
}

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: de.dejan_hopp.Main

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: de.dejan_hopp.Main

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
JAR-Libs/fontbox-2.0.27.jar Normal file

Binary file not shown.

BIN
JAR-Libs/html2pdf-4.0.5.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
JAR-Libs/pdf-renderer.jar Normal file

Binary file not shown.

BIN
JAR-Libs/pdfbox-2.0.27.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
JAR-Libs/xmpbox-2.0.27.jar Normal file

Binary file not shown.

BIN
Jar-Libs.zip Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB