id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
1,400
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Shape.java
Shape.findCenter
protected void findCenter() { center = new float[]{0, 0}; int length = points.length; for(int i=0;i<length;i+=2) { center[0] += points[i]; center[1] += points[i + 1]; } center[0] /= (length / 2); center[1] /= (length / 2); }
java
protected void findCenter() { center = new float[]{0, 0}; int length = points.length; for(int i=0;i<length;i+=2) { center[0] += points[i]; center[1] += points[i + 1]; } center[0] /= (length / 2); center[1] /= (length / 2); }
[ "protected", "void", "findCenter", "(", ")", "{", "center", "=", "new", "float", "[", "]", "{", "0", ",", "0", "}", ";", "int", "length", "=", "points", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "+=", "2", ")", "{", "center", "[", "0", "]", "+=", "points", "[", "i", "]", ";", "center", "[", "1", "]", "+=", "points", "[", "i", "+", "1", "]", ";", "}", "center", "[", "0", "]", "/=", "(", "length", "/", "2", ")", ";", "center", "[", "1", "]", "/=", "(", "length", "/", "2", ")", ";", "}" ]
Get the center of this polygon.
[ "Get", "the", "center", "of", "this", "polygon", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Shape.java#L575-L584
1,401
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Shape.java
Shape.calculateRadius
protected void calculateRadius() { boundingCircleRadius = 0; for(int i=0;i<points.length;i+=2) { float temp = ((points[i] - center[0]) * (points[i] - center[0])) + ((points[i + 1] - center[1]) * (points[i + 1] - center[1])); boundingCircleRadius = (boundingCircleRadius > temp) ? boundingCircleRadius : temp; } boundingCircleRadius = (float)Math.sqrt(boundingCircleRadius); }
java
protected void calculateRadius() { boundingCircleRadius = 0; for(int i=0;i<points.length;i+=2) { float temp = ((points[i] - center[0]) * (points[i] - center[0])) + ((points[i + 1] - center[1]) * (points[i + 1] - center[1])); boundingCircleRadius = (boundingCircleRadius > temp) ? boundingCircleRadius : temp; } boundingCircleRadius = (float)Math.sqrt(boundingCircleRadius); }
[ "protected", "void", "calculateRadius", "(", ")", "{", "boundingCircleRadius", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "points", ".", "length", ";", "i", "+=", "2", ")", "{", "float", "temp", "=", "(", "(", "points", "[", "i", "]", "-", "center", "[", "0", "]", ")", "*", "(", "points", "[", "i", "]", "-", "center", "[", "0", "]", ")", ")", "+", "(", "(", "points", "[", "i", "+", "1", "]", "-", "center", "[", "1", "]", ")", "*", "(", "points", "[", "i", "+", "1", "]", "-", "center", "[", "1", "]", ")", ")", ";", "boundingCircleRadius", "=", "(", "boundingCircleRadius", ">", "temp", ")", "?", "boundingCircleRadius", ":", "temp", ";", "}", "boundingCircleRadius", "=", "(", "float", ")", "Math", ".", "sqrt", "(", "boundingCircleRadius", ")", ";", "}" ]
Calculate the radius of a circle that can completely enclose this shape.
[ "Calculate", "the", "radius", "of", "a", "circle", "that", "can", "completely", "enclose", "this", "shape", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Shape.java#L590-L599
1,402
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Shape.java
Shape.calculateTriangles
protected void calculateTriangles() { if ((!trianglesDirty) && (tris != null)) { return; } if (points.length >= 6) { boolean clockwise = true; float area = 0; for (int i=0;i<(points.length/2)-1;i++) { float x1 = points[(i*2)]; float y1 = points[(i*2)+1]; float x2 = points[(i*2)+2]; float y2 = points[(i*2)+3]; area += (x1 * y2) - (y1 * x2); } area /= 2; clockwise = area > 0; tris = new NeatTriangulator(); for (int i=0;i<points.length;i+=2) { tris.addPolyPoint(points[i], points[i+1]); } tris.triangulate(); } trianglesDirty = false; }
java
protected void calculateTriangles() { if ((!trianglesDirty) && (tris != null)) { return; } if (points.length >= 6) { boolean clockwise = true; float area = 0; for (int i=0;i<(points.length/2)-1;i++) { float x1 = points[(i*2)]; float y1 = points[(i*2)+1]; float x2 = points[(i*2)+2]; float y2 = points[(i*2)+3]; area += (x1 * y2) - (y1 * x2); } area /= 2; clockwise = area > 0; tris = new NeatTriangulator(); for (int i=0;i<points.length;i+=2) { tris.addPolyPoint(points[i], points[i+1]); } tris.triangulate(); } trianglesDirty = false; }
[ "protected", "void", "calculateTriangles", "(", ")", "{", "if", "(", "(", "!", "trianglesDirty", ")", "&&", "(", "tris", "!=", "null", ")", ")", "{", "return", ";", "}", "if", "(", "points", ".", "length", ">=", "6", ")", "{", "boolean", "clockwise", "=", "true", ";", "float", "area", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "(", "points", ".", "length", "/", "2", ")", "-", "1", ";", "i", "++", ")", "{", "float", "x1", "=", "points", "[", "(", "i", "*", "2", ")", "]", ";", "float", "y1", "=", "points", "[", "(", "i", "*", "2", ")", "+", "1", "]", ";", "float", "x2", "=", "points", "[", "(", "i", "*", "2", ")", "+", "2", "]", ";", "float", "y2", "=", "points", "[", "(", "i", "*", "2", ")", "+", "3", "]", ";", "area", "+=", "(", "x1", "*", "y2", ")", "-", "(", "y1", "*", "x2", ")", ";", "}", "area", "/=", "2", ";", "clockwise", "=", "area", ">", "0", ";", "tris", "=", "new", "NeatTriangulator", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "points", ".", "length", ";", "i", "+=", "2", ")", "{", "tris", ".", "addPolyPoint", "(", "points", "[", "i", "]", ",", "points", "[", "i", "+", "1", "]", ")", ";", "}", "tris", ".", "triangulate", "(", ")", ";", "}", "trianglesDirty", "=", "false", ";", "}" ]
Calculate the triangles that can fill this shape
[ "Calculate", "the", "triangles", "that", "can", "fill", "this", "shape" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Shape.java#L604-L630
1,403
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Shape.java
Shape.checkPoints
protected final void checkPoints() { if (pointsDirty) { createPoints(); findCenter(); calculateRadius(); if (points.length > 0) { maxX = points[0]; maxY = points[1]; minX = points[0]; minY = points[1]; for (int i=0;i<points.length/2;i++) { maxX = Math.max(points[i*2],maxX); maxY = Math.max(points[(i*2)+1],maxY); minX = Math.min(points[i*2],minX); minY = Math.min(points[(i*2)+1],minY); } } pointsDirty = false; trianglesDirty = true; } }
java
protected final void checkPoints() { if (pointsDirty) { createPoints(); findCenter(); calculateRadius(); if (points.length > 0) { maxX = points[0]; maxY = points[1]; minX = points[0]; minY = points[1]; for (int i=0;i<points.length/2;i++) { maxX = Math.max(points[i*2],maxX); maxY = Math.max(points[(i*2)+1],maxY); minX = Math.min(points[i*2],minX); minY = Math.min(points[(i*2)+1],minY); } } pointsDirty = false; trianglesDirty = true; } }
[ "protected", "final", "void", "checkPoints", "(", ")", "{", "if", "(", "pointsDirty", ")", "{", "createPoints", "(", ")", ";", "findCenter", "(", ")", ";", "calculateRadius", "(", ")", ";", "if", "(", "points", ".", "length", ">", "0", ")", "{", "maxX", "=", "points", "[", "0", "]", ";", "maxY", "=", "points", "[", "1", "]", ";", "minX", "=", "points", "[", "0", "]", ";", "minY", "=", "points", "[", "1", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "points", ".", "length", "/", "2", ";", "i", "++", ")", "{", "maxX", "=", "Math", ".", "max", "(", "points", "[", "i", "*", "2", "]", ",", "maxX", ")", ";", "maxY", "=", "Math", ".", "max", "(", "points", "[", "(", "i", "*", "2", ")", "+", "1", "]", ",", "maxY", ")", ";", "minX", "=", "Math", ".", "min", "(", "points", "[", "i", "*", "2", "]", ",", "minX", ")", ";", "minY", "=", "Math", ".", "min", "(", "points", "[", "(", "i", "*", "2", ")", "+", "1", "]", ",", "minY", ")", ";", "}", "}", "pointsDirty", "=", "false", ";", "trianglesDirty", "=", "true", ";", "}", "}" ]
Check the dirty flag and create points as necessary.
[ "Check", "the", "dirty", "flag", "and", "create", "points", "as", "necessary", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Shape.java#L656-L677
1,404
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Shape.java
Shape.prune
public Shape prune() { Polygon result = new Polygon(); for (int i=0;i<getPointCount();i++) { int next = i+1 >= getPointCount() ? 0 : i+1; int prev = i-1 < 0 ? getPointCount() - 1 : i-1; float dx1 = getPoint(i)[0] - getPoint(prev)[0]; float dy1 = getPoint(i)[1] - getPoint(prev)[1]; float dx2 = getPoint(next)[0] - getPoint(i)[0]; float dy2 = getPoint(next)[1] - getPoint(i)[1]; float len1 = (float) Math.sqrt((dx1*dx1) + (dy1*dy1)); float len2 = (float) Math.sqrt((dx2*dx2) + (dy2*dy2)); dx1 /= len1; dy1 /= len1; dx2 /= len2; dy2 /= len2; if ((dx1 != dx2) || (dy1 != dy2)) { result.addPoint(getPoint(i)[0],getPoint(i)[1]); } } return result; }
java
public Shape prune() { Polygon result = new Polygon(); for (int i=0;i<getPointCount();i++) { int next = i+1 >= getPointCount() ? 0 : i+1; int prev = i-1 < 0 ? getPointCount() - 1 : i-1; float dx1 = getPoint(i)[0] - getPoint(prev)[0]; float dy1 = getPoint(i)[1] - getPoint(prev)[1]; float dx2 = getPoint(next)[0] - getPoint(i)[0]; float dy2 = getPoint(next)[1] - getPoint(i)[1]; float len1 = (float) Math.sqrt((dx1*dx1) + (dy1*dy1)); float len2 = (float) Math.sqrt((dx2*dx2) + (dy2*dy2)); dx1 /= len1; dy1 /= len1; dx2 /= len2; dy2 /= len2; if ((dx1 != dx2) || (dy1 != dy2)) { result.addPoint(getPoint(i)[0],getPoint(i)[1]); } } return result; }
[ "public", "Shape", "prune", "(", ")", "{", "Polygon", "result", "=", "new", "Polygon", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getPointCount", "(", ")", ";", "i", "++", ")", "{", "int", "next", "=", "i", "+", "1", ">=", "getPointCount", "(", ")", "?", "0", ":", "i", "+", "1", ";", "int", "prev", "=", "i", "-", "1", "<", "0", "?", "getPointCount", "(", ")", "-", "1", ":", "i", "-", "1", ";", "float", "dx1", "=", "getPoint", "(", "i", ")", "[", "0", "]", "-", "getPoint", "(", "prev", ")", "[", "0", "]", ";", "float", "dy1", "=", "getPoint", "(", "i", ")", "[", "1", "]", "-", "getPoint", "(", "prev", ")", "[", "1", "]", ";", "float", "dx2", "=", "getPoint", "(", "next", ")", "[", "0", "]", "-", "getPoint", "(", "i", ")", "[", "0", "]", ";", "float", "dy2", "=", "getPoint", "(", "next", ")", "[", "1", "]", "-", "getPoint", "(", "i", ")", "[", "1", "]", ";", "float", "len1", "=", "(", "float", ")", "Math", ".", "sqrt", "(", "(", "dx1", "*", "dx1", ")", "+", "(", "dy1", "*", "dy1", ")", ")", ";", "float", "len2", "=", "(", "float", ")", "Math", ".", "sqrt", "(", "(", "dx2", "*", "dx2", ")", "+", "(", "dy2", "*", "dy2", ")", ")", ";", "dx1", "/=", "len1", ";", "dy1", "/=", "len1", ";", "dx2", "/=", "len2", ";", "dy2", "/=", "len2", ";", "if", "(", "(", "dx1", "!=", "dx2", ")", "||", "(", "dy1", "!=", "dy2", ")", ")", "{", "result", ".", "addPoint", "(", "getPoint", "(", "i", ")", "[", "0", "]", ",", "getPoint", "(", "i", ")", "[", "1", "]", ")", ";", "}", "}", "return", "result", ";", "}" ]
Prune any required points in this shape @return The new shape with points pruned
[ "Prune", "any", "required", "points", "in", "this", "shape" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Shape.java#L701-L726
1,405
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.setImageColor
public void setImageColor(float r, float g, float b) { setColor(TOP_LEFT, r, g, b); setColor(TOP_RIGHT, r, g, b); setColor(BOTTOM_LEFT, r, g, b); setColor(BOTTOM_RIGHT, r, g, b); }
java
public void setImageColor(float r, float g, float b) { setColor(TOP_LEFT, r, g, b); setColor(TOP_RIGHT, r, g, b); setColor(BOTTOM_LEFT, r, g, b); setColor(BOTTOM_RIGHT, r, g, b); }
[ "public", "void", "setImageColor", "(", "float", "r", ",", "float", "g", ",", "float", "b", ")", "{", "setColor", "(", "TOP_LEFT", ",", "r", ",", "g", ",", "b", ")", ";", "setColor", "(", "TOP_RIGHT", ",", "r", ",", "g", ",", "b", ")", ";", "setColor", "(", "BOTTOM_LEFT", ",", "r", ",", "g", ",", "b", ")", ";", "setColor", "(", "BOTTOM_RIGHT", ",", "r", ",", "g", ",", "b", ")", ";", "}" ]
Set the filter to apply when drawing this image @param r The red component of the filter colour @param g The green component of the filter colour @param b The blue component of the filter colour
[ "Set", "the", "filter", "to", "apply", "when", "drawing", "this", "image" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L358-L363
1,406
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.setColor
public void setColor(int corner, float r, float g, float b, float a) { if (corners == null) { corners = new Color[] {new Color(1,1,1,1f),new Color(1,1,1,1f), new Color(1,1,1,1f), new Color(1,1,1,1f)}; } corners[corner].r = r; corners[corner].g = g; corners[corner].b = b; corners[corner].a = a; }
java
public void setColor(int corner, float r, float g, float b, float a) { if (corners == null) { corners = new Color[] {new Color(1,1,1,1f),new Color(1,1,1,1f), new Color(1,1,1,1f), new Color(1,1,1,1f)}; } corners[corner].r = r; corners[corner].g = g; corners[corner].b = b; corners[corner].a = a; }
[ "public", "void", "setColor", "(", "int", "corner", ",", "float", "r", ",", "float", "g", ",", "float", "b", ",", "float", "a", ")", "{", "if", "(", "corners", "==", "null", ")", "{", "corners", "=", "new", "Color", "[", "]", "{", "new", "Color", "(", "1", ",", "1", ",", "1", ",", "1f", ")", ",", "new", "Color", "(", "1", ",", "1", ",", "1", ",", "1f", ")", ",", "new", "Color", "(", "1", ",", "1", ",", "1", ",", "1f", ")", ",", "new", "Color", "(", "1", ",", "1", ",", "1", ",", "1f", ")", "}", ";", "}", "corners", "[", "corner", "]", ".", "r", "=", "r", ";", "corners", "[", "corner", "]", ".", "g", "=", "g", ";", "corners", "[", "corner", "]", ".", "b", "=", "b", ";", "corners", "[", "corner", "]", ".", "a", "=", "a", ";", "}" ]
Set the color of the given corner when this image is rendered. This is useful lots of visual effect but especially light maps @param corner The corner identifier for the corner to be set @param r The red component value to set (between 0 and 1) @param g The green component value to set (between 0 and 1) @param b The blue component value to set (between 0 and 1) @param a The alpha component value to set (between 0 and 1)
[ "Set", "the", "color", "of", "the", "given", "corner", "when", "this", "image", "is", "rendered", ".", "This", "is", "useful", "lots", "of", "visual", "effect", "but", "especially", "light", "maps" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L375-L384
1,407
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.clampTexture
public void clampTexture() { if (GL.canTextureMirrorClamp()) { GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT); GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT); } else { GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_CLAMP); GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_CLAMP); } }
java
public void clampTexture() { if (GL.canTextureMirrorClamp()) { GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT); GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT); } else { GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_CLAMP); GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_CLAMP); } }
[ "public", "void", "clampTexture", "(", ")", "{", "if", "(", "GL", ".", "canTextureMirrorClamp", "(", ")", ")", "{", "GL", ".", "glTexParameteri", "(", "SGL", ".", "GL_TEXTURE_2D", ",", "SGL", ".", "GL_TEXTURE_WRAP_S", ",", "SGL", ".", "GL_MIRROR_CLAMP_TO_EDGE_EXT", ")", ";", "GL", ".", "glTexParameteri", "(", "SGL", ".", "GL_TEXTURE_2D", ",", "SGL", ".", "GL_TEXTURE_WRAP_T", ",", "SGL", ".", "GL_MIRROR_CLAMP_TO_EDGE_EXT", ")", ";", "}", "else", "{", "GL", ".", "glTexParameteri", "(", "SGL", ".", "GL_TEXTURE_2D", ",", "SGL", ".", "GL_TEXTURE_WRAP_S", ",", "SGL", ".", "GL_CLAMP", ")", ";", "GL", ".", "glTexParameteri", "(", "SGL", ".", "GL_TEXTURE_2D", ",", "SGL", ".", "GL_TEXTURE_WRAP_T", ",", "SGL", ".", "GL_CLAMP", ")", ";", "}", "}" ]
Clamp the loaded texture to it's edges
[ "Clamp", "the", "loaded", "texture", "to", "it", "s", "edges" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L408-L416
1,408
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.load
private void load(InputStream in, String ref, boolean flipped, int f, Color transparent) throws SlickException { this.filter = f == FILTER_LINEAR ? SGL.GL_LINEAR : SGL.GL_NEAREST; try { this.ref = ref; int[] trans = null; if (transparent != null) { trans = new int[3]; trans[0] = (int) (transparent.r * 255); trans[1] = (int) (transparent.g * 255); trans[2] = (int) (transparent.b * 255); } texture = InternalTextureLoader.get().getTexture(in, ref, flipped, filter, trans); } catch (IOException e) { Log.error(e); throw new SlickException("Failed to load image from: "+ref, e); } }
java
private void load(InputStream in, String ref, boolean flipped, int f, Color transparent) throws SlickException { this.filter = f == FILTER_LINEAR ? SGL.GL_LINEAR : SGL.GL_NEAREST; try { this.ref = ref; int[] trans = null; if (transparent != null) { trans = new int[3]; trans[0] = (int) (transparent.r * 255); trans[1] = (int) (transparent.g * 255); trans[2] = (int) (transparent.b * 255); } texture = InternalTextureLoader.get().getTexture(in, ref, flipped, filter, trans); } catch (IOException e) { Log.error(e); throw new SlickException("Failed to load image from: "+ref, e); } }
[ "private", "void", "load", "(", "InputStream", "in", ",", "String", "ref", ",", "boolean", "flipped", ",", "int", "f", ",", "Color", "transparent", ")", "throws", "SlickException", "{", "this", ".", "filter", "=", "f", "==", "FILTER_LINEAR", "?", "SGL", ".", "GL_LINEAR", ":", "SGL", ".", "GL_NEAREST", ";", "try", "{", "this", ".", "ref", "=", "ref", ";", "int", "[", "]", "trans", "=", "null", ";", "if", "(", "transparent", "!=", "null", ")", "{", "trans", "=", "new", "int", "[", "3", "]", ";", "trans", "[", "0", "]", "=", "(", "int", ")", "(", "transparent", ".", "r", "*", "255", ")", ";", "trans", "[", "1", "]", "=", "(", "int", ")", "(", "transparent", ".", "g", "*", "255", ")", ";", "trans", "[", "2", "]", "=", "(", "int", ")", "(", "transparent", ".", "b", "*", "255", ")", ";", "}", "texture", "=", "InternalTextureLoader", ".", "get", "(", ")", ".", "getTexture", "(", "in", ",", "ref", ",", "flipped", ",", "filter", ",", "trans", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "Log", ".", "error", "(", "e", ")", ";", "throw", "new", "SlickException", "(", "\"Failed to load image from: \"", "+", "ref", ",", "e", ")", ";", "}", "}" ]
Load the image @param in The input stream to read the image from @param ref The name that should be assigned to the image @param flipped True if the image should be flipped on the y-axis on load @param f The filter to use when scaling this image @param transparent The color to treat as transparent @throws SlickException Indicates a failure to load the image
[ "Load", "the", "image" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L457-L474
1,409
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.init
protected final void init() { if (inited) { return; } inited = true; if (texture != null) { width = texture.getImageWidth(); height = texture.getImageHeight(); textureOffsetX = 0; textureOffsetY = 0; textureWidth = texture.getWidth(); textureHeight = texture.getHeight(); } initImpl(); centerX = width / 2; centerY = height / 2; }
java
protected final void init() { if (inited) { return; } inited = true; if (texture != null) { width = texture.getImageWidth(); height = texture.getImageHeight(); textureOffsetX = 0; textureOffsetY = 0; textureWidth = texture.getWidth(); textureHeight = texture.getHeight(); } initImpl(); centerX = width / 2; centerY = height / 2; }
[ "protected", "final", "void", "init", "(", ")", "{", "if", "(", "inited", ")", "{", "return", ";", "}", "inited", "=", "true", ";", "if", "(", "texture", "!=", "null", ")", "{", "width", "=", "texture", ".", "getImageWidth", "(", ")", ";", "height", "=", "texture", ".", "getImageHeight", "(", ")", ";", "textureOffsetX", "=", "0", ";", "textureOffsetY", "=", "0", ";", "textureWidth", "=", "texture", ".", "getWidth", "(", ")", ";", "textureHeight", "=", "texture", ".", "getHeight", "(", ")", ";", "}", "initImpl", "(", ")", ";", "centerX", "=", "width", "/", "2", ";", "centerY", "=", "height", "/", "2", ";", "}" ]
Initialise internal data
[ "Initialise", "internal", "data" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L494-L513
1,410
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.draw
@Override public void draw(float x, float y) { init(); draw(x,y,width,height); }
java
@Override public void draw(float x, float y) { init(); draw(x,y,width,height); }
[ "@", "Override", "public", "void", "draw", "(", "float", "x", ",", "float", "y", ")", "{", "init", "(", ")", ";", "draw", "(", "x", ",", "y", ",", "width", ",", "height", ")", ";", "}" ]
Draw this image at the specified location @param x The x location to draw the image at @param y The y location to draw the image at
[ "Draw", "this", "image", "at", "the", "specified", "location" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L545-L549
1,411
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.drawEmbedded
public void drawEmbedded(float x,float y,float width,float height) { init(); if (corners == null) { GL.glTexCoord2f(textureOffsetX, textureOffsetY); GL.glVertex3f(x, y, 0); GL.glTexCoord2f(textureOffsetX, textureOffsetY + textureHeight); GL.glVertex3f(x, y + height, 0); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY + textureHeight); GL.glVertex3f(x + width, y + height, 0); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY); GL.glVertex3f(x + width, y, 0); } else { corners[TOP_LEFT].bind(); GL.glTexCoord2f(textureOffsetX, textureOffsetY); GL.glVertex3f(x, y, 0); corners[BOTTOM_LEFT].bind(); GL.glTexCoord2f(textureOffsetX, textureOffsetY + textureHeight); GL.glVertex3f(x, y + height, 0); corners[BOTTOM_RIGHT].bind(); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY + textureHeight); GL.glVertex3f(x + width, y + height, 0); corners[TOP_RIGHT].bind(); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY); GL.glVertex3f(x + width, y, 0); } }
java
public void drawEmbedded(float x,float y,float width,float height) { init(); if (corners == null) { GL.glTexCoord2f(textureOffsetX, textureOffsetY); GL.glVertex3f(x, y, 0); GL.glTexCoord2f(textureOffsetX, textureOffsetY + textureHeight); GL.glVertex3f(x, y + height, 0); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY + textureHeight); GL.glVertex3f(x + width, y + height, 0); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY); GL.glVertex3f(x + width, y, 0); } else { corners[TOP_LEFT].bind(); GL.glTexCoord2f(textureOffsetX, textureOffsetY); GL.glVertex3f(x, y, 0); corners[BOTTOM_LEFT].bind(); GL.glTexCoord2f(textureOffsetX, textureOffsetY + textureHeight); GL.glVertex3f(x, y + height, 0); corners[BOTTOM_RIGHT].bind(); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY + textureHeight); GL.glVertex3f(x + width, y + height, 0); corners[TOP_RIGHT].bind(); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY); GL.glVertex3f(x + width, y, 0); } }
[ "public", "void", "drawEmbedded", "(", "float", "x", ",", "float", "y", ",", "float", "width", ",", "float", "height", ")", "{", "init", "(", ")", ";", "if", "(", "corners", "==", "null", ")", "{", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", ",", "textureOffsetY", ")", ";", "GL", ".", "glVertex3f", "(", "x", ",", "y", ",", "0", ")", ";", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", ",", "textureOffsetY", "+", "textureHeight", ")", ";", "GL", ".", "glVertex3f", "(", "x", ",", "y", "+", "height", ",", "0", ")", ";", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", "+", "textureWidth", ",", "textureOffsetY", "+", "textureHeight", ")", ";", "GL", ".", "glVertex3f", "(", "x", "+", "width", ",", "y", "+", "height", ",", "0", ")", ";", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", "+", "textureWidth", ",", "textureOffsetY", ")", ";", "GL", ".", "glVertex3f", "(", "x", "+", "width", ",", "y", ",", "0", ")", ";", "}", "else", "{", "corners", "[", "TOP_LEFT", "]", ".", "bind", "(", ")", ";", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", ",", "textureOffsetY", ")", ";", "GL", ".", "glVertex3f", "(", "x", ",", "y", ",", "0", ")", ";", "corners", "[", "BOTTOM_LEFT", "]", ".", "bind", "(", ")", ";", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", ",", "textureOffsetY", "+", "textureHeight", ")", ";", "GL", ".", "glVertex3f", "(", "x", ",", "y", "+", "height", ",", "0", ")", ";", "corners", "[", "BOTTOM_RIGHT", "]", ".", "bind", "(", ")", ";", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", "+", "textureWidth", ",", "textureOffsetY", "+", "textureHeight", ")", ";", "GL", ".", "glVertex3f", "(", "x", "+", "width", ",", "y", "+", "height", ",", "0", ")", ";", "corners", "[", "TOP_RIGHT", "]", ".", "bind", "(", ")", ";", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", "+", "textureWidth", ",", "textureOffsetY", ")", ";", "GL", ".", "glVertex3f", "(", "x", "+", "width", ",", "y", ",", "0", ")", ";", "}", "}" ]
Draw this image as part of a collection of images @param x The x location to draw the image at @param y The y location to draw the image at @param width The width to render the image at @param height The height to render the image at
[ "Draw", "this", "image", "as", "part", "of", "a", "collection", "of", "images" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L572-L600
1,412
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.draw
public void draw(float x,float y,float scale) { init(); draw(x,y,width*scale,height*scale,Color.white); }
java
public void draw(float x,float y,float scale) { init(); draw(x,y,width*scale,height*scale,Color.white); }
[ "public", "void", "draw", "(", "float", "x", ",", "float", "y", ",", "float", "scale", ")", "{", "init", "(", ")", ";", "draw", "(", "x", ",", "y", ",", "width", "*", "scale", ",", "height", "*", "scale", ",", "Color", ".", "white", ")", ";", "}" ]
Draw the image with a given scale @param x The x position to draw the image at @param y The y position to draw the image at @param scale The scaling to apply
[ "Draw", "the", "image", "with", "a", "given", "scale" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L653-L656
1,413
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.getSubImage
public Image getSubImage(int x,int y,int width,int height) { init(); float newTextureOffsetX = ((x / (float) this.width) * textureWidth) + textureOffsetX; float newTextureOffsetY = ((y / (float) this.height) * textureHeight) + textureOffsetY; float newTextureWidth = ((width / (float) this.width) * textureWidth); float newTextureHeight = ((height / (float) this.height) * textureHeight); Image sub = new Image(); sub.inited = true; sub.texture = this.texture; sub.textureOffsetX = newTextureOffsetX; sub.textureOffsetY = newTextureOffsetY; sub.textureWidth = newTextureWidth; sub.textureHeight = newTextureHeight; sub.width = width; sub.height = height; sub.ref = ref; sub.centerX = width / 2; sub.centerY = height / 2; return sub; }
java
public Image getSubImage(int x,int y,int width,int height) { init(); float newTextureOffsetX = ((x / (float) this.width) * textureWidth) + textureOffsetX; float newTextureOffsetY = ((y / (float) this.height) * textureHeight) + textureOffsetY; float newTextureWidth = ((width / (float) this.width) * textureWidth); float newTextureHeight = ((height / (float) this.height) * textureHeight); Image sub = new Image(); sub.inited = true; sub.texture = this.texture; sub.textureOffsetX = newTextureOffsetX; sub.textureOffsetY = newTextureOffsetY; sub.textureWidth = newTextureWidth; sub.textureHeight = newTextureHeight; sub.width = width; sub.height = height; sub.ref = ref; sub.centerX = width / 2; sub.centerY = height / 2; return sub; }
[ "public", "Image", "getSubImage", "(", "int", "x", ",", "int", "y", ",", "int", "width", ",", "int", "height", ")", "{", "init", "(", ")", ";", "float", "newTextureOffsetX", "=", "(", "(", "x", "/", "(", "float", ")", "this", ".", "width", ")", "*", "textureWidth", ")", "+", "textureOffsetX", ";", "float", "newTextureOffsetY", "=", "(", "(", "y", "/", "(", "float", ")", "this", ".", "height", ")", "*", "textureHeight", ")", "+", "textureOffsetY", ";", "float", "newTextureWidth", "=", "(", "(", "width", "/", "(", "float", ")", "this", ".", "width", ")", "*", "textureWidth", ")", ";", "float", "newTextureHeight", "=", "(", "(", "height", "/", "(", "float", ")", "this", ".", "height", ")", "*", "textureHeight", ")", ";", "Image", "sub", "=", "new", "Image", "(", ")", ";", "sub", ".", "inited", "=", "true", ";", "sub", ".", "texture", "=", "this", ".", "texture", ";", "sub", ".", "textureOffsetX", "=", "newTextureOffsetX", ";", "sub", ".", "textureOffsetY", "=", "newTextureOffsetY", ";", "sub", ".", "textureWidth", "=", "newTextureWidth", ";", "sub", ".", "textureHeight", "=", "newTextureHeight", ";", "sub", ".", "width", "=", "width", ";", "sub", ".", "height", "=", "height", ";", "sub", ".", "ref", "=", "ref", ";", "sub", ".", "centerX", "=", "width", "/", "2", ";", "sub", ".", "centerY", "=", "height", "/", "2", ";", "return", "sub", ";", "}" ]
Get a sub-part of this image. Note that the create image retains a reference to the image data so should anything change it will affect sub-images too. @param x The x coordinate of the sub-image @param y The y coordinate of the sub-image @param width The width of the sub-image @param height The height of the sub-image @return The image represent the sub-part of this image
[ "Get", "a", "sub", "-", "part", "of", "this", "image", ".", "Note", "that", "the", "create", "image", "retains", "a", "reference", "to", "the", "image", "data", "so", "should", "anything", "change", "it", "will", "affect", "sub", "-", "images", "too", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L958-L981
1,414
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.drawWarped
public void drawWarped(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) { Color.white.bind(); texture.bind(); GL.glTranslatef(x1, y1, 0); if (angle != 0) { GL.glTranslatef(centerX, centerY, 0.0f); GL.glRotatef(angle, 0.0f, 0.0f, 1.0f); GL.glTranslatef(-centerX, -centerY, 0.0f); } GL.glBegin(SGL.GL_QUADS); init(); GL.glTexCoord2f(textureOffsetX, textureOffsetY); GL.glVertex3f(0, 0, 0); GL.glTexCoord2f(textureOffsetX, textureOffsetY + textureHeight); GL.glVertex3f(x2 - x1, y2 - y1, 0); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY + textureHeight); GL.glVertex3f(x3 - x1, y3 - y1, 0); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY); GL.glVertex3f(x4 - x1, y4 - y1, 0); GL.glEnd(); if (angle != 0) { GL.glTranslatef(centerX, centerY, 0.0f); GL.glRotatef(-angle, 0.0f, 0.0f, 1.0f); GL.glTranslatef(-centerX, -centerY, 0.0f); } GL.glTranslatef(-x1, -y1, 0); }
java
public void drawWarped(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) { Color.white.bind(); texture.bind(); GL.glTranslatef(x1, y1, 0); if (angle != 0) { GL.glTranslatef(centerX, centerY, 0.0f); GL.glRotatef(angle, 0.0f, 0.0f, 1.0f); GL.glTranslatef(-centerX, -centerY, 0.0f); } GL.glBegin(SGL.GL_QUADS); init(); GL.glTexCoord2f(textureOffsetX, textureOffsetY); GL.glVertex3f(0, 0, 0); GL.glTexCoord2f(textureOffsetX, textureOffsetY + textureHeight); GL.glVertex3f(x2 - x1, y2 - y1, 0); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY + textureHeight); GL.glVertex3f(x3 - x1, y3 - y1, 0); GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY); GL.glVertex3f(x4 - x1, y4 - y1, 0); GL.glEnd(); if (angle != 0) { GL.glTranslatef(centerX, centerY, 0.0f); GL.glRotatef(-angle, 0.0f, 0.0f, 1.0f); GL.glTranslatef(-centerX, -centerY, 0.0f); } GL.glTranslatef(-x1, -y1, 0); }
[ "public", "void", "drawWarped", "(", "float", "x1", ",", "float", "y1", ",", "float", "x2", ",", "float", "y2", ",", "float", "x3", ",", "float", "y3", ",", "float", "x4", ",", "float", "y4", ")", "{", "Color", ".", "white", ".", "bind", "(", ")", ";", "texture", ".", "bind", "(", ")", ";", "GL", ".", "glTranslatef", "(", "x1", ",", "y1", ",", "0", ")", ";", "if", "(", "angle", "!=", "0", ")", "{", "GL", ".", "glTranslatef", "(", "centerX", ",", "centerY", ",", "0.0f", ")", ";", "GL", ".", "glRotatef", "(", "angle", ",", "0.0f", ",", "0.0f", ",", "1.0f", ")", ";", "GL", ".", "glTranslatef", "(", "-", "centerX", ",", "-", "centerY", ",", "0.0f", ")", ";", "}", "GL", ".", "glBegin", "(", "SGL", ".", "GL_QUADS", ")", ";", "init", "(", ")", ";", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", ",", "textureOffsetY", ")", ";", "GL", ".", "glVertex3f", "(", "0", ",", "0", ",", "0", ")", ";", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", ",", "textureOffsetY", "+", "textureHeight", ")", ";", "GL", ".", "glVertex3f", "(", "x2", "-", "x1", ",", "y2", "-", "y1", ",", "0", ")", ";", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", "+", "textureWidth", ",", "textureOffsetY", "+", "textureHeight", ")", ";", "GL", ".", "glVertex3f", "(", "x3", "-", "x1", ",", "y3", "-", "y1", ",", "0", ")", ";", "GL", ".", "glTexCoord2f", "(", "textureOffsetX", "+", "textureWidth", ",", "textureOffsetY", ")", ";", "GL", ".", "glVertex3f", "(", "x4", "-", "x1", ",", "y4", "-", "y1", ",", "0", ")", ";", "GL", ".", "glEnd", "(", ")", ";", "if", "(", "angle", "!=", "0", ")", "{", "GL", ".", "glTranslatef", "(", "centerX", ",", "centerY", ",", "0.0f", ")", ";", "GL", ".", "glRotatef", "(", "-", "angle", ",", "0.0f", ",", "0.0f", ",", "1.0f", ")", ";", "GL", ".", "glTranslatef", "(", "-", "centerX", ",", "-", "centerY", ",", "0.0f", ")", ";", "}", "GL", ".", "glTranslatef", "(", "-", "x1", ",", "-", "y1", ",", "0", ")", ";", "}" ]
Draw the image in a warper rectangle. The effects this can have are many and varied, might be interesting though. @param x1 The top left corner x coordinate @param y1 The top left corner y coordinate @param x2 The top right corner x coordinate @param y2 The top right corner y coordinate @param x3 The bottom right corner x coordinate @param y3 The bottom right corner y coordinate @param x4 The bottom left corner x coordinate @param y4 The bottom left corner y coordinate
[ "Draw", "the", "image", "in", "a", "warper", "rectangle", ".", "The", "effects", "this", "can", "have", "are", "many", "and", "varied", "might", "be", "interesting", "though", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L1139-L1170
1,415
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.getFlippedCopy
public Image getFlippedCopy(boolean flipHorizontal, boolean flipVertical) { init(); Image image = copy(); if (flipHorizontal) { image.textureOffsetX = textureOffsetX + textureWidth; image.textureWidth = -textureWidth; } if (flipVertical) { image.textureOffsetY = textureOffsetY + textureHeight; image.textureHeight = -textureHeight; } return image; }
java
public Image getFlippedCopy(boolean flipHorizontal, boolean flipVertical) { init(); Image image = copy(); if (flipHorizontal) { image.textureOffsetX = textureOffsetX + textureWidth; image.textureWidth = -textureWidth; } if (flipVertical) { image.textureOffsetY = textureOffsetY + textureHeight; image.textureHeight = -textureHeight; } return image; }
[ "public", "Image", "getFlippedCopy", "(", "boolean", "flipHorizontal", ",", "boolean", "flipVertical", ")", "{", "init", "(", ")", ";", "Image", "image", "=", "copy", "(", ")", ";", "if", "(", "flipHorizontal", ")", "{", "image", ".", "textureOffsetX", "=", "textureOffsetX", "+", "textureWidth", ";", "image", ".", "textureWidth", "=", "-", "textureWidth", ";", "}", "if", "(", "flipVertical", ")", "{", "image", ".", "textureOffsetY", "=", "textureOffsetY", "+", "textureHeight", ";", "image", ".", "textureHeight", "=", "-", "textureHeight", ";", "}", "return", "image", ";", "}" ]
Get a copy image flipped on potentially two axis @param flipHorizontal True if we want to flip the image horizontally @param flipVertical True if we want to flip the image vertically @return The flipped image instance @see {{@link #getScaledCopy(int, int)} for caveats on scaled images
[ "Get", "a", "copy", "image", "flipped", "on", "potentially", "two", "axis" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L1270-L1284
1,416
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Image.java
Image.getColor
public Color getColor(int x, int y) { if (pixelData == null) { pixelData = texture.getTextureData(); } int xo = (int) (textureOffsetX * texture.getTextureWidth()); int yo = (int) (textureOffsetY * texture.getTextureHeight()); if (textureWidth < 0) { x = xo - x; } else { x = xo + x; } if (textureHeight < 0) { y = yo - y; } else { y = yo + y; } // Clamp to texture dimensions x %= texture.getTextureWidth(); y %= texture.getTextureHeight(); int offset = x + (y * texture.getTextureWidth()); offset *= texture.hasAlpha() ? 4 : 3; if (texture.hasAlpha()) { return new Color(translate(pixelData[offset]),translate(pixelData[offset+1]), translate(pixelData[offset+2]),translate(pixelData[offset+3])); } else { return new Color(translate(pixelData[offset]),translate(pixelData[offset+1]), translate(pixelData[offset+2])); } }
java
public Color getColor(int x, int y) { if (pixelData == null) { pixelData = texture.getTextureData(); } int xo = (int) (textureOffsetX * texture.getTextureWidth()); int yo = (int) (textureOffsetY * texture.getTextureHeight()); if (textureWidth < 0) { x = xo - x; } else { x = xo + x; } if (textureHeight < 0) { y = yo - y; } else { y = yo + y; } // Clamp to texture dimensions x %= texture.getTextureWidth(); y %= texture.getTextureHeight(); int offset = x + (y * texture.getTextureWidth()); offset *= texture.hasAlpha() ? 4 : 3; if (texture.hasAlpha()) { return new Color(translate(pixelData[offset]),translate(pixelData[offset+1]), translate(pixelData[offset+2]),translate(pixelData[offset+3])); } else { return new Color(translate(pixelData[offset]),translate(pixelData[offset+1]), translate(pixelData[offset+2])); } }
[ "public", "Color", "getColor", "(", "int", "x", ",", "int", "y", ")", "{", "if", "(", "pixelData", "==", "null", ")", "{", "pixelData", "=", "texture", ".", "getTextureData", "(", ")", ";", "}", "int", "xo", "=", "(", "int", ")", "(", "textureOffsetX", "*", "texture", ".", "getTextureWidth", "(", ")", ")", ";", "int", "yo", "=", "(", "int", ")", "(", "textureOffsetY", "*", "texture", ".", "getTextureHeight", "(", ")", ")", ";", "if", "(", "textureWidth", "<", "0", ")", "{", "x", "=", "xo", "-", "x", ";", "}", "else", "{", "x", "=", "xo", "+", "x", ";", "}", "if", "(", "textureHeight", "<", "0", ")", "{", "y", "=", "yo", "-", "y", ";", "}", "else", "{", "y", "=", "yo", "+", "y", ";", "}", "// Clamp to texture dimensions\r", "x", "%=", "texture", ".", "getTextureWidth", "(", ")", ";", "y", "%=", "texture", ".", "getTextureHeight", "(", ")", ";", "int", "offset", "=", "x", "+", "(", "y", "*", "texture", ".", "getTextureWidth", "(", ")", ")", ";", "offset", "*=", "texture", ".", "hasAlpha", "(", ")", "?", "4", ":", "3", ";", "if", "(", "texture", ".", "hasAlpha", "(", ")", ")", "{", "return", "new", "Color", "(", "translate", "(", "pixelData", "[", "offset", "]", ")", ",", "translate", "(", "pixelData", "[", "offset", "+", "1", "]", ")", ",", "translate", "(", "pixelData", "[", "offset", "+", "2", "]", ")", ",", "translate", "(", "pixelData", "[", "offset", "+", "3", "]", ")", ")", ";", "}", "else", "{", "return", "new", "Color", "(", "translate", "(", "pixelData", "[", "offset", "]", ")", ",", "translate", "(", "pixelData", "[", "offset", "+", "1", "]", ")", ",", "translate", "(", "pixelData", "[", "offset", "+", "2", "]", ")", ")", ";", "}", "}" ]
Get the colour of a pixel at a specified location in this image @param x The x coordinate of the pixel @param y The y coordinate of the pixel @return The Color of the pixel at the specified location
[ "Get", "the", "colour", "of", "a", "pixel", "at", "a", "specified", "location", "in", "this", "image" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L1366-L1402
1,417
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/FontUtils.java
FontUtils.drawLeft
public static void drawLeft(Font font, String s, int x, int y) { drawString(font, s, Alignment.LEFT, x, y, 0, Color.white); }
java
public static void drawLeft(Font font, String s, int x, int y) { drawString(font, s, Alignment.LEFT, x, y, 0, Color.white); }
[ "public", "static", "void", "drawLeft", "(", "Font", "font", ",", "String", "s", ",", "int", "x", ",", "int", "y", ")", "{", "drawString", "(", "font", ",", "s", ",", "Alignment", ".", "LEFT", ",", "x", ",", "y", ",", "0", ",", "Color", ".", "white", ")", ";", "}" ]
Draw text left justified @param font The font to draw with @param s The string to draw @param x The x location to draw at @param y The y location to draw at
[ "Draw", "text", "left", "justified" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/FontUtils.java#L38-L40
1,418
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/FontUtils.java
FontUtils.drawCenter
public static void drawCenter(Font font, String s, int x, int y, int width) { drawString(font, s, Alignment.CENTER, x, y, width, Color.white); }
java
public static void drawCenter(Font font, String s, int x, int y, int width) { drawString(font, s, Alignment.CENTER, x, y, width, Color.white); }
[ "public", "static", "void", "drawCenter", "(", "Font", "font", ",", "String", "s", ",", "int", "x", ",", "int", "y", ",", "int", "width", ")", "{", "drawString", "(", "font", ",", "s", ",", "Alignment", ".", "CENTER", ",", "x", ",", "y", ",", "width", ",", "Color", ".", "white", ")", ";", "}" ]
Draw text center justified @param font The font to draw with @param s The string to draw @param x The x location to draw at @param y The y location to draw at @param width The width to fill with the text
[ "Draw", "text", "center", "justified" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/FontUtils.java#L51-L53
1,419
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/FontUtils.java
FontUtils.drawRight
public static void drawRight(Font font, String s, int x, int y, int width) { drawString(font, s, Alignment.RIGHT, x, y, width, Color.white); }
java
public static void drawRight(Font font, String s, int x, int y, int width) { drawString(font, s, Alignment.RIGHT, x, y, width, Color.white); }
[ "public", "static", "void", "drawRight", "(", "Font", "font", ",", "String", "s", ",", "int", "x", ",", "int", "y", ",", "int", "width", ")", "{", "drawString", "(", "font", ",", "s", ",", "Alignment", ".", "RIGHT", ",", "x", ",", "y", ",", "width", ",", "Color", ".", "white", ")", ";", "}" ]
Draw text right justified @param font The font to draw with @param s The string to draw @param x The x location to draw at @param y The y location to draw at @param width The width to fill with the text
[ "Draw", "text", "right", "justified" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/FontUtils.java#L79-L81
1,420
nguillaumin/slick2d-maven
slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/Scalar.java
Scalar.load
public void load() { int resp = loadChooser.showOpenDialog(this); if (resp == JFileChooser.APPROVE_OPTION) { lastSelected = loadChooser.getSelectedFile(); saveChooser.setCurrentDirectory(loadChooser.getCurrentDirectory()); try { BufferedImage image = ImageIO.read(lastSelected); imagePanel.setImage(image); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(this, "Unable to load image "+lastSelected.getName()+" "); } } }
java
public void load() { int resp = loadChooser.showOpenDialog(this); if (resp == JFileChooser.APPROVE_OPTION) { lastSelected = loadChooser.getSelectedFile(); saveChooser.setCurrentDirectory(loadChooser.getCurrentDirectory()); try { BufferedImage image = ImageIO.read(lastSelected); imagePanel.setImage(image); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(this, "Unable to load image "+lastSelected.getName()+" "); } } }
[ "public", "void", "load", "(", ")", "{", "int", "resp", "=", "loadChooser", ".", "showOpenDialog", "(", "this", ")", ";", "if", "(", "resp", "==", "JFileChooser", ".", "APPROVE_OPTION", ")", "{", "lastSelected", "=", "loadChooser", ".", "getSelectedFile", "(", ")", ";", "saveChooser", ".", "setCurrentDirectory", "(", "loadChooser", ".", "getCurrentDirectory", "(", ")", ")", ";", "try", "{", "BufferedImage", "image", "=", "ImageIO", ".", "read", "(", "lastSelected", ")", ";", "imagePanel", ".", "setImage", "(", "image", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "JOptionPane", ".", "showMessageDialog", "(", "this", ",", "\"Unable to load image \"", "+", "lastSelected", ".", "getName", "(", ")", "+", "\" \"", ")", ";", "}", "}", "}" ]
Load the current image
[ "Load", "the", "current", "image" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/Scalar.java#L157-L170
1,421
nguillaumin/slick2d-maven
slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/Scalar.java
Scalar.save
public void save() { int resp = saveChooser.showSaveDialog(this); if (resp == JFileChooser.APPROVE_OPTION) { File file = saveChooser.getSelectedFile(); String type = null; if (file.getName().endsWith(".png")) { type = "PNG"; } if (file.getName().endsWith(".gif")) { type = "GIF"; } if (file.getName().endsWith(".jpg")) { type = "JPG"; } if (type == null) { file = new File(file.getAbsolutePath()+".png"); type = "PNG"; } try { ImageIO.write(imagePanel.getImage(), type, file); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(this, "Unable to save file "+file.getName()); } } }
java
public void save() { int resp = saveChooser.showSaveDialog(this); if (resp == JFileChooser.APPROVE_OPTION) { File file = saveChooser.getSelectedFile(); String type = null; if (file.getName().endsWith(".png")) { type = "PNG"; } if (file.getName().endsWith(".gif")) { type = "GIF"; } if (file.getName().endsWith(".jpg")) { type = "JPG"; } if (type == null) { file = new File(file.getAbsolutePath()+".png"); type = "PNG"; } try { ImageIO.write(imagePanel.getImage(), type, file); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(this, "Unable to save file "+file.getName()); } } }
[ "public", "void", "save", "(", ")", "{", "int", "resp", "=", "saveChooser", ".", "showSaveDialog", "(", "this", ")", ";", "if", "(", "resp", "==", "JFileChooser", ".", "APPROVE_OPTION", ")", "{", "File", "file", "=", "saveChooser", ".", "getSelectedFile", "(", ")", ";", "String", "type", "=", "null", ";", "if", "(", "file", ".", "getName", "(", ")", ".", "endsWith", "(", "\".png\"", ")", ")", "{", "type", "=", "\"PNG\"", ";", "}", "if", "(", "file", ".", "getName", "(", ")", ".", "endsWith", "(", "\".gif\"", ")", ")", "{", "type", "=", "\"GIF\"", ";", "}", "if", "(", "file", ".", "getName", "(", ")", ".", "endsWith", "(", "\".jpg\"", ")", ")", "{", "type", "=", "\"JPG\"", ";", "}", "if", "(", "type", "==", "null", ")", "{", "file", "=", "new", "File", "(", "file", ".", "getAbsolutePath", "(", ")", "+", "\".png\"", ")", ";", "type", "=", "\"PNG\"", ";", "}", "try", "{", "ImageIO", ".", "write", "(", "imagePanel", ".", "getImage", "(", ")", ",", "type", ",", "file", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "JOptionPane", ".", "showMessageDialog", "(", "this", ",", "\"Unable to save file \"", "+", "file", ".", "getName", "(", ")", ")", ";", "}", "}", "}" ]
Save the current image
[ "Save", "the", "current", "image" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/Scalar.java#L175-L201
1,422
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java
XMLElement.getAttributeNames
public String[] getAttributeNames() { NamedNodeMap map = dom.getAttributes(); String[] names = new String[map.getLength()]; for (int i=0;i<names.length;i++) { names[i] = map.item(i).getNodeName(); } return names; }
java
public String[] getAttributeNames() { NamedNodeMap map = dom.getAttributes(); String[] names = new String[map.getLength()]; for (int i=0;i<names.length;i++) { names[i] = map.item(i).getNodeName(); } return names; }
[ "public", "String", "[", "]", "getAttributeNames", "(", ")", "{", "NamedNodeMap", "map", "=", "dom", ".", "getAttributes", "(", ")", ";", "String", "[", "]", "names", "=", "new", "String", "[", "map", ".", "getLength", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "names", ".", "length", ";", "i", "++", ")", "{", "names", "[", "i", "]", "=", "map", ".", "item", "(", "i", ")", ".", "getNodeName", "(", ")", ";", "}", "return", "names", ";", "}" ]
Get the names of the attributes specified on this element @return The names of the elements specified
[ "Get", "the", "names", "of", "the", "attributes", "specified", "on", "this", "element" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java#L38-L47
1,423
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java
XMLElement.getAttribute
public String getAttribute(String name, String def) { String value = dom.getAttribute(name); if ((value == null) || (value.length() == 0)) { return def; } return value; }
java
public String getAttribute(String name, String def) { String value = dom.getAttribute(name); if ((value == null) || (value.length() == 0)) { return def; } return value; }
[ "public", "String", "getAttribute", "(", "String", "name", ",", "String", "def", ")", "{", "String", "value", "=", "dom", ".", "getAttribute", "(", "name", ")", ";", "if", "(", "(", "value", "==", "null", ")", "||", "(", "value", ".", "length", "(", ")", "==", "0", ")", ")", "{", "return", "def", ";", "}", "return", "value", ";", "}" ]
Get the value specified for a given attribute on this element @param name The name of the attribute whose value should be retrieved @param def The default value to return if the attribute is specified @return The value given for the attribute
[ "Get", "the", "value", "specified", "for", "a", "given", "attribute", "on", "this", "element" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java#L75-L82
1,424
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java
XMLElement.getIntAttribute
public int getIntAttribute(String name) throws SlickXMLException { try { return Integer.parseInt(getAttribute(name)); } catch (NumberFormatException e) { throw new SlickXMLException("Value read: '"+getAttribute(name)+"' is not an integer",e); } }
java
public int getIntAttribute(String name) throws SlickXMLException { try { return Integer.parseInt(getAttribute(name)); } catch (NumberFormatException e) { throw new SlickXMLException("Value read: '"+getAttribute(name)+"' is not an integer",e); } }
[ "public", "int", "getIntAttribute", "(", "String", "name", ")", "throws", "SlickXMLException", "{", "try", "{", "return", "Integer", ".", "parseInt", "(", "getAttribute", "(", "name", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "throw", "new", "SlickXMLException", "(", "\"Value read: '\"", "+", "getAttribute", "(", "name", ")", "+", "\"' is not an integer\"", ",", "e", ")", ";", "}", "}" ]
Get the value specified for a given attribute on this element as an integer. @param name The name of the attribute whose value should be retrieved @return The value given for the attribute @throws SlickXMLException Indicates a failure to convert the value into an integer
[ "Get", "the", "value", "specified", "for", "a", "given", "attribute", "on", "this", "element", "as", "an", "integer", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java#L91-L97
1,425
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java
XMLElement.getDoubleAttribute
public double getDoubleAttribute(String name) throws SlickXMLException { try { return Double.parseDouble(getAttribute(name)); } catch (NumberFormatException e) { throw new SlickXMLException("Value read: '"+getAttribute(name)+"' is not a double",e); } }
java
public double getDoubleAttribute(String name) throws SlickXMLException { try { return Double.parseDouble(getAttribute(name)); } catch (NumberFormatException e) { throw new SlickXMLException("Value read: '"+getAttribute(name)+"' is not a double",e); } }
[ "public", "double", "getDoubleAttribute", "(", "String", "name", ")", "throws", "SlickXMLException", "{", "try", "{", "return", "Double", ".", "parseDouble", "(", "getAttribute", "(", "name", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "throw", "new", "SlickXMLException", "(", "\"Value read: '\"", "+", "getAttribute", "(", "name", ")", "+", "\"' is not a double\"", ",", "e", ")", ";", "}", "}" ]
Get the value specified for a given attribute on this element as an double. @param name The name of the attribute whose value should be retrieved @return The value given for the attribute @throws SlickXMLException Indicates a failure to convert the value into an double
[ "Get", "the", "value", "specified", "for", "a", "given", "attribute", "on", "this", "element", "as", "an", "double", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java#L122-L128
1,426
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java
XMLElement.getBooleanAttribute
public boolean getBooleanAttribute(String name) throws SlickXMLException { String value = getAttribute(name); if (value.equalsIgnoreCase("true")) { return true; } if (value.equalsIgnoreCase("false")) { return false; } throw new SlickXMLException("Value read: '"+getAttribute(name)+"' is not a boolean"); }
java
public boolean getBooleanAttribute(String name) throws SlickXMLException { String value = getAttribute(name); if (value.equalsIgnoreCase("true")) { return true; } if (value.equalsIgnoreCase("false")) { return false; } throw new SlickXMLException("Value read: '"+getAttribute(name)+"' is not a boolean"); }
[ "public", "boolean", "getBooleanAttribute", "(", "String", "name", ")", "throws", "SlickXMLException", "{", "String", "value", "=", "getAttribute", "(", "name", ")", ";", "if", "(", "value", ".", "equalsIgnoreCase", "(", "\"true\"", ")", ")", "{", "return", "true", ";", "}", "if", "(", "value", ".", "equalsIgnoreCase", "(", "\"false\"", ")", ")", "{", "return", "false", ";", "}", "throw", "new", "SlickXMLException", "(", "\"Value read: '\"", "+", "getAttribute", "(", "name", ")", "+", "\"' is not a boolean\"", ")", ";", "}" ]
Get the value specified for a given attribute on this element as a boolean. @param name The name of the attribute whose value should be retrieved @return The value given for the attribute @throws SlickXMLException Indicates a failure to convert the value into an boolean
[ "Get", "the", "value", "specified", "for", "a", "given", "attribute", "on", "this", "element", "as", "a", "boolean", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java#L153-L163
1,427
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java
XMLElement.getContent
public String getContent() { String content = ""; NodeList list = dom.getChildNodes(); for (int i=0;i<list.getLength();i++) { if (list.item(i) instanceof Text) { content += (list.item(i).getNodeValue()); } } return content; }
java
public String getContent() { String content = ""; NodeList list = dom.getChildNodes(); for (int i=0;i<list.getLength();i++) { if (list.item(i) instanceof Text) { content += (list.item(i).getNodeValue()); } } return content; }
[ "public", "String", "getContent", "(", ")", "{", "String", "content", "=", "\"\"", ";", "NodeList", "list", "=", "dom", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "if", "(", "list", ".", "item", "(", "i", ")", "instanceof", "Text", ")", "{", "content", "+=", "(", "list", ".", "item", "(", "i", ")", ".", "getNodeValue", "(", ")", ")", ";", "}", "}", "return", "content", ";", "}" ]
Get the text content of the element, i.e. the bit between the tags @return The text content of the node
[ "Get", "the", "text", "content", "of", "the", "element", "i", ".", "e", ".", "the", "bit", "between", "the", "tags" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java#L191-L202
1,428
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java
XMLElement.getChildren
public XMLElementList getChildren() { if (children != null) { return children; } NodeList list = dom.getChildNodes(); children = new XMLElementList(); for (int i=0;i<list.getLength();i++) { if (list.item(i) instanceof Element) { children.add(new XMLElement((Element) list.item(i))); } } return children; }
java
public XMLElementList getChildren() { if (children != null) { return children; } NodeList list = dom.getChildNodes(); children = new XMLElementList(); for (int i=0;i<list.getLength();i++) { if (list.item(i) instanceof Element) { children.add(new XMLElement((Element) list.item(i))); } } return children; }
[ "public", "XMLElementList", "getChildren", "(", ")", "{", "if", "(", "children", "!=", "null", ")", "{", "return", "children", ";", "}", "NodeList", "list", "=", "dom", ".", "getChildNodes", "(", ")", ";", "children", "=", "new", "XMLElementList", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "if", "(", "list", ".", "item", "(", "i", ")", "instanceof", "Element", ")", "{", "children", ".", "add", "(", "new", "XMLElement", "(", "(", "Element", ")", "list", ".", "item", "(", "i", ")", ")", ")", ";", "}", "}", "return", "children", ";", "}" ]
Get the complete list of children for this node @return The list of children for this node
[ "Get", "the", "complete", "list", "of", "children", "for", "this", "node" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java#L209-L224
1,429
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java
XMLElement.getChildrenByName
public XMLElementList getChildrenByName(String name) { XMLElementList selected = new XMLElementList(); XMLElementList children = getChildren(); for (int i=0;i<children.size();i++) { if (children.get(i).getName().equals(name)) { selected.add(children.get(i)); } } return selected; }
java
public XMLElementList getChildrenByName(String name) { XMLElementList selected = new XMLElementList(); XMLElementList children = getChildren(); for (int i=0;i<children.size();i++) { if (children.get(i).getName().equals(name)) { selected.add(children.get(i)); } } return selected; }
[ "public", "XMLElementList", "getChildrenByName", "(", "String", "name", ")", "{", "XMLElementList", "selected", "=", "new", "XMLElementList", "(", ")", ";", "XMLElementList", "children", "=", "getChildren", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "children", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "children", ".", "get", "(", "i", ")", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "selected", ".", "add", "(", "children", ".", "get", "(", "i", ")", ")", ";", "}", "}", "return", "selected", ";", "}" ]
Get a list of children with a given element name @param name The name of the element type that should be retrieved @return A list of elements
[ "Get", "a", "list", "of", "children", "with", "a", "given", "element", "name" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/XMLElement.java#L232-L243
1,430
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Ellipse.java
Ellipse.createPoints
protected void createPoints() { ArrayList tempPoints = new ArrayList(); maxX = -Float.MIN_VALUE; maxY = -Float.MIN_VALUE; minX = Float.MAX_VALUE; minY = Float.MAX_VALUE; float start = 0; float end = 359; float cx = x + radius1; float cy = y + radius2; int step = 360 / segmentCount; for (float a=start;a<=end+step;a+=step) { float ang = a; if (ang > end) { ang = end; } float newX = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius1)); float newY = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius2)); if(newX > maxX) { maxX = newX; } if(newY > maxY) { maxY = newY; } if(newX < minX) { minX = newX; } if(newY < minY) { minY = newY; } tempPoints.add(new Float(newX)); tempPoints.add(new Float(newY)); } points = new float[tempPoints.size()]; for(int i=0;i<points.length;i++) { points[i] = ((Float)tempPoints.get(i)).floatValue(); } }
java
protected void createPoints() { ArrayList tempPoints = new ArrayList(); maxX = -Float.MIN_VALUE; maxY = -Float.MIN_VALUE; minX = Float.MAX_VALUE; minY = Float.MAX_VALUE; float start = 0; float end = 359; float cx = x + radius1; float cy = y + radius2; int step = 360 / segmentCount; for (float a=start;a<=end+step;a+=step) { float ang = a; if (ang > end) { ang = end; } float newX = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius1)); float newY = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius2)); if(newX > maxX) { maxX = newX; } if(newY > maxY) { maxY = newY; } if(newX < minX) { minX = newX; } if(newY < minY) { minY = newY; } tempPoints.add(new Float(newX)); tempPoints.add(new Float(newY)); } points = new float[tempPoints.size()]; for(int i=0;i<points.length;i++) { points[i] = ((Float)tempPoints.get(i)).floatValue(); } }
[ "protected", "void", "createPoints", "(", ")", "{", "ArrayList", "tempPoints", "=", "new", "ArrayList", "(", ")", ";", "maxX", "=", "-", "Float", ".", "MIN_VALUE", ";", "maxY", "=", "-", "Float", ".", "MIN_VALUE", ";", "minX", "=", "Float", ".", "MAX_VALUE", ";", "minY", "=", "Float", ".", "MAX_VALUE", ";", "float", "start", "=", "0", ";", "float", "end", "=", "359", ";", "float", "cx", "=", "x", "+", "radius1", ";", "float", "cy", "=", "y", "+", "radius2", ";", "int", "step", "=", "360", "/", "segmentCount", ";", "for", "(", "float", "a", "=", "start", ";", "a", "<=", "end", "+", "step", ";", "a", "+=", "step", ")", "{", "float", "ang", "=", "a", ";", "if", "(", "ang", ">", "end", ")", "{", "ang", "=", "end", ";", "}", "float", "newX", "=", "(", "float", ")", "(", "cx", "+", "(", "FastTrig", ".", "cos", "(", "Math", ".", "toRadians", "(", "ang", ")", ")", "*", "radius1", ")", ")", ";", "float", "newY", "=", "(", "float", ")", "(", "cy", "+", "(", "FastTrig", ".", "sin", "(", "Math", ".", "toRadians", "(", "ang", ")", ")", "*", "radius2", ")", ")", ";", "if", "(", "newX", ">", "maxX", ")", "{", "maxX", "=", "newX", ";", "}", "if", "(", "newY", ">", "maxY", ")", "{", "maxY", "=", "newY", ";", "}", "if", "(", "newX", "<", "minX", ")", "{", "minX", "=", "newX", ";", "}", "if", "(", "newY", "<", "minY", ")", "{", "minY", "=", "newY", ";", "}", "tempPoints", ".", "add", "(", "new", "Float", "(", "newX", ")", ")", ";", "tempPoints", ".", "add", "(", "new", "Float", "(", "newY", ")", ")", ";", "}", "points", "=", "new", "float", "[", "tempPoints", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "points", ".", "length", ";", "i", "++", ")", "{", "points", "[", "i", "]", "=", "(", "(", "Float", ")", "tempPoints", ".", "get", "(", "i", ")", ")", ".", "floatValue", "(", ")", ";", "}", "}" ]
Generate the points to outline this ellipse.
[ "Generate", "the", "points", "to", "outline", "this", "ellipse", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Ellipse.java#L119-L163
1,431
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/NavMesh.java
NavMesh.findSpace
public Space findSpace(float x, float y) { for (int i=0;i<spaces.size();i++) { Space space = getSpace(i); if (space.contains(x,y)) { return space; } } return null; }
java
public Space findSpace(float x, float y) { for (int i=0;i<spaces.size();i++) { Space space = getSpace(i); if (space.contains(x,y)) { return space; } } return null; }
[ "public", "Space", "findSpace", "(", "float", "x", ",", "float", "y", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "spaces", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Space", "space", "=", "getSpace", "(", "i", ")", ";", "if", "(", "space", ".", "contains", "(", "x", ",", "y", ")", ")", "{", "return", "space", ";", "}", "}", "return", "null", ";", "}" ]
Find the space at a given location @param x The x coordinate at which to find the space @param y The y coordinate at which to find the space @return The space at the given location
[ "Find", "the", "space", "at", "a", "given", "location" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/NavMesh.java#L69-L78
1,432
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/NavMesh.java
NavMesh.findPath
public NavPath findPath(float sx, float sy, float tx, float ty, boolean optimize) { Space source = findSpace(sx,sy); Space target = findSpace(tx,ty); if ((source == null) || (target == null)) { return null; } for (int i=0;i<spaces.size();i++) { ((Space) spaces.get(i)).clearCost(); } target.fill(source,tx, ty, 0); if (target.getCost() == Float.MAX_VALUE) { return null; } if (source.getCost() == Float.MAX_VALUE) { return null; } NavPath path = new NavPath(); path.push(new Link(sx, sy, null)); if (source.pickLowestCost(target, path)) { path.push(new Link(tx, ty, null)); if (optimize) { optimize(path); } return path; } return null; }
java
public NavPath findPath(float sx, float sy, float tx, float ty, boolean optimize) { Space source = findSpace(sx,sy); Space target = findSpace(tx,ty); if ((source == null) || (target == null)) { return null; } for (int i=0;i<spaces.size();i++) { ((Space) spaces.get(i)).clearCost(); } target.fill(source,tx, ty, 0); if (target.getCost() == Float.MAX_VALUE) { return null; } if (source.getCost() == Float.MAX_VALUE) { return null; } NavPath path = new NavPath(); path.push(new Link(sx, sy, null)); if (source.pickLowestCost(target, path)) { path.push(new Link(tx, ty, null)); if (optimize) { optimize(path); } return path; } return null; }
[ "public", "NavPath", "findPath", "(", "float", "sx", ",", "float", "sy", ",", "float", "tx", ",", "float", "ty", ",", "boolean", "optimize", ")", "{", "Space", "source", "=", "findSpace", "(", "sx", ",", "sy", ")", ";", "Space", "target", "=", "findSpace", "(", "tx", ",", "ty", ")", ";", "if", "(", "(", "source", "==", "null", ")", "||", "(", "target", "==", "null", ")", ")", "{", "return", "null", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "spaces", ".", "size", "(", ")", ";", "i", "++", ")", "{", "(", "(", "Space", ")", "spaces", ".", "get", "(", "i", ")", ")", ".", "clearCost", "(", ")", ";", "}", "target", ".", "fill", "(", "source", ",", "tx", ",", "ty", ",", "0", ")", ";", "if", "(", "target", ".", "getCost", "(", ")", "==", "Float", ".", "MAX_VALUE", ")", "{", "return", "null", ";", "}", "if", "(", "source", ".", "getCost", "(", ")", "==", "Float", ".", "MAX_VALUE", ")", "{", "return", "null", ";", "}", "NavPath", "path", "=", "new", "NavPath", "(", ")", ";", "path", ".", "push", "(", "new", "Link", "(", "sx", ",", "sy", ",", "null", ")", ")", ";", "if", "(", "source", ".", "pickLowestCost", "(", "target", ",", "path", ")", ")", "{", "path", ".", "push", "(", "new", "Link", "(", "tx", ",", "ty", ",", "null", ")", ")", ";", "if", "(", "optimize", ")", "{", "optimize", "(", "path", ")", ";", "}", "return", "path", ";", "}", "return", "null", ";", "}" ]
Find a path from the source to the target coordinates @param sx The x coordinate of the source location @param sy The y coordinate of the source location @param tx The x coordinate of the target location @param ty The y coordinate of the target location @param optimize True if paths should be optimized @return The path between the two spaces
[ "Find", "a", "path", "from", "the", "source", "to", "the", "target", "coordinates" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/NavMesh.java#L90-L120
1,433
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/NavMesh.java
NavMesh.isClear
private boolean isClear(float x1, float y1, float x2, float y2, float step) { float dx = (x2 - x1); float dy = (y2 - y1); float len = (float) Math.sqrt((dx*dx)+(dy*dy)); dx *= step; dx /= len; dy *= step; dy /= len; int steps = (int) (len / step); for (int i=0;i<steps;i++) { float x = x1 + (dx*i); float y = y1 + (dy*i); if (findSpace(x,y) == null) { return false; } } return true; }
java
private boolean isClear(float x1, float y1, float x2, float y2, float step) { float dx = (x2 - x1); float dy = (y2 - y1); float len = (float) Math.sqrt((dx*dx)+(dy*dy)); dx *= step; dx /= len; dy *= step; dy /= len; int steps = (int) (len / step); for (int i=0;i<steps;i++) { float x = x1 + (dx*i); float y = y1 + (dy*i); if (findSpace(x,y) == null) { return false; } } return true; }
[ "private", "boolean", "isClear", "(", "float", "x1", ",", "float", "y1", ",", "float", "x2", ",", "float", "y2", ",", "float", "step", ")", "{", "float", "dx", "=", "(", "x2", "-", "x1", ")", ";", "float", "dy", "=", "(", "y2", "-", "y1", ")", ";", "float", "len", "=", "(", "float", ")", "Math", ".", "sqrt", "(", "(", "dx", "*", "dx", ")", "+", "(", "dy", "*", "dy", ")", ")", ";", "dx", "*=", "step", ";", "dx", "/=", "len", ";", "dy", "*=", "step", ";", "dy", "/=", "len", ";", "int", "steps", "=", "(", "int", ")", "(", "len", "/", "step", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "steps", ";", "i", "++", ")", "{", "float", "x", "=", "x1", "+", "(", "dx", "*", "i", ")", ";", "float", "y", "=", "y1", "+", "(", "dy", "*", "i", ")", ";", "if", "(", "findSpace", "(", "x", ",", "y", ")", "==", "null", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Check if a particular path is clear @param x1 The x coordinate of the starting point @param y1 The y coordinate of the starting point @param x2 The x coordinate of the ending point @param y2 The y coordinate of the ending point @param step The size of the step between points @return True if there are no blockages along the path
[ "Check", "if", "a", "particular", "path", "is", "clear" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/NavMesh.java#L132-L152
1,434
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/NavMesh.java
NavMesh.optimize
private void optimize(NavPath path) { int pt = 0; while (pt < path.length()-2) { float sx = path.getX(pt); float sy = path.getY(pt); float nx = path.getX(pt+2); float ny = path.getY(pt+2); if (isClear(sx,sy,nx,ny,0.1f)) { path.remove(pt+1); } else { pt++; } } }
java
private void optimize(NavPath path) { int pt = 0; while (pt < path.length()-2) { float sx = path.getX(pt); float sy = path.getY(pt); float nx = path.getX(pt+2); float ny = path.getY(pt+2); if (isClear(sx,sy,nx,ny,0.1f)) { path.remove(pt+1); } else { pt++; } } }
[ "private", "void", "optimize", "(", "NavPath", "path", ")", "{", "int", "pt", "=", "0", ";", "while", "(", "pt", "<", "path", ".", "length", "(", ")", "-", "2", ")", "{", "float", "sx", "=", "path", ".", "getX", "(", "pt", ")", ";", "float", "sy", "=", "path", ".", "getY", "(", "pt", ")", ";", "float", "nx", "=", "path", ".", "getX", "(", "pt", "+", "2", ")", ";", "float", "ny", "=", "path", ".", "getY", "(", "pt", "+", "2", ")", ";", "if", "(", "isClear", "(", "sx", ",", "sy", ",", "nx", ",", "ny", ",", "0.1f", ")", ")", "{", "path", ".", "remove", "(", "pt", "+", "1", ")", ";", "}", "else", "{", "pt", "++", ";", "}", "}", "}" ]
Optimize a path by removing segments that arn't required to reach the end point @param path The path to optimize. Redundant segments will be removed
[ "Optimize", "a", "path", "by", "removing", "segments", "that", "arn", "t", "required", "to", "reach", "the", "end", "point" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/NavMesh.java#L160-L175
1,435
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/FastTrig.java
FastTrig.sin
public static double sin(double radians) { radians = reduceSinAngle(radians); // limits angle to between -PI/2 and +PI/2 if (Math.abs(radians) <= Math.PI / 4) { return Math.sin(radians); } else { return Math.cos(Math.PI / 2 - radians); } }
java
public static double sin(double radians) { radians = reduceSinAngle(radians); // limits angle to between -PI/2 and +PI/2 if (Math.abs(radians) <= Math.PI / 4) { return Math.sin(radians); } else { return Math.cos(Math.PI / 2 - radians); } }
[ "public", "static", "double", "sin", "(", "double", "radians", ")", "{", "radians", "=", "reduceSinAngle", "(", "radians", ")", ";", "// limits angle to between -PI/2 and +PI/2\r", "if", "(", "Math", ".", "abs", "(", "radians", ")", "<=", "Math", ".", "PI", "/", "4", ")", "{", "return", "Math", ".", "sin", "(", "radians", ")", ";", "}", "else", "{", "return", "Math", ".", "cos", "(", "Math", ".", "PI", "/", "2", "-", "radians", ")", ";", "}", "}" ]
Get the sine of an angle @param radians The angle @return The sine of the angle
[ "Get", "the", "sine", "of", "an", "angle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/FastTrig.java#L37-L44
1,436
nguillaumin/slick2d-maven
slick2d-examples/src/main/java/org/newdawn/slick/examples/scroller/Scroller.java
Scroller.tryMove
private boolean tryMove(float x, float y) { float newx = playerX + x; float newy = playerY + y; // first we try the real move, if that doesn't work // we try moving on just one of the axis (X and then Y) // this allows us to slide against edges if (blocked(newx,newy)) { if (blocked(newx, playerY)) { if (blocked(playerX, newy)) { // can't move at all! return false; } else { playerY = newy; return true; } } else { playerX = newx; return true; } } else { playerX = newx; playerY = newy; return true; } }
java
private boolean tryMove(float x, float y) { float newx = playerX + x; float newy = playerY + y; // first we try the real move, if that doesn't work // we try moving on just one of the axis (X and then Y) // this allows us to slide against edges if (blocked(newx,newy)) { if (blocked(newx, playerY)) { if (blocked(playerX, newy)) { // can't move at all! return false; } else { playerY = newy; return true; } } else { playerX = newx; return true; } } else { playerX = newx; playerY = newy; return true; } }
[ "private", "boolean", "tryMove", "(", "float", "x", ",", "float", "y", ")", "{", "float", "newx", "=", "playerX", "+", "x", ";", "float", "newy", "=", "playerY", "+", "y", ";", "// first we try the real move, if that doesn't work\r", "// we try moving on just one of the axis (X and then Y) \r", "// this allows us to slide against edges\r", "if", "(", "blocked", "(", "newx", ",", "newy", ")", ")", "{", "if", "(", "blocked", "(", "newx", ",", "playerY", ")", ")", "{", "if", "(", "blocked", "(", "playerX", ",", "newy", ")", ")", "{", "// can't move at all!\r", "return", "false", ";", "}", "else", "{", "playerY", "=", "newy", ";", "return", "true", ";", "}", "}", "else", "{", "playerX", "=", "newx", ";", "return", "true", ";", "}", "}", "else", "{", "playerX", "=", "newx", ";", "playerY", "=", "newy", ";", "return", "true", ";", "}", "}" ]
Try to move in the direction specified. If it's blocked, try sliding. If that doesn't work just don't bother @param x The amount on the X axis to move @param y The amount on the Y axis to move @return True if we managed to move
[ "Try", "to", "move", "in", "the", "direction", "specified", ".", "If", "it", "s", "blocked", "try", "sliding", ".", "If", "that", "doesn", "t", "work", "just", "don", "t", "bother" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-examples/src/main/java/org/newdawn/slick/examples/scroller/Scroller.java#L160-L185
1,437
nguillaumin/slick2d-maven
slick2d-examples/src/main/java/org/newdawn/slick/examples/scroller/Scroller.java
Scroller.updateMovementVector
private void updateMovementVector() { dirX = (float) Math.sin(Math.toRadians(ang)); dirY = (float) -Math.cos(Math.toRadians(ang)); }
java
private void updateMovementVector() { dirX = (float) Math.sin(Math.toRadians(ang)); dirY = (float) -Math.cos(Math.toRadians(ang)); }
[ "private", "void", "updateMovementVector", "(", ")", "{", "dirX", "=", "(", "float", ")", "Math", ".", "sin", "(", "Math", ".", "toRadians", "(", "ang", ")", ")", ";", "dirY", "=", "(", "float", ")", "-", "Math", ".", "cos", "(", "Math", ".", "toRadians", "(", "ang", ")", ")", ";", "}" ]
Update the direction that will be moved in based on the current angle of rotation
[ "Update", "the", "direction", "that", "will", "be", "moved", "in", "based", "on", "the", "current", "angle", "of", "rotation" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-examples/src/main/java/org/newdawn/slick/examples/scroller/Scroller.java#L191-L194
1,438
nguillaumin/slick2d-maven
slick2d-examples/src/main/java/org/newdawn/slick/examples/scroller/Scroller.java
Scroller.drawTank
public void drawTank(Graphics g, float xpos, float ypos, float rot) { // work out the centre of the tank in rendering coordinates and then // spit onto the screen int cx = (int) (xpos * 32); int cy = (int) (ypos * 32); g.rotate(cx,cy,rot); player.draw(cx-16,cy-16); g.rotate(cx,cy,-rot); }
java
public void drawTank(Graphics g, float xpos, float ypos, float rot) { // work out the centre of the tank in rendering coordinates and then // spit onto the screen int cx = (int) (xpos * 32); int cy = (int) (ypos * 32); g.rotate(cx,cy,rot); player.draw(cx-16,cy-16); g.rotate(cx,cy,-rot); }
[ "public", "void", "drawTank", "(", "Graphics", "g", ",", "float", "xpos", ",", "float", "ypos", ",", "float", "rot", ")", "{", "// work out the centre of the tank in rendering coordinates and then\r", "// spit onto the screen\r", "int", "cx", "=", "(", "int", ")", "(", "xpos", "*", "32", ")", ";", "int", "cy", "=", "(", "int", ")", "(", "ypos", "*", "32", ")", ";", "g", ".", "rotate", "(", "cx", ",", "cy", ",", "rot", ")", ";", "player", ".", "draw", "(", "cx", "-", "16", ",", "cy", "-", "16", ")", ";", "g", ".", "rotate", "(", "cx", ",", "cy", ",", "-", "rot", ")", ";", "}" ]
Draw a single tank to the game @param g The graphics context on which we're drawing @param xpos The x coordinate in tiles the tank is at @param ypos The y coordinate in tiles the tank is at @param rot The rotation of the tank
[ "Draw", "a", "single", "tank", "to", "the", "game" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-examples/src/main/java/org/newdawn/slick/examples/scroller/Scroller.java#L236-L244
1,439
nguillaumin/slick2d-maven
slick2d-examples/src/main/java/org/newdawn/slick/examples/scroller/Scroller.java
Scroller.main
public static void main(String[] argv) { try { // create a new container for our example game. This container // just creates a normal native window for rendering OpenGL accelerated // elements to AppGameContainer container = new AppGameContainer(new Scroller(), 800, 600, false); container.start(); } catch (Exception e) { e.printStackTrace(); } }
java
public static void main(String[] argv) { try { // create a new container for our example game. This container // just creates a normal native window for rendering OpenGL accelerated // elements to AppGameContainer container = new AppGameContainer(new Scroller(), 800, 600, false); container.start(); } catch (Exception e) { e.printStackTrace(); } }
[ "public", "static", "void", "main", "(", "String", "[", "]", "argv", ")", "{", "try", "{", "// create a new container for our example game. This container\r", "// just creates a normal native window for rendering OpenGL accelerated\r", "// elements to\r", "AppGameContainer", "container", "=", "new", "AppGameContainer", "(", "new", "Scroller", "(", ")", ",", "800", ",", "600", ",", "false", ")", ";", "container", ".", "start", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Entry point to the scroller example @param argv The argument passed on the command line (if any)
[ "Entry", "point", "to", "the", "scroller", "example" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-examples/src/main/java/org/newdawn/slick/examples/scroller/Scroller.java#L251-L261
1,440
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/SettingsPanel.java
SettingsPanel.browseForImage
private void browseForImage() { if (emitter != null) { int resp = chooser.showOpenDialog(this); if (resp == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); String path = file.getParentFile().getAbsolutePath(); String name = file.getName(); ConfigurableEmitter.setRelativePath(path); emitter.setImageName(name); imageName.setText(name); } } }
java
private void browseForImage() { if (emitter != null) { int resp = chooser.showOpenDialog(this); if (resp == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); String path = file.getParentFile().getAbsolutePath(); String name = file.getName(); ConfigurableEmitter.setRelativePath(path); emitter.setImageName(name); imageName.setText(name); } } }
[ "private", "void", "browseForImage", "(", ")", "{", "if", "(", "emitter", "!=", "null", ")", "{", "int", "resp", "=", "chooser", ".", "showOpenDialog", "(", "this", ")", ";", "if", "(", "resp", "==", "JFileChooser", ".", "APPROVE_OPTION", ")", "{", "File", "file", "=", "chooser", ".", "getSelectedFile", "(", ")", ";", "String", "path", "=", "file", ".", "getParentFile", "(", ")", ".", "getAbsolutePath", "(", ")", ";", "String", "name", "=", "file", ".", "getName", "(", ")", ";", "ConfigurableEmitter", ".", "setRelativePath", "(", "path", ")", ";", "emitter", ".", "setImageName", "(", "name", ")", ";", "imageName", ".", "setText", "(", "name", ")", ";", "}", "}", "}" ]
Browse for a particle image and set the value into both the emitter and text field on successful completion
[ "Browse", "for", "a", "particle", "image", "and", "set", "the", "value", "into", "both", "the", "emitter", "and", "text", "field", "on", "successful", "completion" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/SettingsPanel.java#L88-L102
1,441
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/BigImage.java
BigImage.getMaxSingleImageSize
public static final int getMaxSingleImageSize() { IntBuffer buffer = BufferUtils.createIntBuffer(16); GL.glGetInteger(SGL.GL_MAX_TEXTURE_SIZE, buffer); return buffer.get(0); }
java
public static final int getMaxSingleImageSize() { IntBuffer buffer = BufferUtils.createIntBuffer(16); GL.glGetInteger(SGL.GL_MAX_TEXTURE_SIZE, buffer); return buffer.get(0); }
[ "public", "static", "final", "int", "getMaxSingleImageSize", "(", ")", "{", "IntBuffer", "buffer", "=", "BufferUtils", ".", "createIntBuffer", "(", "16", ")", ";", "GL", ".", "glGetInteger", "(", "SGL", ".", "GL_MAX_TEXTURE_SIZE", ",", "buffer", ")", ";", "return", "buffer", ".", "get", "(", "0", ")", ";", "}" ]
Get the maximum size of an image supported by the underlying hardware. @return The maximum size of the textures supported by the underlying hardware.
[ "Get", "the", "maximum", "size", "of", "an", "image", "supported", "by", "the", "underlying", "hardware", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/BigImage.java#L43-L48
1,442
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/BigImage.java
BigImage.build
private void build(String ref, int filter, int tileSize) throws SlickException { try { final LoadableImageData data = ImageDataFactory.getImageDataFor(ref); final ByteBuffer imageBuffer = data.loadImage(ResourceLoader.getResourceAsStream(ref), false, null); build(data, imageBuffer, filter, tileSize); } catch (IOException e) { throw new SlickException("Failed to load: "+ref, e); } }
java
private void build(String ref, int filter, int tileSize) throws SlickException { try { final LoadableImageData data = ImageDataFactory.getImageDataFor(ref); final ByteBuffer imageBuffer = data.loadImage(ResourceLoader.getResourceAsStream(ref), false, null); build(data, imageBuffer, filter, tileSize); } catch (IOException e) { throw new SlickException("Failed to load: "+ref, e); } }
[ "private", "void", "build", "(", "String", "ref", ",", "int", "filter", ",", "int", "tileSize", ")", "throws", "SlickException", "{", "try", "{", "final", "LoadableImageData", "data", "=", "ImageDataFactory", ".", "getImageDataFor", "(", "ref", ")", ";", "final", "ByteBuffer", "imageBuffer", "=", "data", ".", "loadImage", "(", "ResourceLoader", ".", "getResourceAsStream", "(", "ref", ")", ",", "false", ",", "null", ")", ";", "build", "(", "data", ",", "imageBuffer", ",", "filter", ",", "tileSize", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "SlickException", "(", "\"Failed to load: \"", "+", "ref", ",", "e", ")", ";", "}", "}" ]
Create a new big image by loading it from the specified reference @param ref The reference to the image to load @param filter The image filter to apply (@see #Image.FILTER_NEAREST) @param tileSize The maximum size of the tiles to use to build the bigger image @throws SlickException Indicates we were unable to locate the resource
[ "Create", "a", "new", "big", "image", "by", "loading", "it", "from", "the", "specified", "reference" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/BigImage.java#L147-L155
1,443
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/BigImage.java
BigImage.destroy
public void destroy() throws SlickException { for (int tx=0;tx<xcount;tx++) { for (int ty=0;ty<ycount;ty++) { Image image = images[tx][ty]; image.destroy(); } } }
java
public void destroy() throws SlickException { for (int tx=0;tx<xcount;tx++) { for (int ty=0;ty<ycount;ty++) { Image image = images[tx][ty]; image.destroy(); } } }
[ "public", "void", "destroy", "(", ")", "throws", "SlickException", "{", "for", "(", "int", "tx", "=", "0", ";", "tx", "<", "xcount", ";", "tx", "++", ")", "{", "for", "(", "int", "ty", "=", "0", ";", "ty", "<", "ycount", ";", "ty", "++", ")", "{", "Image", "image", "=", "images", "[", "tx", "]", "[", "ty", "]", ";", "image", ".", "destroy", "(", ")", ";", "}", "}", "}" ]
Destroy the image and release any native resources. Calls on a destroyed image have undefined results
[ "Destroy", "the", "image", "and", "release", "any", "native", "resources", ".", "Calls", "on", "a", "destroyed", "image", "have", "undefined", "results" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/BigImage.java#L711-L718
1,444
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/ImageIOImageData.java
ImageIOImageData.copyArea
private void copyArea(BufferedImage image, int x, int y, int width, int height, int dx, int dy) { Graphics2D g = (Graphics2D) image.getGraphics(); g.drawImage(image.getSubimage(x, y, width, height),x+dx,y+dy,null); }
java
private void copyArea(BufferedImage image, int x, int y, int width, int height, int dx, int dy) { Graphics2D g = (Graphics2D) image.getGraphics(); g.drawImage(image.getSubimage(x, y, width, height),x+dx,y+dy,null); }
[ "private", "void", "copyArea", "(", "BufferedImage", "image", ",", "int", "x", ",", "int", "y", ",", "int", "width", ",", "int", "height", ",", "int", "dx", ",", "int", "dy", ")", "{", "Graphics2D", "g", "=", "(", "Graphics2D", ")", "image", ".", "getGraphics", "(", ")", ";", "g", ".", "drawImage", "(", "image", ".", "getSubimage", "(", "x", ",", "y", ",", "width", ",", "height", ")", ",", "x", "+", "dx", ",", "y", "+", "dy", ",", "null", ")", ";", "}" ]
Implement of transform copy area for 1.4 @param image The image to copy @param x The x position to copy to @param y The y position to copy to @param width The width of the image @param height The height of the image @param dx The transform on the x axis @param dy The transform on the y axis
[ "Implement", "of", "transform", "copy", "area", "for", "1", ".", "4" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/ImageIOImageData.java#L232-L236
1,445
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/BufferedImageUtil.java
BufferedImageUtil.getTexture
public static Texture getTexture(String resourceName, BufferedImage resourceImage) throws IOException { Texture tex = getTexture(resourceName, resourceImage, SGL.GL_TEXTURE_2D, // target SGL.GL_RGBA8, // dest pixel format SGL.GL_LINEAR, // min filter (unused) SGL.GL_LINEAR); return tex; }
java
public static Texture getTexture(String resourceName, BufferedImage resourceImage) throws IOException { Texture tex = getTexture(resourceName, resourceImage, SGL.GL_TEXTURE_2D, // target SGL.GL_RGBA8, // dest pixel format SGL.GL_LINEAR, // min filter (unused) SGL.GL_LINEAR); return tex; }
[ "public", "static", "Texture", "getTexture", "(", "String", "resourceName", ",", "BufferedImage", "resourceImage", ")", "throws", "IOException", "{", "Texture", "tex", "=", "getTexture", "(", "resourceName", ",", "resourceImage", ",", "SGL", ".", "GL_TEXTURE_2D", ",", "// target\r", "SGL", ".", "GL_RGBA8", ",", "// dest pixel format\r", "SGL", ".", "GL_LINEAR", ",", "// min filter (unused)\r", "SGL", ".", "GL_LINEAR", ")", ";", "return", "tex", ";", "}" ]
Load a texture @param resourceName The location of the resource to load @param resourceImage The BufferedImage we are converting @return The loaded texture @throws IOException Indicates a failure to access the resource
[ "Load", "a", "texture" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/BufferedImageUtil.java#L37-L46
1,446
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/BufferedImageUtil.java
BufferedImageUtil.getTexture
public static Texture getTexture(String resourceName, BufferedImage resourceimage, int target, int dstPixelFormat, int minFilter, int magFilter) throws IOException { ImageIOImageData data = new ImageIOImageData();int srcPixelFormat = 0; // create the texture ID for this texture int textureID = InternalTextureLoader.createTextureID(); TextureImpl texture = new TextureImpl(resourceName, target, textureID); // Enable texturing Renderer.get().glEnable(SGL.GL_TEXTURE_2D); // bind this texture Renderer.get().glBindTexture(target, textureID); BufferedImage bufferedImage = resourceimage; texture.setWidth(bufferedImage.getWidth()); texture.setHeight(bufferedImage.getHeight()); if (bufferedImage.getColorModel().hasAlpha()) { srcPixelFormat = SGL.GL_RGBA; } else { srcPixelFormat = SGL.GL_RGB; } // convert that image into a byte buffer of texture data ByteBuffer textureBuffer = data.imageToByteBuffer(bufferedImage, false, false, null); texture.setTextureHeight(data.getTexHeight()); texture.setTextureWidth(data.getTexWidth()); texture.setAlpha(data.getDepth() == 32); if (target == SGL.GL_TEXTURE_2D) { Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MIN_FILTER, minFilter); Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MAG_FILTER, magFilter); if (Renderer.get().canTextureMirrorClamp()) { Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT); Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT); } else { Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_CLAMP); Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_CLAMP); } } Renderer.get().glTexImage2D(target, 0, dstPixelFormat, texture.getTextureWidth(), texture.getTextureHeight(), 0, srcPixelFormat, SGL.GL_UNSIGNED_BYTE, textureBuffer); return texture; }
java
public static Texture getTexture(String resourceName, BufferedImage resourceimage, int target, int dstPixelFormat, int minFilter, int magFilter) throws IOException { ImageIOImageData data = new ImageIOImageData();int srcPixelFormat = 0; // create the texture ID for this texture int textureID = InternalTextureLoader.createTextureID(); TextureImpl texture = new TextureImpl(resourceName, target, textureID); // Enable texturing Renderer.get().glEnable(SGL.GL_TEXTURE_2D); // bind this texture Renderer.get().glBindTexture(target, textureID); BufferedImage bufferedImage = resourceimage; texture.setWidth(bufferedImage.getWidth()); texture.setHeight(bufferedImage.getHeight()); if (bufferedImage.getColorModel().hasAlpha()) { srcPixelFormat = SGL.GL_RGBA; } else { srcPixelFormat = SGL.GL_RGB; } // convert that image into a byte buffer of texture data ByteBuffer textureBuffer = data.imageToByteBuffer(bufferedImage, false, false, null); texture.setTextureHeight(data.getTexHeight()); texture.setTextureWidth(data.getTexWidth()); texture.setAlpha(data.getDepth() == 32); if (target == SGL.GL_TEXTURE_2D) { Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MIN_FILTER, minFilter); Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MAG_FILTER, magFilter); if (Renderer.get().canTextureMirrorClamp()) { Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT); Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT); } else { Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_CLAMP); Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_CLAMP); } } Renderer.get().glTexImage2D(target, 0, dstPixelFormat, texture.getTextureWidth(), texture.getTextureHeight(), 0, srcPixelFormat, SGL.GL_UNSIGNED_BYTE, textureBuffer); return texture; }
[ "public", "static", "Texture", "getTexture", "(", "String", "resourceName", ",", "BufferedImage", "resourceimage", ",", "int", "target", ",", "int", "dstPixelFormat", ",", "int", "minFilter", ",", "int", "magFilter", ")", "throws", "IOException", "{", "ImageIOImageData", "data", "=", "new", "ImageIOImageData", "(", ")", ";", "int", "srcPixelFormat", "=", "0", ";", "// create the texture ID for this texture\r", "int", "textureID", "=", "InternalTextureLoader", ".", "createTextureID", "(", ")", ";", "TextureImpl", "texture", "=", "new", "TextureImpl", "(", "resourceName", ",", "target", ",", "textureID", ")", ";", "// Enable texturing\r", "Renderer", ".", "get", "(", ")", ".", "glEnable", "(", "SGL", ".", "GL_TEXTURE_2D", ")", ";", "// bind this texture\r", "Renderer", ".", "get", "(", ")", ".", "glBindTexture", "(", "target", ",", "textureID", ")", ";", "BufferedImage", "bufferedImage", "=", "resourceimage", ";", "texture", ".", "setWidth", "(", "bufferedImage", ".", "getWidth", "(", ")", ")", ";", "texture", ".", "setHeight", "(", "bufferedImage", ".", "getHeight", "(", ")", ")", ";", "if", "(", "bufferedImage", ".", "getColorModel", "(", ")", ".", "hasAlpha", "(", ")", ")", "{", "srcPixelFormat", "=", "SGL", ".", "GL_RGBA", ";", "}", "else", "{", "srcPixelFormat", "=", "SGL", ".", "GL_RGB", ";", "}", "// convert that image into a byte buffer of texture data\r", "ByteBuffer", "textureBuffer", "=", "data", ".", "imageToByteBuffer", "(", "bufferedImage", ",", "false", ",", "false", ",", "null", ")", ";", "texture", ".", "setTextureHeight", "(", "data", ".", "getTexHeight", "(", ")", ")", ";", "texture", ".", "setTextureWidth", "(", "data", ".", "getTexWidth", "(", ")", ")", ";", "texture", ".", "setAlpha", "(", "data", ".", "getDepth", "(", ")", "==", "32", ")", ";", "if", "(", "target", "==", "SGL", ".", "GL_TEXTURE_2D", ")", "{", "Renderer", ".", "get", "(", ")", ".", "glTexParameteri", "(", "target", ",", "SGL", ".", "GL_TEXTURE_MIN_FILTER", ",", "minFilter", ")", ";", "Renderer", ".", "get", "(", ")", ".", "glTexParameteri", "(", "target", ",", "SGL", ".", "GL_TEXTURE_MAG_FILTER", ",", "magFilter", ")", ";", "if", "(", "Renderer", ".", "get", "(", ")", ".", "canTextureMirrorClamp", "(", ")", ")", "{", "Renderer", ".", "get", "(", ")", ".", "glTexParameteri", "(", "SGL", ".", "GL_TEXTURE_2D", ",", "SGL", ".", "GL_TEXTURE_WRAP_S", ",", "SGL", ".", "GL_MIRROR_CLAMP_TO_EDGE_EXT", ")", ";", "Renderer", ".", "get", "(", ")", ".", "glTexParameteri", "(", "SGL", ".", "GL_TEXTURE_2D", ",", "SGL", ".", "GL_TEXTURE_WRAP_T", ",", "SGL", ".", "GL_MIRROR_CLAMP_TO_EDGE_EXT", ")", ";", "}", "else", "{", "Renderer", ".", "get", "(", ")", ".", "glTexParameteri", "(", "SGL", ".", "GL_TEXTURE_2D", ",", "SGL", ".", "GL_TEXTURE_WRAP_S", ",", "SGL", ".", "GL_CLAMP", ")", ";", "Renderer", ".", "get", "(", ")", ".", "glTexParameteri", "(", "SGL", ".", "GL_TEXTURE_2D", ",", "SGL", ".", "GL_TEXTURE_WRAP_T", ",", "SGL", ".", "GL_CLAMP", ")", ";", "}", "}", "Renderer", ".", "get", "(", ")", ".", "glTexImage2D", "(", "target", ",", "0", ",", "dstPixelFormat", ",", "texture", ".", "getTextureWidth", "(", ")", ",", "texture", ".", "getTextureHeight", "(", ")", ",", "0", ",", "srcPixelFormat", ",", "SGL", ".", "GL_UNSIGNED_BYTE", ",", "textureBuffer", ")", ";", "return", "texture", ";", "}" ]
Load a texture into OpenGL from a BufferedImage @param resourceName The location of the resource to load @param resourceimage The BufferedImage we are converting @param target The GL target to load the texture against @param dstPixelFormat The pixel format of the screen @param minFilter The minimising filter @param magFilter The magnification filter @return The loaded texture @throws IOException Indicates a failure to access the resource
[ "Load", "a", "texture", "into", "OpenGL", "from", "a", "BufferedImage" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/BufferedImageUtil.java#L89-L144
1,447
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java
EffectUtil.getScratchImage
static public BufferedImage getScratchImage() { Graphics2D g = (Graphics2D)scratchImage.getGraphics(); g.setComposite(AlphaComposite.Clear); g.fillRect(0, 0, GlyphPage.MAX_GLYPH_SIZE, GlyphPage.MAX_GLYPH_SIZE); g.setComposite(AlphaComposite.SrcOver); g.setColor(java.awt.Color.white); return scratchImage; }
java
static public BufferedImage getScratchImage() { Graphics2D g = (Graphics2D)scratchImage.getGraphics(); g.setComposite(AlphaComposite.Clear); g.fillRect(0, 0, GlyphPage.MAX_GLYPH_SIZE, GlyphPage.MAX_GLYPH_SIZE); g.setComposite(AlphaComposite.SrcOver); g.setColor(java.awt.Color.white); return scratchImage; }
[ "static", "public", "BufferedImage", "getScratchImage", "(", ")", "{", "Graphics2D", "g", "=", "(", "Graphics2D", ")", "scratchImage", ".", "getGraphics", "(", ")", ";", "g", ".", "setComposite", "(", "AlphaComposite", ".", "Clear", ")", ";", "g", ".", "fillRect", "(", "0", ",", "0", ",", "GlyphPage", ".", "MAX_GLYPH_SIZE", ",", "GlyphPage", ".", "MAX_GLYPH_SIZE", ")", ";", "g", ".", "setComposite", "(", "AlphaComposite", ".", "SrcOver", ")", ";", "g", ".", "setColor", "(", "java", ".", "awt", ".", "Color", ".", "white", ")", ";", "return", "scratchImage", ";", "}" ]
Returns an image that can be used by effects as a temp image. @return The scratch image used for temporary operations
[ "Returns", "an", "image", "that", "can", "be", "used", "by", "effects", "as", "a", "temp", "image", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java#L48-L55
1,448
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java
EffectUtil.colorValue
static public Value colorValue(String name, Color currentValue) { return new DefaultValue(name, EffectUtil.toString(currentValue)) { public void showDialog () { Color newColor = JColorChooser.showDialog(null, "Choose a color", EffectUtil.fromString(value)); if (newColor != null) value = EffectUtil.toString(newColor); } public Object getObject () { return EffectUtil.fromString(value); } }; }
java
static public Value colorValue(String name, Color currentValue) { return new DefaultValue(name, EffectUtil.toString(currentValue)) { public void showDialog () { Color newColor = JColorChooser.showDialog(null, "Choose a color", EffectUtil.fromString(value)); if (newColor != null) value = EffectUtil.toString(newColor); } public Object getObject () { return EffectUtil.fromString(value); } }; }
[ "static", "public", "Value", "colorValue", "(", "String", "name", ",", "Color", "currentValue", ")", "{", "return", "new", "DefaultValue", "(", "name", ",", "EffectUtil", ".", "toString", "(", "currentValue", ")", ")", "{", "public", "void", "showDialog", "(", ")", "{", "Color", "newColor", "=", "JColorChooser", ".", "showDialog", "(", "null", ",", "\"Choose a color\"", ",", "EffectUtil", ".", "fromString", "(", "value", ")", ")", ";", "if", "(", "newColor", "!=", "null", ")", "value", "=", "EffectUtil", ".", "toString", "(", "newColor", ")", ";", "}", "public", "Object", "getObject", "(", ")", "{", "return", "EffectUtil", ".", "fromString", "(", "value", ")", ";", "}", "}", ";", "}" ]
Prompts the user for a colour value @param name Thename of the value being configured @param currentValue The default value that should be selected @return The value selected
[ "Prompts", "the", "user", "for", "a", "colour", "value" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java#L64-L75
1,449
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java
EffectUtil.intValue
static public Value intValue (String name, final int currentValue, final String description) { return new DefaultValue(name, String.valueOf(currentValue)) { public void showDialog () { JSpinner spinner = new JSpinner(new SpinnerNumberModel(currentValue, Short.MIN_VALUE, Short.MAX_VALUE, 1)); if (showValueDialog(spinner, description)) value = String.valueOf(spinner.getValue()); } public Object getObject () { return Integer.valueOf(value); } }; }
java
static public Value intValue (String name, final int currentValue, final String description) { return new DefaultValue(name, String.valueOf(currentValue)) { public void showDialog () { JSpinner spinner = new JSpinner(new SpinnerNumberModel(currentValue, Short.MIN_VALUE, Short.MAX_VALUE, 1)); if (showValueDialog(spinner, description)) value = String.valueOf(spinner.getValue()); } public Object getObject () { return Integer.valueOf(value); } }; }
[ "static", "public", "Value", "intValue", "(", "String", "name", ",", "final", "int", "currentValue", ",", "final", "String", "description", ")", "{", "return", "new", "DefaultValue", "(", "name", ",", "String", ".", "valueOf", "(", "currentValue", ")", ")", "{", "public", "void", "showDialog", "(", ")", "{", "JSpinner", "spinner", "=", "new", "JSpinner", "(", "new", "SpinnerNumberModel", "(", "currentValue", ",", "Short", ".", "MIN_VALUE", ",", "Short", ".", "MAX_VALUE", ",", "1", ")", ")", ";", "if", "(", "showValueDialog", "(", "spinner", ",", "description", ")", ")", "value", "=", "String", ".", "valueOf", "(", "spinner", ".", "getValue", "(", ")", ")", ";", "}", "public", "Object", "getObject", "(", ")", "{", "return", "Integer", ".", "valueOf", "(", "value", ")", ";", "}", "}", ";", "}" ]
Prompts the user for int value @param name The name of the dialog to show @param currentValue The current value to be displayed @param description The help text to provide @return The value selected by the user
[ "Prompts", "the", "user", "for", "int", "value" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java#L85-L96
1,450
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java
EffectUtil.floatValue
static public Value floatValue (String name, final float currentValue, final float min, final float max, final String description) { return new DefaultValue(name, String.valueOf(currentValue)) { public void showDialog () { JSpinner spinner = new JSpinner(new SpinnerNumberModel(currentValue, min, max, 0.1f)); if (showValueDialog(spinner, description)) value = String.valueOf(((Double)spinner.getValue()).floatValue()); } public Object getObject () { return Float.valueOf(value); } }; }
java
static public Value floatValue (String name, final float currentValue, final float min, final float max, final String description) { return new DefaultValue(name, String.valueOf(currentValue)) { public void showDialog () { JSpinner spinner = new JSpinner(new SpinnerNumberModel(currentValue, min, max, 0.1f)); if (showValueDialog(spinner, description)) value = String.valueOf(((Double)spinner.getValue()).floatValue()); } public Object getObject () { return Float.valueOf(value); } }; }
[ "static", "public", "Value", "floatValue", "(", "String", "name", ",", "final", "float", "currentValue", ",", "final", "float", "min", ",", "final", "float", "max", ",", "final", "String", "description", ")", "{", "return", "new", "DefaultValue", "(", "name", ",", "String", ".", "valueOf", "(", "currentValue", ")", ")", "{", "public", "void", "showDialog", "(", ")", "{", "JSpinner", "spinner", "=", "new", "JSpinner", "(", "new", "SpinnerNumberModel", "(", "currentValue", ",", "min", ",", "max", ",", "0.1f", ")", ")", ";", "if", "(", "showValueDialog", "(", "spinner", ",", "description", ")", ")", "value", "=", "String", ".", "valueOf", "(", "(", "(", "Double", ")", "spinner", ".", "getValue", "(", ")", ")", ".", "floatValue", "(", ")", ")", ";", "}", "public", "Object", "getObject", "(", ")", "{", "return", "Float", ".", "valueOf", "(", "value", ")", ";", "}", "}", ";", "}" ]
Prompts the user for float value @param name The name of the dialog to show @param currentValue The current value to be displayed @param description The help text to provide @param min The minimum value to allow @param max The maximum value to allow @return The value selected by the user
[ "Prompts", "the", "user", "for", "float", "value" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java#L108-L120
1,451
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java
EffectUtil.booleanValue
static public Value booleanValue (String name, final boolean currentValue, final String description) { return new DefaultValue(name, String.valueOf(currentValue)) { public void showDialog () { JCheckBox checkBox = new JCheckBox(); checkBox.setSelected(currentValue); if (showValueDialog(checkBox, description)) value = String.valueOf(checkBox.isSelected()); } public Object getObject () { return Boolean.valueOf(value); } }; }
java
static public Value booleanValue (String name, final boolean currentValue, final String description) { return new DefaultValue(name, String.valueOf(currentValue)) { public void showDialog () { JCheckBox checkBox = new JCheckBox(); checkBox.setSelected(currentValue); if (showValueDialog(checkBox, description)) value = String.valueOf(checkBox.isSelected()); } public Object getObject () { return Boolean.valueOf(value); } }; }
[ "static", "public", "Value", "booleanValue", "(", "String", "name", ",", "final", "boolean", "currentValue", ",", "final", "String", "description", ")", "{", "return", "new", "DefaultValue", "(", "name", ",", "String", ".", "valueOf", "(", "currentValue", ")", ")", "{", "public", "void", "showDialog", "(", ")", "{", "JCheckBox", "checkBox", "=", "new", "JCheckBox", "(", ")", ";", "checkBox", ".", "setSelected", "(", "currentValue", ")", ";", "if", "(", "showValueDialog", "(", "checkBox", ",", "description", ")", ")", "value", "=", "String", ".", "valueOf", "(", "checkBox", ".", "isSelected", "(", ")", ")", ";", "}", "public", "Object", "getObject", "(", ")", "{", "return", "Boolean", ".", "valueOf", "(", "value", ")", ";", "}", "}", ";", "}" ]
Prompts the user for boolean value @param name The name of the dialog to show @param currentValue The current value to be displayed @param description The help text to provide @return The value selected by the user
[ "Prompts", "the", "user", "for", "boolean", "value" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java#L130-L142
1,452
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java
EffectUtil.optionValue
static public Value optionValue (String name, final String currentValue, final String[][] options, final String description) { return new DefaultValue(name, currentValue.toString()) { public void showDialog () { int selectedIndex = -1; DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i = 0; i < options.length; i++) { model.addElement(options[i][0]); if (getValue(i).equals(currentValue)) selectedIndex = i; } JComboBox comboBox = new JComboBox(model); comboBox.setSelectedIndex(selectedIndex); if (showValueDialog(comboBox, description)) value = getValue(comboBox.getSelectedIndex()); } private String getValue (int i) { if (options[i].length == 1) return options[i][0]; return options[i][1]; } public String toString () { for (int i = 0; i < options.length; i++) if (getValue(i).equals(value)) return options[i][0].toString(); return ""; } public Object getObject () { return value; } }; }
java
static public Value optionValue (String name, final String currentValue, final String[][] options, final String description) { return new DefaultValue(name, currentValue.toString()) { public void showDialog () { int selectedIndex = -1; DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i = 0; i < options.length; i++) { model.addElement(options[i][0]); if (getValue(i).equals(currentValue)) selectedIndex = i; } JComboBox comboBox = new JComboBox(model); comboBox.setSelectedIndex(selectedIndex); if (showValueDialog(comboBox, description)) value = getValue(comboBox.getSelectedIndex()); } private String getValue (int i) { if (options[i].length == 1) return options[i][0]; return options[i][1]; } public String toString () { for (int i = 0; i < options.length; i++) if (getValue(i).equals(value)) return options[i][0].toString(); return ""; } public Object getObject () { return value; } }; }
[ "static", "public", "Value", "optionValue", "(", "String", "name", ",", "final", "String", "currentValue", ",", "final", "String", "[", "]", "[", "]", "options", ",", "final", "String", "description", ")", "{", "return", "new", "DefaultValue", "(", "name", ",", "currentValue", ".", "toString", "(", ")", ")", "{", "public", "void", "showDialog", "(", ")", "{", "int", "selectedIndex", "=", "-", "1", ";", "DefaultComboBoxModel", "model", "=", "new", "DefaultComboBoxModel", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "options", ".", "length", ";", "i", "++", ")", "{", "model", ".", "addElement", "(", "options", "[", "i", "]", "[", "0", "]", ")", ";", "if", "(", "getValue", "(", "i", ")", ".", "equals", "(", "currentValue", ")", ")", "selectedIndex", "=", "i", ";", "}", "JComboBox", "comboBox", "=", "new", "JComboBox", "(", "model", ")", ";", "comboBox", ".", "setSelectedIndex", "(", "selectedIndex", ")", ";", "if", "(", "showValueDialog", "(", "comboBox", ",", "description", ")", ")", "value", "=", "getValue", "(", "comboBox", ".", "getSelectedIndex", "(", ")", ")", ";", "}", "private", "String", "getValue", "(", "int", "i", ")", "{", "if", "(", "options", "[", "i", "]", ".", "length", "==", "1", ")", "return", "options", "[", "i", "]", "[", "0", "]", ";", "return", "options", "[", "i", "]", "[", "1", "]", ";", "}", "public", "String", "toString", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "options", ".", "length", ";", "i", "++", ")", "if", "(", "getValue", "(", "i", ")", ".", "equals", "(", "value", ")", ")", "return", "options", "[", "i", "]", "[", "0", "]", ".", "toString", "(", ")", ";", "return", "\"\"", ";", "}", "public", "Object", "getObject", "(", ")", "{", "return", "value", ";", "}", "}", ";", "}" ]
Prompts the user for a value that represents a fixed number of options. All options are strings. @param options The first array has an entry for each option. Each entry is either a String[1] that is both the display value and actual value, or a String[2] whose first element is the display value and second element is the actual value. @param name The name of the value being prompted for @param currentValue The current value to show as default @param description The description of the value @return The value selected by the user
[ "Prompts", "the", "user", "for", "a", "value", "that", "represents", "a", "fixed", "number", "of", "options", ".", "All", "options", "are", "strings", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java#L157-L186
1,453
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java
EffectUtil.fromString
static public Color fromString (String rgb) { if (rgb == null || rgb.length() != 6) return Color.white; return new Color(Integer.parseInt(rgb.substring(0, 2), 16), Integer.parseInt(rgb.substring(2, 4), 16), Integer.parseInt(rgb .substring(4, 6), 16)); }
java
static public Color fromString (String rgb) { if (rgb == null || rgb.length() != 6) return Color.white; return new Color(Integer.parseInt(rgb.substring(0, 2), 16), Integer.parseInt(rgb.substring(2, 4), 16), Integer.parseInt(rgb .substring(4, 6), 16)); }
[ "static", "public", "Color", "fromString", "(", "String", "rgb", ")", "{", "if", "(", "rgb", "==", "null", "||", "rgb", ".", "length", "(", ")", "!=", "6", ")", "return", "Color", ".", "white", ";", "return", "new", "Color", "(", "Integer", ".", "parseInt", "(", "rgb", ".", "substring", "(", "0", ",", "2", ")", ",", "16", ")", ",", "Integer", ".", "parseInt", "(", "rgb", ".", "substring", "(", "2", ",", "4", ")", ",", "16", ")", ",", "Integer", ".", "parseInt", "(", "rgb", ".", "substring", "(", "4", ",", "6", ")", ",", "16", ")", ")", ";", "}" ]
Converts a string to a color. @param rgb The string encoding the colour @return The colour represented by the given encoded string
[ "Converts", "a", "string", "to", "a", "color", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/font/effects/EffectUtil.java#L211-L215
1,454
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.addKeyListenerImpl
private void addKeyListenerImpl(KeyListener listener) { if (keyListeners.contains(listener)) { return; } keyListeners.add(listener); allListeners.add(listener); }
java
private void addKeyListenerImpl(KeyListener listener) { if (keyListeners.contains(listener)) { return; } keyListeners.add(listener); allListeners.add(listener); }
[ "private", "void", "addKeyListenerImpl", "(", "KeyListener", "listener", ")", "{", "if", "(", "keyListeners", ".", "contains", "(", "listener", ")", ")", "{", "return", ";", "}", "keyListeners", ".", "add", "(", "listener", ")", ";", "allListeners", ".", "add", "(", "listener", ")", ";", "}" ]
Add a key listener to be notified of key input events @param listener The listener to be notified
[ "Add", "a", "key", "listener", "to", "be", "notified", "of", "key", "input", "events" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L497-L503
1,455
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.addMouseListenerImpl
private void addMouseListenerImpl(MouseListener listener) { if (mouseListeners.contains(listener)) { return; } mouseListeners.add(listener); allListeners.add(listener); }
java
private void addMouseListenerImpl(MouseListener listener) { if (mouseListeners.contains(listener)) { return; } mouseListeners.add(listener); allListeners.add(listener); }
[ "private", "void", "addMouseListenerImpl", "(", "MouseListener", "listener", ")", "{", "if", "(", "mouseListeners", ".", "contains", "(", "listener", ")", ")", "{", "return", ";", "}", "mouseListeners", ".", "add", "(", "listener", ")", ";", "allListeners", ".", "add", "(", "listener", ")", ";", "}" ]
Add a mouse listener to be notified of mouse input events @param listener The listener to be notified
[ "Add", "a", "mouse", "listener", "to", "be", "notified", "of", "mouse", "input", "events" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L519-L525
1,456
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.addControllerListener
public void addControllerListener(ControllerListener listener) { if (controllerListeners.contains(listener)) { return; } controllerListeners.add(listener); allListeners.add(listener); }
java
public void addControllerListener(ControllerListener listener) { if (controllerListeners.contains(listener)) { return; } controllerListeners.add(listener); allListeners.add(listener); }
[ "public", "void", "addControllerListener", "(", "ControllerListener", "listener", ")", "{", "if", "(", "controllerListeners", ".", "contains", "(", "listener", ")", ")", "{", "return", ";", "}", "controllerListeners", ".", "add", "(", "listener", ")", ";", "allListeners", ".", "add", "(", "listener", ")", ";", "}" ]
Add a controller listener to be notified of controller input events @param listener The listener to be notified
[ "Add", "a", "controller", "listener", "to", "be", "notified", "of", "controller", "input", "events" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L532-L538
1,457
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.addPrimaryListener
public void addPrimaryListener(InputListener listener) { removeListener(listener); keyListeners.add(0, listener); mouseListeners.add(0, listener); controllerListeners.add(0, listener); allListeners.add(listener); }
java
public void addPrimaryListener(InputListener listener) { removeListener(listener); keyListeners.add(0, listener); mouseListeners.add(0, listener); controllerListeners.add(0, listener); allListeners.add(listener); }
[ "public", "void", "addPrimaryListener", "(", "InputListener", "listener", ")", "{", "removeListener", "(", "listener", ")", ";", "keyListeners", ".", "add", "(", "0", ",", "listener", ")", ";", "mouseListeners", ".", "add", "(", "0", ",", "listener", ")", ";", "controllerListeners", ".", "add", "(", "0", ",", "listener", ")", ";", "allListeners", ".", "add", "(", "listener", ")", ";", "}" ]
Add a listener to be notified of input events. This listener will get events before others that are currently registered @param listener The listener to be notified
[ "Add", "a", "listener", "to", "be", "notified", "of", "input", "events", ".", "This", "listener", "will", "get", "events", "before", "others", "that", "are", "currently", "registered" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L579-L587
1,458
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.removeKeyListener
public void removeKeyListener(KeyListener listener) { keyListeners.remove(listener); keyListenersToAdd.remove(listener); if (!mouseListeners.contains(listener) && !controllerListeners.contains(listener)) { allListeners.remove(listener); } }
java
public void removeKeyListener(KeyListener listener) { keyListeners.remove(listener); keyListenersToAdd.remove(listener); if (!mouseListeners.contains(listener) && !controllerListeners.contains(listener)) { allListeners.remove(listener); } }
[ "public", "void", "removeKeyListener", "(", "KeyListener", "listener", ")", "{", "keyListeners", ".", "remove", "(", "listener", ")", ";", "keyListenersToAdd", ".", "remove", "(", "listener", ")", ";", "if", "(", "!", "mouseListeners", ".", "contains", "(", "listener", ")", "&&", "!", "controllerListeners", ".", "contains", "(", "listener", ")", ")", "{", "allListeners", ".", "remove", "(", "listener", ")", ";", "}", "}" ]
Remove a key listener that will no longer be notified @param listener The listen to be removed
[ "Remove", "a", "key", "listener", "that", "will", "no", "longer", "be", "notified" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L605-L612
1,459
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.removeControllerListener
public void removeControllerListener(ControllerListener listener) { controllerListeners.remove(listener); if (!mouseListeners.contains(listener) && !keyListeners.contains(listener)) { allListeners.remove(listener); } }
java
public void removeControllerListener(ControllerListener listener) { controllerListeners.remove(listener); if (!mouseListeners.contains(listener) && !keyListeners.contains(listener)) { allListeners.remove(listener); } }
[ "public", "void", "removeControllerListener", "(", "ControllerListener", "listener", ")", "{", "controllerListeners", ".", "remove", "(", "listener", ")", ";", "if", "(", "!", "mouseListeners", ".", "contains", "(", "listener", ")", "&&", "!", "keyListeners", ".", "contains", "(", "listener", ")", ")", "{", "allListeners", ".", "remove", "(", "listener", ")", ";", "}", "}" ]
Remove a controller listener that will no longer be notified @param listener The listen to be removed
[ "Remove", "a", "controller", "listener", "that", "will", "no", "longer", "be", "notified" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L619-L625
1,460
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.removeMouseListener
public void removeMouseListener(MouseListener listener) { mouseListeners.remove(listener); mouseListenersToAdd.remove(listener); if (!controllerListeners.contains(listener) && !keyListeners.contains(listener)) { allListeners.remove(listener); } }
java
public void removeMouseListener(MouseListener listener) { mouseListeners.remove(listener); mouseListenersToAdd.remove(listener); if (!controllerListeners.contains(listener) && !keyListeners.contains(listener)) { allListeners.remove(listener); } }
[ "public", "void", "removeMouseListener", "(", "MouseListener", "listener", ")", "{", "mouseListeners", ".", "remove", "(", "listener", ")", ";", "mouseListenersToAdd", ".", "remove", "(", "listener", ")", ";", "if", "(", "!", "controllerListeners", ".", "contains", "(", "listener", ")", "&&", "!", "keyListeners", ".", "contains", "(", "listener", ")", ")", "{", "allListeners", ".", "remove", "(", "listener", ")", ";", "}", "}" ]
Remove a mouse listener that will no longer be notified @param listener The listen to be removed
[ "Remove", "a", "mouse", "listener", "that", "will", "no", "longer", "be", "notified" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L632-L639
1,461
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.isControlPressed
public boolean isControlPressed(int button, int controller) { if (controllerPressed[controller][button]) { controllerPressed[controller][button] = false; return true; } return false; }
java
public boolean isControlPressed(int button, int controller) { if (controllerPressed[controller][button]) { controllerPressed[controller][button] = false; return true; } return false; }
[ "public", "boolean", "isControlPressed", "(", "int", "button", ",", "int", "controller", ")", "{", "if", "(", "controllerPressed", "[", "controller", "]", "[", "button", "]", ")", "{", "controllerPressed", "[", "controller", "]", "[", "button", "]", "=", "false", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if a controller button has been pressed since last time @param controller The index of the controller to check @param button The button to check for (note that this includes directional controls first) @return True if the button has been pressed since last time
[ "Check", "if", "a", "controller", "button", "has", "been", "pressed", "since", "last", "time" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L712-L719
1,462
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.clearControlPressedRecord
public void clearControlPressedRecord() { for (int i=0;i<controllers.size();i++) { Arrays.fill(controllerPressed[i], false); } }
java
public void clearControlPressedRecord() { for (int i=0;i<controllers.size();i++) { Arrays.fill(controllerPressed[i], false); } }
[ "public", "void", "clearControlPressedRecord", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "controllers", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Arrays", ".", "fill", "(", "controllerPressed", "[", "i", "]", ",", "false", ")", ";", "}", "}" ]
Clear the state for isControlPressed method. This will reset all controls to not pressed
[ "Clear", "the", "state", "for", "isControlPressed", "method", ".", "This", "will", "reset", "all", "controls", "to", "not", "pressed" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L725-L729
1,463
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.getAxisName
public String getAxisName(int controller, int axis) { return ((Controller) controllers.get(controller)).getAxisName(axis); }
java
public String getAxisName(int controller, int axis) { return ((Controller) controllers.get(controller)).getAxisName(axis); }
[ "public", "String", "getAxisName", "(", "int", "controller", ",", "int", "axis", ")", "{", "return", "(", "(", "Controller", ")", "controllers", ".", "get", "(", "controller", ")", ")", ".", "getAxisName", "(", "axis", ")", ";", "}" ]
Get the name of the axis with the given index @param controller The index of the controller to check @param axis The index of the axis to read @return The name of the specified axis
[ "Get", "the", "name", "of", "the", "axis", "with", "the", "given", "index" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L863-L865
1,464
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.isControllerLeft
public boolean isControllerLeft(int controller) { if (controller >= getControllerCount()) { return false; } if (controller == ANY_CONTROLLER) { for (int i=0;i<controllers.size();i++) { if (isControllerLeft(i)) { return true; } } return false; } return ((Controller) controllers.get(controller)).getXAxisValue() < -0.5f || ((Controller) controllers.get(controller)).getPovX() < -0.5f; }
java
public boolean isControllerLeft(int controller) { if (controller >= getControllerCount()) { return false; } if (controller == ANY_CONTROLLER) { for (int i=0;i<controllers.size();i++) { if (isControllerLeft(i)) { return true; } } return false; } return ((Controller) controllers.get(controller)).getXAxisValue() < -0.5f || ((Controller) controllers.get(controller)).getPovX() < -0.5f; }
[ "public", "boolean", "isControllerLeft", "(", "int", "controller", ")", "{", "if", "(", "controller", ">=", "getControllerCount", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "controller", "==", "ANY_CONTROLLER", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "controllers", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "isControllerLeft", "(", "i", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "return", "(", "(", "Controller", ")", "controllers", ".", "get", "(", "controller", ")", ")", ".", "getXAxisValue", "(", ")", "<", "-", "0.5f", "||", "(", "(", "Controller", ")", "controllers", ".", "get", "(", "controller", ")", ")", ".", "getPovX", "(", ")", "<", "-", "0.5f", ";", "}" ]
Check if the controller has the left direction pressed @param controller The index of the controller to check @return True if the controller is pressed to the left
[ "Check", "if", "the", "controller", "has", "the", "left", "direction", "pressed" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L873-L890
1,465
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.isControllerUp
public boolean isControllerUp(int controller) { if (controller >= getControllerCount()) { return false; } if (controller == ANY_CONTROLLER) { for (int i=0;i<controllers.size();i++) { if (isControllerUp(i)) { return true; } } return false; } return ((Controller) controllers.get(controller)).getYAxisValue() < -0.5f || ((Controller) controllers.get(controller)).getPovY() < -0.5f; }
java
public boolean isControllerUp(int controller) { if (controller >= getControllerCount()) { return false; } if (controller == ANY_CONTROLLER) { for (int i=0;i<controllers.size();i++) { if (isControllerUp(i)) { return true; } } return false; } return ((Controller) controllers.get(controller)).getYAxisValue() < -0.5f || ((Controller) controllers.get(controller)).getPovY() < -0.5f; }
[ "public", "boolean", "isControllerUp", "(", "int", "controller", ")", "{", "if", "(", "controller", ">=", "getControllerCount", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "controller", "==", "ANY_CONTROLLER", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "controllers", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "isControllerUp", "(", "i", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "return", "(", "(", "Controller", ")", "controllers", ".", "get", "(", "controller", ")", ")", ".", "getYAxisValue", "(", ")", "<", "-", "0.5f", "||", "(", "(", "Controller", ")", "controllers", ".", "get", "(", "controller", ")", ")", ".", "getPovY", "(", ")", "<", "-", "0.5f", ";", "}" ]
Check if the controller has the up direction pressed @param controller The index of the controller to check @return True if the controller is pressed to the up
[ "Check", "if", "the", "controller", "has", "the", "up", "direction", "pressed" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L923-L939
1,466
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.isButtonPressed
public boolean isButtonPressed(int index, int controller) { if (controller >= getControllerCount()) { return false; } if (controller == ANY_CONTROLLER) { for (int i=0;i<controllers.size();i++) { if (isButtonPressed(index, i)) { return true; } } return false; } return ((Controller) controllers.get(controller)).isButtonPressed(index); }
java
public boolean isButtonPressed(int index, int controller) { if (controller >= getControllerCount()) { return false; } if (controller == ANY_CONTROLLER) { for (int i=0;i<controllers.size();i++) { if (isButtonPressed(index, i)) { return true; } } return false; } return ((Controller) controllers.get(controller)).isButtonPressed(index); }
[ "public", "boolean", "isButtonPressed", "(", "int", "index", ",", "int", "controller", ")", "{", "if", "(", "controller", ">=", "getControllerCount", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "controller", "==", "ANY_CONTROLLER", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "controllers", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "isButtonPressed", "(", "index", ",", "i", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "return", "(", "(", "Controller", ")", "controllers", ".", "get", "(", "controller", ")", ")", ".", "isButtonPressed", "(", "index", ")", ";", "}" ]
Check if controller button is pressed @param controller The index of the controller to check @param index The index of the button to check @return True if the button is pressed
[ "Check", "if", "controller", "button", "is", "pressed" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L974-L990
1,467
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.initControllers
public void initControllers() throws SlickException { if (controllersInited) { return; } controllersInited = true; try { Controllers.create(); int count = Controllers.getControllerCount(); for (int i = 0; i < count; i++) { Controller controller = Controllers.getController(i); if ((controller.getButtonCount() >= 3) && (controller.getButtonCount() < MAX_BUTTONS)) { controllers.add(controller); } } Log.info("Found "+controllers.size()+" controllers"); for (int i=0;i<controllers.size();i++) { Log.info(i+" : "+((Controller) controllers.get(i)).getName()); } } catch (LWJGLException e) { if (e.getCause() instanceof ClassNotFoundException) { throw new SlickException("Unable to create controller - no jinput found - add jinput.jar to your classpath"); } throw new SlickException("Unable to create controllers"); } catch (NoClassDefFoundError e) { // forget it, no jinput availble } }
java
public void initControllers() throws SlickException { if (controllersInited) { return; } controllersInited = true; try { Controllers.create(); int count = Controllers.getControllerCount(); for (int i = 0; i < count; i++) { Controller controller = Controllers.getController(i); if ((controller.getButtonCount() >= 3) && (controller.getButtonCount() < MAX_BUTTONS)) { controllers.add(controller); } } Log.info("Found "+controllers.size()+" controllers"); for (int i=0;i<controllers.size();i++) { Log.info(i+" : "+((Controller) controllers.get(i)).getName()); } } catch (LWJGLException e) { if (e.getCause() instanceof ClassNotFoundException) { throw new SlickException("Unable to create controller - no jinput found - add jinput.jar to your classpath"); } throw new SlickException("Unable to create controllers"); } catch (NoClassDefFoundError e) { // forget it, no jinput availble } }
[ "public", "void", "initControllers", "(", ")", "throws", "SlickException", "{", "if", "(", "controllersInited", ")", "{", "return", ";", "}", "controllersInited", "=", "true", ";", "try", "{", "Controllers", ".", "create", "(", ")", ";", "int", "count", "=", "Controllers", ".", "getControllerCount", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "Controller", "controller", "=", "Controllers", ".", "getController", "(", "i", ")", ";", "if", "(", "(", "controller", ".", "getButtonCount", "(", ")", ">=", "3", ")", "&&", "(", "controller", ".", "getButtonCount", "(", ")", "<", "MAX_BUTTONS", ")", ")", "{", "controllers", ".", "add", "(", "controller", ")", ";", "}", "}", "Log", ".", "info", "(", "\"Found \"", "+", "controllers", ".", "size", "(", ")", "+", "\" controllers\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "controllers", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Log", ".", "info", "(", "i", "+", "\" : \"", "+", "(", "(", "Controller", ")", "controllers", ".", "get", "(", "i", ")", ")", ".", "getName", "(", ")", ")", ";", "}", "}", "catch", "(", "LWJGLException", "e", ")", "{", "if", "(", "e", ".", "getCause", "(", ")", "instanceof", "ClassNotFoundException", ")", "{", "throw", "new", "SlickException", "(", "\"Unable to create controller - no jinput found - add jinput.jar to your classpath\"", ")", ";", "}", "throw", "new", "SlickException", "(", "\"Unable to create controllers\"", ")", ";", "}", "catch", "(", "NoClassDefFoundError", "e", ")", "{", "// forget it, no jinput availble\r", "}", "}" ]
Initialise the controllers system @throws SlickException Indicates a failure to use the hardware
[ "Initialise", "the", "controllers", "system" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L1027-L1057
1,468
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.considerDoubleClick
public void considerDoubleClick(int button, int x, int y) { if (doubleClickTimeout == 0) { clickX = x; clickY = y; clickButton = button; doubleClickTimeout = System.currentTimeMillis() + doubleClickDelay; fireMouseClicked(button, x, y, 1); } else { if (clickButton == button) { if ((System.currentTimeMillis() < doubleClickTimeout)) { fireMouseClicked(button, x, y, 2); doubleClickTimeout = 0; } } } }
java
public void considerDoubleClick(int button, int x, int y) { if (doubleClickTimeout == 0) { clickX = x; clickY = y; clickButton = button; doubleClickTimeout = System.currentTimeMillis() + doubleClickDelay; fireMouseClicked(button, x, y, 1); } else { if (clickButton == button) { if ((System.currentTimeMillis() < doubleClickTimeout)) { fireMouseClicked(button, x, y, 2); doubleClickTimeout = 0; } } } }
[ "public", "void", "considerDoubleClick", "(", "int", "button", ",", "int", "x", ",", "int", "y", ")", "{", "if", "(", "doubleClickTimeout", "==", "0", ")", "{", "clickX", "=", "x", ";", "clickY", "=", "y", ";", "clickButton", "=", "button", ";", "doubleClickTimeout", "=", "System", ".", "currentTimeMillis", "(", ")", "+", "doubleClickDelay", ";", "fireMouseClicked", "(", "button", ",", "x", ",", "y", ",", "1", ")", ";", "}", "else", "{", "if", "(", "clickButton", "==", "button", ")", "{", "if", "(", "(", "System", ".", "currentTimeMillis", "(", ")", "<", "doubleClickTimeout", ")", ")", "{", "fireMouseClicked", "(", "button", ",", "x", ",", "y", ",", "2", ")", ";", "doubleClickTimeout", "=", "0", ";", "}", "}", "}", "}" ]
Notification that the mouse has been pressed and hence we should consider what we're doing with double clicking @param button The button pressed/released @param x The location of the mouse @param y The location of the mouse
[ "Notification", "that", "the", "mouse", "has", "been", "pressed", "and", "hence", "we", "should", "consider", "what", "we", "re", "doing", "with", "double", "clicking" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L1107-L1122
1,469
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.fireControlPress
private void fireControlPress(int index, int controllerIndex) { consumed = false; for (int i=0;i<controllerListeners.size();i++) { ControllerListener listener = (ControllerListener) controllerListeners.get(i); if (listener.isAcceptingInput()) { switch (index) { case LEFT: listener.controllerLeftPressed(controllerIndex); break; case RIGHT: listener.controllerRightPressed(controllerIndex); break; case UP: listener.controllerUpPressed(controllerIndex); break; case DOWN: listener.controllerDownPressed(controllerIndex); break; default: // assume button pressed listener.controllerButtonPressed(controllerIndex, (index - BUTTON1) + 1); break; } if (consumed) { break; } } } }
java
private void fireControlPress(int index, int controllerIndex) { consumed = false; for (int i=0;i<controllerListeners.size();i++) { ControllerListener listener = (ControllerListener) controllerListeners.get(i); if (listener.isAcceptingInput()) { switch (index) { case LEFT: listener.controllerLeftPressed(controllerIndex); break; case RIGHT: listener.controllerRightPressed(controllerIndex); break; case UP: listener.controllerUpPressed(controllerIndex); break; case DOWN: listener.controllerDownPressed(controllerIndex); break; default: // assume button pressed listener.controllerButtonPressed(controllerIndex, (index - BUTTON1) + 1); break; } if (consumed) { break; } } } }
[ "private", "void", "fireControlPress", "(", "int", "index", ",", "int", "controllerIndex", ")", "{", "consumed", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "controllerListeners", ".", "size", "(", ")", ";", "i", "++", ")", "{", "ControllerListener", "listener", "=", "(", "ControllerListener", ")", "controllerListeners", ".", "get", "(", "i", ")", ";", "if", "(", "listener", ".", "isAcceptingInput", "(", ")", ")", "{", "switch", "(", "index", ")", "{", "case", "LEFT", ":", "listener", ".", "controllerLeftPressed", "(", "controllerIndex", ")", ";", "break", ";", "case", "RIGHT", ":", "listener", ".", "controllerRightPressed", "(", "controllerIndex", ")", ";", "break", ";", "case", "UP", ":", "listener", ".", "controllerUpPressed", "(", "controllerIndex", ")", ";", "break", ";", "case", "DOWN", ":", "listener", ".", "controllerDownPressed", "(", "controllerIndex", ")", ";", "break", ";", "default", ":", "// assume button pressed\r", "listener", ".", "controllerButtonPressed", "(", "controllerIndex", ",", "(", "index", "-", "BUTTON1", ")", "+", "1", ")", ";", "break", ";", "}", "if", "(", "consumed", ")", "{", "break", ";", "}", "}", "}", "}" ]
Fire an event indicating that a control has been pressed @param index The index of the control pressed @param controllerIndex The index of the controller on which the control was pressed
[ "Fire", "an", "event", "indicating", "that", "a", "control", "has", "been", "pressed" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L1403-L1431
1,470
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.fireControlRelease
private void fireControlRelease(int index, int controllerIndex) { consumed = false; for (int i=0;i<controllerListeners.size();i++) { ControllerListener listener = (ControllerListener) controllerListeners.get(i); if (listener.isAcceptingInput()) { switch (index) { case LEFT: listener.controllerLeftReleased(controllerIndex); break; case RIGHT: listener.controllerRightReleased(controllerIndex); break; case UP: listener.controllerUpReleased(controllerIndex); break; case DOWN: listener.controllerDownReleased(controllerIndex); break; default: // assume button release listener.controllerButtonReleased(controllerIndex, (index - BUTTON1) + 1); break; } if (consumed) { break; } } } }
java
private void fireControlRelease(int index, int controllerIndex) { consumed = false; for (int i=0;i<controllerListeners.size();i++) { ControllerListener listener = (ControllerListener) controllerListeners.get(i); if (listener.isAcceptingInput()) { switch (index) { case LEFT: listener.controllerLeftReleased(controllerIndex); break; case RIGHT: listener.controllerRightReleased(controllerIndex); break; case UP: listener.controllerUpReleased(controllerIndex); break; case DOWN: listener.controllerDownReleased(controllerIndex); break; default: // assume button release listener.controllerButtonReleased(controllerIndex, (index - BUTTON1) + 1); break; } if (consumed) { break; } } } }
[ "private", "void", "fireControlRelease", "(", "int", "index", ",", "int", "controllerIndex", ")", "{", "consumed", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "controllerListeners", ".", "size", "(", ")", ";", "i", "++", ")", "{", "ControllerListener", "listener", "=", "(", "ControllerListener", ")", "controllerListeners", ".", "get", "(", "i", ")", ";", "if", "(", "listener", ".", "isAcceptingInput", "(", ")", ")", "{", "switch", "(", "index", ")", "{", "case", "LEFT", ":", "listener", ".", "controllerLeftReleased", "(", "controllerIndex", ")", ";", "break", ";", "case", "RIGHT", ":", "listener", ".", "controllerRightReleased", "(", "controllerIndex", ")", ";", "break", ";", "case", "UP", ":", "listener", ".", "controllerUpReleased", "(", "controllerIndex", ")", ";", "break", ";", "case", "DOWN", ":", "listener", ".", "controllerDownReleased", "(", "controllerIndex", ")", ";", "break", ";", "default", ":", "// assume button release\r", "listener", ".", "controllerButtonReleased", "(", "controllerIndex", ",", "(", "index", "-", "BUTTON1", ")", "+", "1", ")", ";", "break", ";", "}", "if", "(", "consumed", ")", "{", "break", ";", "}", "}", "}", "}" ]
Fire an event indicating that a control has been released @param index The index of the control released @param controllerIndex The index of the controller on which the control was released
[ "Fire", "an", "event", "indicating", "that", "a", "control", "has", "been", "released" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L1439-L1467
1,471
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.isControlDwn
private boolean isControlDwn(int index, int controllerIndex) { switch (index) { case LEFT: return isControllerLeft(controllerIndex); case RIGHT: return isControllerRight(controllerIndex); case UP: return isControllerUp(controllerIndex); case DOWN: return isControllerDown(controllerIndex); } if (index >= BUTTON1) { return isButtonPressed((index-BUTTON1), controllerIndex); } throw new RuntimeException("Unknown control index"); }
java
private boolean isControlDwn(int index, int controllerIndex) { switch (index) { case LEFT: return isControllerLeft(controllerIndex); case RIGHT: return isControllerRight(controllerIndex); case UP: return isControllerUp(controllerIndex); case DOWN: return isControllerDown(controllerIndex); } if (index >= BUTTON1) { return isButtonPressed((index-BUTTON1), controllerIndex); } throw new RuntimeException("Unknown control index"); }
[ "private", "boolean", "isControlDwn", "(", "int", "index", ",", "int", "controllerIndex", ")", "{", "switch", "(", "index", ")", "{", "case", "LEFT", ":", "return", "isControllerLeft", "(", "controllerIndex", ")", ";", "case", "RIGHT", ":", "return", "isControllerRight", "(", "controllerIndex", ")", ";", "case", "UP", ":", "return", "isControllerUp", "(", "controllerIndex", ")", ";", "case", "DOWN", ":", "return", "isControllerDown", "(", "controllerIndex", ")", ";", "}", "if", "(", "index", ">=", "BUTTON1", ")", "{", "return", "isButtonPressed", "(", "(", "index", "-", "BUTTON1", ")", ",", "controllerIndex", ")", ";", "}", "throw", "new", "RuntimeException", "(", "\"Unknown control index\"", ")", ";", "}" ]
Check if a particular control is currently pressed @param index The index of the control @param controllerIndex The index of the control to which the control belongs @return True if the control is pressed
[ "Check", "if", "a", "particular", "control", "is", "currently", "pressed" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L1476-L1493
1,472
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Input.java
Input.fireMouseClicked
private void fireMouseClicked(int button, int x, int y, int clickCount) { consumed = false; for (int i=0;i<mouseListeners.size();i++) { MouseListener listener = (MouseListener) mouseListeners.get(i); if (listener.isAcceptingInput()) { listener.mouseClicked(button, x, y, clickCount); if (consumed) { break; } } } }
java
private void fireMouseClicked(int button, int x, int y, int clickCount) { consumed = false; for (int i=0;i<mouseListeners.size();i++) { MouseListener listener = (MouseListener) mouseListeners.get(i); if (listener.isAcceptingInput()) { listener.mouseClicked(button, x, y, clickCount); if (consumed) { break; } } } }
[ "private", "void", "fireMouseClicked", "(", "int", "button", ",", "int", "x", ",", "int", "y", ",", "int", "clickCount", ")", "{", "consumed", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mouseListeners", ".", "size", "(", ")", ";", "i", "++", ")", "{", "MouseListener", "listener", "=", "(", "MouseListener", ")", "mouseListeners", ".", "get", "(", "i", ")", ";", "if", "(", "listener", ".", "isAcceptingInput", "(", ")", ")", "{", "listener", ".", "mouseClicked", "(", "button", ",", "x", ",", "y", ",", "clickCount", ")", ";", "if", "(", "consumed", ")", "{", "break", ";", "}", "}", "}", "}" ]
Notify listeners that the mouse button has been clicked @param button The button that has been clicked @param x The location at which the button was clicked @param y The location at which the button was clicked @param clickCount The number of times the button was clicked (single or double click)
[ "Notify", "listeners", "that", "the", "mouse", "button", "has", "been", "clicked" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Input.java#L1523-L1534
1,473
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/TextureImpl.java
TextureImpl.createIntBuffer
protected IntBuffer createIntBuffer(int size) { ByteBuffer temp = ByteBuffer.allocateDirect(4 * size); temp.order(ByteOrder.nativeOrder()); return temp.asIntBuffer(); }
java
protected IntBuffer createIntBuffer(int size) { ByteBuffer temp = ByteBuffer.allocateDirect(4 * size); temp.order(ByteOrder.nativeOrder()); return temp.asIntBuffer(); }
[ "protected", "IntBuffer", "createIntBuffer", "(", "int", "size", ")", "{", "ByteBuffer", "temp", "=", "ByteBuffer", ".", "allocateDirect", "(", "4", "*", "size", ")", ";", "temp", ".", "order", "(", "ByteOrder", ".", "nativeOrder", "(", ")", ")", ";", "return", "temp", ".", "asIntBuffer", "(", ")", ";", "}" ]
Creates an integer buffer to hold specified ints - strictly a utility method @param size how many int to contain @return created IntBuffer
[ "Creates", "an", "integer", "buffer", "to", "hold", "specified", "ints", "-", "strictly", "a", "utility", "method" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/TextureImpl.java#L293-L298
1,474
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/TextureImpl.java
TextureImpl.setTextureData
public void setTextureData(int srcPixelFormat, int componentCount, int minFilter, int magFilter, ByteBuffer textureBuffer) { reloadData = new ReloadData(); reloadData.srcPixelFormat = srcPixelFormat; reloadData.componentCount = componentCount; reloadData.minFilter = minFilter; reloadData.magFilter = magFilter; reloadData.textureBuffer = textureBuffer; }
java
public void setTextureData(int srcPixelFormat, int componentCount, int minFilter, int magFilter, ByteBuffer textureBuffer) { reloadData = new ReloadData(); reloadData.srcPixelFormat = srcPixelFormat; reloadData.componentCount = componentCount; reloadData.minFilter = minFilter; reloadData.magFilter = magFilter; reloadData.textureBuffer = textureBuffer; }
[ "public", "void", "setTextureData", "(", "int", "srcPixelFormat", ",", "int", "componentCount", ",", "int", "minFilter", ",", "int", "magFilter", ",", "ByteBuffer", "textureBuffer", ")", "{", "reloadData", "=", "new", "ReloadData", "(", ")", ";", "reloadData", ".", "srcPixelFormat", "=", "srcPixelFormat", ";", "reloadData", ".", "componentCount", "=", "componentCount", ";", "reloadData", ".", "minFilter", "=", "minFilter", ";", "reloadData", ".", "magFilter", "=", "magFilter", ";", "reloadData", ".", "textureBuffer", "=", "textureBuffer", ";", "}" ]
Set the texture data that this texture can be reloaded from @param srcPixelFormat The pixel format @param componentCount The component count @param minFilter The OpenGL minification filter @param magFilter The OpenGL magnification filter @param textureBuffer The texture buffer containing the data for the texture
[ "Set", "the", "texture", "data", "that", "this", "texture", "can", "be", "reloaded", "from" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/TextureImpl.java#L333-L341
1,475
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/imageout/ImageOut.java
ImageOut.write
public static void write(Image image, String format, String dest, boolean writeAlpha) throws SlickException { try { write(image, format, new FileOutputStream(dest), writeAlpha); } catch (IOException e) { throw new SlickException("Unable to write to the destination: "+dest, e); } }
java
public static void write(Image image, String format, String dest, boolean writeAlpha) throws SlickException { try { write(image, format, new FileOutputStream(dest), writeAlpha); } catch (IOException e) { throw new SlickException("Unable to write to the destination: "+dest, e); } }
[ "public", "static", "void", "write", "(", "Image", "image", ",", "String", "format", ",", "String", "dest", ",", "boolean", "writeAlpha", ")", "throws", "SlickException", "{", "try", "{", "write", "(", "image", ",", "format", ",", "new", "FileOutputStream", "(", "dest", ")", ",", "writeAlpha", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "SlickException", "(", "\"Unable to write to the destination: \"", "+", "dest", ",", "e", ")", ";", "}", "}" ]
Write an image out to a file on the local file system. @param image The image to be written out @param format The format to write the image out in @param dest The destination path to write to @param writeAlpha True if we should write the alpha channel out (some formats don't support this, like JPG) @throws SlickException Indicates a failure to write the image in the determined format
[ "Write", "an", "image", "out", "to", "a", "file", "on", "the", "local", "file", "system", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/imageout/ImageOut.java#L124-L130
1,476
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Curve.java
Curve.pointAt
public Vector2f pointAt(float t) { float a = 1 - t; float b = t; float f1 = a * a * a; float f2 = 3 * a * a * b; float f3 = 3 * a * b * b; float f4 = b * b * b; float nx = (p1.x * f1) + (c1.x * f2) + (c2.x * f3) + (p2.x * f4); float ny = (p1.y * f1) + (c1.y * f2) + (c2.y * f3) + (p2.y * f4); return new Vector2f(nx,ny); }
java
public Vector2f pointAt(float t) { float a = 1 - t; float b = t; float f1 = a * a * a; float f2 = 3 * a * a * b; float f3 = 3 * a * b * b; float f4 = b * b * b; float nx = (p1.x * f1) + (c1.x * f2) + (c2.x * f3) + (p2.x * f4); float ny = (p1.y * f1) + (c1.y * f2) + (c2.y * f3) + (p2.y * f4); return new Vector2f(nx,ny); }
[ "public", "Vector2f", "pointAt", "(", "float", "t", ")", "{", "float", "a", "=", "1", "-", "t", ";", "float", "b", "=", "t", ";", "float", "f1", "=", "a", "*", "a", "*", "a", ";", "float", "f2", "=", "3", "*", "a", "*", "a", "*", "b", ";", "float", "f3", "=", "3", "*", "a", "*", "b", "*", "b", ";", "float", "f4", "=", "b", "*", "b", "*", "b", ";", "float", "nx", "=", "(", "p1", ".", "x", "*", "f1", ")", "+", "(", "c1", ".", "x", "*", "f2", ")", "+", "(", "c2", ".", "x", "*", "f3", ")", "+", "(", "p2", ".", "x", "*", "f4", ")", ";", "float", "ny", "=", "(", "p1", ".", "y", "*", "f1", ")", "+", "(", "c1", ".", "y", "*", "f2", ")", "+", "(", "c2", ".", "y", "*", "f3", ")", "+", "(", "p2", ".", "y", "*", "f4", ")", ";", "return", "new", "Vector2f", "(", "nx", ",", "ny", ")", ";", "}" ]
Get the point at a particular location on the curve @param t A value between 0 and 1 defining the location of the curve the point is at @return The point on the curve
[ "Get", "the", "point", "at", "a", "particular", "location", "on", "the", "curve" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Curve.java#L59-L72
1,477
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/DataSet.java
DataSet.toAngelCodeText
public void toAngelCodeText(PrintStream out, String imageName) { out.println("info face=\""+fontName+"\" size="+size+" bold=0 italic=0 charset=\""+setName+"\" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1"); out.println("common lineHeight="+lineHeight+" base=26 scaleW="+width+" scaleH="+height+" pages=1 packed=0"); out.println("page id=0 file=\""+imageName+"\""); out.println("chars count="+chars.size()); for (int i=0;i<chars.size();i++) { CharData c = (CharData) chars.get(i); out.println("char id="+c.getID()+" x="+c.getX()+" y="+c.getY()+" width="+c.getWidth()+" height="+c.getHeight()+" xoffset=0 yoffset="+c.getYOffset()+" xadvance="+c.getXAdvance()+" page=0 chnl=0 "); } out.println("kernings count="+kerning.size()); for (int i=0;i<kerning.size();i++) { KerningData k = (KerningData) kerning.get(i); out.println("kerning first="+k.first+" second="+k.second+" amount="+k.offset); } }
java
public void toAngelCodeText(PrintStream out, String imageName) { out.println("info face=\""+fontName+"\" size="+size+" bold=0 italic=0 charset=\""+setName+"\" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1"); out.println("common lineHeight="+lineHeight+" base=26 scaleW="+width+" scaleH="+height+" pages=1 packed=0"); out.println("page id=0 file=\""+imageName+"\""); out.println("chars count="+chars.size()); for (int i=0;i<chars.size();i++) { CharData c = (CharData) chars.get(i); out.println("char id="+c.getID()+" x="+c.getX()+" y="+c.getY()+" width="+c.getWidth()+" height="+c.getHeight()+" xoffset=0 yoffset="+c.getYOffset()+" xadvance="+c.getXAdvance()+" page=0 chnl=0 "); } out.println("kernings count="+kerning.size()); for (int i=0;i<kerning.size();i++) { KerningData k = (KerningData) kerning.get(i); out.println("kerning first="+k.first+" second="+k.second+" amount="+k.offset); } }
[ "public", "void", "toAngelCodeText", "(", "PrintStream", "out", ",", "String", "imageName", ")", "{", "out", ".", "println", "(", "\"info face=\\\"\"", "+", "fontName", "+", "\"\\\" size=\"", "+", "size", "+", "\" bold=0 italic=0 charset=\\\"\"", "+", "setName", "+", "\"\\\" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1\"", ")", ";", "out", ".", "println", "(", "\"common lineHeight=\"", "+", "lineHeight", "+", "\" base=26 scaleW=\"", "+", "width", "+", "\" scaleH=\"", "+", "height", "+", "\" pages=1 packed=0\"", ")", ";", "out", ".", "println", "(", "\"page id=0 file=\\\"\"", "+", "imageName", "+", "\"\\\"\"", ")", ";", "out", ".", "println", "(", "\"chars count=\"", "+", "chars", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "chars", ".", "size", "(", ")", ";", "i", "++", ")", "{", "CharData", "c", "=", "(", "CharData", ")", "chars", ".", "get", "(", "i", ")", ";", "out", ".", "println", "(", "\"char id=\"", "+", "c", ".", "getID", "(", ")", "+", "\" x=\"", "+", "c", ".", "getX", "(", ")", "+", "\" y=\"", "+", "c", ".", "getY", "(", ")", "+", "\" width=\"", "+", "c", ".", "getWidth", "(", ")", "+", "\" height=\"", "+", "c", ".", "getHeight", "(", ")", "+", "\" xoffset=0 yoffset=\"", "+", "c", ".", "getYOffset", "(", ")", "+", "\" xadvance=\"", "+", "c", ".", "getXAdvance", "(", ")", "+", "\" page=0 chnl=0 \"", ")", ";", "}", "out", ".", "println", "(", "\"kernings count=\"", "+", "kerning", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "kerning", ".", "size", "(", ")", ";", "i", "++", ")", "{", "KerningData", "k", "=", "(", "KerningData", ")", "kerning", ".", "get", "(", "i", ")", ";", "out", ".", "println", "(", "\"kerning first=\"", "+", "k", ".", "first", "+", "\" second=\"", "+", "k", ".", "second", "+", "\" amount=\"", "+", "k", ".", "offset", ")", ";", "}", "}" ]
Output this data set as an angel code data file @param imageName The name of the image to reference @param out The output stream to write to
[ "Output", "this", "data", "set", "as", "an", "angel", "code", "data", "file" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/DataSet.java#L93-L108
1,478
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/DataSet.java
DataSet.addCharacter
public void addCharacter(int code, int xadvance, int x, int y, int width, int height,int yoffset) { chars.add(new CharData(code, xadvance, x, y, width, height,size + yoffset)); }
java
public void addCharacter(int code, int xadvance, int x, int y, int width, int height,int yoffset) { chars.add(new CharData(code, xadvance, x, y, width, height,size + yoffset)); }
[ "public", "void", "addCharacter", "(", "int", "code", ",", "int", "xadvance", ",", "int", "x", ",", "int", "y", ",", "int", "width", ",", "int", "height", ",", "int", "yoffset", ")", "{", "chars", ".", "add", "(", "new", "CharData", "(", "code", ",", "xadvance", ",", "x", ",", "y", ",", "width", ",", "height", ",", "size", "+", "yoffset", ")", ")", ";", "}" ]
Add a character to the data set @param code The character code @param xadvance The advance on the x axis after writing this character @param x The x position on the sheet of the character @param y The y position on the sheet of the character @param width The width of the character on the sheet @param height The height of the character on the sheet @param yoffset The offset on the y axis when drawing the character
[ "Add", "a", "character", "to", "the", "data", "set" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/DataSet.java#L214-L216
1,479
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/DataSet.java
DataSet.addKerning
public void addKerning(int first, int second, int offset) { kerning.add(new KerningData(first, second, offset)); }
java
public void addKerning(int first, int second, int offset) { kerning.add(new KerningData(first, second, offset)); }
[ "public", "void", "addKerning", "(", "int", "first", ",", "int", "second", ",", "int", "offset", ")", "{", "kerning", ".", "add", "(", "new", "KerningData", "(", "first", ",", "second", ",", "offset", ")", ")", ";", "}" ]
Add some kerning data @param first The first character @param second The second character @param offset The kerning offset to apply
[ "Add", "some", "kerning", "data" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/DataSet.java#L225-L227
1,480
nguillaumin/slick2d-maven
slick2d-examples/src/main/java/org/newdawn/slick/examples/lights/Light.java
Light.getEffectAt
public float[] getEffectAt(float x, float y, boolean colouredLights) { // first work out what propotion of the strength distance the light // is from the point. This is a value from 0-1 where 1 is the centre of the // light (i.e. full brightness) and 0 is the very edge (or outside) the lights // range float dx = (x - xpos); float dy = (y - ypos); float distance2 = (dx*dx)+(dy*dy); float effect = 1 - (distance2 / (strength*strength)); if (effect < 0) { effect = 0; } // if we doing coloured lights then multiple the colour of the light // by the effect. Otherwise just use the effect for all components to // give white light if (colouredLights) { return new float[] {col.r * effect, col.g * effect, col.b * effect}; } else { return new float[] {effect,effect,effect}; } }
java
public float[] getEffectAt(float x, float y, boolean colouredLights) { // first work out what propotion of the strength distance the light // is from the point. This is a value from 0-1 where 1 is the centre of the // light (i.e. full brightness) and 0 is the very edge (or outside) the lights // range float dx = (x - xpos); float dy = (y - ypos); float distance2 = (dx*dx)+(dy*dy); float effect = 1 - (distance2 / (strength*strength)); if (effect < 0) { effect = 0; } // if we doing coloured lights then multiple the colour of the light // by the effect. Otherwise just use the effect for all components to // give white light if (colouredLights) { return new float[] {col.r * effect, col.g * effect, col.b * effect}; } else { return new float[] {effect,effect,effect}; } }
[ "public", "float", "[", "]", "getEffectAt", "(", "float", "x", ",", "float", "y", ",", "boolean", "colouredLights", ")", "{", "// first work out what propotion of the strength distance the light\r", "// is from the point. This is a value from 0-1 where 1 is the centre of the\r", "// light (i.e. full brightness) and 0 is the very edge (or outside) the lights\r", "// range\r", "float", "dx", "=", "(", "x", "-", "xpos", ")", ";", "float", "dy", "=", "(", "y", "-", "ypos", ")", ";", "float", "distance2", "=", "(", "dx", "*", "dx", ")", "+", "(", "dy", "*", "dy", ")", ";", "float", "effect", "=", "1", "-", "(", "distance2", "/", "(", "strength", "*", "strength", ")", ")", ";", "if", "(", "effect", "<", "0", ")", "{", "effect", "=", "0", ";", "}", "// if we doing coloured lights then multiple the colour of the light \r", "// by the effect. Otherwise just use the effect for all components to\r", "// give white light\r", "if", "(", "colouredLights", ")", "{", "return", "new", "float", "[", "]", "{", "col", ".", "r", "*", "effect", ",", "col", ".", "g", "*", "effect", ",", "col", ".", "b", "*", "effect", "}", ";", "}", "else", "{", "return", "new", "float", "[", "]", "{", "effect", ",", "effect", ",", "effect", "}", ";", "}", "}" ]
Get the effect the light should apply to a given location @param x The x coordinate of the location being considered for lighting @param y The y coordinate of the location being considered for lighting @param colouredLights True if we're supporting coloured lights @return The effect on a given location of the light in terms of colour components (all the same if we don't support coloured lights)
[ "Get", "the", "effect", "the", "light", "should", "apply", "to", "a", "given", "location" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-examples/src/main/java/org/newdawn/slick/examples/lights/Light.java#L58-L80
1,481
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/SpriteSheet.java
SpriteSheet.getSubImage
public Image getSubImage(int x, int y) { init(); if ((x < 0) || (x >= subImages.length)) { throw new RuntimeException("SubImage out of sheet bounds: "+x+","+y); } if ((y < 0) || (y >= subImages[0].length)) { throw new RuntimeException("SubImage out of sheet bounds: "+x+","+y); } return subImages[x][y]; }
java
public Image getSubImage(int x, int y) { init(); if ((x < 0) || (x >= subImages.length)) { throw new RuntimeException("SubImage out of sheet bounds: "+x+","+y); } if ((y < 0) || (y >= subImages[0].length)) { throw new RuntimeException("SubImage out of sheet bounds: "+x+","+y); } return subImages[x][y]; }
[ "public", "Image", "getSubImage", "(", "int", "x", ",", "int", "y", ")", "{", "init", "(", ")", ";", "if", "(", "(", "x", "<", "0", ")", "||", "(", "x", ">=", "subImages", ".", "length", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"SubImage out of sheet bounds: \"", "+", "x", "+", "\",\"", "+", "y", ")", ";", "}", "if", "(", "(", "y", "<", "0", ")", "||", "(", "y", ">=", "subImages", "[", "0", "]", ".", "length", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"SubImage out of sheet bounds: \"", "+", "x", "+", "\",\"", "+", "y", ")", ";", "}", "return", "subImages", "[", "x", "]", "[", "y", "]", ";", "}" ]
Get the sub image cached in this sprite sheet @param x The x position in tiles of the image to get @param y The y position in tiles of the image to get @return The subimage at that location on the sheet
[ "Get", "the", "sub", "image", "cached", "in", "this", "sprite", "sheet" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/SpriteSheet.java#L198-L209
1,482
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/SpriteSheet.java
SpriteSheet.getSprite
public Image getSprite(int x, int y) { target.init(); initImpl(); if ((x < 0) || (x >= subImages.length)) { throw new RuntimeException("SubImage out of sheet bounds: "+x+","+y); } if ((y < 0) || (y >= subImages[0].length)) { throw new RuntimeException("SubImage out of sheet bounds: "+x+","+y); } return target.getSubImage(x*(tw+spacing) + margin, y*(th+spacing) + margin,tw,th); }
java
public Image getSprite(int x, int y) { target.init(); initImpl(); if ((x < 0) || (x >= subImages.length)) { throw new RuntimeException("SubImage out of sheet bounds: "+x+","+y); } if ((y < 0) || (y >= subImages[0].length)) { throw new RuntimeException("SubImage out of sheet bounds: "+x+","+y); } return target.getSubImage(x*(tw+spacing) + margin, y*(th+spacing) + margin,tw,th); }
[ "public", "Image", "getSprite", "(", "int", "x", ",", "int", "y", ")", "{", "target", ".", "init", "(", ")", ";", "initImpl", "(", ")", ";", "if", "(", "(", "x", "<", "0", ")", "||", "(", "x", ">=", "subImages", ".", "length", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"SubImage out of sheet bounds: \"", "+", "x", "+", "\",\"", "+", "y", ")", ";", "}", "if", "(", "(", "y", "<", "0", ")", "||", "(", "y", ">=", "subImages", "[", "0", "]", ".", "length", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"SubImage out of sheet bounds: \"", "+", "x", "+", "\",\"", "+", "y", ")", ";", "}", "return", "target", ".", "getSubImage", "(", "x", "*", "(", "tw", "+", "spacing", ")", "+", "margin", ",", "y", "*", "(", "th", "+", "spacing", ")", "+", "margin", ",", "tw", ",", "th", ")", ";", "}" ]
Get a sprite at a particular cell on the sprite sheet @param x The x position of the cell on the sprite sheet @param y The y position of the cell on the sprite sheet @return The single image from the sprite sheet
[ "Get", "a", "sprite", "at", "a", "particular", "cell", "on", "the", "sprite", "sheet" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/SpriteSheet.java#L218-L230
1,483
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/SpriteSheet.java
SpriteSheet.renderInUse
public void renderInUse(int x,int y,int sx,int sy) { subImages[sx][sy].drawEmbedded(x, y, tw, th); }
java
public void renderInUse(int x,int y,int sx,int sy) { subImages[sx][sy].drawEmbedded(x, y, tw, th); }
[ "public", "void", "renderInUse", "(", "int", "x", ",", "int", "y", ",", "int", "sx", ",", "int", "sy", ")", "{", "subImages", "[", "sx", "]", "[", "sy", "]", ".", "drawEmbedded", "(", "x", ",", "y", ",", "tw", ",", "th", ")", ";", "}" ]
Render a sprite when this sprite sheet is in use. @see #startUse() @see #endUse() @param x The x position to render the sprite at @param y The y position to render the sprite at @param sx The x location of the cell to render @param sy The y location of the cell to render
[ "Render", "a", "sprite", "when", "this", "sprite", "sheet", "is", "in", "use", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/SpriteSheet.java#L267-L269
1,484
nguillaumin/slick2d-maven
slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/SheetPanel.java
SheetPanel.setTextureSize
public void setTextureSize(int width, int height) { setPreferredSize(new Dimension(width, height)); setSize(new Dimension(width, height)); this.width = width; this.height = height; }
java
public void setTextureSize(int width, int height) { setPreferredSize(new Dimension(width, height)); setSize(new Dimension(width, height)); this.width = width; this.height = height; }
[ "public", "void", "setTextureSize", "(", "int", "width", ",", "int", "height", ")", "{", "setPreferredSize", "(", "new", "Dimension", "(", "width", ",", "height", ")", ")", ";", "setSize", "(", "new", "Dimension", "(", "width", ",", "height", ")", ")", ";", "this", ".", "width", "=", "width", ";", "this", ".", "height", "=", "height", ";", "}" ]
Set the size of the sprite sheet @param width The width of the sheet @param height The height of the sheet
[ "Set", "the", "size", "of", "the", "sprite", "sheet" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/SheetPanel.java#L94-L99
1,485
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java
Circle.setRadius
public void setRadius(float radius) { if (radius != this.radius) { pointsDirty = true; this.radius = radius; setRadii(radius, radius); } }
java
public void setRadius(float radius) { if (radius != this.radius) { pointsDirty = true; this.radius = radius; setRadii(radius, radius); } }
[ "public", "void", "setRadius", "(", "float", "radius", ")", "{", "if", "(", "radius", "!=", "this", ".", "radius", ")", "{", "pointsDirty", "=", "true", ";", "this", ".", "radius", "=", "radius", ";", "setRadii", "(", "radius", ",", "radius", ")", ";", "}", "}" ]
Set the radius of this circle @param radius The radius of this circle
[ "Set", "the", "radius", "of", "this", "circle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java#L72-L78
1,486
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java
Circle.intersects
public boolean intersects(Shape shape) { if(shape instanceof Circle) { Circle other = (Circle)shape; float totalRad2 = getRadius() + other.getRadius(); if (Math.abs(other.getCenterX() - getCenterX()) > totalRad2) { return false; } if (Math.abs(other.getCenterY() - getCenterY()) > totalRad2) { return false; } totalRad2 *= totalRad2; float dx = Math.abs(other.getCenterX() - getCenterX()); float dy = Math.abs(other.getCenterY() - getCenterY()); return totalRad2 >= ((dx*dx) + (dy*dy)); } else if(shape instanceof Rectangle) { return intersects((Rectangle)shape); } else { return super.intersects(shape); } }
java
public boolean intersects(Shape shape) { if(shape instanceof Circle) { Circle other = (Circle)shape; float totalRad2 = getRadius() + other.getRadius(); if (Math.abs(other.getCenterX() - getCenterX()) > totalRad2) { return false; } if (Math.abs(other.getCenterY() - getCenterY()) > totalRad2) { return false; } totalRad2 *= totalRad2; float dx = Math.abs(other.getCenterX() - getCenterX()); float dy = Math.abs(other.getCenterY() - getCenterY()); return totalRad2 >= ((dx*dx) + (dy*dy)); } else if(shape instanceof Rectangle) { return intersects((Rectangle)shape); } else { return super.intersects(shape); } }
[ "public", "boolean", "intersects", "(", "Shape", "shape", ")", "{", "if", "(", "shape", "instanceof", "Circle", ")", "{", "Circle", "other", "=", "(", "Circle", ")", "shape", ";", "float", "totalRad2", "=", "getRadius", "(", ")", "+", "other", ".", "getRadius", "(", ")", ";", "if", "(", "Math", ".", "abs", "(", "other", ".", "getCenterX", "(", ")", "-", "getCenterX", "(", ")", ")", ">", "totalRad2", ")", "{", "return", "false", ";", "}", "if", "(", "Math", ".", "abs", "(", "other", ".", "getCenterY", "(", ")", "-", "getCenterY", "(", ")", ")", ">", "totalRad2", ")", "{", "return", "false", ";", "}", "totalRad2", "*=", "totalRad2", ";", "float", "dx", "=", "Math", ".", "abs", "(", "other", ".", "getCenterX", "(", ")", "-", "getCenterX", "(", ")", ")", ";", "float", "dy", "=", "Math", ".", "abs", "(", "other", ".", "getCenterY", "(", ")", "-", "getCenterY", "(", ")", ")", ";", "return", "totalRad2", ">=", "(", "(", "dx", "*", "dx", ")", "+", "(", "dy", "*", "dy", ")", ")", ";", "}", "else", "if", "(", "shape", "instanceof", "Rectangle", ")", "{", "return", "intersects", "(", "(", "Rectangle", ")", "shape", ")", ";", "}", "else", "{", "return", "super", ".", "intersects", "(", "shape", ")", ";", "}", "}" ]
Check if this circle touches another @param shape The other circle @return True if they touch
[ "Check", "if", "this", "circle", "touches", "another" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java#L95-L120
1,487
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java
Circle.contains
public boolean contains(float x, float y) { float xDelta = x - getCenterX(), yDelta = y - getCenterY(); return xDelta * xDelta + yDelta * yDelta < getRadius() * getRadius(); }
java
public boolean contains(float x, float y) { float xDelta = x - getCenterX(), yDelta = y - getCenterY(); return xDelta * xDelta + yDelta * yDelta < getRadius() * getRadius(); }
[ "public", "boolean", "contains", "(", "float", "x", ",", "float", "y", ")", "{", "float", "xDelta", "=", "x", "-", "getCenterX", "(", ")", ",", "yDelta", "=", "y", "-", "getCenterY", "(", ")", ";", "return", "xDelta", "*", "xDelta", "+", "yDelta", "*", "yDelta", "<", "getRadius", "(", ")", "*", "getRadius", "(", ")", ";", "}" ]
Check if a point is contained by this circle @param x The x coordinate of the point to check @param y The y coorindate of the point to check @return True if the point is contained by this circle
[ "Check", "if", "a", "point", "is", "contained", "by", "this", "circle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java#L129-L133
1,488
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java
Circle.contains
private boolean contains(Line line) { return contains(line.getX1(), line.getY1()) && contains(line.getX2(), line.getY2()); }
java
private boolean contains(Line line) { return contains(line.getX1(), line.getY1()) && contains(line.getX2(), line.getY2()); }
[ "private", "boolean", "contains", "(", "Line", "line", ")", "{", "return", "contains", "(", "line", ".", "getX1", "(", ")", ",", "line", ".", "getY1", "(", ")", ")", "&&", "contains", "(", "line", ".", "getX2", "(", ")", ",", "line", ".", "getY2", "(", ")", ")", ";", "}" ]
Check if circle contains the line @param line Line to check against @return True if line inside circle
[ "Check", "if", "circle", "contains", "the", "line" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java#L140-L142
1,489
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java
Circle.intersects
private boolean intersects(Rectangle other) { Rectangle box = other; Circle circle = this; if (box.contains(x+radius,y+radius)) { return true; } float x1 = box.getX(); float y1 = box.getY(); float x2 = box.getX() + box.getWidth(); float y2 = box.getY() + box.getHeight(); Line[] lines = new Line[4]; lines[0] = new Line(x1,y1,x2,y1); lines[1] = new Line(x2,y1,x2,y2); lines[2] = new Line(x2,y2,x1,y2); lines[3] = new Line(x1,y2,x1,y1); float r2 = circle.getRadius() * circle.getRadius(); Vector2f pos = new Vector2f(circle.getCenterX(), circle.getCenterY()); for (int i=0;i<4;i++) { float dis = lines[i].distanceSquared(pos); if (dis < r2) { return true; } } return false; }
java
private boolean intersects(Rectangle other) { Rectangle box = other; Circle circle = this; if (box.contains(x+radius,y+radius)) { return true; } float x1 = box.getX(); float y1 = box.getY(); float x2 = box.getX() + box.getWidth(); float y2 = box.getY() + box.getHeight(); Line[] lines = new Line[4]; lines[0] = new Line(x1,y1,x2,y1); lines[1] = new Line(x2,y1,x2,y2); lines[2] = new Line(x2,y2,x1,y2); lines[3] = new Line(x1,y2,x1,y1); float r2 = circle.getRadius() * circle.getRadius(); Vector2f pos = new Vector2f(circle.getCenterX(), circle.getCenterY()); for (int i=0;i<4;i++) { float dis = lines[i].distanceSquared(pos); if (dis < r2) { return true; } } return false; }
[ "private", "boolean", "intersects", "(", "Rectangle", "other", ")", "{", "Rectangle", "box", "=", "other", ";", "Circle", "circle", "=", "this", ";", "if", "(", "box", ".", "contains", "(", "x", "+", "radius", ",", "y", "+", "radius", ")", ")", "{", "return", "true", ";", "}", "float", "x1", "=", "box", ".", "getX", "(", ")", ";", "float", "y1", "=", "box", ".", "getY", "(", ")", ";", "float", "x2", "=", "box", ".", "getX", "(", ")", "+", "box", ".", "getWidth", "(", ")", ";", "float", "y2", "=", "box", ".", "getY", "(", ")", "+", "box", ".", "getHeight", "(", ")", ";", "Line", "[", "]", "lines", "=", "new", "Line", "[", "4", "]", ";", "lines", "[", "0", "]", "=", "new", "Line", "(", "x1", ",", "y1", ",", "x2", ",", "y1", ")", ";", "lines", "[", "1", "]", "=", "new", "Line", "(", "x2", ",", "y1", ",", "x2", ",", "y2", ")", ";", "lines", "[", "2", "]", "=", "new", "Line", "(", "x2", ",", "y2", ",", "x1", ",", "y2", ")", ";", "lines", "[", "3", "]", "=", "new", "Line", "(", "x1", ",", "y2", ",", "x1", ",", "y1", ")", ";", "float", "r2", "=", "circle", ".", "getRadius", "(", ")", "*", "circle", ".", "getRadius", "(", ")", ";", "Vector2f", "pos", "=", "new", "Vector2f", "(", "circle", ".", "getCenterX", "(", ")", ",", "circle", ".", "getCenterY", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "float", "dis", "=", "lines", "[", "i", "]", ".", "distanceSquared", "(", "pos", ")", ";", "if", "(", "dis", "<", "r2", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if this circle touches a rectangle @param other The rectangle to check against @return True if they touch
[ "Check", "if", "this", "circle", "touches", "a", "rectangle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java#L166-L197
1,490
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java
Circle.intersects
private boolean intersects(Line other) { // put it nicely into vectors Vector2f lineSegmentStart = new Vector2f(other.getX1(), other.getY1()); Vector2f lineSegmentEnd = new Vector2f(other.getX2(), other.getY2()); Vector2f circleCenter = new Vector2f(getCenterX(), getCenterY()); // calculate point on line closest to the circle center and then // compare radius to distance to the point for intersection result Vector2f closest; Vector2f segv = lineSegmentEnd.copy().sub(lineSegmentStart); Vector2f ptv = circleCenter.copy().sub(lineSegmentStart); float segvLength = segv.length(); float projvl = ptv.dot(segv) / segvLength; if (projvl < 0) { closest = lineSegmentStart; } else if (projvl > segvLength) { closest = lineSegmentEnd; } else { Vector2f projv = segv.copy().scale(projvl / segvLength); closest = lineSegmentStart.copy().add(projv); } boolean intersects = circleCenter.copy().sub(closest).lengthSquared() <= getRadius()*getRadius(); return intersects; }
java
private boolean intersects(Line other) { // put it nicely into vectors Vector2f lineSegmentStart = new Vector2f(other.getX1(), other.getY1()); Vector2f lineSegmentEnd = new Vector2f(other.getX2(), other.getY2()); Vector2f circleCenter = new Vector2f(getCenterX(), getCenterY()); // calculate point on line closest to the circle center and then // compare radius to distance to the point for intersection result Vector2f closest; Vector2f segv = lineSegmentEnd.copy().sub(lineSegmentStart); Vector2f ptv = circleCenter.copy().sub(lineSegmentStart); float segvLength = segv.length(); float projvl = ptv.dot(segv) / segvLength; if (projvl < 0) { closest = lineSegmentStart; } else if (projvl > segvLength) { closest = lineSegmentEnd; } else { Vector2f projv = segv.copy().scale(projvl / segvLength); closest = lineSegmentStart.copy().add(projv); } boolean intersects = circleCenter.copy().sub(closest).lengthSquared() <= getRadius()*getRadius(); return intersects; }
[ "private", "boolean", "intersects", "(", "Line", "other", ")", "{", "// put it nicely into vectors \r", "Vector2f", "lineSegmentStart", "=", "new", "Vector2f", "(", "other", ".", "getX1", "(", ")", ",", "other", ".", "getY1", "(", ")", ")", ";", "Vector2f", "lineSegmentEnd", "=", "new", "Vector2f", "(", "other", ".", "getX2", "(", ")", ",", "other", ".", "getY2", "(", ")", ")", ";", "Vector2f", "circleCenter", "=", "new", "Vector2f", "(", "getCenterX", "(", ")", ",", "getCenterY", "(", ")", ")", ";", "// calculate point on line closest to the circle center and then \r", "// compare radius to distance to the point for intersection result \r", "Vector2f", "closest", ";", "Vector2f", "segv", "=", "lineSegmentEnd", ".", "copy", "(", ")", ".", "sub", "(", "lineSegmentStart", ")", ";", "Vector2f", "ptv", "=", "circleCenter", ".", "copy", "(", ")", ".", "sub", "(", "lineSegmentStart", ")", ";", "float", "segvLength", "=", "segv", ".", "length", "(", ")", ";", "float", "projvl", "=", "ptv", ".", "dot", "(", "segv", ")", "/", "segvLength", ";", "if", "(", "projvl", "<", "0", ")", "{", "closest", "=", "lineSegmentStart", ";", "}", "else", "if", "(", "projvl", ">", "segvLength", ")", "{", "closest", "=", "lineSegmentEnd", ";", "}", "else", "{", "Vector2f", "projv", "=", "segv", ".", "copy", "(", ")", ".", "scale", "(", "projvl", "/", "segvLength", ")", ";", "closest", "=", "lineSegmentStart", ".", "copy", "(", ")", ".", "add", "(", "projv", ")", ";", "}", "boolean", "intersects", "=", "circleCenter", ".", "copy", "(", ")", ".", "sub", "(", "closest", ")", ".", "lengthSquared", "(", ")", "<=", "getRadius", "(", ")", "*", "getRadius", "(", ")", ";", "return", "intersects", ";", "}" ]
Check if circle touches a line. @param other The line to check against @return True if they touch
[ "Check", "if", "circle", "touches", "a", "line", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Circle.java#L204-L233
1,491
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/AudioLoader.java
AudioLoader.getAudio
public static Audio getAudio(String format, InputStream in) throws IOException { init(); if (format.equals(AIF)) { return SoundStore.get().getAIF(in); } if (format.equals(WAV)) { return SoundStore.get().getWAV(in); } if (format.equals(OGG)) { return SoundStore.get().getOgg(in); } throw new IOException("Unsupported format for non-streaming Audio: "+format); }
java
public static Audio getAudio(String format, InputStream in) throws IOException { init(); if (format.equals(AIF)) { return SoundStore.get().getAIF(in); } if (format.equals(WAV)) { return SoundStore.get().getWAV(in); } if (format.equals(OGG)) { return SoundStore.get().getOgg(in); } throw new IOException("Unsupported format for non-streaming Audio: "+format); }
[ "public", "static", "Audio", "getAudio", "(", "String", "format", ",", "InputStream", "in", ")", "throws", "IOException", "{", "init", "(", ")", ";", "if", "(", "format", ".", "equals", "(", "AIF", ")", ")", "{", "return", "SoundStore", ".", "get", "(", ")", ".", "getAIF", "(", "in", ")", ";", "}", "if", "(", "format", ".", "equals", "(", "WAV", ")", ")", "{", "return", "SoundStore", ".", "get", "(", ")", ".", "getWAV", "(", "in", ")", ";", "}", "if", "(", "format", ".", "equals", "(", "OGG", ")", ")", "{", "return", "SoundStore", ".", "get", "(", ")", ".", "getOgg", "(", "in", ")", ";", "}", "throw", "new", "IOException", "(", "\"Unsupported format for non-streaming Audio: \"", "+", "format", ")", ";", "}" ]
Get audio data in a playable state by loading the complete audio into memory. @param format The format of the audio to be loaded (something like "XM" or "OGG") @param in The input stream from which to load the audio data @return An object representing the audio data @throws IOException Indicates a failure to access the audio data
[ "Get", "audio", "data", "in", "a", "playable", "state", "by", "loading", "the", "complete", "audio", "into", "memory", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/AudioLoader.java#L47-L61
1,492
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/AudioLoader.java
AudioLoader.getStreamingAudio
public static Audio getStreamingAudio(String format, URL url) throws IOException { init(); if (format.equals(OGG)) { return SoundStore.get().getOggStream(url); } if (format.equals(MOD)) { return SoundStore.get().getMOD(url.openStream()); } if (format.equals(XM)) { return SoundStore.get().getMOD(url.openStream()); } throw new IOException("Unsupported format for streaming Audio: "+format); }
java
public static Audio getStreamingAudio(String format, URL url) throws IOException { init(); if (format.equals(OGG)) { return SoundStore.get().getOggStream(url); } if (format.equals(MOD)) { return SoundStore.get().getMOD(url.openStream()); } if (format.equals(XM)) { return SoundStore.get().getMOD(url.openStream()); } throw new IOException("Unsupported format for streaming Audio: "+format); }
[ "public", "static", "Audio", "getStreamingAudio", "(", "String", "format", ",", "URL", "url", ")", "throws", "IOException", "{", "init", "(", ")", ";", "if", "(", "format", ".", "equals", "(", "OGG", ")", ")", "{", "return", "SoundStore", ".", "get", "(", ")", ".", "getOggStream", "(", "url", ")", ";", "}", "if", "(", "format", ".", "equals", "(", "MOD", ")", ")", "{", "return", "SoundStore", ".", "get", "(", ")", ".", "getMOD", "(", "url", ".", "openStream", "(", ")", ")", ";", "}", "if", "(", "format", ".", "equals", "(", "XM", ")", ")", "{", "return", "SoundStore", ".", "get", "(", ")", ".", "getMOD", "(", "url", ".", "openStream", "(", ")", ")", ";", "}", "throw", "new", "IOException", "(", "\"Unsupported format for streaming Audio: \"", "+", "format", ")", ";", "}" ]
Get audio data in a playable state by setting up a stream that can be piped into OpenAL - i.e. streaming audio @param format The format of the audio to be loaded (something like "XM" or "OGG") @param url The location of the data that should be streamed @return An object representing the audio data @throws IOException Indicates a failure to access the audio data
[ "Get", "audio", "data", "in", "a", "playable", "state", "by", "setting", "up", "a", "stream", "that", "can", "be", "piped", "into", "OpenAL", "-", "i", ".", "e", ".", "streaming", "audio" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/AudioLoader.java#L72-L86
1,493
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/WaveData.java
WaveData.create
public static WaveData create(AudioInputStream ais) { //get format of data AudioFormat audioformat = ais.getFormat(); // get channels int channels = 0; if (audioformat.getChannels() == 1) { if (audioformat.getSampleSizeInBits() == 8) { channels = AL10.AL_FORMAT_MONO8; } else if (audioformat.getSampleSizeInBits() == 16) { channels = AL10.AL_FORMAT_MONO16; } else { throw new RuntimeException("Illegal sample size"); } } else if (audioformat.getChannels() == 2) { if (audioformat.getSampleSizeInBits() == 8) { channels = AL10.AL_FORMAT_STEREO8; } else if (audioformat.getSampleSizeInBits() == 16) { channels = AL10.AL_FORMAT_STEREO16; } else { throw new RuntimeException("Illegal sample size"); } } else { throw new RuntimeException("Only mono or stereo is supported"); } //read data into buffer byte[] buf = new byte[audioformat.getChannels() * (int) ais.getFrameLength() * audioformat.getSampleSizeInBits() / 8]; int read = 0, total = 0; try { while ((read = ais.read(buf, total, buf.length - total)) != -1 && total < buf.length) { total += read; } } catch (IOException ioe) { return null; } //insert data into bytebuffer ByteBuffer buffer = convertAudioBytes(buf, audioformat.getSampleSizeInBits() == 16); /* ByteBuffer buffer = ByteBuffer.allocateDirect(buf.length); buffer.put(buf); buffer.rewind();*/ //create our result WaveData wavedata = new WaveData(buffer, channels, (int) audioformat.getSampleRate()); //close stream try { ais.close(); } catch (IOException ioe) { } return wavedata; }
java
public static WaveData create(AudioInputStream ais) { //get format of data AudioFormat audioformat = ais.getFormat(); // get channels int channels = 0; if (audioformat.getChannels() == 1) { if (audioformat.getSampleSizeInBits() == 8) { channels = AL10.AL_FORMAT_MONO8; } else if (audioformat.getSampleSizeInBits() == 16) { channels = AL10.AL_FORMAT_MONO16; } else { throw new RuntimeException("Illegal sample size"); } } else if (audioformat.getChannels() == 2) { if (audioformat.getSampleSizeInBits() == 8) { channels = AL10.AL_FORMAT_STEREO8; } else if (audioformat.getSampleSizeInBits() == 16) { channels = AL10.AL_FORMAT_STEREO16; } else { throw new RuntimeException("Illegal sample size"); } } else { throw new RuntimeException("Only mono or stereo is supported"); } //read data into buffer byte[] buf = new byte[audioformat.getChannels() * (int) ais.getFrameLength() * audioformat.getSampleSizeInBits() / 8]; int read = 0, total = 0; try { while ((read = ais.read(buf, total, buf.length - total)) != -1 && total < buf.length) { total += read; } } catch (IOException ioe) { return null; } //insert data into bytebuffer ByteBuffer buffer = convertAudioBytes(buf, audioformat.getSampleSizeInBits() == 16); /* ByteBuffer buffer = ByteBuffer.allocateDirect(buf.length); buffer.put(buf); buffer.rewind();*/ //create our result WaveData wavedata = new WaveData(buffer, channels, (int) audioformat.getSampleRate()); //close stream try { ais.close(); } catch (IOException ioe) { } return wavedata; }
[ "public", "static", "WaveData", "create", "(", "AudioInputStream", "ais", ")", "{", "//get format of data\r", "AudioFormat", "audioformat", "=", "ais", ".", "getFormat", "(", ")", ";", "// get channels\r", "int", "channels", "=", "0", ";", "if", "(", "audioformat", ".", "getChannels", "(", ")", "==", "1", ")", "{", "if", "(", "audioformat", ".", "getSampleSizeInBits", "(", ")", "==", "8", ")", "{", "channels", "=", "AL10", ".", "AL_FORMAT_MONO8", ";", "}", "else", "if", "(", "audioformat", ".", "getSampleSizeInBits", "(", ")", "==", "16", ")", "{", "channels", "=", "AL10", ".", "AL_FORMAT_MONO16", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Illegal sample size\"", ")", ";", "}", "}", "else", "if", "(", "audioformat", ".", "getChannels", "(", ")", "==", "2", ")", "{", "if", "(", "audioformat", ".", "getSampleSizeInBits", "(", ")", "==", "8", ")", "{", "channels", "=", "AL10", ".", "AL_FORMAT_STEREO8", ";", "}", "else", "if", "(", "audioformat", ".", "getSampleSizeInBits", "(", ")", "==", "16", ")", "{", "channels", "=", "AL10", ".", "AL_FORMAT_STEREO16", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Illegal sample size\"", ")", ";", "}", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Only mono or stereo is supported\"", ")", ";", "}", "//read data into buffer\r", "byte", "[", "]", "buf", "=", "new", "byte", "[", "audioformat", ".", "getChannels", "(", ")", "*", "(", "int", ")", "ais", ".", "getFrameLength", "(", ")", "*", "audioformat", ".", "getSampleSizeInBits", "(", ")", "/", "8", "]", ";", "int", "read", "=", "0", ",", "total", "=", "0", ";", "try", "{", "while", "(", "(", "read", "=", "ais", ".", "read", "(", "buf", ",", "total", ",", "buf", ".", "length", "-", "total", ")", ")", "!=", "-", "1", "&&", "total", "<", "buf", ".", "length", ")", "{", "total", "+=", "read", ";", "}", "}", "catch", "(", "IOException", "ioe", ")", "{", "return", "null", ";", "}", "//insert data into bytebuffer\r", "ByteBuffer", "buffer", "=", "convertAudioBytes", "(", "buf", ",", "audioformat", ".", "getSampleSizeInBits", "(", ")", "==", "16", ")", ";", "/*\t\tByteBuffer buffer = ByteBuffer.allocateDirect(buf.length);\r\n\t\tbuffer.put(buf);\r\n\t\tbuffer.rewind();*/", "//create our result\r", "WaveData", "wavedata", "=", "new", "WaveData", "(", "buffer", ",", "channels", ",", "(", "int", ")", "audioformat", ".", "getSampleRate", "(", ")", ")", ";", "//close stream\r", "try", "{", "ais", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "}", "return", "wavedata", ";", "}" ]
Creates a WaveData container from the specified stream @param ais AudioInputStream to read from @return WaveData containing data, or null if a failure occured
[ "Creates", "a", "WaveData", "container", "from", "the", "specified", "stream" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/WaveData.java#L180-L239
1,494
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/MaskUtil.java
MaskUtil.defineMask
public static void defineMask() { GL.glDepthMask(true); GL.glClearDepth(1); GL.glClear(SGL.GL_DEPTH_BUFFER_BIT); GL.glDepthFunc(SGL.GL_ALWAYS); GL.glEnable(SGL.GL_DEPTH_TEST); GL.glDepthMask(true); GL.glColorMask(false, false, false, false); }
java
public static void defineMask() { GL.glDepthMask(true); GL.glClearDepth(1); GL.glClear(SGL.GL_DEPTH_BUFFER_BIT); GL.glDepthFunc(SGL.GL_ALWAYS); GL.glEnable(SGL.GL_DEPTH_TEST); GL.glDepthMask(true); GL.glColorMask(false, false, false, false); }
[ "public", "static", "void", "defineMask", "(", ")", "{", "GL", ".", "glDepthMask", "(", "true", ")", ";", "GL", ".", "glClearDepth", "(", "1", ")", ";", "GL", ".", "glClear", "(", "SGL", ".", "GL_DEPTH_BUFFER_BIT", ")", ";", "GL", ".", "glDepthFunc", "(", "SGL", ".", "GL_ALWAYS", ")", ";", "GL", ".", "glEnable", "(", "SGL", ".", "GL_DEPTH_TEST", ")", ";", "GL", ".", "glDepthMask", "(", "true", ")", ";", "GL", ".", "glColorMask", "(", "false", ",", "false", ",", "false", ",", "false", ")", ";", "}" ]
Start defining the screen mask. After calling this use graphics functions to mask out the area
[ "Start", "defining", "the", "screen", "mask", ".", "After", "calling", "this", "use", "graphics", "functions", "to", "mask", "out", "the", "area" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/MaskUtil.java#L19-L27
1,495
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/MaskUtil.java
MaskUtil.finishDefineMask
public static void finishDefineMask() { GL.glDepthMask(false); GL.glColorMask(true, true, true, true); }
java
public static void finishDefineMask() { GL.glDepthMask(false); GL.glColorMask(true, true, true, true); }
[ "public", "static", "void", "finishDefineMask", "(", ")", "{", "GL", ".", "glDepthMask", "(", "false", ")", ";", "GL", ".", "glColorMask", "(", "true", ",", "true", ",", "true", ",", "true", ")", ";", "}" ]
Finish defining the screen mask
[ "Finish", "defining", "the", "screen", "mask" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/MaskUtil.java#L32-L35
1,496
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/MaskUtil.java
MaskUtil.resetMask
public static void resetMask() { GL.glDepthMask(true); GL.glClearDepth(0); GL.glClear(SGL.GL_DEPTH_BUFFER_BIT); GL.glDepthMask(false); GL.glDisable(SGL.GL_DEPTH_TEST); }
java
public static void resetMask() { GL.glDepthMask(true); GL.glClearDepth(0); GL.glClear(SGL.GL_DEPTH_BUFFER_BIT); GL.glDepthMask(false); GL.glDisable(SGL.GL_DEPTH_TEST); }
[ "public", "static", "void", "resetMask", "(", ")", "{", "GL", ".", "glDepthMask", "(", "true", ")", ";", "GL", ".", "glClearDepth", "(", "0", ")", ";", "GL", ".", "glClear", "(", "SGL", ".", "GL_DEPTH_BUFFER_BIT", ")", ";", "GL", ".", "glDepthMask", "(", "false", ")", ";", "GL", ".", "glDisable", "(", "SGL", ".", "GL_DEPTH_TEST", ")", ";", "}" ]
Reset the masked area - should be done after you've finished rendering
[ "Reset", "the", "masked", "area", "-", "should", "be", "done", "after", "you", "ve", "finished", "rendering" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/MaskUtil.java#L54-L61
1,497
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/UnicodeFont.java
UnicodeFont.createFont
private static Font createFont (String ttfFileRef) throws SlickException { try { return Font.createFont(Font.TRUETYPE_FONT, ResourceLoader.getResourceAsStream(ttfFileRef)); } catch (FontFormatException ex) { throw new SlickException("Invalid font: " + ttfFileRef, ex); } catch (IOException ex) { throw new SlickException("Error reading font: " + ttfFileRef, ex); } }
java
private static Font createFont (String ttfFileRef) throws SlickException { try { return Font.createFont(Font.TRUETYPE_FONT, ResourceLoader.getResourceAsStream(ttfFileRef)); } catch (FontFormatException ex) { throw new SlickException("Invalid font: " + ttfFileRef, ex); } catch (IOException ex) { throw new SlickException("Error reading font: " + ttfFileRef, ex); } }
[ "private", "static", "Font", "createFont", "(", "String", "ttfFileRef", ")", "throws", "SlickException", "{", "try", "{", "return", "Font", ".", "createFont", "(", "Font", ".", "TRUETYPE_FONT", ",", "ResourceLoader", ".", "getResourceAsStream", "(", "ttfFileRef", ")", ")", ";", "}", "catch", "(", "FontFormatException", "ex", ")", "{", "throw", "new", "SlickException", "(", "\"Invalid font: \"", "+", "ttfFileRef", ",", "ex", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "SlickException", "(", "\"Error reading font: \"", "+", "ttfFileRef", ",", "ex", ")", ";", "}", "}" ]
Utility to create a Java font for a TTF file reference @param ttfFileRef The file system or classpath location of the TrueTypeFont file. @return The font created @throws SlickException Indicates a failure to locate or load the font into Java's font system.
[ "Utility", "to", "create", "a", "Java", "font", "for", "a", "TTF", "file", "reference" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/UnicodeFont.java#L59-L67
1,498
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/UnicodeFont.java
UnicodeFont.initializeFont
private void initializeFont(Font baseFont, int size, boolean bold, boolean italic) { Map attributes = baseFont.getAttributes(); attributes.put(TextAttribute.SIZE, new Float(size)); attributes.put(TextAttribute.WEIGHT, bold ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR); attributes.put(TextAttribute.POSTURE, italic ? TextAttribute.POSTURE_OBLIQUE : TextAttribute.POSTURE_REGULAR); try { attributes.put(TextAttribute.class.getDeclaredField("KERNING").get(null), TextAttribute.class.getDeclaredField( "KERNING_ON").get(null)); } catch (Exception ignored) { } font = baseFont.deriveFont(attributes); FontMetrics metrics = GlyphPage.getScratchGraphics().getFontMetrics(font); ascent = metrics.getAscent(); descent = metrics.getDescent(); leading = metrics.getLeading(); // Determine width of space glyph (getGlyphPixelBounds gives a width of zero). char[] chars = " ".toCharArray(); GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); spaceWidth = vector.getGlyphLogicalBounds(0).getBounds().width; }
java
private void initializeFont(Font baseFont, int size, boolean bold, boolean italic) { Map attributes = baseFont.getAttributes(); attributes.put(TextAttribute.SIZE, new Float(size)); attributes.put(TextAttribute.WEIGHT, bold ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR); attributes.put(TextAttribute.POSTURE, italic ? TextAttribute.POSTURE_OBLIQUE : TextAttribute.POSTURE_REGULAR); try { attributes.put(TextAttribute.class.getDeclaredField("KERNING").get(null), TextAttribute.class.getDeclaredField( "KERNING_ON").get(null)); } catch (Exception ignored) { } font = baseFont.deriveFont(attributes); FontMetrics metrics = GlyphPage.getScratchGraphics().getFontMetrics(font); ascent = metrics.getAscent(); descent = metrics.getDescent(); leading = metrics.getLeading(); // Determine width of space glyph (getGlyphPixelBounds gives a width of zero). char[] chars = " ".toCharArray(); GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); spaceWidth = vector.getGlyphLogicalBounds(0).getBounds().width; }
[ "private", "void", "initializeFont", "(", "Font", "baseFont", ",", "int", "size", ",", "boolean", "bold", ",", "boolean", "italic", ")", "{", "Map", "attributes", "=", "baseFont", ".", "getAttributes", "(", ")", ";", "attributes", ".", "put", "(", "TextAttribute", ".", "SIZE", ",", "new", "Float", "(", "size", ")", ")", ";", "attributes", ".", "put", "(", "TextAttribute", ".", "WEIGHT", ",", "bold", "?", "TextAttribute", ".", "WEIGHT_BOLD", ":", "TextAttribute", ".", "WEIGHT_REGULAR", ")", ";", "attributes", ".", "put", "(", "TextAttribute", ".", "POSTURE", ",", "italic", "?", "TextAttribute", ".", "POSTURE_OBLIQUE", ":", "TextAttribute", ".", "POSTURE_REGULAR", ")", ";", "try", "{", "attributes", ".", "put", "(", "TextAttribute", ".", "class", ".", "getDeclaredField", "(", "\"KERNING\"", ")", ".", "get", "(", "null", ")", ",", "TextAttribute", ".", "class", ".", "getDeclaredField", "(", "\"KERNING_ON\"", ")", ".", "get", "(", "null", ")", ")", ";", "}", "catch", "(", "Exception", "ignored", ")", "{", "}", "font", "=", "baseFont", ".", "deriveFont", "(", "attributes", ")", ";", "FontMetrics", "metrics", "=", "GlyphPage", ".", "getScratchGraphics", "(", ")", ".", "getFontMetrics", "(", "font", ")", ";", "ascent", "=", "metrics", ".", "getAscent", "(", ")", ";", "descent", "=", "metrics", ".", "getDescent", "(", ")", ";", "leading", "=", "metrics", ".", "getLeading", "(", ")", ";", "// Determine width of space glyph (getGlyphPixelBounds gives a width of zero).\r", "char", "[", "]", "chars", "=", "\" \"", ".", "toCharArray", "(", ")", ";", "GlyphVector", "vector", "=", "font", ".", "layoutGlyphVector", "(", "GlyphPage", ".", "renderContext", ",", "chars", ",", "0", ",", "chars", ".", "length", ",", "Font", ".", "LAYOUT_LEFT_TO_RIGHT", ")", ";", "spaceWidth", "=", "vector", ".", "getGlyphLogicalBounds", "(", "0", ")", ".", "getBounds", "(", ")", ".", "width", ";", "}" ]
Initialise the font to be used based on configuration @param baseFont The AWT font to render @param size The point size of the font to generated @param bold True if the font should be rendered in bold typeface @param italic True if the font should be rendered in bold typeface
[ "Initialise", "the", "font", "to", "be", "used", "based", "on", "configuration" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/UnicodeFont.java#L227-L248
1,499
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/UnicodeFont.java
UnicodeFont.loadSettings
private void loadSettings(HieroSettings settings) { paddingTop = settings.getPaddingTop(); paddingLeft = settings.getPaddingLeft(); paddingBottom = settings.getPaddingBottom(); paddingRight = settings.getPaddingRight(); paddingAdvanceX = settings.getPaddingAdvanceX(); paddingAdvanceY = settings.getPaddingAdvanceY(); glyphPageWidth = settings.getGlyphPageWidth(); glyphPageHeight = settings.getGlyphPageHeight(); effects.addAll(settings.getEffects()); }
java
private void loadSettings(HieroSettings settings) { paddingTop = settings.getPaddingTop(); paddingLeft = settings.getPaddingLeft(); paddingBottom = settings.getPaddingBottom(); paddingRight = settings.getPaddingRight(); paddingAdvanceX = settings.getPaddingAdvanceX(); paddingAdvanceY = settings.getPaddingAdvanceY(); glyphPageWidth = settings.getGlyphPageWidth(); glyphPageHeight = settings.getGlyphPageHeight(); effects.addAll(settings.getEffects()); }
[ "private", "void", "loadSettings", "(", "HieroSettings", "settings", ")", "{", "paddingTop", "=", "settings", ".", "getPaddingTop", "(", ")", ";", "paddingLeft", "=", "settings", ".", "getPaddingLeft", "(", ")", ";", "paddingBottom", "=", "settings", ".", "getPaddingBottom", "(", ")", ";", "paddingRight", "=", "settings", ".", "getPaddingRight", "(", ")", ";", "paddingAdvanceX", "=", "settings", ".", "getPaddingAdvanceX", "(", ")", ";", "paddingAdvanceY", "=", "settings", ".", "getPaddingAdvanceY", "(", ")", ";", "glyphPageWidth", "=", "settings", ".", "getGlyphPageWidth", "(", ")", ";", "glyphPageHeight", "=", "settings", ".", "getGlyphPageHeight", "(", ")", ";", "effects", ".", "addAll", "(", "settings", ".", "getEffects", "(", ")", ")", ";", "}" ]
Load the hiero setting and configure the unicode font's rendering @param settings The settings to be applied
[ "Load", "the", "hiero", "setting", "and", "configure", "the", "unicode", "font", "s", "rendering" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/UnicodeFont.java#L255-L265