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,600
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/GameContainer.java
GameContainer.initSystem
protected void initSystem() throws SlickException { initGL(); setMusicVolume(1.0f); setSoundVolume(1.0f); graphics = new Graphics(width, height); defaultFont = graphics.getFont(); }
java
protected void initSystem() throws SlickException { initGL(); setMusicVolume(1.0f); setSoundVolume(1.0f); graphics = new Graphics(width, height); defaultFont = graphics.getFont(); }
[ "protected", "void", "initSystem", "(", ")", "throws", "SlickException", "{", "initGL", "(", ")", ";", "setMusicVolume", "(", "1.0f", ")", ";", "setSoundVolume", "(", "1.0f", ")", ";", "graphics", "=", "new", "Graphics", "(", "width", ",", "height", ")", ";", "defaultFont", "=", "graphics", ".", "getFont", "(", ")", ";", "}" ]
Initialise the system components, OpenGL and OpenAL. @throws SlickException Indicates a failure to create a native handler
[ "Initialise", "the", "system", "components", "OpenGL", "and", "OpenAL", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/GameContainer.java#L754-L761
1,601
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/gui/MouseOverArea.java
MouseOverArea.setLocation
public void setLocation(float x, float y) { if (area != null) { area.setX(x); area.setY(y); } }
java
public void setLocation(float x, float y) { if (area != null) { area.setX(x); area.setY(y); } }
[ "public", "void", "setLocation", "(", "float", "x", ",", "float", "y", ")", "{", "if", "(", "area", "!=", "null", ")", "{", "area", ".", "setX", "(", "x", ")", ";", "area", ".", "setY", "(", "y", ")", ";", "}", "}" ]
Moves the component. @param x X coordinate @param y Y coordinate
[ "Moves", "the", "component", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/gui/MouseOverArea.java#L185-L190
1,602
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/gui/MouseOverArea.java
MouseOverArea.updateImage
private void updateImage() { if (!over) { currentImage = normalImage; currentColor = normalColor; state = NORMAL; mouseUp = false; } else { if (mouseDown) { if ((state != MOUSE_DOWN) && (mouseUp)) { if (mouseDownSound != null) { mouseDownSound.play(); } currentImage = mouseDownImage; currentColor = mouseDownColor; state = MOUSE_DOWN; notifyListeners(); mouseUp = false; } return; } else { mouseUp = true; if (state != MOUSE_OVER) { if (mouseOverSound != null) { mouseOverSound.play(); } currentImage = mouseOverImage; currentColor = mouseOverColor; state = MOUSE_OVER; } } } mouseDown = false; state = NORMAL; }
java
private void updateImage() { if (!over) { currentImage = normalImage; currentColor = normalColor; state = NORMAL; mouseUp = false; } else { if (mouseDown) { if ((state != MOUSE_DOWN) && (mouseUp)) { if (mouseDownSound != null) { mouseDownSound.play(); } currentImage = mouseDownImage; currentColor = mouseDownColor; state = MOUSE_DOWN; notifyListeners(); mouseUp = false; } return; } else { mouseUp = true; if (state != MOUSE_OVER) { if (mouseOverSound != null) { mouseOverSound.play(); } currentImage = mouseOverImage; currentColor = mouseOverColor; state = MOUSE_OVER; } } } mouseDown = false; state = NORMAL; }
[ "private", "void", "updateImage", "(", ")", "{", "if", "(", "!", "over", ")", "{", "currentImage", "=", "normalImage", ";", "currentColor", "=", "normalColor", ";", "state", "=", "NORMAL", ";", "mouseUp", "=", "false", ";", "}", "else", "{", "if", "(", "mouseDown", ")", "{", "if", "(", "(", "state", "!=", "MOUSE_DOWN", ")", "&&", "(", "mouseUp", ")", ")", "{", "if", "(", "mouseDownSound", "!=", "null", ")", "{", "mouseDownSound", ".", "play", "(", ")", ";", "}", "currentImage", "=", "mouseDownImage", ";", "currentColor", "=", "mouseDownColor", ";", "state", "=", "MOUSE_DOWN", ";", "notifyListeners", "(", ")", ";", "mouseUp", "=", "false", ";", "}", "return", ";", "}", "else", "{", "mouseUp", "=", "true", ";", "if", "(", "state", "!=", "MOUSE_OVER", ")", "{", "if", "(", "mouseOverSound", "!=", "null", ")", "{", "mouseOverSound", ".", "play", "(", ")", ";", "}", "currentImage", "=", "mouseOverImage", ";", "currentColor", "=", "mouseOverColor", ";", "state", "=", "MOUSE_OVER", ";", "}", "}", "}", "mouseDown", "=", "false", ";", "state", "=", "NORMAL", ";", "}" ]
Update the current normalImage based on the mouse state
[ "Update", "the", "current", "normalImage", "based", "on", "the", "mouse", "state" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/gui/MouseOverArea.java#L309-L345
1,603
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/SimpleDiagramRenderer.java
SimpleDiagramRenderer.render
public void render(Graphics g) { // last list generation if (list == -1) { list = GL.glGenLists(1); GL.glNewList(list, SGL.GL_COMPILE); render(g, diagram); GL.glEndList(); } GL.glCallList(list); TextureImpl.bindNone(); }
java
public void render(Graphics g) { // last list generation if (list == -1) { list = GL.glGenLists(1); GL.glNewList(list, SGL.GL_COMPILE); render(g, diagram); GL.glEndList(); } GL.glCallList(list); TextureImpl.bindNone(); }
[ "public", "void", "render", "(", "Graphics", "g", ")", "{", "// last list generation\r", "if", "(", "list", "==", "-", "1", ")", "{", "list", "=", "GL", ".", "glGenLists", "(", "1", ")", ";", "GL", ".", "glNewList", "(", "list", ",", "SGL", ".", "GL_COMPILE", ")", ";", "render", "(", "g", ",", "diagram", ")", ";", "GL", ".", "glEndList", "(", ")", ";", "}", "GL", ".", "glCallList", "(", "list", ")", ";", "TextureImpl", ".", "bindNone", "(", ")", ";", "}" ]
Render the diagram to the given graphics context @param g The graphics context to which we should render the diagram
[ "Render", "the", "diagram", "to", "the", "given", "graphics", "context" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/SimpleDiagramRenderer.java#L41-L53
1,604
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/SimpleDiagramRenderer.java
SimpleDiagramRenderer.render
public static void render(Graphics g, Diagram diagram) { for (int i=0;i<diagram.getFigureCount();i++) { Figure figure = diagram.getFigure(i); if (figure.getData().isFilled()) { if (figure.getData().isColor(NonGeometricData.FILL)) { g.setColor(figure.getData().getAsColor(NonGeometricData.FILL)); g.fill(diagram.getFigure(i).getShape()); g.setAntiAlias(true); g.draw(diagram.getFigure(i).getShape()); g.setAntiAlias(false); } String fill = figure.getData().getAsReference(NonGeometricData.FILL); if (diagram.getPatternDef(fill) != null){ System.out.println("PATTERN"); } if (diagram.getGradient(fill) != null) { Gradient gradient = diagram.getGradient(fill); Shape shape = diagram.getFigure(i).getShape(); TexCoordGenerator fg = null; if (gradient.isRadial()) { fg = new RadialGradientFill(shape, diagram.getFigure(i).getTransform(), gradient); } else { fg = new LinearGradientFill(shape, diagram.getFigure(i).getTransform(), gradient); } Color.white.bind(); ShapeRenderer.texture(shape, gradient.getImage(), fg); } } if (figure.getData().isStroked()) { if (figure.getData().isColor(NonGeometricData.STROKE)) { g.setColor(figure.getData().getAsColor(NonGeometricData.STROKE)); g.setLineWidth(figure.getData().getAsFloat(NonGeometricData.STROKE_WIDTH)); g.setAntiAlias(true); g.draw(diagram.getFigure(i).getShape()); g.setAntiAlias(false); g.resetLineWidth(); } } // DEBUG VERSION // g.setColor(Color.black); // g.draw(diagram.getFigure(i).getShape()); // g.setColor(Color.red); // g.fill(diagram.getFigure(i).getShape()); } }
java
public static void render(Graphics g, Diagram diagram) { for (int i=0;i<diagram.getFigureCount();i++) { Figure figure = diagram.getFigure(i); if (figure.getData().isFilled()) { if (figure.getData().isColor(NonGeometricData.FILL)) { g.setColor(figure.getData().getAsColor(NonGeometricData.FILL)); g.fill(diagram.getFigure(i).getShape()); g.setAntiAlias(true); g.draw(diagram.getFigure(i).getShape()); g.setAntiAlias(false); } String fill = figure.getData().getAsReference(NonGeometricData.FILL); if (diagram.getPatternDef(fill) != null){ System.out.println("PATTERN"); } if (diagram.getGradient(fill) != null) { Gradient gradient = diagram.getGradient(fill); Shape shape = diagram.getFigure(i).getShape(); TexCoordGenerator fg = null; if (gradient.isRadial()) { fg = new RadialGradientFill(shape, diagram.getFigure(i).getTransform(), gradient); } else { fg = new LinearGradientFill(shape, diagram.getFigure(i).getTransform(), gradient); } Color.white.bind(); ShapeRenderer.texture(shape, gradient.getImage(), fg); } } if (figure.getData().isStroked()) { if (figure.getData().isColor(NonGeometricData.STROKE)) { g.setColor(figure.getData().getAsColor(NonGeometricData.STROKE)); g.setLineWidth(figure.getData().getAsFloat(NonGeometricData.STROKE_WIDTH)); g.setAntiAlias(true); g.draw(diagram.getFigure(i).getShape()); g.setAntiAlias(false); g.resetLineWidth(); } } // DEBUG VERSION // g.setColor(Color.black); // g.draw(diagram.getFigure(i).getShape()); // g.setColor(Color.red); // g.fill(diagram.getFigure(i).getShape()); } }
[ "public", "static", "void", "render", "(", "Graphics", "g", ",", "Diagram", "diagram", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "diagram", ".", "getFigureCount", "(", ")", ";", "i", "++", ")", "{", "Figure", "figure", "=", "diagram", ".", "getFigure", "(", "i", ")", ";", "if", "(", "figure", ".", "getData", "(", ")", ".", "isFilled", "(", ")", ")", "{", "if", "(", "figure", ".", "getData", "(", ")", ".", "isColor", "(", "NonGeometricData", ".", "FILL", ")", ")", "{", "g", ".", "setColor", "(", "figure", ".", "getData", "(", ")", ".", "getAsColor", "(", "NonGeometricData", ".", "FILL", ")", ")", ";", "g", ".", "fill", "(", "diagram", ".", "getFigure", "(", "i", ")", ".", "getShape", "(", ")", ")", ";", "g", ".", "setAntiAlias", "(", "true", ")", ";", "g", ".", "draw", "(", "diagram", ".", "getFigure", "(", "i", ")", ".", "getShape", "(", ")", ")", ";", "g", ".", "setAntiAlias", "(", "false", ")", ";", "}", "String", "fill", "=", "figure", ".", "getData", "(", ")", ".", "getAsReference", "(", "NonGeometricData", ".", "FILL", ")", ";", "if", "(", "diagram", ".", "getPatternDef", "(", "fill", ")", "!=", "null", ")", "{", "System", ".", "out", ".", "println", "(", "\"PATTERN\"", ")", ";", "}", "if", "(", "diagram", ".", "getGradient", "(", "fill", ")", "!=", "null", ")", "{", "Gradient", "gradient", "=", "diagram", ".", "getGradient", "(", "fill", ")", ";", "Shape", "shape", "=", "diagram", ".", "getFigure", "(", "i", ")", ".", "getShape", "(", ")", ";", "TexCoordGenerator", "fg", "=", "null", ";", "if", "(", "gradient", ".", "isRadial", "(", ")", ")", "{", "fg", "=", "new", "RadialGradientFill", "(", "shape", ",", "diagram", ".", "getFigure", "(", "i", ")", ".", "getTransform", "(", ")", ",", "gradient", ")", ";", "}", "else", "{", "fg", "=", "new", "LinearGradientFill", "(", "shape", ",", "diagram", ".", "getFigure", "(", "i", ")", ".", "getTransform", "(", ")", ",", "gradient", ")", ";", "}", "Color", ".", "white", ".", "bind", "(", ")", ";", "ShapeRenderer", ".", "texture", "(", "shape", ",", "gradient", ".", "getImage", "(", ")", ",", "fg", ")", ";", "}", "}", "if", "(", "figure", ".", "getData", "(", ")", ".", "isStroked", "(", ")", ")", "{", "if", "(", "figure", ".", "getData", "(", ")", ".", "isColor", "(", "NonGeometricData", ".", "STROKE", ")", ")", "{", "g", ".", "setColor", "(", "figure", ".", "getData", "(", ")", ".", "getAsColor", "(", "NonGeometricData", ".", "STROKE", ")", ")", ";", "g", ".", "setLineWidth", "(", "figure", ".", "getData", "(", ")", ".", "getAsFloat", "(", "NonGeometricData", ".", "STROKE_WIDTH", ")", ")", ";", "g", ".", "setAntiAlias", "(", "true", ")", ";", "g", ".", "draw", "(", "diagram", ".", "getFigure", "(", "i", ")", ".", "getShape", "(", ")", ")", ";", "g", ".", "setAntiAlias", "(", "false", ")", ";", "g", ".", "resetLineWidth", "(", ")", ";", "}", "}", "// DEBUG VERSION\r", "//\t\t\tg.setColor(Color.black);\r", "//\t\t\tg.draw(diagram.getFigure(i).getShape());\r", "//\t\t\tg.setColor(Color.red);\r", "//\t\t\tg.fill(diagram.getFigure(i).getShape());\r", "}", "}" ]
Utility method to render a diagram in immediate mode @param g The graphics context to render to @param diagram The diagram to render
[ "Utility", "method", "to", "render", "a", "diagram", "in", "immediate", "mode" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/SimpleDiagramRenderer.java#L61-L110
1,605
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java
Vector2f.setTheta
public void setTheta(double theta) { // Next lines are to prevent numbers like -1.8369701E-16 // when working with negative numbers if ((theta < -360) || (theta > 360)) { theta = theta % 360; } if (theta < 0) { theta = 360 + theta; } double oldTheta = getTheta(); if ((theta < -360) || (theta > 360)) { oldTheta = oldTheta % 360; } if (theta < 0) { oldTheta = 360 + oldTheta; } float len = length(); x = len * (float) FastTrig.cos(StrictMath.toRadians(theta)); y = len * (float) FastTrig.sin(StrictMath.toRadians(theta)); // x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta)) // * (float) FastTrig.cos(StrictMath.toRadians(theta)); // y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta)) // * (float) FastTrig.sin(StrictMath.toRadians(theta)); }
java
public void setTheta(double theta) { // Next lines are to prevent numbers like -1.8369701E-16 // when working with negative numbers if ((theta < -360) || (theta > 360)) { theta = theta % 360; } if (theta < 0) { theta = 360 + theta; } double oldTheta = getTheta(); if ((theta < -360) || (theta > 360)) { oldTheta = oldTheta % 360; } if (theta < 0) { oldTheta = 360 + oldTheta; } float len = length(); x = len * (float) FastTrig.cos(StrictMath.toRadians(theta)); y = len * (float) FastTrig.sin(StrictMath.toRadians(theta)); // x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta)) // * (float) FastTrig.cos(StrictMath.toRadians(theta)); // y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta)) // * (float) FastTrig.sin(StrictMath.toRadians(theta)); }
[ "public", "void", "setTheta", "(", "double", "theta", ")", "{", "// Next lines are to prevent numbers like -1.8369701E-16\r", "// when working with negative numbers\r", "if", "(", "(", "theta", "<", "-", "360", ")", "||", "(", "theta", ">", "360", ")", ")", "{", "theta", "=", "theta", "%", "360", ";", "}", "if", "(", "theta", "<", "0", ")", "{", "theta", "=", "360", "+", "theta", ";", "}", "double", "oldTheta", "=", "getTheta", "(", ")", ";", "if", "(", "(", "theta", "<", "-", "360", ")", "||", "(", "theta", ">", "360", ")", ")", "{", "oldTheta", "=", "oldTheta", "%", "360", ";", "}", "if", "(", "theta", "<", "0", ")", "{", "oldTheta", "=", "360", "+", "oldTheta", ";", "}", "float", "len", "=", "length", "(", ")", ";", "x", "=", "len", "*", "(", "float", ")", "FastTrig", ".", "cos", "(", "StrictMath", ".", "toRadians", "(", "theta", ")", ")", ";", "y", "=", "len", "*", "(", "float", ")", "FastTrig", ".", "sin", "(", "StrictMath", ".", "toRadians", "(", "theta", ")", ")", ";", "//\t\tx = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))\r", "//\t\t\t\t* (float) FastTrig.cos(StrictMath.toRadians(theta));\r", "//\t\ty = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))\r", "//\t\t\t\t* (float) FastTrig.sin(StrictMath.toRadians(theta));\r", "}" ]
Calculate the components of the vectors based on a angle @param theta The angle to calculate the components from (in degrees)
[ "Calculate", "the", "components", "of", "the", "vectors", "based", "on", "a", "angle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java#L53-L78
1,606
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java
Vector2f.getTheta
public double getTheta() { double theta = StrictMath.toDegrees(StrictMath.atan2(y, x)); if ((theta < -360) || (theta > 360)) { theta = theta % 360; } if (theta < 0) { theta = 360 + theta; } return theta; }
java
public double getTheta() { double theta = StrictMath.toDegrees(StrictMath.atan2(y, x)); if ((theta < -360) || (theta > 360)) { theta = theta % 360; } if (theta < 0) { theta = 360 + theta; } return theta; }
[ "public", "double", "getTheta", "(", ")", "{", "double", "theta", "=", "StrictMath", ".", "toDegrees", "(", "StrictMath", ".", "atan2", "(", "y", ",", "x", ")", ")", ";", "if", "(", "(", "theta", "<", "-", "360", ")", "||", "(", "theta", ">", "360", ")", ")", "{", "theta", "=", "theta", "%", "360", ";", "}", "if", "(", "theta", "<", "0", ")", "{", "theta", "=", "360", "+", "theta", ";", "}", "return", "theta", ";", "}" ]
Get the angle this vector is at @return The angle this vector is at (in degrees)
[ "Get", "the", "angle", "this", "vector", "is", "at" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java#L111-L121
1,607
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java
Vector2f.add
public Vector2f add(Vector2f v) { x += v.getX(); y += v.getY(); return this; }
java
public Vector2f add(Vector2f v) { x += v.getX(); y += v.getY(); return this; }
[ "public", "Vector2f", "add", "(", "Vector2f", "v", ")", "{", "x", "+=", "v", ".", "getX", "(", ")", ";", "y", "+=", "v", ".", "getY", "(", ")", ";", "return", "this", ";", "}" ]
Add a vector to this vector @param v The vector to add @return This vector - useful for chaning operations
[ "Add", "a", "vector", "to", "this", "vector" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java#L240-L246
1,608
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java
Vector2f.sub
public Vector2f sub(Vector2f v) { x -= v.getX(); y -= v.getY(); return this; }
java
public Vector2f sub(Vector2f v) { x -= v.getX(); y -= v.getY(); return this; }
[ "public", "Vector2f", "sub", "(", "Vector2f", "v", ")", "{", "x", "-=", "v", ".", "getX", "(", ")", ";", "y", "-=", "v", ".", "getY", "(", ")", ";", "return", "this", ";", "}" ]
Subtract a vector from this vector @param v The vector subtract @return This vector - useful for chaining operations
[ "Subtract", "a", "vector", "from", "this", "vector" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java#L254-L260
1,609
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java
Vector2f.projectOntoUnit
public void projectOntoUnit(Vector2f b, Vector2f result) { float dp = b.dot(this); result.x = dp * b.getX(); result.y = dp * b.getY(); }
java
public void projectOntoUnit(Vector2f b, Vector2f result) { float dp = b.dot(this); result.x = dp * b.getX(); result.y = dp * b.getY(); }
[ "public", "void", "projectOntoUnit", "(", "Vector2f", "b", ",", "Vector2f", "result", ")", "{", "float", "dp", "=", "b", ".", "dot", "(", "this", ")", ";", "result", ".", "x", "=", "dp", "*", "b", ".", "getX", "(", ")", ";", "result", ".", "y", "=", "dp", "*", "b", ".", "getY", "(", ")", ";", "}" ]
Project this vector onto another @param b The vector to project onto @param result The projected vector
[ "Project", "this", "vector", "onto", "another" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java#L329-L335
1,610
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java
Vector2f.distanceSquared
public float distanceSquared(Vector2f other) { float dx = other.getX() - getX(); float dy = other.getY() - getY(); return (float) (dx*dx)+(dy*dy); }
java
public float distanceSquared(Vector2f other) { float dx = other.getX() - getX(); float dy = other.getY() - getY(); return (float) (dx*dx)+(dy*dy); }
[ "public", "float", "distanceSquared", "(", "Vector2f", "other", ")", "{", "float", "dx", "=", "other", ".", "getX", "(", ")", "-", "getX", "(", ")", ";", "float", "dy", "=", "other", ".", "getY", "(", ")", "-", "getY", "(", ")", ";", "return", "(", "float", ")", "(", "dx", "*", "dx", ")", "+", "(", "dy", "*", "dy", ")", ";", "}" ]
Get the distance from this point to another, squared. This can sometimes be used in place of distance and avoids the additional sqrt. @param other The other point we're measuring to @return The distance to the other point squared
[ "Get", "the", "distance", "from", "this", "point", "to", "another", "squared", ".", "This", "can", "sometimes", "be", "used", "in", "place", "of", "distance", "and", "avoids", "the", "additional", "sqrt", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Vector2f.java#L371-L376
1,611
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java
GraphEditorWindow.setLinkedEmitter
public void setLinkedEmitter(ConfigurableEmitter emitter) { // set the title Window w = SwingUtilities.windowForComponent(this); if (w instanceof Frame) ((Frame) w).setTitle("Whiskas Gradient Editor (" + emitter.name + ")"); // clear all values properties.removeAllItems(); values.clear(); panel.setInterpolator(null); enableControls(); }
java
public void setLinkedEmitter(ConfigurableEmitter emitter) { // set the title Window w = SwingUtilities.windowForComponent(this); if (w instanceof Frame) ((Frame) w).setTitle("Whiskas Gradient Editor (" + emitter.name + ")"); // clear all values properties.removeAllItems(); values.clear(); panel.setInterpolator(null); enableControls(); }
[ "public", "void", "setLinkedEmitter", "(", "ConfigurableEmitter", "emitter", ")", "{", "// set the title\r", "Window", "w", "=", "SwingUtilities", ".", "windowForComponent", "(", "this", ")", ";", "if", "(", "w", "instanceof", "Frame", ")", "(", "(", "Frame", ")", "w", ")", ".", "setTitle", "(", "\"Whiskas Gradient Editor (\"", "+", "emitter", ".", "name", "+", "\")\"", ")", ";", "// clear all values\r", "properties", ".", "removeAllItems", "(", ")", ";", "values", ".", "clear", "(", ")", ";", "panel", ".", "setInterpolator", "(", "null", ")", ";", "enableControls", "(", ")", ";", "}" ]
Set the emitter that is being controlled @param emitter The emitter that is configured by this panel
[ "Set", "the", "emitter", "that", "is", "being", "controlled" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java#L121-L133
1,612
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java
GraphEditorWindow.fireUpdated
private void fireUpdated(Object control) { if (control.equals(minSpinner)) { int minY = ((Integer) minSpinner.getValue()).intValue(); if (minY < panel.getWorldMaxY()) { panel.setWorldMinY(minY); panel.makeSureCurveFits(); panel.repaint(); } else { minSpinner.setValue(new Integer((int) panel.getWorldMinY())); } } else if (control.equals(maxSpinner)) { int maxY = ((Integer) maxSpinner.getValue()).intValue(); if (maxY > panel.getWorldMinY()) { panel.setWorldMaxY(maxY); panel.makeSureCurveFits(); panel.repaint(); } else { maxSpinner.setValue(new Integer((int) panel.getWorldMaxY())); } } }
java
private void fireUpdated(Object control) { if (control.equals(minSpinner)) { int minY = ((Integer) minSpinner.getValue()).intValue(); if (minY < panel.getWorldMaxY()) { panel.setWorldMinY(minY); panel.makeSureCurveFits(); panel.repaint(); } else { minSpinner.setValue(new Integer((int) panel.getWorldMinY())); } } else if (control.equals(maxSpinner)) { int maxY = ((Integer) maxSpinner.getValue()).intValue(); if (maxY > panel.getWorldMinY()) { panel.setWorldMaxY(maxY); panel.makeSureCurveFits(); panel.repaint(); } else { maxSpinner.setValue(new Integer((int) panel.getWorldMaxY())); } } }
[ "private", "void", "fireUpdated", "(", "Object", "control", ")", "{", "if", "(", "control", ".", "equals", "(", "minSpinner", ")", ")", "{", "int", "minY", "=", "(", "(", "Integer", ")", "minSpinner", ".", "getValue", "(", ")", ")", ".", "intValue", "(", ")", ";", "if", "(", "minY", "<", "panel", ".", "getWorldMaxY", "(", ")", ")", "{", "panel", ".", "setWorldMinY", "(", "minY", ")", ";", "panel", ".", "makeSureCurveFits", "(", ")", ";", "panel", ".", "repaint", "(", ")", ";", "}", "else", "{", "minSpinner", ".", "setValue", "(", "new", "Integer", "(", "(", "int", ")", "panel", ".", "getWorldMinY", "(", ")", ")", ")", ";", "}", "}", "else", "if", "(", "control", ".", "equals", "(", "maxSpinner", ")", ")", "{", "int", "maxY", "=", "(", "(", "Integer", ")", "maxSpinner", ".", "getValue", "(", ")", ")", ".", "intValue", "(", ")", ";", "if", "(", "maxY", ">", "panel", ".", "getWorldMinY", "(", ")", ")", "{", "panel", ".", "setWorldMaxY", "(", "maxY", ")", ";", "panel", ".", "makeSureCurveFits", "(", ")", ";", "panel", ".", "repaint", "(", ")", ";", "}", "else", "{", "maxSpinner", ".", "setValue", "(", "new", "Integer", "(", "(", "int", ")", "panel", ".", "getWorldMaxY", "(", ")", ")", ")", ";", "}", "}", "}" ]
Fire a notification that the panel has been changed @param control The source of the update
[ "Fire", "a", "notification", "that", "the", "panel", "has", "been", "changed" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java#L232-L252
1,613
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java
GraphEditorWindow.registerValue
public void registerValue(LinearInterpolator value, String name) { // add to properties combobox properties.addItem(name); // add to value map values.put(name, value); // set as current interpolator panel.setInterpolator(value); // enable all input fields enableControls(); }
java
public void registerValue(LinearInterpolator value, String name) { // add to properties combobox properties.addItem(name); // add to value map values.put(name, value); // set as current interpolator panel.setInterpolator(value); // enable all input fields enableControls(); }
[ "public", "void", "registerValue", "(", "LinearInterpolator", "value", ",", "String", "name", ")", "{", "// add to properties combobox\r", "properties", ".", "addItem", "(", "name", ")", ";", "// add to value map\r", "values", ".", "put", "(", "name", ",", "value", ")", ";", "// set as current interpolator\r", "panel", ".", "setInterpolator", "(", "value", ")", ";", "// enable all input fields\r", "enableControls", "(", ")", ";", "}" ]
Register a configurable value with the graph panel @param value The value to be registered @param name The name to display for this value
[ "Register", "a", "configurable", "value", "with", "the", "graph", "panel" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java#L260-L272
1,614
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java
GraphEditorWindow.removeValue
public void removeValue(String name) { properties.removeItem(name); values.remove(name); if (properties.getItemCount() >= 1) { properties.setSelectedIndex(0); } else { panel.setInterpolator(null); } enableControls(); }
java
public void removeValue(String name) { properties.removeItem(name); values.remove(name); if (properties.getItemCount() >= 1) { properties.setSelectedIndex(0); } else { panel.setInterpolator(null); } enableControls(); }
[ "public", "void", "removeValue", "(", "String", "name", ")", "{", "properties", ".", "removeItem", "(", "name", ")", ";", "values", ".", "remove", "(", "name", ")", ";", "if", "(", "properties", ".", "getItemCount", "(", ")", ">=", "1", ")", "{", "properties", ".", "setSelectedIndex", "(", "0", ")", ";", "}", "else", "{", "panel", ".", "setInterpolator", "(", "null", ")", ";", "}", "enableControls", "(", ")", ";", "}" ]
Remove a configurable value from the graph @param name The name of the value to be removed
[ "Remove", "a", "configurable", "value", "from", "the", "graph" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java#L289-L300
1,615
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java
GraphEditorWindow.setFirstProperty
public void setFirstProperty() { if (properties.getItemCount() > 0) { properties.setSelectedIndex(0); LinearInterpolator currentValue = (LinearInterpolator) values .get(properties.getSelectedItem()); panel.setInterpolator(currentValue); } }
java
public void setFirstProperty() { if (properties.getItemCount() > 0) { properties.setSelectedIndex(0); LinearInterpolator currentValue = (LinearInterpolator) values .get(properties.getSelectedItem()); panel.setInterpolator(currentValue); } }
[ "public", "void", "setFirstProperty", "(", ")", "{", "if", "(", "properties", ".", "getItemCount", "(", ")", ">", "0", ")", "{", "properties", ".", "setSelectedIndex", "(", "0", ")", ";", "LinearInterpolator", "currentValue", "=", "(", "LinearInterpolator", ")", "values", ".", "get", "(", "properties", ".", "getSelectedItem", "(", ")", ")", ";", "panel", ".", "setInterpolator", "(", "currentValue", ")", ";", "}", "}" ]
Indicate that the first property should be displayed
[ "Indicate", "that", "the", "first", "property", "should", "be", "displayed" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java#L305-L313
1,616
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/ScalableGame.java
ScalableGame.recalculateScale
public void recalculateScale() throws SlickException { targetWidth = container.getWidth(); targetHeight = container.getHeight(); if (maintainAspect) { boolean normalIsWide = (normalWidth / normalHeight > 1.6 ? true : false); boolean containerIsWide = ((float) targetWidth / (float) targetHeight > 1.6 ? true : false); float wScale = targetWidth / normalWidth; float hScale = targetHeight / normalHeight; if (normalIsWide & containerIsWide) { float scale = (wScale < hScale ? wScale : hScale); targetWidth = (int) (normalWidth * scale); targetHeight = (int) (normalHeight * scale); } else if (normalIsWide & !containerIsWide) { targetWidth = (int) (normalWidth * wScale); targetHeight = (int) (normalHeight * wScale); } else if (!normalIsWide & containerIsWide) { targetWidth = (int) (normalWidth * hScale); targetHeight = (int) (normalHeight * hScale); } else { float scale = (wScale < hScale ? wScale : hScale); targetWidth = (int) (normalWidth * scale); targetHeight = (int) (normalHeight * scale); } } if (held instanceof InputListener) { container.getInput().addListener((InputListener) held); } container.getInput().setScale(normalWidth / targetWidth, normalHeight / targetHeight); int yoffset = 0; int xoffset = 0; if (targetHeight < container.getHeight()) { yoffset = (container.getHeight() - targetHeight) / 2; } if (targetWidth < container.getWidth()) { xoffset = (container.getWidth() - targetWidth) / 2; } container.getInput().setOffset(-xoffset / (targetWidth / normalWidth), -yoffset / (targetHeight / normalHeight)); }
java
public void recalculateScale() throws SlickException { targetWidth = container.getWidth(); targetHeight = container.getHeight(); if (maintainAspect) { boolean normalIsWide = (normalWidth / normalHeight > 1.6 ? true : false); boolean containerIsWide = ((float) targetWidth / (float) targetHeight > 1.6 ? true : false); float wScale = targetWidth / normalWidth; float hScale = targetHeight / normalHeight; if (normalIsWide & containerIsWide) { float scale = (wScale < hScale ? wScale : hScale); targetWidth = (int) (normalWidth * scale); targetHeight = (int) (normalHeight * scale); } else if (normalIsWide & !containerIsWide) { targetWidth = (int) (normalWidth * wScale); targetHeight = (int) (normalHeight * wScale); } else if (!normalIsWide & containerIsWide) { targetWidth = (int) (normalWidth * hScale); targetHeight = (int) (normalHeight * hScale); } else { float scale = (wScale < hScale ? wScale : hScale); targetWidth = (int) (normalWidth * scale); targetHeight = (int) (normalHeight * scale); } } if (held instanceof InputListener) { container.getInput().addListener((InputListener) held); } container.getInput().setScale(normalWidth / targetWidth, normalHeight / targetHeight); int yoffset = 0; int xoffset = 0; if (targetHeight < container.getHeight()) { yoffset = (container.getHeight() - targetHeight) / 2; } if (targetWidth < container.getWidth()) { xoffset = (container.getWidth() - targetWidth) / 2; } container.getInput().setOffset(-xoffset / (targetWidth / normalWidth), -yoffset / (targetHeight / normalHeight)); }
[ "public", "void", "recalculateScale", "(", ")", "throws", "SlickException", "{", "targetWidth", "=", "container", ".", "getWidth", "(", ")", ";", "targetHeight", "=", "container", ".", "getHeight", "(", ")", ";", "if", "(", "maintainAspect", ")", "{", "boolean", "normalIsWide", "=", "(", "normalWidth", "/", "normalHeight", ">", "1.6", "?", "true", ":", "false", ")", ";", "boolean", "containerIsWide", "=", "(", "(", "float", ")", "targetWidth", "/", "(", "float", ")", "targetHeight", ">", "1.6", "?", "true", ":", "false", ")", ";", "float", "wScale", "=", "targetWidth", "/", "normalWidth", ";", "float", "hScale", "=", "targetHeight", "/", "normalHeight", ";", "if", "(", "normalIsWide", "&", "containerIsWide", ")", "{", "float", "scale", "=", "(", "wScale", "<", "hScale", "?", "wScale", ":", "hScale", ")", ";", "targetWidth", "=", "(", "int", ")", "(", "normalWidth", "*", "scale", ")", ";", "targetHeight", "=", "(", "int", ")", "(", "normalHeight", "*", "scale", ")", ";", "}", "else", "if", "(", "normalIsWide", "&", "!", "containerIsWide", ")", "{", "targetWidth", "=", "(", "int", ")", "(", "normalWidth", "*", "wScale", ")", ";", "targetHeight", "=", "(", "int", ")", "(", "normalHeight", "*", "wScale", ")", ";", "}", "else", "if", "(", "!", "normalIsWide", "&", "containerIsWide", ")", "{", "targetWidth", "=", "(", "int", ")", "(", "normalWidth", "*", "hScale", ")", ";", "targetHeight", "=", "(", "int", ")", "(", "normalHeight", "*", "hScale", ")", ";", "}", "else", "{", "float", "scale", "=", "(", "wScale", "<", "hScale", "?", "wScale", ":", "hScale", ")", ";", "targetWidth", "=", "(", "int", ")", "(", "normalWidth", "*", "scale", ")", ";", "targetHeight", "=", "(", "int", ")", "(", "normalHeight", "*", "scale", ")", ";", "}", "}", "if", "(", "held", "instanceof", "InputListener", ")", "{", "container", ".", "getInput", "(", ")", ".", "addListener", "(", "(", "InputListener", ")", "held", ")", ";", "}", "container", ".", "getInput", "(", ")", ".", "setScale", "(", "normalWidth", "/", "targetWidth", ",", "normalHeight", "/", "targetHeight", ")", ";", "int", "yoffset", "=", "0", ";", "int", "xoffset", "=", "0", ";", "if", "(", "targetHeight", "<", "container", ".", "getHeight", "(", ")", ")", "{", "yoffset", "=", "(", "container", ".", "getHeight", "(", ")", "-", "targetHeight", ")", "/", "2", ";", "}", "if", "(", "targetWidth", "<", "container", ".", "getWidth", "(", ")", ")", "{", "xoffset", "=", "(", "container", ".", "getWidth", "(", ")", "-", "targetWidth", ")", "/", "2", ";", "}", "container", ".", "getInput", "(", ")", ".", "setOffset", "(", "-", "xoffset", "/", "(", "targetWidth", "/", "normalWidth", ")", ",", "-", "yoffset", "/", "(", "targetHeight", "/", "normalHeight", ")", ")", ";", "}" ]
Recalculate the scale of the game @throws SlickException Indicates a failure to reinit the game
[ "Recalculate", "the", "scale", "of", "the", "game" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/ScalableGame.java#L77-L124
1,617
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/state/StateBasedGame.java
StateBasedGame.addState
public void addState(GameState state) { states.put(new Integer(state.getID()), state); if (currentState.getID() == -1) { currentState = state; } }
java
public void addState(GameState state) { states.put(new Integer(state.getID()), state); if (currentState.getID() == -1) { currentState = state; } }
[ "public", "void", "addState", "(", "GameState", "state", ")", "{", "states", ".", "put", "(", "new", "Integer", "(", "state", ".", "getID", "(", ")", ")", ",", "state", ")", ";", "if", "(", "currentState", ".", "getID", "(", ")", "==", "-", "1", ")", "{", "currentState", "=", "state", ";", "}", "}" ]
Add a state to the game. The state will be updated and maintained by the game @param state The state to be added
[ "Add", "a", "state", "to", "the", "game", ".", "The", "state", "will", "be", "updated", "and", "maintained", "by", "the", "game" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/state/StateBasedGame.java#L107-L113
1,618
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/state/StateBasedGame.java
StateBasedGame.enterState
public void enterState(int id, Transition leave, Transition enter) { if (leave == null) { leave = new EmptyTransition(); } if (enter == null) { enter = new EmptyTransition(); } leaveTransition = leave; enterTransition = enter; nextState = getState(id); if (nextState == null) { throw new RuntimeException("No game state registered with the ID: "+id); } leaveTransition.init(currentState, nextState); }
java
public void enterState(int id, Transition leave, Transition enter) { if (leave == null) { leave = new EmptyTransition(); } if (enter == null) { enter = new EmptyTransition(); } leaveTransition = leave; enterTransition = enter; nextState = getState(id); if (nextState == null) { throw new RuntimeException("No game state registered with the ID: "+id); } leaveTransition.init(currentState, nextState); }
[ "public", "void", "enterState", "(", "int", "id", ",", "Transition", "leave", ",", "Transition", "enter", ")", "{", "if", "(", "leave", "==", "null", ")", "{", "leave", "=", "new", "EmptyTransition", "(", ")", ";", "}", "if", "(", "enter", "==", "null", ")", "{", "enter", "=", "new", "EmptyTransition", "(", ")", ";", "}", "leaveTransition", "=", "leave", ";", "enterTransition", "=", "enter", ";", "nextState", "=", "getState", "(", "id", ")", ";", "if", "(", "nextState", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"No game state registered with the ID: \"", "+", "id", ")", ";", "}", "leaveTransition", ".", "init", "(", "currentState", ",", "nextState", ")", ";", "}" ]
Enter a particular game state with the transitions provided @param id The ID of the state to enter @param leave The transition to use when leaving the current state @param enter The transition to use when entering the new state
[ "Enter", "a", "particular", "game", "state", "with", "the", "transitions", "provided" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/state/StateBasedGame.java#L141-L157
1,619
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/ImageBuffer.java
ImageBuffer.setRGBA
public void setRGBA(int x, int y, int r, int g, int b, int a) { if ((x < 0) || (x >= width) || (y < 0) || (y >= height)) { throw new RuntimeException("Specified location: "+x+","+y+" outside of image"); } int ofs = ((x + (y * texWidth)) * 4); if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) { rawData[ofs] = (byte) b; rawData[ofs + 1] = (byte) g; rawData[ofs + 2] = (byte) r; rawData[ofs + 3] = (byte) a; } else { rawData[ofs] = (byte) r; rawData[ofs + 1] = (byte) g; rawData[ofs + 2] = (byte) b; rawData[ofs + 3] = (byte) a; } }
java
public void setRGBA(int x, int y, int r, int g, int b, int a) { if ((x < 0) || (x >= width) || (y < 0) || (y >= height)) { throw new RuntimeException("Specified location: "+x+","+y+" outside of image"); } int ofs = ((x + (y * texWidth)) * 4); if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) { rawData[ofs] = (byte) b; rawData[ofs + 1] = (byte) g; rawData[ofs + 2] = (byte) r; rawData[ofs + 3] = (byte) a; } else { rawData[ofs] = (byte) r; rawData[ofs + 1] = (byte) g; rawData[ofs + 2] = (byte) b; rawData[ofs + 3] = (byte) a; } }
[ "public", "void", "setRGBA", "(", "int", "x", ",", "int", "y", ",", "int", "r", ",", "int", "g", ",", "int", "b", ",", "int", "a", ")", "{", "if", "(", "(", "x", "<", "0", ")", "||", "(", "x", ">=", "width", ")", "||", "(", "y", "<", "0", ")", "||", "(", "y", ">=", "height", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Specified location: \"", "+", "x", "+", "\",\"", "+", "y", "+", "\" outside of image\"", ")", ";", "}", "int", "ofs", "=", "(", "(", "x", "+", "(", "y", "*", "texWidth", ")", ")", "*", "4", ")", ";", "if", "(", "ByteOrder", ".", "nativeOrder", "(", ")", "==", "ByteOrder", ".", "BIG_ENDIAN", ")", "{", "rawData", "[", "ofs", "]", "=", "(", "byte", ")", "b", ";", "rawData", "[", "ofs", "+", "1", "]", "=", "(", "byte", ")", "g", ";", "rawData", "[", "ofs", "+", "2", "]", "=", "(", "byte", ")", "r", ";", "rawData", "[", "ofs", "+", "3", "]", "=", "(", "byte", ")", "a", ";", "}", "else", "{", "rawData", "[", "ofs", "]", "=", "(", "byte", ")", "r", ";", "rawData", "[", "ofs", "+", "1", "]", "=", "(", "byte", ")", "g", ";", "rawData", "[", "ofs", "+", "2", "]", "=", "(", "byte", ")", "b", ";", "rawData", "[", "ofs", "+", "3", "]", "=", "(", "byte", ")", "a", ";", "}", "}" ]
Set a pixel in the image buffer @param x The x position of the pixel to set @param y The y position of the pixel to set @param r The red component to set (0->255) @param g The green component to set (0->255) @param b The blue component to set (0->255) @param a The alpha component to set (0->255)
[ "Set", "a", "pixel", "in", "the", "image", "buffer" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/ImageBuffer.java#L114-L132
1,620
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java
GradientEditor.fireUpdate
private void fireUpdate() { ActionEvent event = new ActionEvent(this,0,""); for (int i=0;i<listeners.size();i++) { ((ActionListener) listeners.get(i)).actionPerformed(event); } }
java
private void fireUpdate() { ActionEvent event = new ActionEvent(this,0,""); for (int i=0;i<listeners.size();i++) { ((ActionListener) listeners.get(i)).actionPerformed(event); } }
[ "private", "void", "fireUpdate", "(", ")", "{", "ActionEvent", "event", "=", "new", "ActionEvent", "(", "this", ",", "0", ",", "\"\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "size", "(", ")", ";", "i", "++", ")", "{", "(", "(", "ActionListener", ")", "listeners", ".", "get", "(", "i", ")", ")", ".", "actionPerformed", "(", "event", ")", ";", "}", "}" ]
Fire an update to all listeners
[ "Fire", "an", "update", "to", "all", "listeners" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java#L149-L154
1,621
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java
GradientEditor.checkPoint
private boolean checkPoint(int mx, int my, ControlPoint pt) { int dx = (int) Math.abs((10+(width * pt.pos)) - mx); int dy = Math.abs((y+barHeight+7)-my); if ((dx < 5) && (dy < 7)) { return true; } return false; }
java
private boolean checkPoint(int mx, int my, ControlPoint pt) { int dx = (int) Math.abs((10+(width * pt.pos)) - mx); int dy = Math.abs((y+barHeight+7)-my); if ((dx < 5) && (dy < 7)) { return true; } return false; }
[ "private", "boolean", "checkPoint", "(", "int", "mx", ",", "int", "my", ",", "ControlPoint", "pt", ")", "{", "int", "dx", "=", "(", "int", ")", "Math", ".", "abs", "(", "(", "10", "+", "(", "width", "*", "pt", ".", "pos", ")", ")", "-", "mx", ")", ";", "int", "dy", "=", "Math", ".", "abs", "(", "(", "y", "+", "barHeight", "+", "7", ")", "-", "my", ")", ";", "if", "(", "(", "dx", "<", "5", ")", "&&", "(", "dy", "<", "7", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if there is a control point at the specified mouse location @param mx The mouse x coordinate @param my The mouse y coordinate @param pt The point to check agianst @return True if the mouse point conincides with the control point
[ "Check", "if", "there", "is", "a", "control", "point", "at", "the", "specified", "mouse", "location" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java#L164-L173
1,622
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java
GradientEditor.addPoint
private void addPoint() { ControlPoint point = new ControlPoint(Color.white, 0.5f); for (int i=0;i<list.size()-1;i++) { ControlPoint now = (ControlPoint) list.get(i); ControlPoint next = (ControlPoint) list.get(i+1); if ((now.pos <= 0.5f) && (next.pos >=0.5f)) { list.add(i+1,point); break; } } selected = point; sortPoints(); repaint(0); fireUpdate(); }
java
private void addPoint() { ControlPoint point = new ControlPoint(Color.white, 0.5f); for (int i=0;i<list.size()-1;i++) { ControlPoint now = (ControlPoint) list.get(i); ControlPoint next = (ControlPoint) list.get(i+1); if ((now.pos <= 0.5f) && (next.pos >=0.5f)) { list.add(i+1,point); break; } } selected = point; sortPoints(); repaint(0); fireUpdate(); }
[ "private", "void", "addPoint", "(", ")", "{", "ControlPoint", "point", "=", "new", "ControlPoint", "(", "Color", ".", "white", ",", "0.5f", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "size", "(", ")", "-", "1", ";", "i", "++", ")", "{", "ControlPoint", "now", "=", "(", "ControlPoint", ")", "list", ".", "get", "(", "i", ")", ";", "ControlPoint", "next", "=", "(", "ControlPoint", ")", "list", ".", "get", "(", "i", "+", "1", ")", ";", "if", "(", "(", "now", ".", "pos", "<=", "0.5f", ")", "&&", "(", "next", ".", "pos", ">=", "0.5f", ")", ")", "{", "list", ".", "add", "(", "i", "+", "1", ",", "point", ")", ";", "break", ";", "}", "}", "selected", "=", "point", ";", "sortPoints", "(", ")", ";", "repaint", "(", "0", ")", ";", "fireUpdate", "(", ")", ";", "}" ]
Add a new control point
[ "Add", "a", "new", "control", "point" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java#L178-L194
1,623
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java
GradientEditor.sortPoints
private void sortPoints() { final ControlPoint firstPt = (ControlPoint)list.get(0); final ControlPoint lastPt = (ControlPoint)list.get(list.size()-1); Comparator compare = new Comparator() { public int compare(Object first, Object second) { if (first == firstPt) { return -1; } if (second == lastPt) { return -1; } float a = ((ControlPoint) first).pos; float b = ((ControlPoint) second).pos; return (int) ((a-b) * 10000); } }; Collections.sort(list, compare); }
java
private void sortPoints() { final ControlPoint firstPt = (ControlPoint)list.get(0); final ControlPoint lastPt = (ControlPoint)list.get(list.size()-1); Comparator compare = new Comparator() { public int compare(Object first, Object second) { if (first == firstPt) { return -1; } if (second == lastPt) { return -1; } float a = ((ControlPoint) first).pos; float b = ((ControlPoint) second).pos; return (int) ((a-b) * 10000); } }; Collections.sort(list, compare); }
[ "private", "void", "sortPoints", "(", ")", "{", "final", "ControlPoint", "firstPt", "=", "(", "ControlPoint", ")", "list", ".", "get", "(", "0", ")", ";", "final", "ControlPoint", "lastPt", "=", "(", "ControlPoint", ")", "list", ".", "get", "(", "list", ".", "size", "(", ")", "-", "1", ")", ";", "Comparator", "compare", "=", "new", "Comparator", "(", ")", "{", "public", "int", "compare", "(", "Object", "first", ",", "Object", "second", ")", "{", "if", "(", "first", "==", "firstPt", ")", "{", "return", "-", "1", ";", "}", "if", "(", "second", "==", "lastPt", ")", "{", "return", "-", "1", ";", "}", "float", "a", "=", "(", "(", "ControlPoint", ")", "first", ")", ".", "pos", ";", "float", "b", "=", "(", "(", "ControlPoint", ")", "second", ")", ".", "pos", ";", "return", "(", "int", ")", "(", "(", "a", "-", "b", ")", "*", "10000", ")", ";", "}", "}", ";", "Collections", ".", "sort", "(", "list", ",", "compare", ")", ";", "}" ]
Sort the control points based on their position
[ "Sort", "the", "control", "points", "based", "on", "their", "position" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java#L199-L217
1,624
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java
GradientEditor.editPoint
private void editPoint() { if (selected == null) { return; } Color col = JColorChooser.showDialog(this, "Select Color", selected.col); if (col != null) { selected.col = col; repaint(0); fireUpdate(); } }
java
private void editPoint() { if (selected == null) { return; } Color col = JColorChooser.showDialog(this, "Select Color", selected.col); if (col != null) { selected.col = col; repaint(0); fireUpdate(); } }
[ "private", "void", "editPoint", "(", ")", "{", "if", "(", "selected", "==", "null", ")", "{", "return", ";", "}", "Color", "col", "=", "JColorChooser", ".", "showDialog", "(", "this", ",", "\"Select Color\"", ",", "selected", ".", "col", ")", ";", "if", "(", "col", "!=", "null", ")", "{", "selected", ".", "col", "=", "col", ";", "repaint", "(", "0", ")", ";", "fireUpdate", "(", ")", ";", "}", "}" ]
Edit the currently selected control point
[ "Edit", "the", "currently", "selected", "control", "point" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java#L223-L233
1,625
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java
GradientEditor.selectPoint
private void selectPoint(int mx, int my) { if (!isEnabled()) { return; } for (int i=1;i<list.size()-1;i++) { if (checkPoint(mx,my,(ControlPoint) list.get(i))) { selected = (ControlPoint) list.get(i); return; } } if (checkPoint(mx,my,(ControlPoint) list.get(0))) { selected = (ControlPoint) list.get(0); return; } if (checkPoint(mx,my,(ControlPoint) list.get(list.size()-1))) { selected = (ControlPoint) list.get(list.size()-1); return; } selected = null; }
java
private void selectPoint(int mx, int my) { if (!isEnabled()) { return; } for (int i=1;i<list.size()-1;i++) { if (checkPoint(mx,my,(ControlPoint) list.get(i))) { selected = (ControlPoint) list.get(i); return; } } if (checkPoint(mx,my,(ControlPoint) list.get(0))) { selected = (ControlPoint) list.get(0); return; } if (checkPoint(mx,my,(ControlPoint) list.get(list.size()-1))) { selected = (ControlPoint) list.get(list.size()-1); return; } selected = null; }
[ "private", "void", "selectPoint", "(", "int", "mx", ",", "int", "my", ")", "{", "if", "(", "!", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "for", "(", "int", "i", "=", "1", ";", "i", "<", "list", ".", "size", "(", ")", "-", "1", ";", "i", "++", ")", "{", "if", "(", "checkPoint", "(", "mx", ",", "my", ",", "(", "ControlPoint", ")", "list", ".", "get", "(", "i", ")", ")", ")", "{", "selected", "=", "(", "ControlPoint", ")", "list", ".", "get", "(", "i", ")", ";", "return", ";", "}", "}", "if", "(", "checkPoint", "(", "mx", ",", "my", ",", "(", "ControlPoint", ")", "list", ".", "get", "(", "0", ")", ")", ")", "{", "selected", "=", "(", "ControlPoint", ")", "list", ".", "get", "(", "0", ")", ";", "return", ";", "}", "if", "(", "checkPoint", "(", "mx", ",", "my", ",", "(", "ControlPoint", ")", "list", ".", "get", "(", "list", ".", "size", "(", ")", "-", "1", ")", ")", ")", "{", "selected", "=", "(", "ControlPoint", ")", "list", ".", "get", "(", "list", ".", "size", "(", ")", "-", "1", ")", ";", "return", ";", "}", "selected", "=", "null", ";", "}" ]
Select the control point at the specified mouse coordinate @param mx The mouse x coordinate @param my The mouse y coordinate
[ "Select", "the", "control", "point", "at", "the", "specified", "mouse", "coordinate" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java#L241-L262
1,626
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java
GradientEditor.delPoint
private void delPoint() { if (!isEnabled()) { return; } if (selected == null) { return; } if (list.indexOf(selected) == 0) { return; } if (list.indexOf(selected) == list.size()-1) { return; } list.remove(selected); sortPoints(); repaint(0); fireUpdate(); }
java
private void delPoint() { if (!isEnabled()) { return; } if (selected == null) { return; } if (list.indexOf(selected) == 0) { return; } if (list.indexOf(selected) == list.size()-1) { return; } list.remove(selected); sortPoints(); repaint(0); fireUpdate(); }
[ "private", "void", "delPoint", "(", ")", "{", "if", "(", "!", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "if", "(", "selected", "==", "null", ")", "{", "return", ";", "}", "if", "(", "list", ".", "indexOf", "(", "selected", ")", "==", "0", ")", "{", "return", ";", "}", "if", "(", "list", ".", "indexOf", "(", "selected", ")", "==", "list", ".", "size", "(", ")", "-", "1", ")", "{", "return", ";", "}", "list", ".", "remove", "(", "selected", ")", ";", "sortPoints", "(", ")", ";", "repaint", "(", "0", ")", ";", "fireUpdate", "(", ")", ";", "}" ]
Delete the currently selected point
[ "Delete", "the", "currently", "selected", "point" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java#L267-L286
1,627
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java
GradientEditor.movePoint
private void movePoint(int mx, int my) { if (!isEnabled()) { return; } if (selected == null) { return; } if (list.indexOf(selected) == 0) { return; } if (list.indexOf(selected) == list.size()-1) { return; } float newPos = (mx - 10) / (float) width; newPos = Math.min(1, newPos); newPos = Math.max(0, newPos); selected.pos = newPos; sortPoints(); fireUpdate(); }
java
private void movePoint(int mx, int my) { if (!isEnabled()) { return; } if (selected == null) { return; } if (list.indexOf(selected) == 0) { return; } if (list.indexOf(selected) == list.size()-1) { return; } float newPos = (mx - 10) / (float) width; newPos = Math.min(1, newPos); newPos = Math.max(0, newPos); selected.pos = newPos; sortPoints(); fireUpdate(); }
[ "private", "void", "movePoint", "(", "int", "mx", ",", "int", "my", ")", "{", "if", "(", "!", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "if", "(", "selected", "==", "null", ")", "{", "return", ";", "}", "if", "(", "list", ".", "indexOf", "(", "selected", ")", "==", "0", ")", "{", "return", ";", "}", "if", "(", "list", ".", "indexOf", "(", "selected", ")", "==", "list", ".", "size", "(", ")", "-", "1", ")", "{", "return", ";", "}", "float", "newPos", "=", "(", "mx", "-", "10", ")", "/", "(", "float", ")", "width", ";", "newPos", "=", "Math", ".", "min", "(", "1", ",", "newPos", ")", ";", "newPos", "=", "Math", ".", "max", "(", "0", ",", "newPos", ")", ";", "selected", ".", "pos", "=", "newPos", ";", "sortPoints", "(", ")", ";", "fireUpdate", "(", ")", ";", "}" ]
Move the current point to the specified mouse location @param mx The x coordinate of the mouse @param my The y coordinate of teh mouse
[ "Move", "the", "current", "point", "to", "the", "specified", "mouse", "location" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java#L294-L316
1,628
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java
GradientEditor.addPoint
public void addPoint(float pos, Color col) { ControlPoint point = new ControlPoint(col, pos); for (int i=0;i<list.size()-1;i++) { ControlPoint now = (ControlPoint) list.get(i); ControlPoint next = (ControlPoint) list.get(i+1); if ((now.pos <= 0.5f) && (next.pos >=0.5f)) { list.add(i+1,point); break; } } repaint(0); }
java
public void addPoint(float pos, Color col) { ControlPoint point = new ControlPoint(col, pos); for (int i=0;i<list.size()-1;i++) { ControlPoint now = (ControlPoint) list.get(i); ControlPoint next = (ControlPoint) list.get(i+1); if ((now.pos <= 0.5f) && (next.pos >=0.5f)) { list.add(i+1,point); break; } } repaint(0); }
[ "public", "void", "addPoint", "(", "float", "pos", ",", "Color", "col", ")", "{", "ControlPoint", "point", "=", "new", "ControlPoint", "(", "col", ",", "pos", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "size", "(", ")", "-", "1", ";", "i", "++", ")", "{", "ControlPoint", "now", "=", "(", "ControlPoint", ")", "list", ".", "get", "(", "i", ")", ";", "ControlPoint", "next", "=", "(", "ControlPoint", ")", "list", ".", "get", "(", "i", "+", "1", ")", ";", "if", "(", "(", "now", ".", "pos", "<=", "0.5f", ")", "&&", "(", "next", ".", "pos", ">=", "0.5f", ")", ")", "{", "list", ".", "add", "(", "i", "+", "1", ",", "point", ")", ";", "break", ";", "}", "}", "repaint", "(", "0", ")", ";", "}" ]
Add a control point to the gradient @param pos The position in the gradient (0 -> 1) @param col The color at the new control point
[ "Add", "a", "control", "point", "to", "the", "gradient" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java#L364-L375
1,629
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java
GradientEditor.setEnd
public void setEnd(Color col) { ((ControlPoint) list.get(list.size()-1)).col = col; repaint(0); }
java
public void setEnd(Color col) { ((ControlPoint) list.get(list.size()-1)).col = col; repaint(0); }
[ "public", "void", "setEnd", "(", "Color", "col", ")", "{", "(", "(", "ControlPoint", ")", "list", ".", "get", "(", "list", ".", "size", "(", ")", "-", "1", ")", ")", ".", "col", "=", "col", ";", "repaint", "(", "0", ")", ";", "}" ]
Set the ending colour @param col The color at the end of the gradient
[ "Set", "the", "ending", "colour" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java#L392-L395
1,630
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/loading/LoadingList.java
LoadingList.remove
public void remove(DeferredResource resource) { Log.info("Early loading of deferred resource due to req: "+resource.getDescription()); total--; deferred.remove(resource); }
java
public void remove(DeferredResource resource) { Log.info("Early loading of deferred resource due to req: "+resource.getDescription()); total--; deferred.remove(resource); }
[ "public", "void", "remove", "(", "DeferredResource", "resource", ")", "{", "Log", ".", "info", "(", "\"Early loading of deferred resource due to req: \"", "+", "resource", ".", "getDescription", "(", ")", ")", ";", "total", "--", ";", "deferred", ".", "remove", "(", "resource", ")", ";", "}" ]
Remove a resource from the list that has been loaded for other reasons. @param resource The resource to remove
[ "Remove", "a", "resource", "from", "the", "list", "that", "has", "been", "loaded", "for", "other", "reasons", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/loading/LoadingList.java#L76-L80
1,631
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/Log.java
Log.checkVerboseLogSetting
public static void checkVerboseLogSetting() { try { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String val = System.getProperty(Log.forceVerboseProperty); if ((val != null) && (val.equalsIgnoreCase(Log.forceVerbosePropertyOnValue))) { Log.setForcedVerboseOn(); } return null; } }); } catch (Throwable e) { // ignore, security failure - probably an applet } }
java
public static void checkVerboseLogSetting() { try { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String val = System.getProperty(Log.forceVerboseProperty); if ((val != null) && (val.equalsIgnoreCase(Log.forceVerbosePropertyOnValue))) { Log.setForcedVerboseOn(); } return null; } }); } catch (Throwable e) { // ignore, security failure - probably an applet } }
[ "public", "static", "void", "checkVerboseLogSetting", "(", ")", "{", "try", "{", "AccessController", ".", "doPrivileged", "(", "new", "PrivilegedAction", "(", ")", "{", "public", "Object", "run", "(", ")", "{", "String", "val", "=", "System", ".", "getProperty", "(", "Log", ".", "forceVerboseProperty", ")", ";", "if", "(", "(", "val", "!=", "null", ")", "&&", "(", "val", ".", "equalsIgnoreCase", "(", "Log", ".", "forceVerbosePropertyOnValue", ")", ")", ")", "{", "Log", ".", "setForcedVerboseOn", "(", ")", ";", "}", "return", "null", ";", "}", "}", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "// ignore, security failure - probably an applet\r", "}", "}" ]
Check if the system property org.newdawn.slick.verboseLog is set to true. If this is the case we activate the verbose logging mode
[ "Check", "if", "the", "system", "property", "org", ".", "newdawn", ".", "slick", ".", "verboseLog", "is", "set", "to", "true", ".", "If", "this", "is", "the", "case", "we", "activate", "the", "verbose", "logging", "mode" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/Log.java#L66-L81
1,632
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java
MorphShape.addShape
public void addShape(Shape shape) { if (shape.points.length != points.length) { throw new RuntimeException("Attempt to morph between two shapes with different vertex counts"); } Shape prev = (Shape) shapes.get(shapes.size()-1); if (equalShapes(prev, shape)) { shapes.add(prev); } else { shapes.add(shape); } if (shapes.size() == 2) { next = (Shape) shapes.get(1); } }
java
public void addShape(Shape shape) { if (shape.points.length != points.length) { throw new RuntimeException("Attempt to morph between two shapes with different vertex counts"); } Shape prev = (Shape) shapes.get(shapes.size()-1); if (equalShapes(prev, shape)) { shapes.add(prev); } else { shapes.add(shape); } if (shapes.size() == 2) { next = (Shape) shapes.get(1); } }
[ "public", "void", "addShape", "(", "Shape", "shape", ")", "{", "if", "(", "shape", ".", "points", ".", "length", "!=", "points", ".", "length", ")", "{", "throw", "new", "RuntimeException", "(", "\"Attempt to morph between two shapes with different vertex counts\"", ")", ";", "}", "Shape", "prev", "=", "(", "Shape", ")", "shapes", ".", "get", "(", "shapes", ".", "size", "(", ")", "-", "1", ")", ";", "if", "(", "equalShapes", "(", "prev", ",", "shape", ")", ")", "{", "shapes", ".", "add", "(", "prev", ")", ";", "}", "else", "{", "shapes", ".", "add", "(", "shape", ")", ";", "}", "if", "(", "shapes", ".", "size", "(", ")", "==", "2", ")", "{", "next", "=", "(", "Shape", ")", "shapes", ".", "get", "(", "1", ")", ";", "}", "}" ]
Add a subsequent shape that we should morph too in order @param shape The new shape that forms part of the morphing shape
[ "Add", "a", "subsequent", "shape", "that", "we", "should", "morph", "too", "in", "order" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java#L40-L55
1,633
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java
MorphShape.equalShapes
private boolean equalShapes(Shape a, Shape b) { a.checkPoints(); b.checkPoints(); for (int i=0;i<a.points.length;i++) { if (a.points[i] != b.points[i]) { return false; } } return true; }
java
private boolean equalShapes(Shape a, Shape b) { a.checkPoints(); b.checkPoints(); for (int i=0;i<a.points.length;i++) { if (a.points[i] != b.points[i]) { return false; } } return true; }
[ "private", "boolean", "equalShapes", "(", "Shape", "a", ",", "Shape", "b", ")", "{", "a", ".", "checkPoints", "(", ")", ";", "b", ".", "checkPoints", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "a", ".", "points", ".", "length", ";", "i", "++", ")", "{", "if", "(", "a", ".", "points", "[", "i", "]", "!=", "b", ".", "points", "[", "i", "]", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Check if the shape's points are all equal @param a The first shape to compare @param b The second shape to compare @return True if the shapes are equal
[ "Check", "if", "the", "shape", "s", "points", "are", "all", "equal" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java#L64-L75
1,634
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java
MorphShape.setMorphTime
public void setMorphTime(float time) { int p = (int) time; int n = p + 1; float offset = time - p; p = rational(p); n = rational(n); setFrame(p, n, offset); }
java
public void setMorphTime(float time) { int p = (int) time; int n = p + 1; float offset = time - p; p = rational(p); n = rational(n); setFrame(p, n, offset); }
[ "public", "void", "setMorphTime", "(", "float", "time", ")", "{", "int", "p", "=", "(", "int", ")", "time", ";", "int", "n", "=", "p", "+", "1", ";", "float", "offset", "=", "time", "-", "p", ";", "p", "=", "rational", "(", "p", ")", ";", "n", "=", "rational", "(", "n", ")", ";", "setFrame", "(", "p", ",", "n", ",", "offset", ")", ";", "}" ]
Set the "time" index for this morph. This is given in terms of shapes, so 0.5f would give you the position half way between the first and second shapes. @param time The time index to represent on this shape
[ "Set", "the", "time", "index", "for", "this", "morph", ".", "This", "is", "given", "in", "terms", "of", "shapes", "so", "0", ".", "5f", "would", "give", "you", "the", "position", "half", "way", "between", "the", "first", "and", "second", "shapes", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java#L83-L92
1,635
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java
MorphShape.updateMorphTime
public void updateMorphTime(float delta) { offset += delta; if (offset < 0) { int index = shapes.indexOf(current); if (index < 0) { index = shapes.size() - 1; } int nframe = rational(index+1); setFrame(index, nframe, offset); offset += 1; } else if (offset > 1) { int index = shapes.indexOf(next); if (index < 1) { index = 0; } int nframe = rational(index+1); setFrame(index, nframe, offset); offset -= 1; } else { pointsDirty = true; } }
java
public void updateMorphTime(float delta) { offset += delta; if (offset < 0) { int index = shapes.indexOf(current); if (index < 0) { index = shapes.size() - 1; } int nframe = rational(index+1); setFrame(index, nframe, offset); offset += 1; } else if (offset > 1) { int index = shapes.indexOf(next); if (index < 1) { index = 0; } int nframe = rational(index+1); setFrame(index, nframe, offset); offset -= 1; } else { pointsDirty = true; } }
[ "public", "void", "updateMorphTime", "(", "float", "delta", ")", "{", "offset", "+=", "delta", ";", "if", "(", "offset", "<", "0", ")", "{", "int", "index", "=", "shapes", ".", "indexOf", "(", "current", ")", ";", "if", "(", "index", "<", "0", ")", "{", "index", "=", "shapes", ".", "size", "(", ")", "-", "1", ";", "}", "int", "nframe", "=", "rational", "(", "index", "+", "1", ")", ";", "setFrame", "(", "index", ",", "nframe", ",", "offset", ")", ";", "offset", "+=", "1", ";", "}", "else", "if", "(", "offset", ">", "1", ")", "{", "int", "index", "=", "shapes", ".", "indexOf", "(", "next", ")", ";", "if", "(", "index", "<", "1", ")", "{", "index", "=", "0", ";", "}", "int", "nframe", "=", "rational", "(", "index", "+", "1", ")", ";", "setFrame", "(", "index", ",", "nframe", ",", "offset", ")", ";", "offset", "-=", "1", ";", "}", "else", "{", "pointsDirty", "=", "true", ";", "}", "}" ]
Update the morph time and hence the curent frame @param delta The amount to change the morph time by
[ "Update", "the", "morph", "time", "and", "hence", "the", "curent", "frame" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java#L99-L122
1,636
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java
MorphShape.setExternalFrame
public void setExternalFrame(Shape current) { this.current = current; next = (Shape) shapes.get(0); offset = 0; }
java
public void setExternalFrame(Shape current) { this.current = current; next = (Shape) shapes.get(0); offset = 0; }
[ "public", "void", "setExternalFrame", "(", "Shape", "current", ")", "{", "this", ".", "current", "=", "current", ";", "next", "=", "(", "Shape", ")", "shapes", ".", "get", "(", "0", ")", ";", "offset", "=", "0", ";", "}" ]
Set the current frame @param current The current frame
[ "Set", "the", "current", "frame" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java#L129-L133
1,637
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java
MorphShape.rational
private int rational(int n) { while (n >= shapes.size()) { n -= shapes.size(); } while (n < 0) { n += shapes.size(); } return n; }
java
private int rational(int n) { while (n >= shapes.size()) { n -= shapes.size(); } while (n < 0) { n += shapes.size(); } return n; }
[ "private", "int", "rational", "(", "int", "n", ")", "{", "while", "(", "n", ">=", "shapes", ".", "size", "(", ")", ")", "{", "n", "-=", "shapes", ".", "size", "(", ")", ";", "}", "while", "(", "n", "<", "0", ")", "{", "n", "+=", "shapes", ".", "size", "(", ")", ";", "}", "return", "n", ";", "}" ]
Get an index that is rational, i.e. fits inside this set of shapes @param n The index to rationalize @return The index rationalized
[ "Get", "an", "index", "that", "is", "rational", "i", ".", "e", ".", "fits", "inside", "this", "set", "of", "shapes" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java#L141-L150
1,638
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java
MorphShape.setFrame
private void setFrame(int a, int b, float offset) { current = (Shape) shapes.get(a); next = (Shape) shapes.get(b); this.offset = offset; pointsDirty = true; }
java
private void setFrame(int a, int b, float offset) { current = (Shape) shapes.get(a); next = (Shape) shapes.get(b); this.offset = offset; pointsDirty = true; }
[ "private", "void", "setFrame", "(", "int", "a", ",", "int", "b", ",", "float", "offset", ")", "{", "current", "=", "(", "Shape", ")", "shapes", ".", "get", "(", "a", ")", ";", "next", "=", "(", "Shape", ")", "shapes", ".", "get", "(", "b", ")", ";", "this", ".", "offset", "=", "offset", ";", "pointsDirty", "=", "true", ";", "}" ]
Set the frame to be represented @param a The index of the first shape @param b The index of the second shape @param offset The offset between the two shapes to represent
[ "Set", "the", "frame", "to", "be", "represented" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/MorphShape.java#L159-L164
1,639
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/InkscapeLoader.java
InkscapeLoader.loadElement
private void loadElement(Element element, Transform t) throws ParsingException { for (int i = 0; i < processors.size(); i++) { ElementProcessor processor = (ElementProcessor) processors.get(i); if (processor.handles(element)) { processor.process(this, element, diagram, t); } } }
java
private void loadElement(Element element, Transform t) throws ParsingException { for (int i = 0; i < processors.size(); i++) { ElementProcessor processor = (ElementProcessor) processors.get(i); if (processor.handles(element)) { processor.process(this, element, diagram, t); } } }
[ "private", "void", "loadElement", "(", "Element", "element", ",", "Transform", "t", ")", "throws", "ParsingException", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "processors", ".", "size", "(", ")", ";", "i", "++", ")", "{", "ElementProcessor", "processor", "=", "(", "ElementProcessor", ")", "processors", ".", "get", "(", "i", ")", ";", "if", "(", "processor", ".", "handles", "(", "element", ")", ")", "{", "processor", ".", "process", "(", "this", ",", "element", ",", "diagram", ",", "t", ")", ";", "}", "}", "}" ]
Load a single element into the diagram @param element The element ot be loaded @param t The transform to apply to the loaded element from the parent @throws ParsingException Indicates a failure to parse the element
[ "Load", "a", "single", "element", "into", "the", "diagram" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/InkscapeLoader.java#L216-L225
1,640
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/font/effects/OutlineEffect.java
OutlineEffect.getStroke
public Stroke getStroke() { if (stroke == null) { return new BasicStroke(width, BasicStroke.CAP_SQUARE, join); } return stroke; }
java
public Stroke getStroke() { if (stroke == null) { return new BasicStroke(width, BasicStroke.CAP_SQUARE, join); } return stroke; }
[ "public", "Stroke", "getStroke", "(", ")", "{", "if", "(", "stroke", "==", "null", ")", "{", "return", "new", "BasicStroke", "(", "width", ",", "BasicStroke", ".", "CAP_SQUARE", ",", "join", ")", ";", "}", "return", "stroke", ";", "}" ]
Get the stroke being used to draw the outline @return The stroke being used to draw the outline
[ "Get", "the", "stroke", "being", "used", "to", "draw", "the", "outline" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/font/effects/OutlineEffect.java#L113-L119
1,641
nguillaumin/slick2d-maven
slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Packer.java
Packer.getSpriteAt
public Sprite getSpriteAt(int x, int y) { for (int i=0;i<sprites.size();i++) { if (((Sprite) sprites.get(i)).contains(x,y)) { return ((Sprite) sprites.get(i)); } } return null; }
java
public Sprite getSpriteAt(int x, int y) { for (int i=0;i<sprites.size();i++) { if (((Sprite) sprites.get(i)).contains(x,y)) { return ((Sprite) sprites.get(i)); } } return null; }
[ "public", "Sprite", "getSpriteAt", "(", "int", "x", ",", "int", "y", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "sprites", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "(", "(", "Sprite", ")", "sprites", ".", "get", "(", "i", ")", ")", ".", "contains", "(", "x", ",", "y", ")", ")", "{", "return", "(", "(", "Sprite", ")", "sprites", ".", "get", "(", "i", ")", ")", ";", "}", "}", "return", "null", ";", "}" ]
Get the sprite a given location on the current sheet @param x The x coordinate to look for the sprite @param y The y coordinate to look for the sprite @return The sprite found at the given location or null if no sprite can be found
[ "Get", "the", "sprite", "a", "given", "location", "on", "the", "current", "sheet" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Packer.java#L267-L275
1,642
nguillaumin/slick2d-maven
slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Packer.java
Packer.select
public void select(ArrayList selection) { list.clearSelection(); int[] selected = new int[selection.size()]; for (int i=0;i<selection.size();i++) { selected[i] = sprites.indexOf(selection.get(i)); } list.setSelectedIndices(selected); sheetPanel.setSelection(selection); }
java
public void select(ArrayList selection) { list.clearSelection(); int[] selected = new int[selection.size()]; for (int i=0;i<selection.size();i++) { selected[i] = sprites.indexOf(selection.get(i)); } list.setSelectedIndices(selected); sheetPanel.setSelection(selection); }
[ "public", "void", "select", "(", "ArrayList", "selection", ")", "{", "list", ".", "clearSelection", "(", ")", ";", "int", "[", "]", "selected", "=", "new", "int", "[", "selection", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "selection", ".", "size", "(", ")", ";", "i", "++", ")", "{", "selected", "[", "i", "]", "=", "sprites", ".", "indexOf", "(", "selection", ".", "get", "(", "i", ")", ")", ";", "}", "list", ".", "setSelectedIndices", "(", "selected", ")", ";", "sheetPanel", ".", "setSelection", "(", "selection", ")", ";", "}" ]
Select a series of sprites @param selection The series of sprites to be selected (Sprite objects)
[ "Select", "a", "series", "of", "sprites" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Packer.java#L282-L291
1,643
nguillaumin/slick2d-maven
slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Packer.java
Packer.save
private void save() { int resp = saveChooser.showSaveDialog(this); if (resp == JFileChooser.APPROVE_OPTION) { File out = saveChooser.getSelectedFile(); ArrayList list = new ArrayList(); for (int i=0;i<sprites.size();i++) { list.add(sprites.elementAt(i)); } try { int b = ((Integer) border.getValue()).intValue(); pack.packImages(list, twidth, theight, b, out); } catch (IOException e) { // shouldn't happen e.printStackTrace(); JOptionPane.showMessageDialog(this, "Failed to write output"); } } }
java
private void save() { int resp = saveChooser.showSaveDialog(this); if (resp == JFileChooser.APPROVE_OPTION) { File out = saveChooser.getSelectedFile(); ArrayList list = new ArrayList(); for (int i=0;i<sprites.size();i++) { list.add(sprites.elementAt(i)); } try { int b = ((Integer) border.getValue()).intValue(); pack.packImages(list, twidth, theight, b, out); } catch (IOException e) { // shouldn't happen e.printStackTrace(); JOptionPane.showMessageDialog(this, "Failed to write output"); } } }
[ "private", "void", "save", "(", ")", "{", "int", "resp", "=", "saveChooser", ".", "showSaveDialog", "(", "this", ")", ";", "if", "(", "resp", "==", "JFileChooser", ".", "APPROVE_OPTION", ")", "{", "File", "out", "=", "saveChooser", ".", "getSelectedFile", "(", ")", ";", "ArrayList", "list", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "sprites", ".", "size", "(", ")", ";", "i", "++", ")", "{", "list", ".", "add", "(", "sprites", ".", "elementAt", "(", "i", ")", ")", ";", "}", "try", "{", "int", "b", "=", "(", "(", "Integer", ")", "border", ".", "getValue", "(", ")", ")", ".", "intValue", "(", ")", ";", "pack", ".", "packImages", "(", "list", ",", "twidth", ",", "theight", ",", "b", ",", "out", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// shouldn't happen \r", "e", ".", "printStackTrace", "(", ")", ";", "JOptionPane", ".", "showMessageDialog", "(", "this", ",", "\"Failed to write output\"", ")", ";", "}", "}", "}" ]
Save the sprite sheet
[ "Save", "the", "sprite", "sheet" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Packer.java#L296-L315
1,644
nguillaumin/slick2d-maven
slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Packer.java
Packer.regenerate
private void regenerate() { try { ArrayList list = new ArrayList(); for (int i=0;i<sprites.size();i++) { list.add(sprites.elementAt(i)); } int b = ((Integer) border.getValue()).intValue(); Sheet sheet = pack.packImages(list, twidth, theight, b, null); sheetPanel.setImage(sheet); } catch (IOException e) { // shouldn't happen e.printStackTrace(); } }
java
private void regenerate() { try { ArrayList list = new ArrayList(); for (int i=0;i<sprites.size();i++) { list.add(sprites.elementAt(i)); } int b = ((Integer) border.getValue()).intValue(); Sheet sheet = pack.packImages(list, twidth, theight, b, null); sheetPanel.setImage(sheet); } catch (IOException e) { // shouldn't happen e.printStackTrace(); } }
[ "private", "void", "regenerate", "(", ")", "{", "try", "{", "ArrayList", "list", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "sprites", ".", "size", "(", ")", ";", "i", "++", ")", "{", "list", ".", "add", "(", "sprites", ".", "elementAt", "(", "i", ")", ")", ";", "}", "int", "b", "=", "(", "(", "Integer", ")", "border", ".", "getValue", "(", ")", ")", ".", "intValue", "(", ")", ";", "Sheet", "sheet", "=", "pack", ".", "packImages", "(", "list", ",", "twidth", ",", "theight", ",", "b", ",", "null", ")", ";", "sheetPanel", ".", "setImage", "(", "sheet", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// shouldn't happen \r", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Regenerate the sprite sheet that is being displayed
[ "Regenerate", "the", "sprite", "sheet", "that", "is", "being", "displayed" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Packer.java#L320-L334
1,645
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Polygon.java
Polygon.addPoint
public void addPoint(float x, float y) { if (hasVertex(x,y) && (!allowDups)) { return; } ArrayList tempPoints = new ArrayList(); for(int i=0;i<points.length;i++) { tempPoints.add(new Float(points[i])); } tempPoints.add(new Float(x)); tempPoints.add(new Float(y)); int length = tempPoints.size(); points = new float[length]; for(int i=0;i<length;i++) { points[i] = ((Float)tempPoints.get(i)).floatValue(); } if(x > maxX) { maxX = x; } if(y > maxY) { maxY = y; } if(x < minX) { minX = x; } if(y < minY) { minY = y; } findCenter(); calculateRadius(); pointsDirty = true; }
java
public void addPoint(float x, float y) { if (hasVertex(x,y) && (!allowDups)) { return; } ArrayList tempPoints = new ArrayList(); for(int i=0;i<points.length;i++) { tempPoints.add(new Float(points[i])); } tempPoints.add(new Float(x)); tempPoints.add(new Float(y)); int length = tempPoints.size(); points = new float[length]; for(int i=0;i<length;i++) { points[i] = ((Float)tempPoints.get(i)).floatValue(); } if(x > maxX) { maxX = x; } if(y > maxY) { maxY = y; } if(x < minX) { minX = x; } if(y < minY) { minY = y; } findCenter(); calculateRadius(); pointsDirty = true; }
[ "public", "void", "addPoint", "(", "float", "x", ",", "float", "y", ")", "{", "if", "(", "hasVertex", "(", "x", ",", "y", ")", "&&", "(", "!", "allowDups", ")", ")", "{", "return", ";", "}", "ArrayList", "tempPoints", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "points", ".", "length", ";", "i", "++", ")", "{", "tempPoints", ".", "add", "(", "new", "Float", "(", "points", "[", "i", "]", ")", ")", ";", "}", "tempPoints", ".", "add", "(", "new", "Float", "(", "x", ")", ")", ";", "tempPoints", ".", "add", "(", "new", "Float", "(", "y", ")", ")", ";", "int", "length", "=", "tempPoints", ".", "size", "(", ")", ";", "points", "=", "new", "float", "[", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "points", "[", "i", "]", "=", "(", "(", "Float", ")", "tempPoints", ".", "get", "(", "i", ")", ")", ".", "floatValue", "(", ")", ";", "}", "if", "(", "x", ">", "maxX", ")", "{", "maxX", "=", "x", ";", "}", "if", "(", "y", ">", "maxY", ")", "{", "maxY", "=", "y", ";", "}", "if", "(", "x", "<", "minX", ")", "{", "minX", "=", "x", ";", "}", "if", "(", "y", "<", "minY", ")", "{", "minY", "=", "y", ";", "}", "findCenter", "(", ")", ";", "calculateRadius", "(", ")", ";", "pointsDirty", "=", "true", ";", "}" ]
Add a point to the polygon @param x The x coordinate of the point @param y The y coordinate of the point
[ "Add", "a", "point", "to", "the", "polygon" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Polygon.java#L92-L124
1,646
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Polygon.java
Polygon.copy
public Polygon copy() { float[] copyPoints = new float[points.length]; System.arraycopy(points, 0, copyPoints, 0, copyPoints.length); return new Polygon(copyPoints); }
java
public Polygon copy() { float[] copyPoints = new float[points.length]; System.arraycopy(points, 0, copyPoints, 0, copyPoints.length); return new Polygon(copyPoints); }
[ "public", "Polygon", "copy", "(", ")", "{", "float", "[", "]", "copyPoints", "=", "new", "float", "[", "points", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "points", ",", "0", ",", "copyPoints", ",", "0", ",", "copyPoints", ".", "length", ")", ";", "return", "new", "Polygon", "(", "copyPoints", ")", ";", "}" ]
Provide a copy of this polygon @return A copy of this polygon
[ "Provide", "a", "copy", "of", "this", "polygon" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Polygon.java#L194-L199
1,647
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java
ObjectTreeParser.getClassForElementName
private Class getClassForElementName(String name) { Class clazz = (Class) nameToClass.get(name); if (clazz != null) { return clazz; } if (defaultPackage != null) { try { return Class.forName(defaultPackage+"."+name); } catch (ClassNotFoundException e) { // ignore, it's just not there } } return null; }
java
private Class getClassForElementName(String name) { Class clazz = (Class) nameToClass.get(name); if (clazz != null) { return clazz; } if (defaultPackage != null) { try { return Class.forName(defaultPackage+"."+name); } catch (ClassNotFoundException e) { // ignore, it's just not there } } return null; }
[ "private", "Class", "getClassForElementName", "(", "String", "name", ")", "{", "Class", "clazz", "=", "(", "Class", ")", "nameToClass", ".", "get", "(", "name", ")", ";", "if", "(", "clazz", "!=", "null", ")", "{", "return", "clazz", ";", "}", "if", "(", "defaultPackage", "!=", "null", ")", "{", "try", "{", "return", "Class", ".", "forName", "(", "defaultPackage", "+", "\".\"", "+", "name", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "// ignore, it's just not there\r", "}", "}", "return", "null", ";", "}" ]
Deterine the name of the class that should be used for a given XML element name. @param name The name of the XML element @return The class to be used or null if none can be found
[ "Deterine", "the", "name", "of", "the", "class", "that", "should", "be", "used", "for", "a", "given", "XML", "element", "name", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java#L181-L196
1,648
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java
ObjectTreeParser.typeValue
private Object typeValue(String value, Class clazz) throws SlickXMLException { if (clazz == String.class) { return value; } try { clazz = mapPrimitive(clazz); return clazz.getConstructor(new Class[] {String.class}).newInstance(new Object[] {value}); } catch (Exception e) { throw new SlickXMLException("Failed to convert: "+value+" to the expected primitive type: "+clazz, e); } }
java
private Object typeValue(String value, Class clazz) throws SlickXMLException { if (clazz == String.class) { return value; } try { clazz = mapPrimitive(clazz); return clazz.getConstructor(new Class[] {String.class}).newInstance(new Object[] {value}); } catch (Exception e) { throw new SlickXMLException("Failed to convert: "+value+" to the expected primitive type: "+clazz, e); } }
[ "private", "Object", "typeValue", "(", "String", "value", ",", "Class", "clazz", ")", "throws", "SlickXMLException", "{", "if", "(", "clazz", "==", "String", ".", "class", ")", "{", "return", "value", ";", "}", "try", "{", "clazz", "=", "mapPrimitive", "(", "clazz", ")", ";", "return", "clazz", ".", "getConstructor", "(", "new", "Class", "[", "]", "{", "String", ".", "class", "}", ")", ".", "newInstance", "(", "new", "Object", "[", "]", "{", "value", "}", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "SlickXMLException", "(", "\"Failed to convert: \"", "+", "value", "+", "\" to the expected primitive type: \"", "+", "clazz", ",", "e", ")", ";", "}", "}" ]
Convert a given value to a given type @param value The value to convert @param clazz The class that the returned object must be @return The value as the given type @throws SlickXMLException Indicates there is no automatic way of converting the value to the type
[ "Convert", "a", "given", "value", "to", "a", "given", "type" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java#L306-L317
1,649
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java
ObjectTreeParser.mapPrimitive
private Class mapPrimitive(Class clazz) { if (clazz == Integer.TYPE) { return Integer.class; } if (clazz == Double.TYPE) { return Double.class; } if (clazz == Float.TYPE) { return Float.class; } if (clazz == Boolean.TYPE) { return Boolean.class; } if (clazz == Long.TYPE) { return Long.class; } throw new RuntimeException("Unsupported primitive: "+clazz); }
java
private Class mapPrimitive(Class clazz) { if (clazz == Integer.TYPE) { return Integer.class; } if (clazz == Double.TYPE) { return Double.class; } if (clazz == Float.TYPE) { return Float.class; } if (clazz == Boolean.TYPE) { return Boolean.class; } if (clazz == Long.TYPE) { return Long.class; } throw new RuntimeException("Unsupported primitive: "+clazz); }
[ "private", "Class", "mapPrimitive", "(", "Class", "clazz", ")", "{", "if", "(", "clazz", "==", "Integer", ".", "TYPE", ")", "{", "return", "Integer", ".", "class", ";", "}", "if", "(", "clazz", "==", "Double", ".", "TYPE", ")", "{", "return", "Double", ".", "class", ";", "}", "if", "(", "clazz", "==", "Float", ".", "TYPE", ")", "{", "return", "Float", ".", "class", ";", "}", "if", "(", "clazz", "==", "Boolean", ".", "TYPE", ")", "{", "return", "Boolean", ".", "class", ";", "}", "if", "(", "clazz", "==", "Long", ".", "TYPE", ")", "{", "return", "Long", ".", "class", ";", "}", "throw", "new", "RuntimeException", "(", "\"Unsupported primitive: \"", "+", "clazz", ")", ";", "}" ]
Map a primitive class type to it's real object wrapper @param clazz The primitive type class @return The object wrapper class
[ "Map", "a", "primitive", "class", "type", "to", "it", "s", "real", "object", "wrapper" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java#L325-L343
1,650
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java
ObjectTreeParser.findField
private Field findField(Class clazz, String name) { Field[] fields = clazz.getDeclaredFields(); for (int i=0;i<fields.length;i++) { if (fields[i].getName().equalsIgnoreCase(name)) { if (fields[i].getType().isPrimitive()) { return fields[i]; } if (fields[i].getType() == String.class) { return fields[i]; } } } return null; }
java
private Field findField(Class clazz, String name) { Field[] fields = clazz.getDeclaredFields(); for (int i=0;i<fields.length;i++) { if (fields[i].getName().equalsIgnoreCase(name)) { if (fields[i].getType().isPrimitive()) { return fields[i]; } if (fields[i].getType() == String.class) { return fields[i]; } } } return null; }
[ "private", "Field", "findField", "(", "Class", "clazz", ",", "String", "name", ")", "{", "Field", "[", "]", "fields", "=", "clazz", ".", "getDeclaredFields", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fields", ".", "length", ";", "i", "++", ")", "{", "if", "(", "fields", "[", "i", "]", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "name", ")", ")", "{", "if", "(", "fields", "[", "i", "]", ".", "getType", "(", ")", ".", "isPrimitive", "(", ")", ")", "{", "return", "fields", "[", "i", "]", ";", "}", "if", "(", "fields", "[", "i", "]", ".", "getType", "(", ")", "==", "String", ".", "class", ")", "{", "return", "fields", "[", "i", "]", ";", "}", "}", "}", "return", "null", ";", "}" ]
Find a field in a class by it's name. Note that this method is only needed because the general reflection method is case sensitive @param clazz The clazz to search @param name The name of the field to search for @return The field or null if none could be located
[ "Find", "a", "field", "in", "a", "class", "by", "it", "s", "name", ".", "Note", "that", "this", "method", "is", "only", "needed", "because", "the", "general", "reflection", "method", "is", "case", "sensitive" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java#L354-L368
1,651
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java
ObjectTreeParser.findMethod
private Method findMethod(Class clazz, String name) { Method[] methods = clazz.getDeclaredMethods(); for (int i=0;i<methods.length;i++) { if (methods[i].getName().equalsIgnoreCase(name)) { Method method = methods[i]; Class[] params = method.getParameterTypes(); if (params.length == 1) { return method; } } } return null; }
java
private Method findMethod(Class clazz, String name) { Method[] methods = clazz.getDeclaredMethods(); for (int i=0;i<methods.length;i++) { if (methods[i].getName().equalsIgnoreCase(name)) { Method method = methods[i]; Class[] params = method.getParameterTypes(); if (params.length == 1) { return method; } } } return null; }
[ "private", "Method", "findMethod", "(", "Class", "clazz", ",", "String", "name", ")", "{", "Method", "[", "]", "methods", "=", "clazz", ".", "getDeclaredMethods", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "methods", ".", "length", ";", "i", "++", ")", "{", "if", "(", "methods", "[", "i", "]", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "name", ")", ")", "{", "Method", "method", "=", "methods", "[", "i", "]", ";", "Class", "[", "]", "params", "=", "method", ".", "getParameterTypes", "(", ")", ";", "if", "(", "params", ".", "length", "==", "1", ")", "{", "return", "method", ";", "}", "}", "}", "return", "null", ";", "}" ]
Find a method in a class by it's name. Note that this method is only needed because the general reflection method is case sensitive @param clazz The clazz to search @param name The name of the method to search for @return The method or null if none could be located
[ "Find", "a", "method", "in", "a", "class", "by", "it", "s", "name", ".", "Note", "that", "this", "method", "is", "only", "needed", "because", "the", "general", "reflection", "method", "is", "case", "sensitive" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java#L379-L393
1,652
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java
ObjectTreeParser.setField
private void setField(Field field, Object instance, Object value) throws SlickXMLException { try { field.setAccessible(true); field.set(instance, value); } catch (IllegalArgumentException e) { throw new SlickXMLException("Failed to set: "+field+" for an XML attribute, is it valid?", e); } catch (IllegalAccessException e) { throw new SlickXMLException("Failed to set: "+field+" for an XML attribute, is it valid?", e); } finally { field.setAccessible(false); } }
java
private void setField(Field field, Object instance, Object value) throws SlickXMLException { try { field.setAccessible(true); field.set(instance, value); } catch (IllegalArgumentException e) { throw new SlickXMLException("Failed to set: "+field+" for an XML attribute, is it valid?", e); } catch (IllegalAccessException e) { throw new SlickXMLException("Failed to set: "+field+" for an XML attribute, is it valid?", e); } finally { field.setAccessible(false); } }
[ "private", "void", "setField", "(", "Field", "field", ",", "Object", "instance", ",", "Object", "value", ")", "throws", "SlickXMLException", "{", "try", "{", "field", ".", "setAccessible", "(", "true", ")", ";", "field", ".", "set", "(", "instance", ",", "value", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "new", "SlickXMLException", "(", "\"Failed to set: \"", "+", "field", "+", "\" for an XML attribute, is it valid?\"", ",", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "SlickXMLException", "(", "\"Failed to set: \"", "+", "field", "+", "\" for an XML attribute, is it valid?\"", ",", "e", ")", ";", "}", "finally", "{", "field", ".", "setAccessible", "(", "false", ")", ";", "}", "}" ]
Set a field value on a object instance @param field The field to be set @param instance The instance of the object to set it on @param value The value to set @throws SlickXMLException Indicates a failure to set or access the field
[ "Set", "a", "field", "value", "on", "a", "object", "instance" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java#L429-L440
1,653
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java
ObjectTreeParser.invoke
private void invoke(Method method, Object instance, Object[] params) throws SlickXMLException { try { method.setAccessible(true); method.invoke(instance, params); } catch (IllegalArgumentException e) { throw new SlickXMLException("Failed to invoke: "+method+" for an XML attribute, is it valid?", e); } catch (IllegalAccessException e) { throw new SlickXMLException("Failed to invoke: "+method+" for an XML attribute, is it valid?", e); } catch (InvocationTargetException e) { throw new SlickXMLException("Failed to invoke: "+method+" for an XML attribute, is it valid?", e); } finally { method.setAccessible(false); } }
java
private void invoke(Method method, Object instance, Object[] params) throws SlickXMLException { try { method.setAccessible(true); method.invoke(instance, params); } catch (IllegalArgumentException e) { throw new SlickXMLException("Failed to invoke: "+method+" for an XML attribute, is it valid?", e); } catch (IllegalAccessException e) { throw new SlickXMLException("Failed to invoke: "+method+" for an XML attribute, is it valid?", e); } catch (InvocationTargetException e) { throw new SlickXMLException("Failed to invoke: "+method+" for an XML attribute, is it valid?", e); } finally { method.setAccessible(false); } }
[ "private", "void", "invoke", "(", "Method", "method", ",", "Object", "instance", ",", "Object", "[", "]", "params", ")", "throws", "SlickXMLException", "{", "try", "{", "method", ".", "setAccessible", "(", "true", ")", ";", "method", ".", "invoke", "(", "instance", ",", "params", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "new", "SlickXMLException", "(", "\"Failed to invoke: \"", "+", "method", "+", "\" for an XML attribute, is it valid?\"", ",", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "SlickXMLException", "(", "\"Failed to invoke: \"", "+", "method", "+", "\" for an XML attribute, is it valid?\"", ",", "e", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "throw", "new", "SlickXMLException", "(", "\"Failed to invoke: \"", "+", "method", "+", "\" for an XML attribute, is it valid?\"", ",", "e", ")", ";", "}", "finally", "{", "method", ".", "setAccessible", "(", "false", ")", ";", "}", "}" ]
Call a method on a object @param method The method to call @param instance The objet to call the method on @param params The parameters to pass @throws SlickXMLException Indicates a failure to call or access the method
[ "Call", "a", "method", "on", "a", "object" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java#L450-L463
1,654
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Sound.java
Sound.play
public void play(float pitch, float volume) { sound.playAsSoundEffect(pitch, volume * SoundStore.get().getSoundVolume(), false); }
java
public void play(float pitch, float volume) { sound.playAsSoundEffect(pitch, volume * SoundStore.get().getSoundVolume(), false); }
[ "public", "void", "play", "(", "float", "pitch", ",", "float", "volume", ")", "{", "sound", ".", "playAsSoundEffect", "(", "pitch", ",", "volume", "*", "SoundStore", ".", "get", "(", ")", ".", "getSoundVolume", "(", ")", ",", "false", ")", ";", "}" ]
Play this sound effect at a given volume and pitch @param pitch The pitch to play the sound effect at @param volume The volumen to play the sound effect at
[ "Play", "this", "sound", "effect", "at", "a", "given", "volume", "and", "pitch" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Sound.java#L116-L118
1,655
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Sound.java
Sound.playAt
public void playAt(float pitch, float volume, float x, float y, float z) { sound.playAsSoundEffect(pitch, volume * SoundStore.get().getSoundVolume(), false, x,y,z); }
java
public void playAt(float pitch, float volume, float x, float y, float z) { sound.playAsSoundEffect(pitch, volume * SoundStore.get().getSoundVolume(), false, x,y,z); }
[ "public", "void", "playAt", "(", "float", "pitch", ",", "float", "volume", ",", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "sound", ".", "playAsSoundEffect", "(", "pitch", ",", "volume", "*", "SoundStore", ".", "get", "(", ")", ".", "getSoundVolume", "(", ")", ",", "false", ",", "x", ",", "y", ",", "z", ")", ";", "}" ]
Play a sound effect from a particular location @param pitch The pitch to play the sound effect at @param volume The volumen to play the sound effect at @param x The x position of the source of the effect @param y The y position of the source of the effect @param z The z position of the source of the effect
[ "Play", "a", "sound", "effect", "from", "a", "particular", "location" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Sound.java#L140-L142
1,656
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Sound.java
Sound.loop
public void loop(float pitch, float volume) { sound.playAsSoundEffect(pitch, volume * SoundStore.get().getSoundVolume(), true); }
java
public void loop(float pitch, float volume) { sound.playAsSoundEffect(pitch, volume * SoundStore.get().getSoundVolume(), true); }
[ "public", "void", "loop", "(", "float", "pitch", ",", "float", "volume", ")", "{", "sound", ".", "playAsSoundEffect", "(", "pitch", ",", "volume", "*", "SoundStore", ".", "get", "(", ")", ".", "getSoundVolume", "(", ")", ",", "true", ")", ";", "}" ]
Loop this sound effect at a given volume and pitch @param pitch The pitch to play the sound effect at @param volume The volumen to play the sound effect at
[ "Loop", "this", "sound", "effect", "at", "a", "given", "volume", "and", "pitch" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Sound.java#L156-L158
1,657
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/AiffData.java
AiffData.create
public static AiffData create(URL path) { try { return create( AudioSystem.getAudioInputStream( new BufferedInputStream(path.openStream()))); } catch (Exception e) { org.lwjgl.LWJGLUtil.log("Unable to create from: " + path); e.printStackTrace(); return null; } }
java
public static AiffData create(URL path) { try { return create( AudioSystem.getAudioInputStream( new BufferedInputStream(path.openStream()))); } catch (Exception e) { org.lwjgl.LWJGLUtil.log("Unable to create from: " + path); e.printStackTrace(); return null; } }
[ "public", "static", "AiffData", "create", "(", "URL", "path", ")", "{", "try", "{", "return", "create", "(", "AudioSystem", ".", "getAudioInputStream", "(", "new", "BufferedInputStream", "(", "path", ".", "openStream", "(", ")", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "org", ".", "lwjgl", ".", "LWJGLUtil", ".", "log", "(", "\"Unable to create from: \"", "+", "path", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}" ]
Creates a AiffData container from the specified url @param path URL to file @return AiffData containing data, or null if a failure occured
[ "Creates", "a", "AiffData", "container", "from", "the", "specified", "url" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/AiffData.java#L93-L103
1,658
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/AiffData.java
AiffData.create
public static AiffData create(InputStream is) { try { return create( AudioSystem.getAudioInputStream(is)); } catch (Exception e) { org.lwjgl.LWJGLUtil.log("Unable to create from inputstream"); e.printStackTrace(); return null; } }
java
public static AiffData create(InputStream is) { try { return create( AudioSystem.getAudioInputStream(is)); } catch (Exception e) { org.lwjgl.LWJGLUtil.log("Unable to create from inputstream"); e.printStackTrace(); return null; } }
[ "public", "static", "AiffData", "create", "(", "InputStream", "is", ")", "{", "try", "{", "return", "create", "(", "AudioSystem", ".", "getAudioInputStream", "(", "is", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "org", ".", "lwjgl", ".", "LWJGLUtil", ".", "log", "(", "\"Unable to create from inputstream\"", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}" ]
Creates a AiffData container from the specified inputstream @param is InputStream to read from @return AiffData containing data, or null if a failure occured
[ "Creates", "a", "AiffData", "container", "from", "the", "specified", "inputstream" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/AiffData.java#L121-L130
1,659
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/AiffData.java
AiffData.create
public static AiffData create(byte[] buffer) { try { return create( AudioSystem.getAudioInputStream( new BufferedInputStream(new ByteArrayInputStream(buffer)))); } catch (Exception e) { e.printStackTrace(); return null; } }
java
public static AiffData create(byte[] buffer) { try { return create( AudioSystem.getAudioInputStream( new BufferedInputStream(new ByteArrayInputStream(buffer)))); } catch (Exception e) { e.printStackTrace(); return null; } }
[ "public", "static", "AiffData", "create", "(", "byte", "[", "]", "buffer", ")", "{", "try", "{", "return", "create", "(", "AudioSystem", ".", "getAudioInputStream", "(", "new", "BufferedInputStream", "(", "new", "ByteArrayInputStream", "(", "buffer", ")", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}" ]
Creates a AiffData container from the specified bytes @param buffer array of bytes containing the complete Aiff file @return AiffData containing data, or null if a failure occured
[ "Creates", "a", "AiffData", "container", "from", "the", "specified", "bytes" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/AiffData.java#L138-L147
1,660
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java
Space.link
public void link(Space other) { // aligned vertical edges if (inTolerance(x,other.x+other.width) || inTolerance(x+width, other.x)) { float linkx = x; if (x+width == other.x) { linkx = x+width; } float top = Math.max(y, other.y); float bottom = Math.min(y+height, other.y+other.height); float linky = top + ((bottom-top)/2); Link link = new Link(linkx, linky, other); links.put(other,link); linksList.add(link); } // aligned horizontal edges if (inTolerance(y, other.y+other.height) || inTolerance(y+height, other.y)) { float linky = y; if (y+height == other.y) { linky = y+height; } float left = Math.max(x, other.x); float right = Math.min(x+width, other.x+other.width); float linkx = left + ((right-left)/2); Link link = new Link(linkx, linky, other); links.put(other, link); linksList.add(link); } }
java
public void link(Space other) { // aligned vertical edges if (inTolerance(x,other.x+other.width) || inTolerance(x+width, other.x)) { float linkx = x; if (x+width == other.x) { linkx = x+width; } float top = Math.max(y, other.y); float bottom = Math.min(y+height, other.y+other.height); float linky = top + ((bottom-top)/2); Link link = new Link(linkx, linky, other); links.put(other,link); linksList.add(link); } // aligned horizontal edges if (inTolerance(y, other.y+other.height) || inTolerance(y+height, other.y)) { float linky = y; if (y+height == other.y) { linky = y+height; } float left = Math.max(x, other.x); float right = Math.min(x+width, other.x+other.width); float linkx = left + ((right-left)/2); Link link = new Link(linkx, linky, other); links.put(other, link); linksList.add(link); } }
[ "public", "void", "link", "(", "Space", "other", ")", "{", "// aligned vertical edges", "if", "(", "inTolerance", "(", "x", ",", "other", ".", "x", "+", "other", ".", "width", ")", "||", "inTolerance", "(", "x", "+", "width", ",", "other", ".", "x", ")", ")", "{", "float", "linkx", "=", "x", ";", "if", "(", "x", "+", "width", "==", "other", ".", "x", ")", "{", "linkx", "=", "x", "+", "width", ";", "}", "float", "top", "=", "Math", ".", "max", "(", "y", ",", "other", ".", "y", ")", ";", "float", "bottom", "=", "Math", ".", "min", "(", "y", "+", "height", ",", "other", ".", "y", "+", "other", ".", "height", ")", ";", "float", "linky", "=", "top", "+", "(", "(", "bottom", "-", "top", ")", "/", "2", ")", ";", "Link", "link", "=", "new", "Link", "(", "linkx", ",", "linky", ",", "other", ")", ";", "links", ".", "put", "(", "other", ",", "link", ")", ";", "linksList", ".", "add", "(", "link", ")", ";", "}", "// aligned horizontal edges", "if", "(", "inTolerance", "(", "y", ",", "other", ".", "y", "+", "other", ".", "height", ")", "||", "inTolerance", "(", "y", "+", "height", ",", "other", ".", "y", ")", ")", "{", "float", "linky", "=", "y", ";", "if", "(", "y", "+", "height", "==", "other", ".", "y", ")", "{", "linky", "=", "y", "+", "height", ";", "}", "float", "left", "=", "Math", ".", "max", "(", "x", ",", "other", ".", "x", ")", ";", "float", "right", "=", "Math", ".", "min", "(", "x", "+", "width", ",", "other", ".", "x", "+", "other", ".", "width", ")", ";", "float", "linkx", "=", "left", "+", "(", "(", "right", "-", "left", ")", "/", "2", ")", ";", "Link", "link", "=", "new", "Link", "(", "linkx", ",", "linky", ",", "other", ")", ";", "links", ".", "put", "(", "other", ",", "link", ")", ";", "linksList", ".", "add", "(", "link", ")", ";", "}", "}" ]
Link this space to another by creating a link and finding the point at which the spaces link up @param other The other space to link to
[ "Link", "this", "space", "to", "another", "by", "creating", "a", "link", "and", "finding", "the", "point", "at", "which", "the", "spaces", "link", "up" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java#L85-L116
1,661
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java
Space.hasJoinedEdge
public boolean hasJoinedEdge(Space other) { // aligned vertical edges if (inTolerance(x,other.x+other.width) || inTolerance(x+width,other.x)) { if ((y >= other.y) && (y <= other.y + other.height)) { return true; } if ((y+height >= other.y) && (y+height <= other.y + other.height)) { return true; } if ((other.y >= y) && (other.y <= y + height)) { return true; } if ((other.y+other.height >= y) && (other.y+other.height <= y + height)) { return true; } } // aligned horizontal edges if (inTolerance(y, other.y+other.height) || inTolerance(y+height, other.y)) { if ((x >= other.x) && (x <= other.x + other.width)) { return true; } if ((x+width >= other.x) && (x+width <= other.x + other.width)) { return true; } if ((other.x >= x) && (other.x <= x + width)) { return true; } if ((other.x+other.width >= x) && (other.x+other.width <= x + width)) { return true; } } return false; }
java
public boolean hasJoinedEdge(Space other) { // aligned vertical edges if (inTolerance(x,other.x+other.width) || inTolerance(x+width,other.x)) { if ((y >= other.y) && (y <= other.y + other.height)) { return true; } if ((y+height >= other.y) && (y+height <= other.y + other.height)) { return true; } if ((other.y >= y) && (other.y <= y + height)) { return true; } if ((other.y+other.height >= y) && (other.y+other.height <= y + height)) { return true; } } // aligned horizontal edges if (inTolerance(y, other.y+other.height) || inTolerance(y+height, other.y)) { if ((x >= other.x) && (x <= other.x + other.width)) { return true; } if ((x+width >= other.x) && (x+width <= other.x + other.width)) { return true; } if ((other.x >= x) && (other.x <= x + width)) { return true; } if ((other.x+other.width >= x) && (other.x+other.width <= x + width)) { return true; } } return false; }
[ "public", "boolean", "hasJoinedEdge", "(", "Space", "other", ")", "{", "// aligned vertical edges", "if", "(", "inTolerance", "(", "x", ",", "other", ".", "x", "+", "other", ".", "width", ")", "||", "inTolerance", "(", "x", "+", "width", ",", "other", ".", "x", ")", ")", "{", "if", "(", "(", "y", ">=", "other", ".", "y", ")", "&&", "(", "y", "<=", "other", ".", "y", "+", "other", ".", "height", ")", ")", "{", "return", "true", ";", "}", "if", "(", "(", "y", "+", "height", ">=", "other", ".", "y", ")", "&&", "(", "y", "+", "height", "<=", "other", ".", "y", "+", "other", ".", "height", ")", ")", "{", "return", "true", ";", "}", "if", "(", "(", "other", ".", "y", ">=", "y", ")", "&&", "(", "other", ".", "y", "<=", "y", "+", "height", ")", ")", "{", "return", "true", ";", "}", "if", "(", "(", "other", ".", "y", "+", "other", ".", "height", ">=", "y", ")", "&&", "(", "other", ".", "y", "+", "other", ".", "height", "<=", "y", "+", "height", ")", ")", "{", "return", "true", ";", "}", "}", "// aligned horizontal edges", "if", "(", "inTolerance", "(", "y", ",", "other", ".", "y", "+", "other", ".", "height", ")", "||", "inTolerance", "(", "y", "+", "height", ",", "other", ".", "y", ")", ")", "{", "if", "(", "(", "x", ">=", "other", ".", "x", ")", "&&", "(", "x", "<=", "other", ".", "x", "+", "other", ".", "width", ")", ")", "{", "return", "true", ";", "}", "if", "(", "(", "x", "+", "width", ">=", "other", ".", "x", ")", "&&", "(", "x", "+", "width", "<=", "other", ".", "x", "+", "other", ".", "width", ")", ")", "{", "return", "true", ";", "}", "if", "(", "(", "other", ".", "x", ">=", "x", ")", "&&", "(", "other", ".", "x", "<=", "x", "+", "width", ")", ")", "{", "return", "true", ";", "}", "if", "(", "(", "other", ".", "x", "+", "other", ".", "width", ">=", "x", ")", "&&", "(", "other", ".", "x", "+", "other", ".", "width", "<=", "x", "+", "width", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if this space has an edge that is joined with another @param other The other space to check against @return True if the spaces have a shared edge
[ "Check", "if", "this", "space", "has", "an", "edge", "that", "is", "joined", "with", "another" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java#L136-L169
1,662
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java
Space.merge
public Space merge(Space other) { float minx = Math.min(x, other.x); float miny = Math.min(y, other.y); float newwidth = width+other.width; float newheight = height+other.height; if (x == other.x) { newwidth = width; } else { newheight = height; } return new Space(minx, miny, newwidth, newheight); }
java
public Space merge(Space other) { float minx = Math.min(x, other.x); float miny = Math.min(y, other.y); float newwidth = width+other.width; float newheight = height+other.height; if (x == other.x) { newwidth = width; } else { newheight = height; } return new Space(minx, miny, newwidth, newheight); }
[ "public", "Space", "merge", "(", "Space", "other", ")", "{", "float", "minx", "=", "Math", ".", "min", "(", "x", ",", "other", ".", "x", ")", ";", "float", "miny", "=", "Math", ".", "min", "(", "y", ",", "other", ".", "y", ")", ";", "float", "newwidth", "=", "width", "+", "other", ".", "width", ";", "float", "newheight", "=", "height", "+", "other", ".", "height", ";", "if", "(", "x", "==", "other", ".", "x", ")", "{", "newwidth", "=", "width", ";", "}", "else", "{", "newheight", "=", "height", ";", "}", "return", "new", "Space", "(", "minx", ",", "miny", ",", "newwidth", ",", "newheight", ")", ";", "}" ]
Merge this space with another @param other The other space to merge with @return The result space created by joining the two
[ "Merge", "this", "space", "with", "another" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java#L177-L189
1,663
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java
Space.canMerge
public boolean canMerge(Space other) { if (!hasJoinedEdge(other)) { return false; } if ((x == other.x) && (width == other.width)) { return true; } if ((y == other.y) && (height == other.height)) { return true; } return false; }
java
public boolean canMerge(Space other) { if (!hasJoinedEdge(other)) { return false; } if ((x == other.x) && (width == other.width)) { return true; } if ((y == other.y) && (height == other.height)) { return true; } return false; }
[ "public", "boolean", "canMerge", "(", "Space", "other", ")", "{", "if", "(", "!", "hasJoinedEdge", "(", "other", ")", ")", "{", "return", "false", ";", "}", "if", "(", "(", "x", "==", "other", ".", "x", ")", "&&", "(", "width", "==", "other", ".", "width", ")", ")", "{", "return", "true", ";", "}", "if", "(", "(", "y", "==", "other", ".", "y", ")", "&&", "(", "height", "==", "other", ".", "height", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if the given space can be merged with this one. It must have an adjacent edge and have the same height or width as this space. @param other The other space to be considered @return True if the spaces can be joined together
[ "Check", "if", "the", "given", "space", "can", "be", "merged", "with", "this", "one", ".", "It", "must", "have", "an", "adjacent", "edge", "and", "have", "the", "same", "height", "or", "width", "as", "this", "space", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java#L198-L211
1,664
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java
Space.contains
public boolean contains(float xp, float yp) { return (xp >= x) && (xp < x+width) && (yp >= y) && (yp < y+height); }
java
public boolean contains(float xp, float yp) { return (xp >= x) && (xp < x+width) && (yp >= y) && (yp < y+height); }
[ "public", "boolean", "contains", "(", "float", "xp", ",", "float", "yp", ")", "{", "return", "(", "xp", ">=", "x", ")", "&&", "(", "xp", "<", "x", "+", "width", ")", "&&", "(", "yp", ">=", "y", ")", "&&", "(", "yp", "<", "y", "+", "height", ")", ";", "}" ]
Check if this space contains a given point @param xp The x coordinate to check @param yp The y coordinate to check @return True if this space container the coordinate given
[ "Check", "if", "this", "space", "contains", "a", "given", "point" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java#L239-L241
1,665
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java
Space.fill
public void fill(Space target, float sx, float sy, float cost) { if (cost >= this.cost) { return; } this.cost = cost; if (target == this) { return; } for (int i=0;i<getLinkCount();i++) { Link link = getLink(i); float extraCost = link.distance2(sx,sy); float nextCost = cost + extraCost; link.getTarget().fill(target, link.getX(), link.getY(), nextCost); } }
java
public void fill(Space target, float sx, float sy, float cost) { if (cost >= this.cost) { return; } this.cost = cost; if (target == this) { return; } for (int i=0;i<getLinkCount();i++) { Link link = getLink(i); float extraCost = link.distance2(sx,sy); float nextCost = cost + extraCost; link.getTarget().fill(target, link.getX(), link.getY(), nextCost); } }
[ "public", "void", "fill", "(", "Space", "target", ",", "float", "sx", ",", "float", "sy", ",", "float", "cost", ")", "{", "if", "(", "cost", ">=", "this", ".", "cost", ")", "{", "return", ";", "}", "this", ".", "cost", "=", "cost", ";", "if", "(", "target", "==", "this", ")", "{", "return", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getLinkCount", "(", ")", ";", "i", "++", ")", "{", "Link", "link", "=", "getLink", "(", "i", ")", ";", "float", "extraCost", "=", "link", ".", "distance2", "(", "sx", ",", "sy", ")", ";", "float", "nextCost", "=", "cost", "+", "extraCost", ";", "link", ".", "getTarget", "(", ")", ".", "fill", "(", "target", ",", "link", ".", "getX", "(", ")", ",", "link", ".", "getY", "(", ")", ",", "nextCost", ")", ";", "}", "}" ]
Fill the spaces based on the cost from a given starting point @param target The target space we're heading for @param sx The x coordinate of the starting point @param sy The y coordinate of the starting point @param cost The cost up to this point
[ "Fill", "the", "spaces", "based", "on", "the", "cost", "from", "a", "given", "starting", "point" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java#L251-L266
1,666
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java
Space.pickLowestCost
public boolean pickLowestCost(Space target, NavPath path) { if (target == this) { return true; } if (links.size() == 0) { return false; } Link bestLink = null; for (int i=0;i<getLinkCount();i++) { Link link = getLink(i); if ((bestLink == null) || (link.getTarget().getCost() < bestLink.getTarget().getCost())) { bestLink = link; } } path.push(bestLink); return bestLink.getTarget().pickLowestCost(target, path); }
java
public boolean pickLowestCost(Space target, NavPath path) { if (target == this) { return true; } if (links.size() == 0) { return false; } Link bestLink = null; for (int i=0;i<getLinkCount();i++) { Link link = getLink(i); if ((bestLink == null) || (link.getTarget().getCost() < bestLink.getTarget().getCost())) { bestLink = link; } } path.push(bestLink); return bestLink.getTarget().pickLowestCost(target, path); }
[ "public", "boolean", "pickLowestCost", "(", "Space", "target", ",", "NavPath", "path", ")", "{", "if", "(", "target", "==", "this", ")", "{", "return", "true", ";", "}", "if", "(", "links", ".", "size", "(", ")", "==", "0", ")", "{", "return", "false", ";", "}", "Link", "bestLink", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getLinkCount", "(", ")", ";", "i", "++", ")", "{", "Link", "link", "=", "getLink", "(", "i", ")", ";", "if", "(", "(", "bestLink", "==", "null", ")", "||", "(", "link", ".", "getTarget", "(", ")", ".", "getCost", "(", ")", "<", "bestLink", ".", "getTarget", "(", ")", ".", "getCost", "(", ")", ")", ")", "{", "bestLink", "=", "link", ";", "}", "}", "path", ".", "push", "(", "bestLink", ")", ";", "return", "bestLink", ".", "getTarget", "(", ")", ".", "pickLowestCost", "(", "target", ",", "path", ")", ";", "}" ]
Pick the lowest cost route from this space to another on the path @param target The target space we're looking for @param path The path to add the steps to @return True if the path was found
[ "Pick", "the", "lowest", "cost", "route", "from", "this", "space", "to", "another", "on", "the", "path" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/navmesh/Space.java#L291-L309
1,667
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.addFrame
public void addFrame(int duration, int x, int y){ if (duration == 0) { Log.error("Invalid duration: "+duration); throw new RuntimeException("Invalid duration: "+duration); } if (frames.isEmpty()) { nextChange = (int) (duration / speed); } frames.add(new Frame(duration, x, y)); currentFrame = 0; }
java
public void addFrame(int duration, int x, int y){ if (duration == 0) { Log.error("Invalid duration: "+duration); throw new RuntimeException("Invalid duration: "+duration); } if (frames.isEmpty()) { nextChange = (int) (duration / speed); } frames.add(new Frame(duration, x, y)); currentFrame = 0; }
[ "public", "void", "addFrame", "(", "int", "duration", ",", "int", "x", ",", "int", "y", ")", "{", "if", "(", "duration", "==", "0", ")", "{", "Log", ".", "error", "(", "\"Invalid duration: \"", "+", "duration", ")", ";", "throw", "new", "RuntimeException", "(", "\"Invalid duration: \"", "+", "duration", ")", ";", "}", "if", "(", "frames", ".", "isEmpty", "(", ")", ")", "{", "nextChange", "=", "(", "int", ")", "(", "duration", "/", "speed", ")", ";", "}", "frames", ".", "add", "(", "new", "Frame", "(", "duration", ",", "x", ",", "y", ")", ")", ";", "currentFrame", "=", "0", ";", "}" ]
Add animation frame to the animation. @param duration The duration to display the frame for @param x The x location of the frame on the <tt>SpriteSheet</tt> @param y The y location of the frame on the <tt>spriteSheet</tt>
[ "Add", "animation", "frame", "to", "the", "animation", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L185-L197
1,668
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.restart
public void restart() { if (frames.size() == 0) { return; } stopped = false; currentFrame = 0; nextChange = (int) (((Frame) frames.get(0)).duration / speed); firstUpdate = true; lastUpdate = 0; }
java
public void restart() { if (frames.size() == 0) { return; } stopped = false; currentFrame = 0; nextChange = (int) (((Frame) frames.get(0)).duration / speed); firstUpdate = true; lastUpdate = 0; }
[ "public", "void", "restart", "(", ")", "{", "if", "(", "frames", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "}", "stopped", "=", "false", ";", "currentFrame", "=", "0", ";", "nextChange", "=", "(", "int", ")", "(", "(", "(", "Frame", ")", "frames", ".", "get", "(", "0", ")", ")", ".", "duration", "/", "speed", ")", ";", "firstUpdate", "=", "true", ";", "lastUpdate", "=", "0", ";", "}" ]
Restart the animation from the beginning
[ "Restart", "the", "animation", "from", "the", "beginning" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L281-L290
1,669
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.addFrame
public void addFrame(Image frame, int duration) { if (duration == 0) { Log.error("Invalid duration: "+duration); throw new RuntimeException("Invalid duration: "+duration); } if (frames.isEmpty()) { nextChange = (int) (duration / speed); } frames.add(new Frame(frame, duration)); currentFrame = 0; }
java
public void addFrame(Image frame, int duration) { if (duration == 0) { Log.error("Invalid duration: "+duration); throw new RuntimeException("Invalid duration: "+duration); } if (frames.isEmpty()) { nextChange = (int) (duration / speed); } frames.add(new Frame(frame, duration)); currentFrame = 0; }
[ "public", "void", "addFrame", "(", "Image", "frame", ",", "int", "duration", ")", "{", "if", "(", "duration", "==", "0", ")", "{", "Log", ".", "error", "(", "\"Invalid duration: \"", "+", "duration", ")", ";", "throw", "new", "RuntimeException", "(", "\"Invalid duration: \"", "+", "duration", ")", ";", "}", "if", "(", "frames", ".", "isEmpty", "(", ")", ")", "{", "nextChange", "=", "(", "int", ")", "(", "duration", "/", "speed", ")", ";", "}", "frames", ".", "add", "(", "new", "Frame", "(", "frame", ",", "duration", ")", ")", ";", "currentFrame", "=", "0", ";", "}" ]
Add animation frame to the animation @param frame The image to display for the frame @param duration The duration to display the frame for
[ "Add", "animation", "frame", "to", "the", "animation" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L298-L310
1,670
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.draw
@Override public void draw(float x,float y, Color filter) { draw(x,y,getWidth(),getHeight(), filter); }
java
@Override public void draw(float x,float y, Color filter) { draw(x,y,getWidth(),getHeight(), filter); }
[ "@", "Override", "public", "void", "draw", "(", "float", "x", ",", "float", "y", ",", "Color", "filter", ")", "{", "draw", "(", "x", ",", "y", ",", "getWidth", "(", ")", ",", "getHeight", "(", ")", ",", "filter", ")", ";", "}" ]
Draw the animation at a specific location @param x The x position to draw the animation at @param y The y position to draw the animation at @param filter The filter to apply
[ "Draw", "the", "animation", "at", "a", "specific", "location" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L337-L340
1,671
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.renderInUse
public void renderInUse(int x, int y){ if (frames.size() == 0) { return; } if (autoUpdate) { long now = getTime(); long delta = now - lastUpdate; if (firstUpdate) { delta = 0; firstUpdate = false; } lastUpdate = now; nextFrame(delta); } Frame frame = (Frame) frames.get(currentFrame); spriteSheet.renderInUse(x, y, frame.x, frame.y); }
java
public void renderInUse(int x, int y){ if (frames.size() == 0) { return; } if (autoUpdate) { long now = getTime(); long delta = now - lastUpdate; if (firstUpdate) { delta = 0; firstUpdate = false; } lastUpdate = now; nextFrame(delta); } Frame frame = (Frame) frames.get(currentFrame); spriteSheet.renderInUse(x, y, frame.x, frame.y); }
[ "public", "void", "renderInUse", "(", "int", "x", ",", "int", "y", ")", "{", "if", "(", "frames", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "}", "if", "(", "autoUpdate", ")", "{", "long", "now", "=", "getTime", "(", ")", ";", "long", "delta", "=", "now", "-", "lastUpdate", ";", "if", "(", "firstUpdate", ")", "{", "delta", "=", "0", ";", "firstUpdate", "=", "false", ";", "}", "lastUpdate", "=", "now", ";", "nextFrame", "(", "delta", ")", ";", "}", "Frame", "frame", "=", "(", "Frame", ")", "frames", ".", "get", "(", "currentFrame", ")", ";", "spriteSheet", ".", "renderInUse", "(", "x", ",", "y", ",", "frame", ".", "x", ",", "frame", ".", "y", ")", ";", "}" ]
Render the appropriate frame when the spriteSheet backing this Animation is in use. @param x The x position to draw the animation at @param y The y position to draw the animation at
[ "Render", "the", "appropriate", "frame", "when", "the", "spriteSheet", "backing", "this", "Animation", "is", "in", "use", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L390-L408
1,672
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.drawFlash
public void drawFlash(float x,float y,float width,float height, Color col) { if (frames.size() == 0) { return; } if (autoUpdate) { long now = getTime(); long delta = now - lastUpdate; if (firstUpdate) { delta = 0; firstUpdate = false; } lastUpdate = now; nextFrame(delta); } Frame frame = (Frame) frames.get(currentFrame); frame.image.drawFlash(x,y,width,height,col); }
java
public void drawFlash(float x,float y,float width,float height, Color col) { if (frames.size() == 0) { return; } if (autoUpdate) { long now = getTime(); long delta = now - lastUpdate; if (firstUpdate) { delta = 0; firstUpdate = false; } lastUpdate = now; nextFrame(delta); } Frame frame = (Frame) frames.get(currentFrame); frame.image.drawFlash(x,y,width,height,col); }
[ "public", "void", "drawFlash", "(", "float", "x", ",", "float", "y", ",", "float", "width", ",", "float", "height", ",", "Color", "col", ")", "{", "if", "(", "frames", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "}", "if", "(", "autoUpdate", ")", "{", "long", "now", "=", "getTime", "(", ")", ";", "long", "delta", "=", "now", "-", "lastUpdate", ";", "if", "(", "firstUpdate", ")", "{", "delta", "=", "0", ";", "firstUpdate", "=", "false", ";", "}", "lastUpdate", "=", "now", ";", "nextFrame", "(", "delta", ")", ";", "}", "Frame", "frame", "=", "(", "Frame", ")", "frames", ".", "get", "(", "currentFrame", ")", ";", "frame", ".", "image", ".", "drawFlash", "(", "x", ",", "y", ",", "width", ",", "height", ",", "col", ")", ";", "}" ]
Draw the animation @param x The x position to draw the animation at @param y The y position to draw the animation at @param width The width to draw the animation at @param height The height to draw the animation at @param col The colour for the flash
[ "Draw", "the", "animation" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L449-L467
1,673
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.updateNoDraw
public void updateNoDraw() { if (autoUpdate) { long now = getTime(); long delta = now - lastUpdate; if (firstUpdate) { delta = 0; firstUpdate = false; } lastUpdate = now; nextFrame(delta); } }
java
public void updateNoDraw() { if (autoUpdate) { long now = getTime(); long delta = now - lastUpdate; if (firstUpdate) { delta = 0; firstUpdate = false; } lastUpdate = now; nextFrame(delta); } }
[ "public", "void", "updateNoDraw", "(", ")", "{", "if", "(", "autoUpdate", ")", "{", "long", "now", "=", "getTime", "(", ")", ";", "long", "delta", "=", "now", "-", "lastUpdate", ";", "if", "(", "firstUpdate", ")", "{", "delta", "=", "0", ";", "firstUpdate", "=", "false", ";", "}", "lastUpdate", "=", "now", ";", "nextFrame", "(", "delta", ")", ";", "}", "}" ]
Update the animation cycle without draw the image, useful for keeping two animations in sync @deprecated
[ "Update", "the", "animation", "cycle", "without", "draw", "the", "image", "useful", "for", "keeping", "two", "animations", "in", "sync" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L475-L486
1,674
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.getImage
public Image getImage(int index) { Frame frame = (Frame) frames.get(index); return frame.image; }
java
public Image getImage(int index) { Frame frame = (Frame) frames.get(index); return frame.image; }
[ "public", "Image", "getImage", "(", "int", "index", ")", "{", "Frame", "frame", "=", "(", "Frame", ")", "frames", ".", "get", "(", "index", ")", ";", "return", "frame", ".", "image", ";", "}" ]
Get the image assocaited with a given frame index @param index The index of the frame image to retrieve @return The image of the specified animation frame
[ "Get", "the", "image", "assocaited", "with", "a", "given", "frame", "index" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L523-L526
1,675
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.getCurrentFrame
public Image getCurrentFrame() { Frame frame = (Frame) frames.get(currentFrame); return frame.image; }
java
public Image getCurrentFrame() { Frame frame = (Frame) frames.get(currentFrame); return frame.image; }
[ "public", "Image", "getCurrentFrame", "(", ")", "{", "Frame", "frame", "=", "(", "Frame", ")", "frames", ".", "get", "(", "currentFrame", ")", ";", "return", "frame", ".", "image", ";", "}" ]
Get the image associated with the current animation frame @return The image associated with the current animation frame
[ "Get", "the", "image", "associated", "with", "the", "current", "animation", "frame" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L542-L545
1,676
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.nextFrame
private void nextFrame(long delta) { if (stopped) { return; } if (frames.size() == 0) { return; } nextChange -= delta; while (nextChange < 0 && (!stopped)) { if (currentFrame == stopAt) { stopped = true; break; } if ((currentFrame == frames.size() - 1) && (!loop) && (!pingPong)) { stopped = true; break; } currentFrame = (currentFrame + direction) % frames.size(); if (pingPong) { if (currentFrame <= 0) { currentFrame = 0; direction = 1; if (!loop) { stopped = true; break; } } else if (currentFrame >= frames.size()-1) { currentFrame = frames.size()-1; direction = -1; } } int realDuration = (int) (((Frame) frames.get(currentFrame)).duration / speed); nextChange = nextChange + realDuration; } }
java
private void nextFrame(long delta) { if (stopped) { return; } if (frames.size() == 0) { return; } nextChange -= delta; while (nextChange < 0 && (!stopped)) { if (currentFrame == stopAt) { stopped = true; break; } if ((currentFrame == frames.size() - 1) && (!loop) && (!pingPong)) { stopped = true; break; } currentFrame = (currentFrame + direction) % frames.size(); if (pingPong) { if (currentFrame <= 0) { currentFrame = 0; direction = 1; if (!loop) { stopped = true; break; } } else if (currentFrame >= frames.size()-1) { currentFrame = frames.size()-1; direction = -1; } } int realDuration = (int) (((Frame) frames.get(currentFrame)).duration / speed); nextChange = nextChange + realDuration; } }
[ "private", "void", "nextFrame", "(", "long", "delta", ")", "{", "if", "(", "stopped", ")", "{", "return", ";", "}", "if", "(", "frames", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "}", "nextChange", "-=", "delta", ";", "while", "(", "nextChange", "<", "0", "&&", "(", "!", "stopped", ")", ")", "{", "if", "(", "currentFrame", "==", "stopAt", ")", "{", "stopped", "=", "true", ";", "break", ";", "}", "if", "(", "(", "currentFrame", "==", "frames", ".", "size", "(", ")", "-", "1", ")", "&&", "(", "!", "loop", ")", "&&", "(", "!", "pingPong", ")", ")", "{", "stopped", "=", "true", ";", "break", ";", "}", "currentFrame", "=", "(", "currentFrame", "+", "direction", ")", "%", "frames", ".", "size", "(", ")", ";", "if", "(", "pingPong", ")", "{", "if", "(", "currentFrame", "<=", "0", ")", "{", "currentFrame", "=", "0", ";", "direction", "=", "1", ";", "if", "(", "!", "loop", ")", "{", "stopped", "=", "true", ";", "break", ";", "}", "}", "else", "if", "(", "currentFrame", ">=", "frames", ".", "size", "(", ")", "-", "1", ")", "{", "currentFrame", "=", "frames", ".", "size", "(", ")", "-", "1", ";", "direction", "=", "-", "1", ";", "}", "}", "int", "realDuration", "=", "(", "int", ")", "(", "(", "(", "Frame", ")", "frames", ".", "get", "(", "currentFrame", ")", ")", ".", "duration", "/", "speed", ")", ";", "nextChange", "=", "nextChange", "+", "realDuration", ";", "}", "}" ]
Check if we need to move to the next frame @param delta The amount of time thats passed since last update
[ "Check", "if", "we", "need", "to", "move", "to", "the", "next", "frame" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L552-L590
1,677
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.getDurations
public int[] getDurations() { int[] durations = new int[frames.size()]; for (int i=0;i<frames.size();i++) { durations[i] = getDuration(i); } return durations; }
java
public int[] getDurations() { int[] durations = new int[frames.size()]; for (int i=0;i<frames.size();i++) { durations[i] = getDuration(i); } return durations; }
[ "public", "int", "[", "]", "getDurations", "(", ")", "{", "int", "[", "]", "durations", "=", "new", "int", "[", "frames", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "frames", ".", "size", "(", ")", ";", "i", "++", ")", "{", "durations", "[", "i", "]", "=", "getDuration", "(", "i", ")", ";", "}", "return", "durations", ";", "}" ]
Get the durations of all the frames in this animation @return The durations of all the frames in this animation
[ "Get", "the", "durations", "of", "all", "the", "frames", "in", "this", "animation" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L645-L652
1,678
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Animation.java
Animation.copy
public Animation copy() { Animation copy = new Animation(); copy.spriteSheet = spriteSheet; copy.frames = frames; copy.autoUpdate = autoUpdate; copy.direction = direction; copy.loop = loop; copy.pingPong = pingPong; copy.speed = speed; return copy; }
java
public Animation copy() { Animation copy = new Animation(); copy.spriteSheet = spriteSheet; copy.frames = frames; copy.autoUpdate = autoUpdate; copy.direction = direction; copy.loop = loop; copy.pingPong = pingPong; copy.speed = speed; return copy; }
[ "public", "Animation", "copy", "(", ")", "{", "Animation", "copy", "=", "new", "Animation", "(", ")", ";", "copy", ".", "spriteSheet", "=", "spriteSheet", ";", "copy", ".", "frames", "=", "frames", ";", "copy", ".", "autoUpdate", "=", "autoUpdate", ";", "copy", ".", "direction", "=", "direction", ";", "copy", ".", "loop", "=", "loop", ";", "copy", ".", "pingPong", "=", "pingPong", ";", "copy", ".", "speed", "=", "speed", ";", "return", "copy", ";", "}" ]
Create a copy of this animation. Note that the frames are not duplicated but shared with the original @return A copy of this animation
[ "Create", "a", "copy", "of", "this", "animation", ".", "Note", "that", "the", "frames", "are", "not", "duplicated", "but", "shared", "with", "the", "original" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Animation.java#L675-L687
1,679
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/PNGDecoder.java
PNGDecoder.decideTextureFormat
public Format decideTextureFormat(Format fmt) { switch (colorType) { case COLOR_TRUECOLOR: if ((fmt == ABGR) || (fmt == RGBA) || (fmt == BGRA) || (fmt == RGB)) { return fmt; } return RGB; case COLOR_TRUEALPHA: if ((fmt == ABGR) || (fmt == RGBA) || (fmt == BGRA) || (fmt == RGB)) { return fmt; } return RGBA; case COLOR_GREYSCALE: if ((fmt == LUMINANCE) || (fmt == ALPHA)) { return fmt; } return LUMINANCE; case COLOR_GREYALPHA: return LUMINANCE_ALPHA; case COLOR_INDEXED: if ((fmt == ABGR) || (fmt == RGBA) || (fmt == BGRA)) { return fmt; } return RGBA; default: throw new UnsupportedOperationException("Not yet implemented"); } }
java
public Format decideTextureFormat(Format fmt) { switch (colorType) { case COLOR_TRUECOLOR: if ((fmt == ABGR) || (fmt == RGBA) || (fmt == BGRA) || (fmt == RGB)) { return fmt; } return RGB; case COLOR_TRUEALPHA: if ((fmt == ABGR) || (fmt == RGBA) || (fmt == BGRA) || (fmt == RGB)) { return fmt; } return RGBA; case COLOR_GREYSCALE: if ((fmt == LUMINANCE) || (fmt == ALPHA)) { return fmt; } return LUMINANCE; case COLOR_GREYALPHA: return LUMINANCE_ALPHA; case COLOR_INDEXED: if ((fmt == ABGR) || (fmt == RGBA) || (fmt == BGRA)) { return fmt; } return RGBA; default: throw new UnsupportedOperationException("Not yet implemented"); } }
[ "public", "Format", "decideTextureFormat", "(", "Format", "fmt", ")", "{", "switch", "(", "colorType", ")", "{", "case", "COLOR_TRUECOLOR", ":", "if", "(", "(", "fmt", "==", "ABGR", ")", "||", "(", "fmt", "==", "RGBA", ")", "||", "(", "fmt", "==", "BGRA", ")", "||", "(", "fmt", "==", "RGB", ")", ")", "{", "return", "fmt", ";", "}", "return", "RGB", ";", "case", "COLOR_TRUEALPHA", ":", "if", "(", "(", "fmt", "==", "ABGR", ")", "||", "(", "fmt", "==", "RGBA", ")", "||", "(", "fmt", "==", "BGRA", ")", "||", "(", "fmt", "==", "RGB", ")", ")", "{", "return", "fmt", ";", "}", "return", "RGBA", ";", "case", "COLOR_GREYSCALE", ":", "if", "(", "(", "fmt", "==", "LUMINANCE", ")", "||", "(", "fmt", "==", "ALPHA", ")", ")", "{", "return", "fmt", ";", "}", "return", "LUMINANCE", ";", "case", "COLOR_GREYALPHA", ":", "return", "LUMINANCE_ALPHA", ";", "case", "COLOR_INDEXED", ":", "if", "(", "(", "fmt", "==", "ABGR", ")", "||", "(", "fmt", "==", "RGBA", ")", "||", "(", "fmt", "==", "BGRA", ")", ")", "{", "return", "fmt", ";", "}", "return", "RGBA", ";", "default", ":", "throw", "new", "UnsupportedOperationException", "(", "\"Not yet implemented\"", ")", ";", "}", "}" ]
Computes the implemented format conversion for the desired format. @param fmt the desired format @return format which best matches the desired format @throws UnsupportedOperationException if this PNG file can't be decoded
[ "Computes", "the", "implemented", "format", "conversion", "for", "the", "desired", "format", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/PNGDecoder.java#L165-L196
1,680
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/AppletGameContainer.java
AppletGameContainer.destroyLWJGL
private void destroyLWJGL() { container.stopApplet(); try { gameThread.join(); } catch (InterruptedException e) { Log.error(e); } }
java
private void destroyLWJGL() { container.stopApplet(); try { gameThread.join(); } catch (InterruptedException e) { Log.error(e); } }
[ "private", "void", "destroyLWJGL", "(", ")", "{", "container", ".", "stopApplet", "(", ")", ";", "try", "{", "gameThread", ".", "join", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "Log", ".", "error", "(", "e", ")", ";", "}", "}" ]
Clean up the LWJGL resources
[ "Clean", "up", "the", "LWJGL", "resources" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/AppletGameContainer.java#L64-L72
1,681
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/AppletGameContainer.java
AppletGameContainer.startLWJGL
public void startLWJGL() { if (gameThread != null) { return; } gameThread = new Thread() { public void run() { try { canvas.start(); } catch (Exception e) { e.printStackTrace(); if (Display.isCreated()) { Display.destroy(); } displayParent.setVisible(false);//removeAll(); add(new ConsolePanel(e)); validate(); } } }; gameThread.start(); }
java
public void startLWJGL() { if (gameThread != null) { return; } gameThread = new Thread() { public void run() { try { canvas.start(); } catch (Exception e) { e.printStackTrace(); if (Display.isCreated()) { Display.destroy(); } displayParent.setVisible(false);//removeAll(); add(new ConsolePanel(e)); validate(); } } }; gameThread.start(); }
[ "public", "void", "startLWJGL", "(", ")", "{", "if", "(", "gameThread", "!=", "null", ")", "{", "return", ";", "}", "gameThread", "=", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "canvas", ".", "start", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "if", "(", "Display", ".", "isCreated", "(", ")", ")", "{", "Display", ".", "destroy", "(", ")", ";", "}", "displayParent", ".", "setVisible", "(", "false", ")", ";", "//removeAll();\r", "add", "(", "new", "ConsolePanel", "(", "e", ")", ")", ";", "validate", "(", ")", ";", "}", "}", "}", ";", "gameThread", ".", "start", "(", ")", ";", "}" ]
Start a thread to run LWJGL in
[ "Start", "a", "thread", "to", "run", "LWJGL", "in" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/AppletGameContainer.java#L84-L107
1,682
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java
GeomUtil.subtract
public Shape[] subtract(Shape target, Shape missing) { target = target.transform(new Transform()); missing = missing.transform(new Transform()); int count = 0; for (int i=0;i<target.getPointCount();i++) { if (missing.contains(target.getPoint(i)[0], target.getPoint(i)[1])) { count++; } } if (count == target.getPointCount()) { return new Shape[0]; } if (!target.intersects(missing)) { return new Shape[] {target}; } int found = 0; for (int i=0;i<missing.getPointCount();i++) { if (target.contains(missing.getPoint(i)[0], missing.getPoint(i)[1])) { if (!onPath(target, missing.getPoint(i)[0], missing.getPoint(i)[1])) { found++; } } } for (int i=0;i<target.getPointCount();i++) { if (missing.contains(target.getPoint(i)[0], target.getPoint(i)[1])) { if (!onPath(missing, target.getPoint(i)[0], target.getPoint(i)[1])) { found++; } } } if (found < 1) { return new Shape[] {target}; } return combine(target, missing, true); }
java
public Shape[] subtract(Shape target, Shape missing) { target = target.transform(new Transform()); missing = missing.transform(new Transform()); int count = 0; for (int i=0;i<target.getPointCount();i++) { if (missing.contains(target.getPoint(i)[0], target.getPoint(i)[1])) { count++; } } if (count == target.getPointCount()) { return new Shape[0]; } if (!target.intersects(missing)) { return new Shape[] {target}; } int found = 0; for (int i=0;i<missing.getPointCount();i++) { if (target.contains(missing.getPoint(i)[0], missing.getPoint(i)[1])) { if (!onPath(target, missing.getPoint(i)[0], missing.getPoint(i)[1])) { found++; } } } for (int i=0;i<target.getPointCount();i++) { if (missing.contains(target.getPoint(i)[0], target.getPoint(i)[1])) { if (!onPath(missing, target.getPoint(i)[0], target.getPoint(i)[1])) { found++; } } } if (found < 1) { return new Shape[] {target}; } return combine(target, missing, true); }
[ "public", "Shape", "[", "]", "subtract", "(", "Shape", "target", ",", "Shape", "missing", ")", "{", "target", "=", "target", ".", "transform", "(", "new", "Transform", "(", ")", ")", ";", "missing", "=", "missing", ".", "transform", "(", "new", "Transform", "(", ")", ")", ";", "int", "count", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "target", ".", "getPointCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "missing", ".", "contains", "(", "target", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "target", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "count", "++", ";", "}", "}", "if", "(", "count", "==", "target", ".", "getPointCount", "(", ")", ")", "{", "return", "new", "Shape", "[", "0", "]", ";", "}", "if", "(", "!", "target", ".", "intersects", "(", "missing", ")", ")", "{", "return", "new", "Shape", "[", "]", "{", "target", "}", ";", "}", "int", "found", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "missing", ".", "getPointCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "target", ".", "contains", "(", "missing", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "missing", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "if", "(", "!", "onPath", "(", "target", ",", "missing", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "missing", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "found", "++", ";", "}", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "target", ".", "getPointCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "missing", ".", "contains", "(", "target", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "target", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "if", "(", "!", "onPath", "(", "missing", ",", "target", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "target", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "found", "++", ";", "}", "}", "}", "if", "(", "found", "<", "1", ")", "{", "return", "new", "Shape", "[", "]", "{", "target", "}", ";", "}", "return", "combine", "(", "target", ",", "missing", ",", "true", ")", ";", "}" ]
Subtract one shape from another - note this is experimental and doesn't currently handle islands @param target The target to be subtracted from @param missing The shape to subtract @return The newly created shapes
[ "Subtract", "one", "shape", "from", "another", "-", "note", "this", "is", "experimental", "and", "doesn", "t", "currently", "handle", "islands" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java#L28-L69
1,683
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java
GeomUtil.onPath
private boolean onPath(Shape path, float x, float y) { for (int i=0;i<path.getPointCount()+1;i++) { int n = rationalPoint(path, i+1); Line line = getLine(path, rationalPoint(path, i), n); if (line.distance(new Vector2f(x,y)) < EPSILON*100) { return true; } } return false; }
java
private boolean onPath(Shape path, float x, float y) { for (int i=0;i<path.getPointCount()+1;i++) { int n = rationalPoint(path, i+1); Line line = getLine(path, rationalPoint(path, i), n); if (line.distance(new Vector2f(x,y)) < EPSILON*100) { return true; } } return false; }
[ "private", "boolean", "onPath", "(", "Shape", "path", ",", "float", "x", ",", "float", "y", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "path", ".", "getPointCount", "(", ")", "+", "1", ";", "i", "++", ")", "{", "int", "n", "=", "rationalPoint", "(", "path", ",", "i", "+", "1", ")", ";", "Line", "line", "=", "getLine", "(", "path", ",", "rationalPoint", "(", "path", ",", "i", ")", ",", "n", ")", ";", "if", "(", "line", ".", "distance", "(", "new", "Vector2f", "(", "x", ",", "y", ")", ")", "<", "EPSILON", "*", "100", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if the given point is on the path @param path The path to check @param x The x coordinate of the point to check @param y The y coordiante of teh point to check @return True if the point is on the path
[ "Check", "if", "the", "given", "point", "is", "on", "the", "path" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java#L79-L89
1,684
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java
GeomUtil.union
public Shape[] union(Shape target, Shape other) { target = target.transform(new Transform()); other = other.transform(new Transform()); if (!target.intersects(other)) { return new Shape[] {target, other}; } // handle the case where intersects is true but really we're talking // about edge points boolean touches = false; int buttCount = 0; for (int i=0;i<target.getPointCount();i++) { if (other.contains(target.getPoint(i)[0], target.getPoint(i)[1])) { if (!other.hasVertex(target.getPoint(i)[0], target.getPoint(i)[1])) { touches = true; break; } } if (other.hasVertex(target.getPoint(i)[0], target.getPoint(i)[1])) { buttCount++; } } for (int i=0;i<other.getPointCount();i++) { if (target.contains(other.getPoint(i)[0], other.getPoint(i)[1])) { if (!target.hasVertex(other.getPoint(i)[0], other.getPoint(i)[1])) { touches = true; break; } } } if ((!touches) && (buttCount < 2)) { return new Shape[] {target, other}; } // so they are definitely touching, consider the union return combine(target, other, false); }
java
public Shape[] union(Shape target, Shape other) { target = target.transform(new Transform()); other = other.transform(new Transform()); if (!target.intersects(other)) { return new Shape[] {target, other}; } // handle the case where intersects is true but really we're talking // about edge points boolean touches = false; int buttCount = 0; for (int i=0;i<target.getPointCount();i++) { if (other.contains(target.getPoint(i)[0], target.getPoint(i)[1])) { if (!other.hasVertex(target.getPoint(i)[0], target.getPoint(i)[1])) { touches = true; break; } } if (other.hasVertex(target.getPoint(i)[0], target.getPoint(i)[1])) { buttCount++; } } for (int i=0;i<other.getPointCount();i++) { if (target.contains(other.getPoint(i)[0], other.getPoint(i)[1])) { if (!target.hasVertex(other.getPoint(i)[0], other.getPoint(i)[1])) { touches = true; break; } } } if ((!touches) && (buttCount < 2)) { return new Shape[] {target, other}; } // so they are definitely touching, consider the union return combine(target, other, false); }
[ "public", "Shape", "[", "]", "union", "(", "Shape", "target", ",", "Shape", "other", ")", "{", "target", "=", "target", ".", "transform", "(", "new", "Transform", "(", ")", ")", ";", "other", "=", "other", ".", "transform", "(", "new", "Transform", "(", ")", ")", ";", "if", "(", "!", "target", ".", "intersects", "(", "other", ")", ")", "{", "return", "new", "Shape", "[", "]", "{", "target", ",", "other", "}", ";", "}", "// handle the case where intersects is true but really we're talking\r", "// about edge points\r", "boolean", "touches", "=", "false", ";", "int", "buttCount", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "target", ".", "getPointCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "other", ".", "contains", "(", "target", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "target", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "if", "(", "!", "other", ".", "hasVertex", "(", "target", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "target", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "touches", "=", "true", ";", "break", ";", "}", "}", "if", "(", "other", ".", "hasVertex", "(", "target", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "target", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "buttCount", "++", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "other", ".", "getPointCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "target", ".", "contains", "(", "other", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "other", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "if", "(", "!", "target", ".", "hasVertex", "(", "other", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "other", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "touches", "=", "true", ";", "break", ";", "}", "}", "}", "if", "(", "(", "!", "touches", ")", "&&", "(", "buttCount", "<", "2", ")", ")", "{", "return", "new", "Shape", "[", "]", "{", "target", ",", "other", "}", ";", "}", "// so they are definitely touching, consider the union\r", "return", "combine", "(", "target", ",", "other", ",", "false", ")", ";", "}" ]
Join to shapes together. Note that the shapes must be touching for this method to work. @param target The target shape to union with @param other The additional shape to union @return The newly created shapes
[ "Join", "to", "shapes", "together", ".", "Note", "that", "the", "shapes", "must", "be", "touching", "for", "this", "method", "to", "work", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java#L108-L146
1,685
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java
GeomUtil.combine
private Shape[] combine(Shape target, Shape other, boolean subtract) { if (subtract) { ArrayList shapes = new ArrayList(); ArrayList used = new ArrayList(); // remove any points that are contianed in the shape we're removing, these // are implicitly used for (int i=0;i<target.getPointCount();i++) { float[] point = target.getPoint(i); if (other.contains(point[0], point[1])) { used.add(new Vector2f(point[0], point[1])); if (listener != null) { listener.pointExcluded(point[0], point[1]); } } } for (int i=0;i<target.getPointCount();i++) { float[] point = target.getPoint(i); Vector2f pt = new Vector2f(point[0], point[1]); if (!used.contains(pt)) { Shape result = combineSingle(target, other, true, i); shapes.add(result); for (int j=0;j<result.getPointCount();j++) { float[] kpoint = result.getPoint(j); Vector2f kpt = new Vector2f(kpoint[0], kpoint[1]); used.add(kpt); } } } return (Shape[]) shapes.toArray(new Shape[0]); } else { for (int i=0;i<target.getPointCount();i++) { if (!other.contains(target.getPoint(i)[0], target.getPoint(i)[1])) { if (!other.hasVertex(target.getPoint(i)[0], target.getPoint(i)[1])) { Shape shape = combineSingle(target, other, false, i); return new Shape[] {shape}; } } } return new Shape[] {other}; } }
java
private Shape[] combine(Shape target, Shape other, boolean subtract) { if (subtract) { ArrayList shapes = new ArrayList(); ArrayList used = new ArrayList(); // remove any points that are contianed in the shape we're removing, these // are implicitly used for (int i=0;i<target.getPointCount();i++) { float[] point = target.getPoint(i); if (other.contains(point[0], point[1])) { used.add(new Vector2f(point[0], point[1])); if (listener != null) { listener.pointExcluded(point[0], point[1]); } } } for (int i=0;i<target.getPointCount();i++) { float[] point = target.getPoint(i); Vector2f pt = new Vector2f(point[0], point[1]); if (!used.contains(pt)) { Shape result = combineSingle(target, other, true, i); shapes.add(result); for (int j=0;j<result.getPointCount();j++) { float[] kpoint = result.getPoint(j); Vector2f kpt = new Vector2f(kpoint[0], kpoint[1]); used.add(kpt); } } } return (Shape[]) shapes.toArray(new Shape[0]); } else { for (int i=0;i<target.getPointCount();i++) { if (!other.contains(target.getPoint(i)[0], target.getPoint(i)[1])) { if (!other.hasVertex(target.getPoint(i)[0], target.getPoint(i)[1])) { Shape shape = combineSingle(target, other, false, i); return new Shape[] {shape}; } } } return new Shape[] {other}; } }
[ "private", "Shape", "[", "]", "combine", "(", "Shape", "target", ",", "Shape", "other", ",", "boolean", "subtract", ")", "{", "if", "(", "subtract", ")", "{", "ArrayList", "shapes", "=", "new", "ArrayList", "(", ")", ";", "ArrayList", "used", "=", "new", "ArrayList", "(", ")", ";", "// remove any points that are contianed in the shape we're removing, these\r", "// are implicitly used\r", "for", "(", "int", "i", "=", "0", ";", "i", "<", "target", ".", "getPointCount", "(", ")", ";", "i", "++", ")", "{", "float", "[", "]", "point", "=", "target", ".", "getPoint", "(", "i", ")", ";", "if", "(", "other", ".", "contains", "(", "point", "[", "0", "]", ",", "point", "[", "1", "]", ")", ")", "{", "used", ".", "add", "(", "new", "Vector2f", "(", "point", "[", "0", "]", ",", "point", "[", "1", "]", ")", ")", ";", "if", "(", "listener", "!=", "null", ")", "{", "listener", ".", "pointExcluded", "(", "point", "[", "0", "]", ",", "point", "[", "1", "]", ")", ";", "}", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "target", ".", "getPointCount", "(", ")", ";", "i", "++", ")", "{", "float", "[", "]", "point", "=", "target", ".", "getPoint", "(", "i", ")", ";", "Vector2f", "pt", "=", "new", "Vector2f", "(", "point", "[", "0", "]", ",", "point", "[", "1", "]", ")", ";", "if", "(", "!", "used", ".", "contains", "(", "pt", ")", ")", "{", "Shape", "result", "=", "combineSingle", "(", "target", ",", "other", ",", "true", ",", "i", ")", ";", "shapes", ".", "add", "(", "result", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "result", ".", "getPointCount", "(", ")", ";", "j", "++", ")", "{", "float", "[", "]", "kpoint", "=", "result", ".", "getPoint", "(", "j", ")", ";", "Vector2f", "kpt", "=", "new", "Vector2f", "(", "kpoint", "[", "0", "]", ",", "kpoint", "[", "1", "]", ")", ";", "used", ".", "add", "(", "kpt", ")", ";", "}", "}", "}", "return", "(", "Shape", "[", "]", ")", "shapes", ".", "toArray", "(", "new", "Shape", "[", "0", "]", ")", ";", "}", "else", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "target", ".", "getPointCount", "(", ")", ";", "i", "++", ")", "{", "if", "(", "!", "other", ".", "contains", "(", "target", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "target", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "if", "(", "!", "other", ".", "hasVertex", "(", "target", ".", "getPoint", "(", "i", ")", "[", "0", "]", ",", "target", ".", "getPoint", "(", "i", ")", "[", "1", "]", ")", ")", "{", "Shape", "shape", "=", "combineSingle", "(", "target", ",", "other", ",", "false", ",", "i", ")", ";", "return", "new", "Shape", "[", "]", "{", "shape", "}", ";", "}", "}", "}", "return", "new", "Shape", "[", "]", "{", "other", "}", ";", "}", "}" ]
Perform the combination @param target The target shape we're updating @param other The other shape in the operation @param subtract True if it's a subtract operation, otherwise it's union @return The set of shapes produced
[ "Perform", "the", "combination" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java#L156-L201
1,686
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java
GeomUtil.intersect
public HitResult intersect(Shape shape, Line line) { float distance = Float.MAX_VALUE; HitResult hit = null; for (int i=0;i<shape.getPointCount();i++) { int next = rationalPoint(shape, i+1); Line local = getLine(shape, i, next); Vector2f pt = line.intersect(local, true); if (pt != null) { float newDis = pt.distance(line.getStart()); if ((newDis < distance) && (newDis > EPSILON)) { hit = new HitResult(); hit.pt = pt; hit.line = local; hit.p1 = i; hit.p2 = next; distance = newDis; } } } return hit; }
java
public HitResult intersect(Shape shape, Line line) { float distance = Float.MAX_VALUE; HitResult hit = null; for (int i=0;i<shape.getPointCount();i++) { int next = rationalPoint(shape, i+1); Line local = getLine(shape, i, next); Vector2f pt = line.intersect(local, true); if (pt != null) { float newDis = pt.distance(line.getStart()); if ((newDis < distance) && (newDis > EPSILON)) { hit = new HitResult(); hit.pt = pt; hit.line = local; hit.p1 = i; hit.p2 = next; distance = newDis; } } } return hit; }
[ "public", "HitResult", "intersect", "(", "Shape", "shape", ",", "Line", "line", ")", "{", "float", "distance", "=", "Float", ".", "MAX_VALUE", ";", "HitResult", "hit", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "shape", ".", "getPointCount", "(", ")", ";", "i", "++", ")", "{", "int", "next", "=", "rationalPoint", "(", "shape", ",", "i", "+", "1", ")", ";", "Line", "local", "=", "getLine", "(", "shape", ",", "i", ",", "next", ")", ";", "Vector2f", "pt", "=", "line", ".", "intersect", "(", "local", ",", "true", ")", ";", "if", "(", "pt", "!=", "null", ")", "{", "float", "newDis", "=", "pt", ".", "distance", "(", "line", ".", "getStart", "(", ")", ")", ";", "if", "(", "(", "newDis", "<", "distance", ")", "&&", "(", "newDis", ">", "EPSILON", ")", ")", "{", "hit", "=", "new", "HitResult", "(", ")", ";", "hit", ".", "pt", "=", "pt", ";", "hit", ".", "line", "=", "local", ";", "hit", ".", "p1", "=", "i", ";", "hit", ".", "p2", "=", "next", ";", "distance", "=", "newDis", ";", "}", "}", "}", "return", "hit", ";", "}" ]
Intersect a line with a shape @param shape The shape to compare @param line The line to intersect against the shape @return The result describing the intersection or null if none
[ "Intersect", "a", "line", "with", "a", "shape" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java#L360-L383
1,687
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java
GeomUtil.rationalPoint
public static int rationalPoint(Shape shape, int p) { while (p < 0) { p += shape.getPointCount(); } while (p >= shape.getPointCount()) { p -= shape.getPointCount(); } return p; }
java
public static int rationalPoint(Shape shape, int p) { while (p < 0) { p += shape.getPointCount(); } while (p >= shape.getPointCount()) { p -= shape.getPointCount(); } return p; }
[ "public", "static", "int", "rationalPoint", "(", "Shape", "shape", ",", "int", "p", ")", "{", "while", "(", "p", "<", "0", ")", "{", "p", "+=", "shape", ".", "getPointCount", "(", ")", ";", "}", "while", "(", "p", ">=", "shape", ".", "getPointCount", "(", ")", ")", "{", "p", "-=", "shape", ".", "getPointCount", "(", ")", ";", "}", "return", "p", ";", "}" ]
Rationalise a point in terms of a given shape @param shape The shape @param p The index of the point @return The index that is rational for the shape
[ "Rationalise", "a", "point", "in", "terms", "of", "a", "given", "shape" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/GeomUtil.java#L392-L401
1,688
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Music.java
Music.poll
public static void poll(int delta) { if (currentMusic != null) { SoundStore.get().poll(delta); if (!SoundStore.get().isMusicPlaying()) { if (!currentMusic.positioning) { Music oldMusic = currentMusic; currentMusic = null; oldMusic.fireMusicEnded(); } } else { currentMusic.update(delta); } } }
java
public static void poll(int delta) { if (currentMusic != null) { SoundStore.get().poll(delta); if (!SoundStore.get().isMusicPlaying()) { if (!currentMusic.positioning) { Music oldMusic = currentMusic; currentMusic = null; oldMusic.fireMusicEnded(); } } else { currentMusic.update(delta); } } }
[ "public", "static", "void", "poll", "(", "int", "delta", ")", "{", "if", "(", "currentMusic", "!=", "null", ")", "{", "SoundStore", ".", "get", "(", ")", ".", "poll", "(", "delta", ")", ";", "if", "(", "!", "SoundStore", ".", "get", "(", ")", ".", "isMusicPlaying", "(", ")", ")", "{", "if", "(", "!", "currentMusic", ".", "positioning", ")", "{", "Music", "oldMusic", "=", "currentMusic", ";", "currentMusic", "=", "null", ";", "oldMusic", ".", "fireMusicEnded", "(", ")", ";", "}", "}", "else", "{", "currentMusic", ".", "update", "(", "delta", ")", ";", "}", "}", "}" ]
Poll the state of the current music. This causes streaming music to stream and checks listeners. Note that if you're using a game container this will be auto-magically called for you. @param delta The amount of time since last poll
[ "Poll", "the", "state", "of", "the", "current", "music", ".", "This", "causes", "streaming", "music", "to", "stream", "and", "checks", "listeners", ".", "Note", "that", "if", "you", "re", "using", "a", "game", "container", "this", "will", "be", "auto", "-", "magically", "called", "for", "you", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Music.java#L30-L43
1,689
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Music.java
Music.fireMusicEnded
private void fireMusicEnded() { playing = false; for (int i=0;i<listeners.size();i++) { ((MusicListener) listeners.get(i)).musicEnded(this); } }
java
private void fireMusicEnded() { playing = false; for (int i=0;i<listeners.size();i++) { ((MusicListener) listeners.get(i)).musicEnded(this); } }
[ "private", "void", "fireMusicEnded", "(", ")", "{", "playing", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "size", "(", ")", ";", "i", "++", ")", "{", "(", "(", "MusicListener", ")", "listeners", ".", "get", "(", "i", ")", ")", ".", "musicEnded", "(", "this", ")", ";", "}", "}" ]
Fire notifications that this music ended
[ "Fire", "notifications", "that", "this", "music", "ended" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Music.java#L201-L206
1,690
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Music.java
Music.fireMusicSwapped
private void fireMusicSwapped(Music newMusic) { playing = false; for (int i=0;i<listeners.size();i++) { ((MusicListener) listeners.get(i)).musicSwapped(this, newMusic); } }
java
private void fireMusicSwapped(Music newMusic) { playing = false; for (int i=0;i<listeners.size();i++) { ((MusicListener) listeners.get(i)).musicSwapped(this, newMusic); } }
[ "private", "void", "fireMusicSwapped", "(", "Music", "newMusic", ")", "{", "playing", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "size", "(", ")", ";", "i", "++", ")", "{", "(", "(", "MusicListener", ")", "listeners", ".", "get", "(", "i", ")", ")", ".", "musicSwapped", "(", "this", ",", "newMusic", ")", ";", "}", "}" ]
Fire notifications that this music was swapped out @param newMusic The new music that will be played
[ "Fire", "notifications", "that", "this", "music", "was", "swapped", "out" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Music.java#L213-L218
1,691
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Music.java
Music.startMusic
private void startMusic(float pitch, float volume, boolean loop) { if (currentMusic != null) { currentMusic.stop(); currentMusic.fireMusicSwapped(this); } currentMusic = this; if (volume < 0.0f) volume = 0.0f; if (volume > 1.0f) volume = 1.0f; sound.playAsMusic(pitch, volume, loop); playing = true; setVolume(volume); if (requiredPosition != -1) { setPosition(requiredPosition); } }
java
private void startMusic(float pitch, float volume, boolean loop) { if (currentMusic != null) { currentMusic.stop(); currentMusic.fireMusicSwapped(this); } currentMusic = this; if (volume < 0.0f) volume = 0.0f; if (volume > 1.0f) volume = 1.0f; sound.playAsMusic(pitch, volume, loop); playing = true; setVolume(volume); if (requiredPosition != -1) { setPosition(requiredPosition); } }
[ "private", "void", "startMusic", "(", "float", "pitch", ",", "float", "volume", ",", "boolean", "loop", ")", "{", "if", "(", "currentMusic", "!=", "null", ")", "{", "currentMusic", ".", "stop", "(", ")", ";", "currentMusic", ".", "fireMusicSwapped", "(", "this", ")", ";", "}", "currentMusic", "=", "this", ";", "if", "(", "volume", "<", "0.0f", ")", "volume", "=", "0.0f", ";", "if", "(", "volume", ">", "1.0f", ")", "volume", "=", "1.0f", ";", "sound", ".", "playAsMusic", "(", "pitch", ",", "volume", ",", "loop", ")", ";", "playing", "=", "true", ";", "setVolume", "(", "volume", ")", ";", "if", "(", "requiredPosition", "!=", "-", "1", ")", "{", "setPosition", "(", "requiredPosition", ")", ";", "}", "}" ]
play or loop the music at a given pitch and volume @param pitch The pitch to play the music at (1.0 = default) @param volume The volume to play the music at (1.0 = default) @param loop if false the music is played once, the music is looped otherwise
[ "play", "or", "loop", "the", "music", "at", "a", "given", "pitch", "and", "volume" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Music.java#L259-L277
1,692
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Music.java
Music.setVolume
public void setVolume(float volume) { // Bounds check if(volume > 1) { volume = 1; } else if(volume < 0) { volume = 0; } this.volume = volume; // This sound is being played as music if (currentMusic == this) { SoundStore.get().setCurrentMusicVolume(volume); } }
java
public void setVolume(float volume) { // Bounds check if(volume > 1) { volume = 1; } else if(volume < 0) { volume = 0; } this.volume = volume; // This sound is being played as music if (currentMusic == this) { SoundStore.get().setCurrentMusicVolume(volume); } }
[ "public", "void", "setVolume", "(", "float", "volume", ")", "{", "// Bounds check\r", "if", "(", "volume", ">", "1", ")", "{", "volume", "=", "1", ";", "}", "else", "if", "(", "volume", "<", "0", ")", "{", "volume", "=", "0", ";", "}", "this", ".", "volume", "=", "volume", ";", "// This sound is being played as music\r", "if", "(", "currentMusic", "==", "this", ")", "{", "SoundStore", ".", "get", "(", ")", ".", "setCurrentMusicVolume", "(", "volume", ")", ";", "}", "}" ]
Set the volume of the music as a factor of the global volume setting @param volume The volume to play music at. 0 - 1, 1 is Max
[ "Set", "the", "volume", "of", "the", "music", "as", "a", "factor", "of", "the", "global", "volume", "setting" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Music.java#L317-L330
1,693
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Music.java
Music.fade
public void fade (int duration, float endVolume, boolean stopAfterFade) { this.stopAfterFade = stopAfterFade; fadeStartGain = volume; fadeEndGain = endVolume; fadeDuration = duration; fadeTime = duration; }
java
public void fade (int duration, float endVolume, boolean stopAfterFade) { this.stopAfterFade = stopAfterFade; fadeStartGain = volume; fadeEndGain = endVolume; fadeDuration = duration; fadeTime = duration; }
[ "public", "void", "fade", "(", "int", "duration", ",", "float", "endVolume", ",", "boolean", "stopAfterFade", ")", "{", "this", ".", "stopAfterFade", "=", "stopAfterFade", ";", "fadeStartGain", "=", "volume", ";", "fadeEndGain", "=", "endVolume", ";", "fadeDuration", "=", "duration", ";", "fadeTime", "=", "duration", ";", "}" ]
Fade this music to the volume specified @param duration Fade time in milliseconds. @param endVolume The target volume @param stopAfterFade True if music should be stopped after fading in/out
[ "Fade", "this", "music", "to", "the", "volume", "specified" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Music.java#L347-L353
1,694
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Music.java
Music.update
void update(int delta) { if (!playing) { return; } if (fadeTime > 0) { fadeTime -= delta; if (fadeTime <= 0) { fadeTime = 0; if (stopAfterFade) { stop(); return; } } float offset = (fadeEndGain - fadeStartGain) * (1 - (fadeTime / (float)fadeDuration)); setVolume(fadeStartGain + offset); } }
java
void update(int delta) { if (!playing) { return; } if (fadeTime > 0) { fadeTime -= delta; if (fadeTime <= 0) { fadeTime = 0; if (stopAfterFade) { stop(); return; } } float offset = (fadeEndGain - fadeStartGain) * (1 - (fadeTime / (float)fadeDuration)); setVolume(fadeStartGain + offset); } }
[ "void", "update", "(", "int", "delta", ")", "{", "if", "(", "!", "playing", ")", "{", "return", ";", "}", "if", "(", "fadeTime", ">", "0", ")", "{", "fadeTime", "-=", "delta", ";", "if", "(", "fadeTime", "<=", "0", ")", "{", "fadeTime", "=", "0", ";", "if", "(", "stopAfterFade", ")", "{", "stop", "(", ")", ";", "return", ";", "}", "}", "float", "offset", "=", "(", "fadeEndGain", "-", "fadeStartGain", ")", "*", "(", "1", "-", "(", "fadeTime", "/", "(", "float", ")", "fadeDuration", ")", ")", ";", "setVolume", "(", "fadeStartGain", "+", "offset", ")", ";", "}", "}" ]
Update the current music applying any effects that need to updated per tick. @param delta The amount of time in milliseconds thats passed since last update
[ "Update", "the", "current", "music", "applying", "any", "effects", "that", "need", "to", "updated", "per", "tick", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Music.java#L361-L379
1,695
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Music.java
Music.setPosition
public boolean setPosition(float position) { if (playing) { requiredPosition = -1; positioning = true; playing = false; boolean result = sound.setPosition(position); playing = true; positioning = false; return result; } else { requiredPosition = position; return false; } }
java
public boolean setPosition(float position) { if (playing) { requiredPosition = -1; positioning = true; playing = false; boolean result = sound.setPosition(position); playing = true; positioning = false; return result; } else { requiredPosition = position; return false; } }
[ "public", "boolean", "setPosition", "(", "float", "position", ")", "{", "if", "(", "playing", ")", "{", "requiredPosition", "=", "-", "1", ";", "positioning", "=", "true", ";", "playing", "=", "false", ";", "boolean", "result", "=", "sound", ".", "setPosition", "(", "position", ")", ";", "playing", "=", "true", ";", "positioning", "=", "false", ";", "return", "result", ";", "}", "else", "{", "requiredPosition", "=", "position", ";", "return", "false", ";", "}", "}" ]
Seeks to a position in the music. For streaming music, seeking before the current position causes the stream to be reloaded. @param position Position in seconds. @return True if the seek was successful
[ "Seeks", "to", "a", "position", "in", "the", "music", ".", "For", "streaming", "music", "seeking", "before", "the", "current", "position", "causes", "the", "stream", "to", "be", "reloaded", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Music.java#L388-L403
1,696
nguillaumin/slick2d-maven
slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Pack.java
Pack.main
public static void main(String[] argv) throws IOException { File dir = new File("."); dir = new File("C:\\eclipse\\grobot-workspace\\anon\\res\\tiles\\indoor1"); ArrayList list = new ArrayList(); File[] files = dir.listFiles(); for (int i=0;i<files.length;i++) { if (files[i].getName().endsWith(".png")) { if (!files[i].getName().startsWith("output")) { list.add(files[i]); } } } Pack packer = new Pack(); packer.pack(list, 512, 512, 1, new File(dir, "output.png")); System.out.println("Output Generated."); }
java
public static void main(String[] argv) throws IOException { File dir = new File("."); dir = new File("C:\\eclipse\\grobot-workspace\\anon\\res\\tiles\\indoor1"); ArrayList list = new ArrayList(); File[] files = dir.listFiles(); for (int i=0;i<files.length;i++) { if (files[i].getName().endsWith(".png")) { if (!files[i].getName().startsWith("output")) { list.add(files[i]); } } } Pack packer = new Pack(); packer.pack(list, 512, 512, 1, new File(dir, "output.png")); System.out.println("Output Generated."); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "argv", ")", "throws", "IOException", "{", "File", "dir", "=", "new", "File", "(", "\".\"", ")", ";", "dir", "=", "new", "File", "(", "\"C:\\\\eclipse\\\\grobot-workspace\\\\anon\\\\res\\\\tiles\\\\indoor1\"", ")", ";", "ArrayList", "list", "=", "new", "ArrayList", "(", ")", ";", "File", "[", "]", "files", "=", "dir", ".", "listFiles", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "files", ".", "length", ";", "i", "++", ")", "{", "if", "(", "files", "[", "i", "]", ".", "getName", "(", ")", ".", "endsWith", "(", "\".png\"", ")", ")", "{", "if", "(", "!", "files", "[", "i", "]", ".", "getName", "(", ")", ".", "startsWith", "(", "\"output\"", ")", ")", "{", "list", ".", "add", "(", "files", "[", "i", "]", ")", ";", "}", "}", "}", "Pack", "packer", "=", "new", "Pack", "(", ")", ";", "packer", ".", "pack", "(", "list", ",", "512", ",", "512", ",", "1", ",", "new", "File", "(", "dir", ",", "\"output.png\"", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"Output Generated.\"", ")", ";", "}" ]
Entry point to the tool, just pack the current directory of images @param argv The arguments to the program @throws IOException Indicates a failure to write out files
[ "Entry", "point", "to", "the", "tool", "just", "pack", "the", "current", "directory", "of", "images" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Pack.java#L148-L165
1,697
nguillaumin/slick2d-maven
slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Sprite.java
Sprite.contains
public boolean contains(int xp, int yp) { if (xp < x) { return false; } if (yp < y) { return false; } if (xp >= x+width) { return false; } if (yp >= y+height) { return false; } return true; }
java
public boolean contains(int xp, int yp) { if (xp < x) { return false; } if (yp < y) { return false; } if (xp >= x+width) { return false; } if (yp >= y+height) { return false; } return true; }
[ "public", "boolean", "contains", "(", "int", "xp", ",", "int", "yp", ")", "{", "if", "(", "xp", "<", "x", ")", "{", "return", "false", ";", "}", "if", "(", "yp", "<", "y", ")", "{", "return", "false", ";", "}", "if", "(", "xp", ">=", "x", "+", "width", ")", "{", "return", "false", ";", "}", "if", "(", "yp", ">=", "y", "+", "height", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if this sprite location contains the given x,y position @param xp The x position of the sprite @param yp The y position of the sprite @return True if the sprite contains the point
[ "Check", "if", "this", "sprite", "location", "contains", "the", "given", "x", "y", "position" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-packulike/src/main/java/org/newdawn/slick/tools/packulike/Sprite.java#L124-L139
1,698
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ParticleGame.java
ParticleGame.addEmitter
public void addEmitter(ConfigurableEmitter emitter) { emitters.add(emitter); if (system == null) { waiting.add(emitter); } else { system.addEmitter(emitter); } }
java
public void addEmitter(ConfigurableEmitter emitter) { emitters.add(emitter); if (system == null) { waiting.add(emitter); } else { system.addEmitter(emitter); } }
[ "public", "void", "addEmitter", "(", "ConfigurableEmitter", "emitter", ")", "{", "emitters", ".", "add", "(", "emitter", ")", ";", "if", "(", "system", "==", "null", ")", "{", "waiting", ".", "add", "(", "emitter", ")", ";", "}", "else", "{", "system", ".", "addEmitter", "(", "emitter", ")", ";", "}", "}" ]
Add an emitter to the particle system held here @param emitter The emitter to add
[ "Add", "an", "emitter", "to", "the", "particle", "system", "held", "here" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ParticleGame.java#L156-L164
1,699
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ParticleGame.java
ParticleGame.clearSystem
public void clearSystem(boolean additive) { system = new ParticleSystem("org/newdawn/slick/data/particle.tga", 2000); if (additive) { system.setBlendingMode(ParticleSystem.BLEND_ADDITIVE); } system.setRemoveCompletedEmitters(false); }
java
public void clearSystem(boolean additive) { system = new ParticleSystem("org/newdawn/slick/data/particle.tga", 2000); if (additive) { system.setBlendingMode(ParticleSystem.BLEND_ADDITIVE); } system.setRemoveCompletedEmitters(false); }
[ "public", "void", "clearSystem", "(", "boolean", "additive", ")", "{", "system", "=", "new", "ParticleSystem", "(", "\"org/newdawn/slick/data/particle.tga\"", ",", "2000", ")", ";", "if", "(", "additive", ")", "{", "system", ".", "setBlendingMode", "(", "ParticleSystem", ".", "BLEND_ADDITIVE", ")", ";", "}", "system", ".", "setRemoveCompletedEmitters", "(", "false", ")", ";", "}" ]
Clear the particle system held in this canvas @param additive True if the particle system should be set to additive
[ "Clear", "the", "particle", "system", "held", "in", "this", "canvas" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ParticleGame.java#L184-L190