Skip to content

Commit bd69ec0

Browse files
hansonrhansonr
authored andcommitted
background painting detection
1 parent d247028 commit bd69ec0

34 files changed

+606
-136
lines changed
827 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190617071320
1+
20190618062841
827 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190617071320
1+
20190618062841
827 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/awt/Component.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@
6868
import java.util.Set;
6969
import java.util.Vector;
7070

71-
import javax.swing.JInternalFrame;
72-
7371
import sun.awt.AppContext;
7472
import sun.awt.CausedFocusEvent;
7573
import sun.awt.RequestFocusController;

sources/net.sf.j2s.java.core/src/java/awt/Container.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ Component[] getChildArray() {
288288
*/
289289
public Container() {
290290
component = new Lst<Component>();
291+
秘paintClass = 秘updateClass = /**@j2sNative C$ || */null;
291292
}
292293

293294
@Override
@@ -1284,7 +1285,8 @@ public void remove(Component comp) {
12841285
* @see #add
12851286
* @see #remove
12861287
*/
1287-
public void removeAll() {
1288+
@Override
1289+
public void removeAll() {
12881290
synchronized (getTreeLock()) {
12891291
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
12901292
-listeningChildren);

sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import javax.swing.UIDefaults;
4040
import javax.swing.UIManager;
4141
import javax.swing.border.AbstractBorder;
42-
import javax.swing.border.Border;
4342
import javax.swing.plaf.BorderUIResource;
4443
import javax.swing.plaf.ComponentUI;
4544
import javax.swing.plaf.FontUIResource;
@@ -118,7 +117,7 @@ public interface A2SWrappedComponent {
118117

119118
Boolean 秘peerVis;
120119

121-
protected Border 秘border; // from private JComponent field
120+
protected AbstractBorder 秘border; // from private JComponent field; was Border
122121

123122
public final static int PAINTS_SELF_NO = -1;
124123
public final static int PAINTS_SELF_YES = 1;
@@ -240,8 +239,9 @@ public Graphics getGraphics() {
240239
return g;
241240
}
242241

242+
@Override
243243
public void addNotify() {
244-
if (秘paintsSelf())
244+
if (秘paintsSelf() && ui != null) // BoxFiller will not have a ui?
245245
((JSComponentUI) ui).clearPaintPath();
246246
super.addNotify();
247247
}
@@ -576,6 +576,11 @@ public void removeKeyListener(KeyListener l) {
576576
return (秘iPaintMyself == PAINTS_SELF_ALWAYS ? PAINTS_SELF_ALWAYS : (秘iPaintMyself = flag));
577577
}
578578

579+
/**
580+
* the lowest subclass that does not actually paint anything other than a background
581+
*/
582+
public Class<?> 秘paintClass, 秘updateClass;
583+
579584
/**
580585
* Used by:
581586
*
@@ -590,17 +595,18 @@ public void removeKeyListener(KeyListener l) {
590595
* @return
591596
*/
592597
public boolean 秘paintsSelf() {
598+
593599
if (秘iPaintMyself == PAINTS_SELF_UNKNOWN) {
594600
// don't allow if not opaque and has components
595601
// don't allow if JComponent.paint(Graphics) has been overridden
596602
// don't allow if AbstractBorder.paintBorder(...) has been overridden
597603
// unchecked here is if a class calls getGraphics outside of this context
598-
秘iPaintMyself = 秘setPaintsSelf(JSUtil.isOverridden(this, "paint$java_awt_Graphics", JComponent.class)
604+
秘iPaintMyself = 秘setPaintsSelf(JSUtil.isOverridden(this, "paint$java_awt_Graphics", 秘paintClass)
599605
|| JSUtil.isOverridden(this, "paintComponent$java_awt_Graphics", JComponent.class)
600-
|| JSUtil.isOverridden(this, "paintContainer$java_awt_Graphics", Container.class)
601-
|| JSUtil.isOverridden(this, "update$java_awt_Graphics", JComponent.class)
606+
|| JSUtil.isOverridden(this, "update$java_awt_Graphics", 秘updateClass)
607+
|| JSUtil.isOverridden(this, "paintContainer$java_awt_Graphics", Window.class)
602608
|| 秘paintsBorder() && JSUtil.isOverridden(秘border, "paintBorder$java_awt_Component$java_awt_Graphics$I$I$I$I",
603-
AbstractBorder.class)
609+
秘border.秘paintClass)
604610
? PAINTS_SELF_YES : PAINTS_SELF_NO);
605611
}
606612
// TODO -- still need to set RepaintManager so that

sources/net.sf.j2s.java.core/src/java/awt/MediaTracker.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
import java.awt.image.ImageObserver;
2929

30-
import swingjs.JSImagekit;
31-
3230
/**
3331
* The <code>MediaTracker</code> class is a utility class to track the status of
3432
* a number of media objects. Media objects could include audio clips as well as
@@ -924,10 +922,12 @@ boolean matches(Image img, int w, int h) {
924922
return (image == img && width == w && height == h);
925923
}
926924

925+
@Override
927926
Object getMedia() {
928927
return image;
929928
}
930929

930+
@Override
931931
synchronized int getStatus(boolean doLoad, boolean doVerify) {
932932
if (doVerify) {
933933
int flags = tracker.target.checkImage(image, width, height, null);
@@ -943,6 +943,7 @@ synchronized int getStatus(boolean doLoad, boolean doVerify) {
943943
return super.getStatus(doLoad, doVerify);
944944
}
945945

946+
@Override
946947
void startLoad() {
947948
// if (tracker.target.prepareImage(image, width, height, this)) {
948949
setStatus(COMPLETE);
@@ -960,6 +961,7 @@ int parseflags(int infoflags) {
960961
return 0;
961962
}
962963

964+
@Override
963965
public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
964966
if (cancelled) {
965967
return false;

sources/net.sf.j2s.java.core/src/java/awt/Window.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
*/
2828
package java.awt;
2929

30-
import java.applet.JSApplet;
3130
import java.awt.event.ComponentEvent;
3231
import java.awt.event.KeyEvent;
3332
import java.awt.event.MouseWheelEvent;
@@ -50,7 +49,6 @@
5049
import javax.swing.JLayeredPane;
5150
import javax.swing.JRootPane;
5251
import javax.swing.RootPaneContainer;
53-
import javax.swing.plaf.ComponentUI;
5452

5553
import sun.awt.AppContext;
5654
import swingjs.JSToolkit;
@@ -345,7 +343,7 @@ public class Window extends JComponent {
345343
*/
346344
Window() {
347345
//GraphicsEnvironment.checkHeadless();
348-
initWinGC(null, null);
346+
this(null, null);
349347
}
350348

351349
/**
@@ -371,7 +369,7 @@ public class Window extends JComponent {
371369
*
372370
*/
373371
Window(GraphicsConfiguration gc) {
374-
initWinGC(null, gc);
372+
this(null, gc);
375373
}
376374

377375

@@ -435,7 +433,7 @@ public class Window extends JComponent {
435433
*
436434
*/
437435
public Window(Window owner) {
438-
initWinGC(owner, null);
436+
this(owner, null);
439437
}
440438

441439
/**
@@ -472,6 +470,7 @@ public Window(Window owner) {
472470
public Window(Window owner, GraphicsConfiguration gc) {
473471
// everything will pass through here, even Window(gc);
474472
// We just adjust for the 1-parameter issue here
473+
秘paintClass = 秘updateClass = /**@j2sNative C$ || */null;
475474
initWinGC(owner, gc);
476475
}
477476

@@ -2299,7 +2298,8 @@ public Set<AWTKeyStroke> getFocusTraversalKeys(int id) {
22992298
* @see Container#getFocusTraversalPolicy
23002299
* @since 1.4
23012300
*/
2302-
public void setFocusCycleRoot(boolean focusCycleRoot) {
2301+
@Override
2302+
public void setFocusCycleRoot(boolean focusCycleRoot) {
23032303
}
23042304

23052305
/**
@@ -3136,6 +3136,7 @@ Component setTemporaryLostComponent(Component component) {
31363136
* Verifies that it is focusable and as container it can container focus owner.
31373137
* @since 1.5
31383138
*/
3139+
@Override
31393140
protected boolean canContainFocusOwner(Component focusOwnerCandidate) {
31403141
return super.canContainFocusOwner(focusOwnerCandidate) && isFocusableWindow();
31413142
}
@@ -3396,11 +3397,13 @@ public void setBackground(Color bgColor) {
33963397

33973398
private boolean opaque = true;
33983399

3400+
@Override
33993401
public boolean isOpaque() {
34003402
// SwingJS
34013403
return opaque;
34023404
}
34033405

3406+
@Override
34043407
public void setOpaque(boolean opaque) {
34053408
synchronized (getTreeLock()) {
34063409
//TODO ?

0 commit comments

Comments
 (0)