Skip to content
Merged
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20200321085805
20200327093924
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20200321085805
20200327093924
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
47 changes: 47 additions & 0 deletions sources/net.sf.j2s.java.core/src/java/awt/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -2727,6 +2727,53 @@ protected final void invalidateIfValid() {
}
}

// SwingJS see JComponent
// /**
// * Revalidates the component hierarchy up to the nearest validate root.
// * <p>
// * This method first invalidates the component hierarchy starting from this
// * component up to the nearest validate root. Afterwards, the component
// * hierarchy is validated starting from the nearest validate root.
// * <p>
// * This is a convenience method supposed to help application developers
// * avoid looking for validate roots manually. Basically, it's equivalent to
// * first calling the {@link #invalidate()} method on this component, and
// * then calling the {@link #validate()} method on the nearest validate
// * root.
// *
// * @see Container#isValidateRoot
// * @since 1.7
// */
// public void revalidate() {
// revalidateSynchronously();
// }
//
// /**
// * Revalidates the component synchronously.
// */
// final void revalidateSynchronously() {
// synchronized (getTreeLock()) {
// invalidate();
//
// Container root = getContainer();
// if (root == null) {
// // There's no parents. Just validate itself.
// validate();
// } else {
// while (!root.isValidateRoot()) {
// if (root.getContainer() == null) {
// // If there's no validate roots, we'll validate the
// // topmost container
// break;
// }
//
// root = root.getContainer();
// }
//
// root.validate();
// }
// }
// }
/**
*
* Unused in SwingJS. For SwingJS, we have the graphics without needing to get it from a peer.
Expand Down
31 changes: 31 additions & 0 deletions sources/net.sf.j2s.java.core/src/java/awt/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import javax.swing.JRootPane;
import javax.swing.RepaintManager;
import javax.swing.RootPaneContainer;
import javax.swing.SwingUtilities;

import sun.awt.AppContext;
import swingjs.JSToolkit;
Expand All @@ -62,6 +64,8 @@
* with this, but the reason was to allow JInternalFrame to subclass JFrame
* instead of duplicating in code all of its functionality.
*
* In addition, it allows all sorts of windows to be JComponents and have UIs.
*
*
* A <code>Window</code> object is a top-level window with no borders and no
* menubar.
Expand Down Expand Up @@ -3632,6 +3636,33 @@ final Point getLocationOnWindow() {
// y + h * securityWarningAlignmentY + securityWarningPointY);
// }


/**
* Indicates if this container is a validate root.
* <p>
* {@code Window} objects are the validate roots, and, therefore, they
* override this method to return {@code true}.
*
* @return {@code true}
* @since 1.7
* @see java.awt.Container#isValidateRoot
*/
@Override
public boolean isValidateRoot() {
return true;
}

@Override
public void revalidate() {
// added to see if JFrame can be revalidated this way after a change in contentPane.
// SwingJS - set this UI to rebuild itself due to some
// internal structural change.
if (ui != null)
((JSComponentUI)ui).setTainted();
invalidate();
validate();
}

} // class Window


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public final BufferedImage filter(BufferedImage src, BufferedImage dst) {
Graphics2D g = origDst.createGraphics();
try {
g.setComposite(AlphaComposite.Src);
((JSGraphics2D)(Object) g).drawImagePriv(dst, 0, 0, null);
((JSGraphics2D)(Object) g).drawImageFromRaster(dst, 0, 0, null);
} finally {
g.dispose();
}
Expand Down
50 changes: 38 additions & 12 deletions sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@ public void flush() {
// allow creating a Graphics from MemoryImageSource
// so pixels would never be there.
if (pix != null)
秘g.drawImagePriv(this, 0, 0, null);
秘g.drawImageFromRaster(this, 0, 0, null);
/**
* @j2sNative if (pix) pix.img = this;
*
Expand Down Expand Up @@ -1972,23 +1972,49 @@ public void flush() {
* @param force initially false just to get the pre-constructed canvas if it exists
* @return
*/

public final static int GET_IMAGE_ALLOW_NULL = 0;
public final static int GET_IMAGE_FOR_RASTER = 1;
public final static int GET_IMAGE_FOR_ICON = 2;


public DOMNode 秘getImageNode(boolean force) {
/**
*
* Return or create a DOMNode canvas or image tag or null
*
* @param mode GET_IMAGE_ALLOW_NULL(0) || GET_IMAGE_FOR_RASTER(1) ||
* GET_IMAGE_FOR_ICON(2)
* @return if allowing null, return the canvas if we have raster data (always
* null?) or the canvas or imgNode if not; if getting an image for a
* raster, we already know this is a raster image, so create its image;
* if getting an image for an icon, return the canvas or imgNode if this
* is not a raster image, or create its image
*/
public DOMNode 秘getImageNode(int mode) {
// If we have raster data and are not forcing, return the canvas if it exists.
// If we we have no raster data and are not forcing, force the issue anyway
// If we we have no raster data and are not forcing, force the issue anyway
// and return the canvas or image node.
// If we are forcing, or force the creation of a canvas
if (!force)
switch (mode) {
default:
case GET_IMAGE_ALLOW_NULL:
return (DOMNode) (秘hasRasterData || 秘canvas != null ? 秘canvas
: 秘imgNode != null ? 秘imgNode : JSGraphicsCompositor.createImageNode(this));
// we are forcing
秘getPixelsFromRaster();
秘g = null;
秘getImageGraphic();
DOMNode canvas = 秘g.getCanvas();
秘g = null;
秘canvas = null;
return canvas;
case GET_IMAGE_FOR_ICON:
if (!秘hasRasterData)
return (DOMNode) (秘canvas != null ? 秘canvas
: 秘imgNode != null ? 秘imgNode : JSGraphicsCompositor.createImageNode(this));
//$fall-through$
case GET_IMAGE_FOR_RASTER:
// we are forcing
秘getPixelsFromRaster();
秘g = null;
秘getImageGraphic();
DOMNode canvas = 秘g.getCanvas();
秘g = null;
秘canvas = null;
return canvas;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public final BufferedImage filter (BufferedImage src, BufferedImage dst) {
if (origDst != dst) {
Graphics2D g = origDst.createGraphics();
try {
((JSGraphics2D)(Object)g).drawImagePriv(dst, 0, 0, null);
((JSGraphics2D)(Object)g).drawImageFromRaster(dst, 0, 0, null);
} finally {
g.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public void setDescription(String description) {
@Override
public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
if(imageObserver == null) {
((JSGraphics2D)(Object)g).drawImagePriv(image, x, y, c);
((JSGraphics2D)(Object)g).drawImage(image, x, y, c);
} else {
g.drawImage(image, x, y, imageObserver);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4245,7 +4245,7 @@ public void revalidate() {
// internal structural change.
if (ui != null)
((JSComponentUI)ui).setTainted();
if (getParent() == null) {
if (getParent() == null && !isValidateRoot()) {
// Note: We don't bother invalidating here as once added
// to a valid parent invalidate will be invoked (addImpl
// invokes addNotify which will invoke invalidate on the
Expand Down
7 changes: 6 additions & 1 deletion sources/net.sf.j2s.java.core/src/javax/swing/JRootPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public JMenuBar getMenuBar() {
* by the root pane.
* <p>
* Swing's painting architecture requires an opaque <code>JComponent</code> in
* the containment hiearchy. This is typically provided by the content pane.
* the containment hierarchy. This is typically provided by the content pane.
* If you replace the content pane it is recommended you replace it with an
* opaque <code>JComponent</code>.
*
Expand All @@ -592,12 +592,17 @@ public void setContentPane(Container content) {
if (content == null)
throw new IllegalComponentStateException(
"contentPane cannot be set to null.");
if (contentPane == content)
return;
if (contentPane != null && contentPane.getParent() == layeredPane)
layeredPane.remove(contentPane);
content = 秘transferFrameTo((JComponent)content);
content.秘isContentPane = true;
Container old = contentPane;
contentPane = content;
layeredPane.add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER);
if (old != null)
validate();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ private void paintViaBackingStore(Graphics g) {
Graphics bsg = getBackingStoreGraphics(g);
try {
super.paint(bsg);
((JSGraphics2D)(Object)g).drawImagePriv(backingStoreImage, 0, 0, this);
((JSGraphics2D)(Object)g).drawImageFromRaster(backingStoreImage, 0, 0, this);
} finally {
bsg.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2756,9 +2756,8 @@ public boolean addEdit(UndoableEdit anEdit) {
// a hashtable for to locate the change for a given element.
if ((changeLookup == null) && (edits.size() > 10)) {
changeLookup = new Hashtable();
int n = edits.size();
for (int i = 0; i < n; i++) {
Object o = edits.elementAt(i);
for (int i = 0, n = edits.size(); i < n; i++) {
Object o = edits.get(i);
if (o instanceof DocumentEvent.ElementChange) {
DocumentEvent.ElementChange ec = (DocumentEvent.ElementChange) o;
changeLookup.put(ec.getElement(), ec);
Expand Down Expand Up @@ -2934,9 +2933,8 @@ public DocumentEvent.ElementChange getChange(Element elem) {
if (changeLookup != null) {
return (DocumentEvent.ElementChange) changeLookup.get(elem);
}
int n = edits.size();
for (int i = 0; i < n; i++) {
Object o = edits.elementAt(i);
for (int i = 0, n = edits.size(); i < n; i++) {
Object o = edits.get(i);
if (o instanceof DocumentEvent.ElementChange) {
DocumentEvent.ElementChange c = (DocumentEvent.ElementChange) o;
if (elem.equals(c.getElement())) {
Expand Down
Loading