com.google.gwt.core.client.JsArrayInteger Java Examples

The following examples show how to use com.google.gwt.core.client.JsArrayInteger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PZAwarePositionCallback.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private native JsArrayInteger getAbsolutePosition(Element elem) /*-{
    var curr = elem;
    var left = 0;
    var top = 0;

    if ($doc.getElementById) {
        do  {
            left += elem.offsetLeft - elem.scrollLeft;
            top += elem.offsetTop - elem.scrollTop;

            elem = elem.offsetParent;
            curr = curr.parentNode;
            while (curr != elem) {
                left -= curr.scrollLeft;
                top -= curr.scrollTop;

                curr = curr.parentNode;
            }
        } while (elem.offsetParent);
    }

    return [left, top];
}-*/;
 
Example #2
Source File: IEEE754.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static native JsArrayInteger fromDoubleClosure(double a) /*-{
   var f = 11; // ebits
   var c = 52; // fbits
   var b=(1<<f-1)-1,d,e;
   if(isNaN(a))
       e=(1<<b)-1,b=1,d=0;
   else if(Infinity===a||-Infinity===a)
       e=(1<<b)-1,b=0,d=0>a?1:0;
   else if(0===a)
       b=e=0,d=-Infinity===1/a?1:0;
   else if(d=0>a,a=Math.abs(a),a>=Math.pow(2,1-b)){
       var g=Math.min(Math.floor(Math.log(a)/Math.LN2),b);
       e=g+b;
       b=a*Math.pow(2,c-g)-Math.pow(2,c)
   }
   else
       e=0,b=a/Math.pow(2,1-b-c);
   for(a=[];c;c-=1)
       a.push(b%2?1:0),b=Math.floor(b/2);
   for(c=f;c;c-=1)
       a.push(e%2?1:0),e=Math.floor(e/2);
   a.push(d?1:0);
   a.reverse();
   f=a.join("");
   for(d=[];f.length;)
       d.push(parseInt(f.substring(0,8),2)),f=f.substring(8);
   return d;
}-*/;
 
Example #3
Source File: DataOutput.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void writeDouble(double v) throws IOException {
    growToFit(8);
    JsArrayInteger bytes = IEEE754.fromDoubleClosure(v);
    for (int i = 0; i < 8; i++) {
        this.bytes[pos++] = (byte)bytes.get(i);
    }
}
 
Example #4
Source File: DataOutput.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void writeFloat(float v) throws IOException {
    growToFit(4);
    JsArrayInteger bytes = IEEE754.fromFloat(v);
    for (int i = 0; i < 4; i++) {
        this.bytes[pos++] = (byte)bytes.get(i);
    }
}
 
Example #5
Source File: JsMessage.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public JsMessage convert(Message value) {
    JsMessenger messenger = JsMessenger.getInstance();

    String rid = value.getRid() + "";
    String sortKey = value.getSortDate() + "";

    JsPeerInfo sender = messenger.buildPeerInfo(Peer.user(value.getSenderId()));
    boolean isOut = value.getSenderId() == messenger.myUid();
    boolean isOnServer = value.isOnServer();
    String date = messenger.getFormatter().formatTime(value.getDate());
    JsDate fullDate = JsDate.create(value.getDate());

    JsContent content = JsContent.createContent(value.getContent(),
            value.getSenderId());

    JsArray<JsReaction> reactions = JsArray.createArray().cast();

    for (Reaction r : value.getReactions()) {
        JsArrayInteger uids = (JsArrayInteger) JsArrayInteger.createArray();
        boolean isOwnSet = false;
        for (Integer i : r.getUids()) {
            uids.push(i);
            if (i == messenger.myUid()) {
                isOwnSet = true;
            }
        }
        reactions.push(JsReaction.create(r.getCode(), uids, isOwnSet));
    }
    double sortDate = value.getDate() / 1000.0;
    return create(rid, sortKey, sender, isOut, date, fullDate, Enums.convert(value.getMessageState()), isOnServer, content,
            reactions, sortDate);
}
 
Example #6
Source File: LeafletStyle.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
public static JSObject getStyle(VectorStyleDef def) {

		String fillColor = def.getFill().getNormalColor();
		Double fillOpacity = def.getFill().getOpacity();
		String strokeColor = def.getLine().getNormalColor();
		Double strokeWidth = new Double(def.getLine().getThickness());
		
		JSObject styleObject = JSObject.createJSObject();
		styleObject.setProperty(FILL_NAME, true);
		styleObject.setProperty(FILL_COLOR_NAME, fillColor);
		styleObject.setProperty(FILL_OPACITY_NAME, fillOpacity);
		styleObject.setProperty(STROKE_COLOR_NAME, strokeColor);
		styleObject.setProperty(STROKE_WIDTH_NAME, strokeWidth);
		styleObject.setProperty(RADIUS_NAME, RADIUS_VALUE);
		
		
		//icon
		String iconUrl = def.getPoint().getExternalGraphic();
		if (iconUrl != null) {
			JSObject iconObject = JSObject.createJSObject();
			iconObject.setProperty(ICON_URL_NAME, iconUrl);
			JsArrayInteger iconSize = JSObject.createArray().cast();
			
			iconSize.push(def.getPoint().getGraphicWidth());
			iconSize.push(def.getPoint().getGraphicHeight());
			
			JSObject iconSizeObject = iconSize.cast();
			
			iconObject.setProperty(ICON_SIZE_NAME, iconSizeObject);	
			
			styleObject.setProperty(ICON_NAME, iconObject);
		}
						
		return styleObject;
	}
 
Example #7
Source File: TagsInputBase.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
/**
 * Array of keycodes which will add a tag when typing in the input.
 * (default: [13, 188], which are ENTER and comma)
 * 
 * @param confirmKeys Array of keycodes
 */
public void setConfirmKeys(final List<Integer> confirmKeys) {
    JsArrayInteger keys = JsArrayInteger.createArray().cast();
    
    for(int key : confirmKeys) {
        keys.push(key);
    }
    options.setConfirmKeys(keys);
}
 
Example #8
Source File: FastArrayShort.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public FastArrayShort() {
	if(GWT.isScript()) {
		stackNative = JsArrayInteger.createArray().cast();
	} else {
		stackJava = new JsList<Short>();
	}
}
 
Example #9
Source File: FastArrayInteger.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public FastArrayInteger(){
	if(GWT.isScript()) {
		stackNative = JsArrayInteger.createArray().cast();
	} else {
		stackJava = new JsList<Integer>();
	}
}
 
Example #10
Source File: IEEE754.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static native JsArrayInteger fromDouble(double v)/*-{
    var ebits = 11;
    var fbits = 52;
    var bias = (1 << (ebits - 1)) - 1;

    // Compute sign, exponent, fraction
    var s, e, f;
    if (isNaN(v)) {
        e = (1 << bias) - 1; f = 1; s = 0;
    }
    else if (v === Infinity || v === -Infinity) {
        e = (1 << bias) - 1; f = 0; s = (v < 0) ? 1 : 0;
    }
    else if (v === 0) {
        e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0;
    }
    else {
        s = v < 0;
        v = Math.abs(v);

        if (v >= Math.pow(2, 1 - bias)) {
            var ln = Math.min(Math.floor(Math.log(v) / Math.LN2), bias);
            e = ln + bias;
            f = v * Math.pow(2, fbits - ln) - Math.pow(2, fbits);
        }
        else {
            e = 0;
            f = v / Math.pow(2, 1 - bias - fbits);
        }
    }

    // Pack sign, exponent, fraction
    var i, bits = [];
    for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = Math.floor(f / 2); }
    for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = Math.floor(e / 2); }
    bits.push(s ? 1 : 0);
    bits.reverse();
    var str = bits.join('');

    // Bits to bytes
    var bytes = [];
    while (str.length) {
        bytes.push(parseInt(str.substring(0, 8), 2));
        str = str.substring(8);
    }
    return bytes;
}-*/;
 
Example #11
Source File: IEEE754.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static native JsArrayInteger fromFloat(float v)/*-{
    var ebits = 8;
    var fbits = 23;
    var bias = (1 << (ebits - 1)) - 1;

    // Compute sign, exponent, fraction
    var s, e, f;
    if (isNaN(v)) {
        e = (1 << bias) - 1; f = 1; s = 0;
    }
    else if (v === Infinity || v === -Infinity) {
        e = (1 << bias) - 1; f = 0; s = (v < 0) ? 1 : 0;
    }
    else if (v === 0) {
        e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0;
    }
    else {
        s = v < 0;
        v = Math.abs(v);

        if (v >= Math.pow(2, 1 - bias)) {
            var ln = Math.min(Math.floor(Math.log(v) / Math.LN2), bias);
            e = ln + bias;
            f = v * Math.pow(2, fbits - ln) - Math.pow(2, fbits);
        }
        else {
            e = 0;
            f = v / Math.pow(2, 1 - bias - fbits);
        }
    }

    // Pack sign, exponent, fraction
    var i, bits = [];
    for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = Math.floor(f / 2); }
    for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = Math.floor(e / 2); }
    bits.push(s ? 1 : 0);
    bits.reverse();
    var str = bits.join('');

    // Bits to bytes
    var bytes = [];
    while (str.length) {
        bytes.push(parseInt(str.substring(0, 8), 2));
        str = str.substring(8);
    }
    return bytes;
}-*/;
 
Example #12
Source File: TagsInputOptions.java    From gwtbootstrap3-extras with Apache License 2.0 4 votes vote down vote up
public final native void setConfirmKeys(JsArrayInteger keys) /*-{
    this.confirmKeys = keys;
}-*/;
 
Example #13
Source File: GeneralDisplay.java    From gwtbootstrap3-extras with Apache License 2.0 4 votes vote down vote up
public native void setHiddenDays(JsArrayInteger hiddenDays) /*-{
    var theInstance = this;
    theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.GeneralDisplay::general.hiddenDays = hiddenDays;
}-*/;
 
Example #14
Source File: FastArrayInteger.java    From gwt-jackson with Apache License 2.0 4 votes vote down vote up
private static native int[] reinterpretCast( JsArrayInteger value ) /*-{
    return value;
}-*/;
 
Example #15
Source File: FastArrayShort.java    From gwt-jackson with Apache License 2.0 4 votes vote down vote up
private static native short[] reinterpretCast( JsArrayInteger value ) /*-{
    return value;
}-*/;
 
Example #16
Source File: GeoJSONCSS.java    From geowe-core with GNU General Public License v3.0 4 votes vote down vote up
public VectorFeatureStyleDef getStyleDef(JSObject styleObject) {
	VectorFeatureStyleDef def = new VectorFeatureStyleDef();

	if (styleObject.hasProperty(LeafletStyle.FILL_COLOR_NAME)) {
		String fillColor = styleObject.getPropertyAsString(LeafletStyle.FILL_COLOR_NAME);
		def.getFill().setNormalColor(fillColor);
	}

	if (styleObject.hasProperty(LeafletStyle.FILL_OPACITY_NAME)) {
		Double fillOpacity = styleObject.getPropertyAsDouble(LeafletStyle.FILL_OPACITY_NAME);
		def.getFill().setOpacity(fillOpacity);
	}

	if (styleObject.hasProperty(LeafletStyle.STROKE_COLOR_NAME)) {
		String strokeColor = styleObject.getPropertyAsString(LeafletStyle.STROKE_COLOR_NAME);
		def.getLine().setNormalColor(strokeColor);
	}

	if (styleObject.hasProperty(LeafletStyle.STROKE_WIDTH_NAME)) {
		Double strokeWidth = styleObject.getPropertyAsDouble(LeafletStyle.STROKE_WIDTH_NAME);
		def.getLine().setThickness(strokeWidth.intValue());
	}

	JSObject iconObject = styleObject.getProperty(LeafletStyle.ICON_NAME);
	if (iconObject != null) {

		if (iconObject.hasProperty(LeafletStyle.ICON_URL_NAME)) {
			String iconUrl = iconObject.getPropertyAsString(LeafletStyle.ICON_URL_NAME);
			def.getPoint().setExternalGraphic(iconUrl);
		}

		if (iconObject.hasProperty(LeafletStyle.ICON_SIZE_NAME)) {
			JsArrayInteger iconSize = iconObject.getProperty(LeafletStyle.ICON_SIZE_NAME).cast();

			int iconWidth = iconSize.get(0);
			int iconHeight = iconSize.get(1);

			def.getPoint().setGraphicWidth(iconWidth);
			def.getPoint().setGraphicHeight(iconHeight);
		}
	}

	return def;
}
 
Example #17
Source File: JsReaction.java    From actor-platform with GNU Affero General Public License v3.0 4 votes vote down vote up
public static native JsReaction create(String reaction, JsArrayInteger uids, boolean isOwnSet)/*-{
    return {reaction: reaction, uids: uids, isOwnSet: isOwnSet};
}-*/;
 
Example #18
Source File: GwtAceEditor.java    From cuba with Apache License 2.0 4 votes vote down vote up
public final native JsArrayInteger getCoordsOf(GwtAcePosition pos) /*-{
	var p = this.getSession().documentToScreenPosition(pos);
	var c = this.renderer.textToScreenCoordinates(p.row, p.column);
	return [c.pageX,c.pageY];
}-*/;
 
Example #19
Source File: GwtAceEditor.java    From cuba with Apache License 2.0 4 votes vote down vote up
public final native JsArrayInteger getCoordsOfRowCol(int row, int column) /*-{
	var p = this.getSession().documentToScreenPosition({row:row, column:column});
	var c = this.renderer.textToScreenCoordinates(p.row, p.column);
	return [c.pageX,c.pageY];
}-*/;
 
Example #20
Source File: GwtAceEditor.java    From cuba with Apache License 2.0 4 votes vote down vote up
public final native JsArrayInteger getCursorCoords() /*-{
	var p = this.getCursorPositionScreen();
	var c = this.renderer.textToScreenCoordinates(p.row,p.column);
	return [c.pageX,c.pageY];
}-*/;
 
Example #21
Source File: AceEditorWidget.java    From cuba with Apache License 2.0 4 votes vote down vote up
public int[] getCursorCoords() {
	JsArrayInteger cc = editor.getCursorCoords();
	return new int[] {cc.get(0), cc.get(1)};
}
 
Example #22
Source File: JsArraySort.java    From incubator-retired-wave with Apache License 2.0 2 votes vote down vote up
/**
 * Sorts a JsArray of integers.
 *
 * @param sortMe Array to be sorted.
 * @param comparator Comparator to be used, per native JS sort() method.
 */
public static native void sort(JsArrayInteger sortMe, JavaScriptObject comparator) /*-{
  sortMe.sort(comparator);
}-*/;
 
Example #23
Source File: JsArraySort.java    From swellrt with Apache License 2.0 2 votes vote down vote up
/**
 * Sorts a JsArray of integers.
 *
 * @param sortMe Array to be sorted.
 * @param comparator Comparator to be used, per native JS sort() method.
 */
public static native void sort(JsArrayInteger sortMe, JavaScriptObject comparator) /*-{
  sortMe.sort(comparator);
}-*/;