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,500
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/Diagram.java
Diagram.addFigure
public void addFigure(Figure figure) { figures.add(figure); figureMap.put(figure.getData().getAttribute(NonGeometricData.ID), figure); String fillRef = figure.getData().getAsReference(NonGeometricData.FILL); Gradient gradient = getGradient(fillRef); if (gradient != null) { if (gradient.isRadial()) { for (int i=0;i<InkscapeLoader.RADIAL_TRIANGULATION_LEVEL;i++) { figure.getShape().increaseTriangulation(); } } } }
java
public void addFigure(Figure figure) { figures.add(figure); figureMap.put(figure.getData().getAttribute(NonGeometricData.ID), figure); String fillRef = figure.getData().getAsReference(NonGeometricData.FILL); Gradient gradient = getGradient(fillRef); if (gradient != null) { if (gradient.isRadial()) { for (int i=0;i<InkscapeLoader.RADIAL_TRIANGULATION_LEVEL;i++) { figure.getShape().increaseTriangulation(); } } } }
[ "public", "void", "addFigure", "(", "Figure", "figure", ")", "{", "figures", ".", "add", "(", "figure", ")", ";", "figureMap", ".", "put", "(", "figure", ".", "getData", "(", ")", ".", "getAttribute", "(", "NonGeometricData", ".", "ID", ")", ",", "figure", ")", ";", "String", "fillRef", "=", "figure", ".", "getData", "(", ")", ".", "getAsReference", "(", "NonGeometricData", ".", "FILL", ")", ";", "Gradient", "gradient", "=", "getGradient", "(", "fillRef", ")", ";", "if", "(", "gradient", "!=", "null", ")", "{", "if", "(", "gradient", ".", "isRadial", "(", ")", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "InkscapeLoader", ".", "RADIAL_TRIANGULATION_LEVEL", ";", "i", "++", ")", "{", "figure", ".", "getShape", "(", ")", ".", "increaseTriangulation", "(", ")", ";", "}", "}", "}", "}" ]
Add a figure to the diagram @param figure The figure to add
[ "Add", "a", "figure", "to", "the", "diagram" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/Diagram.java#L119-L132
1,501
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/Diagram.java
Diagram.removeFigure
public void removeFigure(Figure figure) { figures.remove(figure); figureMap.remove(figure.getData().getAttribute("id")); }
java
public void removeFigure(Figure figure) { figures.remove(figure); figureMap.remove(figure.getData().getAttribute("id")); }
[ "public", "void", "removeFigure", "(", "Figure", "figure", ")", "{", "figures", ".", "remove", "(", "figure", ")", ";", "figureMap", ".", "remove", "(", "figure", ".", "getData", "(", ")", ".", "getAttribute", "(", "\"id\"", ")", ")", ";", "}" ]
Remove a figure from the diagram @param figure The figure to be removed
[ "Remove", "a", "figure", "from", "the", "diagram" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/Diagram.java#L158-L161
1,502
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/Gradient.java
Gradient.resolve
public void resolve(Diagram diagram) { if (ref == null) { return; } Gradient other = diagram.getGradient(ref); for (int i=0;i<other.steps.size();i++) { steps.add(other.steps.get(i)); } }
java
public void resolve(Diagram diagram) { if (ref == null) { return; } Gradient other = diagram.getGradient(ref); for (int i=0;i<other.steps.size();i++) { steps.add(other.steps.get(i)); } }
[ "public", "void", "resolve", "(", "Diagram", "diagram", ")", "{", "if", "(", "ref", "==", "null", ")", "{", "return", ";", "}", "Gradient", "other", "=", "diagram", ".", "getGradient", "(", "ref", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "other", ".", "steps", ".", "size", "(", ")", ";", "i", "++", ")", "{", "steps", ".", "add", "(", "other", ".", "steps", ".", "get", "(", "i", ")", ")", ";", "}", "}" ]
Resolve the gradient reference @param diagram The diagram to resolve against
[ "Resolve", "the", "gradient", "reference" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/Gradient.java#L91-L101
1,503
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/Gradient.java
Gradient.genImage
public void genImage() { if (image == null) { ImageBuffer buffer = new ImageBuffer(128,16); for (int i=0;i<128;i++) { Color col = getColorAt(i / 128.0f); for (int j=0;j<16;j++) { buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte()); } } image = buffer.getImage(); } }
java
public void genImage() { if (image == null) { ImageBuffer buffer = new ImageBuffer(128,16); for (int i=0;i<128;i++) { Color col = getColorAt(i / 128.0f); for (int j=0;j<16;j++) { buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte()); } } image = buffer.getImage(); } }
[ "public", "void", "genImage", "(", ")", "{", "if", "(", "image", "==", "null", ")", "{", "ImageBuffer", "buffer", "=", "new", "ImageBuffer", "(", "128", ",", "16", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "128", ";", "i", "++", ")", "{", "Color", "col", "=", "getColorAt", "(", "i", "/", "128.0f", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "16", ";", "j", "++", ")", "{", "buffer", ".", "setRGBA", "(", "i", ",", "j", ",", "col", ".", "getRedByte", "(", ")", ",", "col", ".", "getGreenByte", "(", ")", ",", "col", ".", "getBlueByte", "(", ")", ",", "col", ".", "getAlphaByte", "(", ")", ")", ";", "}", "}", "image", "=", "buffer", ".", "getImage", "(", ")", ";", "}", "}" ]
Generate the image used for texturing the gradient across shapes
[ "Generate", "the", "image", "used", "for", "texturing", "the", "gradient", "across", "shapes" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/Gradient.java#L106-L117
1,504
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/Gradient.java
Gradient.getColorAt
public Color getColorAt(float p) { if (p <= 0) { return ((Step) steps.get(0)).col; } if (p > 1) { return ((Step) steps.get(steps.size()-1)).col; } for (int i=1;i<steps.size();i++) { Step prev = ((Step) steps.get(i-1)); Step current = ((Step) steps.get(i)); if (p <= current.location) { float dis = current.location - prev.location; p -= prev.location; float v = p / dis; Color c = new Color(1,1,1,1); c.a = (prev.col.a * (1 - v)) + (current.col.a * (v)); c.r = (prev.col.r * (1 - v)) + (current.col.r * (v)); c.g = (prev.col.g * (1 - v)) + (current.col.g * (v)); c.b = (prev.col.b * (1 - v)) + (current.col.b * (v)); return c; } } // shouldn't ever happen return Color.black; }
java
public Color getColorAt(float p) { if (p <= 0) { return ((Step) steps.get(0)).col; } if (p > 1) { return ((Step) steps.get(steps.size()-1)).col; } for (int i=1;i<steps.size();i++) { Step prev = ((Step) steps.get(i-1)); Step current = ((Step) steps.get(i)); if (p <= current.location) { float dis = current.location - prev.location; p -= prev.location; float v = p / dis; Color c = new Color(1,1,1,1); c.a = (prev.col.a * (1 - v)) + (current.col.a * (v)); c.r = (prev.col.r * (1 - v)) + (current.col.r * (v)); c.g = (prev.col.g * (1 - v)) + (current.col.g * (v)); c.b = (prev.col.b * (1 - v)) + (current.col.b * (v)); return c; } } // shouldn't ever happen return Color.black; }
[ "public", "Color", "getColorAt", "(", "float", "p", ")", "{", "if", "(", "p", "<=", "0", ")", "{", "return", "(", "(", "Step", ")", "steps", ".", "get", "(", "0", ")", ")", ".", "col", ";", "}", "if", "(", "p", ">", "1", ")", "{", "return", "(", "(", "Step", ")", "steps", ".", "get", "(", "steps", ".", "size", "(", ")", "-", "1", ")", ")", ".", "col", ";", "}", "for", "(", "int", "i", "=", "1", ";", "i", "<", "steps", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Step", "prev", "=", "(", "(", "Step", ")", "steps", ".", "get", "(", "i", "-", "1", ")", ")", ";", "Step", "current", "=", "(", "(", "Step", ")", "steps", ".", "get", "(", "i", ")", ")", ";", "if", "(", "p", "<=", "current", ".", "location", ")", "{", "float", "dis", "=", "current", ".", "location", "-", "prev", ".", "location", ";", "p", "-=", "prev", ".", "location", ";", "float", "v", "=", "p", "/", "dis", ";", "Color", "c", "=", "new", "Color", "(", "1", ",", "1", ",", "1", ",", "1", ")", ";", "c", ".", "a", "=", "(", "prev", ".", "col", ".", "a", "*", "(", "1", "-", "v", ")", ")", "+", "(", "current", ".", "col", ".", "a", "*", "(", "v", ")", ")", ";", "c", ".", "r", "=", "(", "prev", ".", "col", ".", "r", "*", "(", "1", "-", "v", ")", ")", "+", "(", "current", ".", "col", ".", "r", "*", "(", "v", ")", ")", ";", "c", ".", "g", "=", "(", "prev", ".", "col", ".", "g", "*", "(", "1", "-", "v", ")", ")", "+", "(", "current", ".", "col", ".", "g", "*", "(", "v", ")", ")", ";", "c", ".", "b", "=", "(", "prev", ".", "col", ".", "b", "*", "(", "1", "-", "v", ")", ")", "+", "(", "current", ".", "col", ".", "b", "*", "(", "v", ")", ")", ";", "return", "c", ";", "}", "}", "// shouldn't ever happen\r", "return", "Color", ".", "black", ";", "}" ]
Get the intepolated colour at the given location on the gradient @param p The point of the gradient (0 >= n >= 1) @return The interpolated colour at the given location
[ "Get", "the", "intepolated", "colour", "at", "the", "given", "location", "on", "the", "gradient" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/Gradient.java#L236-L265
1,505
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java
AppGameContainer.setDisplayMode
public void setDisplayMode(int width, int height, boolean fullscreen) throws SlickException { if ((this.width == width) && (this.height == height) && (isFullscreen() == fullscreen)) { return; } try { targetDisplayMode = null; if (fullscreen) { DisplayMode[] modes = Display.getAvailableDisplayModes(); int freq = 0; for (int i=0;i<modes.length;i++) { DisplayMode current = modes[i]; if ((current.getWidth() == width) && (current.getHeight() == height)) { if ((targetDisplayMode == null) || (current.getFrequency() >= freq)) { if ((targetDisplayMode == null) || (current.getBitsPerPixel() > targetDisplayMode.getBitsPerPixel())) { targetDisplayMode = current; freq = targetDisplayMode.getFrequency(); } } // if we've found a match for bpp and frequence against the // original display mode then it's probably best to go for this one // since it's most likely compatible with the monitor if ((current.getBitsPerPixel() == originalDisplayMode.getBitsPerPixel()) && (current.getFrequency() == originalDisplayMode.getFrequency())) { targetDisplayMode = current; break; } } } } else { targetDisplayMode = new DisplayMode(width,height); } if (targetDisplayMode == null) { throw new SlickException("Failed to find value mode: "+width+"x"+height+" fs="+fullscreen); } this.width = width; this.height = height; Display.setDisplayMode(targetDisplayMode); Display.setFullscreen(fullscreen); if (Display.isCreated()) { initGL(); enterOrtho(); } if (targetDisplayMode.getBitsPerPixel() == 16) { InternalTextureLoader.get().set16BitMode(); } } catch (LWJGLException e) { throw new SlickException("Unable to setup mode "+width+"x"+height+" fullscreen="+fullscreen, e); } getDelta(); }
java
public void setDisplayMode(int width, int height, boolean fullscreen) throws SlickException { if ((this.width == width) && (this.height == height) && (isFullscreen() == fullscreen)) { return; } try { targetDisplayMode = null; if (fullscreen) { DisplayMode[] modes = Display.getAvailableDisplayModes(); int freq = 0; for (int i=0;i<modes.length;i++) { DisplayMode current = modes[i]; if ((current.getWidth() == width) && (current.getHeight() == height)) { if ((targetDisplayMode == null) || (current.getFrequency() >= freq)) { if ((targetDisplayMode == null) || (current.getBitsPerPixel() > targetDisplayMode.getBitsPerPixel())) { targetDisplayMode = current; freq = targetDisplayMode.getFrequency(); } } // if we've found a match for bpp and frequence against the // original display mode then it's probably best to go for this one // since it's most likely compatible with the monitor if ((current.getBitsPerPixel() == originalDisplayMode.getBitsPerPixel()) && (current.getFrequency() == originalDisplayMode.getFrequency())) { targetDisplayMode = current; break; } } } } else { targetDisplayMode = new DisplayMode(width,height); } if (targetDisplayMode == null) { throw new SlickException("Failed to find value mode: "+width+"x"+height+" fs="+fullscreen); } this.width = width; this.height = height; Display.setDisplayMode(targetDisplayMode); Display.setFullscreen(fullscreen); if (Display.isCreated()) { initGL(); enterOrtho(); } if (targetDisplayMode.getBitsPerPixel() == 16) { InternalTextureLoader.get().set16BitMode(); } } catch (LWJGLException e) { throw new SlickException("Unable to setup mode "+width+"x"+height+" fullscreen="+fullscreen, e); } getDelta(); }
[ "public", "void", "setDisplayMode", "(", "int", "width", ",", "int", "height", ",", "boolean", "fullscreen", ")", "throws", "SlickException", "{", "if", "(", "(", "this", ".", "width", "==", "width", ")", "&&", "(", "this", ".", "height", "==", "height", ")", "&&", "(", "isFullscreen", "(", ")", "==", "fullscreen", ")", ")", "{", "return", ";", "}", "try", "{", "targetDisplayMode", "=", "null", ";", "if", "(", "fullscreen", ")", "{", "DisplayMode", "[", "]", "modes", "=", "Display", ".", "getAvailableDisplayModes", "(", ")", ";", "int", "freq", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "modes", ".", "length", ";", "i", "++", ")", "{", "DisplayMode", "current", "=", "modes", "[", "i", "]", ";", "if", "(", "(", "current", ".", "getWidth", "(", ")", "==", "width", ")", "&&", "(", "current", ".", "getHeight", "(", ")", "==", "height", ")", ")", "{", "if", "(", "(", "targetDisplayMode", "==", "null", ")", "||", "(", "current", ".", "getFrequency", "(", ")", ">=", "freq", ")", ")", "{", "if", "(", "(", "targetDisplayMode", "==", "null", ")", "||", "(", "current", ".", "getBitsPerPixel", "(", ")", ">", "targetDisplayMode", ".", "getBitsPerPixel", "(", ")", ")", ")", "{", "targetDisplayMode", "=", "current", ";", "freq", "=", "targetDisplayMode", ".", "getFrequency", "(", ")", ";", "}", "}", "// if we've found a match for bpp and frequence against the \r", "// original display mode then it's probably best to go for this one\r", "// since it's most likely compatible with the monitor\r", "if", "(", "(", "current", ".", "getBitsPerPixel", "(", ")", "==", "originalDisplayMode", ".", "getBitsPerPixel", "(", ")", ")", "&&", "(", "current", ".", "getFrequency", "(", ")", "==", "originalDisplayMode", ".", "getFrequency", "(", ")", ")", ")", "{", "targetDisplayMode", "=", "current", ";", "break", ";", "}", "}", "}", "}", "else", "{", "targetDisplayMode", "=", "new", "DisplayMode", "(", "width", ",", "height", ")", ";", "}", "if", "(", "targetDisplayMode", "==", "null", ")", "{", "throw", "new", "SlickException", "(", "\"Failed to find value mode: \"", "+", "width", "+", "\"x\"", "+", "height", "+", "\" fs=\"", "+", "fullscreen", ")", ";", "}", "this", ".", "width", "=", "width", ";", "this", ".", "height", "=", "height", ";", "Display", ".", "setDisplayMode", "(", "targetDisplayMode", ")", ";", "Display", ".", "setFullscreen", "(", "fullscreen", ")", ";", "if", "(", "Display", ".", "isCreated", "(", ")", ")", "{", "initGL", "(", ")", ";", "enterOrtho", "(", ")", ";", "}", "if", "(", "targetDisplayMode", ".", "getBitsPerPixel", "(", ")", "==", "16", ")", "{", "InternalTextureLoader", ".", "get", "(", ")", ".", "set16BitMode", "(", ")", ";", "}", "}", "catch", "(", "LWJGLException", "e", ")", "{", "throw", "new", "SlickException", "(", "\"Unable to setup mode \"", "+", "width", "+", "\"x\"", "+", "height", "+", "\" fullscreen=\"", "+", "fullscreen", ",", "e", ")", ";", "}", "getDelta", "(", ")", ";", "}" ]
Set the display mode to be used @param width The width of the display required @param height The height of the display required @param fullscreen True if we want fullscreen mode @throws SlickException Indicates a failure to initialise the display
[ "Set", "the", "display", "mode", "to", "be", "used" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java#L109-L168
1,506
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java
AppGameContainer.setFullscreen
public void setFullscreen(boolean fullscreen) throws SlickException { if (isFullscreen() == fullscreen) { return; } if (!fullscreen) { try { Display.setFullscreen(fullscreen); } catch (LWJGLException e) { throw new SlickException("Unable to set fullscreen="+fullscreen, e); } } else { setDisplayMode(width, height, fullscreen); } getDelta(); }
java
public void setFullscreen(boolean fullscreen) throws SlickException { if (isFullscreen() == fullscreen) { return; } if (!fullscreen) { try { Display.setFullscreen(fullscreen); } catch (LWJGLException e) { throw new SlickException("Unable to set fullscreen="+fullscreen, e); } } else { setDisplayMode(width, height, fullscreen); } getDelta(); }
[ "public", "void", "setFullscreen", "(", "boolean", "fullscreen", ")", "throws", "SlickException", "{", "if", "(", "isFullscreen", "(", ")", "==", "fullscreen", ")", "{", "return", ";", "}", "if", "(", "!", "fullscreen", ")", "{", "try", "{", "Display", ".", "setFullscreen", "(", "fullscreen", ")", ";", "}", "catch", "(", "LWJGLException", "e", ")", "{", "throw", "new", "SlickException", "(", "\"Unable to set fullscreen=\"", "+", "fullscreen", ",", "e", ")", ";", "}", "}", "else", "{", "setDisplayMode", "(", "width", ",", "height", ",", "fullscreen", ")", ";", "}", "getDelta", "(", ")", ";", "}" ]
Indicate whether we want to be in fullscreen mode. Note that the current display mode must be valid as a fullscreen mode for this to work @param fullscreen True if we want to be in fullscreen mode @throws SlickException Indicates we failed to change the display mode
[ "Indicate", "whether", "we", "want", "to", "be", "in", "fullscreen", "mode", ".", "Note", "that", "the", "current", "display", "mode", "must", "be", "valid", "as", "a", "fullscreen", "mode", "for", "this", "to", "work" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java#L186-L201
1,507
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java
AppGameContainer.tryCreateDisplay
private void tryCreateDisplay(PixelFormat format) throws LWJGLException { if (SHARED_DRAWABLE == null) { Display.create(format); } else { Display.create(format, SHARED_DRAWABLE); } }
java
private void tryCreateDisplay(PixelFormat format) throws LWJGLException { if (SHARED_DRAWABLE == null) { Display.create(format); } else { Display.create(format, SHARED_DRAWABLE); } }
[ "private", "void", "tryCreateDisplay", "(", "PixelFormat", "format", ")", "throws", "LWJGLException", "{", "if", "(", "SHARED_DRAWABLE", "==", "null", ")", "{", "Display", ".", "create", "(", "format", ")", ";", "}", "else", "{", "Display", ".", "create", "(", "format", ",", "SHARED_DRAWABLE", ")", ";", "}", "}" ]
Try creating a display with the given format @param format The format to attempt @throws LWJGLException Indicates a failure to support the given format
[ "Try", "creating", "a", "display", "with", "the", "given", "format" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java#L299-L308
1,508
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java
AppGameContainer.start
public void start() throws SlickException { try { setup(); getDelta(); while (running()) { gameLoop(); } } finally { destroy(); } if (forceExit) { System.exit(0); } }
java
public void start() throws SlickException { try { setup(); getDelta(); while (running()) { gameLoop(); } } finally { destroy(); } if (forceExit) { System.exit(0); } }
[ "public", "void", "start", "(", ")", "throws", "SlickException", "{", "try", "{", "setup", "(", ")", ";", "getDelta", "(", ")", ";", "while", "(", "running", "(", ")", ")", "{", "gameLoop", "(", ")", ";", "}", "}", "finally", "{", "destroy", "(", ")", ";", "}", "if", "(", "forceExit", ")", "{", "System", ".", "exit", "(", "0", ")", ";", "}", "}" ]
Start running the game @throws SlickException Indicates a failure to initialise the system
[ "Start", "running", "the", "game" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java#L315-L330
1,509
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java
AppGameContainer.setup
protected void setup() throws SlickException { if (targetDisplayMode == null) { setDisplayMode(640,480,false); } Display.setTitle(game.getTitle()); Log.info("LWJGL Version: "+Sys.getVersion()); Log.info("OriginalDisplayMode: "+originalDisplayMode); Log.info("TargetDisplayMode: "+targetDisplayMode); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { PixelFormat format = new PixelFormat(8,8,stencil ? 8 : 0,samples); tryCreateDisplay(format); supportsMultiSample = true; } catch (Exception e) { Display.destroy(); try { PixelFormat format = new PixelFormat(8,8,stencil ? 8 : 0); tryCreateDisplay(format); alphaSupport = false; } catch (Exception e2) { Display.destroy(); // if we couldn't get alpha, let us know try { tryCreateDisplay(new PixelFormat()); } catch (Exception e3) { Log.error(e3); } } } return null; }}); if (!Display.isCreated()) { throw new SlickException("Failed to initialise the LWJGL display"); } initSystem(); enterOrtho(); try { getInput().initControllers(); } catch (SlickException e) { Log.info("Controllers not available"); } catch (Throwable e) { Log.info("Controllers not available"); } try { game.init(this); } catch (SlickException e) { Log.error(e); running = false; } }
java
protected void setup() throws SlickException { if (targetDisplayMode == null) { setDisplayMode(640,480,false); } Display.setTitle(game.getTitle()); Log.info("LWJGL Version: "+Sys.getVersion()); Log.info("OriginalDisplayMode: "+originalDisplayMode); Log.info("TargetDisplayMode: "+targetDisplayMode); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { PixelFormat format = new PixelFormat(8,8,stencil ? 8 : 0,samples); tryCreateDisplay(format); supportsMultiSample = true; } catch (Exception e) { Display.destroy(); try { PixelFormat format = new PixelFormat(8,8,stencil ? 8 : 0); tryCreateDisplay(format); alphaSupport = false; } catch (Exception e2) { Display.destroy(); // if we couldn't get alpha, let us know try { tryCreateDisplay(new PixelFormat()); } catch (Exception e3) { Log.error(e3); } } } return null; }}); if (!Display.isCreated()) { throw new SlickException("Failed to initialise the LWJGL display"); } initSystem(); enterOrtho(); try { getInput().initControllers(); } catch (SlickException e) { Log.info("Controllers not available"); } catch (Throwable e) { Log.info("Controllers not available"); } try { game.init(this); } catch (SlickException e) { Log.error(e); running = false; } }
[ "protected", "void", "setup", "(", ")", "throws", "SlickException", "{", "if", "(", "targetDisplayMode", "==", "null", ")", "{", "setDisplayMode", "(", "640", ",", "480", ",", "false", ")", ";", "}", "Display", ".", "setTitle", "(", "game", ".", "getTitle", "(", ")", ")", ";", "Log", ".", "info", "(", "\"LWJGL Version: \"", "+", "Sys", ".", "getVersion", "(", ")", ")", ";", "Log", ".", "info", "(", "\"OriginalDisplayMode: \"", "+", "originalDisplayMode", ")", ";", "Log", ".", "info", "(", "\"TargetDisplayMode: \"", "+", "targetDisplayMode", ")", ";", "AccessController", ".", "doPrivileged", "(", "new", "PrivilegedAction", "(", ")", "{", "public", "Object", "run", "(", ")", "{", "try", "{", "PixelFormat", "format", "=", "new", "PixelFormat", "(", "8", ",", "8", ",", "stencil", "?", "8", ":", "0", ",", "samples", ")", ";", "tryCreateDisplay", "(", "format", ")", ";", "supportsMultiSample", "=", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Display", ".", "destroy", "(", ")", ";", "try", "{", "PixelFormat", "format", "=", "new", "PixelFormat", "(", "8", ",", "8", ",", "stencil", "?", "8", ":", "0", ")", ";", "tryCreateDisplay", "(", "format", ")", ";", "alphaSupport", "=", "false", ";", "}", "catch", "(", "Exception", "e2", ")", "{", "Display", ".", "destroy", "(", ")", ";", "// if we couldn't get alpha, let us know\r", "try", "{", "tryCreateDisplay", "(", "new", "PixelFormat", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e3", ")", "{", "Log", ".", "error", "(", "e3", ")", ";", "}", "}", "}", "return", "null", ";", "}", "}", ")", ";", "if", "(", "!", "Display", ".", "isCreated", "(", ")", ")", "{", "throw", "new", "SlickException", "(", "\"Failed to initialise the LWJGL display\"", ")", ";", "}", "initSystem", "(", ")", ";", "enterOrtho", "(", ")", ";", "try", "{", "getInput", "(", ")", ".", "initControllers", "(", ")", ";", "}", "catch", "(", "SlickException", "e", ")", "{", "Log", ".", "info", "(", "\"Controllers not available\"", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "Log", ".", "info", "(", "\"Controllers not available\"", ")", ";", "}", "try", "{", "game", ".", "init", "(", "this", ")", ";", "}", "catch", "(", "SlickException", "e", ")", "{", "Log", ".", "error", "(", "e", ")", ";", "running", "=", "false", ";", "}", "}" ]
Setup the environment @throws SlickException Indicates a failure
[ "Setup", "the", "environment" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java#L337-L398
1,510
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java
AppGameContainer.gameLoop
protected void gameLoop() throws SlickException { int delta = getDelta(); if (!Display.isVisible() && updateOnlyOnVisible) { try { Thread.sleep(100); } catch (Exception e) {} } else { try { updateAndRender(delta); } catch (SlickException e) { Log.error(e); running = false; return; } } updateFPS(); Display.update(); if (Display.isCloseRequested()) { if (game.closeRequested()) { running = false; } } }
java
protected void gameLoop() throws SlickException { int delta = getDelta(); if (!Display.isVisible() && updateOnlyOnVisible) { try { Thread.sleep(100); } catch (Exception e) {} } else { try { updateAndRender(delta); } catch (SlickException e) { Log.error(e); running = false; return; } } updateFPS(); Display.update(); if (Display.isCloseRequested()) { if (game.closeRequested()) { running = false; } } }
[ "protected", "void", "gameLoop", "(", ")", "throws", "SlickException", "{", "int", "delta", "=", "getDelta", "(", ")", ";", "if", "(", "!", "Display", ".", "isVisible", "(", ")", "&&", "updateOnlyOnVisible", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "100", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "else", "{", "try", "{", "updateAndRender", "(", "delta", ")", ";", "}", "catch", "(", "SlickException", "e", ")", "{", "Log", ".", "error", "(", "e", ")", ";", "running", "=", "false", ";", "return", ";", "}", "}", "updateFPS", "(", ")", ";", "Display", ".", "update", "(", ")", ";", "if", "(", "Display", ".", "isCloseRequested", "(", ")", ")", "{", "if", "(", "game", ".", "closeRequested", "(", ")", ")", "{", "running", "=", "false", ";", "}", "}", "}" ]
Strategy for overloading game loop context handling @throws SlickException Indicates a game failure
[ "Strategy", "for", "overloading", "game", "loop", "context", "handling" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/AppGameContainer.java#L405-L428
1,511
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/inkscape/Util.java
Util.getNonGeometricData
static NonGeometricData getNonGeometricData(Element element) { String meta = getMetaData(element); NonGeometricData data = new InkscapeNonGeometricData(meta, element); data.addAttribute(NonGeometricData.ID, element.getAttribute("id")); data.addAttribute(NonGeometricData.FILL, getStyle(element, NonGeometricData.FILL)); data.addAttribute(NonGeometricData.STROKE, getStyle(element, NonGeometricData.STROKE)); data.addAttribute(NonGeometricData.OPACITY, getStyle(element, NonGeometricData.OPACITY)); data.addAttribute(NonGeometricData.STROKE_DASHARRAY, getStyle(element, NonGeometricData.STROKE_DASHARRAY)); data.addAttribute(NonGeometricData.STROKE_DASHOFFSET, getStyle(element, NonGeometricData.STROKE_DASHOFFSET)); data.addAttribute(NonGeometricData.STROKE_MITERLIMIT, getStyle(element, NonGeometricData.STROKE_MITERLIMIT)); data.addAttribute(NonGeometricData.STROKE_OPACITY, getStyle(element, NonGeometricData.STROKE_OPACITY)); data.addAttribute(NonGeometricData.STROKE_WIDTH, getStyle(element, NonGeometricData.STROKE_WIDTH)); return data; }
java
static NonGeometricData getNonGeometricData(Element element) { String meta = getMetaData(element); NonGeometricData data = new InkscapeNonGeometricData(meta, element); data.addAttribute(NonGeometricData.ID, element.getAttribute("id")); data.addAttribute(NonGeometricData.FILL, getStyle(element, NonGeometricData.FILL)); data.addAttribute(NonGeometricData.STROKE, getStyle(element, NonGeometricData.STROKE)); data.addAttribute(NonGeometricData.OPACITY, getStyle(element, NonGeometricData.OPACITY)); data.addAttribute(NonGeometricData.STROKE_DASHARRAY, getStyle(element, NonGeometricData.STROKE_DASHARRAY)); data.addAttribute(NonGeometricData.STROKE_DASHOFFSET, getStyle(element, NonGeometricData.STROKE_DASHOFFSET)); data.addAttribute(NonGeometricData.STROKE_MITERLIMIT, getStyle(element, NonGeometricData.STROKE_MITERLIMIT)); data.addAttribute(NonGeometricData.STROKE_OPACITY, getStyle(element, NonGeometricData.STROKE_OPACITY)); data.addAttribute(NonGeometricData.STROKE_WIDTH, getStyle(element, NonGeometricData.STROKE_WIDTH)); return data; }
[ "static", "NonGeometricData", "getNonGeometricData", "(", "Element", "element", ")", "{", "String", "meta", "=", "getMetaData", "(", "element", ")", ";", "NonGeometricData", "data", "=", "new", "InkscapeNonGeometricData", "(", "meta", ",", "element", ")", ";", "data", ".", "addAttribute", "(", "NonGeometricData", ".", "ID", ",", "element", ".", "getAttribute", "(", "\"id\"", ")", ")", ";", "data", ".", "addAttribute", "(", "NonGeometricData", ".", "FILL", ",", "getStyle", "(", "element", ",", "NonGeometricData", ".", "FILL", ")", ")", ";", "data", ".", "addAttribute", "(", "NonGeometricData", ".", "STROKE", ",", "getStyle", "(", "element", ",", "NonGeometricData", ".", "STROKE", ")", ")", ";", "data", ".", "addAttribute", "(", "NonGeometricData", ".", "OPACITY", ",", "getStyle", "(", "element", ",", "NonGeometricData", ".", "OPACITY", ")", ")", ";", "data", ".", "addAttribute", "(", "NonGeometricData", ".", "STROKE_DASHARRAY", ",", "getStyle", "(", "element", ",", "NonGeometricData", ".", "STROKE_DASHARRAY", ")", ")", ";", "data", ".", "addAttribute", "(", "NonGeometricData", ".", "STROKE_DASHOFFSET", ",", "getStyle", "(", "element", ",", "NonGeometricData", ".", "STROKE_DASHOFFSET", ")", ")", ";", "data", ".", "addAttribute", "(", "NonGeometricData", ".", "STROKE_MITERLIMIT", ",", "getStyle", "(", "element", ",", "NonGeometricData", ".", "STROKE_MITERLIMIT", ")", ")", ";", "data", ".", "addAttribute", "(", "NonGeometricData", ".", "STROKE_OPACITY", ",", "getStyle", "(", "element", ",", "NonGeometricData", ".", "STROKE_OPACITY", ")", ")", ";", "data", ".", "addAttribute", "(", "NonGeometricData", ".", "STROKE_WIDTH", ",", "getStyle", "(", "element", ",", "NonGeometricData", ".", "STROKE_WIDTH", ")", ")", ";", "return", "data", ";", "}" ]
Get the non-geometric data information from an XML element @param element The element to be processed @return The non-geometric data (i.e. stroke, fill, etc)
[ "Get", "the", "non", "-", "geometric", "data", "information", "from", "an", "XML", "element" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/inkscape/Util.java#L29-L44
1,512
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/inkscape/Util.java
Util.getMetaData
static String getMetaData(Element element) { String label = element.getAttributeNS(INKSCAPE, "label"); if ((label != null) && (!label.equals(""))) { return label; } return element.getAttribute("id"); }
java
static String getMetaData(Element element) { String label = element.getAttributeNS(INKSCAPE, "label"); if ((label != null) && (!label.equals(""))) { return label; } return element.getAttribute("id"); }
[ "static", "String", "getMetaData", "(", "Element", "element", ")", "{", "String", "label", "=", "element", ".", "getAttributeNS", "(", "INKSCAPE", ",", "\"label\"", ")", ";", "if", "(", "(", "label", "!=", "null", ")", "&&", "(", "!", "label", ".", "equals", "(", "\"\"", ")", ")", ")", "{", "return", "label", ";", "}", "return", "element", ".", "getAttribute", "(", "\"id\"", ")", ";", "}" ]
Get the meta data store within an element either in the label or id atributes @param element The element to be processed @return The meta data stored
[ "Get", "the", "meta", "data", "store", "within", "an", "element", "either", "in", "the", "label", "or", "id", "atributes" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/inkscape/Util.java#L53-L60
1,513
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/inkscape/Util.java
Util.extractStyle
static String extractStyle(String style, String attribute) { if (style == null) { return ""; } StringTokenizer tokens = new StringTokenizer(style,";"); while (tokens.hasMoreTokens()) { String token = tokens.nextToken(); String key = token.substring(0,token.indexOf(':')); if (key.equals(attribute)) { return token.substring(token.indexOf(':')+1); } } return ""; }
java
static String extractStyle(String style, String attribute) { if (style == null) { return ""; } StringTokenizer tokens = new StringTokenizer(style,";"); while (tokens.hasMoreTokens()) { String token = tokens.nextToken(); String key = token.substring(0,token.indexOf(':')); if (key.equals(attribute)) { return token.substring(token.indexOf(':')+1); } } return ""; }
[ "static", "String", "extractStyle", "(", "String", "style", ",", "String", "attribute", ")", "{", "if", "(", "style", "==", "null", ")", "{", "return", "\"\"", ";", "}", "StringTokenizer", "tokens", "=", "new", "StringTokenizer", "(", "style", ",", "\";\"", ")", ";", "while", "(", "tokens", ".", "hasMoreTokens", "(", ")", ")", "{", "String", "token", "=", "tokens", ".", "nextToken", "(", ")", ";", "String", "key", "=", "token", ".", "substring", "(", "0", ",", "token", ".", "indexOf", "(", "'", "'", ")", ")", ";", "if", "(", "key", ".", "equals", "(", "attribute", ")", ")", "{", "return", "token", ".", "substring", "(", "token", ".", "indexOf", "(", "'", "'", ")", "+", "1", ")", ";", "}", "}", "return", "\"\"", ";", "}" ]
Extract the style value from a Inkscape encoded string @param style The style string to be decoded @param attribute The style attribute to retrieve @return The value for the given attribute
[ "Extract", "the", "style", "value", "from", "a", "Inkscape", "encoded", "string" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/inkscape/Util.java#L87-L103
1,514
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/inkscape/Util.java
Util.getTransform
static Transform getTransform(Element element, String attribute) { String str = element.getAttribute(attribute); if (str == null) { return new Transform(); } if (str.equals("")) { return new Transform(); } else if (str.startsWith("translate")) { str = str.substring(0, str.length()-1); str = str.substring("translate(".length()); StringTokenizer tokens = new StringTokenizer(str, ", "); float x = Float.parseFloat(tokens.nextToken()); float y = Float.parseFloat(tokens.nextToken()); return Transform.createTranslateTransform(x,y); } else if (str.startsWith("matrix")) { float[] pose = new float[6]; str = str.substring(0, str.length()-1); str = str.substring("matrix(".length()); StringTokenizer tokens = new StringTokenizer(str, ", "); float[] tr = new float[6]; for (int j=0;j<tr.length;j++) { tr[j] = Float.parseFloat(tokens.nextToken()); } pose[0] = tr[0]; pose[1] = tr[2]; pose[2] = tr[4]; pose[3] = tr[1]; pose[4] = tr[3]; pose[5] = tr[5]; return new Transform(pose); } return new Transform(); }
java
static Transform getTransform(Element element, String attribute) { String str = element.getAttribute(attribute); if (str == null) { return new Transform(); } if (str.equals("")) { return new Transform(); } else if (str.startsWith("translate")) { str = str.substring(0, str.length()-1); str = str.substring("translate(".length()); StringTokenizer tokens = new StringTokenizer(str, ", "); float x = Float.parseFloat(tokens.nextToken()); float y = Float.parseFloat(tokens.nextToken()); return Transform.createTranslateTransform(x,y); } else if (str.startsWith("matrix")) { float[] pose = new float[6]; str = str.substring(0, str.length()-1); str = str.substring("matrix(".length()); StringTokenizer tokens = new StringTokenizer(str, ", "); float[] tr = new float[6]; for (int j=0;j<tr.length;j++) { tr[j] = Float.parseFloat(tokens.nextToken()); } pose[0] = tr[0]; pose[1] = tr[2]; pose[2] = tr[4]; pose[3] = tr[1]; pose[4] = tr[3]; pose[5] = tr[5]; return new Transform(pose); } return new Transform(); }
[ "static", "Transform", "getTransform", "(", "Element", "element", ",", "String", "attribute", ")", "{", "String", "str", "=", "element", ".", "getAttribute", "(", "attribute", ")", ";", "if", "(", "str", "==", "null", ")", "{", "return", "new", "Transform", "(", ")", ";", "}", "if", "(", "str", ".", "equals", "(", "\"\"", ")", ")", "{", "return", "new", "Transform", "(", ")", ";", "}", "else", "if", "(", "str", ".", "startsWith", "(", "\"translate\"", ")", ")", "{", "str", "=", "str", ".", "substring", "(", "0", ",", "str", ".", "length", "(", ")", "-", "1", ")", ";", "str", "=", "str", ".", "substring", "(", "\"translate(\"", ".", "length", "(", ")", ")", ";", "StringTokenizer", "tokens", "=", "new", "StringTokenizer", "(", "str", ",", "\", \"", ")", ";", "float", "x", "=", "Float", ".", "parseFloat", "(", "tokens", ".", "nextToken", "(", ")", ")", ";", "float", "y", "=", "Float", ".", "parseFloat", "(", "tokens", ".", "nextToken", "(", ")", ")", ";", "return", "Transform", ".", "createTranslateTransform", "(", "x", ",", "y", ")", ";", "}", "else", "if", "(", "str", ".", "startsWith", "(", "\"matrix\"", ")", ")", "{", "float", "[", "]", "pose", "=", "new", "float", "[", "6", "]", ";", "str", "=", "str", ".", "substring", "(", "0", ",", "str", ".", "length", "(", ")", "-", "1", ")", ";", "str", "=", "str", ".", "substring", "(", "\"matrix(\"", ".", "length", "(", ")", ")", ";", "StringTokenizer", "tokens", "=", "new", "StringTokenizer", "(", "str", ",", "\", \"", ")", ";", "float", "[", "]", "tr", "=", "new", "float", "[", "6", "]", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "tr", ".", "length", ";", "j", "++", ")", "{", "tr", "[", "j", "]", "=", "Float", ".", "parseFloat", "(", "tokens", ".", "nextToken", "(", ")", ")", ";", "}", "pose", "[", "0", "]", "=", "tr", "[", "0", "]", ";", "pose", "[", "1", "]", "=", "tr", "[", "2", "]", ";", "pose", "[", "2", "]", "=", "tr", "[", "4", "]", ";", "pose", "[", "3", "]", "=", "tr", "[", "1", "]", ";", "pose", "[", "4", "]", "=", "tr", "[", "3", "]", ";", "pose", "[", "5", "]", "=", "tr", "[", "5", "]", ";", "return", "new", "Transform", "(", "pose", ")", ";", "}", "return", "new", "Transform", "(", ")", ";", "}" ]
Get a transform defined in the XML @param element The element from which the transform should be read @param attribute The name of the attribute holding the transform @return The transform to be applied
[ "Get", "a", "transform", "defined", "in", "the", "XML" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/inkscape/Util.java#L122-L159
1,515
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/svg/inkscape/Util.java
Util.getFloatAttribute
static float getFloatAttribute(Element element, String attr) throws ParsingException { String cx = element.getAttribute(attr); if ((cx == null) || (cx.equals(""))) { cx = element.getAttributeNS(SODIPODI, attr); } try { return Float.parseFloat(cx); } catch (NumberFormatException e) { throw new ParsingException(element, "Invalid value for: "+attr, e); } }
java
static float getFloatAttribute(Element element, String attr) throws ParsingException { String cx = element.getAttribute(attr); if ((cx == null) || (cx.equals(""))) { cx = element.getAttributeNS(SODIPODI, attr); } try { return Float.parseFloat(cx); } catch (NumberFormatException e) { throw new ParsingException(element, "Invalid value for: "+attr, e); } }
[ "static", "float", "getFloatAttribute", "(", "Element", "element", ",", "String", "attr", ")", "throws", "ParsingException", "{", "String", "cx", "=", "element", ".", "getAttribute", "(", "attr", ")", ";", "if", "(", "(", "cx", "==", "null", ")", "||", "(", "cx", ".", "equals", "(", "\"\"", ")", ")", ")", "{", "cx", "=", "element", ".", "getAttributeNS", "(", "SODIPODI", ",", "attr", ")", ";", "}", "try", "{", "return", "Float", ".", "parseFloat", "(", "cx", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "throw", "new", "ParsingException", "(", "element", ",", "\"Invalid value for: \"", "+", "attr", ",", "e", ")", ";", "}", "}" ]
Get a floating point attribute that may appear in either the default or SODIPODI namespace @param element The element from which the attribute should be read @param attr The attribute to be read @return The value from the given attribute @throws ParsingException Indicates the value in the attribute was not a float
[ "Get", "a", "floating", "point", "attribute", "that", "may", "appear", "in", "either", "the", "default", "or", "SODIPODI", "namespace" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/inkscape/Util.java#L170-L181
1,516
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/ShapeRenderer.java
ShapeRenderer.validFill
public static boolean validFill(Shape shape) { if (shape.getTriangles() == null) { return false; } return shape.getTriangles().getTriangleCount() != 0; }
java
public static boolean validFill(Shape shape) { if (shape.getTriangles() == null) { return false; } return shape.getTriangles().getTriangleCount() != 0; }
[ "public", "static", "boolean", "validFill", "(", "Shape", "shape", ")", "{", "if", "(", "shape", ".", "getTriangles", "(", ")", "==", "null", ")", "{", "return", "false", ";", "}", "return", "shape", ".", "getTriangles", "(", ")", ".", "getTriangleCount", "(", ")", "!=", "0", ";", "}" ]
Check there are enough points to fill @param shape THe shape we're drawing @return True if the fill is valid
[ "Check", "there", "are", "enough", "points", "to", "fill" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/ShapeRenderer.java#L93-L98
1,517
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/ShapeRenderer.java
ShapeRenderer.textureFit
public static final void textureFit(Shape shape, final Image image, final float scaleX, final float scaleY) { if (!validFill(shape)) { return; } float points[] = shape.getPoints(); Texture t = TextureImpl.getLastBind(); image.getTexture().bind(); final float minX = shape.getX(); final float minY = shape.getY(); final float maxX = shape.getMaxX() - minX; final float maxY = shape.getMaxY() - minY; fill(shape, new PointCallback() { public float[] preRenderPoint(Shape shape, float x, float y) { x -= shape.getMinX(); y -= shape.getMinY(); x /= (shape.getMaxX() - shape.getMinX()); y /= (shape.getMaxY() - shape.getMinY()); float tx = x * scaleX; float ty = y * scaleY; tx = image.getTextureOffsetX() + (image.getTextureWidth() * tx); ty = image.getTextureOffsetY() + (image.getTextureHeight() * ty); GL.glTexCoord2f(tx, ty); return null; } }); if (t == null) { TextureImpl.bindNone(); } else { t.bind(); } }
java
public static final void textureFit(Shape shape, final Image image, final float scaleX, final float scaleY) { if (!validFill(shape)) { return; } float points[] = shape.getPoints(); Texture t = TextureImpl.getLastBind(); image.getTexture().bind(); final float minX = shape.getX(); final float minY = shape.getY(); final float maxX = shape.getMaxX() - minX; final float maxY = shape.getMaxY() - minY; fill(shape, new PointCallback() { public float[] preRenderPoint(Shape shape, float x, float y) { x -= shape.getMinX(); y -= shape.getMinY(); x /= (shape.getMaxX() - shape.getMinX()); y /= (shape.getMaxY() - shape.getMinY()); float tx = x * scaleX; float ty = y * scaleY; tx = image.getTextureOffsetX() + (image.getTextureWidth() * tx); ty = image.getTextureOffsetY() + (image.getTextureHeight() * ty); GL.glTexCoord2f(tx, ty); return null; } }); if (t == null) { TextureImpl.bindNone(); } else { t.bind(); } }
[ "public", "static", "final", "void", "textureFit", "(", "Shape", "shape", ",", "final", "Image", "image", ",", "final", "float", "scaleX", ",", "final", "float", "scaleY", ")", "{", "if", "(", "!", "validFill", "(", "shape", ")", ")", "{", "return", ";", "}", "float", "points", "[", "]", "=", "shape", ".", "getPoints", "(", ")", ";", "Texture", "t", "=", "TextureImpl", ".", "getLastBind", "(", ")", ";", "image", ".", "getTexture", "(", ")", ".", "bind", "(", ")", ";", "final", "float", "minX", "=", "shape", ".", "getX", "(", ")", ";", "final", "float", "minY", "=", "shape", ".", "getY", "(", ")", ";", "final", "float", "maxX", "=", "shape", ".", "getMaxX", "(", ")", "-", "minX", ";", "final", "float", "maxY", "=", "shape", ".", "getMaxY", "(", ")", "-", "minY", ";", "fill", "(", "shape", ",", "new", "PointCallback", "(", ")", "{", "public", "float", "[", "]", "preRenderPoint", "(", "Shape", "shape", ",", "float", "x", ",", "float", "y", ")", "{", "x", "-=", "shape", ".", "getMinX", "(", ")", ";", "y", "-=", "shape", ".", "getMinY", "(", ")", ";", "x", "/=", "(", "shape", ".", "getMaxX", "(", ")", "-", "shape", ".", "getMinX", "(", ")", ")", ";", "y", "/=", "(", "shape", ".", "getMaxY", "(", ")", "-", "shape", ".", "getMinY", "(", ")", ")", ";", "float", "tx", "=", "x", "*", "scaleX", ";", "float", "ty", "=", "y", "*", "scaleY", ";", "tx", "=", "image", ".", "getTextureOffsetX", "(", ")", "+", "(", "image", ".", "getTextureWidth", "(", ")", "*", "tx", ")", ";", "ty", "=", "image", ".", "getTextureOffsetY", "(", ")", "+", "(", "image", ".", "getTextureHeight", "(", ")", "*", "ty", ")", ";", "GL", ".", "glTexCoord2f", "(", "tx", ",", "ty", ")", ";", "return", "null", ";", "}", "}", ")", ";", "if", "(", "t", "==", "null", ")", "{", "TextureImpl", ".", "bindNone", "(", ")", ";", "}", "else", "{", "t", ".", "bind", "(", ")", ";", "}", "}" ]
Draw the the given shape filled in with a texture. Only the vertices are set. The colour has to be set independently of this method. This method is required to fit the texture scaleX times across the shape and scaleY times down the shape. @param shape The shape to texture. @param image The image to tile across the shape @param scaleX The scale to apply on the x axis for texturing @param scaleY The scale to apply on the y axis for texturing
[ "Draw", "the", "the", "given", "shape", "filled", "in", "with", "a", "texture", ".", "Only", "the", "vertices", "are", "set", ".", "The", "colour", "has", "to", "be", "set", "independently", "of", "this", "method", ".", "This", "method", "is", "required", "to", "fit", "the", "texture", "scaleX", "times", "across", "the", "shape", "and", "scaleY", "times", "down", "the", "shape", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/ShapeRenderer.java#L226-L265
1,518
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/DeferredSound.java
DeferredSound.playAsSoundEffect
public int playAsSoundEffect(float pitch, float gain, boolean loop, float x, float y, float z) { checkTarget(); return target.playAsSoundEffect(pitch, gain, loop, x, y, z); }
java
public int playAsSoundEffect(float pitch, float gain, boolean loop, float x, float y, float z) { checkTarget(); return target.playAsSoundEffect(pitch, gain, loop, x, y, z); }
[ "public", "int", "playAsSoundEffect", "(", "float", "pitch", ",", "float", "gain", ",", "boolean", "loop", ",", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "checkTarget", "(", ")", ";", "return", "target", ".", "playAsSoundEffect", "(", "pitch", ",", "gain", ",", "loop", ",", "x", ",", "y", ",", "z", ")", ";", "}" ]
Play this sound as a sound effect @param pitch The pitch of the play back @param gain The gain of the play back @param loop True if we should loop @param x The x position of the sound @param y The y position of the sound @param z The z position of the sound
[ "Play", "this", "sound", "as", "a", "sound", "effect" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/DeferredSound.java#L144-L147
1,519
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Line.java
Line.set
public void set(Vector2f start, Vector2f end) { super.pointsDirty = true; if (this.start == null) { this.start = new Vector2f(); } this.start.set(start); if (this.end == null) { this.end = new Vector2f(); } this.end.set(end); vec = new Vector2f(end); vec.sub(start); lenSquared = vec.lengthSquared(); }
java
public void set(Vector2f start, Vector2f end) { super.pointsDirty = true; if (this.start == null) { this.start = new Vector2f(); } this.start.set(start); if (this.end == null) { this.end = new Vector2f(); } this.end.set(end); vec = new Vector2f(end); vec.sub(start); lenSquared = vec.lengthSquared(); }
[ "public", "void", "set", "(", "Vector2f", "start", ",", "Vector2f", "end", ")", "{", "super", ".", "pointsDirty", "=", "true", ";", "if", "(", "this", ".", "start", "==", "null", ")", "{", "this", ".", "start", "=", "new", "Vector2f", "(", ")", ";", "}", "this", ".", "start", ".", "set", "(", "start", ")", ";", "if", "(", "this", ".", "end", "==", "null", ")", "{", "this", ".", "end", "=", "new", "Vector2f", "(", ")", ";", "}", "this", ".", "end", ".", "set", "(", "end", ")", ";", "vec", "=", "new", "Vector2f", "(", "end", ")", ";", "vec", ".", "sub", "(", "start", ")", ";", "lenSquared", "=", "vec", ".", "lengthSquared", "(", ")", ";", "}" ]
Configure the line @param start The start point of the line @param end The end point of the line
[ "Configure", "the", "line" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Line.java#L185-L201
1,520
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Line.java
Line.set
public void set(float sx, float sy, float ex, float ey) { super.pointsDirty = true; start.set(sx, sy); end.set(ex, ey); float dx = (ex - sx); float dy = (ey - sy); vec.set(dx,dy); lenSquared = (dx * dx) + (dy * dy); }
java
public void set(float sx, float sy, float ex, float ey) { super.pointsDirty = true; start.set(sx, sy); end.set(ex, ey); float dx = (ex - sx); float dy = (ey - sy); vec.set(dx,dy); lenSquared = (dx * dx) + (dy * dy); }
[ "public", "void", "set", "(", "float", "sx", ",", "float", "sy", ",", "float", "ex", ",", "float", "ey", ")", "{", "super", ".", "pointsDirty", "=", "true", ";", "start", ".", "set", "(", "sx", ",", "sy", ")", ";", "end", ".", "set", "(", "ex", ",", "ey", ")", ";", "float", "dx", "=", "(", "ex", "-", "sx", ")", ";", "float", "dy", "=", "(", "ey", "-", "sy", ")", ";", "vec", ".", "set", "(", "dx", ",", "dy", ")", ";", "lenSquared", "=", "(", "dx", "*", "dx", ")", "+", "(", "dy", "*", "dy", ")", ";", "}" ]
Configure the line without garbage @param sx The x coordinate of the start @param sy The y coordinate of the start @param ex The x coordiante of the end @param ey The y coordinate of the end
[ "Configure", "the", "line", "without", "garbage" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Line.java#L215-L224
1,521
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Line.java
Line.distanceSquared
public float distanceSquared(Vector2f point) { getClosestPoint(point, closest); closest.sub(point); float result = closest.lengthSquared(); return result; }
java
public float distanceSquared(Vector2f point) { getClosestPoint(point, closest); closest.sub(point); float result = closest.lengthSquared(); return result; }
[ "public", "float", "distanceSquared", "(", "Vector2f", "point", ")", "{", "getClosestPoint", "(", "point", ",", "closest", ")", ";", "closest", ".", "sub", "(", "point", ")", ";", "float", "result", "=", "closest", ".", "lengthSquared", "(", ")", ";", "return", "result", ";", "}" ]
Get the shortest distance squared from a point to this line @param point The point from which we want the distance @return The distance squared from the line to the point
[ "Get", "the", "shortest", "distance", "squared", "from", "a", "point", "to", "this", "line" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Line.java#L325-L332
1,522
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Line.java
Line.getClosestPoint
public void getClosestPoint(Vector2f point, Vector2f result) { loc.set(point); loc.sub(start); float projDistance = vec.dot(loc); projDistance /= vec.lengthSquared(); if (projDistance < 0) { result.set(start); return; } if (projDistance > 1) { result.set(end); return; } result.x = start.getX() + projDistance * vec.getX(); result.y = start.getY() + projDistance * vec.getY(); }
java
public void getClosestPoint(Vector2f point, Vector2f result) { loc.set(point); loc.sub(start); float projDistance = vec.dot(loc); projDistance /= vec.lengthSquared(); if (projDistance < 0) { result.set(start); return; } if (projDistance > 1) { result.set(end); return; } result.x = start.getX() + projDistance * vec.getX(); result.y = start.getY() + projDistance * vec.getY(); }
[ "public", "void", "getClosestPoint", "(", "Vector2f", "point", ",", "Vector2f", "result", ")", "{", "loc", ".", "set", "(", "point", ")", ";", "loc", ".", "sub", "(", "start", ")", ";", "float", "projDistance", "=", "vec", ".", "dot", "(", "loc", ")", ";", "projDistance", "/=", "vec", ".", "lengthSquared", "(", ")", ";", "if", "(", "projDistance", "<", "0", ")", "{", "result", ".", "set", "(", "start", ")", ";", "return", ";", "}", "if", "(", "projDistance", ">", "1", ")", "{", "result", ".", "set", "(", "end", ")", ";", "return", ";", "}", "result", ".", "x", "=", "start", ".", "getX", "(", ")", "+", "projDistance", "*", "vec", ".", "getX", "(", ")", ";", "result", ".", "y", "=", "start", ".", "getY", "(", ")", "+", "projDistance", "*", "vec", ".", "getY", "(", ")", ";", "}" ]
Get the closest point on the line to a given point @param point The point which we want to project @param result The point on the line closest to the given point
[ "Get", "the", "closest", "point", "on", "the", "line", "to", "a", "given", "point" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Line.java#L342-L361
1,523
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java
FontFileReader.init
private void init(InputStream in) throws java.io.IOException { if (in.available() > 2000000) { throw new IOException("Font too big"); } this.file = IOUtils.toByteArray(in); this.fsize = this.file.length; if (fsize > 2000000) { throw new IOException("Font too big"); } this.current = 0; }
java
private void init(InputStream in) throws java.io.IOException { if (in.available() > 2000000) { throw new IOException("Font too big"); } this.file = IOUtils.toByteArray(in); this.fsize = this.file.length; if (fsize > 2000000) { throw new IOException("Font too big"); } this.current = 0; }
[ "private", "void", "init", "(", "InputStream", "in", ")", "throws", "java", ".", "io", ".", "IOException", "{", "if", "(", "in", ".", "available", "(", ")", ">", "2000000", ")", "{", "throw", "new", "IOException", "(", "\"Font too big\"", ")", ";", "}", "this", ".", "file", "=", "IOUtils", ".", "toByteArray", "(", "in", ")", ";", "this", ".", "fsize", "=", "this", ".", "file", ".", "length", ";", "if", "(", "fsize", ">", "2000000", ")", "{", "throw", "new", "IOException", "(", "\"Font too big\"", ")", ";", "}", "this", ".", "current", "=", "0", ";", "}" ]
Initializes class and reads stream. Init does not close stream. @param in InputStream to read from new array with size + inc @throws IOException In case of an I/O problem
[ "Initializes", "class", "and", "reads", "stream", ".", "Init", "does", "not", "close", "stream", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java#L44-L54
1,524
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java
FontFileReader.seekSet
public void seekSet(long offset) throws IOException { if (offset >= fsize || offset < 0) { throw new java.io.EOFException("Reached EOF, file size=" + fsize + " offset=" + offset); } current = (int)offset; }
java
public void seekSet(long offset) throws IOException { if (offset >= fsize || offset < 0) { throw new java.io.EOFException("Reached EOF, file size=" + fsize + " offset=" + offset); } current = (int)offset; }
[ "public", "void", "seekSet", "(", "long", "offset", ")", "throws", "IOException", "{", "if", "(", "offset", ">=", "fsize", "||", "offset", "<", "0", ")", "{", "throw", "new", "java", ".", "io", ".", "EOFException", "(", "\"Reached EOF, file size=\"", "+", "fsize", "+", "\" offset=\"", "+", "offset", ")", ";", "}", "current", "=", "(", "int", ")", "offset", ";", "}" ]
Set current file position to offset @param offset The new offset to set @throws IOException In case of an I/O problem
[ "Set", "current", "file", "position", "to", "offset" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java#L109-L115
1,525
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java
FontFileReader.read
public byte read() throws IOException { if (current >= fsize) { throw new java.io.EOFException("Reached EOF, file size=" + fsize); } final byte ret = file[current++]; return ret; }
java
public byte read() throws IOException { if (current >= fsize) { throw new java.io.EOFException("Reached EOF, file size=" + fsize); } final byte ret = file[current++]; return ret; }
[ "public", "byte", "read", "(", ")", "throws", "IOException", "{", "if", "(", "current", ">=", "fsize", ")", "{", "throw", "new", "java", ".", "io", ".", "EOFException", "(", "\"Reached EOF, file size=\"", "+", "fsize", ")", ";", "}", "final", "byte", "ret", "=", "file", "[", "current", "++", "]", ";", "return", "ret", ";", "}" ]
Read 1 byte. @return One byte @throws IOException If EOF is reached
[ "Read", "1", "byte", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java#L161-L168
1,526
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java
FontFileReader.writeTTFUShort
public final void writeTTFUShort(int pos, int val) throws IOException { if ((pos + 2) > fsize) { throw new java.io.EOFException("Reached EOF"); } final byte b1 = (byte)((val >> 8) & 0xff); final byte b2 = (byte)(val & 0xff); file[pos] = b1; file[pos + 1] = b2; }
java
public final void writeTTFUShort(int pos, int val) throws IOException { if ((pos + 2) > fsize) { throw new java.io.EOFException("Reached EOF"); } final byte b1 = (byte)((val >> 8) & 0xff); final byte b2 = (byte)(val & 0xff); file[pos] = b1; file[pos + 1] = b2; }
[ "public", "final", "void", "writeTTFUShort", "(", "int", "pos", ",", "int", "val", ")", "throws", "IOException", "{", "if", "(", "(", "pos", "+", "2", ")", ">", "fsize", ")", "{", "throw", "new", "java", ".", "io", ".", "EOFException", "(", "\"Reached EOF\"", ")", ";", "}", "final", "byte", "b1", "=", "(", "byte", ")", "(", "(", "val", ">>", "8", ")", "&", "0xff", ")", ";", "final", "byte", "b2", "=", "(", "byte", ")", "(", "val", "&", "0xff", ")", ";", "file", "[", "pos", "]", "=", "b1", ";", "file", "[", "pos", "+", "1", "]", "=", "b2", ";", "}" ]
Write a USHort at a given position. @param pos The absolute position to write to @param val The value to write @throws IOException If EOF is reached
[ "Write", "a", "USHort", "at", "a", "given", "position", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java#L226-L234
1,527
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java
FontFileReader.readTTFShort
public final short readTTFShort(long pos) throws IOException { final long cp = getCurrentPos(); seekSet(pos); final short ret = readTTFShort(); seekSet(cp); return ret; }
java
public final short readTTFShort(long pos) throws IOException { final long cp = getCurrentPos(); seekSet(pos); final short ret = readTTFShort(); seekSet(cp); return ret; }
[ "public", "final", "short", "readTTFShort", "(", "long", "pos", ")", "throws", "IOException", "{", "final", "long", "cp", "=", "getCurrentPos", "(", ")", ";", "seekSet", "(", "pos", ")", ";", "final", "short", "ret", "=", "readTTFShort", "(", ")", ";", "seekSet", "(", "cp", ")", ";", "return", "ret", ";", "}" ]
Read 2 bytes signed at position pos without changing current position. @param pos The absolute position to read from @return One signed short @throws IOException If EOF is reached
[ "Read", "2", "bytes", "signed", "at", "position", "pos", "without", "changing", "current", "position", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java#L243-L249
1,528
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java
FontFileReader.readTTFUShort
public final int readTTFUShort(long pos) throws IOException { long cp = getCurrentPos(); seekSet(pos); int ret = readTTFUShort(); seekSet(cp); return ret; }
java
public final int readTTFUShort(long pos) throws IOException { long cp = getCurrentPos(); seekSet(pos); int ret = readTTFUShort(); seekSet(cp); return ret; }
[ "public", "final", "int", "readTTFUShort", "(", "long", "pos", ")", "throws", "IOException", "{", "long", "cp", "=", "getCurrentPos", "(", ")", ";", "seekSet", "(", "pos", ")", ";", "int", "ret", "=", "readTTFUShort", "(", ")", ";", "seekSet", "(", "cp", ")", ";", "return", "ret", ";", "}" ]
Read 2 bytes unsigned at position pos without changing current position. @param pos The absolute position to read from @return One unsigned short @throws IOException If EOF is reached
[ "Read", "2", "bytes", "unsigned", "at", "position", "pos", "without", "changing", "current", "position", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java#L258-L264
1,529
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java
FontFileReader.readTTFString
public final String readTTFString() throws IOException { int i = current; while (file[i++] != 0) { if (i > fsize) { throw new java.io.EOFException("Reached EOF, file size=" + fsize); } } byte[] tmp = new byte[i - current]; System.arraycopy(file, current, tmp, 0, i - current); return new String(tmp, "ISO-8859-1"); }
java
public final String readTTFString() throws IOException { int i = current; while (file[i++] != 0) { if (i > fsize) { throw new java.io.EOFException("Reached EOF, file size=" + fsize); } } byte[] tmp = new byte[i - current]; System.arraycopy(file, current, tmp, 0, i - current); return new String(tmp, "ISO-8859-1"); }
[ "public", "final", "String", "readTTFString", "(", ")", "throws", "IOException", "{", "int", "i", "=", "current", ";", "while", "(", "file", "[", "i", "++", "]", "!=", "0", ")", "{", "if", "(", "i", ">", "fsize", ")", "{", "throw", "new", "java", ".", "io", ".", "EOFException", "(", "\"Reached EOF, file size=\"", "+", "fsize", ")", ";", "}", "}", "byte", "[", "]", "tmp", "=", "new", "byte", "[", "i", "-", "current", "]", ";", "System", ".", "arraycopy", "(", "file", ",", "current", ",", "tmp", ",", "0", ",", "i", "-", "current", ")", ";", "return", "new", "String", "(", "tmp", ",", "\"ISO-8859-1\"", ")", ";", "}" ]
Read a NUL terminated ISO-8859-1 string. @return A String @throws IOException If EOF is reached
[ "Read", "a", "NUL", "terminated", "ISO", "-", "8859", "-", "1", "string", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java#L302-L314
1,530
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java
FontFileReader.readTTFString
public final String readTTFString(int len) throws IOException { if ((len + current) > fsize) { throw new java.io.EOFException("Reached EOF, file size=" + fsize); } byte[] tmp = new byte[len]; System.arraycopy(file, current, tmp, 0, len); current += len; final String encoding; if ((tmp.length > 0) && (tmp[0] == 0)) { encoding = "UTF-16BE"; } else { encoding = "ISO-8859-1"; } return new String(tmp, encoding); }
java
public final String readTTFString(int len) throws IOException { if ((len + current) > fsize) { throw new java.io.EOFException("Reached EOF, file size=" + fsize); } byte[] tmp = new byte[len]; System.arraycopy(file, current, tmp, 0, len); current += len; final String encoding; if ((tmp.length > 0) && (tmp[0] == 0)) { encoding = "UTF-16BE"; } else { encoding = "ISO-8859-1"; } return new String(tmp, encoding); }
[ "public", "final", "String", "readTTFString", "(", "int", "len", ")", "throws", "IOException", "{", "if", "(", "(", "len", "+", "current", ")", ">", "fsize", ")", "{", "throw", "new", "java", ".", "io", ".", "EOFException", "(", "\"Reached EOF, file size=\"", "+", "fsize", ")", ";", "}", "byte", "[", "]", "tmp", "=", "new", "byte", "[", "len", "]", ";", "System", ".", "arraycopy", "(", "file", ",", "current", ",", "tmp", ",", "0", ",", "len", ")", ";", "current", "+=", "len", ";", "final", "String", "encoding", ";", "if", "(", "(", "tmp", ".", "length", ">", "0", ")", "&&", "(", "tmp", "[", "0", "]", "==", "0", ")", ")", "{", "encoding", "=", "\"UTF-16BE\"", ";", "}", "else", "{", "encoding", "=", "\"ISO-8859-1\"", ";", "}", "return", "new", "String", "(", "tmp", ",", "encoding", ")", ";", "}" ]
Read an ISO-8859-1 string of len bytes. @param len The length of the string to read @return A String @throws IOException If EOF is reached
[ "Read", "an", "ISO", "-", "8859", "-", "1", "string", "of", "len", "bytes", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java#L324-L339
1,531
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java
FontFileReader.getBytes
public byte[] getBytes(int offset, int length) throws IOException { if ((offset + length) > fsize) { throw new java.io.IOException("Reached EOF"); } byte[] ret = new byte[length]; System.arraycopy(file, offset, ret, 0, length); return ret; }
java
public byte[] getBytes(int offset, int length) throws IOException { if ((offset + length) > fsize) { throw new java.io.IOException("Reached EOF"); } byte[] ret = new byte[length]; System.arraycopy(file, offset, ret, 0, length); return ret; }
[ "public", "byte", "[", "]", "getBytes", "(", "int", "offset", ",", "int", "length", ")", "throws", "IOException", "{", "if", "(", "(", "offset", "+", "length", ")", ">", "fsize", ")", "{", "throw", "new", "java", ".", "io", ".", "IOException", "(", "\"Reached EOF\"", ")", ";", "}", "byte", "[", "]", "ret", "=", "new", "byte", "[", "length", "]", ";", "System", ".", "arraycopy", "(", "file", ",", "offset", ",", "ret", ",", "0", ",", "length", ")", ";", "return", "ret", ";", "}" ]
Return a copy of the internal array @param offset The absolute offset to start reading from @param length The number of bytes to read @return An array of bytes @throws IOException if out of bounds
[ "Return", "a", "copy", "of", "the", "internal", "array" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/truetype/FontFileReader.java#L349-L358
1,532
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/TrueTypeFont.java
TrueTypeFont.getFontImage
private BufferedImage getFontImage(char ch) { // Create a temporary image to extract the character's size BufferedImage tempfontImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); Graphics2D g = (Graphics2D) tempfontImage.getGraphics(); if (antiAlias == true) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } g.setFont(font); fontMetrics = g.getFontMetrics(); int charwidth = fontMetrics.charWidth(ch); if (charwidth <= 0) { charwidth = 1; } int charheight = fontMetrics.getHeight(); if (charheight <= 0) { charheight = fontSize; } // Create another image holding the character we are creating BufferedImage fontImage; fontImage = new BufferedImage(charwidth, charheight, BufferedImage.TYPE_INT_ARGB); Graphics2D gt = (Graphics2D) fontImage.getGraphics(); if (antiAlias == true) { gt.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } gt.setFont(font); gt.setColor(Color.WHITE); int charx = 0; int chary = 0; gt.drawString(String.valueOf(ch), (charx), (chary) + fontMetrics.getAscent()); return fontImage; }
java
private BufferedImage getFontImage(char ch) { // Create a temporary image to extract the character's size BufferedImage tempfontImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); Graphics2D g = (Graphics2D) tempfontImage.getGraphics(); if (antiAlias == true) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } g.setFont(font); fontMetrics = g.getFontMetrics(); int charwidth = fontMetrics.charWidth(ch); if (charwidth <= 0) { charwidth = 1; } int charheight = fontMetrics.getHeight(); if (charheight <= 0) { charheight = fontSize; } // Create another image holding the character we are creating BufferedImage fontImage; fontImage = new BufferedImage(charwidth, charheight, BufferedImage.TYPE_INT_ARGB); Graphics2D gt = (Graphics2D) fontImage.getGraphics(); if (antiAlias == true) { gt.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } gt.setFont(font); gt.setColor(Color.WHITE); int charx = 0; int chary = 0; gt.drawString(String.valueOf(ch), (charx), (chary) + fontMetrics.getAscent()); return fontImage; }
[ "private", "BufferedImage", "getFontImage", "(", "char", "ch", ")", "{", "// Create a temporary image to extract the character's size\r", "BufferedImage", "tempfontImage", "=", "new", "BufferedImage", "(", "1", ",", "1", ",", "BufferedImage", ".", "TYPE_INT_ARGB", ")", ";", "Graphics2D", "g", "=", "(", "Graphics2D", ")", "tempfontImage", ".", "getGraphics", "(", ")", ";", "if", "(", "antiAlias", "==", "true", ")", "{", "g", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_ANTIALIASING", ",", "RenderingHints", ".", "VALUE_ANTIALIAS_ON", ")", ";", "}", "g", ".", "setFont", "(", "font", ")", ";", "fontMetrics", "=", "g", ".", "getFontMetrics", "(", ")", ";", "int", "charwidth", "=", "fontMetrics", ".", "charWidth", "(", "ch", ")", ";", "if", "(", "charwidth", "<=", "0", ")", "{", "charwidth", "=", "1", ";", "}", "int", "charheight", "=", "fontMetrics", ".", "getHeight", "(", ")", ";", "if", "(", "charheight", "<=", "0", ")", "{", "charheight", "=", "fontSize", ";", "}", "// Create another image holding the character we are creating\r", "BufferedImage", "fontImage", ";", "fontImage", "=", "new", "BufferedImage", "(", "charwidth", ",", "charheight", ",", "BufferedImage", ".", "TYPE_INT_ARGB", ")", ";", "Graphics2D", "gt", "=", "(", "Graphics2D", ")", "fontImage", ".", "getGraphics", "(", ")", ";", "if", "(", "antiAlias", "==", "true", ")", "{", "gt", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_ANTIALIASING", ",", "RenderingHints", ".", "VALUE_ANTIALIAS_ON", ")", ";", "}", "gt", ".", "setFont", "(", "font", ")", ";", "gt", ".", "setColor", "(", "Color", ".", "WHITE", ")", ";", "int", "charx", "=", "0", ";", "int", "chary", "=", "0", ";", "gt", ".", "drawString", "(", "String", ".", "valueOf", "(", "ch", ")", ",", "(", "charx", ")", ",", "(", "chary", ")", "+", "fontMetrics", ".", "getAscent", "(", ")", ")", ";", "return", "fontImage", ";", "}" ]
Create a standard Java2D BufferedImage of the given character @param ch The character to create a BufferedImage for @return A BufferedImage containing the character
[ "Create", "a", "standard", "Java2D", "BufferedImage", "of", "the", "given", "character" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/TrueTypeFont.java#L123-L163
1,533
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/TrueTypeFont.java
TrueTypeFont.createSet
private void createSet( char[] customCharsArray ) { // If there are custom chars then I expand the font texture twice if (customCharsArray != null && customCharsArray.length > 0) { textureWidth *= 2; } // In any case this should be done in other way. Texture with size 512x512 // can maintain only 256 characters with resolution of 32x32. The texture // size should be calculated dynamicaly by looking at character sizes. try { BufferedImage imgTemp = new BufferedImage(textureWidth, textureHeight, BufferedImage.TYPE_INT_ARGB); Graphics2D g = (Graphics2D) imgTemp.getGraphics(); g.setColor(new Color(255,255,255,1)); g.fillRect(0,0,textureWidth,textureHeight); int rowHeight = 0; int positionX = 0; int positionY = 0; int customCharsLength = ( customCharsArray != null ) ? customCharsArray.length : 0; for (int i = 0; i < 256 + customCharsLength; i++) { // get 0-255 characters and then custom characters char ch = ( i < 256 ) ? (char) i : customCharsArray[i-256]; BufferedImage fontImage = getFontImage(ch); IntObject newIntObject = new IntObject(); newIntObject.width = fontImage.getWidth(); newIntObject.height = fontImage.getHeight(); if (positionX + newIntObject.width >= textureWidth) { positionX = 0; positionY += rowHeight; rowHeight = 0; } newIntObject.storedX = positionX; newIntObject.storedY = positionY; if (newIntObject.height > fontHeight) { fontHeight = newIntObject.height; } if (newIntObject.height > rowHeight) { rowHeight = newIntObject.height; } // Draw it here g.drawImage(fontImage, positionX, positionY, null); positionX += newIntObject.width; if( i < 256 ) { // standard characters charArray[i] = newIntObject; } else { // custom characters customChars.put( new Character( ch ), newIntObject ); } fontImage = null; } fontTexture = BufferedImageUtil .getTexture(font.toString(), imgTemp); } catch (IOException e) { System.err.println("Failed to create font."); e.printStackTrace(); } }
java
private void createSet( char[] customCharsArray ) { // If there are custom chars then I expand the font texture twice if (customCharsArray != null && customCharsArray.length > 0) { textureWidth *= 2; } // In any case this should be done in other way. Texture with size 512x512 // can maintain only 256 characters with resolution of 32x32. The texture // size should be calculated dynamicaly by looking at character sizes. try { BufferedImage imgTemp = new BufferedImage(textureWidth, textureHeight, BufferedImage.TYPE_INT_ARGB); Graphics2D g = (Graphics2D) imgTemp.getGraphics(); g.setColor(new Color(255,255,255,1)); g.fillRect(0,0,textureWidth,textureHeight); int rowHeight = 0; int positionX = 0; int positionY = 0; int customCharsLength = ( customCharsArray != null ) ? customCharsArray.length : 0; for (int i = 0; i < 256 + customCharsLength; i++) { // get 0-255 characters and then custom characters char ch = ( i < 256 ) ? (char) i : customCharsArray[i-256]; BufferedImage fontImage = getFontImage(ch); IntObject newIntObject = new IntObject(); newIntObject.width = fontImage.getWidth(); newIntObject.height = fontImage.getHeight(); if (positionX + newIntObject.width >= textureWidth) { positionX = 0; positionY += rowHeight; rowHeight = 0; } newIntObject.storedX = positionX; newIntObject.storedY = positionY; if (newIntObject.height > fontHeight) { fontHeight = newIntObject.height; } if (newIntObject.height > rowHeight) { rowHeight = newIntObject.height; } // Draw it here g.drawImage(fontImage, positionX, positionY, null); positionX += newIntObject.width; if( i < 256 ) { // standard characters charArray[i] = newIntObject; } else { // custom characters customChars.put( new Character( ch ), newIntObject ); } fontImage = null; } fontTexture = BufferedImageUtil .getTexture(font.toString(), imgTemp); } catch (IOException e) { System.err.println("Failed to create font."); e.printStackTrace(); } }
[ "private", "void", "createSet", "(", "char", "[", "]", "customCharsArray", ")", "{", "// If there are custom chars then I expand the font texture twice\t\t\r", "if", "(", "customCharsArray", "!=", "null", "&&", "customCharsArray", ".", "length", ">", "0", ")", "{", "textureWidth", "*=", "2", ";", "}", "// In any case this should be done in other way. Texture with size 512x512\r", "// can maintain only 256 characters with resolution of 32x32. The texture\r", "// size should be calculated dynamicaly by looking at character sizes. \r", "try", "{", "BufferedImage", "imgTemp", "=", "new", "BufferedImage", "(", "textureWidth", ",", "textureHeight", ",", "BufferedImage", ".", "TYPE_INT_ARGB", ")", ";", "Graphics2D", "g", "=", "(", "Graphics2D", ")", "imgTemp", ".", "getGraphics", "(", ")", ";", "g", ".", "setColor", "(", "new", "Color", "(", "255", ",", "255", ",", "255", ",", "1", ")", ")", ";", "g", ".", "fillRect", "(", "0", ",", "0", ",", "textureWidth", ",", "textureHeight", ")", ";", "int", "rowHeight", "=", "0", ";", "int", "positionX", "=", "0", ";", "int", "positionY", "=", "0", ";", "int", "customCharsLength", "=", "(", "customCharsArray", "!=", "null", ")", "?", "customCharsArray", ".", "length", ":", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "256", "+", "customCharsLength", ";", "i", "++", ")", "{", "// get 0-255 characters and then custom characters\r", "char", "ch", "=", "(", "i", "<", "256", ")", "?", "(", "char", ")", "i", ":", "customCharsArray", "[", "i", "-", "256", "]", ";", "BufferedImage", "fontImage", "=", "getFontImage", "(", "ch", ")", ";", "IntObject", "newIntObject", "=", "new", "IntObject", "(", ")", ";", "newIntObject", ".", "width", "=", "fontImage", ".", "getWidth", "(", ")", ";", "newIntObject", ".", "height", "=", "fontImage", ".", "getHeight", "(", ")", ";", "if", "(", "positionX", "+", "newIntObject", ".", "width", ">=", "textureWidth", ")", "{", "positionX", "=", "0", ";", "positionY", "+=", "rowHeight", ";", "rowHeight", "=", "0", ";", "}", "newIntObject", ".", "storedX", "=", "positionX", ";", "newIntObject", ".", "storedY", "=", "positionY", ";", "if", "(", "newIntObject", ".", "height", ">", "fontHeight", ")", "{", "fontHeight", "=", "newIntObject", ".", "height", ";", "}", "if", "(", "newIntObject", ".", "height", ">", "rowHeight", ")", "{", "rowHeight", "=", "newIntObject", ".", "height", ";", "}", "// Draw it here\r", "g", ".", "drawImage", "(", "fontImage", ",", "positionX", ",", "positionY", ",", "null", ")", ";", "positionX", "+=", "newIntObject", ".", "width", ";", "if", "(", "i", "<", "256", ")", "{", "// standard characters\r", "charArray", "[", "i", "]", "=", "newIntObject", ";", "}", "else", "{", "// custom characters\r", "customChars", ".", "put", "(", "new", "Character", "(", "ch", ")", ",", "newIntObject", ")", ";", "}", "fontImage", "=", "null", ";", "}", "fontTexture", "=", "BufferedImageUtil", ".", "getTexture", "(", "font", ".", "toString", "(", ")", ",", "imgTemp", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "System", ".", "err", ".", "println", "(", "\"Failed to create font.\"", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Create and store the font @param customCharsArray Characters that should be also added to the cache.
[ "Create", "and", "store", "the", "font" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/TrueTypeFont.java#L170-L244
1,534
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/TrueTypeFont.java
TrueTypeFont.getWidth
public int getWidth(String whatchars) { int totalwidth = 0; IntObject intObject = null; int currentChar = 0; for (int i = 0; i < whatchars.length(); i++) { currentChar = whatchars.charAt(i); if (currentChar < 256) { intObject = charArray[currentChar]; } else { intObject = (IntObject)customChars.get( new Character( (char) currentChar ) ); } if( intObject != null ) totalwidth += intObject.width; } return totalwidth; }
java
public int getWidth(String whatchars) { int totalwidth = 0; IntObject intObject = null; int currentChar = 0; for (int i = 0; i < whatchars.length(); i++) { currentChar = whatchars.charAt(i); if (currentChar < 256) { intObject = charArray[currentChar]; } else { intObject = (IntObject)customChars.get( new Character( (char) currentChar ) ); } if( intObject != null ) totalwidth += intObject.width; } return totalwidth; }
[ "public", "int", "getWidth", "(", "String", "whatchars", ")", "{", "int", "totalwidth", "=", "0", ";", "IntObject", "intObject", "=", "null", ";", "int", "currentChar", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "whatchars", ".", "length", "(", ")", ";", "i", "++", ")", "{", "currentChar", "=", "whatchars", ".", "charAt", "(", "i", ")", ";", "if", "(", "currentChar", "<", "256", ")", "{", "intObject", "=", "charArray", "[", "currentChar", "]", ";", "}", "else", "{", "intObject", "=", "(", "IntObject", ")", "customChars", ".", "get", "(", "new", "Character", "(", "(", "char", ")", "currentChar", ")", ")", ";", "}", "if", "(", "intObject", "!=", "null", ")", "totalwidth", "+=", "intObject", ".", "width", ";", "}", "return", "totalwidth", ";", "}" ]
Get the width of a given String @param whatchars The characters to get the width of @return The width of the characters
[ "Get", "the", "width", "of", "a", "given", "String" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/TrueTypeFont.java#L296-L312
1,535
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/CursorLoader.java
CursorLoader.getCursor
public Cursor getCursor(String ref,int x,int y) throws IOException, LWJGLException { LoadableImageData imageData = null; imageData = ImageDataFactory.getImageDataFor(ref); imageData.configureEdging(false); ByteBuffer buf = imageData.loadImage(ResourceLoader.getResourceAsStream(ref), true, true, null); for (int i=0;i<buf.limit();i+=4) { byte red = buf.get(i); byte green = buf.get(i+1); byte blue = buf.get(i+2); byte alpha = buf.get(i+3); buf.put(i+2, red); buf.put(i+1, green); buf.put(i, blue); buf.put(i+3, alpha); } try { int yspot = imageData.getHeight() - y - 1; if (yspot < 0) { yspot = 0; } return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null); } catch (Throwable e) { Log.info("Chances are you cursor is too small for this platform"); throw new LWJGLException(e); } }
java
public Cursor getCursor(String ref,int x,int y) throws IOException, LWJGLException { LoadableImageData imageData = null; imageData = ImageDataFactory.getImageDataFor(ref); imageData.configureEdging(false); ByteBuffer buf = imageData.loadImage(ResourceLoader.getResourceAsStream(ref), true, true, null); for (int i=0;i<buf.limit();i+=4) { byte red = buf.get(i); byte green = buf.get(i+1); byte blue = buf.get(i+2); byte alpha = buf.get(i+3); buf.put(i+2, red); buf.put(i+1, green); buf.put(i, blue); buf.put(i+3, alpha); } try { int yspot = imageData.getHeight() - y - 1; if (yspot < 0) { yspot = 0; } return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null); } catch (Throwable e) { Log.info("Chances are you cursor is too small for this platform"); throw new LWJGLException(e); } }
[ "public", "Cursor", "getCursor", "(", "String", "ref", ",", "int", "x", ",", "int", "y", ")", "throws", "IOException", ",", "LWJGLException", "{", "LoadableImageData", "imageData", "=", "null", ";", "imageData", "=", "ImageDataFactory", ".", "getImageDataFor", "(", "ref", ")", ";", "imageData", ".", "configureEdging", "(", "false", ")", ";", "ByteBuffer", "buf", "=", "imageData", ".", "loadImage", "(", "ResourceLoader", ".", "getResourceAsStream", "(", "ref", ")", ",", "true", ",", "true", ",", "null", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "buf", ".", "limit", "(", ")", ";", "i", "+=", "4", ")", "{", "byte", "red", "=", "buf", ".", "get", "(", "i", ")", ";", "byte", "green", "=", "buf", ".", "get", "(", "i", "+", "1", ")", ";", "byte", "blue", "=", "buf", ".", "get", "(", "i", "+", "2", ")", ";", "byte", "alpha", "=", "buf", ".", "get", "(", "i", "+", "3", ")", ";", "buf", ".", "put", "(", "i", "+", "2", ",", "red", ")", ";", "buf", ".", "put", "(", "i", "+", "1", ",", "green", ")", ";", "buf", ".", "put", "(", "i", ",", "blue", ")", ";", "buf", ".", "put", "(", "i", "+", "3", ",", "alpha", ")", ";", "}", "try", "{", "int", "yspot", "=", "imageData", ".", "getHeight", "(", ")", "-", "y", "-", "1", ";", "if", "(", "yspot", "<", "0", ")", "{", "yspot", "=", "0", ";", "}", "return", "new", "Cursor", "(", "imageData", ".", "getTexWidth", "(", ")", ",", "imageData", ".", "getTexHeight", "(", ")", ",", "x", ",", "yspot", ",", "1", ",", "buf", ".", "asIntBuffer", "(", ")", ",", "null", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "Log", ".", "info", "(", "\"Chances are you cursor is too small for this platform\"", ")", ";", "throw", "new", "LWJGLException", "(", "e", ")", ";", "}", "}" ]
Get a cursor based on a image reference on the classpath @param ref The reference to the image to be loaded @param x The x-coordinate of the cursor hotspot (left -> right) @param y The y-coordinate of the cursor hotspot (bottom -> top) @return The create cursor @throws IOException Indicates a failure to load the image @throws LWJGLException Indicates a failure to create the hardware cursor
[ "Get", "a", "cursor", "based", "on", "a", "image", "reference", "on", "the", "classpath" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/CursorLoader.java#L49-L79
1,536
nguillaumin/slick2d-maven
slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/RawScale2x.java
RawScale2x.getSourcePixel
private int getSourcePixel(int x,int y) { x = Math.max(0,x); x = Math.min(width-1,x); y = Math.max(0,y); y = Math.min(height-1,y); return srcImage[x+(y*width)]; }
java
private int getSourcePixel(int x,int y) { x = Math.max(0,x); x = Math.min(width-1,x); y = Math.max(0,y); y = Math.min(height-1,y); return srcImage[x+(y*width)]; }
[ "private", "int", "getSourcePixel", "(", "int", "x", ",", "int", "y", ")", "{", "x", "=", "Math", ".", "max", "(", "0", ",", "x", ")", ";", "x", "=", "Math", ".", "min", "(", "width", "-", "1", ",", "x", ")", ";", "y", "=", "Math", ".", "max", "(", "0", ",", "y", ")", ";", "y", "=", "Math", ".", "min", "(", "height", "-", "1", ",", "y", ")", ";", "return", "srcImage", "[", "x", "+", "(", "y", "*", "width", ")", "]", ";", "}" ]
Get a pixel from the source image. This handles bonds checks and resolves to edge pixels @param x The x location of the pixel to retrieve @param y The y location of the pixel to retrieve @return The pixel value at the specified location
[ "Get", "a", "pixel", "from", "the", "source", "image", ".", "This", "handles", "bonds", "checks", "and", "resolves", "to", "edge", "pixels" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/RawScale2x.java#L69-L77
1,537
nguillaumin/slick2d-maven
slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/RawScale2x.java
RawScale2x.getScaledData
public int[] getScaledData() { for (int x=0;x<width;x++) { for (int y=0;y<height;y++) { process(x,y); } } return dstImage; }
java
public int[] getScaledData() { for (int x=0;x<width;x++) { for (int y=0;y<height;y++) { process(x,y); } } return dstImage; }
[ "public", "int", "[", "]", "getScaledData", "(", ")", "{", "for", "(", "int", "x", "=", "0", ";", "x", "<", "width", ";", "x", "++", ")", "{", "for", "(", "int", "y", "=", "0", ";", "y", "<", "height", ";", "y", "++", ")", "{", "process", "(", "x", ",", "y", ")", ";", "}", "}", "return", "dstImage", ";", "}" ]
Get the scale image data. Note this is the method that does the work so it might take some time to process. @return An array of pixels 4 times the size of the input array containing the smoothly scaled image
[ "Get", "the", "scale", "image", "data", ".", "Note", "this", "is", "the", "method", "that", "does", "the", "work", "so", "it", "might", "take", "some", "time", "to", "process", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/RawScale2x.java#L122-L133
1,538
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ColorPanel.java
ColorPanel.updateRender
private void updateRender() { if (inherit.isSelected()) { emitter.usePoints = Particle.INHERIT_POINTS; oriented.setEnabled( true ); } if (quads.isSelected()) { emitter.usePoints = Particle.USE_QUADS; oriented.setEnabled( true ); } if (points.isSelected()) { emitter.usePoints = Particle.USE_POINTS; oriented.setEnabled( false ); oriented.setSelected( false ); } // oriented if( oriented.isSelected()) emitter.useOriented= true; else emitter.useOriented= false; // additive blending if( additive.isSelected()) emitter.useAdditive= true; else emitter.useAdditive= false; }
java
private void updateRender() { if (inherit.isSelected()) { emitter.usePoints = Particle.INHERIT_POINTS; oriented.setEnabled( true ); } if (quads.isSelected()) { emitter.usePoints = Particle.USE_QUADS; oriented.setEnabled( true ); } if (points.isSelected()) { emitter.usePoints = Particle.USE_POINTS; oriented.setEnabled( false ); oriented.setSelected( false ); } // oriented if( oriented.isSelected()) emitter.useOriented= true; else emitter.useOriented= false; // additive blending if( additive.isSelected()) emitter.useAdditive= true; else emitter.useAdditive= false; }
[ "private", "void", "updateRender", "(", ")", "{", "if", "(", "inherit", ".", "isSelected", "(", ")", ")", "{", "emitter", ".", "usePoints", "=", "Particle", ".", "INHERIT_POINTS", ";", "oriented", ".", "setEnabled", "(", "true", ")", ";", "}", "if", "(", "quads", ".", "isSelected", "(", ")", ")", "{", "emitter", ".", "usePoints", "=", "Particle", ".", "USE_QUADS", ";", "oriented", ".", "setEnabled", "(", "true", ")", ";", "}", "if", "(", "points", ".", "isSelected", "(", ")", ")", "{", "emitter", ".", "usePoints", "=", "Particle", ".", "USE_POINTS", ";", "oriented", ".", "setEnabled", "(", "false", ")", ";", "oriented", ".", "setSelected", "(", "false", ")", ";", "}", "// oriented\r", "if", "(", "oriented", ".", "isSelected", "(", ")", ")", "emitter", ".", "useOriented", "=", "true", ";", "else", "emitter", ".", "useOriented", "=", "false", ";", "// additive blending\r", "if", "(", "additive", ".", "isSelected", "(", ")", ")", "emitter", ".", "useAdditive", "=", "true", ";", "else", "emitter", ".", "useAdditive", "=", "false", ";", "}" ]
Update the render setting
[ "Update", "the", "render", "setting" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ColorPanel.java#L125-L154
1,539
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ColorPanel.java
ColorPanel.updateColors
private void updateColors() { if (blockUpdates) { return; } emitter.colors.clear(); for (int i=0;i<grad.getControlPointCount();i++) { float pos = grad.getPointPos(i); java.awt.Color col = grad.getColor(i); Color slick = new Color(col.getRed() / 255.0f, col.getGreen() / 255.0f, col.getBlue() / 255.0f, 1.0f); emitter.addColorPoint(pos, slick); } }
java
private void updateColors() { if (blockUpdates) { return; } emitter.colors.clear(); for (int i=0;i<grad.getControlPointCount();i++) { float pos = grad.getPointPos(i); java.awt.Color col = grad.getColor(i); Color slick = new Color(col.getRed() / 255.0f, col.getGreen() / 255.0f, col.getBlue() / 255.0f, 1.0f); emitter.addColorPoint(pos, slick); } }
[ "private", "void", "updateColors", "(", ")", "{", "if", "(", "blockUpdates", ")", "{", "return", ";", "}", "emitter", ".", "colors", ".", "clear", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "grad", ".", "getControlPointCount", "(", ")", ";", "i", "++", ")", "{", "float", "pos", "=", "grad", ".", "getPointPos", "(", "i", ")", ";", "java", ".", "awt", ".", "Color", "col", "=", "grad", ".", "getColor", "(", "i", ")", ";", "Color", "slick", "=", "new", "Color", "(", "col", ".", "getRed", "(", ")", "/", "255.0f", ",", "col", ".", "getGreen", "(", ")", "/", "255.0f", ",", "col", ".", "getBlue", "(", ")", "/", "255.0f", ",", "1.0f", ")", ";", "emitter", ".", "addColorPoint", "(", "pos", ",", "slick", ")", ";", "}", "}" ]
Update the state of the emitter based on colours in the editor
[ "Update", "the", "state", "of", "the", "emitter", "based", "on", "colours", "in", "the", "editor" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ColorPanel.java#L159-L171
1,540
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/FBOGraphics.java
FBOGraphics.completeCheck
private void completeCheck() throws SlickException { int framebuffer = EXTFramebufferObject.glCheckFramebufferStatusEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT); switch ( framebuffer ) { case EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT: break; case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT exception" ); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT exception" ); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT exception" ); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT exception" ); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT exception" ); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT exception" ); default: throw new SlickException( "Unexpected reply from glCheckFramebufferStatusEXT: " + framebuffer); } }
java
private void completeCheck() throws SlickException { int framebuffer = EXTFramebufferObject.glCheckFramebufferStatusEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT); switch ( framebuffer ) { case EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT: break; case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT exception" ); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT exception" ); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT exception" ); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT exception" ); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT exception" ); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: throw new SlickException( "FrameBuffer: " + FBO + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT exception" ); default: throw new SlickException( "Unexpected reply from glCheckFramebufferStatusEXT: " + framebuffer); } }
[ "private", "void", "completeCheck", "(", ")", "throws", "SlickException", "{", "int", "framebuffer", "=", "EXTFramebufferObject", ".", "glCheckFramebufferStatusEXT", "(", "EXTFramebufferObject", ".", "GL_FRAMEBUFFER_EXT", ")", ";", "switch", "(", "framebuffer", ")", "{", "case", "EXTFramebufferObject", ".", "GL_FRAMEBUFFER_COMPLETE_EXT", ":", "break", ";", "case", "EXTFramebufferObject", ".", "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT", ":", "throw", "new", "SlickException", "(", "\"FrameBuffer: \"", "+", "FBO", "+", "\", has caused a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT exception\"", ")", ";", "case", "EXTFramebufferObject", ".", "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT", ":", "throw", "new", "SlickException", "(", "\"FrameBuffer: \"", "+", "FBO", "+", "\", has caused a GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT exception\"", ")", ";", "case", "EXTFramebufferObject", ".", "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT", ":", "throw", "new", "SlickException", "(", "\"FrameBuffer: \"", "+", "FBO", "+", "\", has caused a GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT exception\"", ")", ";", "case", "EXTFramebufferObject", ".", "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT", ":", "throw", "new", "SlickException", "(", "\"FrameBuffer: \"", "+", "FBO", "+", "\", has caused a GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT exception\"", ")", ";", "case", "EXTFramebufferObject", ".", "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT", ":", "throw", "new", "SlickException", "(", "\"FrameBuffer: \"", "+", "FBO", "+", "\", has caused a GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT exception\"", ")", ";", "case", "EXTFramebufferObject", ".", "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT", ":", "throw", "new", "SlickException", "(", "\"FrameBuffer: \"", "+", "FBO", "+", "\", has caused a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT exception\"", ")", ";", "default", ":", "throw", "new", "SlickException", "(", "\"Unexpected reply from glCheckFramebufferStatusEXT: \"", "+", "framebuffer", ")", ";", "}", "}" ]
Check the FBO for completeness as shown in the LWJGL tutorial @throws SlickException Indicates an incomplete FBO
[ "Check", "the", "FBO", "for", "completeness", "as", "shown", "in", "the", "LWJGL", "tutorial" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/FBOGraphics.java#L55-L81
1,541
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/FBOGraphics.java
FBOGraphics.init
private void init() throws SlickException { IntBuffer buffer = BufferUtils.createIntBuffer(1); EXTFramebufferObject.glGenFramebuffersEXT(buffer); FBO = buffer.get(); // for some reason FBOs won't work on textures unless you've absolutely just // created them. try { Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter()); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, FBO); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, tex.getTextureID(), 0); completeCheck(); unbind(); // Clear our destination area before using it clear(); flush(); // keep hold of the original content drawImage(image, 0, 0); image.setTexture(tex); } catch (Exception e) { throw new SlickException("Failed to create new texture for FBO"); } }
java
private void init() throws SlickException { IntBuffer buffer = BufferUtils.createIntBuffer(1); EXTFramebufferObject.glGenFramebuffersEXT(buffer); FBO = buffer.get(); // for some reason FBOs won't work on textures unless you've absolutely just // created them. try { Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter()); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, FBO); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, tex.getTextureID(), 0); completeCheck(); unbind(); // Clear our destination area before using it clear(); flush(); // keep hold of the original content drawImage(image, 0, 0); image.setTexture(tex); } catch (Exception e) { throw new SlickException("Failed to create new texture for FBO"); } }
[ "private", "void", "init", "(", ")", "throws", "SlickException", "{", "IntBuffer", "buffer", "=", "BufferUtils", ".", "createIntBuffer", "(", "1", ")", ";", "EXTFramebufferObject", ".", "glGenFramebuffersEXT", "(", "buffer", ")", ";", "FBO", "=", "buffer", ".", "get", "(", ")", ";", "// for some reason FBOs won't work on textures unless you've absolutely just\r", "// created them.\r", "try", "{", "Texture", "tex", "=", "InternalTextureLoader", ".", "get", "(", ")", ".", "createTexture", "(", "image", ".", "getWidth", "(", ")", ",", "image", ".", "getHeight", "(", ")", ",", "image", ".", "getFilter", "(", ")", ")", ";", "EXTFramebufferObject", ".", "glBindFramebufferEXT", "(", "EXTFramebufferObject", ".", "GL_FRAMEBUFFER_EXT", ",", "FBO", ")", ";", "EXTFramebufferObject", ".", "glFramebufferTexture2DEXT", "(", "EXTFramebufferObject", ".", "GL_FRAMEBUFFER_EXT", ",", "EXTFramebufferObject", ".", "GL_COLOR_ATTACHMENT0_EXT", ",", "GL11", ".", "GL_TEXTURE_2D", ",", "tex", ".", "getTextureID", "(", ")", ",", "0", ")", ";", "completeCheck", "(", ")", ";", "unbind", "(", ")", ";", "// Clear our destination area before using it\r", "clear", "(", ")", ";", "flush", "(", ")", ";", "// keep hold of the original content\r", "drawImage", "(", "image", ",", "0", ",", "0", ")", ";", "image", ".", "setTexture", "(", "tex", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "SlickException", "(", "\"Failed to create new texture for FBO\"", ")", ";", "}", "}" ]
Initialise the FBO that will be used to render to @throws SlickException
[ "Initialise", "the", "FBO", "that", "will", "be", "used", "to", "render", "to" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/FBOGraphics.java#L88-L117
1,542
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/FBOGraphics.java
FBOGraphics.bind
private void bind() { EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, FBO); GL11.glReadBuffer(EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT); }
java
private void bind() { EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, FBO); GL11.glReadBuffer(EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT); }
[ "private", "void", "bind", "(", ")", "{", "EXTFramebufferObject", ".", "glBindFramebufferEXT", "(", "EXTFramebufferObject", ".", "GL_FRAMEBUFFER_EXT", ",", "FBO", ")", ";", "GL11", ".", "glReadBuffer", "(", "EXTFramebufferObject", ".", "GL_COLOR_ATTACHMENT0_EXT", ")", ";", "}" ]
Bind to the FBO created
[ "Bind", "to", "the", "FBO", "created" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/FBOGraphics.java#L122-L125
1,543
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/FBOGraphics.java
FBOGraphics.enterOrtho
protected void enterOrtho() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, screenWidth, 0, screenHeight, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
java
protected void enterOrtho() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, screenWidth, 0, screenHeight, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
[ "protected", "void", "enterOrtho", "(", ")", "{", "GL11", ".", "glMatrixMode", "(", "GL11", ".", "GL_PROJECTION", ")", ";", "GL11", ".", "glLoadIdentity", "(", ")", ";", "GL11", ".", "glOrtho", "(", "0", ",", "screenWidth", ",", "0", ",", "screenHeight", ",", "1", ",", "-", "1", ")", ";", "GL11", ".", "glMatrixMode", "(", "GL11", ".", "GL_MODELVIEW", ")", ";", "}" ]
Enter the orthographic mode
[ "Enter", "the", "orthographic", "mode" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/FBOGraphics.java#L198-L203
1,544
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/DefaultLogSystem.java
DefaultLogSystem.error
public void error(Throwable e) { out.println(new Date()+" ERROR:" +e.getMessage()); e.printStackTrace(out); }
java
public void error(Throwable e) { out.println(new Date()+" ERROR:" +e.getMessage()); e.printStackTrace(out); }
[ "public", "void", "error", "(", "Throwable", "e", ")", "{", "out", ".", "println", "(", "new", "Date", "(", ")", "+", "\" ERROR:\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "e", ".", "printStackTrace", "(", "out", ")", ";", "}" ]
Log an error @param e The exception causing the error
[ "Log", "an", "error" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/DefaultLogSystem.java#L31-L34
1,545
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/DefaultLogSystem.java
DefaultLogSystem.warn
public void warn(String message, Throwable e) { warn(message); e.printStackTrace(out); }
java
public void warn(String message, Throwable e) { warn(message); e.printStackTrace(out); }
[ "public", "void", "warn", "(", "String", "message", ",", "Throwable", "e", ")", "{", "warn", "(", "message", ")", ";", "e", ".", "printStackTrace", "(", "out", ")", ";", "}" ]
Log a warning with an exception that caused it @param message The message describing the warning @param e The cause of the warning
[ "Log", "a", "warning", "with", "an", "exception", "that", "caused", "it" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/DefaultLogSystem.java#L78-L81
1,546
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/GraphicsFactory.java
GraphicsFactory.init
private static void init() throws SlickException { init = true; if (fbo) { fbo = GLContext.getCapabilities().GL_EXT_framebuffer_object; } pbuffer = (Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) != 0; pbufferRT = (Pbuffer.getCapabilities() & Pbuffer.RENDER_TEXTURE_SUPPORTED) != 0; if (!fbo && !pbuffer && !pbufferRT) { throw new SlickException("Your OpenGL card does not support offscreen buffers and hence can't handle the dynamic images required for this application."); } Log.info("Offscreen Buffers FBO="+fbo+" PBUFFER="+pbuffer+" PBUFFERRT="+pbufferRT); }
java
private static void init() throws SlickException { init = true; if (fbo) { fbo = GLContext.getCapabilities().GL_EXT_framebuffer_object; } pbuffer = (Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) != 0; pbufferRT = (Pbuffer.getCapabilities() & Pbuffer.RENDER_TEXTURE_SUPPORTED) != 0; if (!fbo && !pbuffer && !pbufferRT) { throw new SlickException("Your OpenGL card does not support offscreen buffers and hence can't handle the dynamic images required for this application."); } Log.info("Offscreen Buffers FBO="+fbo+" PBUFFER="+pbuffer+" PBUFFERRT="+pbufferRT); }
[ "private", "static", "void", "init", "(", ")", "throws", "SlickException", "{", "init", "=", "true", ";", "if", "(", "fbo", ")", "{", "fbo", "=", "GLContext", ".", "getCapabilities", "(", ")", ".", "GL_EXT_framebuffer_object", ";", "}", "pbuffer", "=", "(", "Pbuffer", ".", "getCapabilities", "(", ")", "&", "Pbuffer", ".", "PBUFFER_SUPPORTED", ")", "!=", "0", ";", "pbufferRT", "=", "(", "Pbuffer", ".", "getCapabilities", "(", ")", "&", "Pbuffer", ".", "RENDER_TEXTURE_SUPPORTED", ")", "!=", "0", ";", "if", "(", "!", "fbo", "&&", "!", "pbuffer", "&&", "!", "pbufferRT", ")", "{", "throw", "new", "SlickException", "(", "\"Your OpenGL card does not support offscreen buffers and hence can't handle the dynamic images required for this application.\"", ")", ";", "}", "Log", ".", "info", "(", "\"Offscreen Buffers FBO=\"", "+", "fbo", "+", "\" PBUFFER=\"", "+", "pbuffer", "+", "\" PBUFFERRT=\"", "+", "pbufferRT", ")", ";", "}" ]
Initialise offscreen rendering by checking what buffers are supported by the card @throws SlickException Indicates no buffers are supported
[ "Initialise", "offscreen", "rendering", "by", "checking", "what", "buffers", "are", "supported", "by", "the", "card" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/GraphicsFactory.java#L36-L50
1,547
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/GraphicsFactory.java
GraphicsFactory.getGraphicsForImage
public static Graphics getGraphicsForImage(Image image) throws SlickException { Graphics g = (Graphics) graphics.get(image.getTexture()); if (g == null) { g = createGraphics(image); graphics.put(image.getTexture(), g); } return g; }
java
public static Graphics getGraphicsForImage(Image image) throws SlickException { Graphics g = (Graphics) graphics.get(image.getTexture()); if (g == null) { g = createGraphics(image); graphics.put(image.getTexture(), g); } return g; }
[ "public", "static", "Graphics", "getGraphicsForImage", "(", "Image", "image", ")", "throws", "SlickException", "{", "Graphics", "g", "=", "(", "Graphics", ")", "graphics", ".", "get", "(", "image", ".", "getTexture", "(", ")", ")", ";", "if", "(", "g", "==", "null", ")", "{", "g", "=", "createGraphics", "(", "image", ")", ";", "graphics", ".", "put", "(", "image", ".", "getTexture", "(", ")", ",", "g", ")", ";", "}", "return", "g", ";", "}" ]
Get a graphics context for a particular image @param image The image for which to retrieve the graphics context @return The graphics context @throws SlickException Indicates it wasn't possible to create a graphics context given available hardware.
[ "Get", "a", "graphics", "context", "for", "a", "particular", "image" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/GraphicsFactory.java#L87-L96
1,548
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/GraphicsFactory.java
GraphicsFactory.releaseGraphicsForImage
public static void releaseGraphicsForImage(Image image) throws SlickException { Graphics g = (Graphics) graphics.remove(image.getTexture()); if (g != null) { g.destroy(); } }
java
public static void releaseGraphicsForImage(Image image) throws SlickException { Graphics g = (Graphics) graphics.remove(image.getTexture()); if (g != null) { g.destroy(); } }
[ "public", "static", "void", "releaseGraphicsForImage", "(", "Image", "image", ")", "throws", "SlickException", "{", "Graphics", "g", "=", "(", "Graphics", ")", "graphics", ".", "remove", "(", "image", ".", "getTexture", "(", ")", ")", ";", "if", "(", "g", "!=", "null", ")", "{", "g", ".", "destroy", "(", ")", ";", "}", "}" ]
Release any graphics context that is assocaited with the given image @param image The image to release @throws SlickException Indicates a failure to release the context
[ "Release", "any", "graphics", "context", "that", "is", "assocaited", "with", "the", "given", "image" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/GraphicsFactory.java#L104-L110
1,549
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/GraphicsFactory.java
GraphicsFactory.createGraphics
private static Graphics createGraphics(Image image) throws SlickException { init(); if (fbo) { try { return new FBOGraphics(image); } catch (Exception e) { fbo = false; Log.warn("FBO failed in use, falling back to PBuffer"); } } if (pbuffer) { if (pbufferRT) { return new PBufferGraphics(image); } else { return new PBufferUniqueGraphics(image); } } throw new SlickException("Failed to create offscreen buffer even though the card reports it's possible"); }
java
private static Graphics createGraphics(Image image) throws SlickException { init(); if (fbo) { try { return new FBOGraphics(image); } catch (Exception e) { fbo = false; Log.warn("FBO failed in use, falling back to PBuffer"); } } if (pbuffer) { if (pbufferRT) { return new PBufferGraphics(image); } else { return new PBufferUniqueGraphics(image); } } throw new SlickException("Failed to create offscreen buffer even though the card reports it's possible"); }
[ "private", "static", "Graphics", "createGraphics", "(", "Image", "image", ")", "throws", "SlickException", "{", "init", "(", ")", ";", "if", "(", "fbo", ")", "{", "try", "{", "return", "new", "FBOGraphics", "(", "image", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "fbo", "=", "false", ";", "Log", ".", "warn", "(", "\"FBO failed in use, falling back to PBuffer\"", ")", ";", "}", "}", "if", "(", "pbuffer", ")", "{", "if", "(", "pbufferRT", ")", "{", "return", "new", "PBufferGraphics", "(", "image", ")", ";", "}", "else", "{", "return", "new", "PBufferUniqueGraphics", "(", "image", ")", ";", "}", "}", "throw", "new", "SlickException", "(", "\"Failed to create offscreen buffer even though the card reports it's possible\"", ")", ";", "}" ]
Create an underlying graphics context for the given image @param image The image we want to render to @return The graphics context created @throws SlickException
[ "Create", "an", "underlying", "graphics", "context", "for", "the", "given", "image" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/pbuffer/GraphicsFactory.java#L119-L140
1,550
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/AStarPathFinder.java
AStarPathFinder.isValidLocation
protected boolean isValidLocation(Mover mover, int sx, int sy, int x, int y) { boolean invalid = (x < 0) || (y < 0) || (x >= map.getWidthInTiles()) || (y >= map.getHeightInTiles()); if ((!invalid) && ((sx != x) || (sy != y))) { this.mover = mover; this.sourceX = sx; this.sourceY = sy; invalid = map.blocked(this, x, y); } return !invalid; }
java
protected boolean isValidLocation(Mover mover, int sx, int sy, int x, int y) { boolean invalid = (x < 0) || (y < 0) || (x >= map.getWidthInTiles()) || (y >= map.getHeightInTiles()); if ((!invalid) && ((sx != x) || (sy != y))) { this.mover = mover; this.sourceX = sx; this.sourceY = sy; invalid = map.blocked(this, x, y); } return !invalid; }
[ "protected", "boolean", "isValidLocation", "(", "Mover", "mover", ",", "int", "sx", ",", "int", "sy", ",", "int", "x", ",", "int", "y", ")", "{", "boolean", "invalid", "=", "(", "x", "<", "0", ")", "||", "(", "y", "<", "0", ")", "||", "(", "x", ">=", "map", ".", "getWidthInTiles", "(", ")", ")", "||", "(", "y", ">=", "map", ".", "getHeightInTiles", "(", ")", ")", ";", "if", "(", "(", "!", "invalid", ")", "&&", "(", "(", "sx", "!=", "x", ")", "||", "(", "sy", "!=", "y", ")", ")", ")", "{", "this", ".", "mover", "=", "mover", ";", "this", ".", "sourceX", "=", "sx", ";", "this", ".", "sourceY", "=", "sy", ";", "invalid", "=", "map", ".", "blocked", "(", "this", ",", "x", ",", "y", ")", ";", "}", "return", "!", "invalid", ";", "}" ]
Check if a given location is valid for the supplied mover @param mover The mover that would hold a given location @param sx The starting x coordinate @param sy The starting y coordinate @param x The x coordinate of the location to check @param y The y coordinate of the location to check @return True if the location is valid for the given mover
[ "Check", "if", "a", "given", "location", "is", "valid", "for", "the", "supplied", "mover" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/AStarPathFinder.java#L317-L328
1,551
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/AStarPathFinder.java
AStarPathFinder.getMovementCost
public float getMovementCost(Mover mover, int sx, int sy, int tx, int ty) { this.mover = mover; this.sourceX = sx; this.sourceY = sy; return map.getCost(this, tx, ty); }
java
public float getMovementCost(Mover mover, int sx, int sy, int tx, int ty) { this.mover = mover; this.sourceX = sx; this.sourceY = sy; return map.getCost(this, tx, ty); }
[ "public", "float", "getMovementCost", "(", "Mover", "mover", ",", "int", "sx", ",", "int", "sy", ",", "int", "tx", ",", "int", "ty", ")", "{", "this", ".", "mover", "=", "mover", ";", "this", ".", "sourceX", "=", "sx", ";", "this", ".", "sourceY", "=", "sy", ";", "return", "map", ".", "getCost", "(", "this", ",", "tx", ",", "ty", ")", ";", "}" ]
Get the cost to move through a given location @param mover The entity that is being moved @param sx The x coordinate of the tile whose cost is being determined @param sy The y coordiante of the tile whose cost is being determined @param tx The x coordinate of the target location @param ty The y coordinate of the target location @return The cost of movement through the given tile
[ "Get", "the", "cost", "to", "move", "through", "a", "given", "location" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/pathfinding/AStarPathFinder.java#L340-L346
1,552
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Color.java
Color.darker
public Color darker(float scale) { scale = 1 - scale; Color temp = new Color(r * scale,g * scale,b * scale,a); return temp; }
java
public Color darker(float scale) { scale = 1 - scale; Color temp = new Color(r * scale,g * scale,b * scale,a); return temp; }
[ "public", "Color", "darker", "(", "float", "scale", ")", "{", "scale", "=", "1", "-", "scale", ";", "Color", "temp", "=", "new", "Color", "(", "r", "*", "scale", ",", "g", "*", "scale", ",", "b", "*", "scale", ",", "a", ")", ";", "return", "temp", ";", "}" ]
Make a darker instance of this colour @param scale The scale down of RGB (i.e. if you supply 0.03 the colour will be darkened by 3%) @return The darker version of this colour
[ "Make", "a", "darker", "instance", "of", "this", "colour" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Color.java#L226-L231
1,553
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Color.java
Color.brighter
public Color brighter(float scale) { scale += 1; Color temp = new Color(r * scale,g * scale,b * scale,a); return temp; }
java
public Color brighter(float scale) { scale += 1; Color temp = new Color(r * scale,g * scale,b * scale,a); return temp; }
[ "public", "Color", "brighter", "(", "float", "scale", ")", "{", "scale", "+=", "1", ";", "Color", "temp", "=", "new", "Color", "(", "r", "*", "scale", ",", "g", "*", "scale", ",", "b", "*", "scale", ",", "a", ")", ";", "return", "temp", ";", "}" ]
Make a brighter instance of this colour @param scale The scale up of RGB (i.e. if you supply 0.03 the colour will be brightened by 3%) @return The brighter version of this colour
[ "Make", "a", "brighter", "instance", "of", "this", "colour" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Color.java#L320-L325
1,554
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/Color.java
Color.multiply
public Color multiply(Color c) { return new Color(r * c.r, g * c.g, b * c.b, a * c.a); }
java
public Color multiply(Color c) { return new Color(r * c.r, g * c.g, b * c.b, a * c.a); }
[ "public", "Color", "multiply", "(", "Color", "c", ")", "{", "return", "new", "Color", "(", "r", "*", "c", ".", "r", ",", "g", "*", "c", ".", "g", ",", "b", "*", "c", ".", "b", ",", "a", "*", "c", ".", "a", ")", ";", "}" ]
Multiply this color by another @param c the other color @return product of the two colors
[ "Multiply", "this", "color", "by", "another" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Color.java#L333-L335
1,555
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/gui/AbstractComponent.java
AbstractComponent.notifyListeners
protected void notifyListeners() { Iterator it = listeners.iterator(); while (it.hasNext()) { ((ComponentListener) it.next()).componentActivated(this); } }
java
protected void notifyListeners() { Iterator it = listeners.iterator(); while (it.hasNext()) { ((ComponentListener) it.next()).componentActivated(this); } }
[ "protected", "void", "notifyListeners", "(", ")", "{", "Iterator", "it", "=", "listeners", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "(", "(", "ComponentListener", ")", "it", ".", "next", "(", ")", ")", ".", "componentActivated", "(", "this", ")", ";", "}", "}" ]
Notify all the listeners.
[ "Notify", "all", "the", "listeners", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/gui/AbstractComponent.java#L79-L84
1,556
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/gui/AbstractComponent.java
AbstractComponent.setFocus
public void setFocus(boolean focus) { if (focus) { if (currentFocus != null) { currentFocus.setFocus(false); } currentFocus = this; } else { if (currentFocus == this) { currentFocus = null; } } this.focus = focus; }
java
public void setFocus(boolean focus) { if (focus) { if (currentFocus != null) { currentFocus.setFocus(false); } currentFocus = this; } else { if (currentFocus == this) { currentFocus = null; } } this.focus = focus; }
[ "public", "void", "setFocus", "(", "boolean", "focus", ")", "{", "if", "(", "focus", ")", "{", "if", "(", "currentFocus", "!=", "null", ")", "{", "currentFocus", ".", "setFocus", "(", "false", ")", ";", "}", "currentFocus", "=", "this", ";", "}", "else", "{", "if", "(", "currentFocus", "==", "this", ")", "{", "currentFocus", "=", "null", ";", "}", "}", "this", ".", "focus", "=", "focus", ";", "}" ]
Indicate whether this component should be focused or not @param focus if the component should be focused
[ "Indicate", "whether", "this", "component", "should", "be", "focused", "or", "not" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/gui/AbstractComponent.java#L143-L155
1,557
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/gui/AbstractComponent.java
AbstractComponent.mouseReleased
public void mouseReleased(int button, int x, int y) { setFocus(Rectangle.contains(x, y, getX(), getY(), getWidth(), getHeight())); }
java
public void mouseReleased(int button, int x, int y) { setFocus(Rectangle.contains(x, y, getX(), getY(), getWidth(), getHeight())); }
[ "public", "void", "mouseReleased", "(", "int", "button", ",", "int", "x", ",", "int", "y", ")", "{", "setFocus", "(", "Rectangle", ".", "contains", "(", "x", ",", "y", ",", "getX", "(", ")", ",", "getY", "(", ")", ",", "getWidth", "(", ")", ",", "getHeight", "(", ")", ")", ")", ";", "}" ]
Gives the focus to this component with a click of the mouse. @see org.newdawn.slick.gui.AbstractComponent#mouseReleased(int, int, int)
[ "Gives", "the", "focus", "to", "this", "component", "with", "a", "click", "of", "the", "mouse", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/gui/AbstractComponent.java#L178-L181
1,558
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
SoundStore.setMusicOn
public void setMusicOn(boolean music) { if (soundWorks) { this.music = music; if (music) { restartLoop(); setMusicVolume(musicVolume); } else { pauseLoop(); } } }
java
public void setMusicOn(boolean music) { if (soundWorks) { this.music = music; if (music) { restartLoop(); setMusicVolume(musicVolume); } else { pauseLoop(); } } }
[ "public", "void", "setMusicOn", "(", "boolean", "music", ")", "{", "if", "(", "soundWorks", ")", "{", "this", ".", "music", "=", "music", ";", "if", "(", "music", ")", "{", "restartLoop", "(", ")", ";", "setMusicVolume", "(", "musicVolume", ")", ";", "}", "else", "{", "pauseLoop", "(", ")", ";", "}", "}", "}" ]
Inidicate whether music should be playing @param music True if music should be played
[ "Inidicate", "whether", "music", "should", "be", "playing" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L119-L129
1,559
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
SoundStore.setCurrentMusicVolume
public void setCurrentMusicVolume(float volume) { if (volume < 0) { volume = 0; } if (volume > 1) { volume = 1; } if (soundWorks) { lastCurrentMusicVolume = volume; AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume); } }
java
public void setCurrentMusicVolume(float volume) { if (volume < 0) { volume = 0; } if (volume > 1) { volume = 1; } if (soundWorks) { lastCurrentMusicVolume = volume; AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume); } }
[ "public", "void", "setCurrentMusicVolume", "(", "float", "volume", ")", "{", "if", "(", "volume", "<", "0", ")", "{", "volume", "=", "0", ";", "}", "if", "(", "volume", ">", "1", ")", "{", "volume", "=", "1", ";", "}", "if", "(", "soundWorks", ")", "{", "lastCurrentMusicVolume", "=", "volume", ";", "AL10", ".", "alSourcef", "(", "sources", ".", "get", "(", "0", ")", ",", "AL10", ".", "AL_GAIN", ",", "lastCurrentMusicVolume", "*", "musicVolume", ")", ";", "}", "}" ]
Set the music volume of the current playing music. Does NOT affect the global volume @param volume The volume for the current playing music
[ "Set", "the", "music", "volume", "of", "the", "current", "playing", "music", ".", "Does", "NOT", "affect", "the", "global", "volume" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L173-L185
1,560
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
SoundStore.init
public void init() { if (inited) { return; } Log.info("Initialising sounds.."); inited = true; AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { AL.create(); soundWorks = true; sounds = true; music = true; Log.info("- Sound works"); } catch (Exception e) { Log.error("Sound initialisation failure."); Log.error(e); soundWorks = false; sounds = false; music = false; } return null; }}); if (soundWorks) { sourceCount = 0; sources = BufferUtils.createIntBuffer(maxSources); while (AL10.alGetError() == AL10.AL_NO_ERROR) { IntBuffer temp = BufferUtils.createIntBuffer(1); try { AL10.alGenSources(temp); if (AL10.alGetError() == AL10.AL_NO_ERROR) { sourceCount++; sources.put(temp.get(0)); if (sourceCount > maxSources-1) { break; } } } catch (OpenALException e) { // expected at the end break; } } Log.info("- "+sourceCount+" OpenAL source available"); if (AL10.alGetError() != AL10.AL_NO_ERROR) { sounds = false; music = false; soundWorks = false; Log.error("- AL init failed"); } else { FloatBuffer listenerOri = BufferUtils.createFloatBuffer(6).put( new float[] { 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f }); FloatBuffer listenerVel = BufferUtils.createFloatBuffer(3).put( new float[] { 0.0f, 0.0f, 0.0f }); FloatBuffer listenerPos = BufferUtils.createFloatBuffer(3).put( new float[] { 0.0f, 0.0f, 0.0f }); listenerPos.flip(); listenerVel.flip(); listenerOri.flip(); AL10.alListener(AL10.AL_POSITION, listenerPos); AL10.alListener(AL10.AL_VELOCITY, listenerVel); AL10.alListener(AL10.AL_ORIENTATION, listenerOri); Log.info("- Sounds source generated"); } } }
java
public void init() { if (inited) { return; } Log.info("Initialising sounds.."); inited = true; AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { AL.create(); soundWorks = true; sounds = true; music = true; Log.info("- Sound works"); } catch (Exception e) { Log.error("Sound initialisation failure."); Log.error(e); soundWorks = false; sounds = false; music = false; } return null; }}); if (soundWorks) { sourceCount = 0; sources = BufferUtils.createIntBuffer(maxSources); while (AL10.alGetError() == AL10.AL_NO_ERROR) { IntBuffer temp = BufferUtils.createIntBuffer(1); try { AL10.alGenSources(temp); if (AL10.alGetError() == AL10.AL_NO_ERROR) { sourceCount++; sources.put(temp.get(0)); if (sourceCount > maxSources-1) { break; } } } catch (OpenALException e) { // expected at the end break; } } Log.info("- "+sourceCount+" OpenAL source available"); if (AL10.alGetError() != AL10.AL_NO_ERROR) { sounds = false; music = false; soundWorks = false; Log.error("- AL init failed"); } else { FloatBuffer listenerOri = BufferUtils.createFloatBuffer(6).put( new float[] { 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f }); FloatBuffer listenerVel = BufferUtils.createFloatBuffer(3).put( new float[] { 0.0f, 0.0f, 0.0f }); FloatBuffer listenerPos = BufferUtils.createFloatBuffer(3).put( new float[] { 0.0f, 0.0f, 0.0f }); listenerPos.flip(); listenerVel.flip(); listenerOri.flip(); AL10.alListener(AL10.AL_POSITION, listenerPos); AL10.alListener(AL10.AL_VELOCITY, listenerVel); AL10.alListener(AL10.AL_ORIENTATION, listenerOri); Log.info("- Sounds source generated"); } } }
[ "public", "void", "init", "(", ")", "{", "if", "(", "inited", ")", "{", "return", ";", "}", "Log", ".", "info", "(", "\"Initialising sounds..\"", ")", ";", "inited", "=", "true", ";", "AccessController", ".", "doPrivileged", "(", "new", "PrivilegedAction", "(", ")", "{", "public", "Object", "run", "(", ")", "{", "try", "{", "AL", ".", "create", "(", ")", ";", "soundWorks", "=", "true", ";", "sounds", "=", "true", ";", "music", "=", "true", ";", "Log", ".", "info", "(", "\"- Sound works\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Log", ".", "error", "(", "\"Sound initialisation failure.\"", ")", ";", "Log", ".", "error", "(", "e", ")", ";", "soundWorks", "=", "false", ";", "sounds", "=", "false", ";", "music", "=", "false", ";", "}", "return", "null", ";", "}", "}", ")", ";", "if", "(", "soundWorks", ")", "{", "sourceCount", "=", "0", ";", "sources", "=", "BufferUtils", ".", "createIntBuffer", "(", "maxSources", ")", ";", "while", "(", "AL10", ".", "alGetError", "(", ")", "==", "AL10", ".", "AL_NO_ERROR", ")", "{", "IntBuffer", "temp", "=", "BufferUtils", ".", "createIntBuffer", "(", "1", ")", ";", "try", "{", "AL10", ".", "alGenSources", "(", "temp", ")", ";", "if", "(", "AL10", ".", "alGetError", "(", ")", "==", "AL10", ".", "AL_NO_ERROR", ")", "{", "sourceCount", "++", ";", "sources", ".", "put", "(", "temp", ".", "get", "(", "0", ")", ")", ";", "if", "(", "sourceCount", ">", "maxSources", "-", "1", ")", "{", "break", ";", "}", "}", "}", "catch", "(", "OpenALException", "e", ")", "{", "// expected at the end\r", "break", ";", "}", "}", "Log", ".", "info", "(", "\"- \"", "+", "sourceCount", "+", "\" OpenAL source available\"", ")", ";", "if", "(", "AL10", ".", "alGetError", "(", ")", "!=", "AL10", ".", "AL_NO_ERROR", ")", "{", "sounds", "=", "false", ";", "music", "=", "false", ";", "soundWorks", "=", "false", ";", "Log", ".", "error", "(", "\"- AL init failed\"", ")", ";", "}", "else", "{", "FloatBuffer", "listenerOri", "=", "BufferUtils", ".", "createFloatBuffer", "(", "6", ")", ".", "put", "(", "new", "float", "[", "]", "{", "0.0f", ",", "0.0f", ",", "-", "1.0f", ",", "0.0f", ",", "1.0f", ",", "0.0f", "}", ")", ";", "FloatBuffer", "listenerVel", "=", "BufferUtils", ".", "createFloatBuffer", "(", "3", ")", ".", "put", "(", "new", "float", "[", "]", "{", "0.0f", ",", "0.0f", ",", "0.0f", "}", ")", ";", "FloatBuffer", "listenerPos", "=", "BufferUtils", ".", "createFloatBuffer", "(", "3", ")", ".", "put", "(", "new", "float", "[", "]", "{", "0.0f", ",", "0.0f", ",", "0.0f", "}", ")", ";", "listenerPos", ".", "flip", "(", ")", ";", "listenerVel", ".", "flip", "(", ")", ";", "listenerOri", ".", "flip", "(", ")", ";", "AL10", ".", "alListener", "(", "AL10", ".", "AL_POSITION", ",", "listenerPos", ")", ";", "AL10", ".", "alListener", "(", "AL10", ".", "AL_VELOCITY", ",", "listenerVel", ")", ";", "AL10", ".", "alListener", "(", "AL10", ".", "AL_ORIENTATION", ",", "listenerOri", ")", ";", "Log", ".", "info", "(", "\"- Sounds source generated\"", ")", ";", "}", "}", "}" ]
Initialise the sound effects stored. This must be called before anything else will work
[ "Initialise", "the", "sound", "effects", "stored", ".", "This", "must", "be", "called", "before", "anything", "else", "will", "work" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L285-L356
1,561
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
SoundStore.isPlaying
boolean isPlaying(int index) { int state = AL10.alGetSourcei(sources.get(index), AL10.AL_SOURCE_STATE); return (state == AL10.AL_PLAYING); }
java
boolean isPlaying(int index) { int state = AL10.alGetSourcei(sources.get(index), AL10.AL_SOURCE_STATE); return (state == AL10.AL_PLAYING); }
[ "boolean", "isPlaying", "(", "int", "index", ")", "{", "int", "state", "=", "AL10", ".", "alGetSourcei", "(", "sources", ".", "get", "(", "index", ")", ",", "AL10", ".", "AL_SOURCE_STATE", ")", ";", "return", "(", "state", "==", "AL10", ".", "AL_PLAYING", ")", ";", "}" ]
Check if a particular source is playing @param index The index of the source to check @return True if the source is playing
[ "Check", "if", "a", "particular", "source", "is", "playing" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L436-L440
1,562
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
SoundStore.findFreeSource
private int findFreeSource() { for (int i=1;i<sourceCount-1;i++) { int state = AL10.alGetSourcei(sources.get(i), AL10.AL_SOURCE_STATE); if ((state != AL10.AL_PLAYING) && (state != AL10.AL_PAUSED)) { return i; } } return -1; }
java
private int findFreeSource() { for (int i=1;i<sourceCount-1;i++) { int state = AL10.alGetSourcei(sources.get(i), AL10.AL_SOURCE_STATE); if ((state != AL10.AL_PLAYING) && (state != AL10.AL_PAUSED)) { return i; } } return -1; }
[ "private", "int", "findFreeSource", "(", ")", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<", "sourceCount", "-", "1", ";", "i", "++", ")", "{", "int", "state", "=", "AL10", ".", "alGetSourcei", "(", "sources", ".", "get", "(", "i", ")", ",", "AL10", ".", "AL_SOURCE_STATE", ")", ";", "if", "(", "(", "state", "!=", "AL10", ".", "AL_PLAYING", ")", "&&", "(", "state", "!=", "AL10", ".", "AL_PAUSED", ")", ")", "{", "return", "i", ";", "}", "}", "return", "-", "1", ";", "}" ]
Find a free sound source @return The index of the free sound source
[ "Find", "a", "free", "sound", "source" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L447-L457
1,563
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
SoundStore.setMusicPitch
public void setMusicPitch(float pitch) { if (soundWorks) { AL10.alSourcef(sources.get(0), AL10.AL_PITCH, pitch); } }
java
public void setMusicPitch(float pitch) { if (soundWorks) { AL10.alSourcef(sources.get(0), AL10.AL_PITCH, pitch); } }
[ "public", "void", "setMusicPitch", "(", "float", "pitch", ")", "{", "if", "(", "soundWorks", ")", "{", "AL10", ".", "alSourcef", "(", "sources", ".", "get", "(", "0", ")", ",", "AL10", ".", "AL_PITCH", ",", "pitch", ")", ";", "}", "}" ]
Set the pitch at which the current music is being played @param pitch The pitch at which the current music is being played
[ "Set", "the", "pitch", "at", "which", "the", "current", "music", "is", "being", "played" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L507-L511
1,564
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
SoundStore.getWAV
public Audio getWAV(String ref) throws IOException { return getWAV(ref, ResourceLoader.getResourceAsStream(ref)); }
java
public Audio getWAV(String ref) throws IOException { return getWAV(ref, ResourceLoader.getResourceAsStream(ref)); }
[ "public", "Audio", "getWAV", "(", "String", "ref", ")", "throws", "IOException", "{", "return", "getWAV", "(", "ref", ",", "ResourceLoader", ".", "getResourceAsStream", "(", "ref", ")", ")", ";", "}" ]
Get the Sound based on a specified WAV file @param ref The reference to the WAV file in the classpath @return The Sound read from the WAV file @throws IOException Indicates a failure to load the WAV
[ "Get", "the", "Sound", "based", "on", "a", "specified", "WAV", "file" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L671-L673
1,565
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
SoundStore.setMOD
void setMOD(MODSound sound) { if (!soundWorks) { return; } currentMusic = sources.get(0); stopSource(0); this.mod = sound; if (sound != null) { this.stream = null; } paused = false; }
java
void setMOD(MODSound sound) { if (!soundWorks) { return; } currentMusic = sources.get(0); stopSource(0); this.mod = sound; if (sound != null) { this.stream = null; } paused = false; }
[ "void", "setMOD", "(", "MODSound", "sound", ")", "{", "if", "(", "!", "soundWorks", ")", "{", "return", ";", "}", "currentMusic", "=", "sources", ".", "get", "(", "0", ")", ";", "stopSource", "(", "0", ")", ";", "this", ".", "mod", "=", "sound", ";", "if", "(", "sound", "!=", "null", ")", "{", "this", ".", "stream", "=", "null", ";", "}", "paused", "=", "false", ";", "}" ]
Set the mod thats being streamed if any @param sound The mod being streamed
[ "Set", "the", "mod", "thats", "being", "streamed", "if", "any" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L862-L875
1,566
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
SoundStore.setStream
void setStream(OpenALStreamPlayer stream) { if (!soundWorks) { return; } currentMusic = sources.get(0); this.stream = stream; if (stream != null) { this.mod = null; } paused = false; }
java
void setStream(OpenALStreamPlayer stream) { if (!soundWorks) { return; } currentMusic = sources.get(0); this.stream = stream; if (stream != null) { this.mod = null; } paused = false; }
[ "void", "setStream", "(", "OpenALStreamPlayer", "stream", ")", "{", "if", "(", "!", "soundWorks", ")", "{", "return", ";", "}", "currentMusic", "=", "sources", ".", "get", "(", "0", ")", ";", "this", ".", "stream", "=", "stream", ";", "if", "(", "stream", "!=", "null", ")", "{", "this", ".", "mod", "=", "null", ";", "}", "paused", "=", "false", ";", "}" ]
Set the stream being played @param stream The stream being streamed
[ "Set", "the", "stream", "being", "played" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L882-L893
1,567
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
SoundStore.poll
public void poll(int delta) { if (!soundWorks) { return; } if (paused) { return; } if (music) { if (mod != null) { try { mod.poll(); } catch (OpenALException e) { Log.error("Error with OpenGL MOD Player on this this platform"); Log.error(e); mod = null; } } if (stream != null) { try { stream.update(); } catch (OpenALException e) { Log.error("Error with OpenGL Streaming Player on this this platform"); Log.error(e); mod = null; } } } }
java
public void poll(int delta) { if (!soundWorks) { return; } if (paused) { return; } if (music) { if (mod != null) { try { mod.poll(); } catch (OpenALException e) { Log.error("Error with OpenGL MOD Player on this this platform"); Log.error(e); mod = null; } } if (stream != null) { try { stream.update(); } catch (OpenALException e) { Log.error("Error with OpenGL Streaming Player on this this platform"); Log.error(e); mod = null; } } } }
[ "public", "void", "poll", "(", "int", "delta", ")", "{", "if", "(", "!", "soundWorks", ")", "{", "return", ";", "}", "if", "(", "paused", ")", "{", "return", ";", "}", "if", "(", "music", ")", "{", "if", "(", "mod", "!=", "null", ")", "{", "try", "{", "mod", ".", "poll", "(", ")", ";", "}", "catch", "(", "OpenALException", "e", ")", "{", "Log", ".", "error", "(", "\"Error with OpenGL MOD Player on this this platform\"", ")", ";", "Log", ".", "error", "(", "e", ")", ";", "mod", "=", "null", ";", "}", "}", "if", "(", "stream", "!=", "null", ")", "{", "try", "{", "stream", ".", "update", "(", ")", ";", "}", "catch", "(", "OpenALException", "e", ")", "{", "Log", ".", "error", "(", "\"Error with OpenGL Streaming Player on this this platform\"", ")", ";", "Log", ".", "error", "(", "e", ")", ";", "mod", "=", "null", ";", "}", "}", "}", "}" ]
Poll the streaming system @param delta The amount of time passed since last poll (in milliseconds)
[ "Poll", "the", "streaming", "system" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L900-L928
1,568
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java
SoundStore.isMusicPlaying
public boolean isMusicPlaying() { if (!soundWorks) { return false; } int state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE); return ((state == AL10.AL_PLAYING) || (state == AL10.AL_PAUSED)); }
java
public boolean isMusicPlaying() { if (!soundWorks) { return false; } int state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE); return ((state == AL10.AL_PLAYING) || (state == AL10.AL_PAUSED)); }
[ "public", "boolean", "isMusicPlaying", "(", ")", "{", "if", "(", "!", "soundWorks", ")", "{", "return", "false", ";", "}", "int", "state", "=", "AL10", ".", "alGetSourcei", "(", "sources", ".", "get", "(", "0", ")", ",", "AL10", ".", "AL_SOURCE_STATE", ")", ";", "return", "(", "(", "state", "==", "AL10", ".", "AL_PLAYING", ")", "||", "(", "state", "==", "AL10", ".", "AL_PAUSED", ")", ")", ";", "}" ]
Check if the music is currently playing @return True if the music is playing
[ "Check", "if", "the", "music", "is", "currently", "playing" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/openal/SoundStore.java#L935-L943
1,569
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java
ControlPanel.addValue
protected void addValue(String name, ValuePanel valuePanel) { named.put(name, valuePanel); valuePanel.setBounds(0,10+yPos,280,63); valuePanel.addListener(this); add(valuePanel); yPos+=63; }
java
protected void addValue(String name, ValuePanel valuePanel) { named.put(name, valuePanel); valuePanel.setBounds(0,10+yPos,280,63); valuePanel.addListener(this); add(valuePanel); yPos+=63; }
[ "protected", "void", "addValue", "(", "String", "name", ",", "ValuePanel", "valuePanel", ")", "{", "named", ".", "put", "(", "name", ",", "valuePanel", ")", ";", "valuePanel", ".", "setBounds", "(", "0", ",", "10", "+", "yPos", ",", "280", ",", "63", ")", ";", "valuePanel", ".", "addListener", "(", "this", ")", ";", "add", "(", "valuePanel", ")", ";", "yPos", "+=", "63", ";", "}" ]
Add a configurable value to the mapping table @param name The name of the control @param valuePanel The panel used to set the value in the emitter
[ "Add", "a", "configurable", "value", "to", "the", "mapping", "table" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java#L41-L49
1,570
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java
ControlPanel.addMinMax
protected void addMinMax(String name, MinMaxPanel minMax) { named.put(name, minMax); minMax.setBounds(0,10+yPos,280,minMax.getOffset()); minMax.addListener(this); add(minMax); yPos+=minMax.getOffset(); }
java
protected void addMinMax(String name, MinMaxPanel minMax) { named.put(name, minMax); minMax.setBounds(0,10+yPos,280,minMax.getOffset()); minMax.addListener(this); add(minMax); yPos+=minMax.getOffset(); }
[ "protected", "void", "addMinMax", "(", "String", "name", ",", "MinMaxPanel", "minMax", ")", "{", "named", ".", "put", "(", "name", ",", "minMax", ")", ";", "minMax", ".", "setBounds", "(", "0", ",", "10", "+", "yPos", ",", "280", ",", "minMax", ".", "getOffset", "(", ")", ")", ";", "minMax", ".", "addListener", "(", "this", ")", ";", "add", "(", "minMax", ")", ";", "yPos", "+=", "minMax", ".", "getOffset", "(", ")", ";", "}" ]
Add a configurable range panel to the mapping table @param name The name of the control @param minMax The panel used to set the range in the emitter
[ "Add", "a", "configurable", "range", "panel", "to", "the", "mapping", "table" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java#L57-L65
1,571
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java
ControlPanel.link
protected void link(Range range, String name) { link(range, (MinMaxPanel) named.get(name)); }
java
protected void link(Range range, String name) { link(range, (MinMaxPanel) named.get(name)); }
[ "protected", "void", "link", "(", "Range", "range", ",", "String", "name", ")", "{", "link", "(", "range", ",", "(", "MinMaxPanel", ")", "named", ".", "get", "(", "name", ")", ")", ";", "}" ]
Link a emitter configurable range to a named component @param range The configurable range from the emitter @param name The name of the component to link to
[ "Link", "a", "emitter", "configurable", "range", "to", "a", "named", "component" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java#L91-L93
1,572
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java
ControlPanel.link
protected void link(Value value, String name) { link(value, (ValuePanel) named.get(name)); }
java
protected void link(Value value, String name) { link(value, (ValuePanel) named.get(name)); }
[ "protected", "void", "link", "(", "Value", "value", ",", "String", "name", ")", "{", "link", "(", "value", ",", "(", "ValuePanel", ")", "named", ".", "get", "(", "name", ")", ")", ";", "}" ]
Link a emitter configurable value to a named component @param value The configurable value from the emitter @param name The name of the component to link to
[ "Link", "a", "emitter", "configurable", "value", "to", "a", "named", "component" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java#L101-L103
1,573
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java
ControlPanel.link
private void link(Value value, ValuePanel panel) { controlToData.put(panel, value); if( value instanceof SimpleValue ) panel.setValue((int) ((SimpleValue)value).getValue( 0 )); else if( value instanceof RandomValue ) panel.setValue((int) ((RandomValue)value).getValue()); }
java
private void link(Value value, ValuePanel panel) { controlToData.put(panel, value); if( value instanceof SimpleValue ) panel.setValue((int) ((SimpleValue)value).getValue( 0 )); else if( value instanceof RandomValue ) panel.setValue((int) ((RandomValue)value).getValue()); }
[ "private", "void", "link", "(", "Value", "value", ",", "ValuePanel", "panel", ")", "{", "controlToData", ".", "put", "(", "panel", ",", "value", ")", ";", "if", "(", "value", "instanceof", "SimpleValue", ")", "panel", ".", "setValue", "(", "(", "int", ")", "(", "(", "SimpleValue", ")", "value", ")", ".", "getValue", "(", "0", ")", ")", ";", "else", "if", "(", "value", "instanceof", "RandomValue", ")", "panel", ".", "setValue", "(", "(", "int", ")", "(", "(", "RandomValue", ")", "value", ")", ".", "getValue", "(", ")", ")", ";", "}" ]
Link a emitter configurable value to a value panel @param value The configurable value from the emitter @param panel The component to link against
[ "Link", "a", "emitter", "configurable", "value", "to", "a", "value", "panel" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java#L111-L118
1,574
nguillaumin/slick2d-maven
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java
ControlPanel.link
private void link(Range range, MinMaxPanel panel) { controlToData.put(panel, range); panel.setMax((int) range.getMax()); panel.setMin((int) range.getMin()); panel.setEnabledValue(range.isEnabled()); }
java
private void link(Range range, MinMaxPanel panel) { controlToData.put(panel, range); panel.setMax((int) range.getMax()); panel.setMin((int) range.getMin()); panel.setEnabledValue(range.isEnabled()); }
[ "private", "void", "link", "(", "Range", "range", ",", "MinMaxPanel", "panel", ")", "{", "controlToData", ".", "put", "(", "panel", ",", "range", ")", ";", "panel", ".", "setMax", "(", "(", "int", ")", "range", ".", "getMax", "(", ")", ")", ";", "panel", ".", "setMin", "(", "(", "int", ")", "range", ".", "getMin", "(", ")", ")", ";", "panel", ".", "setEnabledValue", "(", "range", ".", "isEnabled", "(", ")", ")", ";", "}" ]
Link a emitter configurable range to a value panel @param range The configurable range from the emitter @param panel The component to link against
[ "Link", "a", "emitter", "configurable", "range", "to", "a", "value", "panel" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/ControlPanel.java#L126-L131
1,575
nguillaumin/slick2d-maven
slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/ImageScale3x.java
ImageScale3x.getScaledImage
public BufferedImage getScaledImage() { RawScale3x scaler = new RawScale3x(srcData,width,height); BufferedImage image = new BufferedImage(width*3,height*3,BufferedImage.TYPE_INT_ARGB); image.setRGB(0,0,width*3,height*3,scaler.getScaledData(),0,width*3); return image; }
java
public BufferedImage getScaledImage() { RawScale3x scaler = new RawScale3x(srcData,width,height); BufferedImage image = new BufferedImage(width*3,height*3,BufferedImage.TYPE_INT_ARGB); image.setRGB(0,0,width*3,height*3,scaler.getScaledData(),0,width*3); return image; }
[ "public", "BufferedImage", "getScaledImage", "(", ")", "{", "RawScale3x", "scaler", "=", "new", "RawScale3x", "(", "srcData", ",", "width", ",", "height", ")", ";", "BufferedImage", "image", "=", "new", "BufferedImage", "(", "width", "*", "3", ",", "height", "*", "3", ",", "BufferedImage", ".", "TYPE_INT_ARGB", ")", ";", "image", ".", "setRGB", "(", "0", ",", "0", ",", "width", "*", "3", ",", "height", "*", "3", ",", "scaler", ".", "getScaledData", "(", ")", ",", "0", ",", "width", "*", "3", ")", ";", "return", "image", ";", "}" ]
Retrieve the scaled image. Note this is the method that actually does the work so it may take some time to return @return The newly scaled image
[ "Retrieve", "the", "scaled", "image", ".", "Note", "this", "is", "the", "method", "that", "actually", "does", "the", "work", "so", "it", "may", "take", "some", "time", "to", "return" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/ImageScale3x.java#L42-L50
1,576
nguillaumin/slick2d-maven
slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/ImageScale3x.java
ImageScale3x.main
public static void main(String argv[]) { String srcFile = "randam_orig.png"; try { System.out.println("Reading: "+srcFile); BufferedImage src = ImageIO.read(new File(srcFile)); ImageScale3x scaler = new ImageScale3x(src); BufferedImage out = scaler.getScaledImage(); String outFile = srcFile.substring(0,srcFile.length()-4); outFile += "3x"; outFile += ".png"; System.out.println("Writing: "+outFile); ImageIO.write(out,"PNG",new File(outFile)); } catch (Exception e) { e.printStackTrace(); } }
java
public static void main(String argv[]) { String srcFile = "randam_orig.png"; try { System.out.println("Reading: "+srcFile); BufferedImage src = ImageIO.read(new File(srcFile)); ImageScale3x scaler = new ImageScale3x(src); BufferedImage out = scaler.getScaledImage(); String outFile = srcFile.substring(0,srcFile.length()-4); outFile += "3x"; outFile += ".png"; System.out.println("Writing: "+outFile); ImageIO.write(out,"PNG",new File(outFile)); } catch (Exception e) { e.printStackTrace(); } }
[ "public", "static", "void", "main", "(", "String", "argv", "[", "]", ")", "{", "String", "srcFile", "=", "\"randam_orig.png\"", ";", "try", "{", "System", ".", "out", ".", "println", "(", "\"Reading: \"", "+", "srcFile", ")", ";", "BufferedImage", "src", "=", "ImageIO", ".", "read", "(", "new", "File", "(", "srcFile", ")", ")", ";", "ImageScale3x", "scaler", "=", "new", "ImageScale3x", "(", "src", ")", ";", "BufferedImage", "out", "=", "scaler", ".", "getScaledImage", "(", ")", ";", "String", "outFile", "=", "srcFile", ".", "substring", "(", "0", ",", "srcFile", ".", "length", "(", ")", "-", "4", ")", ";", "outFile", "+=", "\"3x\"", ";", "outFile", "+=", "\".png\"", ";", "System", ".", "out", ".", "println", "(", "\"Writing: \"", "+", "outFile", ")", ";", "ImageIO", ".", "write", "(", "out", ",", "\"PNG\"", ",", "new", "File", "(", "outFile", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
An entry point and a bit of test code @param argv The arguments passed in to the test code
[ "An", "entry", "point", "and", "a", "bit", "of", "test", "code" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/ImageScale3x.java#L57-L77
1,577
nguillaumin/slick2d-maven
slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/distancemap/DistanceFieldFilter.java
DistanceFieldFilter.findSignedDistance
private static float findSignedDistance(final int pointX, final int pointY, BufferedImage inImage, final int scanWidth, final int scanHeight) { Color baseColour = new Color(inImage.getRGB(pointX, pointY) ); final boolean baseIsSolid = baseColour.getRed() > 0; float closestDistance = Float.MAX_VALUE; boolean closestValid = false; final int startX = pointX - (scanWidth / 2); final int endX = startX + scanWidth; final int startY = pointY - (scanHeight / 2); final int endY = startY + scanHeight; for (int x=startX; x<endX; x++) { if (x < 0 || x >= inImage.getWidth()) continue; for (int y=startY; y<endY; y++) { if (y < 0 || y >= inImage.getWidth()) continue; Color c = new Color(inImage.getRGB(x, y)); if (baseIsSolid) { if (c.getRed() == 0) { final float dist = separation(pointX, pointY, x, y); if (dist < closestDistance) { closestDistance = dist; closestValid = true; } } } else { if (c.getRed() > 0) { final float dist = separation(pointX, pointY, x, y); if (dist < closestDistance) { closestDistance = dist; closestValid = true; } } } } } if (baseIsSolid) { if (closestValid) return closestDistance; else return Float.MAX_VALUE; } else { if (closestValid) return -closestDistance; else return Float.MIN_VALUE; } }
java
private static float findSignedDistance(final int pointX, final int pointY, BufferedImage inImage, final int scanWidth, final int scanHeight) { Color baseColour = new Color(inImage.getRGB(pointX, pointY) ); final boolean baseIsSolid = baseColour.getRed() > 0; float closestDistance = Float.MAX_VALUE; boolean closestValid = false; final int startX = pointX - (scanWidth / 2); final int endX = startX + scanWidth; final int startY = pointY - (scanHeight / 2); final int endY = startY + scanHeight; for (int x=startX; x<endX; x++) { if (x < 0 || x >= inImage.getWidth()) continue; for (int y=startY; y<endY; y++) { if (y < 0 || y >= inImage.getWidth()) continue; Color c = new Color(inImage.getRGB(x, y)); if (baseIsSolid) { if (c.getRed() == 0) { final float dist = separation(pointX, pointY, x, y); if (dist < closestDistance) { closestDistance = dist; closestValid = true; } } } else { if (c.getRed() > 0) { final float dist = separation(pointX, pointY, x, y); if (dist < closestDistance) { closestDistance = dist; closestValid = true; } } } } } if (baseIsSolid) { if (closestValid) return closestDistance; else return Float.MAX_VALUE; } else { if (closestValid) return -closestDistance; else return Float.MIN_VALUE; } }
[ "private", "static", "float", "findSignedDistance", "(", "final", "int", "pointX", ",", "final", "int", "pointY", ",", "BufferedImage", "inImage", ",", "final", "int", "scanWidth", ",", "final", "int", "scanHeight", ")", "{", "Color", "baseColour", "=", "new", "Color", "(", "inImage", ".", "getRGB", "(", "pointX", ",", "pointY", ")", ")", ";", "final", "boolean", "baseIsSolid", "=", "baseColour", ".", "getRed", "(", ")", ">", "0", ";", "float", "closestDistance", "=", "Float", ".", "MAX_VALUE", ";", "boolean", "closestValid", "=", "false", ";", "final", "int", "startX", "=", "pointX", "-", "(", "scanWidth", "/", "2", ")", ";", "final", "int", "endX", "=", "startX", "+", "scanWidth", ";", "final", "int", "startY", "=", "pointY", "-", "(", "scanHeight", "/", "2", ")", ";", "final", "int", "endY", "=", "startY", "+", "scanHeight", ";", "for", "(", "int", "x", "=", "startX", ";", "x", "<", "endX", ";", "x", "++", ")", "{", "if", "(", "x", "<", "0", "||", "x", ">=", "inImage", ".", "getWidth", "(", ")", ")", "continue", ";", "for", "(", "int", "y", "=", "startY", ";", "y", "<", "endY", ";", "y", "++", ")", "{", "if", "(", "y", "<", "0", "||", "y", ">=", "inImage", ".", "getWidth", "(", ")", ")", "continue", ";", "Color", "c", "=", "new", "Color", "(", "inImage", ".", "getRGB", "(", "x", ",", "y", ")", ")", ";", "if", "(", "baseIsSolid", ")", "{", "if", "(", "c", ".", "getRed", "(", ")", "==", "0", ")", "{", "final", "float", "dist", "=", "separation", "(", "pointX", ",", "pointY", ",", "x", ",", "y", ")", ";", "if", "(", "dist", "<", "closestDistance", ")", "{", "closestDistance", "=", "dist", ";", "closestValid", "=", "true", ";", "}", "}", "}", "else", "{", "if", "(", "c", ".", "getRed", "(", ")", ">", "0", ")", "{", "final", "float", "dist", "=", "separation", "(", "pointX", ",", "pointY", ",", "x", ",", "y", ")", ";", "if", "(", "dist", "<", "closestDistance", ")", "{", "closestDistance", "=", "dist", ";", "closestValid", "=", "true", ";", "}", "}", "}", "}", "}", "if", "(", "baseIsSolid", ")", "{", "if", "(", "closestValid", ")", "return", "closestDistance", ";", "else", "return", "Float", ".", "MAX_VALUE", ";", "}", "else", "{", "if", "(", "closestValid", ")", "return", "-", "closestDistance", ";", "else", "return", "Float", ".", "MIN_VALUE", ";", "}", "}" ]
Find the signed distance for a given point @param pointX The x coordinate of the point @param pointY The y coordinate of the point @param inImage The image on which the point exists @param scanWidth The scan line of the image @param scanHeight The scan height of the image @return The signed distance
[ "Find", "the", "signed", "distance", "for", "a", "given", "point" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/distancemap/DistanceFieldFilter.java#L158-L224
1,578
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/font/HieroSettings.java
HieroSettings.save
public void save(File file) throws IOException { PrintStream out = new PrintStream(new FileOutputStream(file)); out.println("font.size=" + fontSize); out.println("font.bold=" + bold); out.println("font.italic=" + italic); out.println(); out.println("pad.top=" + paddingTop); out.println("pad.right=" + paddingRight); out.println("pad.bottom=" + paddingBottom); out.println("pad.left=" + paddingLeft); out.println("pad.advance.x=" + paddingAdvanceX); out.println("pad.advance.y=" + paddingAdvanceY); out.println(); out.println("glyph.page.width=" + glyphPageWidth); out.println("glyph.page.height=" + glyphPageHeight); out.println(); for (Iterator iter = effects.iterator(); iter.hasNext();) { ConfigurableEffect effect = (ConfigurableEffect)iter.next(); out.println("effect.class=" + effect.getClass().getName()); for (Iterator iter2 = effect.getValues().iterator(); iter2.hasNext();) { Value value = (Value)iter2.next(); out.println("effect." + value.getName() + "=" + value.getString()); } out.println(); } out.close(); }
java
public void save(File file) throws IOException { PrintStream out = new PrintStream(new FileOutputStream(file)); out.println("font.size=" + fontSize); out.println("font.bold=" + bold); out.println("font.italic=" + italic); out.println(); out.println("pad.top=" + paddingTop); out.println("pad.right=" + paddingRight); out.println("pad.bottom=" + paddingBottom); out.println("pad.left=" + paddingLeft); out.println("pad.advance.x=" + paddingAdvanceX); out.println("pad.advance.y=" + paddingAdvanceY); out.println(); out.println("glyph.page.width=" + glyphPageWidth); out.println("glyph.page.height=" + glyphPageHeight); out.println(); for (Iterator iter = effects.iterator(); iter.hasNext();) { ConfigurableEffect effect = (ConfigurableEffect)iter.next(); out.println("effect.class=" + effect.getClass().getName()); for (Iterator iter2 = effect.getValues().iterator(); iter2.hasNext();) { Value value = (Value)iter2.next(); out.println("effect." + value.getName() + "=" + value.getString()); } out.println(); } out.close(); }
[ "public", "void", "save", "(", "File", "file", ")", "throws", "IOException", "{", "PrintStream", "out", "=", "new", "PrintStream", "(", "new", "FileOutputStream", "(", "file", ")", ")", ";", "out", ".", "println", "(", "\"font.size=\"", "+", "fontSize", ")", ";", "out", ".", "println", "(", "\"font.bold=\"", "+", "bold", ")", ";", "out", ".", "println", "(", "\"font.italic=\"", "+", "italic", ")", ";", "out", ".", "println", "(", ")", ";", "out", ".", "println", "(", "\"pad.top=\"", "+", "paddingTop", ")", ";", "out", ".", "println", "(", "\"pad.right=\"", "+", "paddingRight", ")", ";", "out", ".", "println", "(", "\"pad.bottom=\"", "+", "paddingBottom", ")", ";", "out", ".", "println", "(", "\"pad.left=\"", "+", "paddingLeft", ")", ";", "out", ".", "println", "(", "\"pad.advance.x=\"", "+", "paddingAdvanceX", ")", ";", "out", ".", "println", "(", "\"pad.advance.y=\"", "+", "paddingAdvanceY", ")", ";", "out", ".", "println", "(", ")", ";", "out", ".", "println", "(", "\"glyph.page.width=\"", "+", "glyphPageWidth", ")", ";", "out", ".", "println", "(", "\"glyph.page.height=\"", "+", "glyphPageHeight", ")", ";", "out", ".", "println", "(", ")", ";", "for", "(", "Iterator", "iter", "=", "effects", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "ConfigurableEffect", "effect", "=", "(", "ConfigurableEffect", ")", "iter", ".", "next", "(", ")", ";", "out", ".", "println", "(", "\"effect.class=\"", "+", "effect", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "for", "(", "Iterator", "iter2", "=", "effect", ".", "getValues", "(", ")", ".", "iterator", "(", ")", ";", "iter2", ".", "hasNext", "(", ")", ";", ")", "{", "Value", "value", "=", "(", "Value", ")", "iter2", ".", "next", "(", ")", ";", "out", ".", "println", "(", "\"effect.\"", "+", "value", ".", "getName", "(", ")", "+", "\"=\"", "+", "value", ".", "getString", "(", ")", ")", ";", "}", "out", ".", "println", "(", ")", ";", "}", "out", ".", "close", "(", ")", ";", "}" ]
Saves the settings to a file. @param file The file we're saving to @throws IOException if the file could not be saved.
[ "Saves", "the", "settings", "to", "a", "file", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/font/HieroSettings.java#L353-L379
1,579
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/renderer/VAOGLRenderer.java
VAOGLRenderer.flushBuffer
private void flushBuffer() { if (vertIndex == 0) { return; } if (currentType == NONE) { return; } if (vertIndex < TOLERANCE) { GL11.glBegin(currentType); for (int i=0;i<vertIndex;i++) { GL11.glColor4f(cols[(i*4)+0], cols[(i*4)+1], cols[(i*4)+2], cols[(i*4)+3]); GL11.glTexCoord2f(texs[(i*2)+0], texs[(i*2)+1]); GL11.glVertex3f(verts[(i*3)+0], verts[(i*3)+1], verts[(i*3)+2]); } GL11.glEnd(); currentType = NONE; return; } vertices.clear(); colors.clear(); textures.clear(); vertices.put(verts,0,vertIndex*3); colors.put(cols,0,vertIndex*4); textures.put(texs,0,vertIndex*2); vertices.flip(); colors.flip(); textures.flip(); GL11.glVertexPointer(3,0,vertices); GL11.glColorPointer(4,0,colors); GL11.glTexCoordPointer(2,0,textures); GL11.glDrawArrays(currentType, 0, vertIndex); currentType = NONE; }
java
private void flushBuffer() { if (vertIndex == 0) { return; } if (currentType == NONE) { return; } if (vertIndex < TOLERANCE) { GL11.glBegin(currentType); for (int i=0;i<vertIndex;i++) { GL11.glColor4f(cols[(i*4)+0], cols[(i*4)+1], cols[(i*4)+2], cols[(i*4)+3]); GL11.glTexCoord2f(texs[(i*2)+0], texs[(i*2)+1]); GL11.glVertex3f(verts[(i*3)+0], verts[(i*3)+1], verts[(i*3)+2]); } GL11.glEnd(); currentType = NONE; return; } vertices.clear(); colors.clear(); textures.clear(); vertices.put(verts,0,vertIndex*3); colors.put(cols,0,vertIndex*4); textures.put(texs,0,vertIndex*2); vertices.flip(); colors.flip(); textures.flip(); GL11.glVertexPointer(3,0,vertices); GL11.glColorPointer(4,0,colors); GL11.glTexCoordPointer(2,0,textures); GL11.glDrawArrays(currentType, 0, vertIndex); currentType = NONE; }
[ "private", "void", "flushBuffer", "(", ")", "{", "if", "(", "vertIndex", "==", "0", ")", "{", "return", ";", "}", "if", "(", "currentType", "==", "NONE", ")", "{", "return", ";", "}", "if", "(", "vertIndex", "<", "TOLERANCE", ")", "{", "GL11", ".", "glBegin", "(", "currentType", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "vertIndex", ";", "i", "++", ")", "{", "GL11", ".", "glColor4f", "(", "cols", "[", "(", "i", "*", "4", ")", "+", "0", "]", ",", "cols", "[", "(", "i", "*", "4", ")", "+", "1", "]", ",", "cols", "[", "(", "i", "*", "4", ")", "+", "2", "]", ",", "cols", "[", "(", "i", "*", "4", ")", "+", "3", "]", ")", ";", "GL11", ".", "glTexCoord2f", "(", "texs", "[", "(", "i", "*", "2", ")", "+", "0", "]", ",", "texs", "[", "(", "i", "*", "2", ")", "+", "1", "]", ")", ";", "GL11", ".", "glVertex3f", "(", "verts", "[", "(", "i", "*", "3", ")", "+", "0", "]", ",", "verts", "[", "(", "i", "*", "3", ")", "+", "1", "]", ",", "verts", "[", "(", "i", "*", "3", ")", "+", "2", "]", ")", ";", "}", "GL11", ".", "glEnd", "(", ")", ";", "currentType", "=", "NONE", ";", "return", ";", "}", "vertices", ".", "clear", "(", ")", ";", "colors", ".", "clear", "(", ")", ";", "textures", ".", "clear", "(", ")", ";", "vertices", ".", "put", "(", "verts", ",", "0", ",", "vertIndex", "*", "3", ")", ";", "colors", ".", "put", "(", "cols", ",", "0", ",", "vertIndex", "*", "4", ")", ";", "textures", ".", "put", "(", "texs", ",", "0", ",", "vertIndex", "*", "2", ")", ";", "vertices", ".", "flip", "(", ")", ";", "colors", ".", "flip", "(", ")", ";", "textures", ".", "flip", "(", ")", ";", "GL11", ".", "glVertexPointer", "(", "3", ",", "0", ",", "vertices", ")", ";", "GL11", ".", "glColorPointer", "(", "4", ",", "0", ",", "colors", ")", ";", "GL11", ".", "glTexCoordPointer", "(", "2", ",", "0", ",", "textures", ")", ";", "GL11", ".", "glDrawArrays", "(", "currentType", ",", "0", ",", "vertIndex", ")", ";", "currentType", "=", "NONE", ";", "}" ]
Flush the currently cached data down to the card
[ "Flush", "the", "currently", "cached", "data", "down", "to", "the", "card" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/renderer/VAOGLRenderer.java#L71-L108
1,580
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/renderer/VAOGLRenderer.java
VAOGLRenderer.applyBuffer
private void applyBuffer() { if (listMode > 0) { return; } if (vertIndex != 0) { flushBuffer(); startBuffer(); } super.glColor4f(color[0], color[1], color[2], color[3]); }
java
private void applyBuffer() { if (listMode > 0) { return; } if (vertIndex != 0) { flushBuffer(); startBuffer(); } super.glColor4f(color[0], color[1], color[2], color[3]); }
[ "private", "void", "applyBuffer", "(", ")", "{", "if", "(", "listMode", ">", "0", ")", "{", "return", ";", "}", "if", "(", "vertIndex", "!=", "0", ")", "{", "flushBuffer", "(", ")", ";", "startBuffer", "(", ")", ";", "}", "super", ".", "glColor4f", "(", "color", "[", "0", "]", ",", "color", "[", "1", "]", ",", "color", "[", "2", "]", ",", "color", "[", "3", "]", ")", ";", "}" ]
Apply the current buffer and restart it
[ "Apply", "the", "current", "buffer", "and", "restart", "it" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/renderer/VAOGLRenderer.java#L113-L124
1,581
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/renderer/VAOGLRenderer.java
VAOGLRenderer.isSplittable
private boolean isSplittable(int count, int type) { switch (type) { case GL11.GL_QUADS: return count % 4 == 0; case GL11.GL_TRIANGLES: return count % 3 == 0; case GL11.GL_LINE: return count % 2 == 0; } return false; }
java
private boolean isSplittable(int count, int type) { switch (type) { case GL11.GL_QUADS: return count % 4 == 0; case GL11.GL_TRIANGLES: return count % 3 == 0; case GL11.GL_LINE: return count % 2 == 0; } return false; }
[ "private", "boolean", "isSplittable", "(", "int", "count", ",", "int", "type", ")", "{", "switch", "(", "type", ")", "{", "case", "GL11", ".", "GL_QUADS", ":", "return", "count", "%", "4", "==", "0", ";", "case", "GL11", ".", "GL_TRIANGLES", ":", "return", "count", "%", "3", "==", "0", ";", "case", "GL11", ".", "GL_LINE", ":", "return", "count", "%", "2", "==", "0", ";", "}", "return", "false", ";", "}" ]
Check if the geometry being created can be split at the current index @param count The current index @param type The type of geometry being built @return True if the geometry can be split at the current index
[ "Check", "if", "the", "geometry", "being", "created", "can", "be", "split", "at", "the", "current", "index" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/renderer/VAOGLRenderer.java#L238-L249
1,582
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/opengl/DeferredTexture.java
DeferredTexture.checkTarget
private void checkTarget() { if (target == null) { try { load(); LoadingList.get().remove(this); return; } catch (IOException e) { throw new RuntimeException("Attempt to use deferred texture before loading and resource not found: "+resourceName); } } }
java
private void checkTarget() { if (target == null) { try { load(); LoadingList.get().remove(this); return; } catch (IOException e) { throw new RuntimeException("Attempt to use deferred texture before loading and resource not found: "+resourceName); } } }
[ "private", "void", "checkTarget", "(", ")", "{", "if", "(", "target", "==", "null", ")", "{", "try", "{", "load", "(", ")", ";", "LoadingList", ".", "get", "(", ")", ".", "remove", "(", "this", ")", ";", "return", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Attempt to use deferred texture before loading and resource not found: \"", "+", "resourceName", ")", ";", "}", "}", "}" ]
Check if the target has been obtained already
[ "Check", "if", "the", "target", "has", "been", "obtained", "already" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/opengl/DeferredTexture.java#L62-L72
1,583
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java
Rectangle.contains
public boolean contains(float xp, float yp) { checkPoints(); if (xp <= getX()) { return false; } if (yp <= getY()) { return false; } if (xp >= maxX) { return false; } if (yp >= maxY) { return false; } return true; }
java
public boolean contains(float xp, float yp) { checkPoints(); if (xp <= getX()) { return false; } if (yp <= getY()) { return false; } if (xp >= maxX) { return false; } if (yp >= maxY) { return false; } return true; }
[ "public", "boolean", "contains", "(", "float", "xp", ",", "float", "yp", ")", "{", "checkPoints", "(", ")", ";", "if", "(", "xp", "<=", "getX", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "yp", "<=", "getY", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "xp", ">=", "maxX", ")", "{", "return", "false", ";", "}", "if", "(", "yp", ">=", "maxY", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if this rectangle contains a point @param xp The x coordinate of the point to check @param yp The y coordinate of the point to check @return True if the point is within the rectangle
[ "Check", "if", "this", "rectangle", "contains", "a", "point" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java#L39-L56
1,584
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java
Rectangle.setBounds
public void setBounds(Rectangle other) { setBounds(other.getX(), other.getY(), other.getWidth(), other.getHeight()); }
java
public void setBounds(Rectangle other) { setBounds(other.getX(), other.getY(), other.getWidth(), other.getHeight()); }
[ "public", "void", "setBounds", "(", "Rectangle", "other", ")", "{", "setBounds", "(", "other", ".", "getX", "(", ")", ",", "other", ".", "getY", "(", ")", ",", "other", ".", "getWidth", "(", ")", ",", "other", ".", "getHeight", "(", ")", ")", ";", "}" ]
Set the bounds of this rectangle based on the given rectangle @param other The other rectangle whose bounds should be applied
[ "Set", "the", "bounds", "of", "this", "rectangle", "based", "on", "the", "given", "rectangle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java#L63-L65
1,585
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java
Rectangle.setBounds
public void setBounds(float x, float y, float width, float height) { setX(x); setY(y); setSize(width, height); }
java
public void setBounds(float x, float y, float width, float height) { setX(x); setY(y); setSize(width, height); }
[ "public", "void", "setBounds", "(", "float", "x", ",", "float", "y", ",", "float", "width", ",", "float", "height", ")", "{", "setX", "(", "x", ")", ";", "setY", "(", "y", ")", ";", "setSize", "(", "width", ",", "height", ")", ";", "}" ]
Set the bounds of this rectangle @param x The x coordinate of this rectangle @param y The y coordinate of this rectangle @param width The width to set in this rectangle @param height The height to set in this rectangle
[ "Set", "the", "bounds", "of", "this", "rectangle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java#L75-L79
1,586
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java
Rectangle.grow
public void grow(float h, float v) { setX(getX() - h); setY(getY() - v); setWidth(getWidth() + (h*2)); setHeight(getHeight() + (v*2)); }
java
public void grow(float h, float v) { setX(getX() - h); setY(getY() - v); setWidth(getWidth() + (h*2)); setHeight(getHeight() + (v*2)); }
[ "public", "void", "grow", "(", "float", "h", ",", "float", "v", ")", "{", "setX", "(", "getX", "(", ")", "-", "h", ")", ";", "setY", "(", "getY", "(", ")", "-", "v", ")", ";", "setWidth", "(", "getWidth", "(", ")", "+", "(", "h", "*", "2", ")", ")", ";", "setHeight", "(", "getHeight", "(", ")", "+", "(", "v", "*", "2", ")", ")", ";", "}" ]
Grow the rectangle at all edges by the given amounts. This will result in the rectangle getting larger around it's centre. @param h The amount to adjust horizontally @param v The amount to ajust vertically
[ "Grow", "the", "rectangle", "at", "all", "edges", "by", "the", "given", "amounts", ".", "This", "will", "result", "in", "the", "rectangle", "getting", "larger", "around", "it", "s", "centre", "." ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java#L118-L123
1,587
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java
Rectangle.setWidth
public void setWidth(float width) { if (width != this.width) { pointsDirty = true; this.width = width; maxX = x+width; } }
java
public void setWidth(float width) { if (width != this.width) { pointsDirty = true; this.width = width; maxX = x+width; } }
[ "public", "void", "setWidth", "(", "float", "width", ")", "{", "if", "(", "width", "!=", "this", ".", "width", ")", "{", "pointsDirty", "=", "true", ";", "this", ".", "width", "=", "width", ";", "maxX", "=", "x", "+", "width", ";", "}", "}" ]
Set the width of this box @param width The new width of this box
[ "Set", "the", "width", "of", "this", "box" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java#L140-L146
1,588
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java
Rectangle.setHeight
public void setHeight(float height) { if (height != this.height) { pointsDirty = true; this.height = height; maxY = y+height; } }
java
public void setHeight(float height) { if (height != this.height) { pointsDirty = true; this.height = height; maxY = y+height; } }
[ "public", "void", "setHeight", "(", "float", "height", ")", "{", "if", "(", "height", "!=", "this", ".", "height", ")", "{", "pointsDirty", "=", "true", ";", "this", ".", "height", "=", "height", ";", "maxY", "=", "y", "+", "height", ";", "}", "}" ]
Set the heightof this box @param height The height of this box
[ "Set", "the", "heightof", "this", "box" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java#L153-L159
1,589
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java
Rectangle.intersects
public boolean intersects(Shape shape) { if(shape instanceof Rectangle) { Rectangle other = (Rectangle)shape; if ((x > (other.x + other.width)) || ((x + width) < other.x)) { return false; } if ((y > (other.y + other.height)) || ((y + height) < other.y)) { return false; } return true; } else if(shape instanceof Circle) { return intersects((Circle)shape); } else { return super.intersects(shape); } }
java
public boolean intersects(Shape shape) { if(shape instanceof Rectangle) { Rectangle other = (Rectangle)shape; if ((x > (other.x + other.width)) || ((x + width) < other.x)) { return false; } if ((y > (other.y + other.height)) || ((y + height) < other.y)) { return false; } return true; } else if(shape instanceof Circle) { return intersects((Circle)shape); } else { return super.intersects(shape); } }
[ "public", "boolean", "intersects", "(", "Shape", "shape", ")", "{", "if", "(", "shape", "instanceof", "Rectangle", ")", "{", "Rectangle", "other", "=", "(", "Rectangle", ")", "shape", ";", "if", "(", "(", "x", ">", "(", "other", ".", "x", "+", "other", ".", "width", ")", ")", "||", "(", "(", "x", "+", "width", ")", "<", "other", ".", "x", ")", ")", "{", "return", "false", ";", "}", "if", "(", "(", "y", ">", "(", "other", ".", "y", "+", "other", ".", "height", ")", ")", "||", "(", "(", "y", "+", "height", ")", "<", "other", ".", "y", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "else", "if", "(", "shape", "instanceof", "Circle", ")", "{", "return", "intersects", "(", "(", "Circle", ")", "shape", ")", ";", "}", "else", "{", "return", "super", ".", "intersects", "(", "shape", ")", ";", "}", "}" ]
Check if this box touches another @param shape The other shape to check against @return True if the rectangles touch
[ "Check", "if", "this", "box", "touches", "another" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Rectangle.java#L167-L184
1,590
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java
Particle.render
public void render() { if ((engine.usePoints() && (usePoints == INHERIT_POINTS)) || (usePoints == USE_POINTS)) { TextureImpl.bindNone(); GL.glEnable(SGL.GL_POINT_SMOOTH); GL.glPointSize(size / 2); color.bind(); GL.glBegin(SGL.GL_POINTS); GL.glVertex2f(x, y); GL.glEnd(); } else if (oriented || scaleY != 1.0f) { GL.glPushMatrix(); GL.glTranslatef(x, y, 0f); if (oriented) { float angle = (float) (Math.atan2(y, x) * 180 / Math.PI); GL.glRotatef(angle, 0f, 0f, 1.0f); } // scale GL.glScalef(1.0f, scaleY, 1.0f); image.draw((int) (-(size / 2)), (int) (-(size / 2)), (int) size, (int) size, color); GL.glPopMatrix(); } else { color.bind(); image.drawEmbedded((int) (x - (size / 2)), (int) (y - (size / 2)), (int) size, (int) size); } }
java
public void render() { if ((engine.usePoints() && (usePoints == INHERIT_POINTS)) || (usePoints == USE_POINTS)) { TextureImpl.bindNone(); GL.glEnable(SGL.GL_POINT_SMOOTH); GL.glPointSize(size / 2); color.bind(); GL.glBegin(SGL.GL_POINTS); GL.glVertex2f(x, y); GL.glEnd(); } else if (oriented || scaleY != 1.0f) { GL.glPushMatrix(); GL.glTranslatef(x, y, 0f); if (oriented) { float angle = (float) (Math.atan2(y, x) * 180 / Math.PI); GL.glRotatef(angle, 0f, 0f, 1.0f); } // scale GL.glScalef(1.0f, scaleY, 1.0f); image.draw((int) (-(size / 2)), (int) (-(size / 2)), (int) size, (int) size, color); GL.glPopMatrix(); } else { color.bind(); image.drawEmbedded((int) (x - (size / 2)), (int) (y - (size / 2)), (int) size, (int) size); } }
[ "public", "void", "render", "(", ")", "{", "if", "(", "(", "engine", ".", "usePoints", "(", ")", "&&", "(", "usePoints", "==", "INHERIT_POINTS", ")", ")", "||", "(", "usePoints", "==", "USE_POINTS", ")", ")", "{", "TextureImpl", ".", "bindNone", "(", ")", ";", "GL", ".", "glEnable", "(", "SGL", ".", "GL_POINT_SMOOTH", ")", ";", "GL", ".", "glPointSize", "(", "size", "/", "2", ")", ";", "color", ".", "bind", "(", ")", ";", "GL", ".", "glBegin", "(", "SGL", ".", "GL_POINTS", ")", ";", "GL", ".", "glVertex2f", "(", "x", ",", "y", ")", ";", "GL", ".", "glEnd", "(", ")", ";", "}", "else", "if", "(", "oriented", "||", "scaleY", "!=", "1.0f", ")", "{", "GL", ".", "glPushMatrix", "(", ")", ";", "GL", ".", "glTranslatef", "(", "x", ",", "y", ",", "0f", ")", ";", "if", "(", "oriented", ")", "{", "float", "angle", "=", "(", "float", ")", "(", "Math", ".", "atan2", "(", "y", ",", "x", ")", "*", "180", "/", "Math", ".", "PI", ")", ";", "GL", ".", "glRotatef", "(", "angle", ",", "0f", ",", "0f", ",", "1.0f", ")", ";", "}", "// scale\r", "GL", ".", "glScalef", "(", "1.0f", ",", "scaleY", ",", "1.0f", ")", ";", "image", ".", "draw", "(", "(", "int", ")", "(", "-", "(", "size", "/", "2", ")", ")", ",", "(", "int", ")", "(", "-", "(", "size", "/", "2", ")", ")", ",", "(", "int", ")", "size", ",", "(", "int", ")", "size", ",", "color", ")", ";", "GL", ".", "glPopMatrix", "(", ")", ";", "}", "else", "{", "color", ".", "bind", "(", ")", ";", "image", ".", "drawEmbedded", "(", "(", "int", ")", "(", "x", "-", "(", "size", "/", "2", ")", ")", ",", "(", "int", ")", "(", "y", "-", "(", "size", "/", "2", ")", ")", ",", "(", "int", ")", "size", ",", "(", "int", ")", "size", ")", ";", "}", "}" ]
Render this particle
[ "Render", "this", "particle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java#L153-L184
1,591
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java
Particle.update
public void update(int delta) { emitter.updateParticle(this, delta); life -= delta; if (life > 0) { x += delta * velx; y += delta * vely; } else { engine.release(this); } }
java
public void update(int delta) { emitter.updateParticle(this, delta); life -= delta; if (life > 0) { x += delta * velx; y += delta * vely; } else { engine.release(this); } }
[ "public", "void", "update", "(", "int", "delta", ")", "{", "emitter", ".", "updateParticle", "(", "this", ",", "delta", ")", ";", "life", "-=", "delta", ";", "if", "(", "life", ">", "0", ")", "{", "x", "+=", "delta", "*", "velx", ";", "y", "+=", "delta", "*", "vely", ";", "}", "else", "{", "engine", ".", "release", "(", "this", ")", ";", "}", "}" ]
Update the state of this particle @param delta The time since the last update
[ "Update", "the", "state", "of", "this", "particle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java#L192-L202
1,592
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java
Particle.init
public void init(ParticleEmitter emitter, float life) { x = 0; this.emitter = emitter; y = 0; velx = 0; vely = 0; size = 10; type = 0; this.originalLife = this.life = life; oriented = false; scaleY = 1.0f; }
java
public void init(ParticleEmitter emitter, float life) { x = 0; this.emitter = emitter; y = 0; velx = 0; vely = 0; size = 10; type = 0; this.originalLife = this.life = life; oriented = false; scaleY = 1.0f; }
[ "public", "void", "init", "(", "ParticleEmitter", "emitter", ",", "float", "life", ")", "{", "x", "=", "0", ";", "this", ".", "emitter", "=", "emitter", ";", "y", "=", "0", ";", "velx", "=", "0", ";", "vely", "=", "0", ";", "size", "=", "10", ";", "type", "=", "0", ";", "this", ".", "originalLife", "=", "this", ".", "life", "=", "life", ";", "oriented", "=", "false", ";", "scaleY", "=", "1.0f", ";", "}" ]
Initialise the state of the particle as it's reused @param emitter The emitter controlling this particle @param life The life the particle should have (in milliseconds)
[ "Initialise", "the", "state", "of", "the", "particle", "as", "it", "s", "reused" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java#L212-L223
1,593
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java
Particle.setColor
public void setColor(float r, float g, float b, float a) { if (color == Color.white) { color = new Color(r,g,b,a); } else { color.r = r; color.g = g; color.b = b; color.a = a; } }
java
public void setColor(float r, float g, float b, float a) { if (color == Color.white) { color = new Color(r,g,b,a); } else { color.r = r; color.g = g; color.b = b; color.a = a; } }
[ "public", "void", "setColor", "(", "float", "r", ",", "float", "g", ",", "float", "b", ",", "float", "a", ")", "{", "if", "(", "color", "==", "Color", ".", "white", ")", "{", "color", "=", "new", "Color", "(", "r", ",", "g", ",", "b", ",", "a", ")", ";", "}", "else", "{", "color", ".", "r", "=", "r", ";", "color", ".", "g", "=", "g", ";", "color", ".", "b", "=", "b", ";", "color", ".", "a", "=", "a", ";", "}", "}" ]
Set the color of the particle @param r The red component of the color @param g The green component of the color @param b The blue component of the color @param a The alpha component of the color
[ "Set", "the", "color", "of", "the", "particle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java#L318-L327
1,594
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java
Particle.setVelocity
public void setVelocity(float dirx, float diry, float speed) { this.velx = dirx * speed; this.vely = diry * speed; }
java
public void setVelocity(float dirx, float diry, float speed) { this.velx = dirx * speed; this.vely = diry * speed; }
[ "public", "void", "setVelocity", "(", "float", "dirx", ",", "float", "diry", ",", "float", "speed", ")", "{", "this", ".", "velx", "=", "dirx", "*", "speed", ";", "this", ".", "vely", "=", "diry", "*", "speed", ";", "}" ]
Set the velocity of the particle @param dirx The x component of the new velocity @param diry The y component of the new velocity @param speed The speed in the given direction
[ "Set", "the", "velocity", "of", "the", "particle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java#L352-L355
1,595
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java
Particle.setSpeed
public void setSpeed(float speed) { float currentSpeed = (float) Math.sqrt((velx*velx) + (vely*vely)); velx *= speed; vely *= speed; velx /= currentSpeed; vely /= currentSpeed; }
java
public void setSpeed(float speed) { float currentSpeed = (float) Math.sqrt((velx*velx) + (vely*vely)); velx *= speed; vely *= speed; velx /= currentSpeed; vely /= currentSpeed; }
[ "public", "void", "setSpeed", "(", "float", "speed", ")", "{", "float", "currentSpeed", "=", "(", "float", ")", "Math", ".", "sqrt", "(", "(", "velx", "*", "velx", ")", "+", "(", "vely", "*", "vely", ")", ")", ";", "velx", "*=", "speed", ";", "vely", "*=", "speed", ";", "velx", "/=", "currentSpeed", ";", "vely", "/=", "currentSpeed", ";", "}" ]
Set the current speed of this particle @param speed The speed of this particle
[ "Set", "the", "current", "speed", "of", "this", "particle" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/particles/Particle.java#L362-L368
1,596
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/GameContainer.java
GameContainer.enableSharedContext
public static void enableSharedContext() throws SlickException { try { SHARED_DRAWABLE = new Pbuffer(64, 64, new PixelFormat(8, 0, 0), null); } catch (LWJGLException e) { throw new SlickException("Unable to create the pbuffer used for shard context, buffers not supported", e); } }
java
public static void enableSharedContext() throws SlickException { try { SHARED_DRAWABLE = new Pbuffer(64, 64, new PixelFormat(8, 0, 0), null); } catch (LWJGLException e) { throw new SlickException("Unable to create the pbuffer used for shard context, buffers not supported", e); } }
[ "public", "static", "void", "enableSharedContext", "(", ")", "throws", "SlickException", "{", "try", "{", "SHARED_DRAWABLE", "=", "new", "Pbuffer", "(", "64", ",", "64", ",", "new", "PixelFormat", "(", "8", ",", "0", ",", "0", ")", ",", "null", ")", ";", "}", "catch", "(", "LWJGLException", "e", ")", "{", "throw", "new", "SlickException", "(", "\"Unable to create the pbuffer used for shard context, buffers not supported\"", ",", "e", ")", ";", "}", "}" ]
Enable shared OpenGL context. After calling this all containers created will shared a single parent context @throws SlickException Indicates a failure to create the shared drawable
[ "Enable", "shared", "OpenGL", "context", ".", "After", "calling", "this", "all", "containers", "created", "will", "shared", "a", "single", "parent", "context" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/GameContainer.java#L207-L213
1,597
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/GameContainer.java
GameContainer.getBuildVersion
public static int getBuildVersion() { try { Properties props = new Properties(); props.load(ResourceLoader.getResourceAsStream("version")); int build = Integer.parseInt(props.getProperty("build")); Log.info("Slick Build #"+build); return build; } catch (Exception e) { Log.error("Unable to determine Slick build number"); return -1; } }
java
public static int getBuildVersion() { try { Properties props = new Properties(); props.load(ResourceLoader.getResourceAsStream("version")); int build = Integer.parseInt(props.getProperty("build")); Log.info("Slick Build #"+build); return build; } catch (Exception e) { Log.error("Unable to determine Slick build number"); return -1; } }
[ "public", "static", "int", "getBuildVersion", "(", ")", "{", "try", "{", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "props", ".", "load", "(", "ResourceLoader", ".", "getResourceAsStream", "(", "\"version\"", ")", ")", ";", "int", "build", "=", "Integer", ".", "parseInt", "(", "props", ".", "getProperty", "(", "\"build\"", ")", ")", ";", "Log", ".", "info", "(", "\"Slick Build #\"", "+", "build", ")", ";", "return", "build", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Log", ".", "error", "(", "\"Unable to determine Slick build number\"", ")", ";", "return", "-", "1", ";", "}", "}" ]
Get the build number of slick @return The build number of slick
[ "Get", "the", "build", "number", "of", "slick" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/GameContainer.java#L302-L315
1,598
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/GameContainer.java
GameContainer.sleep
public void sleep(int milliseconds) { long target = getTime()+milliseconds; while (getTime() < target) { try { Thread.sleep(1); } catch (Exception e) {} } }
java
public void sleep(int milliseconds) { long target = getTime()+milliseconds; while (getTime() < target) { try { Thread.sleep(1); } catch (Exception e) {} } }
[ "public", "void", "sleep", "(", "int", "milliseconds", ")", "{", "long", "target", "=", "getTime", "(", ")", "+", "milliseconds", ";", "while", "(", "getTime", "(", ")", "<", "target", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "1", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "}" ]
Sleep for a given period @param milliseconds The period to sleep for in milliseconds
[ "Sleep", "for", "a", "given", "period" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/GameContainer.java#L461-L466
1,599
nguillaumin/slick2d-maven
slick2d-core/src/main/java/org/newdawn/slick/GameContainer.java
GameContainer.updateAndRender
protected void updateAndRender(int delta) throws SlickException { if (smoothDeltas) { if (getFPS() != 0) { delta = 1000 / getFPS(); } } input.poll(width, height); Music.poll(delta); if (!paused) { storedDelta += delta; if (storedDelta >= minimumLogicInterval) { try { if (maximumLogicInterval != 0) { long cycles = storedDelta / maximumLogicInterval; for (int i=0;i<cycles;i++) { game.update(this, (int) maximumLogicInterval); } int remainder = (int) (storedDelta % maximumLogicInterval); if (remainder > minimumLogicInterval) { game.update(this, (int) (remainder % maximumLogicInterval)); storedDelta = 0; } else { storedDelta = remainder; } } else { game.update(this, (int) storedDelta); storedDelta = 0; } } catch (Throwable e) { Log.error(e); throw new SlickException("Game.update() failure - check the game code."); } } } else { game.update(this, 0); } if (hasFocus() || getAlwaysRender()) { if (clearEachFrame) { GL.glClear(SGL.GL_COLOR_BUFFER_BIT | SGL.GL_DEPTH_BUFFER_BIT); } GL.glLoadIdentity(); graphics.resetTransform(); graphics.resetFont(); graphics.resetLineWidth(); graphics.setAntiAlias(false); try { game.render(this, graphics); } catch (Throwable e) { Log.error(e); throw new SlickException("Game.render() failure - check the game code."); } graphics.resetTransform(); if (showFPS) { defaultFont.drawString(10, 10, "FPS: "+recordedFPS); } GL.flush(); } if (targetFPS != -1) { Display.sync(targetFPS); } }
java
protected void updateAndRender(int delta) throws SlickException { if (smoothDeltas) { if (getFPS() != 0) { delta = 1000 / getFPS(); } } input.poll(width, height); Music.poll(delta); if (!paused) { storedDelta += delta; if (storedDelta >= minimumLogicInterval) { try { if (maximumLogicInterval != 0) { long cycles = storedDelta / maximumLogicInterval; for (int i=0;i<cycles;i++) { game.update(this, (int) maximumLogicInterval); } int remainder = (int) (storedDelta % maximumLogicInterval); if (remainder > minimumLogicInterval) { game.update(this, (int) (remainder % maximumLogicInterval)); storedDelta = 0; } else { storedDelta = remainder; } } else { game.update(this, (int) storedDelta); storedDelta = 0; } } catch (Throwable e) { Log.error(e); throw new SlickException("Game.update() failure - check the game code."); } } } else { game.update(this, 0); } if (hasFocus() || getAlwaysRender()) { if (clearEachFrame) { GL.glClear(SGL.GL_COLOR_BUFFER_BIT | SGL.GL_DEPTH_BUFFER_BIT); } GL.glLoadIdentity(); graphics.resetTransform(); graphics.resetFont(); graphics.resetLineWidth(); graphics.setAntiAlias(false); try { game.render(this, graphics); } catch (Throwable e) { Log.error(e); throw new SlickException("Game.render() failure - check the game code."); } graphics.resetTransform(); if (showFPS) { defaultFont.drawString(10, 10, "FPS: "+recordedFPS); } GL.flush(); } if (targetFPS != -1) { Display.sync(targetFPS); } }
[ "protected", "void", "updateAndRender", "(", "int", "delta", ")", "throws", "SlickException", "{", "if", "(", "smoothDeltas", ")", "{", "if", "(", "getFPS", "(", ")", "!=", "0", ")", "{", "delta", "=", "1000", "/", "getFPS", "(", ")", ";", "}", "}", "input", ".", "poll", "(", "width", ",", "height", ")", ";", "Music", ".", "poll", "(", "delta", ")", ";", "if", "(", "!", "paused", ")", "{", "storedDelta", "+=", "delta", ";", "if", "(", "storedDelta", ">=", "minimumLogicInterval", ")", "{", "try", "{", "if", "(", "maximumLogicInterval", "!=", "0", ")", "{", "long", "cycles", "=", "storedDelta", "/", "maximumLogicInterval", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cycles", ";", "i", "++", ")", "{", "game", ".", "update", "(", "this", ",", "(", "int", ")", "maximumLogicInterval", ")", ";", "}", "int", "remainder", "=", "(", "int", ")", "(", "storedDelta", "%", "maximumLogicInterval", ")", ";", "if", "(", "remainder", ">", "minimumLogicInterval", ")", "{", "game", ".", "update", "(", "this", ",", "(", "int", ")", "(", "remainder", "%", "maximumLogicInterval", ")", ")", ";", "storedDelta", "=", "0", ";", "}", "else", "{", "storedDelta", "=", "remainder", ";", "}", "}", "else", "{", "game", ".", "update", "(", "this", ",", "(", "int", ")", "storedDelta", ")", ";", "storedDelta", "=", "0", ";", "}", "}", "catch", "(", "Throwable", "e", ")", "{", "Log", ".", "error", "(", "e", ")", ";", "throw", "new", "SlickException", "(", "\"Game.update() failure - check the game code.\"", ")", ";", "}", "}", "}", "else", "{", "game", ".", "update", "(", "this", ",", "0", ")", ";", "}", "if", "(", "hasFocus", "(", ")", "||", "getAlwaysRender", "(", ")", ")", "{", "if", "(", "clearEachFrame", ")", "{", "GL", ".", "glClear", "(", "SGL", ".", "GL_COLOR_BUFFER_BIT", "|", "SGL", ".", "GL_DEPTH_BUFFER_BIT", ")", ";", "}", "GL", ".", "glLoadIdentity", "(", ")", ";", "graphics", ".", "resetTransform", "(", ")", ";", "graphics", ".", "resetFont", "(", ")", ";", "graphics", ".", "resetLineWidth", "(", ")", ";", "graphics", ".", "setAntiAlias", "(", "false", ")", ";", "try", "{", "game", ".", "render", "(", "this", ",", "graphics", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "Log", ".", "error", "(", "e", ")", ";", "throw", "new", "SlickException", "(", "\"Game.render() failure - check the game code.\"", ")", ";", "}", "graphics", ".", "resetTransform", "(", ")", ";", "if", "(", "showFPS", ")", "{", "defaultFont", ".", "drawString", "(", "10", ",", "10", ",", "\"FPS: \"", "+", "recordedFPS", ")", ";", "}", "GL", ".", "flush", "(", ")", ";", "}", "if", "(", "targetFPS", "!=", "-", "1", ")", "{", "Display", ".", "sync", "(", "targetFPS", ")", ";", "}", "}" ]
Update and render the game @param delta The change in time since last update and render @throws SlickException Indicates an internal fault to the game.
[ "Update", "and", "render", "the", "game" ]
8251f88a0ed6a70e726d2468842455cd1f80893f
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/GameContainer.java#L634-L705