Total members 11890 |It is currently Tue Apr 23, 2024 11:58 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





This a line Translation using Java . which u change the postion of the line using new dx and dy.
it is so simple to understand.

java code
/*
* Translation.java
* Created on April 17, 2007, 3:32 PM
*/

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
/**
*
*/
public class Translation extends JFrame{

private int width=400;
private int height=400;
private int x1=-100;
private int y1=-100;
private int x2=100;
private int y2=100;
private int dx=20;
private int dy=20;
public Translation() {
setTitle("Line Translation");
setSize(width,height);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public void paint(Graphics g) {
g.fillRect(0,0,500,500);
g.setColor(Color.RED);

g.drawLine(x1+200,200-y1,x2+200,200-y2);
g.setColor(Color.GREEN);
g.drawLine(x1+200+dx,200-y1+dy,x2+200+dx,200-y2+dy);

}
public static void main(String[] args) {
// TODO code application logic here
new Translation();
}

}




_________________
Recommend my post if you found it helpful.


Author:
Newbie
User avatar Posts: 15
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Line Translation 2D
 Reading a File Line by Line in php     -  
 VB.NET to JAVA translation     -  
 skymiles translation     -  
 search for coding java/jsp for translation text     -  
 Line Rotation 2D     -  
 start a new line in html     -  
 Line Styles in java     -  
 read from command line     -  
 getting a full line input     -  
 DDA Line Drawing Algorithm     -  



Topic Tags

Java Graphics
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com