Kaynağa Gözat

assira.ui: new border, new utils

Ranides Atterwim 7 ay önce
ebeveyn
işleme
47c40bf5e4

+ 25 - 0
assira.ui/src/main/java/net/ranides/assira/ui/ScreenUtils.java

@@ -0,0 +1,25 @@
+package net.ranides.assira.ui;
+
+import lombok.experimental.UtilityClass;
+
+import java.awt.*;
+
+@UtilityClass
+public class ScreenUtils {
+
+    public static Rectangle getScreenBounds() {
+        Rectangle global = new Rectangle(0,0,0,0);
+
+        for(GraphicsDevice device : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
+            Rectangle screen = device.getDefaultConfiguration().getBounds();
+
+            global.x = Math.min(global.x, screen.x);
+            global.y = Math.min(global.y, screen.y);
+            global.width = Math.max(global.width, screen.x + screen.width);
+            global.height = Math.max(global.height, screen.y + screen.height);
+        }
+
+        return global;
+    }
+
+}

+ 40 - 0
assira.ui/src/main/java/net/ranides/assira/ui/components/CustomRoundedBorder.java

@@ -0,0 +1,40 @@
+package net.ranides.assira.ui.components;
+
+import javax.swing.border.AbstractBorder;
+import java.awt.*;
+
+public class CustomRoundedBorder extends AbstractBorder {
+    private final BasicStroke stroke;
+    private final Color color;
+    private final int radius;
+
+    public CustomRoundedBorder(int size, Color color, int radius) {
+        this.stroke = new BasicStroke(size);
+        this.radius = radius;
+        this.color = color;
+    }
+
+    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
+        super.paintBorder(c, g, x, y, width, height);
+
+        Graphics2D g2 = (Graphics2D) g.create();
+        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        g2.setColor(color);
+        g2.setStroke(stroke);
+        int size = (int)Math.ceil(stroke.getLineWidth());
+        g2.drawRoundRect(x, y, width-size, height-size, radius, radius);
+
+        g2.dispose();
+    }
+
+    @Override
+    public Insets getBorderInsets(Component c, Insets insets) {
+        int size = (int)Math.ceil(stroke.getLineWidth());
+        insets.set(size, size, size, size);
+        return insets;
+    }
+
+    @Override
+    public boolean isBorderOpaque() {return true;}
+
+}

+ 31 - 31
pom.xml

@@ -96,37 +96,6 @@
             </activation>
             <build>
                 <plugins>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-source-plugin</artifactId>
-                        <version>2.2.1</version>
-                        <executions>
-                            <execution>
-                                <id>attach-sources</id>
-                                <goals>
-                                    <goal>jar-no-fork</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                    </plugin>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-javadoc-plugin</artifactId>
-                        <version>3.3.1</version>
-                        <executions>
-                            <execution>
-                                <id>attach-javadocs</id>
-                                <goals>
-                                    <goal>jar</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                        <configuration>
-                            <version>true</version>
-                            <show>public</show>
-                            <doclint>none</doclint>
-                        </configuration>
-                    </plugin>
                     <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
                         <artifactId>maven-gpg-plugin</artifactId>
@@ -237,6 +206,37 @@
                 <artifactId>maven-jxr-plugin</artifactId>
                 <version>2.3</version>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>2.2.1</version>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <goals>
+                            <goal>jar-no-fork</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>3.3.1</version>
+                <executions>
+                    <execution>
+                        <id>attach-javadocs</id>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <version>true</version>
+                    <show>public</show>
+                    <doclint>none</doclint>
+                </configuration>
+            </plugin>
         </plugins>
     </build>