public final Date getTime(String key) { String type = getType(key); if ("array".equals(type)) { JsArrayInteger jsAray = getNativeValue(key).cast(); Date date = new Date(); date.setHours(jsAray.get(0)); date.setMinutes(jsAray.get(1)); date.setSeconds(jsAray.get(2)); return date; } return null; }
public int nextSetBit(int fromIndex) { checkIndex(fromIndex); int index = wordIndex(fromIndex); // check the current word int word = getWord(array, index); if (word != 0) { for (int i = bitOffset(fromIndex); i < 32; i++) { if ((word & (1 << i)) != 0) { return (bitIndex(index)) + i; } } } index++; // find the next set word trimToSize(array); index = nextSetWord(array, index); if (index == -1) { return -1; } // return the next set bit return (bitIndex(index)) + Integer.numberOfTrailingZeros(array.get(index)); };
public void and(BitSet set) { // a & a is just a if (this == set) { return; } // trim the second set to avoid extra work trimToSize(set.array); // check if the length is longer than otherLength int otherLength = set.array.length(); if (array.length() > otherLength) { // shrink the array, effectively ANDing those bits to false setLengthWords(array, otherLength); } // truth table // // case | a | b | a & b | change? // 1 | false | false | false | a is already false // 2 | false | true | false | a is already false // 3 | true | false | false | set a to false // 4 | true | true | true | a is already true // // we only need to change something in case 3, so iterate over set a int index = 0; while ((index = nextSetWord(array, index)) != -1) { setWord(array, index, array.get(index) & getWord(set.array, index)); index++; } }
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); } }
public void writeDouble(double v) throws IOException { growToFit(8); JsArrayInteger bytes = IEEE754.fromDouble(v); for (int i = 0; i < 8; i++) { this.bytes[pos++] = (byte) bytes.get(i); } }
private int[] jsArrayIntegerToIntArray(JsArrayInteger values) { int len = values.length(); int[] vals = new int[len]; for (int i = 0; i < len; i++) { vals[i] = values.get(i); } return vals; }
public DragObject(Element draggableElement, Element containerElement) { m_draggableElement = draggableElement; m_containerElement = containerElement; // User m_vertexgroup because this is what we scale instead of every vertex element m_transform = D3.getTransform(D3.d3().select(m_vertexGroup).attr("transform")); JsArrayInteger position = D3.getMouse(containerElement); m_startX = (int) (position.get(0) / m_transform.getScale().get(0)); m_startY = (int) (position.get(1) / m_transform.getScale().get(1)); }
public final Date getDate(String key) { String type = getType(key); if ("number".equals(type)) { return new Date(getLong(key)); } else if ("date".equals(type)) { return getNativeDate(key); } else if ("string".equals(type)) { // DateTimeFormat dtf = DateTimeFormat.getFormat(Defaults.getDateFormat()); // return dtf.parse(get(key)); } else if ("array".equals(type)) { JsArrayInteger jsAray = getNativeValue(key).cast(); Date date = new Date(); date.setYear(jsAray.get(0)); date.setMonth(jsAray.get(1)); date.setDate(jsAray.get(2)); if (jsAray.length() > 3) { date.setHours(jsAray.get(3)); date.setMinutes(jsAray.get(4)); date.setSeconds(jsAray.get(5)); } return date; } return null; }
public boolean intersects(BitSet set) { int last = trimToSize(array); if (this == set) { // if it has any bits then it intersects itself return last != -1; } int length = set.array.length(); int index = 0; while ((index = nextSetWord(array, index)) != -1) { if ((array.get(index) & getWord(set.array, index)) != 0) { return true; } if (++index >= length) { // nothing further can intersect break; } } return false; }
public int getCurrentY() { JsArrayInteger position = D3.getMouse(m_containerElement); return (int) (position.get(1) / m_transform.getScale().get(1)); }