├── .github
└── FUNDING.yml
├── .gitlab-ci.yml
├── CHANGELOG.md
├── KeysPerSecond
├── .classpath
├── .gitignore
├── .project
├── .settings
│ ├── org.eclipse.buildship.core.prefs
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.core.runtime.prefs
│ ├── org.eclipse.jdt.core.prefs
│ └── org.sonarlint.eclipse.core.prefs
├── build.gradle
├── exclude.xml
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── kps.ico
├── resources
│ ├── arrow.png
│ ├── checkmark.png
│ ├── graph_lower_left.png
│ ├── graph_lower_middle.png
│ ├── graph_lower_right.png
│ ├── graph_side_left.png
│ ├── graph_side_right.png
│ ├── graph_upper_left.png
│ ├── graph_upper_middle.png
│ ├── graph_upper_right.png
│ ├── kps.png
│ └── kps_small.png
├── settings.gradle
├── sonar-project.properties
├── src
│ └── dev
│ │ └── roanh
│ │ └── kps
│ │ ├── ColorManager.java
│ │ ├── CommandKeys.java
│ │ ├── Key.java
│ │ ├── Listener.java
│ │ ├── Main.java
│ │ ├── Menu.java
│ │ ├── RenderingMode.java
│ │ ├── Statistics.java
│ │ ├── config
│ │ ├── ConfigLoader.java
│ │ ├── ConfigParser.java
│ │ ├── Configuration.java
│ │ ├── GraphType.java
│ │ ├── IndentWriter.java
│ │ ├── ListItemConstructor.java
│ │ ├── PanelType.java
│ │ ├── Setting.java
│ │ ├── SettingGroup.java
│ │ ├── SettingList.java
│ │ ├── ThemeColor.java
│ │ ├── UpdateRate.java
│ │ ├── Version.java
│ │ ├── group
│ │ │ ├── AveragePanelSettings.java
│ │ │ ├── CommandSettings.java
│ │ │ ├── CurrentPanelSettings.java
│ │ │ ├── CursorGraphSettings.java
│ │ │ ├── DataPanelSettings.java
│ │ │ ├── GraphPanelSettings.java
│ │ │ ├── KeyPanelSettings.java
│ │ │ ├── LastPanelSettings.java
│ │ │ ├── LayoutSettings.java
│ │ │ ├── LineGraphSettings.java
│ │ │ ├── LocationSettings.java
│ │ │ ├── MaxPanelSettings.java
│ │ │ ├── PanelSettings.java
│ │ │ ├── PositionSettings.java
│ │ │ ├── SpecialPanelSettings.java
│ │ │ ├── StatsSavingSettings.java
│ │ │ ├── ThemeSettings.java
│ │ │ └── TotalPanelSettings.java
│ │ ├── legacy
│ │ │ ├── LegacyColorProxy.java
│ │ │ ├── LegacyCompatibleKeyConstructor.java
│ │ │ ├── LegacyGraphSetting.java
│ │ │ ├── LegacyPanelShowSetting.java
│ │ │ ├── LegacyPositionProxy.java
│ │ │ ├── LegacyProxyStore.java
│ │ │ └── ProxySetting.java
│ │ └── setting
│ │ │ ├── BooleanSetting.java
│ │ │ ├── ColorSetting.java
│ │ │ ├── CommandKeySetting.java
│ │ │ ├── IntSetting.java
│ │ │ ├── LongSetting.java
│ │ │ ├── PathSetting.java
│ │ │ ├── PrecisionSetting.java
│ │ │ ├── RenderingModeSetting.java
│ │ │ ├── StringSetting.java
│ │ │ └── UpdateRateSetting.java
│ │ ├── event
│ │ ├── EventManager.java
│ │ ├── InputSource.java
│ │ ├── listener
│ │ │ ├── ButtonPressListener.java
│ │ │ ├── ButtonReleaseListener.java
│ │ │ ├── KeyPressListener.java
│ │ │ ├── KeyReleaseListener.java
│ │ │ └── MouseMoveListener.java
│ │ └── source
│ │ │ └── NativeHookInputSource.java
│ │ ├── layout
│ │ ├── GridPanel.java
│ │ ├── Layout.java
│ │ ├── LayoutPosition.java
│ │ └── LayoutValidator.java
│ │ ├── panels
│ │ ├── AvgPanel.java
│ │ ├── BasePanel.java
│ │ ├── CursorGraphPanel.java
│ │ ├── DataPanel.java
│ │ ├── GraphPanel.java
│ │ ├── KeyPanel.java
│ │ ├── LastPanel.java
│ │ ├── LineGraphPanel.java
│ │ ├── MaxPanel.java
│ │ ├── NowPanel.java
│ │ └── TotPanel.java
│ │ └── ui
│ │ ├── component
│ │ ├── ColorPicker.java
│ │ └── TablePanel.java
│ │ ├── dialog
│ │ ├── AboutDialog.java
│ │ ├── ColorDialog.java
│ │ ├── CommandKeysDialog.java
│ │ ├── DefaultConfigDialog.java
│ │ ├── KeysDialog.java
│ │ ├── LayoutDialog.java
│ │ ├── MainDialog.java
│ │ ├── StatsSavingDialog.java
│ │ └── UpdateRateDialog.java
│ │ ├── editor
│ │ ├── AvgPanelEditor.java
│ │ ├── CursorGraphEditor.java
│ │ ├── DataPanelEditor.java
│ │ ├── Editor.java
│ │ ├── EditorProvider.java
│ │ ├── KeyPanelEditor.java
│ │ ├── LastPanelEditor.java
│ │ └── LineGraphEditor.java
│ │ ├── listener
│ │ ├── FieldChangeListener.java
│ │ └── MainWindowListener.java
│ │ └── model
│ │ ├── DynamicInteger.java
│ │ ├── EndNumberModel.java
│ │ ├── FilePathFormatterFactory.java
│ │ ├── MaxNumberModel.java
│ │ ├── SpecialNumberModel.java
│ │ └── SpecialNumberModelEditor.java
└── test
│ ├── config87nodefault.kps
│ ├── config88.kps
│ ├── dev
│ └── roanh
│ │ └── kps
│ │ └── config
│ │ ├── ConfigParserTest.java
│ │ ├── UpdateRateTest.java
│ │ ├── VersionTest.java
│ │ └── setting
│ │ └── ColorSettingTest.java
│ ├── latestnodefault.kps
│ └── legacy.kps
├── LICENSE
└── README.md
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: RoanH
2 | ko_fi: RoanHofland
3 | custom: https://www.paypal.me/RoanHofland
--------------------------------------------------------------------------------
/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | image: openjdk:8
2 |
3 | variables:
4 | SUFFIX: ${CI_PIPELINE_ID}-${CI_COMMIT_REF_NAME}
5 | PROJECTNAME: KeysPerSecond
6 |
7 | before_script:
8 | - java -version
9 | - cd ${PROJECTNAME}
10 | - ls -l
11 | - chmod -R 755 ./*
12 |
13 | stages:
14 | - check
15 | - compile
16 | - test
17 | - status
18 | - javadoc
19 |
20 | endings:
21 | allow_failure: true
22 | script: curl ${SERVER}ci/lf.sh | bash
23 | stage: check
24 |
25 | sonar:
26 | image:
27 | name: sonarsource/sonar-scanner-cli:5.0
28 | entrypoint: [""]
29 | allow_failure: true
30 | script:
31 | - ./gradlew -PrefName=${CI_COMMIT_REF_NAME} -PnexusPublic=${NEXUS_PUBLIC} assemble
32 | - ./gradlew -PrefName=${CI_COMMIT_REF_NAME} -PnexusPublic=${NEXUS_PUBLIC} test jacocoTestReport
33 | - sonar-scanner
34 | stage: check
35 | only:
36 | - master
37 |
38 | spotbugs:
39 | allow_failure: true
40 | script: ./gradlew -PrefName=${CI_COMMIT_REF_NAME} -PnexusPublic=${NEXUS_PUBLIC} spotbugsMain
41 | stage: check
42 | artifacts:
43 | name: SpotBugs-${SUFFIX}
44 | expire_in: 1 day
45 | when: always
46 | paths:
47 | - ./${PROJECTNAME}/build/reports/spotbugs/main/spotbugs.html
48 |
49 | pending:
50 | allow_failure: true
51 | script: curl ${SERVER}ci/pending.sh | bash
52 | stage: compile
53 |
54 | success:
55 | allow_failure: true
56 | script: curl ${SERVER}ci/success.sh | bash
57 | when: on_success
58 | stage: status
59 |
60 | failure:
61 | allow_failure: true
62 | script: curl ${SERVER}ci/failure.sh | bash
63 | when: on_failure
64 | stage: status
65 |
66 | verify:
67 | allow_failure: true
68 | script: curl ${SERVER}ci/javadoc.sh | bash
69 | stage: javadoc
70 | coverage: '/\([0-9]{2,3}\.[0-9]{2}%\)/'
71 |
72 | javadoc:
73 | script:
74 | - ./gradlew -PrefName=${CI_COMMIT_REF_NAME} -PnexusPublic=${NEXUS_PUBLIC} javadoc
75 | - mv ./build/docs/javadoc ../
76 | stage: javadoc
77 | artifacts:
78 | name: Javadoc-${SUFFIX}
79 | expire_in: 1 day
80 | paths:
81 | - javadoc/
82 |
83 | compile:
84 | script:
85 | - ./gradlew -PrefName=${CI_COMMIT_REF_NAME} -PnexusPublic=${NEXUS_PUBLIC} :shadowJar
86 | - ./gradlew -PrefName=${CI_COMMIT_REF_NAME} -PnexusPublic=${NEXUS_PUBLIC} :createExe
87 | - mv ./build/libs/* ..
88 | - mv ./build/launch4j/*.exe ..
89 | stage: compile
90 | artifacts:
91 | name: KeysPerSecond-${SUFFIX}
92 | expire_in: 1 day
93 | paths:
94 | - KeysPerSecond-*.jar
95 | - KeysPerSecond-*.exe
96 |
97 | test:
98 | script:
99 | - ./gradlew -PrefName=${CI_COMMIT_REF_NAME} -PnexusPublic=${NEXUS_PUBLIC} :test :jacocoTestReport
100 | - cat ./build/reports/jacoco/test/html/index.html
101 | stage: test
102 | coverage: '/Total.*?([0-9]{1,3})%/'
103 | artifacts:
104 | reports:
105 | junit: ./${PROJECTNAME}/build/test-results/test/TEST-*.xml
106 |
--------------------------------------------------------------------------------
/KeysPerSecond/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/KeysPerSecond/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore Gradle project-specific cache directory
2 | .gradle
3 |
4 | # Ignore Gradle build output directory
5 | build
6 | /bin/
7 |
--------------------------------------------------------------------------------
/KeysPerSecond/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | KeysPerSecond
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/KeysPerSecond/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | arguments=
2 | auto.sync=false
3 | build.scans.enabled=false
4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5 | connection.project.dir=
6 | eclipse.preferences.version=1
7 | gradle.user.home=
8 | java.home=
9 | jvm.arguments=
10 | offline.mode=false
11 | override.workspace.settings=false
12 | show.console.view=true
13 | show.executions.view=true
14 |
--------------------------------------------------------------------------------
/KeysPerSecond/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/KeysPerSecond/.settings/org.eclipse.core.runtime.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | line.separator=\n
3 |
--------------------------------------------------------------------------------
/KeysPerSecond/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
3 | org.eclipse.jdt.core.compiler.compliance=1.8
4 | org.eclipse.jdt.core.compiler.source=1.8
5 |
--------------------------------------------------------------------------------
/KeysPerSecond/.settings/org.sonarlint.eclipse.core.prefs:
--------------------------------------------------------------------------------
1 | autoEnabled=true
2 | bindingSuggestionsDisabled=true
3 | eclipse.preferences.version=1
4 | projectKey=roan_KeysPerSecond_e60d9328-42c1-47ff-a708-7d7ee7eda435
5 | serverId=sonar.roanh.dev
6 |
--------------------------------------------------------------------------------
/KeysPerSecond/build.gradle:
--------------------------------------------------------------------------------
1 | plugins{
2 | id 'eclipse'
3 | id 'application'
4 | id 'maven-publish'
5 | id 'com.gradleup.shadow' version '8.3.2'
6 | id 'edu.sc.seis.launch4j' version '3.0.5'
7 | id 'com.github.spotbugs' version '6.0.18'
8 | id 'jacoco'
9 | }
10 |
11 | import com.github.spotbugs.snom.Confidence
12 | import com.github.spotbugs.snom.Effort
13 |
14 | sourceSets{
15 | main{
16 | java.srcDirs = ['src']
17 | resources.srcDirs = ['resources']
18 | }
19 |
20 | test{
21 | java.srcDirs = ['test']
22 | resources.srcDirs = ['test']
23 | }
24 | }
25 |
26 | dependencies{
27 | //Util
28 | implementation 'dev.roanh.util:util:2.5'
29 |
30 | //JNativeHook
31 | implementation 'com.github.kwhat:jnativehook:2.2.2'
32 |
33 | //Testing
34 | testImplementation(platform('org.junit:junit-bom:5.11.1'))
35 | testImplementation('org.junit.jupiter:junit-jupiter')
36 | }
37 |
38 | repositories{
39 | //Local cache
40 | if(project.hasProperty("nexusPublic")){
41 | maven{
42 | allowInsecureProtocol = true
43 | url "$nexusPublic"
44 | }
45 | }
46 | mavenCentral()
47 | }
48 |
49 | version = findProperty("refName") ?: 'SNAPSHOT'
50 | if(version.matches("v\\d+\\.\\d+")){
51 | version = version.substring(1)
52 | }
53 |
54 | eclipse.classpath.downloadSources = true
55 | eclipse.classpath.downloadJavadoc = true
56 | compileJava.options.encoding = 'UTF-8'
57 | compileTestJava.options.encoding = 'UTF-8'
58 | jacocoTestReport.reports.xml.required = true
59 | sourceCompatibility = 1.8
60 | javadoc.options.memberLevel = JavadocMemberLevel.PRIVATE
61 | group = 'dev.roanh.kps'
62 | ext.artifact = 'keyspersecond'
63 | shadowJar.archiveBaseName = 'KeysPerSecond'
64 | shadowJar.archiveVersion = 'v' + version
65 | shadowJar.archiveClassifier = ''
66 | application.mainClass = 'dev.roanh.kps.Main'
67 |
68 | test{
69 | useJUnitPlatform()
70 | dependsOn 'cleanTest'
71 |
72 | testLogging{
73 | events "passed", "skipped", "failed"
74 | }
75 | }
76 |
77 | spotbugs{
78 | showProgress = true
79 | effort = Effort.valueOf('MAX')
80 | reportLevel = Confidence.valueOf('LOW')
81 | excludeFilter = file("$rootDir/exclude.xml")
82 | }
83 |
84 | tasks.withType(com.github.spotbugs.snom.SpotBugsTask){
85 | reports{
86 | html{
87 | required = true
88 | outputLocation = file("$buildDir/reports/spotbugs/main/spotbugs.html")
89 | stylesheet = 'fancy-hist.xsl'
90 | }
91 | }
92 | }
93 |
94 | publishing{
95 | publications{
96 | mavenJava(MavenPublication){
97 | from components.java
98 | artifactId = project.artifact
99 |
100 | pom{
101 | name = project.eclipse.project.name
102 | description = 'Program to measure the keys pressed per second'
103 | url = 'https://github.com/RoanH/KeysPerSecond'
104 | licenses{
105 | license{
106 | name = 'GNU General Public License v3.0'
107 | url = 'https://www.gnu.org/licenses/gpl-3.0.txt'
108 | }
109 | }
110 | developers{
111 | developer{
112 | id = 'RoanH'
113 | name = 'Roan Hofland'
114 | email = 'roan@roanh.dev'
115 | }
116 | }
117 | scm{
118 | connection = 'scm:git:git@github.com:RoanH/KeysPerSecond.git'
119 | developerConnection = 'scm:git:git@git.roanh.dev:roan/KeysPerSecond.git'
120 | url = 'https://github.com/RoanH/KeysPerSecond'
121 | }
122 | }
123 | }
124 | }
125 | }
126 |
127 | shadowJar{
128 | mergeServiceFiles()
129 | into("META-INF/maven/$project.group/$project.artifact"){
130 | from{
131 | generatePomFileForMavenJavaPublication
132 | }
133 | rename ".*", "pom.xml"
134 | }
135 | }
136 |
137 | launch4j{
138 | jarTask = project.tasks.shadowJar
139 | mainClassName = application.mainClass
140 | icon = "${projectDir}/kps.ico"
141 | jreMinVersion = project.sourceCompatibility.toString()
142 | bundledJrePath = "%JAVA_HOME%"
143 | outfile = 'KeysPerSecond-v' + project.version + '.exe'
144 | fileDescription = "KeysPerSecond"
145 | productName = rootProject.name
146 | version = project.version
147 | textVersion = project.version
148 | copyright = "Roan Hofland"
149 | }
150 |
--------------------------------------------------------------------------------
/KeysPerSecond/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/KeysPerSecond/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/KeysPerSecond/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/KeysPerSecond/kps.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/kps.ico
--------------------------------------------------------------------------------
/KeysPerSecond/resources/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/arrow.png
--------------------------------------------------------------------------------
/KeysPerSecond/resources/checkmark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/checkmark.png
--------------------------------------------------------------------------------
/KeysPerSecond/resources/graph_lower_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/graph_lower_left.png
--------------------------------------------------------------------------------
/KeysPerSecond/resources/graph_lower_middle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/graph_lower_middle.png
--------------------------------------------------------------------------------
/KeysPerSecond/resources/graph_lower_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/graph_lower_right.png
--------------------------------------------------------------------------------
/KeysPerSecond/resources/graph_side_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/graph_side_left.png
--------------------------------------------------------------------------------
/KeysPerSecond/resources/graph_side_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/graph_side_right.png
--------------------------------------------------------------------------------
/KeysPerSecond/resources/graph_upper_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/graph_upper_left.png
--------------------------------------------------------------------------------
/KeysPerSecond/resources/graph_upper_middle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/graph_upper_middle.png
--------------------------------------------------------------------------------
/KeysPerSecond/resources/graph_upper_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/graph_upper_right.png
--------------------------------------------------------------------------------
/KeysPerSecond/resources/kps.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/kps.png
--------------------------------------------------------------------------------
/KeysPerSecond/resources/kps_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoanH/KeysPerSecond/57e60b272a269c0473089efe32ebe1465e6d8682/KeysPerSecond/resources/kps_small.png
--------------------------------------------------------------------------------
/KeysPerSecond/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement{
2 | repositories{
3 | //Local cache
4 | if(settings.ext.find("nexusPublic") != null){
5 | maven{
6 | allowInsecureProtocol = true
7 | url "$nexusPublic"
8 | }
9 | }
10 | gradlePluginPortal()
11 | mavenCentral()
12 | }
13 | }
14 |
15 | rootProject.name = 'KeysPerSecond'
16 |
--------------------------------------------------------------------------------
/KeysPerSecond/sonar-project.properties:
--------------------------------------------------------------------------------
1 | sonar.projectName=KeysPerSecond
2 | sonar.projectKey=roan_KeysPerSecond_e60d9328-42c1-47ff-a708-7d7ee7eda435
3 | sonar.java.binaries=build/classes
4 | sonar.sources=src,resources
5 | sonar.tests=test
6 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/GraphType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.function.Supplier;
24 |
25 | import dev.roanh.kps.config.ListItemConstructor.ParsedItem;
26 | import dev.roanh.kps.config.group.CursorGraphSettings;
27 | import dev.roanh.kps.config.group.GraphPanelSettings;
28 | import dev.roanh.kps.config.group.LineGraphSettings;
29 |
30 | /**
31 | * Enum of graph types that exist.
32 | * @author Roan
33 | * @see GraphPanelSettings
34 | */
35 | public enum GraphType{
36 | /**
37 | * Line graph showing the average and current KPS.
38 | */
39 | LINE("line", LineGraphSettings::new),
40 | /**
41 | * Cursor graph showing the cursor trail.
42 | */
43 | CURSOR("cursor", CursorGraphSettings::new);
44 |
45 | /**
46 | * The graph type identifier.
47 | */
48 | private final String key;
49 | /**
50 | * A constructor to create a new configuration for a graph panel.
51 | */
52 | private final Supplier ctor;
53 |
54 | /**
55 | * Constructs a new graph type.
56 | * @param key The graph type identifier.
57 | * @param ctor A supplier of new graph settings.
58 | */
59 | private GraphType(String key, Supplier ctor){
60 | this.key = key;
61 | this.ctor = ctor;
62 | }
63 |
64 | /**
65 | * Creates new settings for this graph type.
66 | * @return The newly created settings.
67 | */
68 | public GraphPanelSettings newSettings(){
69 | return ctor.get();
70 | }
71 |
72 | /**
73 | * Gets the identifier key for this graph type.
74 | * @return The identifier for this graph type.
75 | */
76 | public String getKey(){
77 | return key;
78 | }
79 |
80 | /**
81 | * Constructs new panel settings based on the given list of configuration data.
82 | * @param data The panel configuration data.
83 | * @return The parsed panel settings or null if the data
84 | * did not encoded valid panel settings.
85 | * @see ListItemConstructor
86 | */
87 | public static ParsedItem construct(List data){
88 | Map info = ListItemConstructor.buildMap(data);
89 | if(info == null){
90 | return null;
91 | }
92 |
93 | String key = info.get("type");
94 | for(GraphType type : values()){
95 | if(type.key.equals(key)){
96 | return ListItemConstructor.constructThenParse(type.ctor, info);
97 | }
98 | }
99 |
100 | //for legacy reasons the fallback type is the line graph
101 | return ListItemConstructor.constructThenParse(LINE.ctor, info);
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/IndentWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config;
20 |
21 | import java.io.PrintWriter;
22 |
23 | /**
24 | * Utility class used to write config files.
25 | * @author Roan
26 | */
27 | public class IndentWriter{
28 | /**
29 | * The writer to write output to.
30 | */
31 | private PrintWriter writer;
32 | /**
33 | * The current indent of the writer in spaces.
34 | */
35 | private int indent;
36 | /**
37 | * True if the next println action writes the
38 | * start of a new list item.
39 | */
40 | private boolean nextIsListItem = false;
41 |
42 | /**
43 | * Constructs a new indent writer with the
44 | * given writer to forward writes to.
45 | * @param writer The underlying writer to output to.
46 | */
47 | public IndentWriter(PrintWriter writer){
48 | this.writer = writer;
49 | }
50 |
51 | /**
52 | * Starts a new list item.
53 | * @see #endListItem()
54 | */
55 | public void startListItem(){
56 | indent += 4;
57 | nextIsListItem = true;
58 | }
59 |
60 | /**
61 | * Ends the current list.
62 | * @see #startListItem()
63 | */
64 | public void endListItem(){
65 | indent -= 4;
66 | nextIsListItem = false;
67 | }
68 |
69 | /**
70 | * Increase the indent of the writer.
71 | * @see #decreaseIndent()
72 | */
73 | public void increaseIndent(){
74 | indent += 2;
75 | }
76 |
77 | /**
78 | * Decreases the indent of the writer.
79 | * @see #increaseIndent()
80 | */
81 | public void decreaseIndent(){
82 | indent -= 2;
83 | }
84 |
85 | /**
86 | * Prints an empty line.
87 | */
88 | public void println(){
89 | writer.print('\n');
90 | writer.flush();
91 | }
92 |
93 | /**
94 | * Prints a new line to the configuration subject
95 | * to the current indent and list settings.
96 | * @param val The value to write.
97 | */
98 | public void println(String val){
99 | for(int i = 0; i < (nextIsListItem ? (indent - 2) : indent); i++){
100 | writer.print(' ');
101 | }
102 |
103 | if(nextIsListItem){
104 | writer.print("- ");
105 | nextIsListItem = false;
106 | }
107 |
108 | writer.print(val);
109 | println();
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/PanelType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.function.Supplier;
24 |
25 | import dev.roanh.kps.config.ListItemConstructor.ParsedItem;
26 | import dev.roanh.kps.config.group.AveragePanelSettings;
27 | import dev.roanh.kps.config.group.CurrentPanelSettings;
28 | import dev.roanh.kps.config.group.LastPanelSettings;
29 | import dev.roanh.kps.config.group.MaxPanelSettings;
30 | import dev.roanh.kps.config.group.SpecialPanelSettings;
31 | import dev.roanh.kps.config.group.TotalPanelSettings;
32 |
33 | /**
34 | * Enum of special panel types that exist.
35 | * @author Roan
36 | * @see SpecialPanelSettings
37 | */
38 | public enum PanelType{
39 | /**
40 | * Maximum panel that shows the highest recorded KPS.
41 | */
42 | MAX("max", MaxPanelSettings::new),
43 | /**
44 | * Average panel that shows the average KPS.
45 | */
46 | AVG("avg", AveragePanelSettings::new),
47 | /**
48 | * Current panel that shows the current KPS.
49 | */
50 | CURRENT("current", CurrentPanelSettings::new),
51 | /**
52 | * Total panel that shows the total number of hits.
53 | */
54 | TOTAL("total", TotalPanelSettings::new),
55 | /**
56 | * Last panel that shows the time since the last tracked input.
57 | */
58 | LAST("last", LastPanelSettings::new);
59 |
60 | /**
61 | * The panel type identifier.
62 | */
63 | private final String key;
64 | /**
65 | * A constructor to create a new configuration for a panel type.
66 | */
67 | private final Supplier ctor;
68 |
69 | /**
70 | * Constructs a new panel type.
71 | * @param key The panel type identifier.
72 | * @param ctor A supplier of new panel settings.
73 | */
74 | private PanelType(String key, Supplier ctor){
75 | this.key = key;
76 | this.ctor = ctor;
77 | }
78 |
79 | /**
80 | * Creates new settings for this panel type.
81 | * @return The newly created settings.
82 | */
83 | public SpecialPanelSettings newSettings(){
84 | return ctor.get();
85 | }
86 |
87 | /**
88 | * Gets the identifier key for this panel type.
89 | * @return The identifier for this panel type.
90 | */
91 | public String getKey(){
92 | return key;
93 | }
94 |
95 | /**
96 | * Constructs new panel settings based on the given list of configuration data.
97 | * @param data The panel configuration data.
98 | * @return The parsed panel settings or null if the data
99 | * did not encoded valid panel settings.
100 | * @see ListItemConstructor
101 | */
102 | public static ParsedItem construct(List data){
103 | Map info = ListItemConstructor.buildMap(data);
104 | if(info == null){
105 | return null;
106 | }
107 |
108 | String key = info.get("type");
109 | for(PanelType type : values()){
110 | if(type.key.equals(key)){
111 | return ListItemConstructor.constructThenParse(type.ctor, info);
112 | }
113 | }
114 |
115 | return null;
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/Setting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config;
20 |
21 | import java.io.PrintWriter;
22 | import java.io.StringWriter;
23 |
24 | /**
25 | * Abstract base class for automatically validating settings.
26 | * @author Roan
27 | * @param The data type for this setting.
28 | */
29 | public abstract class Setting{
30 | /**
31 | * The configuration file key identifying this setting.
32 | */
33 | protected final String key;
34 | /**
35 | * The current value for this setting.
36 | */
37 | protected T value;
38 | /**
39 | * The default value for this setting.
40 | */
41 | private T defaultValue;
42 |
43 | /**
44 | * Constructs a new setting with the given identifier and default value.
45 | * @param key The identifier for this setting.
46 | * @param defaultValue The default value for this setting.
47 | */
48 | protected Setting(String key, T defaultValue){
49 | this.key = key;
50 | this.defaultValue = defaultValue;
51 | update(defaultValue);
52 | }
53 |
54 | /**
55 | * Parses this setting from the given string data. This function will either
56 | * call {@link #update(Object)} to set the parsed setting or {@link #reset()}
57 | * to signal that the setting could not be parsed from the given data.
58 | * @param data The data to attempt to parse.
59 | * @return True if the data could not be parsed, meaning the default value was used.
60 | */
61 | public abstract boolean parse(String data);
62 |
63 | /**
64 | * Writes this setting to the given writer.
65 | * @param out The writer to write to.
66 | */
67 | public abstract void write(IndentWriter out);
68 |
69 | /**
70 | * Gets the key identifier for this setting.
71 | * @return The key identifier for this setting.
72 | */
73 | public String getKey(){
74 | return key;
75 | }
76 |
77 | /**
78 | * Updates this setting with a new value. Note
79 | * that this method does not validate values.
80 | * @param newValue The new value to set.
81 | */
82 | public void update(T newValue){
83 | value = newValue;
84 | }
85 |
86 | /**
87 | * Resets this setting to its default value.
88 | */
89 | public void reset(){
90 | value = defaultValue;
91 | }
92 |
93 | /**
94 | * Gets the current value for this setting.
95 | * @return The current value for this setting.
96 | */
97 | public T getValue(){
98 | return value;
99 | }
100 |
101 | /**
102 | * Gets the default value for this setting.
103 | * @return The default value for this setting.
104 | */
105 | public T getDefaultValue(){
106 | return defaultValue;
107 | }
108 |
109 | @Override
110 | public String toString(){
111 | StringWriter writer = new StringWriter();
112 | write(new IndentWriter(new PrintWriter(writer)));
113 | return "Setting[" + writer.toString().replace('\n', ']');
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/SettingGroup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config;
20 |
21 | import java.util.Map;
22 |
23 | /**
24 | * Group of regular settings that can be handled as a single unit.
25 | * @author Roan
26 | */
27 | public abstract class SettingGroup{
28 | /**
29 | * The key identifier for this group.
30 | */
31 | private final String key;
32 |
33 | /**
34 | * Constructs a new settings group with the given identifier.
35 | * @param key The
36 | */
37 | public SettingGroup(String key){
38 | this.key = key;
39 | }
40 |
41 | /**
42 | * Gets the identifier key for this group.
43 | * @return The identifier for this group.
44 | */
45 | public String getKey(){
46 | return key;
47 | }
48 |
49 | /**
50 | * Parses all the settings under this group.
51 | * @param data The setting data.
52 | * @return True if default values were used during the parsing process.
53 | * @see #findAndParse(Map, Setting...)
54 | * @see Setting#parse(String)
55 | */
56 | public abstract boolean parse(Map data);
57 |
58 | /**
59 | * Writes all the individual settings that are contained in this group.
60 | * @param out The writer to write to.
61 | */
62 | public abstract void writeItems(IndentWriter out);
63 |
64 | /**
65 | * Writes this entire settings group.
66 | * @param out The writer to write.
67 | */
68 | public final void write(IndentWriter out){
69 | out.println(key + ":");
70 | out.increaseIndent();
71 | writeItems(out);
72 | out.decreaseIndent();
73 | }
74 |
75 | /**
76 | * Resolves the given settings by their key from the given map of
77 | * data and attempts to parse the provided data for each setting.
78 | * @param data The key-value setting data.
79 | * @param settings The settings to resolve and parse.
80 | * @return True if default values were used during the parsing process.
81 | * @see Setting#parse(String)
82 | */
83 | protected boolean findAndParse(Map data, Setting>... settings){
84 | boolean modified = false;
85 | for(Setting> setting : settings){
86 | String val = data.get(setting.getKey());
87 | if(val == null){
88 | setting.reset();
89 | modified = true;
90 | }else{
91 | modified |= setting.parse(val);
92 | }
93 | }
94 | return modified;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/ThemeColor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config;
20 |
21 | import java.awt.Color;
22 | import java.util.Locale;
23 | import java.util.Objects;
24 |
25 | /**
26 | * Class representing a theme color.
27 | * @author Roan
28 | */
29 | public class ThemeColor{
30 | /**
31 | * The RBG component of this color.
32 | */
33 | private final Color color;
34 | /**
35 | * The alpha component of this color.
36 | */
37 | private final float alpha;
38 |
39 | /**
40 | * Constructs a new theme color.
41 | * @param rgb The RGB component of this color.
42 | * @param alpha The alpha component of this color (0 - 255).
43 | */
44 | public ThemeColor(int rgb, int alpha){
45 | this(rgb, alpha / 255.0F);
46 | }
47 |
48 | /**
49 | * Constructs a new theme color.
50 | * @param rgb The RGB component of this color.
51 | * @param alpha The alpha component of this color (0 - 1).
52 | */
53 | public ThemeColor(int rgb, float alpha){
54 | color = new Color(rgb);
55 | this.alpha = alpha;
56 | }
57 |
58 | /**
59 | * Constructs a new theme color.
60 | * @param r The red component of this color (0 - 255).
61 | * @param g The green component of this color (0 - 255).
62 | * @param b The blue component of this color (0 - 255).
63 | * @param alpha The alpha component of this color (0 - 255).
64 | */
65 | public ThemeColor(int r, int g, int b, int alpha){
66 | this(r, g, b, alpha / 255.0F);
67 | }
68 |
69 | /**
70 | * Constructs a new theme color.
71 | * @param r The red component of this color (0 - 255).
72 | * @param g The green component of this color (0 - 255).
73 | * @param b The blue component of this color (0 - 255).
74 | * @param alpha The alpha component of this color (0 - 1).
75 | */
76 | public ThemeColor(int r, int g, int b, float alpha){
77 | color = new Color(r, g, b);
78 | this.alpha = alpha;
79 | }
80 |
81 | /**
82 | * Gets the RGB component of this color.
83 | * @return The RGB component of this color.
84 | */
85 | public Color getColor(){
86 | return color;
87 | }
88 |
89 | /**
90 | * Gets the alpha component of this color
91 | * @return The alpha component of this color.
92 | */
93 | public float getAlpha(){
94 | return alpha;
95 | }
96 |
97 | /**
98 | * Gets the RGB component of this color.
99 | * @return The RGB component of this color.
100 | */
101 | public int getRGB(){
102 | return color.getRGB() & 0xFFFFFF;
103 | }
104 |
105 | /**
106 | * Converts this color to a HEX string in the format
107 | * RRGGBBAA, where the alpha part will be omitted if
108 | * the alpha value is equal to 255 (max opacity).
109 | * @return A HEX string for this color.
110 | */
111 | public String toHex(){
112 | int alpha = Math.round(this.alpha * 255.0F);
113 | String rgb = String.format("%6s", Integer.toHexString(getRGB())).replace(' ', '0').toUpperCase(Locale.ROOT);
114 |
115 | if(alpha == 0xFF){
116 | return rgb;
117 | }else if(alpha < 16){
118 | return rgb + "0" + Integer.toHexString(alpha).toUpperCase(Locale.ROOT);
119 | }else{
120 | return rgb + Integer.toHexString(alpha).toUpperCase(Locale.ROOT);
121 | }
122 | }
123 |
124 | @Override
125 | public boolean equals(Object obj){
126 | if(obj instanceof ThemeColor){
127 | ThemeColor other = (ThemeColor)obj;
128 | return other.color.equals(color) && Float.compare(alpha, other.alpha) == 0;
129 | }else{
130 | return false;
131 | }
132 | }
133 |
134 | @Override
135 | public int hashCode(){
136 | return Objects.hash(color, alpha);
137 | }
138 |
139 | @Override
140 | public String toString(){
141 | return "#" + toHex();
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/UpdateRate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config;
20 |
21 | /**
22 | * Enum of valid update rates for the program. These
23 | * values are all positive and a clean divisors of 1000.
24 | * The update rate only affects constantly updating components
25 | * such as statistic panels and graphs.
26 | * @author Roan
27 | */
28 | public enum UpdateRate{
29 | /**
30 | * Update rate of 1000 milliseconds.
31 | */
32 | MS_1000(1000),
33 | /**
34 | * Update rate of 500 milliseconds.
35 | */
36 | MS_500(500),
37 | /**
38 | * Update rate of 250 milliseconds.
39 | */
40 | MS_250(250),
41 | /**
42 | * Update rate of 200 milliseconds.
43 | */
44 | MS_200(200),
45 | /**
46 | * Update rate of 125 milliseconds.
47 | */
48 | MS_125(125),
49 | /**
50 | * Update rate of 100 milliseconds.
51 | */
52 | MS_100(100),
53 | /**
54 | * Update rate of 50 milliseconds.
55 | */
56 | MS_50(50),
57 | /**
58 | * Update rate of 25 milliseconds.
59 | */
60 | MS_25(25),
61 | /**
62 | * Update rate of 20 milliseconds.
63 | */
64 | MS_20(20),
65 | /**
66 | * Update rate of 10 milliseconds.
67 | */
68 | MS_10(10),
69 | /**
70 | * Update rate of 5 milliseconds.
71 | */
72 | MS_5(5),
73 | /**
74 | * Update rate of 1 millisecond.
75 | */
76 | MS_1(1);
77 |
78 | /**
79 | * The update rate in milliseconds.
80 | */
81 | private final int ms;
82 |
83 | /**
84 | * Constructs a new update rate with the given update
85 | * rate time frame in milliseconds.
86 | * @param ms The update rate in milliseconds, has to
87 | * be a positive clean divisor of 1000.
88 | */
89 | private UpdateRate(int ms){
90 | this.ms = ms;
91 | }
92 |
93 | /**
94 | * Gets the update rate in milliseconds.
95 | * @return The update rate in milliseconds.
96 | */
97 | public int getRate(){
98 | return ms;
99 | }
100 |
101 | /**
102 | * Checks if this update is considered high, this
103 | * classification applies to update rates below 100ms.
104 | * @return True if this update rate is high.
105 | */
106 | public boolean isHigh(){
107 | return ms < 100;
108 | }
109 |
110 | /**
111 | * Checks if this update is considered very high, this
112 | * classification applies to update rates below 10ms.
113 | * Update rates this low are likely to cause performance issues.
114 | * @return True if this update rate is very high.
115 | */
116 | public boolean isVeryHigh(){
117 | return ms < 10;
118 | }
119 |
120 | @Override
121 | public String toString(){
122 | return ms + "ms";
123 | }
124 |
125 | /**
126 | * Resolves an update rate from its millisecond rate.
127 | * @param ms The update rate in milliseconds.
128 | * @return The update rate instance.
129 | * @throws IllegalArgumentException When the given rate
130 | * does not correspond to a valid update rate.
131 | */
132 | public static UpdateRate fromMs(int ms) throws IllegalArgumentException{
133 | for(UpdateRate rate : values()){
134 | if(rate.ms == ms){
135 | return rate;
136 | }
137 | }
138 |
139 | throw new IllegalArgumentException("Invalid update rate.");
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/group/AveragePanelSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.group;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | import dev.roanh.kps.config.IndentWriter;
25 | import dev.roanh.kps.config.PanelType;
26 | import dev.roanh.kps.config.Setting;
27 | import dev.roanh.kps.config.legacy.LegacyProxyStore;
28 | import dev.roanh.kps.config.legacy.ProxySetting;
29 | import dev.roanh.kps.config.setting.PrecisionSetting;
30 | import dev.roanh.kps.panels.AvgPanel;
31 | import dev.roanh.kps.ui.editor.AvgPanelEditor;
32 | import dev.roanh.kps.ui.editor.Editor;
33 |
34 | /**
35 | * Configuration for the average panel.
36 | * @author Roan
37 | * @see AvgPanel
38 | */
39 | public class AveragePanelSettings extends SpecialPanelSettings implements LegacyProxyStore{
40 | /**
41 | * Setting for the display precision of the panel (decimal digits).
42 | */
43 | private final PrecisionSetting precision = new PrecisionSetting("precision", 0, 3, 0);
44 |
45 | /**
46 | * Constructs new average panel settings.
47 | */
48 | public AveragePanelSettings(){
49 | super(PanelType.AVG, "AVG");
50 | }
51 |
52 | /**
53 | * Sets the precision for the panel.
54 | * @param value The number of decimal digits to display.
55 | */
56 | public void setPrecision(int value){
57 | precision.update(value);
58 | }
59 |
60 | /**
61 | * Gets the precision for the panel.
62 | * @return The number of decimal digits to display.
63 | */
64 | public int getPrecision(){
65 | return precision.getValue();
66 | }
67 |
68 | /**
69 | * Formats the given number according to the precision
70 | * configured for this average panel.
71 | * @param value The value to format.
72 | * @return The formatted value.
73 | */
74 | public String formatAvg(double value){
75 | return precision.format(value);
76 | }
77 |
78 | @Override
79 | public AvgPanel createPanel(){
80 | return new AvgPanel(this);
81 | }
82 |
83 | @Override
84 | public boolean parse(Map data){
85 | return super.parse(data) | findAndParse(data, precision);
86 | }
87 |
88 | @Override
89 | public void writeItems(IndentWriter out){
90 | super.writeItems(out);
91 | precision.write(out);
92 | }
93 |
94 | @Override
95 | public void showEditor(boolean live){
96 | Editor.showEditor(new AvgPanelEditor(this, live));
97 | }
98 |
99 | @Override
100 | public void collectLegacyProxies(List> proxyList){
101 | proxyList.add(ProxySetting.of("avgX", x));
102 | proxyList.add(ProxySetting.of("avgY", y));
103 | proxyList.add(ProxySetting.of("avgWidth", width));
104 | proxyList.add(ProxySetting.of("avgHeight", height));
105 | proxyList.add(ProxySetting.of("avgMode", mode));
106 | proxyList.add(ProxySetting.of("precision", precision));
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/group/CurrentPanelSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.group;
20 |
21 | import java.util.List;
22 |
23 | import dev.roanh.kps.config.PanelType;
24 | import dev.roanh.kps.config.Setting;
25 | import dev.roanh.kps.config.legacy.LegacyProxyStore;
26 | import dev.roanh.kps.config.legacy.ProxySetting;
27 | import dev.roanh.kps.panels.NowPanel;
28 | import dev.roanh.kps.ui.editor.DataPanelEditor;
29 | import dev.roanh.kps.ui.editor.Editor;
30 |
31 | /**
32 | * Configuration for a current KPS panel.
33 | * @author Roan
34 | * @see NowPanel
35 | */
36 | public class CurrentPanelSettings extends SpecialPanelSettings implements LegacyProxyStore{
37 |
38 | /**
39 | * Constructs new current KPS panel settings.
40 | */
41 | public CurrentPanelSettings(){
42 | super(PanelType.CURRENT, "KPS");
43 | }
44 |
45 | @Override
46 | public NowPanel createPanel(){
47 | return new NowPanel(this);
48 | }
49 |
50 | @Override
51 | public void showEditor(boolean live){
52 | Editor.showEditor(new DataPanelEditor(this, live));
53 | }
54 |
55 | @Override
56 | public void collectLegacyProxies(List> proxyList){
57 | proxyList.add(ProxySetting.of("curX", x));
58 | proxyList.add(ProxySetting.of("curY", y));
59 | proxyList.add(ProxySetting.of("curWidth", width));
60 | proxyList.add(ProxySetting.of("curHeight", height));
61 | proxyList.add(ProxySetting.of("curMode", mode));
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/group/DataPanelSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.group;
20 |
21 | import java.util.Map;
22 |
23 | import dev.roanh.kps.RenderingMode;
24 | import dev.roanh.kps.config.IndentWriter;
25 | import dev.roanh.kps.config.setting.RenderingModeSetting;
26 |
27 | /**
28 | * Settings for a named value display panel.
29 | * @author Roan
30 | */
31 | public abstract class DataPanelSettings extends PanelSettings{
32 | /**
33 | * The rendering mode used the panel.
34 | */
35 | protected final RenderingModeSetting mode = new RenderingModeSetting("mode", RenderingMode.VERTICAL);
36 |
37 | /**
38 | * Constructs new panel settings.
39 | * @param key The settings group key.
40 | * @param x The x position of the panel.
41 | * @param y The y position of the panel.
42 | * @param width The width of the panel.
43 | * @param height The height of the panel.
44 | * @param defaultName The display name of the panel.
45 | */
46 | protected DataPanelSettings(String key, int x, int y, int width, int height, String defaultName){
47 | super(key, x, y, width, height, defaultName);
48 | }
49 |
50 | /**
51 | * Constructs a new panel with default dimensions.
52 | * @param key The settings group key.
53 | * @param defaultName The display name of the panel.
54 | */
55 | protected DataPanelSettings(String key, String defaultName){
56 | super(key, defaultName);
57 | }
58 |
59 | /**
60 | * Gets the rendering mode for this panel.
61 | * @return The rendering mode for this panel.
62 | * @see RenderingMode
63 | */
64 | public RenderingMode getRenderingMode(){
65 | return mode.getValue();
66 | }
67 |
68 | /**
69 | * Sets the rendering mode for the panel.
70 | * @param mode The new rendering mode.
71 | */
72 | public void setRenderingMode(RenderingMode mode){
73 | this.mode.update(mode);
74 | }
75 |
76 | @Override
77 | public boolean parse(Map data){
78 | return super.parse(data) | findAndParse(data, mode);
79 | }
80 |
81 | @Override
82 | public void writeItems(IndentWriter out){
83 | super.writeItems(out);
84 | mode.write(out);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/group/GraphPanelSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.group;
20 |
21 | import dev.roanh.kps.config.GraphType;
22 | import dev.roanh.kps.config.IndentWriter;
23 | import dev.roanh.kps.panels.GraphPanel;
24 |
25 | /**
26 | * Settings for graph panels.
27 | * @author Roan
28 | * @see GraphType
29 | */
30 | public abstract class GraphPanelSettings extends PanelSettings{
31 | /**
32 | * The type of this graph.
33 | */
34 | private final GraphType type;
35 |
36 | /**
37 | * Constructs new graph panel settings.
38 | * @param type The type of the graph panel.
39 | * @param x The x position of the panel.
40 | * @param y The y position of the panel.
41 | * @param width The width of the panel.
42 | * @param height The height of the panel.
43 | * @param defaultName The display name of the panel.
44 | */
45 | protected GraphPanelSettings(GraphType type, int x, int y, int width, int height, String defaultName){
46 | super("graphs", x, y, width, height, defaultName);
47 | this.type = type;
48 | }
49 |
50 | /**
51 | * Creates a new graph panel with this configuration.
52 | * @return The newly created graph panel.
53 | */
54 | public abstract GraphPanel createGraph();
55 |
56 | @Override
57 | public void writeItems(IndentWriter out){
58 | out.println("type: " + type.getKey());
59 | super.writeItems(out);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/group/LastPanelSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.group;
20 |
21 | import java.util.Map;
22 |
23 | import dev.roanh.kps.config.IndentWriter;
24 | import dev.roanh.kps.config.PanelType;
25 | import dev.roanh.kps.config.setting.BooleanSetting;
26 | import dev.roanh.kps.config.setting.IntSetting;
27 | import dev.roanh.kps.panels.LastPanel;
28 | import dev.roanh.kps.ui.editor.Editor;
29 | import dev.roanh.kps.ui.editor.LastPanelEditor;
30 |
31 | /**
32 | * Settings for a panel showing the time since the last input.
33 | * @author Roan
34 | * @see LastPanel
35 | */
36 | public class LastPanelSettings extends SpecialPanelSettings{
37 | /**
38 | * Maximum number of time units to show at the same time.
39 | * E.g., two units could mean showing '5m 26s'.
40 | */
41 | private final IntSetting units = new IntSetting("units", 1, 4, 1);
42 | /**
43 | * Whether milliseconds are considered as a valid unit to show or not.
44 | * If false milliseconds are never shown.
45 | */
46 | private final BooleanSetting millis = new BooleanSetting("showMillis", false);
47 |
48 | /**
49 | * Constructs new last panel settings.
50 | */
51 | public LastPanelSettings(){
52 | super(PanelType.LAST, "LST");
53 | }
54 |
55 | /**
56 | * True if millisecond may be shown as a value for this panel.
57 | * @return True if milliseconds are considered a valid unit.
58 | */
59 | public boolean showMillis(){
60 | return millis.getValue();
61 | }
62 |
63 | /**
64 | * Gets the maximum number of time units to string
65 | * together to form the time string.
66 | * @return The maximum time unit count.
67 | */
68 | public int getUnitCount(){
69 | return units.getValue();
70 | }
71 |
72 | /**
73 | * Sets the maximum number of time units allowed to be used.
74 | * @param units The maximum number of time units.
75 | */
76 | public void setUnitCount(int units){
77 | this.units.update(units);
78 | }
79 |
80 | /**
81 | * Sets whether millisecond resolution is allowed as a valid panel value.
82 | * @param shown True if milliseconds are allowed to be shown.
83 | */
84 | public void setShowMillis(boolean shown){
85 | millis.update(shown);
86 | }
87 |
88 | @Override
89 | public boolean parse(Map data){
90 | return super.parse(data) | findAndParse(data, units, millis);
91 | }
92 |
93 | @Override
94 | public void writeItems(IndentWriter out){
95 | super.writeItems(out);
96 | units.write(out);
97 | millis.write(out);
98 | }
99 |
100 | @Override
101 | public void showEditor(boolean live){
102 | Editor.showEditor(new LastPanelEditor(this, live));
103 | }
104 |
105 | @Override
106 | public LastPanel createPanel(){
107 | return new LastPanel(this);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/group/LayoutSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.group;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | import dev.roanh.kps.config.IndentWriter;
25 | import dev.roanh.kps.config.Setting;
26 | import dev.roanh.kps.config.SettingGroup;
27 | import dev.roanh.kps.config.legacy.LegacyProxyStore;
28 | import dev.roanh.kps.config.legacy.ProxySetting;
29 | import dev.roanh.kps.config.setting.IntSetting;
30 | import dev.roanh.kps.panels.BasePanel;
31 |
32 | /**
33 | * Settings group with all general layout related settings.
34 | * @author Roan
35 | */
36 | public class LayoutSettings extends SettingGroup implements LegacyProxyStore{
37 | /**
38 | * The offset from the border of a panel to the actual panel content.
39 | */
40 | private final IntSetting borderOffset = new IntSetting("borderOffset", 0, Integer.MAX_VALUE, 2);
41 | /**
42 | * The pixel size of one grid cell in the program.
43 | */
44 | private final IntSetting cellSize = new IntSetting("cellSize", BasePanel.imageSize, Integer.MAX_VALUE, 22);
45 |
46 | /**
47 | * Constructs new layout settings.
48 | */
49 | public LayoutSettings(){
50 | super("layout");
51 | }
52 |
53 | /**
54 | * Gets the size in pixels of all the layout grid cells.
55 | * @return The grid cell size in pixels.
56 | */
57 | public int getCellSize(){
58 | return cellSize.getValue();
59 | }
60 |
61 | /**
62 | * Gets the offset from the border of a panel to the actual content.
63 | * @return The distance in pixels from panel border to panel content.
64 | */
65 | public int getBorderOffset(){
66 | return borderOffset.getValue();
67 | }
68 |
69 | /**
70 | * Sets the offset from the panel border to the panel content.
71 | * The value will be adjusted if invalid.
72 | * @param offset The offset in pixels.
73 | * @see #validate()
74 | */
75 | public void setBorderOffset(int offset){
76 | borderOffset.update(offset);
77 | validate();
78 | }
79 |
80 | /**
81 | * Sets the size of the layout cells. The border offset may
82 | * be adjusted if required for the settings to be valid.
83 | * @param size The cell size in pixels.
84 | * @see #validate()
85 | */
86 | public void setCellSize(int size){
87 | cellSize.update(size);
88 | validate();
89 | }
90 |
91 | /**
92 | * Validates that the configured layout options are valid and adjusts
93 | * them if necessary. This check ensures that the border offset always
94 | * leaves an interior for a cell.
95 | * @return True if values had to be adjusted to obtain valid settings,
96 | * false if no values were adjusted.
97 | */
98 | private boolean validate(){
99 | if(borderOffset.getValue() > cellSize.getValue() - BasePanel.imageSize){
100 | borderOffset.update(cellSize.getValue() - BasePanel.imageSize);
101 | return true;
102 | }else{
103 | return false;
104 | }
105 | }
106 |
107 | @Override
108 | public boolean parse(Map data){
109 | boolean defaultUsed = findAndParse(data, borderOffset, cellSize);
110 | return validate() || defaultUsed;
111 | }
112 |
113 | @Override
114 | public void writeItems(IndentWriter out){
115 | cellSize.write(out);
116 | borderOffset.write(out);
117 | }
118 |
119 | @Override
120 | public void collectLegacyProxies(List> proxyList){
121 | proxyList.add(ProxySetting.of("borderOffset", borderOffset));
122 | proxyList.add(ProxySetting.of("cellSize", cellSize));
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/group/MaxPanelSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.group;
20 |
21 | import java.util.List;
22 |
23 | import dev.roanh.kps.config.PanelType;
24 | import dev.roanh.kps.config.Setting;
25 | import dev.roanh.kps.config.legacy.LegacyProxyStore;
26 | import dev.roanh.kps.config.legacy.ProxySetting;
27 | import dev.roanh.kps.panels.MaxPanel;
28 | import dev.roanh.kps.ui.editor.DataPanelEditor;
29 | import dev.roanh.kps.ui.editor.Editor;
30 |
31 | /**
32 | * Configuration for a maximum panel.
33 | * @author Roan
34 | * @see MaxPanel
35 | */
36 | public class MaxPanelSettings extends SpecialPanelSettings implements LegacyProxyStore{
37 |
38 | /**
39 | * Constructs new maximum panel settings.
40 | */
41 | public MaxPanelSettings(){
42 | super(PanelType.MAX, "MAX");
43 | }
44 |
45 | @Override
46 | public MaxPanel createPanel(){
47 | return new MaxPanel(this);
48 | }
49 |
50 | @Override
51 | public void showEditor(boolean live){
52 | Editor.showEditor(new DataPanelEditor(this, live));
53 | }
54 |
55 | @Override
56 | public void collectLegacyProxies(List> proxyList){
57 | proxyList.add(ProxySetting.of("maxX", x));
58 | proxyList.add(ProxySetting.of("maxY", y));
59 | proxyList.add(ProxySetting.of("maxWidth", width));
60 | proxyList.add(ProxySetting.of("maxHeight", height));
61 | proxyList.add(ProxySetting.of("maxMode", mode));
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/group/PanelSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.group;
20 |
21 | import java.util.Map;
22 |
23 | import dev.roanh.kps.config.IndentWriter;
24 | import dev.roanh.kps.config.setting.StringSetting;
25 | import dev.roanh.kps.ui.editor.EditorProvider;
26 |
27 | /**
28 | * Settings for a named panel.
29 | * @author Roan
30 | */
31 | public abstract class PanelSettings extends LocationSettings implements EditorProvider{
32 | /**
33 | * The name of this panel.
34 | */
35 | protected final StringSetting name;
36 |
37 | /**
38 | * Constructs new panel settings.
39 | * @param key The settings group key.
40 | * @param x The x position of the panel.
41 | * @param y The y position of the panel.
42 | * @param width The width of the panel.
43 | * @param height The height of the panel.
44 | * @param defaultName The display name of the panel.
45 | */
46 | protected PanelSettings(String key, int x, int y, int width, int height, String defaultName){
47 | super(key, x, y, width, height);
48 | name = new StringSetting("name", defaultName);
49 | }
50 |
51 | /**
52 | * Constructs a new panel with default dimensions.
53 | * @param key The settings group key.
54 | * @param defaultName The display name of the panel.
55 | */
56 | protected PanelSettings(String key, String defaultName){
57 | this(key, -1, 0, 2, 3, defaultName);
58 | }
59 |
60 | /**
61 | * Gets the display name of this panel.
62 | * @return The name of this panel.
63 | */
64 | public String getName(){
65 | return name.getValue();
66 | }
67 |
68 | /**
69 | * Sets the display name of the panel.
70 | * @param name The new display name.
71 | */
72 | public void setName(String name){
73 | this.name.update(name);
74 | }
75 |
76 | @Override
77 | public boolean parse(Map data){
78 | return super.parse(data) | findAndParse(data, name);
79 | }
80 |
81 | @Override
82 | public void writeItems(IndentWriter out){
83 | name.write(out);
84 | super.writeItems(out);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/group/PositionSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.group;
20 |
21 | import java.awt.Point;
22 | import java.util.List;
23 | import java.util.Map;
24 |
25 | import dev.roanh.kps.config.IndentWriter;
26 | import dev.roanh.kps.config.Setting;
27 | import dev.roanh.kps.config.SettingGroup;
28 | import dev.roanh.kps.config.legacy.LegacyPositionProxy;
29 | import dev.roanh.kps.config.legacy.LegacyProxyStore;
30 | import dev.roanh.kps.config.setting.IntSetting;
31 |
32 | /**
33 | * Position setting that also tracks if it was ever updated from default.
34 | * @author Roan
35 | */
36 | public class PositionSettings extends SettingGroup implements LegacyProxyStore{
37 | /**
38 | * The position x coordinate.
39 | */
40 | private final IntSetting x = new IntSetting("x", 0, Integer.MAX_VALUE, 0);
41 | /**
42 | * The position y coordinate.
43 | */
44 | private final IntSetting y = new IntSetting("y", 0, Integer.MAX_VALUE, 0);
45 | /**
46 | * If this setting was ever updated.
47 | */
48 | private boolean parsed = false;
49 |
50 | /**
51 | * Constructs a new position setting.
52 | */
53 | public PositionSettings(){
54 | super("frame");
55 | }
56 |
57 | /**
58 | * Stores a new position in this setting.
59 | * @param location The new position.
60 | */
61 | public void update(Point location){
62 | x.update(location.x);
63 | y.update(location.y);
64 | parsed = true;
65 | }
66 |
67 | /**
68 | * Tests if this setting was updated with some value at
69 | * some point in time. If this is false then the value
70 | * of this setting is still the initial default.
71 | * @return True if this setting was updated at some point.
72 | */
73 | public boolean hasPosition(){
74 | return parsed;
75 | }
76 |
77 | /**
78 | * Gets the position represented by this settting.
79 | * @return The configured point.
80 | */
81 | public Point getLocation(){
82 | return new Point(x.getValue(), y.getValue());
83 | }
84 |
85 | @Override
86 | public boolean parse(Map data){
87 | if(findAndParse(data, x, y)){
88 | return true;
89 | }else{
90 | parsed = true;
91 | return false;
92 | }
93 | }
94 |
95 | @Override
96 | public void writeItems(IndentWriter out){
97 | x.write(out);
98 | y.write(out);
99 | }
100 |
101 | @Override
102 | public void collectLegacyProxies(List> proxyList){
103 | proxyList.add(new LegacyPositionProxy(this));
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/group/SpecialPanelSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.group;
20 |
21 | import dev.roanh.kps.config.IndentWriter;
22 | import dev.roanh.kps.config.PanelType;
23 | import dev.roanh.kps.panels.DataPanel;
24 |
25 | /**
26 | * Settings for special panels that display some sort
27 | * of derived statistic.
28 | * @author Roan
29 | * @see PanelType
30 | */
31 | public abstract class SpecialPanelSettings extends DataPanelSettings{
32 | /**
33 | * The type of this panel, indicative of the metric displayed.
34 | */
35 | private final PanelType type;
36 |
37 | /**
38 | * Constructs new special panel settings.
39 | * @param type The type of the special panel.
40 | * @param defaultName The display name of the panel.
41 | */
42 | protected SpecialPanelSettings(PanelType type, String defaultName){
43 | super("panels", defaultName);
44 | this.type = type;
45 | }
46 |
47 | /**
48 | * Creates a new panel based on these settings.
49 | * @return The newly created panel.
50 | */
51 | public abstract DataPanel createPanel();
52 |
53 | /**
54 | * Gets the type of the panel.
55 | * @return The type of the panel.
56 | */
57 | public PanelType getType(){
58 | return type;
59 | }
60 |
61 | @Override
62 | public void writeItems(IndentWriter out){
63 | out.println("type: " + type.getKey());
64 | super.writeItems(out);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/group/TotalPanelSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.group;
20 |
21 | import java.util.List;
22 |
23 | import dev.roanh.kps.config.PanelType;
24 | import dev.roanh.kps.config.Setting;
25 | import dev.roanh.kps.config.legacy.LegacyProxyStore;
26 | import dev.roanh.kps.config.legacy.ProxySetting;
27 | import dev.roanh.kps.panels.TotPanel;
28 | import dev.roanh.kps.ui.editor.DataPanelEditor;
29 | import dev.roanh.kps.ui.editor.Editor;
30 |
31 | /**
32 | * Configuration for a total panel.
33 | * @author Roan
34 | * @see TotPanel
35 | */
36 | public class TotalPanelSettings extends SpecialPanelSettings implements LegacyProxyStore{
37 |
38 | /**
39 | * Constructs new total panel settings.
40 | */
41 | public TotalPanelSettings(){
42 | super(PanelType.TOTAL, "TOT");
43 | }
44 |
45 | @Override
46 | public TotPanel createPanel(){
47 | return new TotPanel(this);
48 | }
49 |
50 | @Override
51 | public void showEditor(boolean live){
52 | Editor.showEditor(new DataPanelEditor(this, live));
53 | }
54 |
55 | @Override
56 | public void collectLegacyProxies(List> proxyList){
57 | proxyList.add(ProxySetting.of("totX", x));
58 | proxyList.add(ProxySetting.of("totY", y));
59 | proxyList.add(ProxySetting.of("totWidth", width));
60 | proxyList.add(ProxySetting.of("totHeight", height));
61 | proxyList.add(ProxySetting.of("totMode", mode));
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/legacy/LegacyColorProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.legacy;
20 |
21 | import dev.roanh.kps.config.IndentWriter;
22 | import dev.roanh.kps.config.Setting;
23 | import dev.roanh.kps.config.ThemeColor;
24 | import dev.roanh.kps.config.setting.ColorSetting;
25 |
26 | /**
27 | * Extension of a regular color setting that can deal
28 | * with the two settings that were used to describe
29 | * colours in legacy configuration formats. This setting
30 | * handler the RGB values like normal, but overwrites
31 | * the alpha of the existing colour instead of fully replacing it.
32 | * @author Roan
33 | */
34 | public class LegacyColorProxy extends Setting{
35 | /**
36 | * The color setting to update with parsed data.
37 | */
38 | private ColorSetting setting;
39 |
40 | /**
41 | * Constructs a new legacy color setting proxy.
42 | * @param key The legacy configuration setting key.
43 | * @param setting The setting to update with parsed values.
44 | */
45 | public LegacyColorProxy(String key, ColorSetting setting){
46 | super(key, null);
47 | this.setting = setting;
48 | }
49 |
50 | @Override
51 | public boolean parse(String data){
52 | try{
53 | float alpha = Float.parseFloat(data);
54 | if(alpha < 0.0F || alpha > 1.0F){
55 | setting.reset();
56 | return true;
57 | }else{
58 | setting.update(new ThemeColor(setting.getValue().getRGB(), alpha));
59 | return false;
60 | }
61 | }catch(NumberFormatException e){
62 | return setting.parse(data);
63 | }
64 | }
65 |
66 | @Override
67 | public void write(IndentWriter out){
68 | throw new IllegalStateException("Legacy proxy settings should never be written.");
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/legacy/LegacyCompatibleKeyConstructor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.legacy;
20 |
21 | import java.util.HashMap;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.regex.Matcher;
25 | import java.util.regex.Pattern;
26 |
27 | import dev.roanh.kps.config.ListItemConstructor;
28 | import dev.roanh.kps.config.group.KeyPanelSettings;
29 |
30 | /**
31 | * Key panel settings parser that handles the legacy key
32 | * format in addition to the new format introduced in v8.8.
33 | * @author Roan
34 | */
35 | public class LegacyCompatibleKeyConstructor implements ListItemConstructor{
36 | /**
37 | * Regex used to parse the legacy key format used from v8.0 to v8.7.
38 | * Group 1: key keycode.
39 | * Group 2: panel x location.
40 | * Group 3: panel y location.
41 | * Group 4: panel width.
42 | * Group 5: panel height.
43 | * Group 6: panel rendering mode.
44 | * Group 7: true/false if the panel is visible or not.
45 | * Group 8: display name of the panel.
46 | */
47 | private static final Pattern LEGEACY_KEY_REGEX = Pattern.compile("^\\[keycode=(\\d+),x=(-?\\d+),y=(-?\\d+),width=(-?\\d+),height=(-?\\d+),mode=(HORIZONTAL_TN|HORIZONTAL_NT|DIAGONAL1|DIAGONAL2|DIAGONAL3|DIAGONAL4|VERTICAL|TEXT_ONLY|VALUE_ONLY),visible=(true|false),name=\\\"(.*)\\\"]$");
48 |
49 | @Override
50 | public ParsedItem construct(List data){
51 | Map info = new HashMap();
52 | if(data.size() == 1){
53 | Matcher m = LEGEACY_KEY_REGEX.matcher(data.get(0));
54 | if(m.matches()){
55 | info.put("keycode", m.group(1));
56 | info.put("x", m.group(2));
57 | info.put("y", m.group(3));
58 | info.put("width", m.group(4));
59 | info.put("height", m.group(5));
60 | info.put("mode", m.group(6));
61 | info.put("visible", m.group(7));
62 | info.put("name", m.group(8));
63 | return ListItemConstructor.constructThenParse(KeyPanelSettings::new, info);
64 | }
65 | }
66 |
67 | info = ListItemConstructor.buildMap(data);
68 | return info == null ? null : ListItemConstructor.constructThenParse(KeyPanelSettings::new, info);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/legacy/LegacyGraphSetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.legacy;
20 |
21 | import dev.roanh.kps.config.IndentWriter;
22 | import dev.roanh.kps.config.Setting;
23 |
24 | /**
25 | * Small legacy setting that ensures parsing of the legacy
26 | * graphMode setting does not throw a warning that a default
27 | * was used as long as the configured value was set to the
28 | * only currently supported option of inline. In addition this
29 | * setting silently discards the legacy graphPosition setting
30 | * that accompanied the detached graph mode setting.
31 | * @author Roan
32 | */
33 | public class LegacyGraphSetting extends Setting{
34 |
35 | /**
36 | * Constructs a new legacy graph mode setting.
37 | * @param key The setting key, either graphMode or graphPosition.
38 | * @param required The only accepted value to not trigger a
39 | * warning that a default value was used. If null all
40 | * values are accepted without generating a warning.
41 | */
42 | public LegacyGraphSetting(String key, String required){
43 | super(key, required);
44 | }
45 |
46 | @Override
47 | public boolean parse(String data){
48 | return getDefaultValue() != null && !data.equalsIgnoreCase(getDefaultValue());
49 | }
50 |
51 | @Override
52 | public void write(IndentWriter out){
53 | throw new IllegalStateException("Legacy proxy settings should never be written.");
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/legacy/LegacyPanelShowSetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.legacy;
20 |
21 | import dev.roanh.kps.config.SettingList;
22 | import dev.roanh.kps.config.group.LocationSettings;
23 | import dev.roanh.kps.config.setting.BooleanSetting;
24 |
25 | /**
26 | * Legacy setting that handles the various show settings
27 | * for certain panels in the legacy configuration format.
28 | * If these settings are detected and set to false the
29 | * relevant panel is removed from the configuration.
30 | * @author Roan
31 | */
32 | public class LegacyPanelShowSetting extends BooleanSetting{
33 | /**
34 | * The list with panels to update if the item needs to be removed.
35 | */
36 | private SettingList extends LocationSettings> data;
37 | /**
38 | * The item to remove if the setting is found and set to false.
39 | */
40 | private LocationSettings item;
41 |
42 | /**
43 | * Creates a new legacy panel show setting.
44 | * @param key The configuration key.
45 | * @param data The list with panels to update.
46 | * @param item The item to potentially remove.
47 | */
48 | public LegacyPanelShowSetting(String key, SettingList extends LocationSettings> data, LocationSettings item){
49 | super(key, true);
50 | this.data = data;
51 | this.item = item;
52 | }
53 |
54 | @Override
55 | public boolean parse(String data){
56 | boolean defaultUsed = super.parse(data);
57 |
58 | if(!getValue()){
59 | this.data.remove(item);
60 | }
61 |
62 | return defaultUsed;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/legacy/LegacyPositionProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.legacy;
20 |
21 | import java.awt.Point;
22 | import java.util.regex.Matcher;
23 | import java.util.regex.Pattern;
24 |
25 | import dev.roanh.kps.config.IndentWriter;
26 | import dev.roanh.kps.config.Setting;
27 | import dev.roanh.kps.config.group.PositionSettings;
28 |
29 | /**
30 | * Proxy setting for the legacy position setting.
31 | * @author Roan
32 | * @see PositionSettings
33 | */
34 | public class LegacyPositionProxy extends Setting{
35 | /**
36 | * Legacy format regex:
37 | * Group 1: x coordinate.
38 | * Group 2: y coordinate.
39 | */
40 | private static final Pattern LEGACY_POSITION_REGEX = Pattern.compile("\\[x=(\\d+),y=(\\d+)]");
41 | /**
42 | * The position settings to proxy to.
43 | */
44 | private final PositionSettings position;
45 |
46 | /**
47 | * Constructs a new legacy position setting proxy with the given target to update.
48 | * @param setting The setting being proxied.
49 | */
50 | public LegacyPositionProxy(PositionSettings setting){
51 | super("position", null);
52 | position = setting;
53 | }
54 |
55 | @Override
56 | public boolean parse(String data){
57 | Matcher m = LEGACY_POSITION_REGEX.matcher(data);
58 | if(m.matches()){
59 | try{
60 | position.update(new Point(Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2))));
61 | return false;
62 | }catch(NumberFormatException e){
63 | return true;
64 | }
65 | }else{
66 | return true;
67 | }
68 | }
69 |
70 | @Override
71 | public void write(IndentWriter out){
72 | throw new IllegalStateException("Legacy proxy settings should never be written.");
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/legacy/LegacyProxyStore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.legacy;
20 |
21 | import java.util.List;
22 |
23 | import dev.roanh.kps.config.Setting;
24 | import dev.roanh.kps.config.SettingGroup;
25 |
26 | /**
27 | * Interface used by setting groups to indicate that they
28 | * provide legacy setting mapping proxies.
29 | * @author Roan
30 | * @see SettingGroup
31 | */
32 | public abstract interface LegacyProxyStore{
33 |
34 | /**
35 | * Collects mappings of legacy settings for this panel
36 | * used to map legacy settings onto the new config system.
37 | * @param proxyList The list to add the legacy settings to.
38 | * @see ProxySetting
39 | */
40 | public abstract void collectLegacyProxies(List> proxyList);
41 | }
42 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/legacy/ProxySetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.legacy;
20 |
21 | import dev.roanh.kps.config.IndentWriter;
22 | import dev.roanh.kps.config.Setting;
23 |
24 | /**
25 | * Proxy setting used to map old settings onto new settings.
26 | * Generally used to set new settings based on the value for
27 | * old legacy settings that no longer exist.
28 | * @author Roan
29 | */
30 | public class ProxySetting extends Setting{
31 | /**
32 | * All the settings to update with received data.
33 | */
34 | private final Setting>[] targets;
35 |
36 | /**
37 | * Constructs a new proxy setting.
38 | * @param key The configuration key.
39 | * @param targets A list of target settings to update with received data.
40 | */
41 | private ProxySetting(String key, Setting>... targets){
42 | super(key, null);
43 | this.targets = targets;
44 | }
45 |
46 | @Override
47 | public boolean parse(String data){
48 | boolean defaultUsed = false;
49 | for(Setting> setting : targets){
50 | defaultUsed |= setting.parse(data);
51 | }
52 | return defaultUsed;
53 | }
54 |
55 | @Override
56 | public void write(IndentWriter out){
57 | throw new IllegalStateException("Legacy proxy settings should never be written.");
58 | }
59 |
60 | /**
61 | * Constructs a new proxy setting.
62 | * @param key The configuration key.
63 | * @param targets A list of settings to update with received data.
64 | * @return The newly constructed proxy setting.
65 | */
66 | public static final ProxySetting of(String key, Setting>... targets){
67 | return new ProxySetting(key, targets);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/setting/BooleanSetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.setting;
20 |
21 | import dev.roanh.kps.config.IndentWriter;
22 | import dev.roanh.kps.config.Setting;
23 |
24 | /**
25 | * Boolean setting implementation.
26 | * @author Roan
27 | */
28 | public class BooleanSetting extends Setting{
29 |
30 | /**
31 | * Constructs a new boolean setting with the given key and default value.
32 | * @param key The setting key to associate the value with.
33 | * @param defaultValue The default value for this setting.
34 | */
35 | public BooleanSetting(String key, boolean defaultValue){
36 | super(key, defaultValue);
37 | }
38 |
39 | @Override
40 | public boolean parse(String data){
41 | if("true".equalsIgnoreCase(data)){
42 | update(true);
43 | return false;
44 | }else if("false".equalsIgnoreCase(data)){
45 | update(false);
46 | return false;
47 | }else{
48 | reset();
49 | return true;
50 | }
51 | }
52 |
53 | @Override
54 | public void write(IndentWriter out){
55 | out.println(key + ": " + value);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/setting/ColorSetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.setting;
20 |
21 | import java.util.Locale;
22 | import java.util.regex.Matcher;
23 | import java.util.regex.Pattern;
24 |
25 | import dev.roanh.kps.config.IndentWriter;
26 | import dev.roanh.kps.config.Setting;
27 | import dev.roanh.kps.config.ThemeColor;
28 |
29 | /**
30 | * Setting for theme colors.
31 | * @author Roan
32 | * @see ThemeColor
33 | */
34 | public class ColorSetting extends Setting{
35 | /**
36 | * Regex for the legacy RGB color format.
37 | * Group 1: integer red component.
38 | * Group 2: integer green component.
39 | * Group 3: integer blue component.
40 | */
41 | private static final Pattern LEGACY_COLOR_REGEX = Pattern.compile("\\[r=(\\d{1,3}),g=(\\d{1,3}),b=(\\d{1,3})]");
42 | /**
43 | * Regex for the new HEX based #RRGGBBAA color format, where alpha is optional.
44 | * Group 1: RGB HEX color.
45 | * Group 2: alpha HEX color or null if there is no alpha component (defaults to fully opaque).
46 | */
47 | private static final Pattern COLOR_REGEX = Pattern.compile("#([A-F0-9]{6})([A-F0-9]{2})?");
48 |
49 | /**
50 | * Constructs a new color setting.
51 | * @param key The setting key.
52 | * @param defaultValue The default setting value.
53 | */
54 | public ColorSetting(String key, ThemeColor defaultValue){
55 | super(key, defaultValue);
56 | }
57 |
58 | @Override
59 | public boolean parse(String data){
60 | Matcher m = LEGACY_COLOR_REGEX.matcher(data);
61 | if(m.matches()){
62 | int r = Integer.parseInt(m.group(1));
63 | int g = Integer.parseInt(m.group(2));
64 | int b = Integer.parseInt(m.group(3));
65 | if(r > 255 || g > 255 || b > 255){
66 | reset();
67 | return true;
68 | }else{
69 | update(new ThemeColor(r, g, b, value.getAlpha()));
70 | return false;
71 | }
72 | }else{
73 | data = data.toUpperCase(Locale.ROOT);
74 | m = COLOR_REGEX.matcher(data);
75 | if(m.matches()){
76 | int rgb = Integer.parseUnsignedInt(m.group(1), 16);
77 | String alphaStr = m.group(2);
78 | int alpha = alphaStr == null ? 0xFF : Integer.parseUnsignedInt(alphaStr, 16);
79 | update(new ThemeColor(rgb, alpha));
80 | return false;
81 | }else{
82 | reset();
83 | return true;
84 | }
85 | }
86 | }
87 |
88 | @Override
89 | public void write(IndentWriter out){
90 | out.println(key + ": #" + value.toHex());
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/setting/CommandKeySetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.setting;
20 |
21 | import java.util.regex.Matcher;
22 | import java.util.regex.Pattern;
23 |
24 | import dev.roanh.kps.CommandKeys;
25 | import dev.roanh.kps.config.IndentWriter;
26 |
27 | /**
28 | * Setting for command keys.
29 | * @author Roan
30 | */
31 | public class CommandKeySetting extends IntSetting{
32 | /**
33 | * Regex used to parse the legacy command format used until v8.8.
34 | * Group 1: command key code.
35 | * Group 2: true/false if ctrl needs to be pressed to activate the command.
36 | * Group 3: true/false if alt needs to be pressed to activate the command.
37 | */
38 | private static final Pattern LEGACY_COMMAND_REGEX = Pattern.compile("\\[keycode=(\\d+),ctrl=(true|false),alt=(true|false)]");
39 |
40 | /**
41 | * Constructs a new command key setting.
42 | * @param key The setting key.
43 | * @param code The code of the key for this command (not the extended key code).
44 | * @param alt If alt has to be down to trigger the command.
45 | * @param ctrl If ctrl has to be down to trigger the command.
46 | */
47 | public CommandKeySetting(String key, int code, boolean alt, boolean ctrl){
48 | super(key, Integer.MIN_VALUE, Integer.MAX_VALUE, CommandKeys.getExtendedKeyCode(code, false, ctrl, alt));
49 | }
50 |
51 | /**
52 | * Constructs a new initially unbound command key setting.
53 | * @param key The setting key.
54 | */
55 | public CommandKeySetting(String key){
56 | super(key, Integer.MIN_VALUE, Integer.MAX_VALUE, null);
57 | }
58 |
59 | /**
60 | * Tests if the given key activates this setting at the moment.
61 | * Note that the result of this subroutine depends both on the
62 | * provided key and whether ctrl and alt are currently pressed.
63 | * @param code The code of the key that was pressed (not the extended key code).
64 | * @return True if the command key matches at the moment.
65 | */
66 | public boolean matches(int code){
67 | return value != null && value.intValue() == CommandKeys.getExtendedKeyCode(code, false, CommandKeys.isCtrlDown, CommandKeys.isAltDown);
68 | }
69 |
70 | /**
71 | * Unbinds this command key to nothing, meaning it never triggers.
72 | */
73 | public void unbind(){
74 | update(null);
75 | }
76 |
77 | /**
78 | * Gets a display string for this command key such as
79 | * 'Ctrl + S' or 'Unbound' if the key is not bound.
80 | * @return A display string for the command.
81 | */
82 | public String toDisplayString(){
83 | return value == null ? "Unbound" : CommandKeys.formatExtendedCode(value);
84 | }
85 |
86 | @Override
87 | public boolean parse(String data){
88 | if(data.equalsIgnoreCase("unbound")){
89 | update(null);
90 | return false;
91 | }else{
92 | Matcher m = LEGACY_COMMAND_REGEX.matcher(data);
93 | if(m.matches()){
94 | if(super.parse(m.group(1))){
95 | return true;
96 | }
97 |
98 | update(CommandKeys.getExtendedKeyCode(value, false, Boolean.parseBoolean(m.group(2)), Boolean.parseBoolean(m.group(3))));
99 | return false;
100 | }else{
101 | return super.parse(data);
102 | }
103 | }
104 | }
105 |
106 | @Override
107 | public void write(IndentWriter out){
108 | if(value == null){
109 | out.println(key + ": unbound");
110 | }else{
111 | super.write(out);
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/setting/IntSetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.setting;
20 |
21 | import dev.roanh.kps.config.IndentWriter;
22 | import dev.roanh.kps.config.Setting;
23 |
24 | /**
25 | * Integer setting implementation.
26 | * @author Roan
27 | */
28 | public class IntSetting extends Setting{
29 | /**
30 | * The minimum valid value.
31 | */
32 | private final int min;
33 | /**
34 | * The maximum valid value.
35 | */
36 | private final int max;
37 |
38 | /**
39 | * Constructs a new integer setting.
40 | * @param key The setting key to associate the value with.
41 | * @param min The minimum allowed value.
42 | * @param max The maximum allowed value.
43 | * @param defaultValue The default value for this setting.
44 | */
45 | public IntSetting(String key, int min, int max, Integer defaultValue){
46 | super(key, defaultValue);
47 | this.min = min;
48 | this.max = max;
49 | }
50 |
51 | @Override
52 | public boolean parse(String data){
53 | try{
54 | int val = Integer.parseInt(data);
55 | if(min <= val && val <= max){
56 | update(val);
57 | return false;
58 | }else{
59 | reset();
60 | return true;
61 | }
62 | }catch(NumberFormatException e){
63 | reset();
64 | return true;
65 | }
66 | }
67 |
68 | @Override
69 | public void write(IndentWriter out){
70 | out.println(key + ": " + value);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/setting/LongSetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.setting;
20 |
21 | import dev.roanh.kps.config.IndentWriter;
22 | import dev.roanh.kps.config.Setting;
23 |
24 | /**
25 | * Long setting implementation.
26 | * @author Roan
27 | */
28 | public class LongSetting extends Setting{
29 | /**
30 | * The minimum valid value.
31 | */
32 | private final long min;
33 | /**
34 | * The maximum valid value.
35 | */
36 | private final long max;
37 |
38 | /**
39 | * Constructs a new long setting.
40 | * @param key The setting key to associate the value with.
41 | * @param min The minimum allowed value.
42 | * @param max The maximum allowed value.
43 | * @param defaultValue The default value for this setting.
44 | */
45 | public LongSetting(String key, long min, long max, long defaultValue){
46 | super(key, defaultValue);
47 | this.min = min;
48 | this.max = max;
49 | }
50 |
51 | @Override
52 | public boolean parse(String data){
53 | try{
54 | long val = Long.parseLong(data);
55 | if(min <= val && val <= max){
56 | update(val);
57 | return false;
58 | }else{
59 | reset();
60 | return true;
61 | }
62 | }catch(NumberFormatException e){
63 | reset();
64 | return true;
65 | }
66 | }
67 |
68 | @Override
69 | public void write(IndentWriter out){
70 | out.println(key + ": " + value);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/setting/PathSetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.setting;
20 |
21 | import dev.roanh.kps.ui.model.FilePathFormatterFactory;
22 |
23 | /**
24 | * Setting for file paths that performs some extra
25 | * validation to ensure paths are valid file system paths.
26 | * @author Roan
27 | */
28 | public class PathSetting extends StringSetting{
29 |
30 | /**
31 | * Constructs a new path setting.
32 | * @param key The setting key.
33 | * @param defaultValue The default setting value.
34 | */
35 | public PathSetting(String key, String defaultValue){
36 | super(key, defaultValue);
37 | }
38 |
39 | @Override
40 | public boolean parse(String data){
41 | super.parse(data);
42 |
43 | if(FilePathFormatterFactory.isValidPath(getValue())){
44 | return false;
45 | }else{
46 | reset();
47 | return true;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/setting/PrecisionSetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.setting;
20 |
21 | /**
22 | * Precision setting used to format real numbers.
23 | * @author Roan
24 | */
25 | public class PrecisionSetting extends IntSetting{
26 | /**
27 | * The format string used for formatting.
28 | */
29 | private String format;
30 |
31 | /**
32 | * Constructs a new precision setting.
33 | * @param key The setting key.
34 | * @param min The minimum precision value.
35 | * @param max The maximum precision value.
36 | * @param defaultValue The default precision value.
37 | */
38 | public PrecisionSetting(String key, int min, int max, int defaultValue){
39 | super(key, min, max, defaultValue);
40 | }
41 |
42 | /**
43 | * Formats the given double value according to
44 | * the precision value configured for this setting.
45 | * @param value The value to format.
46 | * @return The formatted value.
47 | */
48 | public String format(double value){
49 | return String.format(format, value);
50 | }
51 |
52 | @Override
53 | public void update(Integer newValue){
54 | super.update(newValue);
55 | format = "%1$." + getValue() + "f";
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/setting/RenderingModeSetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.setting;
20 |
21 | import java.util.Locale;
22 |
23 | import dev.roanh.kps.RenderingMode;
24 | import dev.roanh.kps.config.IndentWriter;
25 | import dev.roanh.kps.config.Setting;
26 |
27 | /**
28 | * Setting for rendering modes.
29 | * @author Roan
30 | * @see RenderingMode
31 | */
32 | public class RenderingModeSetting extends Setting{
33 |
34 | /**
35 | * Constructs a new rendering mode setting.
36 | * @param key The setting key.
37 | * @param defaultValue The default setting value.
38 | */
39 | public RenderingModeSetting(String key, RenderingMode defaultValue){
40 | super(key, defaultValue);
41 | }
42 |
43 | @Override
44 | public boolean parse(String data){
45 | try{
46 | data = data.toUpperCase(Locale.ROOT);
47 | switch(data){
48 | case "HORIZONTAL":
49 | update(RenderingMode.HORIZONTAL_TN);
50 | return false;
51 | case "VERTICALS":
52 | case "HORIZONTAL_TAN":
53 | update(RenderingMode.VERTICAL);
54 | return false;
55 | case "HORIZONTAL_TDAN":
56 | case "HORIZONTAL_TDANS":
57 | update(RenderingMode.DIAGONAL1);
58 | return false;
59 | case "HORIZONTAL_TDAN2":
60 | case "HORIZONTAL_TDAN2S":
61 | update(RenderingMode.DIAGONAL3);
62 | return false;
63 | default:
64 | update(RenderingMode.valueOf(data));
65 | return false;
66 | }
67 | }catch(IllegalArgumentException e){
68 | reset();
69 | return true;
70 | }
71 | }
72 |
73 | @Override
74 | public void write(IndentWriter out){
75 | out.println(key + ": " + value.name());
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/setting/StringSetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.setting;
20 |
21 | import dev.roanh.kps.config.IndentWriter;
22 | import dev.roanh.kps.config.Setting;
23 |
24 | /**
25 | * String setting implementation.
26 | * @author Roan
27 | */
28 | public class StringSetting extends Setting{
29 |
30 | /**
31 | * Constructs a new string setting with the given key and default value.
32 | * @param key The setting key to associate the value with.
33 | * @param defaultValue The default value for this setting.
34 | */
35 | public StringSetting(String key, String defaultValue){
36 | super(key, defaultValue);
37 | }
38 |
39 | @Override
40 | public boolean parse(String data){
41 | update(data);
42 | return false;
43 | }
44 |
45 | @Override
46 | public void write(IndentWriter out){
47 | out.println(key + ": " + value);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/config/setting/UpdateRateSetting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.setting;
20 |
21 | import dev.roanh.kps.config.IndentWriter;
22 | import dev.roanh.kps.config.Setting;
23 | import dev.roanh.kps.config.UpdateRate;
24 |
25 | /**
26 | * Setting for update rates.
27 | * @author Roan
28 | * @see UpdateRate
29 | */
30 | public class UpdateRateSetting extends Setting{
31 |
32 | /**
33 | * Constructs a new update rate setting.
34 | * @param key The configuration setting key.
35 | * @param defaultValue The default setting value.
36 | */
37 | public UpdateRateSetting(String key, UpdateRate defaultValue){
38 | super(key, defaultValue);
39 | }
40 |
41 | @Override
42 | public boolean parse(String data){
43 | try{
44 | update(UpdateRate.fromMs(Integer.parseInt(data)));
45 | return false;
46 | }catch(IllegalArgumentException e){
47 | reset();
48 | return true;
49 | }
50 | }
51 |
52 | @Override
53 | public void write(IndentWriter out){
54 | out.println(key + ": " + value.getRate());
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/event/InputSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.event;
20 |
21 | /**
22 | * Abstract base class for providers of input events.
23 | * @author Roan
24 | */
25 | public abstract class InputSource{
26 | /**
27 | * The event manager to report input to.
28 | */
29 | protected EventManager manager;
30 |
31 | /**
32 | * Constructs a new input source with the
33 | * given event manager to report to.
34 | * @param manager The event manager to report to.
35 | */
36 | public InputSource(EventManager manager){
37 | this.manager = manager;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/event/listener/ButtonPressListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.event.listener;
20 |
21 | import dev.roanh.kps.event.EventManager;
22 |
23 | /**
24 | * Listener called when a mouse button was pressed.
25 | * @author Roan
26 | * @see EventManager
27 | */
28 | @FunctionalInterface
29 | public abstract interface ButtonPressListener{
30 |
31 | /**
32 | * Called when a mouse button was pressed.
33 | * @param button The ID of the button that was pressed.
34 | */
35 | public abstract void onButtonPress(int button);
36 | }
37 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/event/listener/ButtonReleaseListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.event.listener;
20 |
21 | import dev.roanh.kps.event.EventManager;
22 |
23 | /**
24 | * Listener called when a mouse button was released.
25 | * @author Roan
26 | * @see EventManager
27 | */
28 | @FunctionalInterface
29 | public abstract interface ButtonReleaseListener{
30 |
31 | /**
32 | * Called when a mouse button was released.
33 | * @param button The ID of the button that was released.
34 | */
35 | public abstract void onButtonRelease(int button);
36 | }
37 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/event/listener/KeyPressListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.event.listener;
20 |
21 | import dev.roanh.kps.event.EventManager;
22 |
23 | /**
24 | * Listener called when a key was pressed.
25 | * @author Roan
26 | * @see EventManager
27 | */
28 | @FunctionalInterface
29 | public abstract interface KeyPressListener{
30 |
31 | /**
32 | * Called when a key was pressed.
33 | * @param code The key code of the key that was pressed.
34 | */
35 | public abstract void onKeyPress(int code);
36 | }
37 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/event/listener/KeyReleaseListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.event.listener;
20 |
21 | import dev.roanh.kps.event.EventManager;
22 |
23 | /**
24 | * Listener called when a key was released.
25 | * @author Roan
26 | * @see EventManager
27 | */
28 | @FunctionalInterface
29 | public abstract interface KeyReleaseListener{
30 |
31 | /**
32 | * Called when a key was released.
33 | * @param code The key code of the key that was released.
34 | */
35 | public abstract void onKeyRelease(int code);
36 | }
37 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/event/listener/MouseMoveListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.event.listener;
20 |
21 | import dev.roanh.kps.event.EventManager;
22 |
23 | /**
24 | * Listener called when the mouse was moved.
25 | * @author Roan
26 | * @see EventManager
27 | */
28 | @FunctionalInterface
29 | public abstract interface MouseMoveListener{
30 |
31 | /**
32 | * Called when the cursor was moved.
33 | * @param x The x coordinate the cursor moved to.
34 | * @param y The y coordinate the cursor moved to.
35 | */
36 | public abstract void onMouseMove(int x, int y);
37 | }
38 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/event/source/NativeHookInputSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.event.source;
20 |
21 | import java.util.logging.Level;
22 | import java.util.logging.Logger;
23 |
24 | import com.github.kwhat.jnativehook.GlobalScreen;
25 | import com.github.kwhat.jnativehook.NativeHookException;
26 | import com.github.kwhat.jnativehook.keyboard.NativeKeyEvent;
27 | import com.github.kwhat.jnativehook.keyboard.NativeKeyListener;
28 | import com.github.kwhat.jnativehook.mouse.NativeMouseEvent;
29 | import com.github.kwhat.jnativehook.mouse.NativeMouseListener;
30 | import com.github.kwhat.jnativehook.mouse.NativeMouseMotionListener;
31 |
32 | import dev.roanh.kps.event.EventManager;
33 | import dev.roanh.kps.event.InputSource;
34 |
35 | /**
36 | * Input source of key and mouse event as reported by JNativeHook.
37 | * @author Roan
38 | */
39 | public class NativeHookInputSource extends InputSource implements NativeKeyListener, NativeMouseListener, NativeMouseMotionListener{
40 |
41 | /**
42 | * Constructs a new JNativeHook input source.
43 | * @param manager The event manager to report to.
44 | * @throws NativeHookException When some exception occurs.
45 | */
46 | public NativeHookInputSource(EventManager manager) throws NativeHookException{
47 | super(manager);
48 |
49 | //Make sure the native hook is always unregistered
50 | Runtime.getRuntime().addShutdownHook(new Thread(this::cleanup));
51 |
52 | //Initialise native library
53 | System.setProperty("jnativehook.lib.path", System.getProperty("java.io.tmpdir"));
54 | Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
55 | logger.setLevel(Level.WARNING);
56 | logger.setUseParentHandlers(false);
57 | GlobalScreen.registerNativeHook();
58 |
59 | GlobalScreen.addNativeKeyListener(this);
60 | GlobalScreen.addNativeMouseListener(this);
61 | GlobalScreen.addNativeMouseMotionListener(this);
62 | }
63 |
64 | /**
65 | * Cleans up all resources used by JNativeHook.
66 | */
67 | private void cleanup(){
68 | try{
69 | GlobalScreen.unregisterNativeHook();
70 | }catch(NativeHookException e1){
71 | e1.printStackTrace();
72 | }
73 | }
74 |
75 | @Override
76 | public void nativeKeyPressed(NativeKeyEvent event){
77 | manager.fireKeyPressEvent(event.getKeyCode());
78 | }
79 |
80 | @Override
81 | public void nativeKeyReleased(NativeKeyEvent event){
82 | manager.fireKeyReleaseEvent(event.getKeyCode());
83 | }
84 |
85 | @Override
86 | public void nativeKeyTyped(NativeKeyEvent event){
87 | }
88 |
89 | @Override
90 | public void nativeMouseClicked(NativeMouseEvent event){
91 | }
92 |
93 | @Override
94 | public void nativeMousePressed(NativeMouseEvent event){
95 | manager.fireButtonPressEvent(event.getButton());
96 | }
97 |
98 | @Override
99 | public void nativeMouseReleased(NativeMouseEvent event){
100 | manager.fireButtonReleaseEvent(event.getButton());
101 | }
102 |
103 | @Override
104 | public void nativeMouseMoved(NativeMouseEvent event){
105 | manager.fireMouseMoveEvent(event.getX(), event.getY());
106 | }
107 |
108 | @Override
109 | public void nativeMouseDragged(NativeMouseEvent event){
110 | manager.fireMouseMoveEvent(event.getX(), event.getY());
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/layout/GridPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.layout;
20 |
21 | import java.awt.AlphaComposite;
22 | import java.awt.Composite;
23 | import java.awt.Graphics;
24 | import java.awt.Graphics2D;
25 |
26 | import javax.swing.JPanel;
27 |
28 | import dev.roanh.kps.ColorManager;
29 | import dev.roanh.kps.Main;
30 | import dev.roanh.kps.config.ThemeColor;
31 |
32 | /**
33 | * Simple panel that draws a spaced grid
34 | * @author Roan
35 | */
36 | public class GridPanel extends JPanel{
37 | /**
38 | * Serial ID
39 | */
40 | private static final long serialVersionUID = 5878892347456014988L;
41 | /**
42 | * Whether or not the grid is currently displayed
43 | */
44 | private boolean showGrid = false;
45 |
46 | @Override
47 | public void paintComponent(Graphics g1){
48 | Graphics2D g = (Graphics2D)g1;
49 | Composite comp = g.getComposite();
50 | ThemeColor background = Main.config.getTheme().getBackground();
51 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, background.getAlpha()));
52 | g.setColor(background.getColor());
53 | g.fillRect(0, 0, this.getWidth(), this.getHeight());
54 | g.setComposite(comp);
55 |
56 | if(showGrid){
57 | g.setColor(ColorManager.alphaAqua);
58 | int cellSize = Main.config.getCellSize();
59 |
60 | for(int i = cellSize; i < this.getWidth(); i += cellSize){
61 | g.drawLine(i, 0, i, this.getHeight());
62 | g.drawLine(i - 1, 0, i - 1, this.getHeight());
63 | }
64 |
65 | for(int i = cellSize; i < this.getHeight(); i += cellSize){
66 | g.drawLine(0, i, this.getWidth(), i);
67 | g.drawLine(0, i - 1, this.getWidth(), i - 1);
68 | }
69 | }
70 | }
71 |
72 | /**
73 | * Turns on grid rendering
74 | */
75 | public void showGrid(){
76 | showGrid = true;
77 | }
78 |
79 | /**
80 | * Turns off grid rendering
81 | */
82 | public void hideGrid(){
83 | showGrid = false;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/layout/LayoutPosition.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.layout;
20 |
21 | /**
22 | * Interface that panels that will be
23 | * added to a {@link Layout} have to implement
24 | * @author Roan
25 | * @see Layout
26 | */
27 | public abstract interface LayoutPosition{
28 | /**
29 | * Gets the x position of this
30 | * panel in the layout
31 | * @return The x position of this
32 | * panel in the layout
33 | */
34 | public abstract int getLayoutX();
35 |
36 | /**
37 | * Gets the y position of this
38 | * panel in the layout
39 | * @return The y position of this
40 | * panel in the layout
41 | */
42 | public abstract int getLayoutY();
43 |
44 | /**
45 | * Gets the width of this panel
46 | * in the layout
47 | * @return The width of this panel
48 | * in the layout
49 | */
50 | public abstract int getLayoutWidth();
51 |
52 | /**
53 | * Gets the height of this panel
54 | * in the layout
55 | * @return The height of this panel
56 | * in the layout
57 | */
58 | public abstract int getLayoutHeight();
59 |
60 | /**
61 | * Gets the position and size given by
62 | * this LayoutPosition as a string
63 | * @return A string giving the position
64 | * and size of this LayoutPosition
65 | */
66 | public default String getLayoutLocation(){
67 | return "LayoutPosition[x=" + getLayoutX() + ",y=" + getLayoutY() + ",width=" + getLayoutWidth() + ",height=" + getLayoutHeight() + "]";
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/panels/AvgPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.panels;
20 |
21 | import dev.roanh.kps.Main;
22 | import dev.roanh.kps.config.group.AveragePanelSettings;
23 |
24 | /**
25 | * Panel used to display the average keys pressed per second.
26 | * @author Roan
27 | */
28 | public final class AvgPanel extends DataPanel{
29 | /**
30 | * Serial ID
31 | */
32 | private static final long serialVersionUID = 5628759695450014071L;
33 | /**
34 | * The panel configuration.
35 | */
36 | private AveragePanelSettings settings;
37 |
38 | /**
39 | * Constructs a new average panel
40 | * @param settings The configuration for this panel.
41 | */
42 | public AvgPanel(AveragePanelSettings settings){
43 | super(settings);
44 | this.settings = settings;
45 | }
46 |
47 | @Override
48 | protected String getValue(){
49 | return settings.formatAvg(Main.avg);
50 | }
51 | }
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/panels/DataPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.panels;
20 |
21 | import java.awt.Graphics2D;
22 |
23 | import dev.roanh.kps.ColorManager;
24 | import dev.roanh.kps.RenderingMode.RenderCache;
25 | import dev.roanh.kps.config.group.DataPanelSettings;
26 |
27 | /**
28 | * Abstract base class for panels that display a title and a value.
29 | * @author Roan
30 | */
31 | public abstract class DataPanel extends BasePanel{
32 | /**
33 | * Serial ID.
34 | */
35 | private static final long serialVersionUID = 4584033301375308252L;
36 | /**
37 | * RenderCache for this panel
38 | */
39 | protected RenderCache cache = new RenderCache();
40 | /**
41 | * Settings for this panel.
42 | */
43 | private DataPanelSettings config;
44 |
45 | /**
46 | * Constructs a new data panel with the given settings.
47 | * @param config The panel settings.
48 | */
49 | protected DataPanel(DataPanelSettings config){
50 | super(config);
51 | this.config = config;
52 | sizeChanged();
53 | }
54 |
55 | /**
56 | * Signals this panel that its size
57 | * or properties changed and that thus
58 | * the render cache should be invalidated
59 | */
60 | public final void sizeChanged(){
61 | cache.init(config.getRenderingMode());
62 | this.repaint();
63 | }
64 |
65 | /**
66 | * Gets whether or not this panel should be highlighted.
67 | * @return Whether the panel is "active" or not.
68 | */
69 | protected boolean isActive(){
70 | return false;
71 | }
72 |
73 | /**
74 | * Gets the value for this panel.
75 | * @return The value for this panel.
76 | */
77 | protected abstract String getValue();
78 |
79 | @Override
80 | protected void render(Graphics2D g){
81 | if(isActive()){
82 | g.setColor(ColorManager.activeColor);
83 | g.fillRect(
84 | borderOffset + (imageSize / 4) * 3,
85 | borderOffset + (imageSize / 4) * 2,
86 | this.getWidth() - 2 * borderOffset - (imageSize / 4) * 6,
87 | this.getHeight() - 2 * borderOffset - (imageSize / 4) * 4
88 | );
89 | g.setColor(background.getColor());
90 | }else{
91 | g.setColor(foreground.getColor());
92 | }
93 |
94 | cache.renderTitle(config.getName(), g, this);
95 |
96 | cache.renderValue(getValue(), g, this);
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/panels/GraphPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.panels;
20 |
21 | import dev.roanh.kps.config.group.GraphPanelSettings;
22 |
23 | /**
24 | * Base class for graph implementations.
25 | * @author Roan
26 | */
27 | public abstract class GraphPanel extends BasePanel{
28 | /**
29 | * Serial ID.
30 | */
31 | private static final long serialVersionUID = 393397627762727201L;
32 |
33 | /**
34 | * Constructs a new graph panel.
35 | * @param config The graph settings.
36 | */
37 | protected GraphPanel(GraphPanelSettings config){
38 | super(config);
39 | }
40 |
41 | /**
42 | * Called when the graph should update its data. This
43 | * method is called from the main update loop thread
44 | * and it is thus guaranteed that derived statistics
45 | * do not update during this method.
46 | */
47 | public abstract void update();
48 |
49 | /**
50 | * Resets any data collected by this graph to defaults.
51 | */
52 | public abstract void reset();
53 | }
54 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/panels/KeyPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.panels;
20 |
21 | import dev.roanh.kps.Key;
22 | import dev.roanh.kps.config.group.KeyPanelSettings;
23 |
24 | /**
25 | * Panel to display the number
26 | * of times a certain key has
27 | * been pressed
28 | * @author Roan
29 | */
30 | public final class KeyPanel extends DataPanel{
31 | /**
32 | * Serial ID
33 | */
34 | private static final long serialVersionUID = 8816524158873355997L;
35 | /**
36 | * The key object associated with this panel. This key object
37 | * keeps track of the number of times the assigned key has been hit.
38 | */
39 | private Key key;
40 |
41 | /**
42 | * Constructs a new KeyPanel with the given key object.
43 | * @param key The key object to associate this panel with.
44 | * @param settings The key settings object for this panel.
45 | * @see Key
46 | * @see KeyPanelSettings
47 | */
48 | public KeyPanel(Key key, KeyPanelSettings settings){
49 | super(settings);
50 | this.key = key;
51 | key.setPanel(this);
52 | }
53 |
54 | @Override
55 | protected boolean isActive(){
56 | return key.isDown();
57 | }
58 |
59 | @Override
60 | protected String getValue(){
61 | return String.valueOf(key.getCount());
62 | }
63 | }
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/panels/LastPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.panels;
20 |
21 | import dev.roanh.kps.Main;
22 | import dev.roanh.kps.config.group.LastPanelSettings;
23 |
24 | /**
25 | * Panel showing the time since the last input.
26 | * @author Roan
27 | */
28 | public class LastPanel extends DataPanel{
29 | /**
30 | * Serial ID.
31 | */
32 | private static final long serialVersionUID = -2570027494924539862L;
33 | /**
34 | * Array of time resolutions to use when formatting times.
35 | */
36 | private static final Resolution[] magnitudes = new Resolution[]{Resolution.HOUR, Resolution.MINUTE, Resolution.SECOND, Resolution.MILLIS};
37 | /**
38 | * Last used resolution, used to invalidate cached rendering
39 | * info when the resolution magnitude changes.
40 | */
41 | private int lastResolution = 0;
42 | /**
43 | * The settings for this panel.
44 | */
45 | private LastPanelSettings config;
46 |
47 | /**
48 | * Constructs a new last panel.
49 | * @param config The panel configuration.
50 | */
51 | public LastPanel(LastPanelSettings config){
52 | super(config);
53 | this.config = config;
54 | }
55 |
56 | @Override
57 | protected String getValue(){
58 | if(Main.lastHitTime == -1){
59 | lastResolution = -1;
60 | return "-";
61 | }
62 |
63 | boolean millis = config.showMillis();
64 | long diff = (System.nanoTime() - Main.lastHitTime) / 1000000;
65 | for(int i = 0; i < magnitudes.length; i++){
66 | if(diff >= magnitudes[i].millis || (magnitudes[i] == Resolution.SECOND && !millis)){
67 | String value = "";
68 |
69 | for(int j = magnitudes.length - 1; j > i; j--){
70 | Resolution res = magnitudes[j];
71 | if(j - i < config.getUnitCount() && (res != Resolution.MILLIS || millis)){
72 | value = " " + (diff % res.factor) + res.suffix + value;
73 | }
74 | diff /= res.factor;
75 | }
76 |
77 | if(lastResolution != i){
78 | lastResolution = i;
79 | cache.invalidateValueCache();
80 | }
81 |
82 | return diff + magnitudes[i].suffix + value;
83 | }
84 | }
85 |
86 | //this is impossible unless the time difference somehow goes negative
87 | return "?";
88 | }
89 |
90 | /**
91 | * Helper class with time unit properties.
92 | * @author Roan
93 | */
94 | private static enum Resolution{
95 | /**
96 | * Hour resolution.
97 | */
98 | HOUR(24, 60 * 60 * 1000, "h"),
99 | /**
100 | * Minute resolution.
101 | */
102 | MINUTE(60, 60 * 1000, "m"),
103 | /**
104 | * Second resolution.
105 | */
106 | SECOND(60, 1000, "s"),
107 | /**
108 | * Millisecond resolution.
109 | */
110 | MILLIS(1000, 0, "ms");
111 |
112 | /**
113 | * The factor get from a single unit of this resolution
114 | * to a single unit of one resolution larger.
115 | */
116 | private final int factor;
117 | /**
118 | * The total number of milliseconds in a single unit of this resolution.
119 | */
120 | private final long millis;
121 | /**
122 | * The suffix to use for this resolution.
123 | */
124 | private final String suffix;
125 |
126 | /**
127 | * Constructs a new resolution.
128 | * @param factor The factor up to the next resolution.
129 | * @param millis The total number of milliseconds in one unit.
130 | * @param suffix The suffix for this resolution.
131 | */
132 | private Resolution(int factor, long millis, String suffix){
133 | this.factor = factor;
134 | this.millis = millis;
135 | this.suffix = suffix;
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/panels/MaxPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.panels;
20 |
21 | import dev.roanh.kps.Main;
22 | import dev.roanh.kps.config.group.MaxPanelSettings;
23 |
24 | /**
25 | * Panel used to display the maximum keys pressed per second.
26 | * @author Roan
27 | */
28 | public final class MaxPanel extends DataPanel{
29 | /**
30 | * Serial ID
31 | */
32 | private static final long serialVersionUID = 8816524158873355997L;
33 |
34 | /**
35 | * Constructs a new maximum panel
36 | * @param settings The panel configuration.
37 | */
38 | public MaxPanel(MaxPanelSettings settings){
39 | super(settings);
40 | }
41 |
42 | @Override
43 | protected String getValue(){
44 | return String.valueOf(Main.max);
45 | }
46 | }
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/panels/NowPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.panels;
20 |
21 | import dev.roanh.kps.Main;
22 | import dev.roanh.kps.config.group.CurrentPanelSettings;
23 |
24 | /**
25 | * Panel used to display the current keys pressed per second.
26 | * Note that since the actual 'current' time frame is still on
27 | * going this actually displays the keys per second from the
28 | * previous second.
29 | * @author Roan
30 | */
31 | public final class NowPanel extends DataPanel{
32 | /**
33 | * Serial ID
34 | */
35 | private static final long serialVersionUID = 8816524158873355997L;
36 |
37 | /**
38 | * Constructs a new current panel
39 | * @param settings The panel configuration.
40 | */
41 | public NowPanel(CurrentPanelSettings settings){
42 | super(settings);
43 | }
44 |
45 | @Override
46 | protected String getValue(){
47 | return String.valueOf(Main.prev);
48 | }
49 | }
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/panels/TotPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.panels;
20 |
21 | import dev.roanh.kps.Main;
22 | import dev.roanh.kps.config.group.TotalPanelSettings;
23 |
24 | /**
25 | * Panel used to display the
26 | * total number of keys pressed
27 | * @author Roan
28 | */
29 | public final class TotPanel extends DataPanel{
30 | /**
31 | * Serial ID
32 | */
33 | private static final long serialVersionUID = 5628759695450014071L;
34 |
35 | /**
36 | * Constructs a new total panel
37 | * @param settings The panel configuration.
38 | */
39 | public TotPanel(TotalPanelSettings settings){
40 | super(settings);
41 | }
42 |
43 | @Override
44 | protected String getValue(){
45 | return String.valueOf(Main.hits);
46 | }
47 | }
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/component/ColorPicker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.component;
20 |
21 | import java.awt.event.MouseEvent;
22 | import java.awt.event.MouseListener;
23 | import java.util.function.Consumer;
24 | import java.util.function.Supplier;
25 |
26 | import javax.swing.BorderFactory;
27 | import javax.swing.JColorChooser;
28 | import javax.swing.JPanel;
29 |
30 | import dev.roanh.kps.Main;
31 | import dev.roanh.kps.config.ThemeColor;
32 | import dev.roanh.util.Dialog;
33 |
34 | /**
35 | * Simple color picker implementation.
36 | * @author Roan
37 | */
38 | public class ColorPicker extends JPanel implements MouseListener{
39 | /**
40 | * Serial ID.
41 | */
42 | private static final long serialVersionUID = 3576402284968096657L;
43 | /**
44 | * The function to use to read the current color.
45 | */
46 | private Supplier read;
47 | /**
48 | * The function to use to save a newly selected color.
49 | */
50 | private Consumer write;
51 | /**
52 | * Color chooser instance
53 | */
54 | private final JColorChooser chooser = new JColorChooser();
55 |
56 | /**
57 | * Constructs a new color picker.
58 | * @param read The function to use to read the current color.
59 | * @param write The function to use to save a newly selected color.
60 | * @param live True if the GUI is already live and updates should be reflected in real time.
61 | */
62 | public ColorPicker(Supplier read, Consumer write, boolean live){
63 | this.read = read;
64 | this.write = c->{
65 | write.accept(c);
66 | if(live){
67 | Main.reconfigure();
68 | }
69 | };
70 |
71 | setBorder(BorderFactory.createLoweredBevelBorder());
72 | setBackground(read.get().getColor());
73 | this.addMouseListener(this);
74 | }
75 |
76 | @Override
77 | public void mouseClicked(MouseEvent e){
78 | chooser.setColor(getBackground());
79 | if(Dialog.showSaveDialog(chooser)){
80 | setBackground(chooser.getColor());
81 | write.accept(new ThemeColor(chooser.getColor().getRGB(), read.get().getAlpha()));
82 | }
83 | }
84 |
85 | @Override
86 | public void mousePressed(MouseEvent e){
87 | }
88 |
89 | @Override
90 | public void mouseReleased(MouseEvent e){
91 | }
92 |
93 | @Override
94 | public void mouseEntered(MouseEvent e){
95 | }
96 |
97 | @Override
98 | public void mouseExited(MouseEvent e){
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/dialog/ColorDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.dialog;
20 |
21 | import java.awt.BorderLayout;
22 | import java.awt.GridLayout;
23 |
24 | import javax.swing.JCheckBox;
25 | import javax.swing.JLabel;
26 | import javax.swing.JPanel;
27 | import javax.swing.JSpinner;
28 | import javax.swing.SpinnerNumberModel;
29 |
30 | import dev.roanh.kps.Main;
31 | import dev.roanh.kps.config.ThemeColor;
32 | import dev.roanh.kps.config.group.ThemeSettings;
33 | import dev.roanh.kps.ui.component.ColorPicker;
34 | import dev.roanh.util.Dialog;
35 |
36 | /**
37 | * Dialog used to configure custom theme colors.
38 | * @author Roan
39 | * @see ThemeSettings
40 | */
41 | public class ColorDialog extends JPanel{
42 | /**
43 | * Serial ID.
44 | */
45 | private static final long serialVersionUID = -5867337735121395139L;
46 |
47 | /**
48 | * Creates a new color configuration dialog
49 | * @param config The configuration to update.
50 | * @param live If the GUI is already live and should
51 | * be updated in real time.
52 | */
53 | public ColorDialog(ThemeSettings config, boolean live){
54 | super(new GridLayout(3, 3, 4, 2));
55 |
56 | //enabled
57 | JCheckBox enable = new JCheckBox("", config.hasCustomColors());
58 | enable.addActionListener(e->{
59 | config.setCustomColorsEnabled(enable.isSelected());
60 | if(live){
61 | Main.reconfigure();
62 | }
63 | });
64 |
65 | add(new JLabel("Enable custom colours: "));
66 | add(enable);
67 | add(new JLabel());
68 |
69 | //foreground
70 | JLabel lfg = new JLabel("Foreground colour: ");
71 | ColorPicker cfg = new ColorPicker(config::getCustomForeground, config::setForeground, live);
72 |
73 | JPanel spanelfg = new JPanel(new BorderLayout());
74 | JSpinner sfg = new JSpinner(new SpinnerNumberModel(config.getCustomForeground().getAlpha() * 100.0D, 0.0D, 100.0D, 5.0D));
75 | spanelfg.add(new JLabel("Opacity (%): "), BorderLayout.LINE_START);
76 | spanelfg.add(sfg, BorderLayout.CENTER);
77 | sfg.addChangeListener(e->{
78 | config.setForeground(new ThemeColor(config.getCustomForeground().getRGB(), (float)((double)sfg.getValue() / 100.0D)));
79 | if(live){
80 | Main.reconfigure();
81 | }
82 | });
83 |
84 | add(lfg);
85 | add(cfg);
86 | add(spanelfg);
87 |
88 | //background
89 | JLabel lbg = new JLabel("Background colour: ");
90 | ColorPicker cbg = new ColorPicker(config::getCustomBackground, config::setBackground, live);
91 |
92 | JPanel spanelbg = new JPanel(new BorderLayout());
93 | JSpinner sbg = new JSpinner(new SpinnerNumberModel(config.getCustomBackground().getAlpha() * 100.0D, 0.0D, 100.0D, 5.0D));
94 | spanelbg.add(new JLabel("Opacity (%): "), BorderLayout.LINE_START);
95 | spanelbg.add(sbg, BorderLayout.CENTER);
96 | sbg.addChangeListener(e->{
97 | config.setBackground(new ThemeColor(config.getCustomBackground().getRGB(), (float)((double)sbg.getValue() / 100.0D)));
98 | if(live){
99 | Main.reconfigure();
100 | }
101 | });
102 |
103 | add(lbg);
104 | add(cbg);
105 | add(spanelbg);
106 | }
107 |
108 | /**
109 | * Shows the color configuration dialog
110 | * @param config The configuration to update.
111 | * @param live If the GUI is already live and should
112 | * be updated in real time.
113 | */
114 | public static final void configureColors(ThemeSettings config, boolean live){
115 | boolean enabled = config.hasCustomColors();
116 | ThemeColor foreground = config.getCustomForeground();
117 | ThemeColor background = config.getCustomBackground();
118 | if(!Dialog.showSaveDialog(new ColorDialog(config, live))){
119 | config.setCustomColorsEnabled(enabled);
120 | config.setForeground(foreground);
121 | config.setBackground(background);
122 | if(live){
123 | Main.reconfigure();
124 | }
125 | }
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/dialog/DefaultConfigDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.dialog;
20 |
21 | import java.awt.BorderLayout;
22 | import java.nio.file.InvalidPathException;
23 | import java.nio.file.Path;
24 | import java.nio.file.Paths;
25 | import java.util.Objects;
26 | import java.util.prefs.BackingStoreException;
27 |
28 | import javax.swing.JButton;
29 | import javax.swing.JFormattedTextField;
30 | import javax.swing.JLabel;
31 | import javax.swing.JPanel;
32 | import javax.swing.JTextField;
33 |
34 | import dev.roanh.kps.config.ConfigLoader;
35 | import dev.roanh.kps.config.Configuration;
36 | import dev.roanh.kps.ui.model.FilePathFormatterFactory;
37 | import dev.roanh.util.Dialog;
38 |
39 | /**
40 | * Dialog used to configure the default configuration.
41 | * @author Roan
42 | */
43 | public class DefaultConfigDialog extends JPanel{
44 | /**
45 | * Serial ID.
46 | */
47 | private static final long serialVersionUID = 7089667269158157654L;
48 | /**
49 | * The text field holding the default config.
50 | */
51 | private JTextField selectedFile = new JFormattedTextField(new FilePathFormatterFactory(), Objects.toString(ConfigLoader.getDefaultConfig(), ""));
52 |
53 | /**
54 | * Constructs a new default config dialog.
55 | */
56 | private DefaultConfigDialog(){
57 | super(new BorderLayout(0, 5));
58 |
59 | add(new JLabel("You can configure a default configuration to be opened automatically on launch."), BorderLayout.PAGE_START);
60 | add(new JLabel("Config: "), BorderLayout.LINE_START);
61 | add(selectedFile, BorderLayout.CENTER);
62 |
63 | JButton select = new JButton("Select");
64 | add(select, BorderLayout.LINE_END);
65 | select.addActionListener(e->{
66 | Path file = Dialog.showFileOpenDialog(Configuration.KPS_NEW_EXT);
67 | if(file != null){
68 | selectedFile.setText(file.toAbsolutePath().toString());
69 | }
70 | });
71 | }
72 |
73 | /**
74 | * Shows a dialog to configure the default configuration file to use.
75 | */
76 | public static final void showDefaultConfigDialog(){
77 | DefaultConfigDialog dialog = new DefaultConfigDialog();
78 | try{
79 | switch(Dialog.showDialog(dialog, new String[]{"Save", "Remove Default Config", "Cancel"})){
80 | case 0:
81 | ConfigLoader.setDefaultConfig(Paths.get(dialog.selectedFile.getText()));
82 | break;
83 | case 1:
84 | ConfigLoader.setDefaultConfig(null);
85 | break;
86 | case 2:
87 | default:
88 | break;
89 | }
90 | }catch(BackingStoreException | InvalidPathException e){
91 | e.printStackTrace();
92 | Dialog.showErrorDialog("Failed to save default config, cause: " + e.getMessage());
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/dialog/UpdateRateDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.dialog;
20 |
21 | import java.awt.BorderLayout;
22 | import java.awt.Color;
23 | import java.awt.Component;
24 | import java.awt.GridLayout;
25 |
26 | import javax.swing.DefaultListCellRenderer;
27 | import javax.swing.JComboBox;
28 | import javax.swing.JLabel;
29 | import javax.swing.JList;
30 | import javax.swing.JPanel;
31 |
32 | import dev.roanh.kps.config.Configuration;
33 | import dev.roanh.kps.config.UpdateRate;
34 | import dev.roanh.util.Dialog;
35 |
36 | /**
37 | * Dialog for configuring the update rate of the program.
38 | * @author Roan
39 | */
40 | public class UpdateRateDialog extends JPanel{
41 | /**
42 | * Serial ID.
43 | */
44 | private static final long serialVersionUID = -726535693978900995L;
45 | /**
46 | * The combo box listing available update rates.
47 | */
48 | private JComboBox update = new JComboBox(UpdateRate.values());
49 |
50 | /**
51 | * Constructs a new update rate configuration dialog.
52 | * @param config The config to update.
53 | */
54 | private UpdateRateDialog(Configuration config){
55 | super(new BorderLayout(0, 5));
56 |
57 | JPanel info = new JPanel(new GridLayout(2, 1, 0, 0));
58 | info.add(new JLabel("Here you can change the rate at which"));
59 | info.add(new JLabel("most panels are updated."));
60 |
61 | update.setSelectedItem(config.getUpdateRate());
62 | update.setRenderer(new RateCellRenderer());
63 |
64 | add(info, BorderLayout.PAGE_START);
65 | add(new JLabel("Update rate: "), BorderLayout.WEST);
66 | add(update, BorderLayout.CENTER);
67 | }
68 |
69 | /**
70 | * Shows a dialog to configure the update rate.
71 | * @param config The config to update.
72 | */
73 | public static final void configureUpdateRate(Configuration config){
74 | UpdateRateDialog pconfig = new UpdateRateDialog(config);
75 | if(Dialog.showSaveDialog(pconfig)){
76 | config.setUpdateRate((UpdateRate)pconfig.update.getSelectedItem());
77 | }
78 | }
79 |
80 | /**
81 | * Special cell renderer than colours high and very high update rates.
82 | * @author Roan
83 | */
84 | private static final class RateCellRenderer extends DefaultListCellRenderer{
85 | /**
86 | * Serial ID
87 | */
88 | private static final long serialVersionUID = 1L;
89 |
90 | @Override
91 | public Component getListCellRendererComponent(JList> list, Object value, int index, boolean isSelected, boolean cellHasFocus){
92 | Component item = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
93 |
94 | UpdateRate rate = (UpdateRate)value;
95 | if(rate.isVeryHigh()){
96 | item.setForeground(Color.MAGENTA);
97 | }else if(rate.isHigh()){
98 | item.setForeground(Color.RED);
99 | }
100 |
101 | return item;
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/editor/AvgPanelEditor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.editor;
20 |
21 | import javax.swing.JComboBox;
22 | import javax.swing.JLabel;
23 |
24 | import dev.roanh.kps.Main;
25 | import dev.roanh.kps.config.group.AveragePanelSettings;
26 |
27 | /**
28 | * Editor for the average panel settings.
29 | * @author Roan
30 | * @see AveragePanelSettings
31 | */
32 | public class AvgPanelEditor extends DataPanelEditor{
33 | /**
34 | * Serial ID.
35 | */
36 | private static final long serialVersionUID = -6191919120127582754L;
37 |
38 | /**
39 | * Constructs a new average panel settings editor.
40 | * @param config The settings to update.
41 | * @param live If updates should be reflected in real time.
42 | */
43 | public AvgPanelEditor(AveragePanelSettings config, boolean live){
44 | super(config, live);
45 |
46 | labels.add(new JLabel("Precision: "));
47 | JComboBox values = new JComboBox(new String[]{"No digits beyond the decimal point", "1 digit beyond the decimal point", "2 digits beyond the decimal point", "3 digits beyond the decimal point"});
48 | fields.add(values);
49 | values.setSelectedIndex(config.getPrecision());
50 | values.addActionListener(e->{
51 | config.setPrecision(values.getSelectedIndex());
52 | if(live){
53 | Main.frame.repaint();
54 | }
55 | });
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/editor/CursorGraphEditor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.editor;
20 |
21 | import java.awt.GraphicsDevice;
22 |
23 | import javax.swing.JComboBox;
24 | import javax.swing.JLabel;
25 | import javax.swing.JSpinner;
26 | import javax.swing.SpinnerNumberModel;
27 |
28 | import dev.roanh.kps.Main;
29 | import dev.roanh.kps.config.group.CursorGraphSettings;
30 |
31 | /**
32 | * Editor for cursor graph settings.
33 | * @author Roan
34 | * @see CursorGraphSettings
35 | */
36 | public class CursorGraphEditor extends Editor{
37 | /**
38 | * Serial ID.
39 | */
40 | private static final long serialVersionUID = 2126285185766458287L;
41 |
42 | /**
43 | * Constructs a new editor.
44 | * @param config The configuration to update.
45 | * @param live If updates should be reflected in real time.
46 | */
47 | public CursorGraphEditor(CursorGraphSettings config, boolean live){
48 | super("Graph Settings");
49 |
50 | labels.add(new JLabel("Display: "));
51 | GraphicsDevice[] screens = CursorGraphSettings.getScreens();
52 | String[] screenNames = new String[screens.length];
53 | int selectedIdx = 0;
54 | for(int i = 0; i < screens.length; i++){
55 | GraphicsDevice screen = screens[i];
56 | screenNames[i] = screen.getIDstring() + " (" + screen.getDisplayMode().getWidth() + "x" + screen.getDisplayMode().getHeight() + ")";
57 | if(screen.getIDstring().equals(config.getDisplayId())){
58 | selectedIdx = i;
59 | }
60 | }
61 |
62 | JComboBox screenSelector = new JComboBox(screenNames);
63 | screenSelector.setSelectedIndex(selectedIdx);
64 | fields.add(screenSelector);
65 | screenSelector.addActionListener(e->{
66 | config.setDisplay(screens[screenSelector.getSelectedIndex()].getIDstring());
67 | if(live){
68 | Main.reconfigure();
69 | }
70 | });
71 |
72 | labels.add(new JLabel("Backlog (milliseconds): "));
73 | JSpinner backlog = new JSpinner(new SpinnerNumberModel(config.getBacklog(), 0, Integer.MAX_VALUE, 100));
74 | backlog.addChangeListener(e->config.setBacklog((int)backlog.getValue()));
75 | fields.add(backlog);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/editor/DataPanelEditor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.editor;
20 |
21 | import javax.swing.JComboBox;
22 | import javax.swing.JLabel;
23 | import javax.swing.JTextField;
24 |
25 | import dev.roanh.kps.Main;
26 | import dev.roanh.kps.RenderingMode;
27 | import dev.roanh.kps.config.group.DataPanelSettings;
28 | import dev.roanh.kps.ui.listener.FieldChangeListener;
29 |
30 | /**
31 | * Editor for data panels.
32 | * @author Roan
33 | * @see DataPanelSettings
34 | */
35 | public class DataPanelEditor extends Editor{
36 | /**
37 | * Serial ID.
38 | */
39 | private static final long serialVersionUID = -2982608015931683558L;
40 |
41 | /**
42 | * Constructs a new editor.
43 | * @param config The settings to update.
44 | * @param live If updates should be reflected in real time.
45 | */
46 | public DataPanelEditor(DataPanelSettings config, boolean live){
47 | super("Panel Specific Settings");
48 |
49 | labels.add(new JLabel("Name: "));
50 | JTextField name = new JTextField(config.getName());
51 | fields.add(name);
52 | name.getDocument().addDocumentListener((FieldChangeListener)e->{
53 | config.setName(name.getText());
54 | if(live){
55 | Main.resetPanels();
56 | }
57 | });
58 |
59 | labels.add(new JLabel("Mode: "));
60 | JComboBox mode = new JComboBox(RenderingMode.values());
61 | fields.add(mode);
62 | mode.setSelectedItem(config.getRenderingMode());
63 | mode.addActionListener((e)->{
64 | config.setRenderingMode((RenderingMode)mode.getSelectedItem());
65 | if(live){
66 | Main.resetPanels();
67 | }
68 | });
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/editor/Editor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.editor;
20 |
21 | import java.awt.BorderLayout;
22 | import java.awt.GridLayout;
23 |
24 | import javax.swing.BorderFactory;
25 | import javax.swing.JPanel;
26 |
27 | import dev.roanh.util.Dialog;
28 |
29 | /**
30 | * Base class for setting editors.
31 | * @author Roan
32 | */
33 | public abstract class Editor extends JPanel{
34 | /**
35 | * Serial ID.
36 | */
37 | private static final long serialVersionUID = -3685233769737234444L;
38 | /**
39 | * Panel containing setting names.
40 | */
41 | protected JPanel labels = new JPanel(new GridLayout(0, 1, 0, 2));
42 | /**
43 | * Panel containing setting editors.
44 | */
45 | protected JPanel fields = new JPanel(new GridLayout(0, 1, 0, 2));
46 |
47 | /**
48 | * Constructs a new editor with the given title.
49 | * @param title The UI title to show.
50 | */
51 | protected Editor(String title){
52 | super(new BorderLayout());
53 | this.setBorder(BorderFactory.createTitledBorder(title));
54 | this.add(labels, BorderLayout.LINE_START);
55 | this.add(fields, BorderLayout.CENTER);
56 | }
57 |
58 | /**
59 | * Shows the given editor in a dialog.
60 | * @param editor The editor to show.
61 | */
62 | public static final void showEditor(Editor editor){
63 | Dialog.showMessageDialog(editor);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/editor/EditorProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.editor;
20 |
21 | /**
22 | * Interface for objects that can show an editor to edit their properties.
23 | * @author Roan
24 | */
25 | public abstract interface EditorProvider{
26 |
27 | /**
28 | * Shows an editor to edit advanced panel properties.
29 | * @param live True if the GUI is already live and
30 | * updates should be reflected in real time.
31 | */
32 | public abstract void showEditor(boolean live);
33 | }
34 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/editor/KeyPanelEditor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.editor;
20 |
21 | import javax.swing.JCheckBox;
22 | import javax.swing.JLabel;
23 |
24 | import dev.roanh.kps.Main;
25 | import dev.roanh.kps.config.group.KeyPanelSettings;
26 |
27 | /**
28 | * Editor for key panel settings.
29 | * @author Roan
30 | * @see KeyPanelSettings
31 | */
32 | public class KeyPanelEditor extends DataPanelEditor{
33 | /**
34 | * Serial ID.
35 | */
36 | private static final long serialVersionUID = 8336531868831372183L;
37 |
38 | /**
39 | * Constructs a new editor.
40 | * @param config The configuration to update.
41 | * @param live If updates should be reflected in real time.
42 | */
43 | public KeyPanelEditor(KeyPanelSettings config, boolean live){
44 | super(config, live);
45 |
46 | labels.add(new JLabel("Visible: "));
47 | JCheckBox visible = new JCheckBox("(invisible keys only track input)", config.isVisible());
48 | fields.add(visible);
49 | visible.addActionListener(e->{
50 | config.setVisible(visible.isSelected());
51 | Main.reconfigure();
52 | });
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/editor/LastPanelEditor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.editor;
20 |
21 | import javax.swing.JCheckBox;
22 | import javax.swing.JLabel;
23 | import javax.swing.JSpinner;
24 | import javax.swing.SpinnerNumberModel;
25 |
26 | import dev.roanh.kps.Main;
27 | import dev.roanh.kps.config.group.LastPanelSettings;
28 |
29 | /**
30 | * Editor for the last panel settings.
31 | * @author Roan
32 | * @see LastPanelSettings
33 | */
34 | public class LastPanelEditor extends DataPanelEditor{
35 | /**
36 | * Serial ID.
37 | */
38 | private static final long serialVersionUID = -6191919120127582754L;
39 |
40 | /**
41 | * Constructs a new last panel settings editor.
42 | * @param config The settings to update.
43 | * @param live If updates should be reflected in real time.
44 | */
45 | public LastPanelEditor(LastPanelSettings config, boolean live){
46 | super(config, live);
47 |
48 | labels.add(new JLabel("Time units: "));
49 | JSpinner units = new JSpinner(new SpinnerNumberModel(config.getUnitCount(), 1, 4, 1));
50 | fields.add(units);
51 | units.addChangeListener(e->{
52 | config.setUnitCount((int)units.getValue());
53 | if(live){
54 | Main.resetPanels();
55 | }
56 | });
57 |
58 | labels.add(new JLabel("Show milliseconds: "));
59 | JCheckBox millis = new JCheckBox("", config.showMillis());
60 | fields.add(millis);
61 | millis.addActionListener(e->{
62 | config.setShowMillis(millis.isSelected());
63 | if(live){
64 | Main.resetPanels();
65 | }
66 | });
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/editor/LineGraphEditor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.editor;
20 |
21 | import javax.swing.JCheckBox;
22 | import javax.swing.JLabel;
23 | import javax.swing.JSpinner;
24 | import javax.swing.SpinnerNumberModel;
25 |
26 | import dev.roanh.kps.Main;
27 | import dev.roanh.kps.config.group.LineGraphSettings;
28 |
29 | /**
30 | * Editor for line graph settings.
31 | * @author Roan
32 | * @see LineGraphSettings
33 | */
34 | public class LineGraphEditor extends Editor{
35 | /**
36 | * Serial ID.
37 | */
38 | private static final long serialVersionUID = 2459364509023481281L;
39 |
40 | /**
41 | * Constructs a new editor.
42 | * @param config The configuration to update.
43 | * @param live If updates should be reflected in real time.
44 | */
45 | public LineGraphEditor(LineGraphSettings config, boolean live){
46 | super("Graph Settings");
47 |
48 | labels.add(new JLabel("Backlog (milliseconds): "));
49 | JSpinner backlog = new JSpinner(new SpinnerNumberModel(config.getBacklog(), 2, Integer.MAX_VALUE, 100));
50 | backlog.addChangeListener(e->config.setBacklog((int)backlog.getValue()));
51 | fields.add(backlog);
52 |
53 | labels.add(new JLabel("Maximum (Y cap): "));
54 | JSpinner max = new JSpinner(new SpinnerNumberModel(config.getMaxValue(), 1, Integer.MAX_VALUE, 1));
55 | fields.add(max);
56 | max.addChangeListener(e->{
57 | config.setMaxValue((int)max.getValue());
58 | Main.resetGraphs();
59 | });
60 |
61 | labels.add(new JLabel("Show average: "));
62 | JCheckBox avg = new JCheckBox("", config.isAverageVisible());
63 | fields.add(avg);
64 | avg.addActionListener(e->{
65 | config.setAverageVisible(avg.isSelected());
66 | Main.frame.repaint();
67 | });
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/listener/FieldChangeListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.listener;
20 |
21 | import javax.swing.event.DocumentEvent;
22 | import javax.swing.event.DocumentListener;
23 |
24 | /**
25 | * Document listener that activates on any event.
26 | * @author Roan
27 | */
28 | @FunctionalInterface
29 | public abstract interface FieldChangeListener extends DocumentListener{
30 |
31 | /**
32 | * Called when the document is modified using an
33 | * insert, remove, or change operation.
34 | * @param e The document event that occurred.
35 | */
36 | public abstract void onChange(DocumentEvent e);
37 |
38 | @Override
39 | public default void insertUpdate(DocumentEvent e){
40 | onChange(e);
41 | }
42 |
43 | @Override
44 | public default void removeUpdate(DocumentEvent e){
45 | onChange(e);
46 | }
47 |
48 | @Override
49 | public default void changedUpdate(DocumentEvent e){
50 | onChange(e);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/listener/MainWindowListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.listener;
20 |
21 | import java.awt.event.WindowEvent;
22 | import java.awt.event.WindowListener;
23 |
24 | import dev.roanh.kps.Main;
25 |
26 | /**
27 | * Listener for the main window so cleanup and exit tasks run properly.
28 | * @author Roan
29 | */
30 | public class MainWindowListener implements WindowListener{
31 |
32 | @Override
33 | public void windowOpened(WindowEvent e){
34 | if(!Main.config.getFramePosition().hasPosition()){
35 | e.getWindow().setLocationRelativeTo(null);
36 | }
37 | }
38 |
39 | @Override
40 | public void windowClosing(WindowEvent e){
41 | Main.exit();
42 | }
43 |
44 | @Override
45 | public void windowClosed(WindowEvent e){
46 | }
47 |
48 | @Override
49 | public void windowIconified(WindowEvent e){
50 | }
51 |
52 | @Override
53 | public void windowDeiconified(WindowEvent e){
54 | }
55 |
56 | @Override
57 | public void windowActivated(WindowEvent e){
58 | }
59 |
60 | @Override
61 | public void windowDeactivated(WindowEvent e){
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/model/DynamicInteger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.model;
20 |
21 | import java.util.Objects;
22 | import java.util.function.Supplier;
23 |
24 | /**
25 | * Custom comparable to use as a variable
26 | * bound on a JSpinner
27 | * @author Roan
28 | * @see Number
29 | * @see Comparable
30 | */
31 | public class DynamicInteger extends Number implements Comparable{
32 | /**
33 | * Serial ID
34 | */
35 | private static final long serialVersionUID = 7783953216941858736L;
36 | /**
37 | * The value of this variable
38 | */
39 | private Supplier bound;
40 |
41 | /**
42 | * Constructs a new DynamicInteger
43 | * with the given variable bound
44 | * @param bound The variable value
45 | * for this DynamicInteger
46 | */
47 | public DynamicInteger(Supplier bound){
48 | this.bound = bound;
49 | }
50 |
51 | @Override
52 | public int compareTo(Integer o){
53 | return bound.get().compareTo(o);
54 | }
55 |
56 | @Override
57 | public boolean equals(Object obj){
58 | if(obj instanceof Number){
59 | return bound.get() == ((Number)obj).intValue();
60 | }else{
61 | return false;
62 | }
63 | }
64 |
65 | @Override
66 | public int hashCode(){
67 | return Objects.hash(bound.get());
68 | }
69 |
70 | @Override
71 | public int intValue(){
72 | return bound.get();
73 | }
74 |
75 | @Override
76 | public long longValue(){
77 | return bound.get();
78 | }
79 |
80 | @Override
81 | public float floatValue(){
82 | return bound.get();
83 | }
84 |
85 | @Override
86 | public double doubleValue(){
87 | return bound.get();
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/model/EndNumberModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.model;
20 |
21 | import dev.roanh.kps.layout.LayoutValidator.FieldListener;
22 |
23 | /**
24 | * SpecialNumberModel with end
25 | * as the special value
26 | * @author Roan
27 | * @see SpecialNumberModel
28 | */
29 | public class EndNumberModel extends SpecialNumberModel{
30 | /**
31 | * Serial ID
32 | */
33 | private static final long serialVersionUID = -2971851618376128616L;
34 |
35 | /**
36 | * Constructs a new EndNumberModel with the
37 | * given initial value, validator and listener
38 | * @param value The initial model value
39 | * @param validator The validator to use to validate value changes
40 | * @param listener The listener to inform of value changes
41 | */
42 | public EndNumberModel(int value, FieldListener validator, ValueChangeListener listener){
43 | super(value, "end", validator, listener);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/model/FilePathFormatterFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.model;
20 |
21 | import java.nio.file.InvalidPathException;
22 | import java.nio.file.Paths;
23 | import java.text.ParseException;
24 |
25 | import javax.swing.JFormattedTextField;
26 | import javax.swing.JFormattedTextField.AbstractFormatter;
27 | import javax.swing.JFormattedTextField.AbstractFormatterFactory;
28 |
29 | /**
30 | * Formatter factory that creates a formatter that rejects
31 | * content containing characters that are illegal in file paths.
32 | *
33 | * @author Roan
34 | */
35 | public class FilePathFormatterFactory extends AbstractFormatterFactory{
36 |
37 | @Override
38 | public AbstractFormatter getFormatter(JFormattedTextField tf){
39 | return new AbstractFormatter(){
40 | /**
41 | * Serial ID
42 | */
43 | private static final long serialVersionUID = 5956641218097576666L;
44 |
45 | @Override
46 | public Object stringToValue(String text) throws ParseException{
47 | if(isValidPath(text)){
48 | return text;
49 | }else{
50 | throw new ParseException("Invalid character found", 0);
51 | }
52 | }
53 |
54 | @Override
55 | public String valueToString(Object value) throws ParseException{
56 | return value instanceof String ? (String)value : null;
57 | }
58 | };
59 | }
60 |
61 | /**
62 | * Tests if there are any invalid characters in the given file path.
63 | * @param path The file path to check.
64 | * @return True if the file path does not contain any invalid characters.
65 | */
66 | public static final boolean isValidPath(String path){
67 | try{
68 | Paths.get(path);
69 | return true;
70 | }catch(InvalidPathException e){
71 | return false;
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/model/MaxNumberModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.model;
20 |
21 | import dev.roanh.kps.layout.LayoutValidator.FieldListener;
22 |
23 | /**
24 | * SpecialNumberModel with max
25 | * as the special value
26 | * @author Roan
27 | * @see SpecialNumberModel
28 | */
29 | public class MaxNumberModel extends SpecialNumberModel{
30 | /**
31 | * Serial ID
32 | */
33 | private static final long serialVersionUID = -7707259211999223448L;
34 |
35 | /**
36 | * Constructs a new MaxNumberModel with the
37 | * given initial value, validator and listener
38 | * @param value The initial model value
39 | * @param validator The validator to use to validate value changes
40 | * @param listener The listener to inform of value changes
41 | */
42 | public MaxNumberModel(int value, FieldListener validator, ValueChangeListener listener){
43 | super(value, "max", validator, listener);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/model/SpecialNumberModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.model;
20 |
21 | import javax.swing.AbstractSpinnerModel;
22 |
23 | import dev.roanh.kps.layout.LayoutValidator.FieldListener;
24 |
25 | /**
26 | * Special number model for spinner that allows
27 | * for one custom value to be added. This custom
28 | * value will take the position of the value -1.
29 | * @author Roan
30 | * @see EndNumberModel
31 | * @see MaxNumberModel
32 | */
33 | public class SpecialNumberModel extends AbstractSpinnerModel{
34 | /**
35 | * Serial ID
36 | */
37 | private static final long serialVersionUID = 4181535442197142288L;
38 | /**
39 | * The current value of this spinner
40 | */
41 | private int value;
42 | /**
43 | * The name of the special value
44 | */
45 | private final String special;
46 | /**
47 | * The listener to notify of value changes
48 | */
49 | private ValueChangeListener listener;
50 | /**
51 | * The validator to use to check the validity of new values
52 | */
53 | private FieldListener validator;
54 |
55 | /**
56 | * Constructs a new SpecialNumberModel with
57 | * the given arguments.
58 | * @param value The initial value for the model
59 | * @param special The name of the special value
60 | * @param validator The validator to use
61 | * @param listener The listener to notify of value changes
62 | */
63 | public SpecialNumberModel(int value, String special, FieldListener validator, ValueChangeListener listener){
64 | this.value = value;
65 | this.special = special;
66 | this.validator = validator;
67 | validator.setModel(this);
68 | this.listener = listener;
69 | }
70 |
71 | /**
72 | * Checks to see if the current value
73 | * is the special (-1) value
74 | * @return Whether or not the special
75 | * value is currently selected
76 | */
77 | public boolean isSpecialValueSelected(){
78 | return value == -1;
79 | }
80 |
81 | @Override
82 | public void setValue(Object value){
83 | this.value = ((String)value).equals(special) ? -1 : Integer.parseInt((String)value);
84 | listener.valueChanged(this.value);
85 | fireStateChanged();
86 | }
87 |
88 | @Override
89 | public Object getNextValue(){
90 | return String.valueOf(value + 1);
91 | }
92 |
93 | @Override
94 | public Object getPreviousValue(){
95 | if(value <= 0){
96 | if(validator.specialValid()){
97 | return special;
98 | }else{
99 | return String.valueOf(value);
100 | }
101 | }else{
102 | return String.valueOf(value - 1);
103 | }
104 | }
105 |
106 | @Override
107 | public Object getValue(){
108 | return value == -1 ? special : String.valueOf(value);
109 | }
110 |
111 | /**
112 | * Listener that is notified of value changes
113 | * for a SpecialNumberModel
114 | * @author Roan
115 | */
116 | @FunctionalInterface
117 | public static abstract interface ValueChangeListener{
118 | /**
119 | * Called when a new value was requested
120 | * @param newValue The requested new value
121 | */
122 | public abstract void valueChanged(int newValue);
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/KeysPerSecond/src/dev/roanh/kps/ui/model/SpecialNumberModelEditor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.ui.model;
20 |
21 | import javax.swing.JFormattedTextField;
22 | import javax.swing.JSpinner;
23 | import javax.swing.JSpinner.DefaultEditor;
24 | import javax.swing.JTextField;
25 |
26 | /**
27 | * Simple editor that allows edits in the default editor field.
28 | * @author Roan
29 | */
30 | public class SpecialNumberModelEditor extends DefaultEditor{
31 | /**
32 | * Serial ID.
33 | */
34 | private static final long serialVersionUID = 7262846110148041166L;
35 |
36 | /**
37 | * Constructs a new special number model editor for the given spinner.
38 | * @param spinner The spinner to create an editor for.
39 | */
40 | public SpecialNumberModelEditor(JSpinner spinner){
41 | super(spinner);
42 |
43 | JFormattedTextField disp = getTextField();
44 | disp.setEditable(true);
45 | disp.setHorizontalAlignment(JTextField.RIGHT);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/KeysPerSecond/test/config87nodefault.kps:
--------------------------------------------------------------------------------
1 | version: v8.7
2 |
3 | # General
4 | showMax: false
5 | showAvg: false
6 | showCur: false
7 | showTotal: false
8 | showKeys: true
9 | overlay: true
10 | trackAllKeys: true
11 | trackAllButtons: true
12 | updateRate: 250
13 | precision: 0
14 | enableKeyModifierCombinations: true
15 |
16 | # Graph
17 | graphEnabled: false
18 | graphBacklog: 1800
19 | graphAverage: true
20 |
21 | # Colors
22 | customColors: true
23 | foregroundColor: [r=1,g=2,b=3]
24 | backgroundColor: [r=104,g=105,b=106]
25 | foregroundOpacity: 0.0
26 | backgroundOpacity: 0.5
27 |
28 | # Command keys
29 | keyResetStats: unbound
30 | keyExit: [keycode=2,ctrl=false,alt=true]
31 | keyResetTotals: [keycode=3,ctrl=false,alt=true]
32 | keyHide: [keycode=4,ctrl=false,alt=true]
33 | keyPause: [keycode=5,ctrl=false,alt=true]
34 | keyReload: [keycode=6,ctrl=false,alt=true]
35 |
36 | # Layout
37 | maxX: 23
38 | maxY: 0
39 | maxWidth: 2
40 | maxHeight: 3
41 | maxMode: VERTICAL
42 | avgX: 21
43 | avgY: 0
44 | avgWidth: 2
45 | avgHeight: 3
46 | avgMode: VERTICAL
47 | curX: 25
48 | curY: 0
49 | curWidth: 2
50 | curHeight: 3
51 | curMode: VERTICAL
52 | totX: 25
53 | totY: 0
54 | totWidth: 2
55 | totHeight: 3
56 | totMode: VERTICAL
57 | graphX: 0
58 | graphY: -1
59 | graphWidth: 40
60 | graphHeight: 7
61 | graphMode: INLINE
62 | cellSize: 34
63 | borderOffset: 4
64 |
65 | # Stats auto saving
66 | autoSaveStats: true
67 | statsDest: C:\Users\test
68 | statsFormat: test
69 | statsSaveInterval: 100
70 | saveStatsOnExit: true
71 | loadStatsOnLaunch: true
72 | statsSaveFile: C:\Users\RoanH\alsotest
73 |
74 | # Keys
75 | keys:
76 | - [keycode=1,x=3,y=5,width=7,height=10,mode=VALUE_ONLY,visible=false,name="R"]
77 | - [keycode=2,x=4,y=6,width=8,height=11,mode=VERTICAL,visible=true,name="S"]
--------------------------------------------------------------------------------
/KeysPerSecond/test/config88.kps:
--------------------------------------------------------------------------------
1 | version: v8.8
2 |
3 | # General
4 | overlay: false
5 | trackAllKeys: false
6 | trackAllButtons: false
7 | updateRate: 100
8 | enableKeyModifierCombinations: false
9 | windowed: false
10 |
11 | frame:
12 | x: 100
13 | y: 90
14 |
15 | theme:
16 | customColors: false
17 | foreground: #00FFFF
18 | background: #000000
19 |
20 | commands:
21 | resetStats: 1114137
22 | exit: 1114134
23 | resetTotals: 1114135
24 | hide: 1114133
25 | pause: 1114132
26 | reload: 1114131
27 |
28 | layout:
29 | cellSize: 22
30 | borderOffset: 2
31 |
32 | statsSaving:
33 | autoSave: false
34 | autoDestination: C:\Users\RoanH
35 | autoFormat: 'kps stats' yyyy-MM-dd HH.mm.ss'.kpsstats'
36 | autoInterval: 600000
37 | saveOnExit: false
38 | loadOnLaunch: false
39 | saveFile: C:\Users\RoanH\stats.kpsstats
40 |
41 | graphs:
42 | - name: KPS
43 | x: 1
44 | y: 2
45 | width: 5
46 | height: 8
47 | showAvg: false
48 | backlog: 45
49 | max: 2147483647
50 |
51 | panels:
52 | - type: max
53 | x: 6
54 | y: 3
55 | width: 5
56 | height: 1
57 | mode: VALUE_ONLY
58 | name: NMAX
59 | - type: avg
60 | x: 9
61 | y: 8
62 | width: 7
63 | height: 6
64 | mode: VALUE_ONLY
65 | name: average
66 | precision: 2
67 | - type: current
68 | x: 0
69 | y: 9
70 | width: 4
71 | height: 5
72 | mode: VALUE_ONLY
73 | name: kps
74 | - type: total
75 | x: 1
76 | y: 1
77 | width: 2
78 | height: 2
79 | mode: VALUE_ONLY
80 | name: Total Panel
81 |
82 | keys:
83 | - keycode: 1048606
84 | x: 13
85 | y: 0
86 | width: 2
87 | height: 3
88 | mode: VALUE_ONLY
89 | visible: true
90 | name: A
91 | - keycode: 1048607
92 | x: 12
93 | y: 9
94 | width: 6
95 | height: 7
96 | mode: VALUE_ONLY
97 | visible: false
98 | name: B
99 |
--------------------------------------------------------------------------------
/KeysPerSecond/test/dev/roanh/kps/config/UpdateRateTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config;
20 |
21 | import static org.junit.jupiter.api.Assertions.assertEquals;
22 |
23 | import org.junit.jupiter.api.Test;
24 |
25 | public class UpdateRateTest{
26 |
27 | @Test
28 | public void testDivisible(){
29 | for(UpdateRate rate : UpdateRate.values()){
30 | assertEquals(0, 1000 % rate.getRate());
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/KeysPerSecond/test/dev/roanh/kps/config/VersionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config;
20 |
21 | import static org.junit.jupiter.api.Assertions.assertEquals;
22 | import static org.junit.jupiter.api.Assertions.assertFalse;
23 | import static org.junit.jupiter.api.Assertions.assertNotEquals;
24 | import static org.junit.jupiter.api.Assertions.assertTrue;
25 |
26 | import org.junit.jupiter.api.Test;
27 |
28 | public class VersionTest{
29 |
30 | @Test
31 | public void beforeDirect(){
32 | Version base = new Version(4, 6);
33 |
34 | assertTrue(base.isBefore(5, 6));
35 | assertFalse(base.isBefore(4, 5));
36 | assertFalse(base.isBefore(4, 6));
37 | assertTrue(base.isBefore(6, 0));
38 | assertTrue(base.isBefore(4, 7));
39 | assertFalse(base.isBefore(3, 7));
40 | }
41 |
42 | @Test
43 | public void beforeCompare(){
44 | Version base = new Version(4, 6);
45 |
46 | assertTrue(base.isBefore(new Version(5, 6)));
47 | assertFalse(base.isBefore(new Version(4, 5)));
48 | assertFalse(base.isBefore(new Version(4, 6)));
49 | assertTrue(base.isBefore(new Version(6, 0)));
50 | assertTrue(base.isBefore(new Version(4, 7)));
51 | assertFalse(base.isBefore(new Version(3, 7)));
52 | assertFalse(base.isBefore(Version.UNKNOWN));
53 | assertTrue(Version.UNKNOWN.isBefore(0, 0));
54 | }
55 |
56 | @Test
57 | public void stringTest(){
58 | assertEquals("v8.4", new Version(8, 4).toString());
59 | assertEquals("unknown", Version.UNKNOWN.toString());
60 | }
61 |
62 | @Test
63 | public void parseTest(){
64 | assertEquals(new Version(4, 5), Version.parse("4.5"));
65 | assertEquals(new Version(5, 9), Version.parse("v5.9"));
66 | assertNotEquals(new Version(4, 5), Version.parse("3.5"));
67 | assertEquals(Version.UNKNOWN, Version.parse("ver6.7"));
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/KeysPerSecond/test/dev/roanh/kps/config/setting/ColorSettingTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * KeysPerSecond: An open source input statistics displayer.
3 | * Copyright (C) 2017 Roan Hofland (roan@roanh.dev). All rights reserved.
4 | * GitHub Repository: https://github.com/RoanH/KeysPerSecond
5 | *
6 | * KeysPerSecond is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * KeysPerSecond is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package dev.roanh.kps.config.setting;
20 |
21 | import static org.junit.jupiter.api.Assertions.assertEquals;
22 | import static org.junit.jupiter.api.Assertions.assertFalse;
23 | import static org.junit.jupiter.api.Assertions.assertTrue;
24 |
25 | import org.junit.jupiter.api.Test;
26 |
27 | import dev.roanh.kps.config.ThemeColor;
28 |
29 | public class ColorSettingTest{
30 |
31 | @Test
32 | public void writeTest(){
33 | ColorSetting color = new ColorSetting("test", new ThemeColor(0, 0, 0, 255));
34 |
35 | assertEquals("Setting[test: #000000]", color.toString());
36 |
37 | color.update(new ThemeColor(15, 255, 255, 3));
38 | assertEquals("Setting[test: #0FFFFF03]", color.toString());
39 |
40 | color.update(new ThemeColor(128, 255, 16, 3));
41 | assertEquals("Setting[test: #80FF1003]", color.toString());
42 |
43 | color.update(new ThemeColor(128, 255, 16, 255));
44 | assertEquals("Setting[test: #80FF10]", color.toString());
45 |
46 | color.update(new ThemeColor(255, 255, 16, 128));
47 | assertEquals("Setting[test: #FFFF1080]", color.toString());
48 | }
49 |
50 | @Test
51 | public void parseTest(){
52 | ColorSetting color = new ColorSetting("test", new ThemeColor(0, 0, 0, 255));
53 |
54 | assertFalse(color.parse("#FFFFFF"));
55 | assertEquals(new ThemeColor(255, 255, 255, 255), color.getValue());
56 |
57 | assertFalse(color.parse("#FFFF1080"));
58 | assertEquals(new ThemeColor(255, 255, 16, 128), color.getValue());
59 |
60 | assertFalse(color.parse("[r=0,g=255,b=255]"));
61 | assertEquals(new ThemeColor(0, 255, 255, 128), color.getValue());
62 |
63 | assertTrue(color.parse("[r=0,g=300,b=255]"));
64 | color.update(new ThemeColor(color.getValue().getRGB(), 255));
65 | assertEquals(new ThemeColor(0, 0, 0, 255), color.getValue());
66 |
67 | assertTrue(color.parse("[r=300,g=0,b=255]"));
68 | assertEquals(new ThemeColor(0, 0, 0, 255), color.getValue());
69 |
70 | assertTrue(color.parse("[r=40,g=0,b=300]"));
71 | assertEquals(new ThemeColor(0, 0, 0, 255), color.getValue());
72 |
73 | assertTrue(color.parse("something"));
74 | assertEquals(new ThemeColor(0, 0, 0, 255), color.getValue());
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/KeysPerSecond/test/latestnodefault.kps:
--------------------------------------------------------------------------------
1 | version: v8.9
2 |
3 | # General
4 | overlay: true
5 | trackAllKeys: true
6 | trackAllButtons: true
7 | updateRate: 250
8 | enableKeyModifierCombinations: true
9 | windowed: true
10 |
11 | theme:
12 | customColors: true
13 | foreground: #01020300
14 | background: #68696A00
15 |
16 | commands:
17 | resetStats: unbound
18 | exit: 1179650
19 | resetTotals: 1179651
20 | hide: 1179652
21 | pause: 1179653
22 | reload: 1179654
23 |
24 | layout:
25 | cellSize: 34
26 | borderOffset: 4
27 |
28 | statsSaving:
29 | autoSave: true
30 | autoDestination: C:\Users\test
31 | autoFormat: test
32 | autoInterval: 100
33 | saveOnExit: true
34 | loadOnLaunch: true
35 | saveFile: C:\Users\RoanH\alsotest
36 |
37 | graphs:
38 | - type: line
39 | name: Line Graph
40 | x: 1
41 | y: 2
42 | width: 5
43 | height: 8
44 | showAvg: false
45 | backlog: 45
46 | max: 20
47 | - type: cursor
48 | name: Cursor Graph
49 | x: 5
50 | y: 4
51 | width: 8
52 | height: 7
53 | display: \Display1
54 | backlog: 1234
55 |
56 | panels:
57 | - type: max
58 | name: NMAX
59 | x: 6
60 | y: 3
61 | width: 5
62 | height: 1
63 | mode: VALUE_ONLY
64 | - type: avg
65 | name: average
66 | x: 9
67 | y: 8
68 | width: 7
69 | height: 6
70 | mode: VALUE_ONLY
71 | precision: 2
72 | - type: current
73 | name: kps
74 | x: 0
75 | y: 9
76 | width: 4
77 | height: 5
78 | mode: VALUE_ONLY
79 | - type: total
80 | name: Total Panel
81 | x: 1
82 | y: 1
83 | width: 5
84 | height: 2
85 | mode: VALUE_ONLY
86 | - type: last
87 | name: Last
88 | x: 66
89 | y: 77
90 | width: 3
91 | height: 6
92 | mode: DIAGONAL1
93 | units: 2
94 | showMillis: true
95 |
96 | keys:
97 | - keycode: 1048606
98 | name: A
99 | x: 13
100 | y: 0
101 | width: 2
102 | height: 3
103 | mode: VALUE_ONLY
104 | visible: true
105 | - keycode: 1048607
106 | name: B
107 | x: 12
108 | y: 9
109 | width: 6
110 | height: 7
111 | mode: VERTICAL
112 | visible: false
113 |
--------------------------------------------------------------------------------
/KeysPerSecond/test/legacy.kps:
--------------------------------------------------------------------------------
1 | # General
2 | showMax: true
3 | showAvg: true
4 | showCur: true
5 | showTotal: true
6 | showKeys: true
7 | overlay: false
8 | trackAllKeys: false
9 | trackAllButtons: false
10 | updateRate: 100
11 | precision: 0
12 | enableKeyModifierCombinations: false
13 |
14 | # Position
15 | position: [x=100,y=90]
16 |
17 | # Graph
18 | graphEnabled: true
19 | graphBacklog: 1800
20 | graphAverage: true
21 |
22 | # Colors
23 | customColors: false
24 | foregroundColor: [r=0,g=255,b=255]
25 | backgroundColor: [r=0,g=0,b=0]
26 | foregroundOpacity: 1.0
27 | backgroundOpacity: 1.0
28 |
29 | # Command keys
30 | keyResetStats: [keycode=25,ctrl=true,alt=false]
31 | keyExit: [keycode=22,ctrl=true,alt=false]
32 | keyResetTotals: [keycode=23,ctrl=true,alt=false]
33 | keyHide: [keycode=21,ctrl=true,alt=false]
34 | keyPause: [keycode=20,ctrl=true,alt=false]
35 | keyReload: [keycode=19,ctrl=true,alt=false]
36 |
37 | # Layout
38 | maxX: 23
39 | maxY: 0
40 | maxWidth: 2
41 | maxHeight: 3
42 | maxMode: VERTICAL
43 | avgX: 21
44 | avgY: 0
45 | avgWidth: 2
46 | avgHeight: 3
47 | avgMode: VERTICAL
48 | curX: 25
49 | curY: 0
50 | curWidth: 2
51 | curHeight: 3
52 | curMode: VERTICAL
53 | totX: 25
54 | totY: 0
55 | totWidth: 2
56 | totHeight: 3
57 | totMode: VERTICAL
58 | graphX: 0
59 | graphY: -1
60 | graphWidth: 40
61 | graphHeight: 7
62 | graphMode: INLINE
63 | cellSize: 22
64 | borderOffset: 2
65 |
66 | # Stats auto saving
67 | autoSaveStats: false
68 | statsDest: C:\Users\RoanH
69 | statsFormat: 'kps stats' yyyy-MM-dd HH.mm.ss'.kpsstats'
70 | statsSaveInterval: 600000
71 |
72 | # Keys
73 | keys:
74 | - [keycode=1048606,x=13,y=0,width=2,height=3,mode=VERTICAL,visible=true,name="A"]
75 | - [keycode=1048607,x=15,y=0,width=2,height=3,mode=VERTICAL,visible=true,name="S"]
76 | - [keycode=1048615,x=17,y=0,width=2,height=3,mode=VERTICAL,visible=true,name=";"]
77 | - [keycode=1048616,x=19,y=0,width=2,height=3,mode=VERTICAL,visible=true,name="""]
78 | - [keycode=1048593,x=11,y=0,width=2,height=3,mode=VERTICAL,visible=true,name="W"]
79 | - [keycode=1048594,x=9,y=0,width=2,height=3,mode=VERTICAL,visible=true,name="E"]
80 |
--------------------------------------------------------------------------------