Revision: 2991
http://sourceforge.net/p/swingme/code/2991
Author: yuranet
Date: 2025-12-29 22:25:10 +0000 (Mon, 29 Dec 2025)
Log Message:
-----------
background border
Added Paths:
-----------
SwingME/src/net/yura/mobile/gui/border/BackgroundBorder.java
Added: SwingME/src/net/yura/mobile/gui/border/BackgroundBorder.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/border/BackgroundBorder.java (rev 0)
+++ SwingME/src/net/yura/mobile/gui/border/BackgroundBorder.java 2025-12-29 22:25:10 UTC (rev 2991)
@@ -0,0 +1,47 @@
+package net.yura.mobile.gui.border;
+
+import javax.microedition.lcdui.Image;
+import net.yura.mobile.gui.Graphics2D;
+import net.yura.mobile.gui.components.Component;
+
+/**
+ * @author Yura
+ */
+public class BackgroundBorder implements Border {
+
+ Image img;
+
+ public BackgroundBorder(Image i) {
+ img = i;
+ }
+
+ public void paintBorder(Component cmpnt, Graphics2D g, int w, int h) {
+ double s = Math.max(h / (double) img.getHeight(), w / (double) img.getWidth());
+
+ // need to round up or we may end up not covering the bottom row of pixels
+ int dw = (int) Math.ceil(img.getWidth() * s);
+ int dh = (int) Math.ceil(img.getHeight() * s);
+
+ g.drawScaledImage(img, (w - dw) / 2, (h - dh) / 2, dw, dh);
+ }
+
+ public int getTop() {
+ return 0;
+ }
+
+ public int getBottom() {
+ return 0;
+ }
+
+ public int getRight() {
+ return 0;
+ }
+
+ public int getLeft() {
+ return 0;
+ }
+
+ public boolean isBorderOpaque() {
+ return true;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|