Total members 11894 |It is currently Thu Nov 21, 2024 3:42 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





draw General Path using java
java code
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
import java.util.Vector;

public class ShowGeneralPath extends JApplet {
Canvas1 canvas;

public static void main(String[] args) {
JFrame frame = new JFrame("Show General Paths");
ShowGeneralPath path = new ShowGeneralPath();
path.init();
frame.getContentPane().add(path);
frame.setSize(280, 250);
frame.show();
}
public void init() {
Container container = getContentPane();
JPanel panel = new JPanel();
canvas = new Canvas1();
container.add(canvas);
}
class Canvas1 extends Canvas {
Vector generalPath;

public Canvas1() {
setBackground(Color.white);
setSize(400, 200);
generalPath = new Vector();
GeneralPath path1, path2,path3;

path1 = new GeneralPath();
path1.moveTo(25, 35);
path1.lineTo(35, 50);
path1.lineTo(50, 20);
path1.lineTo(80, 30);
path1.curveTo(20, 100, 110, 60, 40, 100);
generalPath.addElement(path1);

path2 = new GeneralPath();
path2.moveTo(120, 20);
path2.lineTo(120, 80);
path2.lineTo(180, 20);
path2.lineTo(180, 80);
path2.closePath();
generalPath.addElement(path2);

path3 = new GeneralPath();
path3.moveTo(50, 120);
path3.lineTo(70, 180);
path3.lineTo(20, 140);
path3.lineTo(80, 140);
path3.lineTo(30, 180);
path3.closePath();
generalPath.addElement(path3);
}
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
for (int i = 0; i < generalPath.size(); i++) {
g2d.setPaint(Color.red);
g2d.draw((GeneralPath) generalPath.elementAt(i));
}
}
}
}





Attachments:
File comment: draw path .
path.gif
path.gif [ 4.99 KiB | Viewed 11399 times ]

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada
Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : draw General Path
 Java code to draw shortest path tree     -  
 c++ general programming     -  
 General call (Invoke) to method     -  
 General Error: Style data     -  
 get include path     -  
 Dijkstra ( Shortage Path )     -  
 Dijkstra ( Shortest Path )     -  
 get Folder path and size     -  
 shortest path algorithm java     -  
 return file path after encoded using UTF-8 from URL     -  



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