@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<classpath> | |||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> | |||
<attributes> | |||
<attribute name="module" value="true"/> | |||
</attributes> | |||
</classpathentry> | |||
<classpathentry kind="src" path="src"/> | |||
<classpathentry exported="true" kind="lib" path="dist/ffeststeuerungNeu.jar"/> | |||
<classpathentry exported="true" kind="lib" path="jars/client-combined-3.10.0.jar"/> | |||
<classpathentry exported="true" kind="lib" path="jars/commons-lang3-3.7-javadoc.jar"/> | |||
<classpathentry exported="true" kind="lib" path="jars/commons-lang3-3.7.jar"/> | |||
<classpathentry exported="true" kind="lib" path="jars/commons-validator-1.6-javadoc.jar"/> | |||
<classpathentry exported="true" kind="lib" path="jars/commons-validator-1.6-sources.jar"/> | |||
<classpathentry exported="true" kind="lib" path="jars/commons-validator-1.6.jar"/> | |||
<classpathentry exported="true" kind="lib" path="jars/gson-2.6.2.jar"/> | |||
<classpathentry exported="true" kind="lib" path="jars/java-client-6.0.0-BETA3-javadoc.jar"/> | |||
<classpathentry exported="true" kind="lib" path="jars/java-client-6.0.0-BETA3.jar"/> | |||
<classpathentry exported="true" kind="lib" path="jars/selenium-server-standalone-3.10.0.jar"/> | |||
<classpathentry exported="true" kind="lib" path="resources/jars/synthetica.jar"/> | |||
<classpathentry exported="true" kind="lib" path="resources/jars/synthetica1.jar"/> | |||
<classpathentry exported="true" kind="lib" path="resources/jars/syntheticaPlain.jar"/> | |||
<classpathentry exported="true" kind="lib" path="resources/jars/weblaf-complete-1.28.jar"/> | |||
<classpathentry kind="output" path="build/classes"/> | |||
</classpath> |
@ -0,0 +1,24 @@ | |||
# Compiled class file | |||
*.class | |||
# Log file | |||
*.log | |||
# BlueJ files | |||
*.ctxt | |||
# Mobile Tools for Java (J2ME) | |||
.mtj.tmp/ | |||
# Package Files # | |||
*.jar | |||
*.war | |||
*.nar | |||
*.ear | |||
*.zip | |||
*.tar.gz | |||
*.rar | |||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | |||
hs_err_pid* | |||
replay_pid* |
@ -0,0 +1,17 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<projectDescription> | |||
<name>ffeststeuerungNeu</name> | |||
<comment></comment> | |||
<projects> | |||
</projects> | |||
<buildSpec> | |||
<buildCommand> | |||
<name>org.eclipse.jdt.core.javabuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
</buildSpec> | |||
<natures> | |||
<nature>org.eclipse.jdt.core.javanature</nature> | |||
</natures> | |||
</projectDescription> |
@ -0,0 +1,73 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!-- You may freely edit this file. See commented blocks below for --> | |||
<!-- some examples of how to customize the build. --> | |||
<!-- (If you delete it and reopen the project it will be recreated.) --> | |||
<!-- By default, only the Clean and Build commands use this build script. --> | |||
<!-- Commands such as Run, Debug, and Test only use this build script if --> | |||
<!-- the Compile on Save feature is turned off for the project. --> | |||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> | |||
<!-- in the project's Project Properties dialog box.--> | |||
<project name="ffeststeuerungNeu" default="default" basedir="."> | |||
<description>Builds, tests, and runs the project ffeststeuerungNeu.</description> | |||
<import file="nbproject/build-impl.xml"/> | |||
<!-- | |||
There exist several targets which are by default empty and which can be | |||
used for execution of your tasks. These targets are usually executed | |||
before and after some main targets. They are: | |||
-pre-init: called before initialization of project properties | |||
-post-init: called after initialization of project properties | |||
-pre-compile: called before javac compilation | |||
-post-compile: called after javac compilation | |||
-pre-compile-single: called before javac compilation of single file | |||
-post-compile-single: called after javac compilation of single file | |||
-pre-compile-test: called before javac compilation of JUnit tests | |||
-post-compile-test: called after javac compilation of JUnit tests | |||
-pre-compile-test-single: called before javac compilation of single JUnit test | |||
-post-compile-test-single: called after javac compilation of single JUunit test | |||
-pre-jar: called before JAR building | |||
-post-jar: called after JAR building | |||
-post-clean: called after cleaning build products | |||
(Targets beginning with '-' are not intended to be called on their own.) | |||
Example of inserting an obfuscator after compilation could look like this: | |||
<target name="-post-compile"> | |||
<obfuscate> | |||
<fileset dir="${build.classes.dir}"/> | |||
</obfuscate> | |||
</target> | |||
For list of available properties check the imported | |||
nbproject/build-impl.xml file. | |||
Another way to customize the build is by overriding existing main targets. | |||
The targets of interest are: | |||
-init-macrodef-javac: defines macro for javac compilation | |||
-init-macrodef-junit: defines macro for junit execution | |||
-init-macrodef-debug: defines macro for class debugging | |||
-init-macrodef-java: defines macro for class execution | |||
-do-jar: JAR building | |||
run: execution of project | |||
-javadoc-build: Javadoc generation | |||
test-report: JUnit report generation | |||
An example of overriding the target for project execution could look like this: | |||
<target name="run" depends="ffeststeuerungNeu-impl.jar"> | |||
<exec dir="bin" executable="launcher.exe"> | |||
<arg file="${dist.jar}"/> | |||
</exec> | |||
</target> | |||
Notice that the overridden target depends on the jar target and not only on | |||
the compile target as the regular run target does. Again, for a list of available | |||
properties which you can use, check the target you are overriding in the | |||
nbproject/build-impl.xml file. | |||
--> | |||
</project> |
@ -0,0 +1,4 @@ | |||
#Sun, 08 Jan 2023 21:48:27 +0100 | |||
D\:\\Dropbox\\ffeststeuerungNeu= |
@ -0,0 +1,15 @@ | |||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> | |||
<properties> | |||
<comment>Speicherorte</comment> | |||
<entry key="snapchat">C:\ffestData\snapchat</entry> | |||
<entry key="whatsapp">C:\ffestData\whatsapp</entry> | |||
<entry key="instagram">C:\ffestData\instagram\4K Stogram\frühling_tag</entry> | |||
<entry key="ffestData">C:\ffestData\</entry> | |||
<entry key="resources">/resources/image/</entry> | |||
<entry key="whatsappnummer">015259079638</entry> | |||
<entry key="instagramtag">#frühling</entry> | |||
<entry key="snapchatname">mv_owennnn</entry> | |||
<entry key="fullscreen">no</entry> | |||
<entry key="screen">1</entry> | |||
</properties> |
@ -0,0 +1,15 @@ | |||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> | |||
<properties> | |||
<comment>Speicherorte</comment> | |||
<entry key="snapchat">C:\ffestData\snapchat</entry> | |||
<entry key="whatsapp">C:\ffestData\whatsappBusiness</entry> | |||
<entry key="instagram">C:\ffestData\instagram\4K Stogram\frühling_tag</entry> | |||
<entry key="ffestData">C:\ffestData\</entry> | |||
<entry key="resources">resources/image/</entry> | |||
<entry key="whatsappnummer">015259079638</entry> | |||
<entry key="instagramtag">#frühling</entry> | |||
<entry key="snapchatname">mv_owennnn</entry> | |||
<entry key="fullscreen">no</entry> | |||
<entry key="screen">0</entry> | |||
</properties> |
@ -0,0 +1,3 @@ | |||
//synchronized testen | |||
Bildanzahl einstellbar | |||
bilddaauer anfangs setzen |
@ -0,0 +1,32 @@ | |||
======================== | |||
BUILD OUTPUT DESCRIPTION | |||
======================== | |||
When you build an Java application project that has a main class, the IDE | |||
automatically copies all of the JAR | |||
files on the projects classpath to your projects dist/lib folder. The IDE | |||
also adds each of the JAR files to the Class-Path element in the application | |||
JAR files manifest file (MANIFEST.MF). | |||
To run the project from the command line, go to the dist folder and | |||
type the following: | |||
java -jar "ffeststeuerungNeu.jar" | |||
To distribute this project, zip up the dist folder (including the lib folder) | |||
and distribute the ZIP file. | |||
Notes: | |||
* If two JAR files on the project classpath have the same name, only the first | |||
JAR file is copied to the lib folder. | |||
* Only JAR files are copied to the lib folder. | |||
If the classpath contains other types of files or folders, these files (folders) | |||
are not copied. | |||
* If a library on the projects classpath also has a Class-Path element | |||
specified in the manifest,the content of the Class-Path element has to be on | |||
the projects runtime path. | |||
* To set a main class in a standard Java project, right-click the project node | |||
in the Projects window and choose Properties. Then click Run and enter the | |||
class name in the Main Class field. Alternatively, you can manually type the | |||
class name in the manifest Main-Class element. |
@ -0,0 +1,3 @@ | |||
Manifest-Version: 1.0 | |||
X-COMMENT: Main-Class will be added automatically by build | |||
@ -0,0 +1,8 @@ | |||
build.xml.data.CRC32=3704fc3c | |||
build.xml.script.CRC32=080de010 | |||
build.xml.stylesheet.CRC32=8064a381@1.80.1.48 | |||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. | |||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. | |||
nbproject/build-impl.xml.data.CRC32=3704fc3c | |||
nbproject/build-impl.xml.script.CRC32=8912f73d | |||
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 |
@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> | |||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> | |||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> | |||
<group> | |||
<file>file:/D:/Dropbox/ffeststeuerungNeu/src/Diashow/DiashowVerwaltung.java</file> | |||
<file>file:/D:/Dropbox/ffeststeuerungNeu/src/ffeststeuerungneu/props.java</file> | |||
<file>file:/D:/Dropbox/ffeststeuerungNeu/src/Diashow/AnzeigeDiashow.java</file> | |||
</group> | |||
</open-files> | |||
</project-private> |
@ -0,0 +1,14 @@ | |||
compile.on.save=true | |||
do.depend=false | |||
do.jar=true | |||
file.reference.client-combined-3.10.0.jar=D:\\Dropbox\\ffeststeuerungNeu\\jars\\client-combined-3.10.0.jar | |||
file.reference.commons-lang3-3.7-javadoc.jar=D:\\Dropbox\\ffeststeuerungNeu\\jars\\commons-lang3-3.7-javadoc.jar | |||
file.reference.commons-lang3-3.7.jar=D:\\Dropbox\\ffeststeuerungNeu\\jars\\commons-lang3-3.7.jar | |||
file.reference.commons-validator-1.6.jar=D:\\Dropbox\\ffeststeuerungNeu\\jars\\commons-validator-1.6.jar | |||
file.reference.gson-2.6.2.jar=D:\\Dropbox\\ffeststeuerungNeu\\jars\\gson-2.6.2.jar | |||
file.reference.java-client-6.0.0-BETA3-javadoc.jar=D:\\Dropbox\\ffeststeuerungNeu\\jars\\java-client-6.0.0-BETA3-javadoc.jar | |||
file.reference.java-client-6.0.0-BETA3.jar=D:\\Dropbox\\ffeststeuerungNeu\\jars\\java-client-6.0.0-BETA3.jar | |||
file.reference.selenium-server-standalone-3.10.0.jar=D:\\Dropbox\\ffeststeuerungNeu\\jars\\selenium-server-standalone-3.10.0.jar | |||
javac.debug=true | |||
javadoc.preview=true | |||
user.properties.file=C:\\Users\\Rino\\AppData\\Roaming\\NetBeans\\8.2\\build.properties |
@ -0,0 +1,7 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> | |||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> | |||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> | |||
<group/> | |||
</open-files> | |||
</project-private> |
@ -0,0 +1,92 @@ | |||
annotation.processing.enabled=true | |||
annotation.processing.enabled.in.editor=false | |||
annotation.processing.processors.list= | |||
annotation.processing.run.all.processors=true | |||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output | |||
application.title=ffeststeuerungNeu | |||
application.vendor=Rino | |||
build.classes.dir=${build.dir}/classes | |||
build.classes.excludes=**/*.java,**/*.form | |||
# This directory is removed when the project is cleaned: | |||
build.dir=build | |||
build.generated.dir=${build.dir}/generated | |||
build.generated.sources.dir=${build.dir}/generated-sources | |||
# Only compile against the classpath explicitly listed here: | |||
build.sysclasspath=ignore | |||
build.test.classes.dir=${build.dir}/test/classes | |||
build.test.results.dir=${build.dir}/test/results | |||
# Uncomment to specify the preferred debugger connection transport: | |||
#debug.transport=dt_socket | |||
debug.classpath=\ | |||
${run.classpath} | |||
debug.test.classpath=\ | |||
${run.test.classpath} | |||
# Files in build.classes.dir which should be excluded from distribution jar | |||
dist.archive.excludes= | |||
# This directory is removed when the project is cleaned: | |||
dist.dir=dist | |||
dist.jar=${dist.dir}/ffeststeuerungNeu.jar | |||
dist.javadoc.dir=${dist.dir}/javadoc | |||
endorsed.classpath= | |||
excludes= | |||
file.reference.client-combined-3.10.0.jar=D:\\Dropbox\\Appium\\jars\\client-combined-3.10.0.jar | |||
file.reference.commons-lang3-3.7-javadoc.jar=D:\\Dropbox\\Appium\\jars\\commons-lang3-3.7-javadoc.jar | |||
file.reference.commons-lang3-3.7.jar=D:\\Dropbox\\Appium\\jars\\commons-lang3-3.7.jar | |||
file.reference.commons-validator-1.6.jar=D:\\Dropbox\\Appium\\jars\\commons-validator-1.6.jar | |||
file.reference.gson-2.6.2.jar=D:\\Dropbox\\Appium\\jars\\gson-2.6.2.jar | |||
file.reference.java-client-6.0.0-BETA3-javadoc.jar=D:\\Dropbox\\Appium\\jars\\java-client-6.0.0-BETA3-javadoc.jar | |||
file.reference.java-client-6.0.0-BETA3.jar=D:\\Dropbox\\Appium\\jars\\java-client-6.0.0-BETA3.jar | |||
file.reference.selenium-server-standalone-3.10.0.jar=D:\\Dropbox\\Appium\\jars\\selenium-server-standalone-3.10.0.jar | |||
includes=** | |||
jar.compress=false | |||
javac.classpath=\ | |||
${file.reference.client-combined-3.10.0.jar}:\ | |||
${file.reference.commons-lang3-3.7-javadoc.jar}:\ | |||
${file.reference.commons-lang3-3.7.jar}:\ | |||
${file.reference.commons-validator-1.6.jar}:\ | |||
${file.reference.gson-2.6.2.jar}:\ | |||
${file.reference.java-client-6.0.0-BETA3-javadoc.jar}:\ | |||
${file.reference.java-client-6.0.0-BETA3.jar}:\ | |||
${file.reference.selenium-server-standalone-3.10.0.jar} | |||
# Space-separated list of extra javac options | |||
javac.compilerargs= | |||
javac.deprecation=false | |||
javac.external.vm=true | |||
javac.processorpath=\ | |||
${javac.classpath} | |||
javac.source=1.8 | |||
javac.target=1.8 | |||
javac.test.classpath=\ | |||
${javac.classpath}:\ | |||
${build.classes.dir} | |||
javac.test.processorpath=\ | |||
${javac.test.classpath} | |||
javadoc.additionalparam= | |||
javadoc.author=false | |||
javadoc.encoding=${source.encoding} | |||
javadoc.noindex=false | |||
javadoc.nonavbar=false | |||
javadoc.notree=false | |||
javadoc.private=false | |||
javadoc.splitindex=true | |||
javadoc.use=true | |||
javadoc.version=false | |||
javadoc.windowtitle= | |||
main.class=ffeststeuerungneu.frame | |||
manifest.file=manifest.mf | |||
meta.inf.dir=${src.dir}/META-INF | |||
mkdist.disabled=false | |||
platform.active=default_platform | |||
run.classpath=\ | |||
${javac.classpath}:\ | |||
${build.classes.dir} | |||
# Space-separated list of JVM arguments used when running the project. | |||
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. | |||
# To set system properties for unit tests define test-sys-prop.name=value: | |||
run.jvmargs= | |||
run.test.classpath=\ | |||
${javac.test.classpath}:\ | |||
${build.test.classes.dir} | |||
source.encoding=UTF-8 | |||
src.src.dir=src | |||
test.src.dir=test |
@ -0,0 +1,15 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project xmlns="http://www.netbeans.org/ns/project/1"> | |||
<type>org.netbeans.modules.java.j2seproject</type> | |||
<configuration> | |||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3"> | |||
<name>ffeststeuerungNeu</name> | |||
<source-roots> | |||
<root id="src.src.dir"/> | |||
</source-roots> | |||
<test-roots> | |||
<root id="test.src.dir"/> | |||
</test-roots> | |||
</data> | |||
</configuration> | |||
</project> |
@ -0,0 +1,15 @@ | |||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> | |||
<properties> | |||
<comment>Speicherorte</comment> | |||
<entry key="snapchat">C:\ffestData\snapchat</entry> | |||
<entry key="whatsapp">C:\ffestData\whatsappBusiness</entry> | |||
<entry key="instagram">C:\ffestData\instagram\4K Stogram\frühling_tag</entry> | |||
<entry key="ffestData">C:\ffestData\</entry> | |||
<entry key="resources">resources/image/</entry> | |||
<entry key="whatsappnummer">015259079638</entry> | |||
<entry key="instagramtag">#frühling</entry> | |||
<entry key="snapchatname">mv_owennnn</entry> | |||
<entry key="fullscreen">no</entry> | |||
<entry key="screen">1</entry> | |||
</properties> |
@ -0,0 +1,111 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package Bildquellen; | |||
import bilderAuswahl.ThreadBilderAuswahl; | |||
import ffeststeuerungneu.Log; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.nio.file.FileSystems; | |||
import java.nio.file.Path; | |||
import java.nio.file.Paths; | |||
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; | |||
import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE; | |||
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; | |||
import java.nio.file.WatchEvent; | |||
import java.nio.file.WatchKey; | |||
import java.nio.file.WatchService; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class InstagramBilder extends Thread { | |||
int i = 0; | |||
private ThreadBilderAuswahl tba; | |||
private WatchService watcher; | |||
private String INSTAGRAM; // = "C:\\ffestData\\instagram\\4K Stogram\\mvö_tag"; | |||
private boolean runnable = true; | |||
public InstagramBilder(ThreadBilderAuswahl tba, String pfad) { | |||
INSTAGRAM = pfad; | |||
this.tba = tba; | |||
// tba.neuesBild("C:\\ffestData\\instagram\\4k stogram\\tag_mvö\\1.jpg"); | |||
// tba.neuesBild("C:\\ffestData\\instagram\\4k stogram\\tag_mvö\\2.jpg"); | |||
// tba.neuesBild("C:\\ffestData\\instagram\\4k stogram\\tag_mvö\\3.jpg"); | |||
// tba.neuesBild("C:\\ffestData\\instagram\\4k stogram\\tag_mvö\\4.jpg"); | |||
try { | |||
watcher = FileSystems.getDefault().newWatchService(); | |||
Path dir = Paths.get(INSTAGRAM); | |||
dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY); | |||
} catch (IOException ex) { | |||
Logger.getLogger(Bildquellen.InstagramBilder.class.getName()).log(Level.SEVERE, null, ex); | |||
Log.setError(ex, "Class: InstagramBilder. Directory not found."); | |||
} | |||
} | |||
@Override | |||
public void run() { | |||
while (runnable) { | |||
WatchKey key; | |||
try { | |||
// wait for a key to be available | |||
key = watcher.take(); | |||
} catch (InterruptedException ex) { | |||
Log.setError(ex, "Class: InstagramBilder Interrupt of Thread"); | |||
return; | |||
} | |||
for (WatchEvent<?> event : key.pollEvents()) { | |||
// get event type | |||
WatchEvent.Kind<?> kind = event.kind(); | |||
// get file name | |||
@SuppressWarnings("unchecked") | |||
WatchEvent<Path> ev = (WatchEvent<Path>) event; | |||
Path fileName = ev.context(); | |||
i++; | |||
if (fileName.toString().endsWith("jpg") && kind.equals(ENTRY_CREATE)) { | |||
tba.neuesBild(INSTAGRAM + "\\" + fileName.toString()); | |||
Log.incInstagram(); | |||
Log.setInfo("Image detectet: Instagram"); | |||
} | |||
if (kind == ENTRY_CREATE) { | |||
// process create event | |||
} else if (kind == ENTRY_DELETE) { | |||
// process delete event | |||
} else if (kind == ENTRY_MODIFY) { | |||
// process modify event | |||
} | |||
} | |||
// IMPORTANT: The key must be reset after processed | |||
boolean valid = key.reset(); | |||
if (!valid) { | |||
break; | |||
} | |||
} | |||
} | |||
public void terminate(){ | |||
runnable = false; | |||
} | |||
} |
@ -0,0 +1,98 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package Bildquellen; | |||
import bilderAuswahl.ThreadBilderAuswahl; | |||
import ffeststeuerungneu.Log; | |||
import java.io.IOException; | |||
import java.nio.file.FileSystems; | |||
import java.nio.file.Path; | |||
import java.nio.file.Paths; | |||
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; | |||
import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE; | |||
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; | |||
import java.nio.file.WatchEvent; | |||
import java.nio.file.WatchKey; | |||
import java.nio.file.WatchService; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class SnapchatBilder extends Thread{ | |||
private ThreadBilderAuswahl tba; | |||
private WatchService watcher; | |||
private String SNAPCHAT; // = "C:\\ffestData\\instagram\\4K Stogram\\mvö_tag"; | |||
private boolean runnable =true; | |||
public SnapchatBilder(ThreadBilderAuswahl tba, String pfad) { | |||
SNAPCHAT = pfad; | |||
this.tba = tba; | |||
try { | |||
watcher = FileSystems.getDefault().newWatchService(); | |||
Path dir = Paths.get(SNAPCHAT); | |||
dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY); | |||
} catch (IOException ex) { | |||
Logger.getLogger(Bildquellen.InstagramBilder.class.getName()).log(Level.SEVERE, null, ex); | |||
Log.setError(ex, "Class: InstagramBilder. File not found"); | |||
} | |||
} | |||
@Override | |||
public void run() { | |||
while (!isInterrupted()) { | |||
WatchKey key; | |||
try { | |||
// wait for a key to be available | |||
key = watcher.take(); | |||
} catch (InterruptedException ex) { | |||
Log.setError(ex, "Class: InstagramBilder Interrupt of Thread"); | |||
return; | |||
} | |||
for (WatchEvent<?> event : key.pollEvents()) { | |||
// get event type | |||
WatchEvent.Kind<?> kind = event.kind(); | |||
// get file name | |||
@SuppressWarnings("unchecked") | |||
WatchEvent<Path> ev = (WatchEvent<Path>) event; | |||
Path fileName = ev.context(); | |||
if (fileName.toString().endsWith("jpg") && kind.equals(ENTRY_CREATE)) { | |||
Log.incSnapchat(); | |||
tba.neuesBild(SNAPCHAT + "\\" + fileName.toString()); | |||
Log.setInfo("Image detected: Snapchat"); | |||
} | |||
if (kind == ENTRY_CREATE) { | |||
// process create event | |||
} else if (kind == ENTRY_DELETE) { | |||
// process delete event | |||
} else if (kind == ENTRY_MODIFY) { | |||
// process modify event | |||
} | |||
} | |||
// IMPORTANT: The key must be reset after processed | |||
boolean valid = key.reset(); | |||
if (!valid) { | |||
break; | |||
} | |||
} | |||
} | |||
public void terminate(){ | |||
runnable = false; | |||
} | |||
} |
@ -0,0 +1,99 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package Bildquellen; | |||
import bilderAuswahl.ThreadBilderAuswahl; | |||
import ffeststeuerungneu.Log; | |||
import java.io.IOException; | |||
import java.nio.file.FileSystems; | |||
import java.nio.file.Path; | |||
import java.nio.file.Paths; | |||
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; | |||
import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE; | |||
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; | |||
import java.nio.file.WatchEvent; | |||
import java.nio.file.WatchKey; | |||
import java.nio.file.WatchService; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class WhatsappBilder extends Thread{ | |||
private ThreadBilderAuswahl tba; | |||
private WatchService watcher; | |||
private String WHATSAPP; // = "C:\\ffestData\\instagram\\4K Stogram\\mvö_tag"; | |||
private boolean runnable =true; | |||
public WhatsappBilder(ThreadBilderAuswahl tba, String pfad) { | |||
WHATSAPP = pfad; | |||
this.tba = tba; | |||
try { | |||
watcher = FileSystems.getDefault().newWatchService(); | |||
Path dir = Paths.get(WHATSAPP); | |||
System.out.println(dir.toString()); | |||
dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY); | |||
} catch (IOException ex) { | |||
Logger.getLogger(Bildquellen.WhatsappBilder.class.getName()).log(Level.SEVERE, null, ex); | |||
Log.setError(ex, "Class: WhatsappBilder. File not found"); | |||
} | |||
} | |||
@Override | |||
public void run() { | |||
while (!isInterrupted()) { | |||
WatchKey key; | |||
try { | |||
// wait for a key to be available | |||
key = watcher.take(); | |||
} catch (InterruptedException ex) { | |||
Log.setError(ex, "Class: WhatsappBilder Interrupt of Thread"); | |||
return; | |||
} | |||
for (WatchEvent<?> event : key.pollEvents()) { | |||
// get event type | |||
WatchEvent.Kind<?> kind = event.kind(); | |||
// get file name | |||
@SuppressWarnings("unchecked") | |||
WatchEvent<Path> ev = (WatchEvent<Path>) event; | |||
Path fileName = ev.context(); | |||
if (fileName.toString().endsWith("jpg") && kind.equals(ENTRY_CREATE)) { | |||
Log.incWhatsapp(); | |||
tba.neuesBild(WHATSAPP + "\\" + fileName.toString()); | |||
Log.setInfo("Image detected: Whatsapp"); | |||
} | |||
if (kind == ENTRY_CREATE) { | |||
// process create event | |||
} else if (kind == ENTRY_DELETE) { | |||
// process delete event | |||
} else if (kind == ENTRY_MODIFY) { | |||
// process modify event | |||
} | |||
} | |||
// IMPORTANT: The key must be reset after processed | |||
boolean valid = key.reset(); | |||
if (!valid) { | |||
break; | |||
} | |||
} | |||
} | |||
public void terminate(){ | |||
runnable = false; | |||
} | |||
} |
@ -0,0 +1,229 @@ | |||
package Diashow; | |||
import ffeststeuerungneu.Props; | |||
import java.awt.BorderLayout; | |||
import java.awt.Color; | |||
import java.awt.Dimension; | |||
import java.awt.Graphics; | |||
import java.awt.GridLayout; | |||
import java.awt.Image; | |||
import java.awt.event.ActionEvent; | |||
import java.awt.event.ActionListener; | |||
import java.awt.image.BufferedImage; | |||
import javax.swing.ImageIcon; | |||
import javax.swing.JPanel; | |||
import javax.swing.JLabel; | |||
import javax.swing.Timer; | |||
public class AnzeigeDiashow extends JPanel { | |||
/** | |||
* Creates new form PDiashow | |||
*/ | |||
private int anzahlBilder = 20; | |||
private int neueBilderArray = 0; | |||
private int bildNr = 0; | |||
private static final int INSTAGRAM = 0; | |||
private static final int SNAPCHAT = 1; | |||
private static final int WHATSAPP = 2; | |||
private Timer t; | |||
private final ImageIcon icon[] = new ImageIcon[3]; | |||
private BufferedImage bim[] = new BufferedImage[anzahlBilder]; | |||
private BufferedImage neueBilder[] = new BufferedImage[99]; | |||
private final Props p; | |||
private final String pfad; | |||
private boolean pause = false, fertig = false; | |||
private double fx, fy; | |||
private int width, height; | |||
public AnzeigeDiashow() { | |||
p = new Props(); | |||
pfad = p.getInfo("resources"); | |||
initIcon(); | |||
initComponents(); | |||
fertig = true; | |||
} | |||
private void initIcon() { | |||
icon[INSTAGRAM] = new ImageIcon(pfad + "instagram.png"); | |||
icon[SNAPCHAT] = new ImageIcon(pfad + "snapchat.png"); | |||
icon[WHATSAPP] = new ImageIcon(pfad + "whatsapp.png"); | |||
for (int j = 0; j < icon.length; j++) { | |||
icon[j].setImage(icon[j].getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)); | |||
} | |||
} | |||
@Override | |||
public void paintComponent(Graphics g) { | |||
width = this.getWidth(); | |||
height = this.getHeight() - this.panelText.getHeight(); | |||
// this.setPreferredSize(new Dimension(200,400)); | |||
g.setColor(Color.black); | |||
g.fillRect(0, 0, this.getWidth(), this.getHeight() + 40); | |||
if (bim[bildNr] != null && fertig) { | |||
fx = ((double) width / bim[bildNr].getWidth()); | |||
fy = ((double) height / bim[bildNr].getHeight()); | |||
if (pause) { | |||
} else if (fx > fy) { | |||
g.drawImage(bim[bildNr], | |||
(int) ((width - (bim[bildNr].getWidth() * fy)) / 2), | |||
(int) ((height - (bim[bildNr].getHeight() * fy)) / 2) + this.panelText.getHeight(), | |||
(int) (bim[bildNr].getWidth() * fy), | |||
(int) (bim[bildNr].getHeight() * fy), panelBild); | |||
} else { | |||
g.drawImage(bim[bildNr], | |||
(int) ((width - (bim[bildNr].getWidth() * fx)) / 2), | |||
(int) ((height - (bim[bildNr].getHeight() * fx)) / 2), | |||
(int) (bim[bildNr].getWidth() * fx), | |||
(int) (bim[bildNr].getHeight() * fx), panelBild); | |||
} | |||
} | |||
} | |||
private void naechstesBild() { | |||
bildNr++; | |||
if (bildNr >= anzahlBilder || bim[bildNr] == null) { | |||
bilderEinfuegen(); | |||
bildNr = 0; | |||
} | |||
super.repaint(); | |||
} | |||
public void bilderEinfuegen() { | |||
for (int i = 0; i < neueBilderArray; i++) { | |||
for (int j = bim.length - 1; j > 0; j--) { | |||
bim[j] = bim[j - 1]; | |||
} | |||
bim[0] = neueBilder[i]; | |||
} | |||
neueBilderArray = 0; | |||
} | |||
public void neuesBild(BufferedImage nbim) { | |||
neueBilder[neueBilderArray] = nbim; | |||
neueBilderArray++; | |||
} | |||
public void stop() { | |||
t.stop(); | |||
} | |||
public void pause() { | |||
pause = !pause; | |||
repaint(); | |||
} | |||
public void start() { | |||
t = new Timer(1000, new ActionListener() { | |||
@Override | |||
public void actionPerformed(ActionEvent ae) { | |||
if (!pause) { | |||
naechstesBild(); | |||
} | |||
} | |||
}); | |||
t.start(); | |||
} | |||
public void setSek(int sec) { | |||
t.setDelay(sec * 1000); | |||
t.restart(); | |||
} | |||
public void setAnzahlBilder(int a) { | |||
anzahlBilder = a; | |||
} | |||
public void weiter() { | |||
naechstesBild(); | |||
} | |||
public void setAnzahl(int a) { | |||
anzahlBilder = a; | |||
} | |||
private void initComponents() { | |||
initText(); | |||
// | |||
panelText = new JPanel(); | |||
panelText.setBackground(Color.black); | |||
panelText.add(labelInstagram); | |||
panelText.add(new JLabel(" ")); | |||
panelText.add(labelSnapchat); | |||
panelText.add(new JLabel(" ")); | |||
panelText.add(labelWhatsapp); | |||
this.setLayout(new BorderLayout()); | |||
// | |||
this.add(panelText, BorderLayout.NORTH); | |||
} | |||
private void initText() { | |||
labelWhatsapp = new JLabel(p.getInfo("whatsappnummer")); | |||
labelSnapchat = new JLabel(p.getInfo("snapchatname")); | |||
labelInstagram = new JLabel(p.getInfo("instagramtag")); | |||
labelWhatsapp.setIcon(icon[WHATSAPP]); | |||
labelSnapchat.setIcon(icon[SNAPCHAT]); | |||
labelInstagram.setIcon(icon[INSTAGRAM]); | |||
labelSnapchat.setForeground(Color.white); | |||
labelInstagram.setForeground(Color.white); | |||
labelWhatsapp.setForeground(Color.white); | |||
labelSnapchat.setFont(new java.awt.Font("Tahoma", 1, 48)); | |||
labelInstagram.setFont(new java.awt.Font("Tahoma", 1, 48)); | |||
labelWhatsapp.setFont(new java.awt.Font("Tahoma", 1, 48)); | |||
labelWhatsapp.setVisible(false); | |||
labelInstagram.setVisible(false); | |||
labelSnapchat.setVisible(false); | |||
} | |||
public void setOnline(int what, boolean online) { | |||
switch (what) { | |||
case SNAPCHAT: | |||
labelSnapchat.setVisible(online); | |||
break; | |||
case INSTAGRAM: | |||
labelInstagram.setVisible(online); | |||
break; | |||
case WHATSAPP: | |||
labelWhatsapp.setVisible(online); | |||
break; | |||
} | |||
} | |||
private JPanel panelText; | |||
private JPanel panelBild; | |||
private JLabel labelWhatsapp; | |||
private JLabel labelInstagram; | |||
private JLabel labelSnapchat; | |||
} |
@ -0,0 +1,105 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package Diashow; | |||
import java.awt.Color; | |||
import java.awt.Dimension; | |||
import java.awt.Graphics; | |||
import java.awt.GraphicsDevice; | |||
import java.awt.GraphicsEnvironment; | |||
import java.awt.Rectangle; | |||
import java.awt.image.BufferedImage; | |||
import javax.swing.JFrame; | |||
import javax.swing.JPanel; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class DiashowVerwaltung { | |||
private final AnzeigeDiashow dia; | |||
private final JFrame diaframe; | |||
public DiashowVerwaltung(int anzeige) { | |||
diaframe = new JFrame(); | |||
dia = new AnzeigeDiashow(); | |||
diaframe.getContentPane().setBackground(Color.yellow); | |||
// dia.setBackground(Color.red); | |||
switch (anzeige) { | |||
case 0: | |||
diaframe.setUndecorated(true); | |||
GraphicsDevice[] graphicsDevices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); | |||
for (GraphicsDevice d : graphicsDevices) { | |||
Rectangle deviceBounds = d.getDefaultConfiguration().getBounds(); | |||
diaframe.setBounds((int) deviceBounds.getX(), (int) deviceBounds.getY(), (int) deviceBounds.getWidth(), (int) deviceBounds.getHeight()); | |||
diaframe.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | |||
diaframe.add(dia); | |||
diaframe.setVisible(true); | |||
} | |||
break; | |||
case 1: | |||
diaframe.add(dia); | |||
diaframe.setVisible(true); | |||
diaframe.setSize(400, 600); | |||
dia.setPreferredSize(new Dimension(diaframe.getWidth(), diaframe.getHeight())); | |||
dia.setSize(new Dimension(diaframe.getWidth(), diaframe.getHeight())); | |||
break; | |||
case 2: | |||
break; | |||
} | |||
} | |||
public void setOnline(int what, boolean online) { | |||
dia.setOnline(what, online); | |||
} | |||
public void start() { | |||
dia.start(); | |||
} | |||
public void pause() { | |||
dia.pause(); | |||
} | |||
public void neuesBild(BufferedImage bim) { | |||
dia.neuesBild(bim); | |||
} | |||
public void setTime(int t) { | |||
dia.setSek(t); | |||
} | |||
public void weiter() { | |||
dia.weiter(); | |||
} | |||
public void setAnzahl(int a) { | |||
dia.setAnzahl(a); | |||
} | |||
public class pan extends JPanel { | |||
@Override | |||
public void paint(Graphics g) { | |||
g.setColor(Color.red); | |||
g.fillRect(0, 0, this.getWidth(), this.getHeight()); | |||
} | |||
} | |||
} |
@ -0,0 +1,35 @@ | |||
package Server; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.OutputStream; | |||
import com.sun.net.httpserver.HttpHandler; | |||
import ffeststeuerungneu.Anzeige; | |||
public class AcceptHandler implements HttpHandler{ | |||
private Anzeige anzeige; | |||
public AcceptHandler(Anzeige anzeige) { | |||
this.anzeige = anzeige; | |||
} | |||
@Override | |||
public void handle(com.sun.net.httpserver.HttpExchange he) throws IOException { | |||
anzeige.clickAccept(); | |||
he.sendResponseHeaders(200, 0); | |||
OutputStream outputStream=he.getResponseBody(); | |||
outputStream.write(anzeige.getNumberOfImages()); | |||
outputStream.close(); | |||
System.out.println("Received Accept Request"); | |||
} | |||
} |
@ -0,0 +1,46 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package Server; | |||
import com.sun.net.httpserver.Headers; | |||
import com.sun.net.httpserver.HttpHandler; | |||
import ffeststeuerungneu.Anzeige; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.OutputStream; | |||
import java.nio.file.Files; | |||
import javax.sound.sampled.Port; | |||
import javax.xml.*; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class CountHandler implements HttpHandler { | |||
private Anzeige anzeige; | |||
public CountHandler(Anzeige anzeige) { | |||
this.anzeige = anzeige; | |||
} | |||
@Override | |||
public void handle(com.sun.net.httpserver.HttpExchange he) throws IOException { | |||
//File file = new File("C:\\ffestData\\whatsapp\\grimassen(1).jpg"); | |||
he.sendResponseHeaders(200, 0); | |||
OutputStream outputStream=he.getResponseBody(); | |||
outputStream.write(anzeige.getNumberOfImages()); | |||
outputStream.close(); | |||
System.out.println("Received Count Request"); | |||
} | |||
} |
@ -0,0 +1,35 @@ | |||
package Server; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.OutputStream; | |||
import com.sun.net.httpserver.HttpHandler; | |||
import ffeststeuerungneu.Anzeige; | |||
public class DeclineHandler implements HttpHandler{ | |||
private Anzeige anzeige; | |||
public DeclineHandler(Anzeige anzeige) { | |||
this.anzeige = anzeige; | |||
} | |||
@Override | |||
public void handle(com.sun.net.httpserver.HttpExchange he) throws IOException { | |||
anzeige.clickDecline(); | |||
he.sendResponseHeaders(200, 0); | |||
OutputStream outputStream=he.getResponseBody(); | |||
outputStream.write(anzeige.getNumberOfImages()); | |||
outputStream.close(); | |||
System.out.println("Received Accept Request"); | |||
} | |||
} |
@ -0,0 +1,72 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package Server; | |||
import com.sun.net.httpserver.HttpHandler; | |||
import ffeststeuerungneu.Anzeige; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.OutputStream; | |||
import java.nio.file.Files; | |||
import javax.imageio.ImageIO; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class ImageHandler implements HttpHandler { | |||
private Anzeige anzeige; | |||
public ImageHandler(Anzeige anzeige) { | |||
this.anzeige = anzeige; | |||
} | |||
@Override | |||
public void handle(com.sun.net.httpserver.HttpExchange he) throws IOException { | |||
System.out.println("test"); | |||
File temp = new File("C:\\ffestData\\temp.jpg"); | |||
temp.createNewFile(); | |||
ImageIO.write(anzeige.getBild(), "jpg", temp); | |||
he.sendResponseHeaders(200, temp.length()); | |||
he.setAttribute("image", 0); | |||
OutputStream outputStream=he.getResponseBody(); | |||
Files.copy(temp.toPath(), outputStream); | |||
outputStream.close(); | |||
System.out.println("Received REquest"); | |||
} | |||
/* | |||
@Override | |||
public void handle(com.sun.net.httpserver.HttpExchange he) throws IOException { | |||
File file = new File("C:\\ffestData\\whatsapp\\grimassen(1).jpg"); | |||
WritableRaster writableRaster=anzeige.getBild().getRaster(); | |||
DataBufferByte data=(DataBufferByte) writableRaster.getDataBuffer(); | |||
he.sendResponseHeaders(200, file.length()); | |||
he.setAttribute("image", 0); | |||
OutputStream outputStream=he.getResponseBody(); | |||
outputStream.write(data.getData()); | |||
outputStream.close(); | |||
System.out.println("Received Image Request"); | |||
} | |||
*/ | |||
} |
@ -0,0 +1,57 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package Server; | |||
import com.sun.net.httpserver.HttpServer; | |||
import ffeststeuerungneu.Anzeige; | |||
import java.io.IOException; | |||
import java.net.InetSocketAddress; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class Server { | |||
HttpServer server; | |||
Boolean running = false; | |||
public Server(Anzeige anzeige){ | |||
try { | |||
int port = 9000; | |||
server = HttpServer.create(new InetSocketAddress(port), 0); | |||
System.out.println("server started at " + port); | |||
server.createContext("/image", new ImageHandler(anzeige)); | |||
server.createContext("/count", new CountHandler(anzeige)); | |||
server.createContext("/accept", new AcceptHandler(anzeige)); | |||
server.createContext("/decline", new DeclineHandler(anzeige)); | |||
server.setExecutor(null); | |||
} catch (IOException ex) { | |||
Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
} | |||
public boolean getStatus(){ | |||
return running; | |||
} | |||
public void startServer(){ | |||
server.start(); | |||
running = true; | |||
} | |||
public void stopServer(){ | |||
System.out.println("stop"); | |||
server.stop(0); | |||
running = false; | |||
} | |||
} |
@ -0,0 +1,71 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
import bilderAuswahl.ThreadBilderAuswahl; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class ThreadSucheLinks extends Thread { | |||
private final String PFAD;// = "%appdata%\\.purple\\logs\\whatsapp\\491608599916"; | |||
// private String dir[]; | |||
private List<String> dir = new ArrayList(); | |||
private List<String> saved = new ArrayList(); | |||
// private String saved[] = new String[999]; | |||
private final File f; | |||
private int n = 0; | |||
private boolean save = false; | |||
// private Thread dateien[] = new Thread[999]; | |||
private List<Thread> t = new ArrayList(); | |||
ThreadBilderAuswahl tba; | |||
public ThreadSucheLinks(ThreadBilderAuswahl tba, String pfad) { | |||
PFAD = pfad; | |||
this.tba = tba; | |||
f = new File(PFAD); | |||
} | |||
@Override | |||
public void run() { | |||
while (true) { | |||
dir = new ArrayList<>(Arrays.asList(f.list())); | |||
if (dir.size() > 0) { | |||
for (int i = 0; i < dir.size(); i++) { | |||
for (int j = 0; j < saved.size(); j++) { | |||
if (dir.get(i).equals(saved.get(j))) { | |||
save = true; | |||
} | |||
} | |||
if (!save) { | |||
saved.add(dir.get(i)); | |||
t.add(new Thread(new UeberwacheDatei(saved.get(n), this, tba, PFAD))); | |||
t.get(n).start(); | |||
n++; | |||
} | |||
save = false; | |||
} | |||
} | |||
} | |||
} | |||
} |
@ -0,0 +1,97 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
import bilderAuswahl.ThreadBilderAuswahl; | |||
import ffeststeuerungneu.Log; | |||
import java.io.BufferedReader; | |||
import java.io.File; | |||
import java.io.FileNotFoundException; | |||
import java.io.FileReader; | |||
import java.io.IOException; | |||
import static java.lang.Thread.sleep; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
/** | |||
* | |||
* @author xewvtgbfhnju | |||
*/ | |||
public class UeberwacheDatei implements Runnable { | |||
private final String PFAD; //= "%appdata%\\.purple\\logs\\whatsapp\\491608599916"; | |||
private File f; | |||
private File log[]; | |||
private BufferedReader br; | |||
private String[] verarbeite; | |||
private List<String> links = new ArrayList(); | |||
private String line; | |||
private boolean schonda = false; | |||
private ThreadBilderAuswahl tba; | |||
public UeberwacheDatei(String Ordnername, ThreadSucheLinks sl, ThreadBilderAuswahl tba, String pfad) { | |||
this.tba = tba; | |||
PFAD = pfad; | |||
f = new File(PFAD + "\\" + Ordnername); | |||
log = f.listFiles(); | |||
try { | |||
if (log.length > 0) { | |||
br = new BufferedReader(new FileReader(log[0])); | |||
} | |||
} catch (FileNotFoundException ex) { | |||
Logger.getLogger(UeberwacheDatei.class.getName()).log(Level.SEVERE, null, ex); | |||
Log.setError(ex, "Class: File. File not found"); | |||
} | |||
} | |||
@Override | |||
public void run() { | |||
while (true) { | |||
try { | |||
line = " "; | |||
while (line != null && br != null) { | |||
line = br.readLine(); | |||
if (line != null && line.contains("<a href=")) { | |||
verarbeite = line.split("\""); | |||
for (int i = 0; i < links.size(); i++) { | |||
if (links.get(i).equals(verarbeite[5])) { | |||
schonda = true; | |||
} | |||
} | |||
if (!schonda) { | |||
links.add(verarbeite[5]); | |||
this.open(verarbeite[5]); | |||
} | |||
} | |||
} | |||
} catch (IOException ex) { | |||
Logger.getLogger(UeberwacheDatei.class.getName()).log(Level.SEVERE, null, ex); | |||
Log.setError(ex, "Class: ÜberwacheDaite. WhatsappLog not found"); | |||
} | |||
try { | |||
sleep(1000); | |||
} catch (InterruptedException ex) { | |||
Logger.getLogger(UeberwacheDatei.class.getName()).log(Level.SEVERE, null, ex); | |||
Log.setError(ex, "Class: ÜberwacheDaite. Thread Interrupted"); | |||
} | |||
} | |||
} | |||
private void open(String link) { | |||
tba.neuesBild(link); | |||
Log.incWhatsapp(); | |||
} | |||
} |
@ -0,0 +1,52 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package appium; | |||
import io.appium.java_client.service.local.AppiumDriverLocalService; | |||
import io.appium.java_client.service.local.AppiumServiceBuilder; | |||
import io.appium.java_client.service.local.flags.GeneralServerFlag; | |||
import org.openqa.selenium.remote.DesiredCapabilities; | |||
//import org.apache.commons. | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class AppiumServer { | |||
static AppiumDriverLocalService service; | |||
static AppiumServiceBuilder builder; | |||
static DesiredCapabilities cap; | |||
static void start(){ | |||
//Set Capabilities | |||
cap = new DesiredCapabilities(); | |||
cap.setCapability("noReset", "false"); | |||
//Build the Appium service | |||
builder = new AppiumServiceBuilder(); | |||
builder.withIPAddress("127.0.0.1"); | |||
builder.usingPort(4723); | |||
builder.withCapabilities(cap); | |||
builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE); | |||
builder.withArgument(GeneralServerFlag.LOG_LEVEL,"error"); | |||
//Start the server with the builder | |||
service = AppiumDriverLocalService.buildService(builder); | |||
service.start(); | |||
System.out.println("In Server - started"); | |||
} | |||
static void stop() { | |||
// service.stop(); | |||
} | |||
} |
@ -0,0 +1,79 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package appium; | |||
import io.appium.java_client.android.Activity; | |||
import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
import org.openqa.selenium.WebElement; | |||
import io.appium.java_client.android.AndroidDriver; | |||
import io.appium.java_client.android.AndroidKeyCode; | |||
import java.util.concurrent.TimeUnit; | |||
import org.openqa.selenium.remote.DesiredCapabilities; | |||
import org.openqa.selenium.By; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class Connector extends Thread { | |||
protected AndroidDriver driver = null; | |||
public int contactNumber = 0; | |||
List<WebElement> a = new ArrayList<WebElement>(); | |||
public Connector(){ | |||
AppiumServer.start(); | |||
driver = Driver.start(); | |||
} | |||
@Override | |||
public void run() { | |||
while(true){ | |||
a = driver.findElements(By.xpath("//*[@resource-id='com.whatsapp.w4b:id/conversations_row_contact_name']")); | |||
for(WebElement x : a){ | |||
if (x.getText().contains("+49")){ | |||
addContact(x.getText()); | |||
} | |||
} | |||
} | |||
} | |||
private void addContact(String number) { | |||
Activity contactActivity = new Activity("com.simplemobiletools.contacts", ".activities.EditContactActivity"); | |||
driver.startActivity(contactActivity); | |||
String withSpaces = number; | |||
number = number.replace(" ",""); | |||
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); | |||
driver.findElement(By.xpath("//*[@text='Vorname']")).sendKeys("mvo-" +contactNumber); | |||
driver.findElement(By.xpath("//*[@text='Nummer']")).sendKeys(number); | |||
driver.findElement(By.xpath("//*[@resource-id='com.simplemobiletools.contacts:id/save']")).click(); | |||
if(driver.findElements(By.xpath("//*[@text='mvo-" +contactNumber+"']")).size()>0){ | |||
driver.findElement(By.xpath("//*[@text='mvo-" +contactNumber+"']")).click(); | |||
}else{ | |||
if(driver.findElements(By.xpath("//*[@text='" + withSpaces +"']")).size() >0){ | |||
driver.findElement(By.xpath("//*[@text='" + withSpaces +"']")).click(); | |||
} | |||
} | |||
if(driver.findElements(By.xpath("//*[@resource-id='com.whatsapp.w4b:id/control_btn']")).size() > 0){ | |||
driver.findElement(By.xpath("//*[@resource-id='com.whatsapp.w4b:id/control_btn']")).click(); | |||
} | |||
driver.pressKeyCode(AndroidKeyCode.BACK); | |||
contactNumber++; | |||
} | |||
} |
@ -0,0 +1,49 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package appium; | |||
import io.appium.java_client.android.AndroidDriver; | |||
import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
import org.openqa.selenium.remote.DesiredCapabilities; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class Driver { | |||
private static AndroidDriver driver; | |||
public static AndroidDriver start(){ | |||
try { | |||
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), settings()); | |||
} catch (MalformedURLException ex) { | |||
Logger.getLogger(Connector.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
return driver; | |||
} | |||
private static DesiredCapabilities settings(){ | |||
DesiredCapabilities capability = new DesiredCapabilities(); | |||
capability.setCapability("deviceName", "879d796a"); | |||
capability.setCapability("platformName","Android"); | |||
capability.setCapability("platformVersion","7.1.2"); | |||
capability.setCapability("appPackage", "com.whatsapp.w4b"); | |||
capability.setCapability("appActivity", "com.whatsapp.Main"); | |||
capability.setCapability("noReset", true); | |||
capability.setCapability("fullReset", false); | |||
capability.setCapability("unicodeKeyboard", "true"); | |||
capability.setCapability("resetKeyboard", "true"); | |||
return capability; | |||
} | |||
} |
@ -0,0 +1,235 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package bilderAuswahl; | |||
import ffeststeuerungneu.Anzeige; | |||
import ffeststeuerungneu.Log; | |||
import java.awt.Color; | |||
import java.awt.Graphics; | |||
import java.awt.Graphics2D; | |||
import java.awt.GraphicsConfiguration; | |||
import java.awt.GraphicsDevice; | |||
import java.awt.GraphicsEnvironment; | |||
import java.awt.Transparency; | |||
import java.awt.event.ActionEvent; | |||
import java.awt.event.ActionListener; | |||
import java.awt.geom.AffineTransform; | |||
import java.awt.image.BufferedImage; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.net.URL; | |||
import java.text.SimpleDateFormat; | |||
import java.util.ArrayList; | |||
import java.util.Calendar; | |||
import java.util.List; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
import javax.imageio.ImageIO; | |||
import javax.swing.Timer; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class AnzeigeAuswahlbild extends javax.swing.JPanel { | |||
/** | |||
* Creates new form Auswahlbild | |||
*/ | |||
private static final int RIGHT = 0; | |||
private static final int LEFT = 1; | |||
private double fx, fy; | |||
private Timer t; | |||
private Anzeige gui; | |||
private BufferedImage rot, bim, NoImages; | |||
private Archiv archiv; | |||
private boolean erlaubt = false; | |||
private AffineTransform affineTransform; | |||
private BufferedImage rotatedImage; | |||
private Graphics2D g; | |||
private Anzeige a; | |||
private List<String> pfad = new ArrayList(); | |||
int RotAngle = 0; | |||
public AnzeigeAuswahlbild(String pfad, String iconPfad, Anzeige a) { | |||
this.a = a; | |||
archiv = new Archiv(pfad); | |||
initData(pfad); | |||
try { | |||
NoImages = ImageIO.read(new File(iconPfad + "NoImage.png")); | |||
// NoImages = ImageIO.read(this.getClass().getResourceAsStream(iconPfad + "NoImage.png")); | |||
} catch (IOException ex) { | |||
Logger.getLogger(AnzeigeAuswahlbild.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
bim = NoImages; | |||
initComponents(); | |||
t = new Timer(500, new ActionListener() { | |||
@Override | |||
public void actionPerformed(ActionEvent ae) { | |||
neuesBild(); | |||
} | |||
}); | |||
t.start(); | |||
} | |||
private void initData(String pfad) { | |||
checkDir(pfad); | |||
checkDir(pfad + "archiv"); | |||
checkDir(pfad + "archiv\\gut"); | |||
checkDir(pfad + "archiv\\müll"); | |||
Calendar cal = Calendar.getInstance(); | |||
SimpleDateFormat sdf = new SimpleDateFormat("HH_mm_ss"); | |||
checkDir(pfad + "archiv\\müll\\" + sdf.format(cal.getTime())); | |||
checkDir(pfad + "archiv\\gut\\" + sdf.format(cal.getTime())); | |||
} | |||
private boolean checkDir(String dirName) { | |||
File stats = new File(dirName); | |||
if (stats.exists() && stats.isDirectory()) // Überprüfen, ob es den Ordner gibt | |||
{ | |||
return true; | |||
} else { | |||
return stats.mkdir(); // Erstellen des Ordners | |||
} | |||
} | |||
@Override | |||
public void paintComponent(Graphics g) { | |||
super.paintComponent(g); | |||
g.setColor(Color.black); | |||
g.fillRect(0, 0, this.getWidth(), this.getHeight()); | |||
fx = ((double) this.getWidth() / bim.getWidth()); | |||
fy = ((double) this.getHeight() / bim.getHeight()); | |||
if (fx > fy) { | |||
g.drawImage(bim, (int) ((this.getWidth() - (bim.getWidth() * fy)) / 2), | |||
(int) ((this.getHeight() - (bim.getHeight() * fy)) / 2), | |||
(int) (bim.getWidth() * fy), (int) (bim.getHeight() * fy), this); | |||
} else { | |||
g.drawImage(bim, (int) ((this.getWidth() - (bim.getWidth() * fx)) / 2), | |||
(int) ((this.getHeight() - (bim.getHeight() * fx)) / 2), | |||
(int) (bim.getWidth() * fx), (int) (bim.getHeight() * fx), this); | |||
} | |||
} | |||
public void neuesBild() { | |||
if (pfad.size() > 0 && !erlaubt) { | |||
try { | |||
a.setButtons(true); | |||
a.sleepThreads(); | |||
bim = ImageIO.read(new File(pfad.get(0))); | |||
pfad.remove(0); | |||
erlaubt = true; | |||
rot = bim; | |||
} catch (IOException ex) { | |||
Logger.getLogger(AnzeigeAuswahlbild.class.getName()).log(Level.SEVERE, null, ex); | |||
Log.setError(ex, "Class: AnzeigeAuswahlbilde<. NeuesBild einlesen failed"); | |||
} | |||
} else if (!(pfad.size() > 0) && !erlaubt) { | |||
bim = NoImages; | |||
a.setButtons(false); | |||
} | |||
// if (tba.checkImage() && !erlaubt) { | |||
// bim = tba.getImage(); | |||
// erlaubt = true; | |||
// rot = bim; | |||
// } else if (!tba.checkImage() && !erlaubt) { | |||
// bim = NoImages; | |||
// } | |||
repaint(); | |||
} | |||
public void addPath(String p) { | |||
pfad.add(p); | |||
} | |||
public void verarbeite(boolean gut) { | |||
if (erlaubt) { | |||
erlaubt = false; | |||
if (gut) { | |||
archiv.bildInArchiv(bim); | |||
gui.uebergebeBild(bim); | |||
} else { | |||
archiv.bildInMuell(bim); | |||
} | |||
this.neuesBild(); | |||
} else { | |||
bim = NoImages; | |||
} | |||
} | |||
public void rotate(int angle) { | |||
bim = rotateImage(bim, Math.toRadians(angle)); | |||
repaint(); | |||
} | |||
public BufferedImage rotateImage(BufferedImage image, double angle) { | |||
double sin = Math.abs(Math.sin(angle)), cos = Math.abs(Math.cos(angle)); | |||
int w = image.getWidth(), h = image.getHeight(); | |||
int neww = (int) Math.floor(w * cos + h * sin), newh = (int) Math.floor(h * cos + w * sin); | |||
GraphicsConfiguration gc = getDefaultConfiguration(); | |||
BufferedImage result = gc.createCompatibleImage(neww, newh, Transparency.TRANSLUCENT); | |||
Graphics2D g = result.createGraphics(); | |||
g.translate((neww - w) / 2, (newh - h) / 2); | |||
g.rotate(angle, w / 2, h / 2); | |||
g.drawRenderedImage(image, null); | |||
g.dispose(); | |||
return result; | |||
} | |||
private GraphicsConfiguration getDefaultConfiguration() { | |||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |||
GraphicsDevice gd = ge.getDefaultScreenDevice(); | |||
return gd.getDefaultConfiguration(); | |||
} | |||
public void setAnzeige(Anzeige a) { | |||
gui = a; | |||
} | |||
private void initComponents() { | |||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); | |||
this.setLayout(layout); | |||
layout.setHorizontalGroup( | |||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |||
.addGap(0, 400, Short.MAX_VALUE) | |||
); | |||
layout.setVerticalGroup( | |||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |||
.addGap(0, 300, Short.MAX_VALUE) | |||
); | |||
} | |||
public BufferedImage getImage() { | |||
return bim; | |||
} | |||
} |
@ -0,0 +1,100 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package bilderAuswahl; | |||
import ffeststeuerungneu.Log; | |||
import java.awt.image.BufferedImage; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.nio.file.FileSystems; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Calendar; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
import javax.imageio.ImageIO; | |||
import javax.imageio.stream.ImageOutputStream; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class Archiv { | |||
private final String ARCHIVMÜLL; | |||
private final String ARCHIVGUT; | |||
private int archivMuell = 0; | |||
private int archivGut = 0; | |||
private File dir; | |||
public Archiv(String pfad) { | |||
Calendar cal = Calendar.getInstance(); | |||
SimpleDateFormat sdf = new SimpleDateFormat("HH_mm_ss"); | |||
ARCHIVMÜLL = pfad + "archiv\\Muell\\" + sdf.format(cal.getTime()) + "\\"; | |||
ARCHIVGUT = pfad + "archiv\\gut\\" + sdf.format(cal.getTime()) + "\\"; | |||
dir = new File(ARCHIVMÜLL); | |||
dir.mkdir(); | |||
dir = new File(ARCHIVGUT); | |||
dir.mkdir(); | |||
// for (int i = 0; i < archivPfadMuell.length; i++) { | |||
// if (i < 10) { | |||
// archivPfadMuell[i] = FileSystems.getDefault().getPath(ARCHIVMÜLL + "000" + i + ".jpg"); | |||
// archivPfadGut[i] = FileSystems.getDefault().getPath(ARCHIVGUT + "000" + i + ".jpg"); | |||
// } else if (i < 100) { | |||
// archivPfadMuell[i] = FileSystems.getDefault().getPath(ARCHIVMÜLL + "00" + i + ".jpg"); | |||
// archivPfadGut[i] = FileSystems.getDefault().getPath(ARCHIVGUT + "00" + i + ".jpg"); | |||
// } else if (i < 1000) { | |||
// archivPfadMuell[i] = FileSystems.getDefault().getPath(ARCHIVMÜLL + "0" + i + ".jpg"); | |||
// archivPfadGut[i] = FileSystems.getDefault().getPath(ARCHIVGUT + "0" + i + ".jpg"); | |||
// } else { | |||
// archivPfadMuell[i] = FileSystems.getDefault().getPath(ARCHIVMÜLL + i + ".jpg"); | |||
// archivPfadGut[i] = FileSystems.getDefault().getPath(ARCHIVGUT + i + ".jpg"); | |||
// } | |||
// | |||
// } | |||
} | |||
public void bildInArchiv(BufferedImage bim) { | |||
try { | |||
if (archivGut < 10) { | |||
ImageIO.write(bim, "jpg", new File(ARCHIVGUT + "000" + archivGut + ".jpg")); | |||
} else if (archivGut < 100) { | |||
ImageIO.write(bim, "jpg", new File(ARCHIVGUT + "00" + archivGut + ".jpg")); | |||
} else if (archivGut < 1000) { | |||
ImageIO.write(bim, "jpg", new File(ARCHIVGUT + "0" + archivGut + ".jpg")); | |||
} else { | |||
ImageIO.write(bim, "jpg", new File(ARCHIVGUT + archivGut + ".jpg")); | |||
} | |||
} catch (IOException ex) { | |||
Logger.getLogger(Archiv.class.getName()).log(Level.SEVERE, null, ex); | |||
Log.setError(ex, "Class: bildInArchiv. Writing to archive failed"); | |||
} | |||
archivGut++; | |||
} | |||
public void bildInMuell(BufferedImage bim) { | |||
try { | |||
if (archivGut < 10) { | |||
ImageIO.write(bim, "jpg", new File(ARCHIVMÜLL + "000" + archivMuell + ".jpg")); | |||
} else if (archivGut < 100) { | |||
ImageIO.write(bim, "jpg", new File(ARCHIVMÜLL + "00" + archivMuell + ".jpg")); | |||
} else if (archivGut < 1000) { | |||
ImageIO.write(bim, "jpg", new File(ARCHIVMÜLL + "0" + archivMuell + ".jpg")); | |||
} else { | |||
ImageIO.write(bim, "jpg", new File(ARCHIVMÜLL + archivMuell + ".jpg")); | |||
} | |||
} catch (IOException ex) { | |||
Logger.getLogger(Archiv.class.getName()).log(Level.SEVERE, null, ex); | |||
Log.setError(ex, "Class: bildInArchiv. Writing to archive failed"); | |||
} | |||
archivMuell++; | |||
} | |||
} |
@ -0,0 +1,35 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package bilderAuswahl; | |||
import ffeststeuerungneu.Anzeige; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class ThreadBilderAuswahl { | |||
private final Anzeige anzeige; | |||
private List<String> paths = new ArrayList(); | |||
public ThreadBilderAuswahl(Anzeige anzeige) { | |||
this.anzeige = anzeige; | |||
} | |||
public synchronized void neuesBild(String link){ | |||
paths.add(link); | |||
anzeige.addPath(link); | |||
} | |||
public boolean checkImage() { | |||
return paths.size()>0; | |||
} | |||
} |
@ -0,0 +1,15 @@ | |||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> | |||
<properties> | |||
<comment>Speicherorte</comment> | |||
<entry key="snapchat">C:\ffestData\snapchat</entry> | |||
<entry key="whatsapp">C:\ffestData\whatsapp</entry> | |||
<entry key="instagram">C:\ffestData\instagram\4K Stogram\frühling_tag</entry> | |||
<entry key="ffestData">C:\ffestData\</entry> | |||
<entry key="resources">/resources/image/</entry> | |||
<entry key="whatsappnummer">015259079638</entry> | |||
<entry key="instagramtag">#frühling</entry> | |||
<entry key="snapchatname">mv_owennnn</entry> | |||
<entry key="fullscreen">no</entry> | |||
<entry key="screen">1</entry> | |||
</properties> |
@ -0,0 +1,858 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package ffeststeuerungneu; | |||
import Diashow.DiashowVerwaltung; | |||
import Bildquellen.InstagramBilder; | |||
import Bildquellen.SnapchatBilder; | |||
import bilderAuswahl.ThreadBilderAuswahl; | |||
import Bildquellen.WhatsappBilder; | |||
import Server.Server; | |||
import bilderAuswahl.AnzeigeAuswahlbild; | |||
import appium.Connector; | |||
import java.awt.BorderLayout; | |||
import java.awt.Color; | |||
import java.awt.Dimension; | |||
import java.awt.GridLayout; | |||
import java.awt.Image; | |||
import java.awt.Insets; | |||
import java.awt.event.ActionEvent; | |||
import java.awt.image.BufferedImage; | |||
import java.io.File; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Calendar; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
import javax.swing.*; | |||
import javax.swing.border.Border; | |||
import com.sun.java.swing.plaf.windows.WindowsTabbedPaneUI; | |||
/** | |||
* | |||
* @author Rudi | |||
*/ | |||
public class Anzeige extends JPanel { | |||
//int for Icons | |||
private static final int ACCEPT = 0; | |||
private static final int DECLINE = 1; | |||
private static final int ROTATELEFT = 2; | |||
private static final int ROTATERIGHT = 3; | |||
private static final int PAUSE = 4; | |||
private static final int START = 5; | |||
private static final int FEHLER = 6; | |||
private static final int EINGANG = 7; | |||
private static final int SETTINGS = 8; | |||
private static final int MONITOR = 9; | |||
private final String ICONPFAD; | |||
private static final int INSTAGRAM = 0; | |||
private static final int SNAPCHAT = 1; | |||
private static final int WHATSAPP = 2; | |||
//int for showing number of received messages | |||
private int snapchatBildZahl = 0; | |||
private int instagramBildZahl = 0; | |||
private int fileBildZahl = 0; | |||
private int bildZahl = 0; | |||
private DiashowVerwaltung diashowVerwaltung; | |||
private ThreadBilderAuswahl tba; | |||
//Threads to receive | |||
private Thread threadInstagram; | |||
private Thread threadSnapchat; | |||
private Thread threadWhatsapp; | |||
private Thread threadWhatsappListener; | |||
private final Props p; | |||
private boolean fertig = false; | |||
private boolean pause = false; | |||
private Server server; | |||
private String meldung; | |||
private Border buttonBorder; | |||
private Border whiteBorder; | |||
private final ImageIcon icon[] = new ImageIcon[10]; | |||
private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); | |||
/** | |||
* Creates new form Anzeige | |||
* | |||
* @param f Frame | |||
*/ | |||
public Anzeige(frame f) { | |||
p = new Props(); | |||
initDirectories(p.getInfo("ffestData"), p.getInfo("instagram"), p.getInfo("snapchat")); | |||
ICONPFAD = p.getInfo("resources"); | |||
//Icons are read | |||
initIcon(); | |||
//Classes get initialised | |||
initClasses(); | |||
//Graphics get initialised | |||
initGraphic(); | |||
//starts show on 2nd screen | |||
diashowVerwaltung.start(); | |||
//sets Touchoptimized tabsize | |||
tabbedPane.setUI(new MyTabUI()); | |||
//initialising has finished | |||
fertig = true; | |||
} | |||
public void setLogAnzeige() { | |||
Log.setAnzeige(this); | |||
} | |||
private void initClasses() { | |||
this.setBackground(Color.white); | |||
buttonBorder = BorderFactory.createRaisedSoftBevelBorder(); | |||
whiteBorder = BorderFactory.createEmptyBorder(0, 10, 0, 10); | |||
diashowVerwaltung = new DiashowVerwaltung(Integer.valueOf(p.getInfo("screen"))); | |||
auswahlbild1 = new AnzeigeAuswahlbild(getPfad(), p.getInfo("resources"), this); | |||
tba = new ThreadBilderAuswahl(this); | |||
} | |||
public void sleepThreads() { | |||
try { | |||
Thread.sleep(500); | |||
} catch (InterruptedException ex) { | |||
Logger.getLogger(Anzeige.class.getName()).log(Level.SEVERE, null, ex); | |||
Log.setError(ex, "Class: Anzeige. Sleepthreads failed"); | |||
} | |||
} | |||
//Überprüft ob Ordner/Pfad vorhanden, erstellt ihn zur Not | |||
private boolean checkDir(String dirName) { | |||
File stats = new File(dirName); | |||
if (stats.exists() && stats.isDirectory()) // Überprüfen, ob es den Ordner gibt | |||
{ | |||
Log.setInfo("Directory exists: " + dirName); | |||
return true; | |||
} else { | |||
Log.setDebug("Directory missing: " + dirName); | |||
return stats.mkdirs(); // Erstellen des Ordners | |||
} | |||
} | |||
//checks if all directories exist | |||
public void initDirectories(String pfad, String instagram, String snapchat) { | |||
checkDir(instagram); | |||
checkDir(snapchat); | |||
checkDir(pfad); | |||
checkDir(pfad + "archiv"); | |||
checkDir(pfad + "log"); | |||
checkDir(pfad + "archiv\\gut"); | |||
checkDir(pfad + "archiv\\müll"); | |||
Calendar cal = Calendar.getInstance(); | |||
SimpleDateFormat sdf = new SimpleDateFormat("HH_mm_ss"); | |||
checkDir(pfad + "archiv\\müll\\" + sdf.format(cal.getTime())); | |||
checkDir(pfad + "archiv\\gut\\" + sdf.format(cal.getTime())); | |||
Log.setProps(pfad); | |||
} | |||
/** | |||
* Gives new Image to the Diasho | |||
* | |||
* @param bim Image for Show | |||
*/ | |||
public void uebergebeBild(BufferedImage bim) { | |||
diashowVerwaltung.neuesBild(bim); | |||
} | |||
/** | |||
* | |||
* @return Pfad o ffestdata | |||
*/ | |||
public String getPfad() { | |||
return p.getInfo("ffestData"); | |||
// return "C:\\"; | |||
} | |||
/** | |||
* initialises Icons | |||
*/ | |||
private void initIcon() { | |||
icon[ACCEPT] = new ImageIcon(ICONPFAD + "accept.png"); | |||
icon[DECLINE] = new ImageIcon(ICONPFAD + "decline.png"); | |||
icon[ROTATERIGHT] = new ImageIcon(ICONPFAD + "rotateRight.png"); | |||
icon[ROTATELEFT] = new ImageIcon(ICONPFAD + "rotateLeft.png"); | |||
icon[PAUSE] = new ImageIcon(ICONPFAD + "pause.png"); | |||
icon[START] = new ImageIcon(ICONPFAD + "start.png"); | |||
icon[FEHLER] = new ImageIcon(ICONPFAD + "fehler.png"); | |||
icon[EINGANG] = new ImageIcon(ICONPFAD + "eingang.png"); | |||
icon[SETTINGS] = new ImageIcon(ICONPFAD + "settings.png"); | |||
icon[MONITOR] = new ImageIcon(ICONPFAD + "monitor.png"); | |||
// | |||
// icon[DECLINE] = new ImageIcon(this.getClass().getResource(ICONPFAD + "decline.png")); | |||
// icon[ROTATERIGHT] = new ImageIcon(this.getClass().getResource(ICONPFAD + "rotateRight.png")); | |||
// icon[ROTATELEFT] = new ImageIcon(this.getClass().getResource(ICONPFAD + "rotateLeft.png")); | |||
// icon[PAUSE] = new ImageIcon(this.getClass().getResource(ICONPFAD + "pause.png")); | |||
// icon[START] = new ImageIcon(this.getClass().getResource(ICONPFAD + "start.png")); | |||
// icon[FEHLER] = new ImageIcon(this.getClass().getResource(ICONPFAD + "fehler.png")); | |||
// icon[EINGANG] = new ImageIcon(this.getClass().getResource(ICONPFAD + "eingang.png")); | |||
// icon[SETTINGS] = new ImageIcon(this.getClass().getResource(ICONPFAD + "settings.png")); | |||
// icon[MONITOR] = new ImageIcon(this.getClass().getResource(ICONPFAD + "monitor.png")); | |||
scaleIcon(); | |||
} | |||
/** | |||
* Scales Icons | |||
*/ | |||
private void scaleIcon() { | |||
for (int i = 0; i < FEHLER; i++) { | |||
icon[i].setImage(icon[i].getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)); | |||
} | |||
//TabIcons are smaller | |||
for (int i = FEHLER; i < icon.length; i++) { | |||
icon[i].setImage(icon[i].getImage().getScaledInstance(25, 25, Image.SCALE_DEFAULT)); | |||
} | |||
} | |||
@Override | |||
/** | |||
* sets sizes of Components new | |||
*/ | |||
public void repaint() { | |||
if (fertig) { | |||
// | |||
// this.textareaLog.setPreferredSize(new Dimension(this.getWidth(), (int) (this.getHeight() * 0.6))); | |||
tabbedPane.setPreferredSize(new Dimension(this.getWidth(), this.getHeight())); | |||
auswahlbild1.setPreferredSize(new Dimension(this.getWidth(), (int) ((this.getHeight() - 210)))); | |||
buttonDecline.setPreferredSize(new Dimension((int) (this.getWidth() / 4.5), 125)); | |||
buttonAccept.setPreferredSize(new Dimension((int) (this.getWidth() / 4.5), 125)); | |||
buttonRotateLeft.setPreferredSize(new Dimension((int) (this.getWidth() / 4.5), 125)); | |||
buttonRotateRight.setPreferredSize(new Dimension((int) (this.getWidth() / 4.5), 125)); | |||
this.buttonsEinstellungen.setPreferredSize(new Dimension(this.getWidth(), (int) (this.getHeight() * 0.25))); | |||
this.panelSliderEinstellungen.setPreferredSize(new Dimension(this.getWidth(), (int) (this.getHeight() * 0.4))); | |||
this.buttonNächstesBild.setPreferredSize(new Dimension((int) (buttonsEinstellungen.getWidth() * 0.25), buttonsEinstellungen.getHeight())); | |||
this.buttonPause.setPreferredSize(new Dimension((int) (buttonsEinstellungen.getWidth() * 0.25), buttonsEinstellungen.getHeight())); | |||
this.textareaLog.setPreferredSize(new Dimension(this.getWidth(), (int) (this.getHeight() * 0.6))); | |||
} | |||
} | |||
/** | |||
* initialises Graphic components and adds them to Panel | |||
*/ | |||
private void initGraphic() { | |||
initComponents(); | |||
initSlider(); | |||
initButtons(); | |||
initMenuband(); | |||
initEinstellungen(); | |||
initMonitor(); | |||
auswahlbild1.setAnzeige(this); | |||
panelBildereingang.setLayout(new BorderLayout()); | |||
panelBildereingang.add(auswahlbild1, BorderLayout.NORTH); | |||
panelBildereingang.add(panelButtons, BorderLayout.SOUTH); | |||
panelMonitor.setVisible(true); | |||
tabbedPane.addTab(" Bildereingang (" + bildZahl + ")", panelBildereingang); | |||
tabbedPane.addTab(" Diashow", panelDiashow); | |||
tabbedPane.addTab(" Monitor", panelMonitor); | |||
tabbedPane.setIconAt(0, icon[EINGANG]); | |||
tabbedPane.setIconAt(1, icon[SETTINGS]); | |||
tabbedPane.setIconAt(2, icon[MONITOR]); | |||
this.add(tabbedPane); | |||
validate(); | |||
repaint(); | |||
} | |||
/** | |||
* adds/creates Settingswindow | |||
*/ | |||
private void initEinstellungen() { | |||
this.labelAnzahlbilder.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
this.labelBilddauer.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
this.sliderAnzahlbilder.setFont(new java.awt.Font("Tahoma", 4, 20)); | |||
this.sliderBilddauer.setFont(new java.awt.Font("Tahoma", 4, 20)); | |||
panelThreadsControl.setLayout(new GridLayout(2, 5)); | |||
panelThreadsControl.add(new JLabel("")); | |||
panelThreadsControl.add(new JLabel("")); | |||
panelThreadsControl.add(new JLabel("")); | |||
panelThreadsControl.add(new JLabel("")); | |||
panelThreadsControl.add(new JLabel("")); | |||
panelThreadsControl.add(buttonInstagram); | |||
panelThreadsControl.add(buttonSnapchat); | |||
panelThreadsControl.add(buttonFile); | |||
panelThreadsControl.add(buttonWhatsappListener); | |||
panelThreadsControl.add(buttonServer); | |||
panelLabel.setLayout(new BorderLayout()); | |||
buttonsEinstellungen.setLayout(new GridLayout(1, 3)); | |||
buttonsEinstellungen.add(buttonPause, BorderLayout.WEST); | |||
buttonsEinstellungen.add(panelLabel); | |||
panelLabel.add(labelPause, BorderLayout.CENTER); | |||
labelPause.setIcon(icon[DECLINE]); | |||
buttonsEinstellungen.add(this.buttonNächstesBild, BorderLayout.EAST); | |||
labelPause.setVisible(false); | |||
// panelSliderBilddauer.setBorder(whiteBorder); | |||
// panelSliderBildanzahl.setBorder(whiteBorder); | |||
panelSliderBilddauer.setLayout(new BorderLayout()); | |||
panelSliderBildanzahl.setLayout(new BorderLayout()); | |||
panelSliderBilddauer.add(this.labelBilddauer, BorderLayout.CENTER); | |||
panelSliderBilddauer.add(sliderBilddauer, BorderLayout.SOUTH); | |||
panelSliderBildanzahl.add(this.labelAnzahlbilder, BorderLayout.CENTER); | |||
panelSliderBildanzahl.add(sliderAnzahlbilder, BorderLayout.SOUTH); | |||
panelDiashow.setLayout(new GridLayout(4, 1)); | |||
panelDiashow.add(this.buttonsEinstellungen); | |||
panelDiashow.add(panelThreadsControl); | |||
panelDiashow.add(panelSliderBilddauer); | |||
panelDiashow.add(panelSliderBildanzahl); | |||
} | |||
/** | |||
* adds Buttons of image Entry (Accept etc.) | |||
*/ | |||
private void initMenuband() { | |||
panelButtons.setLayout(new GridLayout(1, 4)); | |||
panelButtons.add(buttonAccept); | |||
panelButtons.add(buttonRotateLeft); | |||
panelButtons.add(buttonRotateRight); | |||
panelButtons.add(buttonDecline); | |||
} | |||
/** | |||
* initialises Graphical Components | |||
*/ | |||
private void initComponents() { | |||
tabbedPane = new JTabbedPane(); | |||
server = new Server(this); | |||
// tabbedPane.setFont(new java.awt.Font("Tahoma", 4, 12)); | |||
panelBildereingang = new JPanel(); | |||
panelDiashow = new JPanel(); | |||
panelButtons = new JPanel(); | |||
buttonsEinstellungen = new JPanel(); | |||
panelSliderEinstellungen = new JPanel(); | |||
panelThreadsControl = new JPanel(); | |||
panelSliderBilddauer = new JPanel(); | |||
panelSliderBildanzahl = new JPanel(); | |||
panelLog = new JPanel(); | |||
panelMonitor = new JPanel(); | |||
panelMonitorInfo = new JPanel(); | |||
panelLabel = new JPanel(); | |||
labelBilddauer = new JLabel("Anzeigedauer Bild"); | |||
labelAnzahlbilder = new JLabel("Anzahl Bilder"); | |||
labelPause = new JLabel("Pause"); | |||
labelInstagram = new JLabel("Instagram: 0"); | |||
labelSnapchat = new JLabel("Snapchat: 0"); | |||
labelFile = new JLabel("File: 0"); | |||
buttonAccept = new JButton(icon[ACCEPT]); | |||
buttonDecline = new JButton(icon[DECLINE]); | |||
buttonRotateRight = new JButton(icon[ROTATERIGHT]); | |||
buttonRotateLeft = new JButton(icon[ROTATELEFT]); | |||
buttonPause = new JButton(icon[PAUSE]); | |||
buttonInstagram = new JButton("Instagram"); | |||
buttonSnapchat = new JButton("Snapchat"); | |||
buttonFile = new JButton("Whatsapp"); | |||
buttonWhatsappListener = new JButton("Listener"); | |||
buttonServer = new JButton("Server"); | |||
buttonResetAlarm = new JButton("ResetAlarm"); | |||
sliderBilddauer = new JSlider(); | |||
buttonNächstesBild = new JButton(); | |||
sliderAnzahlbilder = new JSlider(); | |||
textareaLog = new JTextArea(" "); | |||
} | |||
/** | |||
* creates Slider and sets properties | |||
*/ | |||
private void initSlider() { | |||
sliderAnzahlbilder.setMajorTickSpacing(5); | |||
sliderAnzahlbilder.setMaximum(30); | |||
sliderAnzahlbilder.setMinorTickSpacing(1); | |||
sliderAnzahlbilder.setPaintLabels(true); | |||
sliderAnzahlbilder.setPaintTicks(true); | |||
sliderAnzahlbilder.setSnapToTicks(true); | |||
sliderAnzahlbilder.setValue(10); | |||
sliderAnzahlbilder.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); | |||
sliderAnzahlbilder.setEnabled(false); | |||
sliderBilddauer.setMajorTickSpacing(5); | |||
sliderBilddauer.setMaximum(30); | |||
sliderBilddauer.setMinorTickSpacing(1); | |||
sliderBilddauer.setPaintLabels(true); | |||
sliderBilddauer.setPaintTicks(true); | |||
sliderBilddauer.setSnapToTicks(true); | |||
sliderBilddauer.setValue(15); | |||
sliderBilddauer.setExtent(1); | |||
sliderBilddauer.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); | |||
sliderBilddauer.addChangeListener((javax.swing.event.ChangeEvent evt) -> { | |||
actionBildDauerStateChanged(evt); | |||
}); | |||
} | |||
/** | |||
* adds path of a new Image | |||
* | |||
* @param pfad Link to the new Image | |||
*/ | |||
public void addPath(String pfad) { | |||
this.auswahlbild1.addPath(pfad); | |||
bildZahl++; | |||
setBildZahl(); | |||
} | |||
/** | |||
* adds Buttons and properties | |||
*/ | |||
private void initButtons() { | |||
buttonAccept.setText("Accept"); | |||
buttonDecline.setText("Decline"); | |||
buttonRotateRight.setText("Rechts drehen"); | |||
buttonRotateLeft.setText("Links drehen"); | |||
buttonNächstesBild.setText("Nächstes Bild"); | |||
buttonResetAlarm.setText("Reset Alarm"); | |||
buttonPause.setText(" Pause"); | |||
buttonAccept.setFont(new java.awt.Font("Tahoma", 4, 18)); | |||
buttonDecline.setFont(new java.awt.Font("Tahoma", 4, 18)); | |||
buttonRotateRight.setFont(new java.awt.Font("Tahoma", 4, 18)); | |||
buttonRotateLeft.setFont(new java.awt.Font("Tahoma", 4, 18)); | |||
buttonNächstesBild.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
buttonResetAlarm.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
buttonPause.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
buttonInstagram.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
buttonFile.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
buttonWhatsappListener.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
buttonSnapchat.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
buttonSnapchat.addActionListener(this::actionSnapThreadActionPerformed); | |||
buttonInstagram.addActionListener(this::actionInstaThreadActionPerformed); | |||
buttonFile.addActionListener(this::actionWhatsappThreadActionPerformed); | |||
buttonPause.addActionListener(this::actionButtonPauseActionPerformed); | |||
buttonNächstesBild.addActionListener(this::actionNächstesBildActionPerformed); | |||
buttonAccept.addActionListener((evt) -> this.actionAcceptImageActionPerformed(evt)); | |||
buttonDecline.addActionListener(this::actionDeclineImageActionPerformed); | |||
buttonRotateRight.addActionListener(this::actionRotateImageRechtsActionPerformed); | |||
buttonRotateLeft.addActionListener((evt) -> this.actionRotateImageLinksActionPerformed(evt)); | |||
buttonResetAlarm.addActionListener((evt) -> this.actionResetAlarmActionPerformed(evt)); | |||
buttonWhatsappListener.addActionListener((evt) -> this.actionWhatsappListenerActionPerformed(evt)); | |||
buttonServer.addActionListener((evt) -> this.actionStartServerPerformed(evt)); | |||
buttonResetAlarm.setEnabled(false); | |||
buttonSnapchat.setBackground(Color.red); | |||
buttonInstagram.setBackground(Color.red); | |||
buttonFile.setBackground(Color.red); | |||
buttonWhatsappListener.setBackground(Color.red); | |||
} | |||
/** | |||
* creates MonitorPanel | |||
*/ | |||
private void initMonitor() { | |||
labelSnapchat.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
labelFile.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
labelInstagram.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
buttonResetAlarm.setFont(new java.awt.Font("Tahoma", 4, 25)); | |||
panelMonitor.setLayout(new BorderLayout()); | |||
this.panelMonitorInfo.setLayout(new GridLayout(2, 4)); | |||
this.panelMonitorInfo.add(new JLabel("")); | |||
this.panelMonitorInfo.add(new JLabel("")); | |||
this.panelMonitorInfo.add(new JLabel("")); | |||
this.panelMonitorInfo.add(new JLabel("")); | |||
this.panelMonitorInfo.add(labelSnapchat); | |||
panelMonitorInfo.add(labelInstagram); | |||
panelMonitorInfo.add(labelFile); | |||
panelMonitorInfo.add(buttonResetAlarm); | |||
this.panelLog.add(textareaLog); | |||
panelMonitor.add(panelMonitorInfo, BorderLayout.NORTH); | |||
panelMonitor.add(panelLog, BorderLayout.SOUTH); | |||
} | |||
/** | |||
* Action when Snapchat button pressed (starts/stops snapchat thread) | |||
* | |||
* @param evt not used | |||
*/ | |||
private void actionSnapThreadActionPerformed(java.awt.event.ActionEvent evt) { | |||
if (threadSnapchat != null && threadSnapchat.isAlive()) { | |||
meldung = "SnapchatThread BEENDEN?"; | |||
} else { | |||
meldung = "SnapchatThread starten?"; | |||
} | |||
int n = JOptionPane.showConfirmDialog( | |||
this, | |||
meldung, | |||
"SelfieGrabber", | |||
JOptionPane.YES_NO_OPTION); | |||
if (n == 0) { | |||
if (threadSnapchat != null && threadSnapchat.isAlive()) { | |||
threadSnapchat.interrupt(); | |||
this.buttonSnapchat.setBackground(Color.RED); | |||
diashowVerwaltung.setOnline(SNAPCHAT, false); | |||
} else { | |||
threadSnapchat = new SnapchatBilder(tba, p.getInfo("snapchat")); | |||
threadSnapchat.start(); | |||
this.buttonSnapchat.setBackground(Color.GREEN); | |||
diashowVerwaltung.setOnline(SNAPCHAT, true); | |||
} | |||
} | |||
} | |||
private void actionStartServerPerformed(java.awt.event.ActionEvent evt){ | |||
if (server.getStatus()) { | |||
meldung = "Server BEENDEN?"; | |||
} else { | |||
meldung = "Server starten?"; | |||
} | |||
int n = JOptionPane.showConfirmDialog( | |||
this, | |||
meldung, | |||
"SelfieGrabber", | |||
JOptionPane.YES_NO_OPTION); | |||
if (n == 0) { | |||
if (server.getStatus()) { | |||
server.stopServer(); | |||
this.buttonServer.setBackground(Color.RED); | |||
} else { | |||
server.startServer(); | |||
this.buttonServer.setBackground(Color.GREEN); | |||
} | |||
} | |||
} | |||
/** | |||
* Action when insta button pressed (starts/stops insta thread) | |||
* | |||
* @param evt not used | |||
*/ | |||
private void actionInstaThreadActionPerformed(java.awt.event.ActionEvent evt) { | |||
if (threadInstagram != null && threadInstagram.isAlive()) { | |||
meldung = "InstagramThread BEENDEN?"; | |||
} else { | |||
meldung = "InstagramThread starten?"; | |||
} | |||
int n = JOptionPane.showConfirmDialog( | |||
this, | |||
meldung, | |||
"SelfieGrabber", | |||
JOptionPane.YES_NO_OPTION); | |||
if (n == 0) { | |||
if (threadInstagram != null && threadInstagram.isAlive()) { | |||
threadInstagram.interrupt(); | |||
this.buttonInstagram.setBackground(Color.RED); | |||
diashowVerwaltung.setOnline(INSTAGRAM, false); | |||
} else { | |||
threadInstagram = new InstagramBilder(tba, p.getInfo("instagram")); | |||
threadInstagram.start(); | |||
this.buttonInstagram.setBackground(Color.GREEN); | |||
diashowVerwaltung.setOnline(INSTAGRAM, true); | |||
} | |||
} | |||
} | |||
/** | |||
* Action when file button pressed (starts/stops file thread) | |||
* | |||
* @param evt not used | |||
*/ | |||
private void actionWhatsappThreadActionPerformed(java.awt.event.ActionEvent evt) { | |||
if (threadWhatsapp != null && threadWhatsapp.isAlive()) { | |||
meldung = "FileThread BEENDEN?"; | |||
} else { | |||
meldung = "FileThread starten?"; | |||
} | |||
int n = JOptionPane.showConfirmDialog( | |||
this, | |||
meldung, | |||
"SelfieGrabber", | |||
JOptionPane.YES_NO_OPTION); | |||
if (n == 0) { | |||
if (threadWhatsapp != null && threadWhatsapp.isAlive()) { | |||
threadWhatsapp.interrupt(); | |||
this.buttonFile.setBackground(Color.RED); | |||
diashowVerwaltung.setOnline(WHATSAPP, false); | |||
} else { | |||
threadWhatsapp = new WhatsappBilder(tba, p.getInfo("whatsapp")); | |||
threadWhatsapp.start(); | |||
this.buttonFile.setBackground(Color.GREEN); | |||
diashowVerwaltung.setOnline(WHATSAPP, true); | |||
} | |||
} | |||
} | |||
/** | |||
* Accept button pressed -> adds image to show | |||
* | |||
* @param evt not used | |||
*/ | |||
private void actionAcceptImageActionPerformed(java.awt.event.ActionEvent evt) { | |||
auswahlbild1.verarbeite(true); | |||
bildZahl--; | |||
setBildZahl(); | |||
this.labelFile.setText("File: " + Log.getFile()); | |||
this.labelSnapchat.setText("Snapchat: " + Log.getSnapchat()); | |||
this.labelInstagram.setText("Instagram: " + Log.getInstagram()); | |||
} | |||
/** | |||
* rotate Rigth button pressed -> rotates image | |||
* | |||
* @param evt not used | |||
*/ | |||
private void actionRotateImageRechtsActionPerformed(java.awt.event.ActionEvent evt) { | |||
auswahlbild1.rotate(90); | |||
} | |||
/** | |||
* decline button pressed -> saves images in garbage | |||
* | |||
* @param evt | |||
*/ | |||
private void actionDeclineImageActionPerformed(java.awt.event.ActionEvent evt) { | |||
auswahlbild1.verarbeite(false); | |||
bildZahl--; | |||
setBildZahl(); | |||
} | |||
/** | |||
* button Pause pressed -> pausses show, sets label pause visible | |||
* | |||
* @param evt | |||
*/ | |||
private void actionButtonPauseActionPerformed(java.awt.event.ActionEvent evt) { | |||
if (pause != true) { | |||
labelPause.setVisible(true); | |||
buttonPause.setIcon(icon[START]); | |||
buttonPause.setText(" Start "); | |||
pause = true; | |||
} else { | |||
labelPause.setVisible(false); | |||
buttonPause.setIcon(icon[PAUSE]); | |||
buttonPause.setText(" Pause"); | |||
pause = false; | |||
} | |||
repaint(); | |||
diashowVerwaltung.pause(); | |||
this.validate(); | |||
} | |||
private void actionBildDauerStateChanged(javax.swing.event.ChangeEvent evt) { | |||
if (sliderBilddauer.getValue() < 1) { | |||
sliderBilddauer.setValue(1); | |||
} | |||
diashowVerwaltung.setTime(sliderBilddauer.getValue()); | |||
} | |||
private void actionNächstesBildActionPerformed(java.awt.event.ActionEvent evt) { | |||
diashowVerwaltung.weiter(); | |||
} | |||
private void actionRotateImageLinksActionPerformed(java.awt.event.ActionEvent evt) { | |||
auswahlbild1.rotate(-90); | |||
} | |||
private void actionResetAlarmActionPerformed(java.awt.event.ActionEvent evt) { | |||
buttonResetAlarm.setEnabled(false); | |||
this.tabbedPane.setIconAt(2, icon[MONITOR]); | |||
this.tabbedPane.setForegroundAt(2, Color.black); | |||
} | |||
private void actionWhatsappListenerActionPerformed(java.awt.event.ActionEvent evt) { | |||
if (threadWhatsappListener != null && threadWhatsappListener.isAlive()) { | |||
meldung = "ListenerThread BEENDEN?"; | |||
} else { | |||
meldung = "ListenerThread starten?"; | |||
} | |||
int n = JOptionPane.showConfirmDialog( | |||
this, | |||
meldung, | |||
"Listener", | |||
JOptionPane.YES_NO_OPTION); | |||
if (n == 0) { | |||
if (threadWhatsappListener != null && threadWhatsappListener.isAlive()) { | |||
threadWhatsappListener.interrupt(); | |||
this.buttonWhatsappListener.setBackground(Color.RED); | |||
} else { | |||
threadWhatsappListener = new Connector(); | |||
threadWhatsappListener.start(); | |||
this.buttonWhatsappListener.setBackground(Color.GREEN); | |||
} | |||
} | |||
} | |||
public void setButtons(boolean status) { | |||
buttonAccept.setEnabled(status); | |||
buttonDecline.setEnabled(status); | |||
buttonRotateLeft.setEnabled(status); | |||
buttonRotateRight.setEnabled(status); | |||
} | |||
public void setLogData(String s) { | |||
textareaLog.append("---------------------\n" + s + "\n"); | |||
buttonResetAlarm.setEnabled(true); | |||
this.tabbedPane.setForegroundAt(2, Color.red); | |||
this.tabbedPane.setIconAt(2, this.icon[FEHLER]); | |||
this.tabbedPane.validate(); | |||
} | |||
public void setSnapchatNumber(int s) { | |||
this.snapchatBildZahl++; | |||
this.labelSnapchat.setText("Snapchat: " + snapchatBildZahl); | |||
} | |||
public void setInstagramNumber(int s) { | |||
this.instagramBildZahl++; | |||
this.labelSnapchat.setText("Instagram: " + instagramBildZahl); | |||
} | |||
public void setFileNumber() { | |||
this.fileBildZahl++; | |||
this.labelSnapchat.setText("File: " + fileBildZahl); | |||
} | |||
public void setBildZahl() { | |||
tabbedPane.setTitleAt(0, " Bildereingang (" + this.bildZahl + ")"); | |||
} | |||
//returns aktuelles Auswahlbild f�r server | |||
public BufferedImage getBild() { | |||
return auswahlbild1.getImage(); | |||
} | |||
public int getNumberOfImages() { | |||
return bildZahl; | |||
} | |||
public void clickAccept() { | |||
ActionEvent click = new ActionEvent(this.buttonAccept, (int) System.currentTimeMillis(), ""); | |||
this.actionAcceptImageActionPerformed(click); | |||
} | |||
public void clickDecline() { | |||
ActionEvent click = new ActionEvent(this.buttonDecline, (int) System.currentTimeMillis(), ""); | |||
this.actionDeclineImageActionPerformed(click); | |||
} | |||
// Variables declaration - do not modify | |||
private JTabbedPane tabbedPane; | |||
private JPanel panelBildereingang; | |||
private JPanel panelDiashow; | |||
private JPanel panelButtons; | |||
private JPanel buttonsEinstellungen; | |||
private JPanel panelSliderEinstellungen; | |||
private JPanel panelThreadsControl; | |||
private JPanel panelSliderBilddauer; | |||
private JPanel panelSliderBildanzahl; | |||
private JPanel panelMonitor; | |||
private JPanel panelLog; | |||
private JPanel panelMonitorInfo; | |||
private JPanel panelLabel; | |||
private JButton buttonAccept; | |||
private JButton buttonDecline; | |||
private JButton buttonNächstesBild; | |||
private JButton buttonRotateLeft; | |||
private JButton buttonRotateRight; | |||
private JButton buttonInstagram; | |||
private JButton buttonSnapchat; | |||
private JButton buttonWhatsappListener; | |||
private JButton buttonFile; | |||
private JButton buttonServer; | |||
private JButton buttonResetAlarm; | |||
private JButton buttonPause; | |||
private AnzeigeAuswahlbild auswahlbild1; | |||
private JLabel labelAnzahlbilder; | |||
private JLabel labelBilddauer; | |||
private JLabel labelPause; | |||
private JLabel labelSnapchat; | |||
private JLabel labelInstagram; | |||
private JLabel labelFile; | |||
private JTextArea textareaLog; | |||
private JSlider sliderAnzahlbilder; | |||
private JSlider sliderBilddauer; | |||
public class MyTabUI extends WindowsTabbedPaneUI { | |||
@Override | |||
protected Insets getTabInsets(int tabPlacement, int tabIndex) { | |||
return new Insets(0, 0, 50, 200); | |||
} | |||
} | |||
} |
@ -0,0 +1,137 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package ffeststeuerungneu; | |||
import java.io.BufferedWriter; | |||
import java.io.File; | |||
import java.io.FileWriter; | |||
import java.io.IOException; | |||
import java.text.SimpleDateFormat; | |||
import java.util.ArrayList; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class Log { | |||
private static List<String> data = new ArrayList(); | |||
private static int snapchat = 0; | |||
private static int instagram = 0; | |||
private static int whatsapp = 0; | |||
private static SimpleDateFormat sdf = new SimpleDateFormat("yy_MM_dd-HH_mm_ss"); | |||
private static String zeile; | |||
private static String pfad = null; | |||
private static Anzeige a; | |||
private static FileWriter fw; | |||
private static BufferedWriter bw; | |||
private static File f; | |||
public static void setProps(String pfadData) { | |||
pfad = pfadData + "\\log\\" + sdf.format(new Date()) + "_log.txt"; | |||
try { | |||
f = new File(pfad); | |||
f.createNewFile(); | |||
fw = new FileWriter(f); | |||
bw = new BufferedWriter(fw); | |||
for (int i = 0; i < data.size(); i++) { | |||
bw.write(data.get(i)); | |||
} | |||
bw.close(); | |||
fw.close(); | |||
} catch (IOException ex) { | |||
Logger.getLogger(Log.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
} | |||
public static void write(String meldung) { | |||
if (pfad != null) { | |||
try { | |||
fw = new FileWriter(f); | |||
bw = new BufferedWriter(fw); | |||
bw.write(meldung); | |||
bw.close(); | |||
fw.close(); | |||
} catch (IOException ex) { | |||
Logger.getLogger(Log.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
} else { | |||
data.add(meldung); | |||
} | |||
} | |||
public static void setAnzeige(Anzeige a) { | |||
Log.a = a; | |||
} | |||
public static void setError(Exception e, String s) { | |||
zeile = sdf.format(new Date()) + " ERROR: " + s + ": " + e; | |||
if (a != null) { | |||
a.setLogData(zeile); | |||
} | |||
} | |||
public static void setDebug(String s) { | |||
zeile = sdf.format(new Date()) + " DEBUG: " + s; | |||
write(zeile); | |||
} | |||
public static void setInfo(String s) { | |||
zeile = sdf.format(new Date()) + " INFO: " + s; | |||
write(zeile); | |||
} | |||
public static void incSnapchat() { | |||
snapchat++; | |||
} | |||
public static void incInstagram() { | |||
instagram++; | |||
} | |||
public static void incWhatsapp() { | |||
whatsapp++; | |||
} | |||
// public static List getData() { | |||
// return data; | |||
// | |||
// } | |||
public static int getSnapchat() { | |||
return snapchat; | |||
} | |||
public static int getInstagram() { | |||
return instagram; | |||
} | |||
public static int getFile() { | |||
return whatsapp; | |||
} | |||
} |
@ -0,0 +1,47 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package ffeststeuerungneu; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
import java.net.URL; | |||
import java.util.Properties; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class Props { | |||
private Properties props; | |||
public Props() { | |||
try { | |||
props = new Properties(); | |||
File f = new File("test.txt"); | |||
f.createNewFile(); | |||
// props.loadFromXML(this.getClass().getResourceAsStream("/resources/properties.xml")); | |||
props.loadFromXML(new FileInputStream("resources/properties.xml")); | |||
} catch (IOException ex) { | |||
Logger.getLogger(Props.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
} | |||
public String getInfo(String key){ | |||
System.out.println(key); | |||
return props.getProperty(key); | |||
} | |||
} |
@ -0,0 +1,77 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package ffeststeuerungneu; | |||
import javax.swing.JFrame; | |||
import javax.swing.UIManager; | |||
import java.awt.Dimension; | |||
import java.awt.Font; | |||
import java.awt.GraphicsDevice; | |||
import java.awt.GraphicsEnvironment; | |||
import java.awt.Rectangle; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
import javax.swing.JLabel; | |||
import javax.swing.UnsupportedLookAndFeelException; | |||
/** | |||
* | |||
* @author Rino | |||
*/ | |||
public class frame extends JFrame { | |||
private Anzeige a; | |||
public frame() { | |||
try { | |||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); | |||
UIManager.put("OptionPane.buttonFont", new Font("Arial", Font.PLAIN, 30)); | |||
UIManager.put("OptionPane.messageFont", new Font("Arial", Font.BOLD, 40)); | |||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { | |||
Logger.getLogger(frame.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
// try { | |||
// UIManager.setLookAndFeel ( "com.alee.laf.WebLookAndFeel" ); | |||
// } catch (UnsupportedLookAndFeelException e) { | |||
// Log.setData(e, "Class: frame. Set LookAndFeel failed"); | |||
// } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { | |||
// Logger.getLogger(frame.class.getName()).log(Level.SEVERE, null, ex); | |||
// } | |||
// try { | |||
// UIManager.setLookAndFeel(new SyntheticaPlainLookAndFeel()); | |||
// } catch (ParseException | UnsupportedLookAndFeelException e) { | |||
// Log.setData(e, "Class: frame. Set LookAndFeel failed"); | |||
// } | |||
initComponents(true); | |||
} | |||
public static void main(String[] args) { | |||
java.awt.EventQueue.invokeLater(() -> { | |||
new frame().setVisible(true); | |||
}); | |||
} | |||
private void initComponents(boolean secondScreen) { | |||
this.setTitle("SelfieGrabber"); | |||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | |||
setPreferredSize(new Dimension(1000, 1000)); | |||
add(a = new Anzeige(this)); | |||
a.setLogAnzeige(); | |||
pack(); | |||
a.revalidate(); | |||
a.repaint(); | |||
a.setVisible(true); | |||
this.pack(); | |||
} | |||
} | |||