當前位置: 首頁>>代碼示例>>Java>>正文


Java Graphics.drawString方法代碼示例

本文整理匯總了Java中org.newdawn.slick.Graphics.drawString方法的典型用法代碼示例。如果您正苦於以下問題:Java Graphics.drawString方法的具體用法?Java Graphics.drawString怎麽用?Java Graphics.drawString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.newdawn.slick.Graphics的用法示例。


在下文中一共展示了Graphics.drawString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	g.drawString("T - TGA Snapshot", 10,50);
	g.drawString("J - JPG Snapshot", 10,70);
	g.drawString("P - PNG Snapshot", 10,90);

	g.setDrawMode(Graphics.MODE_ADD);
	g.drawImage(copy, 200, 300);
	g.setDrawMode(Graphics.MODE_NORMAL);
	
	g.drawString(message, 10,400);
	g.drawRect(200,0,400,300);
	g.translate(400, 250);
	fire.render();
	this.g = g;
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:19,代碼來源:ImageOutTest.java

示例2: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	g.drawString("R - Toggle Rotationg",10,50);
	g.drawImage(image1, 100, 236);
	g.drawImage(image2, 600, 236);
	
	g.translate(0, -150);
	g.rotate(400, 300, ang);
	g.texture(shape, image2);
	g.texture(shape, image1, fill);
	g.resetTransform();
	
	g.translate(0, 150);
	g.rotate(400, 300, ang);
	g.texture(poly, image2);
	g.texture(poly, image1, fill);
	g.resetTransform();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:21,代碼來源:GradientImageTest.java

示例3: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	g.drawString("Space to restart() animation", 100, 50);
	g.drawString("Til Limited animation: "+start, 100, 500);
	g.drawString("Hold 1 to move the manually animated", 100, 70);
	g.drawString("PingPong Frame:"+pingPong.getFrame(), 600, 70);
	
	g.scale(-1,1);
	animation.draw(-100,100);
	animation.draw(-200,100,36*4,65*4);
	if (start < 0) {
		limited.draw(-400,100,36*4,65*4);
	}
	manual.draw(-600,100,36*4,65*4);
	pingPong.draw(-700,100,36*2,65*2);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:19,代碼來源:AnimationTest.java

示例4: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	this.g = g;
	
	image.draw(100,100);
	g.setColor(Color.white);
	g.drawString("Move mouse over test image", 200, 20);
	g.setColor(read[0]);
	g.drawString(read[0].toString(), 100,300);
	g.setColor(read[1]);
	g.drawString(read[1].toString(), 150,320);
	g.setColor(read[2]);
	g.drawString(read[2].toString(), 200,340);
	g.setColor(read[3]);
	g.drawString(read[3].toString(), 250,360);
	if (read[4] != null) {
		g.setColor(read[4]);
		g.drawString("On image: "+read[4].toString(), 100,250);
	}
	if (read[5] != null) {
		g.setColor(Color.white);
		g.drawString("On screen: "+read[5].toString(), 100,270);
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:27,代碼來源:ImageReadTest.java

示例5: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
       g.drawString("left shift down: "+lshift, 100, 240);
       g.drawString("right shift down: "+rshift, 100, 260);
       g.drawString("space down: "+space, 100, 280); 
       
	g.setColor(Color.white);
	g.drawString(message, 10, 50);
	g.drawString(""+container.getInput().getMouseY(), 10, 400);
	g.drawString("Use the primary gamepad to control the blob, and hit a gamepad button to change the color", 10, 90);

	for (int i=0;i<lines.size();i++) {
		Line line = (Line) lines.get(i);
		line.draw(g);
	}
	
	g.setColor(cols[index]);
	g.fillOval((int) x, (int) y, 50, 50);
	g.setColor(Color.yellow);
	g.fillRect(50,200+ypos,40,40);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:24,代碼來源:InputTest.java

示例6: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	g.setColor(Color.white);
	g.drawString("The OGG loop is now streaming from the file, woot.",100,60);
	g.drawString("Press space for sound effect (OGG)",100,100);
	g.drawString("Press P to pause/resume music (XM)",100,130);
	g.drawString("Press E to pause/resume engine sound (WAV)",100,190);
	g.drawString("Press enter for charlie (WAV)",100,160);
	g.drawString("Press C to change music",100,210);
	g.drawString("Press B to burp (AIF)",100,240);
	g.drawString("Press + or - to change volume of music", 100, 270);
	g.setColor(Color.blue);
	g.drawString("Music Volume Level: " + volume / 10.0f, 150, 300);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:17,代碼來源:SoundURLTest.java

示例7: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.state.BasicGameState#render(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, StateBasedGame game, Graphics g) {
	g.setFont(font);
	g.setColor(Color.green);
	g.drawString("This is State 2", 200, 50);
	
	g.rotate(400,300,ang);
	g.drawImage(image,400-(image.getWidth()/2),300-(image.getHeight()/2));
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:12,代碼來源:TestState2.java

示例8: renderLives

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * This method draws and updates the lives of pacman
 * @param g
 * @param lives
 * @throws SlickException 
 */
private void renderLives(Graphics g, int lives) throws SlickException {
    g.setColor(Color.yellow);
    Image pacmanLives = new Image("data/pacman/pacman0.png");

    if (lives != 0) 
        pacmanLives.draw(510, 1, 18, 18);
    if (lives == 2 || lives == 3)
        pacmanLives.draw(533, 1, 18, 18);
    if (lives == 3)
        pacmanLives.draw(556, 1, 18, 18);
    g.drawString("LIVES: ", 450, 1);
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:19,代碼來源:MazeView.java

示例9: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) throws SlickException {
	g.setColor(Color.white);
	g.drawString("Press space to toggle caching", 10, 130);
	if (drawCached) {
		g.drawString("Drawing from cache", 10, 100);
		cached.render();
	} else {
		g.drawString("Drawing direct", 10, 100);
		operations.run();
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:15,代碼來源:CachedRenderTest.java

示例10: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.state.BasicGameState#render(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, StateBasedGame game, Graphics g) {
	g.setFont(font);
	g.setColor(Color.white);
	g.drawString("State Based Game Test", 100, 100);
	g.drawString("Numbers 1-3 will switch between states.", 150, 300);
	g.setColor(Color.red);
	g.drawString("This is State 1", 200, 50);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:12,代碼來源:TestState1.java

示例11: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) throws SlickException {
	g.setColor(new Color(0.4f,0.6f,0.8f));
	g.fillRect(0,0, 1024,568);
	g.setColor(Color.white);
	g.drawRect(5,5, 1024-10,568-10);
	
	g.setColor(Color.white);
	g.drawString(container.getInput().getMouseX()+","+container.getInput().getMouseY(), 10, 400);
	g.setColor(Color.red);
	g.fillOval(container.getInput().getMouseX()-10,container.getInput().getMouseY()-10,20,20);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:15,代碼來源:ScalableTest.java

示例12: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	
	String text = new String();
	
	switch(curTest) {
	
	case 0:
			text = "Rectangles";
			rectTest(g);
			break;
			
	case 1:
			text = "Ovals";
			ovalTest(g);
			break;
			
	case 2:
			text ="Arcs";
			arcTest(g);
			break;
	}
	
	g.setColor(Color.white);
	g.drawString("Press T to toggle overlay", 200, 55);
	g.drawString("Press N to switch tests", 200, 35);
	g.drawString("Press C to cycle drawing colors", 200, 15);
	g.drawString("Current Test:", 400, 35);
	g.setColor(Color.blue);
	g.drawString(text, 485, 35);
	
	g.setColor(Color.white);
	g.drawString("Normal:", 10, 150);
	g.drawString("Filled:", 10, 300);
	
	g.drawString("Drawn with Graphics context", 125, 400);
	g.drawString("Drawn using Shapes", 450, 400);
	
	// Grab our mouse position and copy the screen to our magnified image
	g.copyArea(magImage, container.getInput().getMouseX() - 10, container.getInput().getMouseY() - 10);
	magImage.draw(351, 451, 5);
	g.drawString("Mag Area -", 250, 475);
	g.setColor(Color.darkGray);
	g.drawRect(350, 450, 106, 106);
	
	g.setColor(Color.white);
	g.drawString("NOTE:", 500, 450);
	g.drawString("lines should be flush with edges", 525, 470);
	g.drawString("corners should be symetric", 525, 490);
	
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:54,代碼來源:GeomAccuracyTest.java

示例13: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.gui.AbstractComponent#render(org.newdawn.slick.gui.GUIContext,
 *      org.newdawn.slick.Graphics)
 */
public void render(GUIContext container, Graphics g) {
	if (lastKey != -1) {
		if (input.isKeyDown(lastKey)) {
			if (repeatTimer < System.currentTimeMillis()) {
				repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL;
				keyPressed(lastKey, lastChar);
			}
		} else {
			lastKey = -1;
		}
	}
	Rectangle oldClip = g.getClip();
	g.setWorldClip(x,y,width, height);
	
	// Someone could have set a color for me to blend...
	Color clr = g.getColor();

	if (background != null) {
		g.setColor(background.multiply(clr));
		g.fillRect(x, y, width, height);
	}
	g.setColor(text.multiply(clr));
	Font temp = g.getFont();

	int cpos = font.getWidth(value.substring(0, cursorPos));
	int tx = 0;
	if (cpos > width) {
		tx = width - cpos - font.getWidth("_");
	}

	g.translate(tx + 2, 0);
	g.setFont(font);
	g.drawString(value, x + 1, y + 1);

	if (hasFocus() && visibleCursor) {
		g.drawString("_", x + 1 + cpos + 2, y + 1);
	}

	g.translate(-tx - 2, 0);

	if (border != null) {
		g.setColor(border.multiply(clr));
		g.drawRect(x, y, width, height);
	}
	g.setColor(clr);
	g.setFont(temp);
	g.clearWorldClip();
	g.setClip(oldClip);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:54,代碼來源:TextField.java

示例14: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) throws SlickException {
	g.drawString(message, 100, 100);
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:7,代碼來源:DoubleClickTest.java

示例15: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) throws SlickException {

	// RENDERING TO AN IMAGE AND THEN DRAWING IT TO THE DISPLAY
	// Draw graphics and text onto our graphics context from the Image target
	gTarget.setBackground(new Color(0,0,0,0));
	gTarget.clear();
	gTarget.rotate(200,160,ang);
	gTarget.setFont(testFont);
	gTarget.fillRect(10, 10, 50, 50);
	gTarget.drawString("HELLO WORLD",10,10);

	gTarget.drawImage(testImage,100,150);
	gTarget.drawImage(testImage,100,50);
	gTarget.drawImage(testImage,50,75);
	
	// Note we started by clearing the offscreen graphics area and then end
	// by calling flush
	gTarget.flush(); 

	g.setColor(Color.red);
	g.fillRect(250, 50, 200, 200);
	// The image has been updated using its graphics context, so now draw the image
	// to the screen a few times
	target.draw(300,100);
	target.draw(300,410,200,150);
	target.draw(505,410,100,75);
	
	// Draw some text on the screen to indicate what we did and put some
	// nice boxes around the three areas
	g.setColor(Color.white);
	g.drawString("Testing On Offscreen Buffer", 300, 80);
	g.setColor(Color.green);
	g.drawRect(300, 100, target.getWidth(), target.getHeight());
	g.drawRect(300, 410, target.getWidth()/2, target.getHeight()/2);
	g.drawRect(505, 410, target.getWidth()/4, target.getHeight()/4);
	
	// SCREEN COPY EXAMPLE
	// Put some text and simple graphics on the screen to test copying
	// from the screen to a target image
	g.setColor(Color.white);
	g.drawString("Testing Font On Back Buffer", 10, 100);
	g.drawString("Using: "+using, 10, 580);
	g.setColor(Color.red);
	g.fillRect(10,120,200,5);
	
	// Copy the screen area into a destination image
	int xp = (int) (60 + (Math.sin(ang / 60) * 50));
	g.copyArea(cut,xp,50);
	
	// Draw the copied image to the screen and put some nice
	// boxes around the source and the destination
	cut.draw(30,250);
	g.setColor(Color.white);
	g.drawRect(30, 250, cut.getWidth(), cut.getHeight());
	g.setColor(Color.gray);
	g.drawRect(xp, 50, cut.getWidth(), cut.getHeight());
	
	// ALTERING A LOADED IMAGE EXAMPLE
	// Draw the image we loaded in the init method and then modified
	// by drawing some text and simple geometry on it
	preloaded.draw(2,400);
	g.setColor(Color.blue);
	g.drawRect(2,400,preloaded.getWidth(),preloaded.getHeight());
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:68,代碼來源:ImageGraphicsTest.java


注:本文中的org.newdawn.slick.Graphics.drawString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。