Skip to content
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
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 @@
20180913053826
20180915215829
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.2/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.2/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20180913053826
20180915215829
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
6 changes: 5 additions & 1 deletion sources/net.sf.j2s.java.core/doc/Differences.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Notes
=====
updated 9/15/19 -- adds integer 1/0 == 0
updated 7/24/18 -- most classes replaced with https://github.com/frohoff/jdk8u-jdk
updated 6/28/18 -- arrays do not inherit Object
updated 2/26/18
Expand Down Expand Up @@ -174,7 +175,6 @@ JTabbedPane (in development, NEM)
MINOR ISSUES--required some rewriting/refactoring by Bob and Udo
================================================================

java.util.BitSet is implemented using 16-bit integers, not 32
Thread.currentThread() == dispatchThread


Expand Down Expand Up @@ -214,6 +214,7 @@ no format internationalization
no winding rules
text-related field implementation
Formatter/Regex limitations
integer 1/0 == 0

========================================================================

Expand Down Expand Up @@ -1133,6 +1134,9 @@ Matcher.start(groupID) is not supported.

java.util.Formatter will function correctly for all standard %... patterns.

integer 1/0 == 0
----------------

1/0 in Java throws java.lang.ArithmeticException: / by zero but in JavaScript is just 0.


4 changes: 3 additions & 1 deletion sources/net.sf.j2s.java.core/src/java/awt/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,8 @@ public void paint(Graphics g) {
}

public void paintContainer(Graphics g) {

// !NOT! -- 9/15/18
// SwingJS: split off here so that
// the new JComponent-subclassed Window can
// hit this one directly instead of JComponent.paint()
Expand Down Expand Up @@ -2693,7 +2695,7 @@ public void addNotify() {
public void setDispatcher() {
if (dispatcher != null)
return;
System.err.println("LWD dispatch for "+ this);
//System.err.println("LWD dispatch for "+ this);
dispatcher = new LightweightDispatcher(this);
}
/**
Expand Down
4 changes: 4 additions & 0 deletions sources/net.sf.j2s.java.core/src/javax/swing/BoxLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager2;
import java.io.PrintStream;

/**
* A layout manager that allows multiple components to be laid out either
Expand Down Expand Up @@ -169,6 +170,9 @@ public class BoxLayout implements LayoutManager2 {
*/
public static final int PAGE_AXIS = 3;

public BoxLayout(Container target, int axis, PrintStream dbg) {
this(target, axis);
}
/**
* Creates a layout manager that will lay out components along the
* given axis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ private void paintDirtyRegions1(
if (g != null) {
// SwingJS not clipping, for performance g.setClip(rect.x, rect.y, rect.width, rect.height);
try {
((Container) dirtyComponent).paintContainer(g); // SwingJS
((Container) dirtyComponent).paint(g); // SwingJS was paintContainer, but that bypasses user's paint(g)?? 9/15/18
} finally {
g.dispose();
}
Expand Down
27 changes: 18 additions & 9 deletions sources/net.sf.j2s.java.core/src/swingjs/JSGraphics2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public JSGraphics2D(Object canvas) { // this must be Object, because we are
hints = new RenderingHints(new Hashtable());
this.canvas = (HTML5Canvas) canvas;
ctx = this.canvas.getContext("2d");
// reduce antialiasing, thank you,
// http://www.rgraph.net/docs/howto-get-crisp-lines-with-no- antialias.html
if (!isShifted)
ctx.translate(-0.5, -0.5);
isShifted = true;
transform = new AffineTransform();
setStroke(new BasicStroke());
/**
Expand Down Expand Up @@ -184,14 +189,6 @@ private double toRad(double a) {
public void background(Color bgcolor) {
backgroundColor = bgcolor;
if (bgcolor == null) {
/*
*
* reduce antialiasing, thank you,
* http://www.rgraph.net/docs/howto-get-crisp-lines-with-no- antialias.html
*/
if (!isShifted)
ctx.translate(-0.5, -0.5);
isShifted = true;
return;
}
clearRect(0, 0, width, height);
Expand Down Expand Up @@ -244,7 +241,15 @@ public void fillRect(int x, int y, int width, int height) {
if (width <= 0 || height <= 0)
return;
backgroundPainted = true;
ctx.translate(0.5, 0.5);
ctx.fillRect(x, y, width, height);
ctx.translate(-0.5, -0.5);
//
// if (width == 1)
// drawLine(x, y, x, y + height);
// else if (height == 1)
// drawLine(x, y, x + width, y);
// else
}

public void draw3DRect(int x, int y, int width, int height, boolean raised) {
Expand Down Expand Up @@ -702,10 +707,14 @@ public Shape getClip() {
}

public void drawString(String s, int x, int y) {
ctx.fillText(s, x, y);
fillText(s, x, y);
}

public void drawString(String str, float x, float y) {
fillText(str, x, y);
}

private void fillText(String str, float x, float y) {
ctx.fillText(str, x, y);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,9 @@
.swingjs .ui-j2sslider-tick-mark-vert { display:inline-block; width:1px; background: black; border:1px; height:5px; position:absolute; top:12px; }
.swingjs .ui-j2sslider-tick-mark-horiz { display:inline-block; height:1px; background: black; border:1px; width:5px; position:absolute; left:14px; }

.swingjs .ui-j2sslider-at-bottom { border-bottom-width:3px; border-bottom-color:red }
.swingjs .ui-j2sslider-at-top { border-top-width:3px; border-top-color:red }
.swingjs .ui-j2sslider-at-left { border-left-width:3px; border-left-color:red }
.swingjs .ui-j2sslider-at-right { border-right-width:3px; border-right-color:red }


Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@

var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle;

var clearEnds = function(e) {
e.removeClass("ui-j2sslider-at-top");
e.removeClass("ui-j2sslider-at-bottom");
e.removeClass("ui-j2sslider-at-left");
e.removeClass("ui-j2sslider-at-right");
};

$
.widget(
"ui.j2sslider",
Expand Down Expand Up @@ -137,6 +144,14 @@
me._mouseSliding = false;
};

var fOutTrack = function(event, id) {
clearEnds(me.element);
};

var fMoveTrack = function(event, id) {
me._doMouseCapture(event, true, true);
};

var fDrag = function(xye, id) {
if (me.options.disabled)
return;
Expand Down Expand Up @@ -190,9 +205,14 @@
fUp ]);
}

if (handleCount == 1)
if (handleCount == 1) {
$(this.element).mousedown(fDownTrack);

if (this.isScrollBar) {
$(this.element).mousemove(fMoveTrack);
$(this.element).mouseout(fOutTrack);
}
}

this.handle = this.handles.eq(0);

this.handles.add(this.range).filter("a").click(
Expand Down Expand Up @@ -231,7 +251,8 @@
this._mouseDestroy();
},

_doMouseCapture : function(event, isTrackClick) {
_doMouseCapture : function(event, isTrackClick, isEndCheck) {

var that = this, o = this.options;

if (o.disabled) {
Expand Down Expand Up @@ -293,11 +314,11 @@
this._clickOffset = (mouseOverHandle ? {
left : position.x
- offset.left
- (closestHandle.width() / 2 * this.options.scaleX)
- (closestHandle.width() / 2 * o.scaleX)
,
top : position.y
- offset.top
- (closestHandle.height() / 2 * this.options.scaleY)
- (closestHandle.height() / 2 * o.scaleY)
- (parseInt(closestHandle
.css("borderTopWidth"), 10) || 0)
- (parseInt(closestHandle
Expand All @@ -310,10 +331,27 @@
left : 0,
top : 0
});

normValue = this._normValueFromMouse(position, isTrackClick);
var val = this._normValueFromMouse(position, isTrackClick);
var isMin = false;
var isAtEnd = (!this.isScrollBar ? 0 : (isMin = (val == this._valueMin())) ? -1
: val >= this._getRealMax() - (isTrackClick ? 0 : o.jslider.ui.getUnitIncrement$()) ? 1 : 0);
if (isAtEnd) {
this.element.addClass(this.orientation === "horizontal" ?
(isAtEnd == 1 ? "ui-j2sslider-at-right" : "ui-j2sslider-at-left")
: (isAtEnd == 1 ? "ui-j2sslider-at-bottom" : "ui-j2sslider-at-top"));
} else {
clearEnds(this.element);
}
if (isEndCheck) {
return;
}
var dir = Math.signum(!isAtEnd ? val - o.jslider.getValue$() : isMin ? -1 : 1);
if (!this.handles.hasClass("ui-state-hover")) {
this._slide(event, index, normValue);
if (isAtEnd) {
o.jslider.ui.scrollByUnit$I(dir);
} else if (isTrackClick) {
o.jslider.ui.scrollDueToClickInTrack$I(dir);
}
}
this._animateOff = true;
return true;
Expand Down Expand Up @@ -573,7 +611,7 @@
this._animateOff = false;
break;
case "handleSize":
this.isScrollBar = this.options.isScrollBar = true;
this.isScrollBar = true;
this.handleFraction = value;
if (this.orientation === "horizontal")
$(this.handles[0]).width(this.handleSize = value * this.element.outerWidth());
Expand All @@ -590,10 +628,7 @@
// _value() returns value trimmed by min and max,
// aligned by step
_value : function() {
var val = this.options.value;
val = this._trimAlignValue(val);

return val;
return this._trimAlignValue(this.options.value);
},

// internal values getter
Expand All @@ -602,33 +637,30 @@
// _values( index ) returns single value trimmed by
// min and max, aligned by step
_values : function(index) {
var val, vals, i;

if (arguments.length) {
val = this.options.values[index];
val = this._trimAlignValue(val);

return val;
} else {
// .slice() creates a copy of the array
// this copy gets trimmed by min and max and
// then returned
vals = this.options.values.slice();
for (i = 0; i < vals.length; i += 1) {
vals[i] = this._trimAlignValue(vals[i]);
}

return vals;
return this._trimAlignValue(this.options.values[index]);
}
// .slice() creates a copy of the array
// this copy gets trimmed by min and max and
// then returned
var vals = this.options.values.slice();
for (var i = 0; i < vals.length; i += 1) {
vals[i] = this._trimAlignValue(vals[i]);
}
return vals;
},

_getRealMax : function() {
return Math.round((this._valueMax() - this._valueMin()) * (1-this.handleFraction) + this._valueMin());
},

// returns the step-aligned value that val is
// closest to, between (inclusive) min and max
_trimAlignValue : function(val) {
if (val <= this._valueMin()) {
return this._valueMin();
}
var max = Math.round((this._valueMax() - this._valueMin()) * (1-this.handleFraction) + this._valueMin());
var max = this._getRealMax();
if (val >= max) {
return max;
}
Expand Down Expand Up @@ -791,3 +823,4 @@
})(J2S.__$);

})();
// BH 9/15/2018
14 changes: 7 additions & 7 deletions sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1614,14 +1614,14 @@ protected void setHorizontalButtonAlignments(JComponent b, int pos, int align) {
DOMNode.setStyles(iconNode, "left", null, "right", null);
DOMNode.setStyles(centeringNode, "text-align", null, "left", null, "right", null);
DOMNode.setStyles(centeringNode, poslr, "0px", "text-align", alignlr);
if (buttonNode != null) {
DOMNode.setStyles(buttonNode, "text-align", null, "left", null, "right", null);
DOMNode.setStyles(buttonNode, "text-align", alignlr, alignlr, "0px");
}
//if (buttonNode != null) {
DOMNode.setStyles(domNode, "text-align", null, "left", null, "right", null);
DOMNode.setStyles(domNode, "text-align", alignlr, poslr, "0px");
//}
if (centered) {
int w = actualWidth;
if (w == 0)
w = setHTMLSize1(centeringNode, false, false).width;
int w = (buttonNode == null ?
$(domNode).width() : setHTMLSize1(centeringNode, false, false).width
);
int off = (w - wText - wIcon) / 2;
if (text0) {
DOMNode.setStyles(textNode, "left", off + "px");
Expand Down
9 changes: 8 additions & 1 deletion sources/net.sf.j2s.java.core/src/swingjs/plaf/JSLabelUI.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package swingjs.plaf;

import java.awt.Container;
import java.awt.Dimension;

import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
Expand Down Expand Up @@ -52,7 +55,7 @@ public DOMNode updateDOMNode() {
if (label != null) {
// not for JToolTip
setHorizontalButtonAlignments(label, label.getHorizontalTextPosition(),
label.getHorizontalAlignment());
label.getHorizontalAlignment());
}
if (jc.isOpaque() && jc.isEnabled())
setBackground(jc.getBackground());
Expand Down Expand Up @@ -89,4 +92,8 @@ public void uninstallUI(JComponent jc) {

}

Dimension getMaximumSize(JComponent jc) {
return getPreferredSize();
}

}
Loading