-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
238 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
license_text='/* | ||
* Copyright (c) 2024, Alexander Rziha | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/' | ||
|
||
# Target directory | ||
target_dir="src" | ||
|
||
# Loop through all .java files in the target directory and its subdirectories | ||
find "$target_dir" -type f -name "*.java" | while read file; do | ||
|
||
# Check if file exists | ||
if [ -f "$file" ]; then | ||
# Check if license text already exists | ||
if ! grep -qF "$license_text" "$file"; then | ||
# Prepend license text | ||
echo "$license_text" | cat - "$file" > temp_file && mv temp_file "$file" | ||
echo "License comment added to $file" | ||
else | ||
echo "License comment already exists in $file (skipped)" | ||
fi | ||
fi | ||
done | ||
|
||
echo "Checked all Java files and added the license text" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,82 @@ | ||
/* | ||
* Copyright (c) 2024, Alexander Rziha | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package at.rziha.jsaveexam; | ||
|
||
import at.rziha.jsaveexam.webpage.BlackedOutWindow; | ||
import at.rziha.jsaveexam.webpage.WebPageLoader; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class JSaveExam { | ||
public static void main(String[] args) { | ||
if (args == null || args.length == 0) { | ||
new JSaveExam(null); | ||
return; | ||
} | ||
|
||
String url = null; | ||
|
||
for (String arg : args) { | ||
if (arg.startsWith("--url=")) | ||
{ | ||
url = arg.substring("--url=".length()); | ||
} | ||
} | ||
|
||
new JSaveExam(url); | ||
} | ||
|
||
private GraphicsDevice defaultGraphicsDefault = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); | ||
|
||
private List<GraphicsDevice> notMainDisplay = new ArrayList<>(); | ||
|
||
public JSaveExam(String url) { | ||
if (url == null || url.isEmpty()) | ||
url = "https://html5test.co/"; | ||
|
||
int test = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length; | ||
|
||
if (GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length > 1) { | ||
for (GraphicsDevice graphicsDevice : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) { | ||
if (graphicsDevice != defaultGraphicsDefault) | ||
notMainDisplay.add(graphicsDevice); | ||
} | ||
} | ||
|
||
String finalUrl = url; | ||
SwingUtilities.invokeLater(() -> { | ||
WebPageLoader webPageLoader = new WebPageLoader(finalUrl); | ||
webPageLoader.setVisible(true); | ||
defaultGraphicsDefault.setFullScreenWindow(webPageLoader); | ||
}); | ||
|
||
if (!notMainDisplay.isEmpty()) | ||
{ | ||
notMainDisplay.forEach(d -> { | ||
SwingUtilities.invokeLater(() -> { | ||
BlackedOutWindow blackedOutWindow = new BlackedOutWindow(); | ||
Rectangle bounds = d.getDefaultConfiguration().getBounds(); | ||
blackedOutWindow.setLocationByPlatform(true); | ||
blackedOutWindow.setLocation(bounds.x, bounds.y); | ||
d.setFullScreenWindow(blackedOutWindow); | ||
blackedOutWindow.setVisible(true); | ||
}); | ||
}); | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
src/main/java/at/rziha/jsaveexam/webpage/BlackedOutWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package at.rziha.jsaveexam.webpage; | ||
|
||
import com.sun.webkit.WebPage; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.WindowEvent; | ||
import java.awt.event.WindowFocusListener; | ||
|
||
public class BlackedOutWindow extends JFrame { | ||
public BlackedOutWindow() { | ||
setTitle("Blacked Out"); | ||
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); | ||
setUndecorated(true); | ||
setExtendedState(JFrame.MAXIMIZED_BOTH); | ||
|
||
getContentPane().setBackground(Color.BLACK); | ||
|
||
addWindowFocusListener((new WindowFocusListener() { | ||
@Override | ||
public void windowGainedFocus(WindowEvent e) { | ||
|
||
} | ||
|
||
@Override | ||
public void windowLostFocus(WindowEvent e) { | ||
requestFocus(); | ||
} | ||
})); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/at/rziha/jsaveexam/webpage/WebPageLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2024, Alexander Rziha | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package at.rziha.jsaveexam.webpage; | ||
|
||
import javafx.application.Platform; | ||
import javafx.embed.swing.JFXPanel; | ||
import javafx.scene.Scene; | ||
import javafx.scene.web.WebView; | ||
|
||
import javax.swing.*; | ||
import java.awt.event.WindowEvent; | ||
import java.awt.event.WindowFocusListener; | ||
|
||
public class WebPageLoader extends JFrame { | ||
|
||
public WebPageLoader(String url) { | ||
setTitle("Web Page"); | ||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
setUndecorated(true); | ||
setExtendedState(JFrame.MAXIMIZED_BOTH); | ||
|
||
JFXPanel fxPanel = new JFXPanel(); | ||
|
||
Platform.runLater(() -> { | ||
WebView webView = new WebView(); | ||
webView.getEngine().load(url); | ||
|
||
Scene scene = new Scene(webView); | ||
fxPanel.setScene(scene); | ||
}); | ||
|
||
add(fxPanel); | ||
|
||
addWindowFocusListener((new WindowFocusListener() { | ||
@Override | ||
public void windowGainedFocus(WindowEvent e) { | ||
|
||
} | ||
|
||
@Override | ||
public void windowLostFocus(WindowEvent e) { | ||
requestFocus(); | ||
} | ||
})); | ||
|
||
Platform.runLater(() -> { | ||
pack(); | ||
}); | ||
} | ||
} |