Revision: 2524
http://sourceforge.net/p/swingme/code/2524
Author: yuranet
Date: 2021-07-08 15:53:01 +0000 (Thu, 08 Jul 2021)
Log Message:
-----------
can color full background of component with synth config
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/border/MatteBorder.java
SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java
Modified: SwingME/src/net/yura/mobile/gui/border/MatteBorder.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/border/MatteBorder.java 2021-07-08 12:06:30 UTC (rev 2523)
+++ SwingME/src/net/yura/mobile/gui/border/MatteBorder.java 2021-07-08 15:53:01 UTC (rev 2524)
@@ -34,14 +34,18 @@
*/
public class MatteBorder extends EmptyBorder {
- private Icon activeimage;
+ protected int color;
+ protected Icon tileIcon;
+
+ // for synth imagePainter
private int imageTop;
private int imageBottom;
private int imageRight;
private int imageLeft;
- private boolean back;
- private int color;
+ public boolean paintCenter;
+ public boolean opaque = true;
+
/**
* @param top the top inset of the border
* @param left the left inset of the border
@@ -65,8 +69,8 @@
*/
public MatteBorder(int top, int left, int bottom, int right, Icon tileIcon) {
super(top,left,bottom,right);
- activeimage = tileIcon;
- back=true;
+ this.tileIcon = tileIcon;
+ paintCenter = true;
}
@@ -204,15 +208,14 @@
}
- public boolean opaque=true;
public MatteBorder(Icon i, int top, int left, int bottom, int right, int t, int l, int b, int r, boolean back, int color) {
super(top,left,bottom,right);
- activeimage = i;
+ tileIcon = i;
imageTop=t;
imageLeft=l;
imageBottom=b;
imageRight=r;
- this.back=back;
+ this.paintCenter = back;
this.color=color;
//#mdebug debug
@@ -220,7 +223,6 @@
Logger.debug("[WARN] MatteBorder created with filling background with tiled image set to true, this should be avoided unless a textured background is needed");
}
//#enddebug
-
}
/**
@@ -228,11 +230,9 @@
* @see javax.swing.border.MatteBorder#getTileIcon() MatteBorder.getTileIcon
*/
public Icon getTileIcon() {
- return activeimage;
+ return tileIcon;
}
-
-
/**
* @param c
* @param g
@@ -242,10 +242,10 @@
*/
public void paintBorder(Component c, Graphics2D g, int width,int height) {
- if (activeimage==null) {
+ if (tileIcon ==null) {
// color can NOT be Style.NO_COLOR here
g.setColor(color);
- if (back) {
+ if (paintCenter) {
g.fillRect(-left, -top, width+left+right, height+top+bottom);
}
else {
@@ -256,7 +256,7 @@
}
}
// we will have a image, but its not loaded yet or we can not use it for some reason
- else if (activeimage.getImage() == null) {
+ else if (tileIcon.getImage() == null) {
if (color!=Style.NO_COLOR) {
g.setColor(color);
g.fillRect(-left, -top, width+left+right, height+top+bottom);
@@ -264,8 +264,8 @@
}
else {
- int imageWidth=activeimage.getIconWidth();
- int imageHeight=activeimage.getIconHeight();
+ int imageWidth = tileIcon.getIconWidth();
+ int imageHeight = tileIcon.getIconHeight();
int topDiff = imageTop-top;
int rightDiff= imageRight-right;
@@ -272,7 +272,7 @@
int leftDiff= imageLeft-left;
int bottomDiff= imageBottom-bottom;
- Image image = activeimage.getImage();
+ Image image = tileIcon.getImage();
// on blackberry we can not draw a image of 0 width or 0 height, so we have to check
if (imageTop>0) {
@@ -304,15 +304,14 @@
g.drawImage(image,imageWidth-imageRight,imageTop,imageRight,imageHeight-imageTop-imageBottom,
width-rightDiff,topDiff,imageRight,height-topDiff-bottomDiff); // right
- if (!back && color==Style.NO_COLOR) {
+ if (!paintCenter && color == Style.NO_COLOR) {
// TODO matte tileing the border with the whole image
// check that if there is NO bckground that the Diff values are not negative
// as if they r negative we need to fill in those aras
}
+ else if (paintCenter) {
- else if (back) {
-
int src_w = imageWidth-imageRight-imageLeft;
int src_h = imageHeight-imageTop-imageBottom;
int dist_w = width-leftDiff-rightDiff;
@@ -326,7 +325,6 @@
g.drawImage(image,imageLeft,imageTop,src_w,src_h,leftDiff,topDiff,dist_w,dist_h); // centre
}
}
-
else if (color!=Style.NO_COLOR) {
boolean fillsides = (imageHeight-imageTop-imageBottom) == 0;
boolean filltop = (imageWidth-imageRight-imageLeft) == 0;
@@ -333,7 +331,6 @@
g.setColor(color);
g.fillRect(fillsides?-left:leftDiff,filltop?-top:topDiff,width-(fillsides?-(left+right):leftDiff+rightDiff),height-(filltop?-(top+bottom):topDiff+bottomDiff));
}
-
//#mdebug info
else {
Logger.info("imagePainter has image but does not have anything to fill the area, this is prob bad");
@@ -351,12 +348,10 @@
}
//#enddebug
}
-
}
-
public boolean isBorderOpaque() {
- return opaque && (back || (activeimage!=null && Graphics2D.isOpaque(color) ) );
+ return opaque && (paintCenter || (tileIcon !=null && Graphics2D.isOpaque(color) ) );
}
public void setColor(int c) {
Modified: SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java 2021-07-08 12:06:30 UTC (rev 2523)
+++ SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java 2021-07-08 15:53:01 UTC (rev 2524)
@@ -312,6 +312,13 @@
}
}
+ if (borderfill != Style.NO_COLOR && border == null) {
+ Border sourceInsets = insets == null ? Component.empty : insets;
+ border = new MatteBorder(sourceInsets.getTop(), sourceInsets.getLeft(), sourceInsets.getBottom(), sourceInsets.getRight(), borderfill);
+ ((MatteBorder) border).paintCenter = true;
+ ((MatteBorder) border).opaque = Graphics2D.isOpaque(borderfill);
+ newStyle.addBorder(border, st);
+ }
}
else if ("font".equals(name)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|