Thanks to visit codestin.com
Credit goes to github.com

Skip to content

from Hanson1 #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sources/net.sf.j2s.core/dist/build-site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- unzip libjs/*.zip into site/swingjs/j2s
- unzips swingjs/SwingJS-site.zip into site/
- copies non-java resources from resources/ into site/swingjs/j2s
- copies site resources from site-resources/ to site/

-->

Expand Down
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
1 change: 0 additions & 1 deletion sources/net.sf.j2s.core/dist/swingjs/_j2sclasslist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ swingjs/a2s/ScrollPane.js
swingjs/a2s/TextArea.js
swingjs/a2s/TextField.js
swingjs/api/Interface.js
swingjs/api/JSUtilI.js
swingjs/api/js/DOMNode.js
swingjs/api/js/HTML5CanvasContext2D.js
swingjs/api/js/JSInterface.js
Expand Down
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 @@
20200327093924
20200404075511
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/SwingJS-site.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ swingjs/a2s/ScrollPane.js
swingjs/a2s/TextArea.js
swingjs/a2s/TextField.js
swingjs/api/Interface.js
swingjs/api/JSUtilI.js
swingjs/api/js/DOMNode.js
swingjs/api/js/HTML5CanvasContext2D.js
swingjs/api/js/JSInterface.js
Expand Down
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 @@
20200327093924
20200404075511
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
1 change: 0 additions & 1 deletion sources/net.sf.j2s.java.core/dist/_j2sclasslist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ swingjs/a2s/ScrollPane.js
swingjs/a2s/TextArea.js
swingjs/a2s/TextField.js
swingjs/api/Interface.js
swingjs/api/JSUtilI.js
swingjs/api/js/DOMNode.js
swingjs/api/js/HTML5CanvasContext2D.js
swingjs/api/js/JSInterface.js
Expand Down
1 change: 1 addition & 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 @@ -51,6 +51,7 @@
import java.awt.event.PaintEvent;
import java.awt.event.TextEvent;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
Expand Down
11 changes: 4 additions & 7 deletions sources/net.sf.j2s.java.core/src/java/awt/EventQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -735,15 +735,12 @@ private void dispatchEventImpl(final AWTEvent event, final Object src, boolean a
* @since 1.4
*/
public static long getMostRecentEventTime() {
return 0;
// return Toolkit.getEventQueue().getMostRecentEventTimeImpl();
return Toolkit.getEventQueue().getMostRecentEventTimeImpl();
}

// private synchronized long getMostRecentEventTimeImpl() {
// return (Thread.currentThread() == dispatchThread)
// ? mostRecentEventTime
// : System.currentTimeMillis();
// }
private synchronized long getMostRecentEventTimeImpl() {
return (Thread.currentThread() == dispatchThread) ? mostRecentEventTime : System.currentTimeMillis();
}

/**
* @return most recent event time on all threads.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.io.IOException;

import sun.awt.EventListenerAggregate;
import swingjs.JSUtil;


/**
Expand Down Expand Up @@ -127,14 +128,21 @@ public synchronized void setContents(Transferable contents, ClipboardOwner owner

this.owner = owner;
this.contents = contents;

if (oldOwner != null && oldOwner != owner) {
EventQueue.invokeLater(new Runnable() {
public void run() {
oldOwner.lostOwnership(Clipboard.this, oldContents);
}
});
if ("System".equals(name) && contents.isDataFlavorSupported(DataFlavor.stringFlavor)) {
try {
String s = (String) contents.getTransferData(DataFlavor.stringFlavor);
JSUtil.setClipboardContents(s);
} catch (UnsupportedFlavorException | IOException e) {
}
}

// if (oldOwner != null && oldOwner != owner) {
// EventQueue.invokeLater(new Runnable() {
// public void run() {
// oldOwner.lostOwnership(Clipboard.this, oldContents);
// }
// });
// }
fireFlavorsChanged();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ public void dispatch() {
exception = (Exception) t;
}
throwable = t;
System.err.println("InvocationException: " + t);
try {
t.printStackTrace();
} catch(Throwable e) {}
}
}
else {
Expand Down
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.java.core/src/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,7 @@ public InputStream getResourceAsStream(String name) {
Clazz.load("java.io.ByteArrayInputStream");
var is = Clazz.new_(java.io.BufferedInputStream.c$$java_io_InputStream, [Clazz.new_(java.io.ByteArrayInputStream.c$$BA, [bytes])]);
is.url = url;
url._streamData = is;
url._streamData = bytes;
return is;
*/
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.peer.ComponentPeer;

import swingjs.api.js.DOMNode;
import swingjs.plaf.JSComponentUI;

/**
Expand Down Expand Up @@ -164,9 +166,16 @@ public void paintComponent(Graphics g, Component c, Container p, int x, int y, i
// c.validate();
// }
JSComponentUI ui = ((JComponent) c).秘getUI();
c.秘reshape(x, y, w, h, false);
c.秘reshape(0, 0, w, h, false);
// x and y are not used in Component.reshape in SwingJS
//c.setLocation(x, y);
//ui.setBounds(x, y, 0, 0, ComponentPeer.SET_LOCATION);
((JComponent) c).validateTree();
ui.updateDOMNode();
if (p instanceof JTable)
DOMNode.setTopLeftAbsolute(ui.domNode, ((JTable) p).getRowMargin() / 2, ((JTable) p).getColumnModel().getColumnMargin() / 2);
if (c instanceof JLabel)
DOMNode.setStyles(ui.domNode, "overflow", "hidden");
// if (!ui.doPaintBackground())
// return;
// ui.setTainted(false);
Expand Down
7 changes: 7 additions & 0 deletions sources/net.sf.j2s.java.core/src/javax/swing/ImageIcon.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import swingjs.JSGraphics2D;

Expand Down Expand Up @@ -126,6 +127,12 @@ public class ImageIcon implements Icon {
* Id used in loading images from MediaTracker.
*/
private static int mediaTrackerID;
/**
* See JSImageKit
*
*/
public ImageIcon 秘tempIcon;


private final static Object TRACKER_KEY = new StringBuilder("TRACKER_KEY");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4847,7 +4847,7 @@ public void setTransferHandler(TransferHandler newHandler) {
}

public TransferHandler getTransferHandler() {
return null;
return (TransferHandler)getClientProperty(JComponent_TRANSFER_HANDLER);
}

Object setDropLocation(DropLocation dropLocation, Object state,
Expand Down
16 changes: 14 additions & 2 deletions sources/net.sf.j2s.java.core/src/javax/swing/JTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@
import swingjs.plaf.CellHolder;
// SwingJS TODO import java.text.DateFormat;
//import sun.swing.SwingLazyValue;
import swingjs.plaf.JSComponentUI;
import swingjs.plaf.JSTableUI;

/**
* SwingJS TODO: print/printable all not implemented
Expand Down Expand Up @@ -4655,7 +4653,11 @@ private void tableRowsInserted(TableModelEvent e) {
int rh = getRowHeight();
Rectangle drawRect = new Rectangle(0, start * rh, getColumnModel().getTotalColumnWidth(),
(getRowCount() - start) * rh);
firePropertyChange("tableAppending", null, e); //$NON-NLS-1$

Rectangle r = getVisibleRect();
if (drawRect.y > r.y + r.height)
return;
revalidate();
// PENDING(milne) revalidate calls 秘repaint() if parent is a ScrollPane
// repaint still required in the unusual case where there is no
Expand Down Expand Up @@ -6065,5 +6067,15 @@ public void removeEditor() {
}
}

/**
* SwingJS method to optionally return null.
* @param row
* @param col
* @param isScrolling
* @return the cell renderer or null.
*/
public TableCellRenderer getCellRendererOrNull(int row, int col, boolean isScrolling) {
return getCellRenderer(row, col);
}

} // End of Class JTable
7 changes: 5 additions & 2 deletions sources/net.sf.j2s.java.core/src/javax/swing/JTextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
package javax.swing;

import swingjs.JSToolkit;
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Dimension;
Expand Down Expand Up @@ -252,7 +251,11 @@ public JTextField(Document doc, String text, int columns) {
this.columns = columns;
if (doc == null) {
doc = createDefaultModel();
}
} else if ((Object) doc == "null") {
// SwingJS only
doc = new JSPlainDocument();
}

setDocument(doc);
if (text != null) {
setText(text);
Expand Down
29 changes: 14 additions & 15 deletions sources/net.sf.j2s.java.core/src/javax/swing/JViewport.java
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,9 @@ public void paint(Graphics g)
return;
}

myClip.width = width;
myClip.height = height;
((JSViewportUI) ui).setClip(myClip);
秘myClip.width = width;
秘myClip.height = height;
((JSViewportUI) ui).setClip(秘myClip);
if (inBlitPaint) {
// We invoked paint as part of copyArea cleanup, let it through.
super.paint(g);
Expand Down Expand Up @@ -1625,8 +1625,8 @@ private boolean windowBlitPaint(Graphics g) {
// }


Rectangle myClip = new Rectangle();

private Rectangle 秘myClip = new Rectangle();
/**
* Called to paint the view, usually when <code>blitPaint</code>
* can not blit.
Expand All @@ -1635,20 +1635,18 @@ private boolean windowBlitPaint(Graphics g) {
*/
private void paintView(Graphics g) {
JComponent view = (JComponent)getView();

Rectangle clip = g.getClipBounds();
if (view.getWidth() >= getWidth()) {
// Graphics is relative to JViewport, need to map to view's
// coordinates space.
int x = view.getX();
int y = view.getY();// will be negative
//System.out.println(">>>>painting JView" + x + " " + y + " " +clip);
//Graphics g1 = g.create();
g.translate(x, y);
myClip.width = clip.width;
myClip.height = clip.height;
myClip.x = clip.x - x;
myClip.y = clip.y - y;
秘myClip.width = clip.width;
秘myClip.height = clip.height;
秘myClip.x = clip.x - x;
秘myClip.y = clip.y - y;
paintForceDoubleBuffered(g, view);
//g.setColor(Math.random() > 0.5 ? Color.GREEN : Color.MAGENTA);
//g.fillRect(-x, 50-y, clip.width, clip.height);
Expand All @@ -1657,8 +1655,8 @@ private void paintView(Graphics g) {
//g.setClip(clip.x, clip.y, clip.width, clip.height);
}
else {
myClip.x = clip.x;
myClip.y = clip.y;
秘myClip.x = clip.x;
秘myClip.y = clip.y;
// To avoid any problems that may result from the viewport being
// bigger than the view we start painting from the viewport.
try {
Expand All @@ -1668,16 +1666,17 @@ private void paintView(Graphics g) {
inBlitPaint = false;
}
}

}

private void paintForceDoubleBuffered(Graphics g, JComponent c) {

g.clipRect(myClip.x, myClip.y, myClip.width, myClip.height);
g.clipRect(秘myClip.x, 秘myClip.y, 秘myClip.width, 秘myClip.height);
RepaintManager rm = RepaintManager.currentManager(c);
rm.beginPaint();
秘setFlag(JComponent.秘ISREPAINTING, true);
try {
rm.paint(c, c, g, myClip.x, myClip.y, myClip.width, myClip.height);
rm.paint(c, c, g, 秘myClip.x, 秘myClip.y, 秘myClip.width, 秘myClip.height);
} finally {
rm.endPaint();
秘setFlag(JComponent.秘ISREPAINTING, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ public boolean isEnabled(Object sender) {
//
@Override
public void actionPerformed(final ActionEvent e) {
final Object src = e.getSource();
// final Object src = e.getSource();
//
// final PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
// public Void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,9 @@ else if(lastBias != Position.Bias.Backward &&
}
if (lastBias == Position.Bias.Backward && offset > 0) {
try {
Segment s = new Segment();
s.count = 0;
s.offset = 0;
s.array = null;
component.getDocument().getText(offset - 1, 1, s);
if (s.count > 0 && s.array[s.offset] == '\n') {
lastBias = Position.Bias.Forward;
Expand All @@ -1309,6 +1311,8 @@ else if(lastBias != Position.Bias.Backward &&
}
return lastBias;
}

private static Segment s = new Segment();

// ---- local methods --------------------------------------------

Expand Down Expand Up @@ -1778,7 +1782,8 @@ public void insertUpdate(DocumentEvent e) {
Document doc = component.getDocument();
boolean isNewline;
try {
Segment s = new Segment();
s.count = s.offset = 0;
s.array = null;
doc.getText(newDot - 1, 1, s);
isNewline = (s.count > 0 &&
s.array[s.offset] == '\n');
Expand Down
Loading