Skip to content

Commit 75ab6c4

Browse files
authored
0.8.15
* renamed `prepareFixedPanels()` to `initializePanels()` for paneled pages * test improvements: * some refactoring * import optimization * docs improvements
1 parent dec140e commit 75ab6c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+482
-376
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.KruMF</groupId>
88
<artifactId>GraphicsEngine</artifactId>
9-
<version>0.8.14</version>
9+
<version>0.8.15</version>
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/graphicsEngine/pages/AbstractPage.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public AbstractPage() {
2222
}
2323

2424
//TODO: add javadoc
25-
public AbstractPage(@Nullable List<ActionListener> actionListenerList,
25+
public AbstractPage(@Nullable List<@Nullable ActionListener> actionListenerList,
2626
@Nullable Color backgroundColor) {
2727
super(
2828
null,
@@ -31,6 +31,9 @@ public AbstractPage(@Nullable List<ActionListener> actionListenerList,
3131
addListeners(actionListenerList);
3232
}
3333

34+
//TODO: add javadoc
35+
public abstract @NotNull String getPageKey();
36+
3437
/**
3538
* Adds known listeners to this page.
3639
* Override this to add custom listeners.
@@ -39,10 +42,7 @@ public AbstractPage(@Nullable List<ActionListener> actionListenerList,
3942
*
4043
* @return Remaining unknown listeners.
4144
*/
42-
public @NotNull List<ActionListener> addListeners(@Nullable List<ActionListener> list) {
45+
public @NotNull List<@Nullable ActionListener> addListeners(@Nullable List<@Nullable ActionListener> list) {
4346
return Objects.requireNonNullElse(list, new ArrayList<>());
4447
}
45-
46-
//TODO: add javadoc
47-
public abstract String getPageKey();
4848
}

src/main/java/graphicsEngine/pages/HeaderAndFooterPage.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public HeaderAndFooterPage(@Nullable List<ActionListener> actionListenerList,
3030

3131
//this has to be called manually in constructor in order to support custom parameters
3232
//TODO: add javadoc
33-
public final void prepareFixedPanels(@Nullable SimpleColorScheme headerAndFooterColors,
34-
@Nullable SimpleColorScheme bodyColors,
35-
@Nullable BorderProperties borderProperties) {
33+
public final void initializePanels(@Nullable SimpleColorScheme headerAndFooterColors,
34+
@Nullable SimpleColorScheme bodyColors,
35+
@Nullable BorderProperties borderProperties) {
3636
setLayout(new BorderLayout(0, 0));
3737
setHeaderAndFooter(headerAndFooterColors, borderProperties);
3838
addHeaderAndFooter();
@@ -66,7 +66,7 @@ private void addBody() {
6666
}
6767
}
6868

69-
//
69+
//TODO: add javadoc
7070
public @Nullable SimplePanel getPanelByLocation(@NotNull PanelLocation location) {
7171
try {
7272
return switch (location) {

src/test/java/graphicsEngineDemo/d1_simplestDemo/Main.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package graphicsEngineDemo.d1_simplestDemo;
22

3+
import org.jetbrains.annotations.NotNull;
4+
35
import graphicsEngine.GraphicsAdapter;
6+
import graphicsEngine.windows.WindowConfig;
47
import graphicsEngine.windows.WindowManager;
58
import graphicsEngine.windows.WindowUpdater;
6-
import graphicsEngine.windows.WindowConfig;
79
import graphicsEngine.windows.windowTypes.SimpleWindow;
810

9-
import org.jetbrains.annotations.NotNull;
10-
1111
/**
1212
* Simplest possible use of the GraphicsEngine.
1313
* Everything contained in just one class.
14+
* See <b><code>ReadMe.md<code/></b> for more info.
1415
*/
1516
public class Main {
1617

src/test/java/graphicsEngineDemo/d1_simplestDemo/ReadMe.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
This is a demo demonstrating the simplest possible use of the Graphics Engine.
66

7+
Starts a blank SimpleWindow.
8+
79
Everything contained in just one class.
810

911
## Instructions

src/test/java/graphicsEngineDemo/d2_overlayDemo/ButtonListener.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

src/test/java/graphicsEngineDemo/d2_overlayDemo/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
/**
77
* GraphicsEngine demo demonstrating the use of overlays.
8+
* See <b><code>ReadMe.md<code/></b> for more info.
89
*/
910
public class Main {
1011
/**

src/test/java/graphicsEngineDemo/d2_overlayDemo/Overlay.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/test/java/graphicsEngineDemo/d2_overlayDemo/ReadMe.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
This is a demo for demonstrating the overlay functionality.
66

7+
Launches a SinglePageWindow with an overlay.
8+
9+
Contains buttons for toggling overlay visibility and color.
10+
711
## Instructions
812

913
Run `Main.main(String[] args)` to launch this demo.

src/test/java/graphicsEngineDemo/d2_overlayDemo/Window.java

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
11
package graphicsEngineDemo.d2_overlayDemo;
22

3-
import graphicsEngine.pages.AbstractPage;
4-
import graphicsEngine.windows.WindowConfig;
5-
import graphicsEngine.windows.WindowManager;
6-
import graphicsEngine.windows.windowTypes.SinglePageWindow;
7-
83
import java.util.List;
9-
import java.awt.Color;
104
import java.awt.event.ActionListener;
115

126
import org.jetbrains.annotations.NotNull;
137
import org.jetbrains.annotations.Nullable;
148

9+
import graphicsEngine.windows.WindowConfig;
10+
import graphicsEngine.windows.WindowManager;
11+
import graphicsEngine.windows.windowTypes.SinglePageWindow;
12+
import graphicsEngine.pages.AbstractPage;
13+
import graphicsEngine.presets.SimpleOverlay;
14+
15+
import graphicsEngineDemo.d2_overlayDemo.page.Page;
16+
import graphicsEngineDemo.d2_overlayDemo.overlay.Overlay;
17+
import graphicsEngineDemo.d2_overlayDemo.buttons.ButtonListener;
18+
1519
/**
1620
* The window to display.
1721
*/
18-
class Window extends SinglePageWindow {
19-
private static final String WINDOW_TITLE = "Overlay demo";
20-
21-
private boolean overlayColorState;
22-
private ButtonListener headerButtonListener;
22+
public class Window extends SinglePageWindow {
23+
private static final @NotNull String WINDOW_TITLE = "Overlay demo";
24+
private @Nullable ButtonListener buttonListener;
2325

2426
//TODO: add javadoc
25-
Window(@NotNull WindowManager windowManager) {
27+
protected Window(@NotNull WindowManager windowManager) {
2628
super(windowManager, new WindowConfig(), null, null);
2729
setDefaultCloseOperation(EXIT_ON_CLOSE);
2830
setTitle(WINDOW_TITLE);
31+
setOverlay(new Overlay(buttonListener));
32+
}
2933

30-
overlayColorState = false;
31-
setOverlay(new Overlay(headerButtonListener));
34+
/**
35+
* Redundant as there is only one window.
36+
* TODO: finish this javadoc
37+
*
38+
* @return The key of this window.
39+
*/
40+
@Override
41+
public final @NotNull String getWindowKey() {
42+
return "window";
3243
}
3344

3445
/**
@@ -41,44 +52,27 @@ class Window extends SinglePageWindow {
4152
*/
4253
@Override
4354
public @NotNull List<ActionListener> addListeners(@Nullable List<ActionListener> list) {
44-
headerButtonListener = new ButtonListener(this);
55+
buttonListener = new ButtonListener(this);
4556
return super.addListeners(list);
4657
}
4758

48-
/**
49-
* Redundant as there is only one window.
50-
* TODO: finish this javadoc
51-
*
52-
* @return The key of this window.
53-
*/
54-
@Override
55-
public final @NotNull String getWindowKey() {
56-
return "window";
57-
}
58-
5959
/**
6060
* Prepares a page to add to this window.
6161
*
6262
* @return An AbstractPage object.
6363
*/
6464
@Override
6565
public final @NotNull AbstractPage getPage() {
66-
return new Page(headerButtonListener, null);
66+
return new Page(buttonListener, null);
6767
}
6868

6969
//TODO: add javadoc
70-
void toggleOverlayColor() {
71-
overlayColorState = !overlayColorState;
72-
if (overlayColorState) {
73-
setOverlayColor(OverlayColors.GREEN);
74-
} else {
75-
setOverlayColor(OverlayColors.RED);
76-
}
77-
}
78-
79-
private void setOverlayColor(@Nullable Color color) {
70+
public void toggleOverlayColor() {
8071
try {
81-
getOverlay().setColor(color);
72+
@NotNull SimpleOverlay simpleOverlay = getOverlay(); //throws ClassCastException
73+
if (simpleOverlay instanceof Overlay) {
74+
((Overlay) simpleOverlay).toggleColor();
75+
}
8276
} catch (ClassCastException ignored) {
8377
//glassPane does not contain a SimpleOverlay object
8478
}

0 commit comments

Comments
 (0)