Java Code Examples for com.badlogic.gdx.utils.Pool#free()
The following examples show how to use
com.badlogic.gdx.utils.Pool#free() .
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: Pools.java From Cubes with MIT License | 5 votes |
public static <T> void registerType(Class<? extends T> c, Pool<T> pool) { T obj = pool.obtain(); Class<?> objClass = obj.getClass(); pool.free(obj); if (objClass.equals(c)) { synchronized (pools) { if (!pools.containsKey(c)) { pools.put(c, pool); } } } else { throw new CubesException("Calling obtain on " + pool + " does not return " + c.getName()); } }
Example 2
Source File: Pools.java From Cubes with MIT License | 5 votes |
public static <T> void free(Class<T> c, T obj) { Pool<T> pool = pool(c); if (pool == null) return; synchronized (pool) { pool.free(obj); } }
Example 3
Source File: Pools.java From Cubes with MIT License | 5 votes |
public static <T> void free(T obj) { Pool pool = pool(obj); if (pool == null) return; synchronized (pool) { pool.free(obj); } }
Example 4
Source File: Pools.java From Cubes with MIT License | 5 votes |
public static void free(AreaReference obj) { Pool pool = pool(AreaReference.class); if (pool == null) return; synchronized (pool) { pool.free(obj); } }
Example 5
Source File: Pools.java From Cubes with MIT License | 5 votes |
public static void free(BlockReference obj) { Pool pool = pool(BlockReference.class); if (pool == null) return; synchronized (pool) { pool.free(obj); } }
Example 6
Source File: MultiPool.java From artemis-odb-orion with Apache License 2.0 | 4 votes |
static <T extends Operation> void free(T operation) { Pool<T> pool = (Pool<T>) context.get().pool(operation.getClass()); pool.free(operation); }
Example 7
Source File: HighlightTextArea.java From vis-ui with Apache License 2.0 | 4 votes |
@Override protected void calculateOffsets () { super.calculateOffsets(); if (chunkUpdateScheduled == false) return; chunkUpdateScheduled = false; highlights.sort(); renderChunks.clear(); String text = getText(); Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class); GlyphLayout layout = layoutPool.obtain(); boolean carryHighlight = false; for (int lineIdx = 0, highlightIdx = 0; lineIdx < linesBreak.size; lineIdx += 2) { int lineStart = linesBreak.items[lineIdx]; int lineEnd = linesBreak.items[lineIdx + 1]; int lineProgress = lineStart; float chunkOffset = 0; for (; highlightIdx < highlights.size; ) { Highlight highlight = highlights.get(highlightIdx); if (highlight.getStart() > lineEnd) { break; } if (highlight.getStart() == lineProgress || carryHighlight) { renderChunks.add(new Chunk(text.substring(lineProgress, Math.min(highlight.getEnd(), lineEnd)), highlight.getColor(), chunkOffset, lineIdx)); lineProgress = Math.min(highlight.getEnd(), lineEnd); if (highlight.getEnd() > lineEnd) { carryHighlight = true; } else { carryHighlight = false; highlightIdx++; } } else { //protect against overlapping highlights boolean noMatch = false; while (highlight.getStart() <= lineProgress) { highlightIdx++; if (highlightIdx >= highlights.size) { noMatch = true; break; } highlight = highlights.get(highlightIdx); if (highlight.getStart() > lineEnd) { noMatch = true; break; } } if (noMatch) break; renderChunks.add(new Chunk(text.substring(lineProgress, highlight.getStart()), defaultColor, chunkOffset, lineIdx)); lineProgress = highlight.getStart(); } Chunk chunk = renderChunks.peek(); layout.setText(style.font, chunk.text); chunkOffset += layout.width; //current highlight needs to be applied to next line meaning that there is no other highlights that can be applied to currently parsed line if (carryHighlight) break; } if (lineProgress < lineEnd) { renderChunks.add(new Chunk(text.substring(lineProgress, lineEnd), defaultColor, chunkOffset, lineIdx)); } } maxAreaWidth = 0; for (String line : text.split("\\n")) { layout.setText(style.font, line); maxAreaWidth = Math.max(maxAreaWidth, layout.width + 30); } layoutPool.free(layout); updateScrollLayout(); }
Example 8
Source File: VisTextArea.java From vis-ui with Apache License 2.0 | 4 votes |
@Override protected void calculateOffsets () { super.calculateOffsets(); if (!this.text.equals(lastText)) { this.lastText = text; BitmapFont font = style.font; float maxWidthLine = this.getWidth() - (style.background != null ? style.background.getLeftWidth() + style.background.getRightWidth() : 0); linesBreak.clear(); int lineStart = 0; int lastSpace = 0; char lastCharacter; Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class); GlyphLayout layout = layoutPool.obtain(); for (int i = 0; i < text.length(); i++) { lastCharacter = text.charAt(i); if (lastCharacter == ENTER_DESKTOP || lastCharacter == ENTER_ANDROID) { linesBreak.add(lineStart); linesBreak.add(i); lineStart = i + 1; } else { lastSpace = (continueCursor(i, 0) ? lastSpace : i); layout.setText(font, text.subSequence(lineStart, i + 1)); if (layout.width > maxWidthLine && softwrap) { if (lineStart >= lastSpace) { lastSpace = i - 1; } linesBreak.add(lineStart); linesBreak.add(lastSpace + 1); lineStart = lastSpace + 1; lastSpace = lineStart; } } } layoutPool.free(layout); // Add last line if (lineStart < text.length()) { linesBreak.add(lineStart); linesBreak.add(text.length()); } showCursor(); } }
Example 9
Source File: PooledBehaviorTreeLibrary.java From gdx-ai with Apache License 2.0 | 4 votes |
@Override public void disposeBehaviorTree(final String treeReference, BehaviorTree<?> behaviorTree) { Pool<BehaviorTree> pool = getPool(treeReference); pool.free(behaviorTree); }