Revision: 2502
http://sourceforge.net/p/swingme/code/2502
Author: yuranet
Date: 2021-07-02 14:00:44 +0000 (Fri, 02 Jul 2021)
Log Message:
-----------
allow custom loading of all imagePainters
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/Graphics2D.java
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/Graphics2D.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/Graphics2D.java 2021-07-01 23:48:15 UTC (rev 2501)
+++ SwingME/src/net/yura/mobile/gui/Graphics2D.java 2021-07-02 14:00:44 UTC (rev 2502)
@@ -180,7 +180,7 @@
Logger.info("going to tile a very small image "+tile+" times: src_w=" +src_w+" src_h="+src_h+" dest_w="+ dest_w +" dest_h="+dest_h );
if ( tile>30 ) {
- Logger.info("###########################################################");
+ Logger.info("########################################################### " + img);
g.setColor( new Random().nextInt() );
for (int pos_x=start_x;pos_x<end_x;pos_x=pos_x+src_w) {
g.drawLine(pos_x, start_y, pos_x, end_y);
Modified: SwingME/src/net/yura/mobile/gui/border/MatteBorder.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/border/MatteBorder.java 2021-07-01 23:48:15 UTC (rev 2501)
+++ SwingME/src/net/yura/mobile/gui/border/MatteBorder.java 2021-07-02 14:00:44 UTC (rev 2502)
@@ -360,6 +360,10 @@
public void setColor(int c) {
color =c;
}
+
+ public int[] getImageEdgeInsets() {
+ return new int[] { imageTop, imageLeft, imageBottom, imageRight};
+ }
}
Modified: SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java 2021-07-01 23:48:15 UTC (rev 2501)
+++ SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java 2021-07-02 14:00:44 UTC (rev 2502)
@@ -39,7 +39,7 @@
*/
public class SynthLookAndFeel extends LookAndFeel {
- protected Icon getIcon( String path ,int x,int y,int w,int h) {
+ protected Icon getIcon(String path, int x, int y, int w, int h) {
Image in = createImage(path);
if (in!=null) {
if (w!=0 && h !=0) {
@@ -58,6 +58,14 @@
return null;
}
+ protected Border getBorder(String path, int top, int left, int bottom, int right, int t, int l, int b, int r, boolean back, int color) {
+ Icon activeimage = getIcon(path,0,0,0,0 );
+ if (activeimage!=null) {
+ return new MatteBorder(activeimage, top, left, bottom, right, t, l, b, r, back, color);
+ }
+ return null;
+ }
+
/**
* The system or custom midlet may return a higher-resolution image
* @see Image#createImage(String)
@@ -147,12 +155,10 @@
// read end tag
parser.skipSubTree();
-
}
}
}
-
private Style readStyle(KXmlParser parser,Hashtable fonts) throws Exception {
Hashtable params = new Hashtable();
@@ -173,7 +179,7 @@
// vars local to this state
int borderfill=Style.NO_COLOR;
- MatteBorder border = null;
+ Border border = null;
// read start tag
//parser.getEventType();
@@ -190,23 +196,22 @@
String paintCenter = parser.getAttributeValue(null, "paintCenter");
if (sourceInsets!=null) {
- Icon activeimage = getIcon( path,0,0,0,0 );
- if (activeimage!=null) {
- String[] split = StringUtil.split(sourceInsets, ' ');
- border = new MatteBorder(activeimage,
- insets==null?0:insets.getTop(), insets==null?0:insets.getLeft(), insets==null?0:insets.getBottom(), insets==null?0:insets.getRight(),
- Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]),
- "true".equals(paintCenter) || "Y".equals(paintCenter)
- , borderfill);
- border.opaque = opaque;
+ String[] split = StringUtil.split(sourceInsets, ' ');
+ border = getBorder(path, insets == null ? 0 : insets.getTop(), insets == null ? 0 : insets.getLeft(), insets == null ? 0 : insets.getBottom(), insets == null ? 0 : insets.getRight(),
+ Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]),
+ "true".equals(paintCenter) || "Y".equals(paintCenter), borderfill);
+ if (border != null) {
+ if (border instanceof MatteBorder) {
+ ((MatteBorder)border).opaque = opaque;
+ }
newStyle.addBorder(border, st);
}
}
else {
if (path.indexOf(".9.")>0) {
- Border border2 = getBorder(path);
- if (border2!=null) {
- newStyle.addBorder(border2, st);
+ border = getBorder(path);
+ if (border != null) {
+ newStyle.addBorder(border, st);
}
}
else {
@@ -270,8 +275,8 @@
newStyle.addForeground(color, st);
}
else if ("BORDERFILL".equals(type)) {
- if (border!=null) {
- border.setColor(color);
+ if (border instanceof MatteBorder) {
+ ((MatteBorder)border).setColor(color);
}
else {
borderfill = color;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|