Skip to content

Commit f2ed22a

Browse files
authored
Merge pull request #90 from BobHanson/master
antialias, menus, scrollbars, URLConnection.useCache()/.useDefaultCache()
2 parents 0c1e49e + aac7d01 commit f2ed22a

File tree

12 files changed

+107
-37
lines changed

12 files changed

+107
-37
lines changed
-21 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181120230421
1+
20181121134911
-21 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181120230421
1+
20181121134911
-21 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/javajs/util/AjaxURLConnection.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.net.HttpURLConnection;
77
import java.net.URL;
88
import java.net.URLConnection;
9+
import java.util.Hashtable;
10+
import java.util.Map;
911

1012
import javajs.api.js.J2SObjectInterface;
1113

@@ -71,7 +73,25 @@ public void outputString(String post) {
7173
public InputStream getInputStream() {
7274
responseCode = 200;
7375
BufferedInputStream is = getAttachedStreamData(url, false);
74-
return (is == null ? attachStreamData(url, doAjax(true)) : is);
76+
if (is != null || getUseCaches() && (is = getCachedStream(url)) != null)
77+
return is;
78+
is = attachStreamData(url, doAjax(true));
79+
if (getUseCaches() && is != null)
80+
setCachedStream(url);
81+
return is;
82+
}
83+
84+
static Map<String, Object> urlCache = new Hashtable<String, Object>();
85+
86+
private BufferedInputStream getCachedStream(URL url) {
87+
Object data = urlCache.get(url.toString());
88+
return (data == null ? null : Rdr.toBIS(data));
89+
}
90+
91+
private void setCachedStream(URL url) {
92+
Object data = url._streamData;
93+
if (data != null)
94+
urlCache.put(url.toString(), data);
7595
}
7696

7797
/**
@@ -96,6 +116,7 @@ public static BufferedInputStream getAttachedStreamData(URL url, boolean andDele
96116
}
97117

98118
public static BufferedInputStream attachStreamData(URL url, Object o) {
119+
99120
/**
100121
* @j2sNative
101122
*

sources/net.sf.j2s.java.core/src/swingjs/JSGraphics2D.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,18 @@ public JSGraphics2D(Object canvas) { // this must be Object, because we are
9898
*/
9999
{
100100
}
101-
// removed - caused blurriness 9/17/2018
102101
// // reduce antialiasing, thank you,
103102
// // http://www.rgraph.net/docs/howto-get-crisp-lines-with-no- antialias.html
104-
// having this set default TRUE gave extra lines around panels in Jalview
105-
setAntialias(false);
103+
setAntialias(true);
106104
}
107105

108106
public void setAntialias(boolean tf) {
109107
if (tf) {
110108
if (!isShifted)
111-
ctx.translate(-0.5, -0.5);
109+
ctx.translate(0.5, 0.5);
112110
} else {
113111
if (isShifted)
114-
ctx.translate(0.5, 0.5);
112+
ctx.translate(-0.5, -0.5);
115113
}
116114
// this is important if images are being drawn - test/TAPP6
117115
// see also http://vaughnroyko.com/state-of-nearest-neighbor-interpolation-in-canvas/

sources/net.sf.j2s.java.core/src/swingjs/jquery/j2sMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Swing.__getMenuStyle = function(applet) { return '\
125125
.swingjsPopupMenu .ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat;position:absolute;top:.2em;left:.2em}\
126126
.swingjsPopupMenu .ui-menu-icon{position:static;float:right}\
127127
.swingjsPopupMenu .ui-icon-carat-1-e{min-width:10ex;text-align:right;background-image:none;background-position:0 0}\
128-
.swingjsPopupMenu .ui-icon-carat-1-e:after{content:"\\0023F5"}\
128+
.swingjsPopupMenu .ui-icon-carat-1-e:after{content:"\\0025B6"}\
129129
.swingjsPopupMenu .ui-state-default{border:1px solid #c5dbec;background:#dfeffc;color:#2e6e9e}\
130130
.swingjsPopupMenu .ui-state-default a{color:#2e6e9e;text-decoration:none}\
131131
.swingjsPopupMenu .ui-state-hover,.swingjsPopupMenu .ui-state-focus{border:1px solid #79b7e7;background:#d0e5f5;color:#1d5987}\

sources/net.sf.j2s.java.core/src/swingjs/jquery/jquery-ui-j2sslider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@
618618
},
619619

620620
_getPixelMouse : function(position, offsetHandle) {
621-
var offset = this.element.offset;
621+
var offset = this.element.offset();
622622
var p = (this.orientation === "horizontal" ?
623623
position.x
624624
- offset.left

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuUI.java

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import javax.swing.JComponent;
99
import javax.swing.JMenu;
1010
import swingjs.api.js.DOMNode;
11-
public class JSMenuUI extends JSMenuItemUI implements ContainerListener {
12-
11+
public class JSMenuUI extends JSMenuItemUI {
12+
1313
private JMenu jm;
1414

1515
public JSMenuUI() {
@@ -76,8 +76,6 @@ public boolean handleJSEvent(Object target, int eventType, Object jQueryEvent) {
7676
public void installUI(JComponent jc) {
7777
jm = (JMenu) jc;
7878
super.installUI(jc);
79-
// handle add/remove
80-
jm.getPopupMenu().addContainerListener(this);
8179
}
8280

8381
@Override
@@ -91,22 +89,4 @@ public Dimension getMaximumSize() {
9189
return getPreferredSize();
9290
}
9391

94-
@Override
95-
public void componentAdded(ContainerEvent e) {
96-
JSPopupMenuUI popupui = (JSPopupMenuUI) jm.getPopupMenu().getUI();
97-
// OK, the idea here is that we detach all child nodes
98-
// and then reattach them.
99-
DOMNode.detachAll(popupui.outerNode);
100-
popupui.setTainted();
101-
popupui.setHTMLElement();
102-
}
103-
104-
@Override
105-
public void componentRemoved(ContainerEvent e) {
106-
JSPopupMenuUI popupui = (JSPopupMenuUI) jm.getPopupMenu().getUI();
107-
DOMNode.detachAll(popupui.outerNode);
108-
popupui.setTainted();
109-
popupui.setHTMLElement();
110-
}
111-
11292
}

0 commit comments

Comments
 (0)