当前位置: 首页>>代码示例>>Java>>正文


Java TypedArrays类代码示例

本文整理汇总了Java中com.google.gwt.typedarrays.shared.TypedArrays的典型用法代码示例。如果您正苦于以下问题:Java TypedArrays类的具体用法?Java TypedArrays怎么用?Java TypedArrays使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TypedArrays类属于com.google.gwt.typedarrays.shared包,在下文中一共展示了TypedArrays类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: putMethod

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public Promise<HTTPResponse> putMethod(String url, byte[] contents) {
    return new Promise<>(resolver -> {
        JsHttpRequest request = JsHttpRequest.create();
        request.open("PUT", url);
        request.setRequestHeader("Content-Type", "application/octet-stream");
        request.setOnLoadHandler(request1 -> {
            if (request1.getReadyState() == 4) {
                if (request1.getStatus() >= 200 && request1.getStatus() < 300) {
                    resolver.result(new HTTPResponse(request1.getStatus(), null));
                } else {
                    resolver.error(new HTTPError(request1.getStatus()));
                }
            }
        });
        Uint8Array push = TypedArrays.createUint8Array(contents.length);
        for (int i = 0; i < contents.length; i++) {
            push.set(i, contents[i]);
        }
        request.send(push.buffer());
    });
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:23,代码来源:JsHttpProvider.java

示例2: send

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public void send(ByteBuffer data) {
  int len = data.limit();
  // TODO(haustein) Sending the view directly does not work for some reason.
  // May be a chrome issue...?
  //  Object trick = data;
  // ArrayBufferView ta = ((HasArrayBufferView) trick).getTypedArray();
  // Int8Array view = Int8Array.create(ta.getBuffer(), ta.getByteOffset(), len)
  // ws.send(view);
  ArrayBuffer buf = TypedArrays.createArrayBuffer(len);
  Uint8Array view = TypedArrays.createUint8Array(buf);
  for (int i = 0; i < len; i++) {
    view.set(i, data.get(i));
  }
  ws.send(buf);
}
 
开发者ID:playn,项目名称:playn,代码行数:17,代码来源:HtmlWebSocket.java

示例3: BSInputStream

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
/**
  * Creates a new BSInputStream object.
* @param bsInputStream 
  */
 public BSInputStream(BSInputStream toCopy) {
  this.zp = new ZPCodec(toCopy.zp);
  for (int i = 0; i < toCopy.ctx.length; i++) {
	  if (toCopy.ctx[i] != null) {
		  ctx[i] = new BitContext((short) (toCopy.ctx[i].get() & 0xFF));
	  }
  }
  if (toCopy.data != null) {
	  data = TypedArrays.createUint8Array(toCopy.data.length());
	  data.set(toCopy.data);
  }
  eof = toCopy.eof;
  blocksize = toCopy.blocksize;
  bptr = toCopy.bptr;
  size = toCopy.size;
 }
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:21,代码来源:BSInputStream.java

示例4: loadBinary

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
public void loadBinary (final String url, final AssetLoaderListener<Blob> listener) {
	XMLHttpRequest request = XMLHttpRequest.create();		
	request.setOnReadyStateChange(new ReadyStateChangeHandler() {
		@Override
		public void onReadyStateChange (XMLHttpRequest xhr) {
			if (xhr.getReadyState() == XMLHttpRequest.DONE) {
				if (xhr.getStatus() != 200) {
					listener.onFailure();
				} else {
					Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
					listener.onSuccess(new Blob(data));
				}
			}
		}
	});
	setOnProgress(request, listener);
	request.open("GET", url);
	request.setResponseType(ResponseType.ArrayBuffer);
	request.send();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:21,代码来源:AssetDownloader.java

示例5: doSend

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public void doSend(byte[] data) {
    // Log.d(TAG, "doSend");
    if (isClosed) {
        return;
    }
    Uint8Array push = TypedArrays.createUint8Array(data.length);
    for (int i = 0; i < data.length; i++) {
        push.set(i, data[i]);
    }
    send(push);
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:13,代码来源:WebSocketConnection.java

示例6: convertBytes

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
public static byte[] convertBytes(ArrayBuffer buffer) {
    Uint8Array array = TypedArrays.createUint8Array(buffer);
    byte[] res = new byte[array.length()];
    for (int i = 0; i < res.length; i++) {
        res[i] = (byte) (array.get(i));
    }
    return res;
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:9,代码来源:Conversion.java

示例7: read

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public Promise<FilePart> read(int fileOffset, int len) {
    return new Promise<>(resolver -> {
        JsFileReader fileReader = JsFileReader.create();
        fileReader.setOnLoaded(message -> {
            Uint8Array array = TypedArrays.createUint8Array(message);
            byte[] data = new byte[len];
            for (int i = 0; i < len; i++) {
                data[i] = (byte) (array.get(i));
            }
            resolver.result(new FilePart(fileOffset, len, data));
        });
        fileReader.readAsArrayBuffer(jsFile.slice(fileOffset, fileOffset + len));
    });
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:16,代码来源:JsFileInput.java

示例8: FloatBuffer

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
FloatBuffer (ByteBuffer byteBuffer) {
  super((byteBuffer.capacity() >> 2));
  this.byteBuffer = byteBuffer;
  this.byteBuffer.clear();
  this.floatArray = TypedArrays.createFloat32Array(
    byteBuffer.byteArray.buffer(), byteBuffer.byteArray.byteOffset(), capacity);
}
 
开发者ID:playn,项目名称:playn,代码行数:8,代码来源:FloatBuffer.java

示例9: IntBuffer

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
IntBuffer(ByteBuffer byteBuffer) {
  super((byteBuffer.capacity() >> 2));
  this.byteBuffer = byteBuffer;
  this.byteBuffer.clear();
  this.intArray = TypedArrays.createInt32Array(
      byteBuffer.byteArray.buffer(),
      byteBuffer.byteArray.byteOffset(), capacity);
}
 
开发者ID:playn,项目名称:playn,代码行数:9,代码来源:IntBuffer.java

示例10: ShortBuffer

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
ShortBuffer(ByteBuffer byteBuffer) {
  super((byteBuffer.capacity() >> 1));
  this.byteBuffer = byteBuffer;
  this.byteBuffer.clear();
  this.shortArray = TypedArrays.createInt16Array(
      byteBuffer.byteArray.buffer(),
      byteBuffer.byteArray.byteOffset(), capacity);
}
 
开发者ID:playn,项目名称:playn,代码行数:9,代码来源:ShortBuffer.java

示例11: getTypedArray

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
/**
 * Returns the typed array of the given native buffer. Set byteSize to -1 to use remaining().
 */
private ArrayBufferView getTypedArray(Buffer buffer, int type, int byteSize) {
  if (!(buffer instanceof HasArrayBufferView)) {
    throw new RuntimeException("Native buffer required " + buffer);
  }
  HasArrayBufferView arrayHolder = (HasArrayBufferView) buffer;
  int bufferElementSize = arrayHolder.getElementSize();

  ArrayBufferView webGLArray = arrayHolder.getTypedArray();
  if (byteSize == -1) {
    byteSize = buffer.remaining() * bufferElementSize;
  }
  if (byteSize == buffer.capacity() * bufferElementSize && type == arrayHolder.getElementType()) {
    return webGLArray;
  }

  int byteOffset = webGLArray.byteOffset() + buffer.position() * bufferElementSize;

  switch (type) {
    case FLOAT:
      return TypedArrays.createFloat32Array(webGLArray.buffer(), byteOffset, byteSize / 4);
    case UNSIGNED_BYTE:
      return TypedArrays.createUint8Array(webGLArray.buffer(), byteOffset, byteSize);
    case UNSIGNED_SHORT:
      return TypedArrays.createUint16Array(webGLArray.buffer(), byteOffset, byteSize / 2);
    case INT:
      return TypedArrays.createInt32Array(webGLArray.buffer(), byteOffset, byteSize / 4);
    case SHORT:
      return TypedArrays.createInt16Array(webGLArray.buffer(), byteOffset, byteSize / 2);
    case BYTE:
      return TypedArrays.createInt8Array(webGLArray.buffer(), byteOffset, byteSize);
    default:
      throw new IllegalArgumentException("Type: " + type);
  }
}
 
开发者ID:playn,项目名称:playn,代码行数:38,代码来源:HtmlGL20.java

示例12: getBytes

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public RFuture<ByteBuffer> getBytes(final String path) {
  if (!TypedArrays.isSupported()) return RFuture.failure(
    new UnsupportedOperationException("TypedArrays not supported by this browser."));
  return doXhr(pathPrefix + path, XMLHttpRequest.ResponseType.ArrayBuffer).
    map(new Function<XMLHttpRequest,ByteBuffer>() {
      public ByteBuffer apply (XMLHttpRequest xhr) {
        return TypedArrayHelper.wrap(xhr.getResponseArrayBuffer());
      }
    });
}
 
开发者ID:playn,项目名称:playn,代码行数:12,代码来源:HtmlAssets.java

示例13: downloadFile

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
private void downloadFile(final String url) {
	XMLHttpRequest request = XMLHttpRequest.create();
	request.open("GET", url);
	request.setResponseType(ResponseType.ArrayBuffer);
	request.setOnReadyStateChange(new ReadyStateChangeHandler() {
		@Override
		public void onReadyStateChange(XMLHttpRequest xhr) {
			if (xhr.getReadyState() == XMLHttpRequest.DONE) {
				downloadsInProgress--;
				if (xhr.getStatus() == 200) {
					FileItem entry = getCachedFile(url);
					entry.data = TypedArrays.createUint8Array(xhr.getResponseArrayBuffer());
					entry.dataSize = entry.data.byteLength();
					filesMemoryUsage += entry.dataSize;
					checkFilesMemory();
					context.startProcessing();
					fireReady(url);
					continueDownload();
				} else {
					GWT.log("Error downloading " + url);
					GWT.log("response status: " + xhr.getStatus() + " " + xhr.getStatusText());
					context.setStatus(ProcessingContext.STATUS_ERROR);
					fileCache.get(url).downloadStarted = false;
				}
			}
		}
	});
	request.send();
	fileCache.get(url).downloadStarted = true;
	downloadsInProgress++;
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:32,代码来源:PageDecoder.java

示例14: IWCodec

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
/**
 * Creates a new IWCodec object.
 */
public IWCodec()
{
  ctxStart = new BitContext[32];

  for(int i = 0; i < 32; i++)
  {
    ctxStart[i] = new BitContext();
  }

  ctxBucket = new BitContext[10][8];

  for(int i = 0; i < 10; i++)
  {
    for(int j = 0; j < 8; j++)
    {
      ctxBucket[i][j] = new BitContext();
    }
  }

  quant_hi      = TypedArrays.createInt32Array(10);
  quant_lo      = TypedArrays.createInt32Array(16);
  coeffstate    = TypedArrays.createInt8Array(256);
  bucketstate   = TypedArrays.createInt8Array(16);
  curband       = 0;
  curbit        = 1;
  ctxMant       = new BitContext();
  ctxRoot       = new BitContext();
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:32,代码来源:IWCodec.java

示例15: doSend

import com.google.gwt.typedarrays.shared.TypedArrays; //导入依赖的package包/类
@Override
public void doSend(byte[] data) {
    if (isClosed) {
        return;
    }
    Uint8Array push = TypedArrays.createUint8Array(data.length);
    for (int i = 0; i < data.length; i++) {
        push.set(i, data[i]);
    }
    send(push);
}
 
开发者ID:dsaved,项目名称:africhat-platform-0.1,代码行数:12,代码来源:WebSocketConnection.java


注:本文中的com.google.gwt.typedarrays.shared.TypedArrays类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。