Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Drawer #1

Merged
merged 19 commits into from
Nov 12, 2023
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ target/
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/workspace.xml
.idea/libraries/
*.iws
*.iml
Expand Down
124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 46 additions & 18 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed jar library/swing-glasspane-popup-1.0.0.jar
Binary file not shown.
Binary file added jar library/swing-glasspane-popup-1.1.0.jar
Binary file not shown.
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>raven.popup</groupId>
<artifactId>swing-glasspane-popup</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand All @@ -31,6 +31,13 @@
<artifactId>miglayout-swing</artifactId>
<version>11.2</version>
</dependency>

<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf-fonts-roboto</artifactId>
<version>2.137</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
47 changes: 47 additions & 0 deletions src/main/java/raven/drawer/Drawer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package raven.drawer;

import raven.drawer.component.DrawerBuilder;
import raven.drawer.component.DrawerPanel;
import raven.popup.GlassPanePopup;

public class Drawer {

private static Drawer instance;
private DrawerPanel drawerPanel;
private DrawerOption option;

public static Drawer getInstance() {
if (instance == null) {
instance = new Drawer();
}
return instance;
}

public static Drawer newInstance() {
return new Drawer();
}

private Drawer() {
option = new DrawerOption();
}

public void setDrawerBuilder(DrawerBuilder drawerBuilder) {
drawerPanel = new DrawerPanel(drawerBuilder);
drawerBuilder.build(drawerPanel);
}

public void showDrawer() {
if (drawerPanel == null) {
throw new NullPointerException("Drawer builder has not initialize");
}
GlassPanePopup.showPopup(drawerPanel, option, "drawer");
}

public void closeDrawer() {
GlassPanePopup.closePopup("drawer");
}

public DrawerPanel getDrawerPanel() {
return drawerPanel;
}
}
33 changes: 33 additions & 0 deletions src/main/java/raven/drawer/DrawerOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package raven.drawer;

import raven.popup.DefaultOption;

import java.awt.*;

public class DrawerOption extends DefaultOption {

private final int width = 275;

@Override
public String getLayout(Component parent, float animate) {
String l;
if (parent.getComponentOrientation().isLeftToRight()) {
float x = (animate * width) - width;
l = "pos " + x + " 0,height 100%,width " + width;
} else {
float x = (animate * width);
l = "pos 100%-" + x + " 0,height 100%,width " + width;
}
return l;
}

@Override
public boolean closeWhenClickOutside() {
return true;
}

@Override
public boolean closeWhenPressedEsc() {
return true;
}
}
16 changes: 16 additions & 0 deletions src/main/java/raven/drawer/component/DrawerBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package raven.drawer.component;

import java.awt.*;

public interface DrawerBuilder {

public void build(DrawerPanel drawerPanel);

public Component getHeader();

public Component getHeaderSeparator();

public Component getMenu();

public Component getFooter();
}
Loading