How to change the co-ordinayte system?

Hello to all,
I am working on a java project in which i want to display Earth's longitudes and latitudes. Right now my program giving me cartesian means the applet's own co-ordinate but i want the co-ordinates in degrees to solve some communication equations .
please help me to solve this problem.
I will be very thankfull to you all...
My code is given as:
import java.awt.*;
import java.applet.*;
import javax.swing.JApplet;
import javax.swing.JPanel;
import java.awt.event.*;
public class DrawEarth extends JApplet implements MouseListener
     public void mouseClicked (MouseEvent me) {
          xpos = me.getX();
            ypos = me.getY();
            // Check if the click was inside the Earth area.
            if ((xpos >50 && xpos < 450 && ypos >50 &&  ypos < 450)||(xpos >450 && xpos < 850 && ypos >50 &&  ypos < 450)) {
                 mouseClicked = true;
            // if it was not then mouseClicked is false;
            else
                 return ;
            repaint();
      public void mouseEntered (MouseEvent me) {}
      public void mousePressed (MouseEvent me) {}
      public void mouseReleased (MouseEvent me) {} 
      public void mouseExited (MouseEvent me) {}
     boolean mouseClicked;
     int  xpos,ypos;
     String msg;
    public void init() {
         //addMouseListener(this);
         super.init();
         addMouseListener(this);
        setContentPane(new JPanel() {
            final Dimension size = new Dimension(1000, 1000);
            final GradientPaint backgradient = new GradientPaint(0, 0, Color.WHITE, 0, 350, Color.BLACK);
            final GradientPaint earthgradient = new GradientPaint(0, 50, Color.CYAN, 0, 450, Color.GREEN);
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                Graphics2D g2 = (Graphics2D) g;
                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                g2.setPaint(backgradient);
                g2.fillRect(0, 0, 1000, 1000);
                g2.setPaint(backgradient);
                g2.setPaint(earthgradient);
                g2.fillOval(50, 50, 400, 400);
                g2.fillOval(450, 50, 400, 400);
                g2.setColor(Color.BLUE);
                g2.setColor(Color.BLUE);
                g.drawString("270",35,250);
                g.drawString("300",70,250);
                g.drawString("330",145,250);
                  g.drawString("(0,0)",245,250);
                  g.drawString("30",345,250);
                  g.drawString("60",415,250);
                  g.drawString("90",445,250);
                  g.drawString("120",470,250);
                  g.drawString("150",545,250);
                     g.drawString("(180,0)",645,250);
                     g.drawString("210",745,250);
                     g.drawString("240",815,250);
                     g.drawString("270",850,250);
                     g.drawString("90",255,48);
                     g.drawString("60",255,77);
                     g.drawString("30",255,150);
                     g.drawString("-30",255,350);
                     g.drawString("-60",255,425);
                     g.drawString("-90",255,460);
                     g.drawString("90",650,48);
                     g.drawString("60",650,77);
                     g.drawString("30",650,150);
                     g.drawString("-30",650,350);
                     g.drawString("-60",650,425);
                     g.drawString("-90",650,460);
                for (int i = 0; i <= 180; i += 10) {
                    int widthlong = (int) (200 * Math.cos(Math.toRadians(i)));
                    g2.drawOval(250 - widthlong, 50, 2 * widthlong, 400);
                    g2.drawOval(650 - widthlong, 50, 2 * widthlong, 400);
                    int widthlat = (int) (200 * Math.sin(Math.toRadians(i)));
                    g2.drawLine(250 - widthlat, 250 - widthlong, 250 + widthlat, 250 - widthlong);
                    g2.drawLine(650 - widthlat, 250 - widthlong, 650 + widthlat, 250 - widthlong);
                double xco = xpos/22.22;
                double yco = ypos/22.22;
                    if(xpos >50 && xpos < 450 && ypos >50 && ypos < 250){
                         g.drawString("("+xpos+","+ypos+")",xpos,ypos);
                    if(xpos >450 && xpos < 850 && ypos >50 && ypos < 250){
                         g.drawString("("+xpos+","+ypos+")",xpos,ypos);
                    if(xpos >50 && xpos < 450 && ypos >250 && ypos < 450){
                         g.drawString("("+xpos+","+ypos+")",xpos,ypos);
                    if(xpos >450 && xpos < 850 && ypos >250 && ypos < 450){
                         g.drawString("("+xpos+","+ypos+")",xpos,ypos);
                    if((xpos==250&&ypos==50)  || (xpos== 650 && ypos==450 )){
                         g.drawString("("+xpos+","+ypos+")",xpos,ypos);
                    if(xpos >=50 && xpos <= 850 && ypos ==250 ){
                         g.drawString("("+xpos+","+ypos+")",xpos,ypos);
           /* public Dimension getPreferredSize()
                return size;
   

=)
For the boundaries of the globe you can test if the click was outside the globes by comparing the radius and the calculated distance from the center of each globe for each globe separately. The transform of the drawing the OP made is not a standard one so I'm having to comprehend the calculus of transformations I picked up last year and combine it with the linear algebra I learned this year ( might take until next week =( ). I tried implementing it by using weighted average procedures
i.e.
>
delta = ( 1 - t )*P + tQ>
where t is time in fraction of the total time and P and Q are two different points on a line. But there is also the effect of moving away from the equator for the longitude where the effect on the rate of change is increased when moving sideways ( longitude measures degrees around the earth from the prime meridian ) and when I tried to implement those two effects together, they seem to work for some parts but fail as I go diagonally (simply put) from 0deg,0deg which give false results in that the lat or lon (can remember which) is greater than the possible amount allowed ( i.e. abs_value > 180 for longitude or > 90 for latitude ).
Here's the code so far if you want to take a look at it:
I wasn't trying to worried too much about anything else but the algorithm for transforming the coords. I added the JLabel on the north side so I wouldn't have to look at the command prompt.
import java.awt.Dimension;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GradientPaint;
import java.awt.RenderingHints;
import java.awt.Point;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.BorderLayout;
import javax.swing.JLabel;
public class DrawEarthPanel extends JPanel
     public static final long serialVersionUID = 1L;
     private static final Dimension size = new Dimension(900, 500); // width, height
     private static final GradientPaint backgradient = new GradientPaint(0, 0, Color.WHITE, 0, 350, Color.BLACK);
     private static final GradientPaint earthgradient = new GradientPaint(0, 50, Color.CYAN, 0, 450, Color.GREEN);
     private boolean mouseClicked;
     private int xpos = 0;
     private int ypos = 0;
     public DrawEarthPanel()
          addMouseListener( new MouseEvents() );
     public Dimension getPreferredSize()
          return DrawEarthPanel.size;
     public void paintComponent( Graphics g )
          super.paintComponent(g);
          Graphics2D g2 = (Graphics2D) g;
          g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
          g2.setPaint(backgradient);
          g2.fillRect(0, 0, 1000, 1000);
          g2.setPaint(earthgradient);
          g2.fillOval(50, 50, 400, 400);
          g2.fillOval(450, 50, 400, 400);
          g2.setColor(Color.BLUE);
          g.drawString("270",35,250);
          g.drawString("300",70,250);
          g.drawString("330",145,250);
          g.drawString("(0,0)",245,250);
          g.drawString("30",345,250);
          g.drawString("60",415,250);
          g.drawString("90",445,250);
          g.drawString("120",470,250);
          g.drawString("150",545,250);
          g.drawString("(180,0)",645,250);
          g.drawString("210",745,250);
          g.drawString("240",815,250);
          g.drawString("270",850,250);
          labelLatitudes( g, 255 );
          labelLatitudes( g, 650 );
          for ( int i=0; i<=180; i+=10 )
               int wLon = (int) (200 * Math.cos(Math.toRadians(i)));
               g2.drawOval(250-wLon, 50, 2*wLon, 400);
               g2.drawOval(650-wLon, 50, 2*wLon, 400);
               int wLat = (int) (200 * Math.sin(Math.toRadians(i)));
               g2.drawLine(250-wLat, 250-wLon, 250+wLat, 250-wLon);
               g2.drawLine(650-wLat, 250-wLon, 650+wLat, 250-wLon);
     private static final Point left_globe_origin = new Point( 250, 250 );
     private static final Point right_globe_origin = new Point( 650, 250 );
     private static final int globe_radius = 200;
     private void labelLatitudes(Graphics g, int x)
          g.drawString("90",x,48);
          g.drawString("60",x,77);
          g.drawString("30",x,150);
          g.drawString("-30",x,350);
          g.drawString("-60",x,425);
          g.drawString("-90",x,460);
     class MouseEvents extends MouseAdapter implements MouseListener
          public void mouseClicked( MouseEvent evt )
               xpos = evt.getX();
               ypos = evt.getY();
               System.err.println("DEBUG: xpos="+xpos+", ypos="+ypos);
               double lat = 0.0;
               double lon = 0.0;
               if ( xpos>50 && xpos<450 && distance(left_globe_origin,xpos,ypos) <= globe_radius ) // left globe
                    Point origin = left_globe_origin;
                    double radius = globe_radius;
                    double dx = xpos-origin.x;
                    double dy = -ypos+origin.y;
                    lat = (dy/(radius-dx))*90;
                    lon = (dx/(radius-dy))*90;
               //     lat = ypos - 250;
               //     lon = xpos - 250;
                    setLabel( String.format( "longitude >>> %.3f, latitude >> %.3f", lon, lat ) );
                    System.err.println( "DEBUG: lat=" + lat + ", lon=" + lon );
               else if ( xpos>450 && xpos<850 && distance( right_globe_origin,xpos,ypos) <= globe_radius ) // right globe
                    Point origin = right_globe_origin;
                    int radius = globe_radius;
                    int dx = xpos-origin.x;
                    int dy = ypos-origin.y;
                    lat = (1d*dx/radius+1d*dy/radius)*90;
                    lon = (1d*dx/radius+1d*dy/radius)*90;
               //     lat = ypos - 250;
               //     lon = xpos - 650;
                    setLabel( String.format( "longitude >>> %3.3f, latitude >> %3.3f", lon, lat ) );
                    System.err.println( "DEBUG: lat=" + lat + ", lon=" + lon );
               repaint();
     private static JLabel output = new JLabel( "Output of Longitude and Latitude" );
     public static void setLabel( String text )
          output.setText( text );
     public static double distance( Point origin, int x, int y )
          return Math.pow( Math.pow((x-origin.x),2)+Math.pow((y-origin.y),2), 0.5 );
     private static void createAndShowGUI()
          JFrame frame = new JFrame( "DrawEarthPanel" );
          frame.setLayout( new BorderLayout() );
          frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          frame.setLocation(10, 10);
          frame.setContentPane(new DrawEarthPanel());
          frame.add( output, BorderLayout.NORTH );
          frame.pack();
          frame.setVisible(true);
     public static void main( String[] args )
          javax.swing.SwingUtilities.invokeLater(
               new Runnable()
                    public void run()
                         createAndShowGUI();
}The transform isn't a regular one since the OP kept his lat. lines straight so it's kind of weird to me right now.
Happy coding

Similar Messages

  • How to change the IOS operating system

    how do you change the IOS operating system from 2 to a more modern in my ipod touch?

    It is very simple, see here: http://www.apple.com/ios/.
    Updating is easy.
    Just connect your device to your Mac or PC and follow the onscreen instructions in iTunes.

  • How to change the ECC Source system in SAP BI

    Dear Experts,
    In my BI development system instead of showing ECC development system as a source system it is showing ECC production system.
    Now in my BI system I want to change the source system from ECC Production to ECC development.
    Kindly explain me step by step to change the source system from ECC Production to ECC development.
    Regards,
    Suresh.

    Hi,
    Ask your basis team to change source system entries.
    They knows how to assign logical mappings.
    Tx - BDLS.
    Tables - RSLOGSYSMAP.
    Try this way.
    Bw, Tx - RSA1-->source system, Menu Tools - Conversion of logical system name and Assignment of source system to source system ID.
    Thanks

  • How to change the category of system messages in PS

    Hi All,
    Is it possible to change the category (i.e from information to warning/error) of the system messages like CN707 in PS? If yes how?

    Hi,
    You will have to go for development. Use userexit CNEX0009.
    Refer similar thread:Re: CN707, SE721
    Regards
    Edited by: Shrikant Rakate on Jan 14, 2009 4:57 PM
    Edited by: Shrikant Rakate on Jan 14, 2009 4:58 PM
    Edited by: Shrikant Rakate on Jan 15, 2009 12:37 PM
    Edited by: Shrikant Rakate on Jan 15, 2009 12:38 PM

  • How to change the SID during system copy

    This blog /people/johannes.heinrich/blog/2006/07/07/new-features-in-db2-udb-v9--part-3 (i.e.  the "new feature of V9" in this group) only
    talk about the system copy without changing the SID.
    In reality, we often want to change the SID during the system copy. Can we modify the script mentioned in above blog
    to make SID change possible?
    Thanks!

    Hi Christy,
    if you´re using export/import which is prefered you can change the sid during the parameter setting for export and import. You´ll be asked by the old sid and the new sid. For the tablespace names it is not so important because db2 is using tablespace id not the name for the internal administration.
    Regards
    Olaf

  • How to change the worklist in schedule manager in production system

    we are using schedule manager (SCMA) to arrange the daily process in SAP system. but we have to config the worklist and transport it to the production system every time cause in production system if we press edit worklist there would be a message called " TK430 The system administrator has set your logon client to the 'not modifiable' status.Client-specific objects can not be changed in this client."
    Is there any way that I can directly change the worklist in production system?
    Thanks.
    Jiajia

    Hi SUN,
    Take a look at 11g Grid Control: Steps for Migrating the 11g Grid Control Repository from One Database to Another [ID 1302281.1]. Step 4.7
    and
    http://gavinsoorma.com/2010/10/11g-grid-control-how-to-change-the-oms-repository-database-listener-port-or-hostname/
    ps Stop the OMS first.
    Eric

  • How to change the language of administrator system message in outlook

    I wonder where is the option which changes the language of the text
    related
    to : Your mailbox is over its size limit send by the system
    administrator ?
    Some mailboxes get this message in French and other in
    English ?
    Is anyone can help me ?
    I work with French Outlook 2003 sp2 and
    English Exchange server 2000 sp3
    I try to change the regional setting on the
    server but nothing has changed.
    Thanks,

    Hi,
    Please refer to this duplicate thread below:
    http://social.technet.microsoft.com/Forums/en-US/5afe1e1a-82a9-445f-bcce-a76173ceb6bb/how-to-change-the-language-of-administrator-system-message-in-outlook?forum=outlook
    Regards,
    Melon Chen
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • How to change the sender name "workflow system" to Diff name

    Hi ,,
      How to change the mail sender name that is "workflow system" to different name. Whenever the mail is triggered it shows the sender name as "workflow system" . i want to change the name of the sender..Even i changed the name of the WF-Batch(name) user but no use.. Pls advice.
    regards,
    Roops.

    Hi Roops,
    Check if the following [link1|Re: How to change text of wf batch??] [link2|Update should not happen in the name of WF-BATCH] helps you.
    Regards,
    Saumya

  • My ipad mini ID code is forgetten, and its system is also broken and how to change the ID and restore the system?

    my ipad mini ID code is forgetten, and its system is also broken and how to change the ID and restore the system?

    Hi ..
    Follow the instructions here >  iOS: Forgotten passcode or device disabled after entering wrong passcode

  • My system of iphone is english, why the app store is german? How to change the language of app store?

    My system of iphone is english, why the app store is german? How to change the language of app store?

    This changes the actual store. There are dozens of stores. Each store is posted in ONLY ONE LANGUAGE. Changing the country (actually, it changes the store) doesn't change the language. The language is hard-fixed for the particular country's store. You cannot change the language of the store. You can only change the store. The German Store is always in German. You can change to the U.S. store, but you can NEVER download / purchase anything from a different store than the one where you first got your Apple ID.
    You could create a new Apple ID in the U.S. store, but that is only allowed WHILE YOU ARE LOCATED IN THE U.S. This is the most annoying limitation of the Apple ID and flies in the face of Apple's attempt to present a globe-trotter image for their customers.

  • How to change the default time?

    when you finish the action of dialing ,the CCM system recognize your finish after 10s .How to change the default time in Service Parameters ,which is the detail Parameters ?

    Please see the following link for information on configuring the interdigit timeout.
    http://www.cisco.com/en/US/products/sw/voicesw/ps556/products_tech_note09186a00800dab26.shtml
    Hope this helps. If so, please rate the post.
    Brandon

  • How to change the default currency in CJ32 and CJ33

    Dear all,
    As required by the user, I want to know how to change the default currency from controlling area currency to object currency in TCODE CJ32 and CJ33. Currently, the controlling area currency will be defaulted in the field "Views in".
    Could any one help me? Points will be awarded.
    Thank you.
    Christina.
    Edited by: Virendra Pal on May 5, 2010 8:34 AM

    Hi Christiana ,
    Once you are in tcode CJ30 / CJ32 , Enter either Project definition or WBS element and this shall take you to the Budget screen and once you are here you can find a drop down with two options .One is Controlling are currency and the other one is Object currency.
    Since the Currency is set to Object currency in OPS9, System shall allow the budget values in Object currency and if the user wants to see the same values in Controlling are currency ,then the user needs to view the values in Controlling are currency using the drop down .
    Regards
    Judy

  • How to change the default port of webdispatcher

    Hello Everyone,
    We wish to  know to how to change the default port of SAP webpatcher port from 81$$ to 80.
    Appreciate your response.
    Thanks,
    Vadi

    Hello Vadi
    you have to change the PORT value in your profile parameter from 81$$ to 80
    icm/server_port_0 = PROT=HTTP,PORT=81$$ to
    icm/server_port_0 = PROT=HTTP,PORT=80
    Also, in SMICM, then change http service port and activate it and above parameter will require SAP restart
    $$ is used generally to accomodate multiple port services running in SMICM and so as to avoid the parameter setting according to instance number of any system.
    thanks
    Bhudev

  • How to change the default structure when exporting data in CSV format?

    Hello,
    can some one tell us how to change the default structure in CRM when exporting lists in CSV format (with Option "Always use unformatted list format (CSV) for download" ? Because we want to add a new structure for our own -is it possible ?
    If it is possible where can we find these structure ? In the blueprint customizing ?
    Thank you very much,
    Christian

    There is a workaround to move from 1.5 version to the older 1.4 version. But this could be specific to the browser setting the JRE version.
    Excerpts from sun docs:
    However, a user can still run older versions. To do so, launch the Java Plug-in Control Panel for the older version, then (re)select the browser in the Browser tab.
    Example:
    Assume you are running on Microsoft Windows with Microsoft Internet Explorer, have first installed version 1.4.2, then version 5.0, and you want to run 1.4.2.
    Go to the j2re1.4.2\bin directory where JRE 1.4.2 was installed. On a Windows default installation, this would be here: C:\Program Files\Java\j2re1.4.2\bin
    Double-click the jpicpl32.exe file located there. It will launch the control panel for 1.4.2.
    Select the Browser tab. Microsoft Internet Explorer might still appear to be set (checked). However, when 5.0 was installed, the registration of the 1.4.2 JRE with Internet Explorer was overwritten by the 5.0 JRE.
    If Microsoft Internet Explorer is shown as checked, uncheck it and click Apply. You will see a confirmation dialog stating that browser settings have changed.
    Check Microsoft Internet Explorer and click Apply. You should see a confirmation dialog.
    Restart the browser. It should now use the 1.4.2 JRE for conventional APPLET tags.
    Details are here
    http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/jcp.html
    My system (Windows XP) has the version 1.5_09 set as the default. However i just installed JRE 1.5_06 and would like to revert back to _06 as the default JRE..
    Will update if i find more information

  • How to change the default date in Person assignment tab?

    Hi experts,
    Does anyone know how to change the default date in person assignment tab in cj20n? Currently, the system always take the scheduled finish date to the date of the person assignment tab. Can I change it to the start date?
    Thanks and rgs,
    Michelle

    Hi Michelle,
    Goto SPRO->Project system->Dates->Scheduling->Specify Parameters for Network Scheduling, Here you can control the workforce planning dates.
    Hope this is useful...
    Regards
    Aatish

Maybe you are looking for