public void addKerning(int second, int amount){ kerning.put(second, amount); }
protected void findVertexIndex(Vertex vert){ Integer index = vertIndexMap.get(vert); if (index != null){ vert.index = index.intValue(); }else{ vert.index = curIndex++; vertIndexMap.put(vert, vert.index); indexVertMap.put(vert.index, vert); } }
private IntMap<Savable> intSavableMapFromKV(int[] keys, Savable[] values) { if(keys == null || values == null) { return null; } IntMap<Savable> map = new IntMap<Savable>(keys.length); for (int x = 0; x < keys.length; x++) map.put(keys[x], values[x]); return map; }
private static void noEnumArgs(String method, int... argSlots) { IntMap<Void> argSlotsMap = new IntMap<Void>(); for (int argSlot : argSlots) { argSlotsMap.put(argSlot, (Void) null); } nonEnumArgMap.put(method, argSlotsMap); }
private static IntMap<String> generateConstantMap(Class<?> ... classes) { IntMap<String> constMap = new IntMap<String>(); for (Class<?> clazz : classes) { for (Field field : clazz.getFields()) { if (field.getType() == int.class) { try { int val = field.getInt(null); String name = field.getName(); constMap.put(val, name); } catch (IllegalArgumentException ex) { } catch (IllegalAccessException ex) { } } } } // GL_ONE is more common than GL_TRUE (which is a boolean anyway..) constMap.put(1, "GL_ONE"); return constMap; }
public void addCharacter(int index, BitmapCharacter ch){ getCharacterSet(0).put(index, ch); }
private IntMap<BitmapCharacter> readCharset(InputCapsule ic, int style) throws IOException { IntMap<BitmapCharacter> charset = new IntMap<BitmapCharacter>(); short[] indexes = ic.readShortArray("indexes"+style, null); Savable[] chars = ic.readSavableArray("chars"+style, null); for (int i = 0; i < indexes.length; i++){ int index = indexes[i] & 0xFFFF; BitmapCharacter chr = (BitmapCharacter) chars[i]; charset.put(index, chr); } return charset; }
private SkinBuffers getSkinBuffers(String bufferType) { int bufIndex = getIndex(bufferType); SkinBuffers buffs = skinBuffers.get(bufIndex); if (buffs == null) { buffs = new SkinBuffers(); skinBuffers.put(bufIndex, buffs); } return buffs; }
private IntMap<BitmapCharacter> getCharacterSet(int style) { if (characters.size() == 0) { characters.put(style, new IntMap<BitmapCharacter>()); } return characters.get(style); }
public void setStyle(int style) { if (characters.size() > 1) { throw new RuntimeException("Applicable only for single style font"); } Entry<IntMap<BitmapCharacter>> entry = characters.iterator().next(); IntMap<BitmapCharacter> charset = entry.getValue(); characters.remove(entry.getKey()); characters.put(style, charset); }
private SensorData initSensor(int sensorType) { boolean success = false; SensorData sensorData = sensors.get(sensorType); if (sensorData != null) { unRegisterListener(sensorType); } else { sensorData = new SensorData(sensorType, null); sensors.put(sensorType, sensorData); } sensorData.androidSensorType = sensorType; sensorData.sensor = sensorManager.getDefaultSensor(sensorType); if (sensorData.sensor != null) { logger.log(Level.FINE, "Sensor Type {0} found.", sensorType); success = registerListener(sensorType); } else { logger.log(Level.FINE, "Sensor Type {0} not found.", sensorType); } if (success) { return sensorData; } else { return null; } }
private void invokeTimedActions(int hash, long time, boolean pressed) { if (!bindings.containsKey(hash)) { return; } if (pressed) { pressedButtons.put(hash, time); } else { Long pressTimeObj = pressedButtons.remove(hash); if (pressTimeObj == null) { return; // under certain circumstances it can be null, ignore } // the event then. long pressTime = pressTimeObj; long lastUpdate = lastLastUpdateTime; long releaseTime = time; long timeDelta = releaseTime - Math.max(pressTime, lastUpdate); if (timeDelta > 0) { invokeAnalogs(hash, computeAnalogValue(timeDelta), false); } } }
public Attribute getAttribute(VertexBuffer.Type attribType){ int ordinal = attribType.ordinal(); Attribute attrib = attribs.get(ordinal); if (attrib == null){ attrib = new Attribute(); attrib.name = attribType.name(); attribs.put(ordinal, attrib); } return attrib; }
private void startLodFaceList(String submeshindex, String numfaces) { int index = Integer.parseInt(submeshindex); mesh = geoms.get(index).getMesh(); int faceCount = Integer.parseInt(numfaces); VertexBuffer originalIndexBuffer = mesh.getBuffer(Type.Index); vb = new VertexBuffer(VertexBuffer.Type.Index); if (originalIndexBuffer.getFormat() == Format.UnsignedInt) { // LOD buffer should also be integer ib = BufferUtils.createIntBuffer(faceCount * 3); sb = null; vb.setupData(Usage.Static, 3, Format.UnsignedInt, ib); } else { sb = BufferUtils.createShortBuffer(faceCount * 3); ib = null; vb.setupData(Usage.Static, 3, Format.UnsignedShort, sb); } List<VertexBuffer> levels = lodLevels.get(index); if (levels == null) { // Create the LOD levels list levels = new ArrayList<VertexBuffer>(); // Add the first LOD level (always the original index buffer) levels.add(originalIndexBuffer); lodLevels.put(index, levels); } levels.add(vb); }
/** * Called by the Renderer when a texture has been set. * * @param image The image that was set * @param wasSwitched If true, the texture has required a state switch */ public void onTextureUse(Image image, boolean wasSwitched){ assert image.getId() >= 1; if( !enabled ) return; if (!texturesUsed.containsKey(image.getId())) texturesUsed.put(image.getId(), null); if (wasSwitched) numTextureBinds ++; }
/** * Called by the Renderer when a framebuffer has been set. * * @param fb The framebuffer that was set * @param wasSwitched If true, the framebuffer required a state switch */ public void onFrameBufferUse(FrameBuffer fb, boolean wasSwitched){ if( !enabled ) return; if (fb != null){ assert fb.getId() >= 1; if (!fbosUsed.containsKey(fb.getId())) fbosUsed.put(fb.getId(), null); } if (wasSwitched) numFboSwitches ++; }
/** * Sets the {@link VertexBuffer} on the mesh. * This will update the vertex/triangle counts if needed. * * @param vb The buffer to set * @throws IllegalArgumentException If the buffer type is already set */ public void setBuffer(VertexBuffer vb){ if (buffers.containsKey(vb.getBufferType().ordinal())) { throw new IllegalArgumentException("Buffer type already set: " + vb.getBufferType()); } buffers.put(vb.getBufferType().ordinal(), vb); buffersList.add(vb); updateCounts(); }
/** * Called by the Renderer when a shader has been utilized. * * @param shader The shader that was used * @param wasSwitched If true, the shader has required a state switch */ public void onShaderUse(Shader shader, boolean wasSwitched){ assert shader.getId() >= 1; if( !enabled ) return; // Reduces unnecessary hashmap lookups if // we already considered this shader. if (lastShader != shader.getId()) { lastShader = shader.getId(); if (!shadersUsed.containsKey(shader.getId())) { shadersUsed.put(shader.getId(), null); } } if (wasSwitched) numShaderSwitches++; }
@Override public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); lineHeight = ic.readInt("lineHeight", 0); base = ic.readInt("base", 0); renderedSize = ic.readInt("renderedSize", 0); width = ic.readInt("width", 0); height = ic.readInt("height", 0); pageSize = ic.readInt("pageSize", 0); int[] styles = ic.readIntArray("styles", null); for (int style : styles) { characters.put(style, readCharset(ic, style)); } }
public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); c = (char) ic.readInt("c", 0); x = ic.readInt("x", 0); y = ic.readInt("y", 0); width = ic.readInt("width", 0); height = ic.readInt("height", 0); xOffset = ic.readInt("xOffset", 0); yOffset = ic.readInt("yOffset", 0); xAdvance = ic.readInt("xAdvance", 0); int[] seconds = ic.readIntArray("seconds", null); int[] amounts = ic.readIntArray("amounts", null); for (int i = 0; i < seconds.length; i++){ kerning.put(seconds[i], amounts[i]); } } }