Java2D graphics -GIS (Help pls)

Hey!...
My Applet is basically split into two parts....a JTree on the left and a text area on the right...i have two arrays...x3Points and y3Points that contain the map co-ordinates that are retrieved from the server side. They contain data like following for example.....
x3points (-119.169)
y3points (45.7601)
x3points (-119.259)
y3points (45.8506)
I am trying to display these points in the text area using the following code syntax....but nothing show up :(...can neone help pls!
for(int i=0;i<x3Points.length-1;i++)
g2.draw(new Line2D.Double(x3Points,y3Points[i],x3Points[i+1],y3Points[i+1]));
Thank You...An

if your using Swing than use JPanel and turn of opaque or make your one JComponent
if your using awt to build your application then use canvas.
if you need more information look in the swing part of the forum or look at java doc and tutor. I suggest to you to d/l the doc/tut of your specific j2se.

Similar Messages

  • Java2D graphics -GIS(pls help)

    Hey!...
    My Applet is basically split into two parts....a JTree on the left and a text area on the right...i have two arrays...x3Points and y3Points that contain the map co-ordinates that are retrieved from the server side. They contain data like following for example.....
    x3points (-119.169)
    y3points (45.7601)
    x3points (-119.259)
    y3points (45.8506)
    I am trying to display these points in the text area using the following code syntax....but nothing show up :(...can neone help pls!
    for(int i=0;i<x3Points.length-1;i++)
    g2.draw(new Line2D.Double(x3Points,y3Points,x3Points[i+1],y3Points[i+1]));
    Thank You...An

    I don't think you can paint graphics inside a JTextArea.
    import java.awt.*;
    import java.awt.geom.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.tree.*;
    public class ShowingPoints {
      public static void main(String[] args) {
        TreeNode root = new DefaultMutableTreeNode("Root Node");
        TreeModel model = new DefaultTreeModel(root);
        JTree tree = new JTree(model);
        tree.setPreferredSize(new Dimension(200,200));
        double[] xPoints = {
          -20.0, 15.5, 84.1, 65.3
        double[] yPoints = {
          12.9, 15.3, 19.0, 44.3
        LinePlotter lp = new LinePlotter(xPoints, yPoints);
        lp.setPreferredSize(new Dimension(200,200));
        JPanel panel = new JPanel();
        panel.add(tree);
        panel.add(lp);
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(new JScrollPane(panel));
        f.setSize(400,300);
        f.setLocation(300,300);
        f.setVisible(true);
    class LinePlotter extends JPanel {
      List xData, yData;
      final double PAD = 25.0;
      public LinePlotter(double[] xPoints, double[] yPoints) {
        xData = new ArrayList();
        yData = new ArrayList();
        for(int i = 0; i < xPoints.length; i++) {
          xData.add(new Double(xPoints));
    yData.add(new Double(yPoints[i]));
    setBackground(Color.white);
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);
    if(xData.size() == 0 || yData.size() == 0 ||
    xData.size() % 2 != 0 || yData.size() % 2 != 0 || xData.size()/yData.size() != 1)
    return;
    double
    xMin = ((Double)Collections.min(xData)).doubleValue(),
    xMax = ((Double)Collections.max(xData)).doubleValue(),
    yMin = ((Double)Collections.min(yData)).doubleValue(),
    yMax = ((Double)Collections.max(yData)).doubleValue();
    double
    width = getWidth(),
    height = getHeight(),
    yOffset = height - PAD,
    yDataOffset = (yMin >= 0 ? yMin : yMax > 0 ? 0 : yMax),
    xDataOffset = (xMin >= 0 ? xMin : xMax > 0 ? 0 : xMax),
    vertSpace = height - 2*PAD,
    vScale = vertSpace/(yMax - yMin),
    yOrigin = yOffset + (yMin > 0 ? 0 : yMax > 0 ? vScale*yMin : - vertSpace),
    horizSpace = width - 2*PAD,
    hScale = horizSpace/(xMax - xMin),
    xOrigin = PAD - (xMin >= 0 ? 0 : xMax > 0 ? hScale*xMin : - horizSpace);
    double x1, y1, x2, y2;
    for(int i = 0; i < xData.size(); i += 2) {
    x1 = xOrigin + hScale*(((Double)xData.get(i)).doubleValue() - yDataOffset);
    y1 = yOrigin - vScale*(((Double)yData.get(i)).doubleValue() - yDataOffset);
    x2 = xOrigin + hScale*(((Double)xData.get(i + 1)).doubleValue() - xDataOffset);
    y2 = yOrigin - vScale*(((Double)yData.get(i + 1)).doubleValue() - yDataOffset);
    g2.draw(new Line2D.Double(x1, y1, x2, y2));

  • My dear laptop has perished (graphically speaking) help pls:

    I own a HP Pavilion hdx9494nr and my graphics card has apparently stopped working all together, is this something I can replace myself and if so is it something I can upgrade?  My warranty was up a few months back so I'm not concerned with voiding anything,  ty for any assistance in advance.

    Good advice for almost all laptops, but not yours. That bad boy has a removable nVidia graphics card. It is HP Part No.
    454311-001. I do not believe it is upgradeable because it is not a fully standard MXM card but it can be replaced. There is also a replacement heatsink for the video card and while you are at it, you might want to replace it, too.
    Here is the Manual.
    Manual
    The Manual has a full parts list and instructions on disassembly.You can go through HP Partsurfer or just google the parts numbers and you will find vendors. I looked for a minute and could not find a specific price, but do not expect it to be cheap.

  • Adding JButtons to a Java2d Graphics program

    Hi,
    I apologise to all you seasoned programmers if this seems an easy question, but I can't seem to see the solution to this one.
    I'm trying to add 2 JButtons to an existing Java2D graphics program. When I run the program I get the following error,
    'java.lang.IllegalArgumentException: adding a window to a container'
    I can't seem to see how to correct this error. My current code is as follows,
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    public class PacMan2Clicks extends JFrame implements ActionListener {
        public static int mode = 0;
        private static JButton rightButton;
        private static JButton leftButton;
        public PacMan2Clicks() {
            Container contentPane = getContentPane();
            JPanel panel = new JPanel();
            leftButton = new JButton("Leftt");
            leftButton.addActionListener(this);
            panel.add(leftButton);
            rightButton = new JButton("Right");
            rightButton.addActionListener(this);
            panel.add(rightButton);
            contentPane.add(panel, BorderLayout.SOUTH);
        public void paintComponent(Graphics g) {
            Dimension d = getSize();
            Graphics2D g2 = (Graphics2D)g;
            int size = 100;
            Ellipse2D.Double head =
                    new Ellipse2D.Double(0, 0, size, size);
            Ellipse2D.Double eye =
                    new Ellipse2D.Double(size/2-1, size/5-1,
                    size/10, size/10);
            GeneralPath mouth = new GeneralPath();
            mouth.moveTo(size, size/4);
            mouth.lineTo(size/8, size/2);
            mouth.lineTo(size, size*3/4);
            mouth.closePath();
            Area pacman = new Area(head);
            pacman.subtract(new Area(eye));
            pacman.subtract(new Area(mouth));
            g2.setPaint(Color.yellow);
            g2.fill(pacman);
            g2.setPaint(Color.black);
            g2.draw(pacman);
        public void actionPerformed(ActionEvent event) {
            if(event.getSource().equals(rightButton)) {
            } else if(event.getSource().equals(leftButton)) {
        public static void main(String[] args) {
            JFrame frame = new JFrame("Drawing stuff");
            frame.add(new PacMan2Clicks());
            frame.setSize(600, 600);
            //frame.setContentPane(new PacMan2Clicks());
            frame.setVisible(true);
            frame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
    }Any help appreciated. Thank you.

    Your public class extends JFrame so it is a JFrame. In your main method you create a new JFrame and try to add the enclosing class (a JFrame by extension) to it. So you can either:
    1 &#8212; remove the JFrame extension from the class declaration and leave the code in the main method as&#8212;is:
    public class PM2C implements ActionListener {or,
    2 &#8212; leave the JFrame extension and remove the new JFrame instance in the main method.
    public class PM2C extends JFrame implements ActionListener {
        public PM2C(String title) {
            super(title);
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
            Container contentPane = getContentPane();
            JPanel panel = new JPanel();
            leftButton = new JButton("Leftt");
            leftButton.addActionListener(this);
            panel.add(leftButton);
            rightButton = new JButton("Right");
            rightButton.addActionListener(this);
            panel.add(rightButton);
            contentPane.add(panel, BorderLayout.SOUTH);
            setSize(600, 600);
            setVisible(true);
        public static void main(String[] args) {
            new PM2C("Drawing stuff");
    }

  • How to create matrix template help pls

    hi frs,
    i have generated xml file after creating matrix report in report builder.
    i want to know how to create matrix template(rtf) in word document.
    if i use wizard or insert> all fields i am not getting rtf like matrix.
    help pls
    Thanks
    Rajesh

    This issue is really becoming a problem for us. Does anyone have any examples of label templates. The label when generated automatically converts from pontrait to landscape. If you increase the size of the template then word complains about the page and margin size before printing.
    Anyone have any ideas?
    Thanks

  • My ipod touch screen is totally unresponsive and i have been using it under normal conditions. ihave tried the reset and restore but to no avail.everything works as it would normally do  on the screen.help pls????

    my ipod touch screen is totally unresponsive and i have been using it under normal conditions. ihave tried the reset and restore but to no avail.everything works as it would normally do  on the screen.help pls????

    Might want to post your question in the correct forum.  This is the iPHONE forum.

  • I have a MacBook Pro 15" laptop with Retina running OSX 10.8.5. It will not recognize that my android device (Samsung Galaxy Note3). I am using the standard USB that came out of the box to connect my device to my MAC. Deleted Kies 4 MAC. Help Pls!

    I have a MacBook Pro 15" laptop with Retina running OSX 10.8.5. It will not recognize that my android device (Samsung Galaxy Note3). I am using the standard USB that came out of the box to connect my device to my MAC. Deleted Kies 4 MAC. Help Pls!

    Dee002 wrote:
    MacBook's only have 2.0 USB ports.
    Wrong. 
    If you're not going to provide correct advice then don't repsond at all.
    http://www.apple.com/macbook-pro/specs-retina/

  • I made a mistake. i installed windows using boot camp without os x lion dvd. what should i do? help pls

    i made a mistake. i installed windows using boot camp without os x lion dvd. what should i do? help pls
    Re: can i install windows for pc on my mac or do i need the windows for mac? 

    There is no Lion DVD. Start Boot Camp Assistant and select the menu item to download the Windows Support Software.
    Read and follow the Boot Camp Installation Guide. http://manuals.info.apple.com/en_US/boot_camp_install-setup_10.7.pdf

  • I have Firefox 10.0.2. and OSX 10.6.8. and the latest PDF adobe reader, and still can not open with the browser PDF files.Can someone help,pls?Thanx

    Dear Ones,
    I have Firefox 10.0.2. and OSX 10.6.8. and the latest PDF adobe reader, and still can not open with the browser PDF files.Can someone help,pls?Thanx

    see if this is helpful : [http://support.mozilla.org/en-US/kb/Opening%20PDF%20files%20within%20Firefox Opening PDF files within Firefox]
    thank you
    Please mark "Solved" the answer that really solve the problem, to help others with a similar problem.

  • "Adobe Illustrator cs5 quit unexpectedly" error message. After I upgratded my imac to Mavericks I can't open Illustrater CS5. Help pls.

    "Adobe Illustrator cs5 quit unexpectedly" error message.
    After I upgrated my imac from Snow Leopard to Mavericks I can't open Illustrator CS5. (No problem with PS)
    Every opening attemp crashes. May this be possible because of third party plug-ins. (eg. Esko Artwork)
    Help pls.
    Thank you.

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Step 1
    For this step, the title of the Console window should be All Messages. If it isn't, select
    SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
    View ▹ Show Log List
    from the menu bar at the top of the screen.
    In the top right corner of the Console window, there's a search box labeled Filter. Initially the words "String Matching" are shown in that box. Enter the name of the crashed application or process. For example, if iTunes crashed, you would enter "iTunes" (without the quotes.)
    Each message in the log begins with the date and time when it was entered. Select the messages from the time of the last crash, if any. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    ☞ The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    ☞ Some private information, such as your name, may appear in the log. Anonymize before posting.
    Step 2
    In the Console window, select
    DIAGNOSTIC AND USAGE INFORMATION ▹ User Diagnostic Reports
    (not Diagnostic and Usage Messages) from the log list on the left. There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points down. You'll see a list of crash reports. The name of each report starts with the name of the process, and ends with ".crash". Select the most recent report related to the process in question. The contents of the report will appear on the right. Use copy and paste to post the entire contents—the text, not a screenshot.
    I know the report is long, maybe several hundred lines. Please post all of it anyway.
    ☞ If you don't see any reports listed, but you know there was a crash, you may have chosen Diagnostic and Usage Messages from the log list. Choose DIAGNOSTIC AND USAGE INFORMATION instead.
    In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.)
    ☞ Please don’t post other kinds of diagnostic report—they're very long and rarely helpful.

  • All of sudden, I can't launch iTunes as I get a popup saying "iTunes requires Quicktime 7.5.5 or later". I only have 7.4 currently and the apple site doesn't show anywhere to download Quicktime upgrade. Software Update detects no reqd updates. Help pls??

    all of sudden, I can't launch iTunes as I get a popup saying "iTunes requires Quicktime 7.5.5 or later". I only have 7.4 currently and the apple site doesn't show anywhere to download Quicktime upgrade. Software Update detects no reqd updates. Help pls??

    Here's a link to the QuickTime for Leopard 7.7 installer:
    http://support.apple.com/kb/DL761

  • Upgraded pc to ios7 but when syncing to iphone 4 it crashed. Phone is now in recovery mode but it nearly finishes recovery then stops with error 3014. Phone rendered useless until this is fixed. Help pls?

    Upgraded pc to ios 7 but when syncing to iphone 4 it crashed. Phone is now in recovery mode but it nearly finishes recovery then stops with error 3014. Phone rendered useless until this is fixed. Help pls? I have tried many of the suggestions for the error code given. Im getting frustrated. I'm not a techno so would appreciate simple terms or ways of explanation. Thx!!

    I have the exact same issue right now!

  • Sound on my phone has gone so when someone calls me they can hear me but i cant hear them.The ticks cant be heard when you press the keyboard. I've checked the settings and they are ok. can still hear music thru headphones but not without. Any help pls.

    sound on my phone has gone so when someone calls me they can hear me but i cant hear them.The ticks cant be heard when you press the keyboard. I've checked the settings and they are ok. can still hear music thru headphones but not without. Any help pls.

    Hey shahbazfromgbr,
    Thanks for the question, and welcome to Apple Support Communities.
    I understand you are having issues with sound output on your iPhone 4S. For troubleshooting steps, the following article provides the best information:
    iPhone: Can't hear through the receiver or speakers
    http://support.apple.com/kb/TS1630
    1. Verify that there is nothing plugged in to the headset jack, including headsets, headphones, or adapters.
    2. Make sure the Ring/Silent switch is not switched to silent.
    3. While on the Home screen, adjust the volume buttons. If you see the icon below, indicating that headphones are attached, there may be debris or an object lodged in the headset jack:
    4. Check the headset jack. If there is an object lodged in the headset jack that is not easily removed, have the iPhone serviced to remove object.
    5. For Original iPhone: If there is light debris, such as lint, in the headset jack, try connecting a pair of headphones to the headset jack and then remove the headphones. Repeat this several times to remove the debris.
    6. If you have installed a protective film on the display, either ensure that the receiver is not covered or remove the film completely.
    7. Check the receiver mesh (which is on the top front of the device, above the display). If it appears blocked, use a clean, small, dry, soft-bristled brush to carefully and gently brush away any debris.
    8. If you have paired with a Bluetooth headset that is nearby, either use the headset or turn Bluetooth off (choose Settings > General > Bluetooth).
    9. Restart the iPhone.
    10. If restarting the iPhone doesn't resolve the issue, try restoring the device.
    11. If the issue persists, go to the Service Answer Center - iPhone for information on service.
    Thanks,
    Matt M.

  • Can't send emails.  Can you help pls? Thanks.

    Hi, my Mac Book Pro won't let me send emails.  It says: Outgoing mail server (SMTP): Gmail Offline.  Can you help pls? Thanks.

    Help.  I have the same problem.  I can receive email but can not send email from my MacBook Pro running OS X 10.9.4.
    I have been reading posts about this issue until my eyes are rectangular.
    I have tried the following:
    1. Removing the passwords from the keychain.
    2. Trying the various ports (default set, custom 25 alone, custom 465 alone, custom 587 alone)
    3. Unticking the Use SSL box.   Interesting note, it sometimes self-ticks this box.
    4. Supplying full email name in the userid box.  Interesting note, it sometimes self-corrects to just the plain userid prefix.
    5. Running repair disk permissions
    6. Turning offline all mailbox accounts and then turning then back online.
    7. Rebooting numerous times
    8. Force Quit of Mail and numerous normal quits and restarts.
    9. All software updates have been installed.
    10.  I may have forgotten some of the more bizarre things I have tried but I have not got to the point of deleting the entire account (and all of its 3 years of emails). 
    I have a sister MacBook Pro (same operating system, larger screen, same ISP, same email provider, same power source, etc.) sitting right next to this one and it is working fine - mail comes in and mail goes out. It is on the same network and I have dutifully copied all of the parameters and this still does not solve the issue.  Surely, there is more witchcraft out there that I can try?   New to this "posting" process.  Not even sure how to get back to see if anyone has any further suggestions.  Thanks to all those who have tried to provide suggestions.  Much appreciated but I am still stuck with webmail!  Arghhhh. Ron

  • Error 4251 help pls....

    i try to burn cd and all i get is error 4251 i have tried to reduced the speed but still i keep getting this error message any help pls from anyone....

    Same thing has been happening to me. Hope someone can help!
    I burned one CD (there was an error message after burning) and it doesn't play properly. Subsequent attempts to burn the same playlist - and I tried a different playlist too, just in case it was that particular album - result in the error message mentioned in the above posting. It starts to burn, then ejects the cd with the message "error 4251", even when I select a slower write speed. Diagnostics show no problem, but it seems to test only for reading, not writing. Here's the diagnostic message I got:
    Microsoft Windows Vista x64 x64 Home Premium Edition Service Pack 1 (Build 6001)
    TOSHIBA Satellite E105
    iTunes 9.0.2.25
    QuickTime 7.6.4
    FairPlay 1.5.23
    Apple Application Support 1.0.1
    iPod Updater Library 9.0d11
    CD Driver 2.2.0.1
    CD Driver DLL 2.1.1.1
    Apple Mobile Device 2.6.0.32
    Apple Mobile Device Driver 1.45.0.0
    Bonjour 1.0.6.2 (118.5)
    iTunes Serial Number CBFABDA2556C6D0C
    Current user is not an administrator.
    The current local date and time is 2010-04-13 11:00:49.
    iTunes is not running in safe mode.
    Video Display Information
    Intel Corporation, Mobile Intel(R) 4 Series Express Chipset Family
    Intel Corporation, Mobile Intel(R) 4 Series Express Chipset Family
    ** External Plug-ins Information **
    No external plug-ins installed.
    iPodService 9.0.2.25 is currently running.
    iTunesHelper 9.0.2.25 is currently running.
    Apple Mobile Device service 2.50.39.0 is currently running.
    ** CD/DVD Drive Tests **
    No drivers in LowerFilters.
    UpperFilters: GEARAspiWDM (2.2.0.1),
    D: MATSHITA DVD-RAM UJ862ES, Rev 1.90
    Audio CD in drive.
    Found 16 songs on CD, playing time 71:31 on Audio CD.
    Track 1, start time 00:02:00
    Track 2, start time 04:44:53
    Track 3, start time 10:03:39
    Track 4, start time 14:58:64
    Track 5, start time 18:14:34
    Track 6, start time 22:28:43
    Track 7, start time 26:49:15
    Track 8, start time 31:10:28
    Track 9, start time 35:54:08
    Track 10, start time 40:10:03
    Track 11, start time 45:14:58
    Track 12, start time 49:45:24
    Track 13, start time 53:44:07
    Track 14, start time 58:27:16
    Track 15, start time 62:43:45
    Track 16, start time 66:39:60
    Audio CD reading succeeded.
    Get drive speed succeeded.
    The drive CDR speeds are: 4 8 12 16 24.
    The drive CDRW speeds are: 4.
    The drive DVDR speeds are: 4.
    The drive DVDRW speeds are: 4.
    Force Optical Power Calibration before burn is turned on in the preferences.
    The last failed audio CD burn had error code 4251(0x0000109b). It happened on drive D: MATSHITA DVD-RAM UJ862ES on CDR media at speed 8X.

Maybe you are looking for