5 Replies - 3481 Views - Last Post: 24 January 2006 - 07:41 AM Rate Topic: -----

#1 sudip  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-January 06

Mapping Coordinates in Applet

Post icon  Posted 19 January 2006 - 05:43 AM

hi,
this is sudip. i m new to this site.and of course i m in problem.so try helping me.With due respect i would like to inform u that i have been facing a problem in coding java and so i need ur kind help.please read below...
The problem is like that...There is a table which is created by oracle9i and this table is located in a server machine.This table contains a huge collections of very large coordinates(x,y) and what i want is to write a code in java applet,then connect my code to the database table and which will in turn access the coordinates(x,y) and draw a map after plotting them on to the applet.But here the main problem is as the coordinates are very large in size i m not able to draw line within the applet area and so not able to form the map.

So it is my humble request to you that please send me the java code for the above problem. I am waiting for your kind reply.

here the coordinates are as given below......

X_COORD Y_COORD Z_COORD
---------- ---------- -------
3054897 941852.375 0
3054898.75 941833.5 0
3054898.5 941835.375 0
3054900.75 941835.563 0
3054901 941833.688 0
3054897.5 941844.25 0
3054897.75 941842.375 0
3054900.25 941842.625 0
3054900 941844.5 0
3054897.25 941850.5 0
3054897 941852.375 0


how much i have implemented know i provide that below.....

<code>

import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.awt.*;
import java.applet.Applet;
import java.net.*;
import java.awt.geom.*;
import java.lang.String.*;
import java.io.*;


public class MapDrawingAppletNew extends JApplet
{

public void init()
{
//get Screen dimensions
//add panel to Frame

NotHelloworldpanel panel1=new NotHelloworldpanel ();

Container contentpane=getContentPane();
contentpane.add(panel1);

}
}

class NotHelloworldpanel extends JPanel

{
int point[][]=new int[20][20];
Connection conn = null;
int i=0;
int j=0;

NotHelloworldpanel()
{
try
{

Class.forName("oracle.jdbc.driver.OracleDriver");

conn = DriverManager.getConnection(
"jdbc:oracle:thin:@172.18.16.94:1521:oitds1",
"dbauser",
"rama6831");

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM t_survey_coord4");

//Loop through results of query.
if(rs !=null)
{

while(rs.next())
{
point[i][j]=Integer.parseInt(rs.getString(1));
point[i][j+1]=Integer.parseInt(rs.getString(2));
i++;
}

}



}catch(SQLException e)
{

System.out.println("SQLException: " + e.getMessage() );
while((e = e.getNextException()) != null)
System.out.println(e.getMessage() );

}
catch(ClassNotFoundException e)

{
System.out.println("ClassNotFoundException: " + e.getMessage() );
}
finally

{
//Clean up resources, close the connection.

if(conn != null)
{
try
{
conn.close();
System.out.println("Congratulation data has been loaded successfully");
}
catch (Exception ignored) {}
}
}
}



public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2=(Graphics2D) g;

// Creating new fonts

Font font1=new Font("Times New Roman",Font.BOLD,10);
g2.setFont(font1);



//draw a diagonal line



for (int k=0;k<point.length;k++)
{
if(k==(point.length-1))
{
Point2D p1=new Point2D.Double(point[k][j],point[k][j+1]);
Point2D p2=new Point2D.Double(point[j][j],point[j][j+1]);
Line2D l= new Line2D.Double(p1,p2);
g2.draw(l);
break;
}

else{
Point2D p1=new Point2D.Double(point[k][j],point[k][j+1]);
Point2D p2=new Point2D.Double(point[k+1][j],point[k+1][j+1]);

Line2D l= new Line2D.Double(p1,p2);
g2.setPaint(Color.white);
g2.draw(l);

}

}



}
}


</code>

Now is this coding enough for the above implementation, if not please modify the code in such a way that could serve my purpose. please
send me the reply in deep_gh1@rediffmail.com



Thanking you sir,
Sincerely Yours,
Sudip Ghosh
BE(CSE),MIT
Manipal

Is This A Good Question/Topic? 0
  • +

Replies To: Mapping Coordinates in Applet

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Mapping Coordinates in Applet

Posted 19 January 2006 - 07:28 AM

I'd suggest that you use a static scale to reduce the coordinates to something that will be able to be displayed within the applet. As long as the scale is static, the display will be the same as with the original coordinates.
Was This Post Helpful? 0
  • +
  • -

#3 sudip  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-January 06

Re: Mapping Coordinates in Applet

Post icon  Posted 20 January 2006 - 12:08 AM

Amadeus, on 19 Jan, 2006 - 08:25 AM, said:

I'd suggest that you use a static scale to reduce the coordinates to something that will be able to be displayed within the applet. As long as the scale is static, the display will be the same as with the original coordinates.

Sir,
i m very regret to say you that i am not able to understand the concept u suggested me. Please dont miss judge me. It would be more helpful to me you modify the code what i was trying to implement in such a way that would establish ur suggestion. Otherwise i won't be able to complete my project. Please sir try to understand my problem.

If u feel that i m enough to touch ur heart then send me ur kind reply to deep.gh3@gmail.com. I m waiting for ur reply.

Thanking u for ur kind suggestion.

Sincerely Yours,

Sudip Ghosh

This post has been edited by sudip: 20 January 2006 - 12:10 AM

Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Mapping Coordinates in Applet

Posted 20 January 2006 - 07:17 AM

The concept I was suggesting was to scale back each coordinate by the same amount, thereby preserving the correct dimensions. A logical suggestion might be to divide each coordinate by 100,000. this would leave you with coordinates of (first set):

Quote

original coordinates:
3054897 941852.375 0

Scaled coordinates:
30.54897 9.41852.375 0

This scaling wil allow the coodinates to be mapped within the applet.

I aplogize for not sending you an email directly. We prefer to provide solutions within the forums so that other member may benefit should they be confonted with a similar challenge.
Was This Post Helpful? 0
  • +
  • -

#5 sudip  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-January 06

Re: Mapping Coordinates in Applet

Post icon  Posted 24 January 2006 - 01:57 AM

Amadeus, on 20 Jan, 2006 - 08:14 AM, said:

The concept I was suggesting was to scale back each coordinate by the same amount, thereby preserving the correct dimensions. A logical suggestion might be to divide each coordinate by 100,000. this would leave you with coordinates of (first set):

Quote

original coordinates:
3054897 941852.375 0

Scaled coordinates:
30.54897 9.41852.375 0

This scaling wil allow the coodinates to be mapped within the applet.

I aplogize for not sending you an email directly. We prefer to provide solutions within the forums so that other member may benefit should they be confonted with a similar challenge.

Sir,
First of all i give u a thank for sugessting me that. I request u to send me a very small sample code covering the concept being given by u. So that i could make sample run on that code and my concept will be more clearer. I dont want to request for any huge coding , because i know the forum rules. But what i just try to say u that write a sample code which accept such big coordinates and that scale it. Just write the code snipet required to establish concept.

Thank u again sir. Please get into contact. i will have more questions regarding java in future. And i hope ur full help on me.

Sincerely Yours,

Sudip Ghosh
Was This Post Helpful? 0
  • +
  • -

#6 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Mapping Coordinates in Applet

Posted 24 January 2006 - 07:41 AM

Before drawing the line, I suggest simply scaling the values...in this way, the original values are preserved if you require them for something.
Line2D l= new Line2D.Double((p1/100000),(p2/100000);


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1