Get instantly the coordinate of end and start point of line, when moving it

hello guys,
i'm just wondering on how to get the coordinate of Start and End point of a line when I'm using PathWrangler wrangler = new PathWrangler(this); this latter allows the paint components to be dragged, so i want to get instantly the coordinate of the Start and End point of the line.
MY AIM IS: i want whenver an intersection between 2 lines occur( the line is being dragged so intersection may occur between the two lines) i want to draw a circle having as center the intersection of the 2 lines.
i managed to write a code that draws 2 lines and a circle having a center the intersection of both lines. here is the code:
import java.awt.*; 
    import java.awt.event.*; 
    import java.awt.geom.*; 
    import java.util.*; 
    import java.util.List; 
    import javax.swing.*; 
    import javax.swing.event.MouseInputAdapter; 
    public class SDRx extends JPanel { 
       List<Path2D.Double> paths = new ArrayList<Path2D.Double>(); 
       PathWrangler wrangler = new PathWrangler(this);
       Point p1= new Point(120,150);
       Point p2= new Point(140,210);
       Point p3= new Point(120,150);
       Point p4= new Point(110,230);               
        Line2D.Double l1=new Line2D.Double(p1,p2);
       Line2D.Double l2=new Line2D.Double(p3,p4);
        Point2D.Double inter= intersection(l1.getX1(),l1.getY1(),l1.getX2(),l1.getY2(),l2.getX1(),l2.getY1(),l2.getX2(),l2.getY2());
       Ellipse2D.Double ell= new Ellipse2D.Double(inter.getX()-25,inter.getY()-25,50,50);
       public SDRx() { 
           paths.add(wrap(l1));
           paths.add(wrap(l2));
           paths.add(wrap(ell));             
       private Path2D.Double wrap(Shape s) { 
           return new Path2D.Double(s); 
       protected void paintComponent(Graphics g) { 
           super.paintComponent(g); 
           Graphics2D g2 = (Graphics2D)g; 
           g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
                               RenderingHints.VALUE_ANTIALIAS_ON); 
           g2.setPaint(Color.blue); 
           for(int j = 0; j < paths.size(); j++) { 
               g2.draw(paths.get(j)); 
       public void transformPath(Path2D.Double path, AffineTransform at) { 
           path.transform(at); 
           repaint(); 
        public Point2D.Double intersection(double x1,double y1,double x2,double y2, double x3, double y3, double x4,double y4) {
      double d = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4);
      if (d == 0) return null;
      double xi = ((x3-x4)*(x1*y2-y1*x2)-(x1-x2)*(x3*y4-y3*x4))/d;
      double yi = ((y3-y4)*(x1*y2-y1*x2)-(y1-y2)*(x3*y4-y3*x4))/d;
    return new Point2D.Double(xi,yi);
       public static void main(String[] args) { 
           JFrame f = new JFrame(); 
           f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
           f.add(new SDRx()); 
           f.setSize(400,400); 
           f.setLocation(100,100); 
           f.setVisible(true); 
   }any help is appreciated.
10x

OK guys i'm sorry for before i said few wrong things about PathWrangler wrangler = new PathWrangler(this); i thought it was in the java library.
anyway here is the full code( i got it few weeks ago(with few modidfication) from somwhere, u can google it)
    import java.awt.*; 
    import java.awt.event.*; 
    import java.awt.geom.*; 
    import java.util.*; 
    import java.util.List; 
    import javax.swing.*; 
    import javax.swing.event.MouseInputAdapter; 
    public class SDRx extends JPanel { 
       List<Path2D.Double> paths = new ArrayList<Path2D.Double>(); 
       PathWrangler wrangler = new PathWrangler(this);
       Point p1= new Point(120,150);
       Point p2= new Point(140,210);
       Point p3= new Point(120,150);
       Point p4= new Point(110,230);               
        Line2D.Double l1=new Line2D.Double(p1,p2);
       Line2D.Double l2=new Line2D.Double(p3,p4);
        Point2D.Double inter= intersection(l1.getX1(),l1.getY1(),l1.getX2(),l1.getY2(),l2.getX1(),l2.getY1(),l2.getX2(),l2.getY2());
       Ellipse2D.Double ell= new Ellipse2D.Double(inter.getX()-25,inter.getY()-25,50,50);
       public SDRx() { 
           paths.add(wrap(l1));
           paths.add(wrap(l2));
           paths.add(wrap(ell));             
       private Path2D.Double wrap(Shape s) { 
           return new Path2D.Double(s); 
       protected void paintComponent(Graphics g) { 
           super.paintComponent(g); 
           Graphics2D g2 = (Graphics2D)g; 
           g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
                               RenderingHints.VALUE_ANTIALIAS_ON); 
           g2.setPaint(Color.blue); 
           for(int j = 0; j < paths.size(); j++) { 
               g2.draw(paths.get(j)); 
       public void transformPath(Path2D.Double path, AffineTransform at) { 
           path.transform(at); 
           repaint(); 
        public Point2D.Double intersection(double x1,double y1,double x2,double y2, double x3, double y3, double x4,double y4) {
      double d = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4);
      if (d == 0) return null;
      double xi = ((x3-x4)*(x1*y2-y1*x2)-(x1-x2)*(x3*y4-y3*x4))/d;
      double yi = ((y3-y4)*(x1*y2-y1*x2)-(y1-y2)*(x3*y4-y3*x4))/d;
    return new Point2D.Double(xi,yi);
       public static void main(String[] args) { 
           JFrame f = new JFrame(); 
           f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
           f.add(new SDRx()); 
           f.setSize(400,400); 
           f.setLocation(100,100); 
           f.setVisible(true); 
   class PathWrangler extends MouseInputAdapter { 
       SDRx component; 
       AffineTransform at = new AffineTransform(); 
       final int S = 6; 
       Rectangle net = new Rectangle(S, S); 
       Path2D.Double selectedPath; 
       Point offset = new Point(); 
       boolean dragging = false; 
       public PathWrangler(SDRx sdr) { 
           component = sdr; 
           component.addMouseListener(this); 
           component.addMouseMotionListener(this); 
       public void mousePressed(MouseEvent e) { 
           Point p = e.getPoint(); 
           net.setLocation(p.x-S/2, p.y-S/2); 
           List<Path2D.Double> list = component.paths; 
           for(int j = 0; j < list.size(); j++) { 
               Path2D.Double path = list.get(j); 
               // Use the contains method to detect RectangluarShapes 
               // and the intersects method with net to detect lines. 
              if(path.contains(p) || path.intersects(net)) { 
                   selectedPath = path; 
                   Rectangle r = selectedPath.getBounds(); 
                   offset.x = p.x - r.x; 
                   offset.y = p.y - r.y; 
                   dragging = true; 
                   break; 
       public void mouseReleased(MouseEvent e) { 
           dragging = false; 
       public void mouseDragged(MouseEvent e) { 
           if(dragging) { 
               int x = e.getX() - offset.x; 
               int y = e.getY() - offset.y; 
               Rectangle r = selectedPath.getBounds(); 
               at.setToTranslation(x-r.x, y-r.y); 
               component.transformPath(selectedPath, at);
   }  10x

Similar Messages

  • When i set iphoto to 'fit slideshow to music' the song cuts off before the end and starts again.  Anyone know why?

    I have tried changing the seconds each slide displays for and fiting the slides to the music and no matter what I do the song cuts off 30-40 seconds before it actually ends and starts again.  I haven't had this problem before.

    Hi kjackson73,
    Thanks for visiting Apple Support Communities.
    If the same songs seem to cut out on multiple devices, first try re-importing or converting them using iTunes. You can also download iTunes Store purchases again. See these articles for more information:
    iPhone and iPod touch: Songs or other audio content are skipped during playback
    http://support.apple.com/kb/TS3159
    If the original CD is available, remove the affected content from the iPhone or iPod touch and then import it again from the CD using iTunes.
    If the original CD is not available, convert the content to AAC using iTunes.
    Download past purchases
    http://support.apple.com/kb/HT2519
    Best,
    Jeremy

  • My video download gets about 2/3 of the way through, stops, and starts over

    My video download gets about 2/3 of the way through, stops, and starts over (as if I had never downloaded anything). I have DSL, and it's the only video downloading. Why does it stop and start all over again, over and over? It's really bumming out my iTunes experience. Oh, and I'm running XP, not XPpro.

    Let it go... these DL's take forever, depending on the spped of your connection and the traffic on the servers.
    If by morning it is still sitting there restart and the DL should pick up from where it left off.

  • Getting all the members (variables, methods AND method bodies) of a java source file

    For a project I want to programmatically get access to the members of java source file (member variables, methods etc) as well as to the source code of those members. My question is what is the best method for this? So far I have found the following methods:
    Use AST's provided by the Java Source API and Java Tree API, as discussed in the following posts:
    http://today.java.net/pub/a/today/2008/04/10/source-code-analysis-using-java-6-compiler-apis.html
    http://weblogs.java.net/blog/timboudreau/archive/2008/02/see_java_code_t.html
    http://netbeans.dzone.com/announcements/new-class-visualization-module
    This has the disadvantage that the classes actually have to be compilable. When I look at the Netbeans Navigator view however, it provides me with a nicely formatted UI list, regardless of the "compilable" state of the class.
    Thus I started looking at how to do this... The answer appears to be through the use of tools such as JavaCC: https://javacc.dev.java.net/
    ANTLR: http://www.antlr.org/
    which are lexers and parsers of source code. However, since the Navigator panel already does this, couldn't I use part of this code to get me the list of variables and methods in a source file? Does the Navigator API help in this regard?
    Another route seems to be through tools such as
    BeautyJ: http://beautyj.berlios.de/
    which run on top of JavaCC if I am correct, and which has the ability to provide a clean view on your java code (or an XML view). However, BeautyJ does not seem to be too actively developed, and is only j2se1.4 compatible.
    I hope someone can shed a light on the best way to go about what I want to achieve. Somebody already doing this?
    (I crossposted on the Netbeans forums too, hope this is OK...)

    I'm currently developing a LaTeX editor(MDI) and I do the same thing, but I don't know what exactly do you need.

  • HT1414 using Windows 7 OS, I had downloaded the new ioS 6 and started the update on the iPhone 4 and everything was going routine until the phone had been going thought what I though

    I attempted to update my iPhone 4 from ioS 5 to ioS 6 from iTunes on my laptop using Windows 7 OS, I had downloaded the new ioS 6 and started the update on the iPhone 4 and everything seemed to be going routine until the phone had been going thought what I though was the update process, when an error window opened up and it said that an error had occured and the iPhone 4 could not be updated. I have never had a problem like this before and it caught me off guard and I did not note all the information in the error window, but it did not appear to indicate anything other than that I would have to abort the update and did not think it would be that big of a problem. I tried to disconnect the phone and was going to do the update at a different time when I could investigate what the problem was. However I could not get iTunes to recognize the iPhone 4 after this and still cannot. After rebooting the laptop a few times and also trying to reset the phone a few times as well, I just have a dead phone. The iPhone 4 just has the image of a USB cable with an arrow pointing to an icon for iTunes. I have tried to get iTunes to recognize the iPhone, but cannot get it to. I am unable to do anything else with the phone. It seems like the phone is in a state where it does not have enough software loaded to do anything or I don’t know how to get it to. Any suggestions how I can get my iPhone 4 back into service. Note: iTunes still recognizes my iPad and iPods, so iTunes seems to be okay to me. Craig

    I had this problem on my iPod Touch 4g. Just press the home and sleep button. Wait and it will give an iTunes and cable logo. Now you can put in DFU mode (Hold Sleep and Home button 10 seconds and then release the power button kand keep pressing on the home button.) Now you will be able to restore it in iTunes.
    If you didn't sell it in al this time

  • Need to get all the files, well music and video, from my ipod touch 5th gen to my itunes libary.

    Need to get all the files, (well music and video), from my ipod touch 5th gen to my itunes libary. (So basically sync the other way to normal)
    Laptop hard drive broke so had to buy a new one and obviously now need to sort out my itunes.
    Did try downloading all my purchased stuff onto itunes but it has missed some things off, and there are some files I did not purchase from itunes so need a way of getting them back on there.
    Sure this question has been asked a million times but can't find anything to help me on here so thought I'd ask.
    -Did have a look at going onto the start menu and opening the hidden items thing but couldn't see any reference to ipod or device on it so wasn't sure how to do it that way.
    -On itunes under my device when its connected, the section about manually restoring and backing up, would that help me? Because that says it will manually back up my ipod to my computer then could restore that back up, obviously I don't want to accidnetally get rid of everything on my ipod so didn't want to try that just in case without checking.
    (And yes I have disabled auto sync to device when conncected!)
    Can anyone help me please? Sorry if i've overcomplicated this!
    Thanks:)
    Chris

    Backing up an iOS device will copy some data to a backup file within iTunes, but this excludes all media.  You can also transfer iTunes Store purchases from the iDevice to iTunes but, without using a third-party tool, nothing else.  As long as you do not sync the iPod with your new library, the media that's on it will remain ... for as long as it keeps functioning, is not lost, stolen, eaten by the dog, ...
    You may also have an option to recover your previous library from your old laptop; as long as its hard drive isn't fried, a computer repair store or technician may be able to extract the drive, mount it in an external enclosure, and copy your data to another PC.  Whatever you choose, there is no real alternative to having all your media on your computer, managed by iTunes, and regularly backed up to another device/location.

  • I always have trouble with my mailbox. It is always asking for my passwords but everything has been verified. How can I get it to stop doing it and start working????

    I always have trouble with my mailbox. It is always asking for my passwords but everything has been verified. How can I get it to stop doing it and start working????

    There is only one thing that happens -- the Server does not respond.
    Your mac concludes that you must have entered the wrong password. That may happen once, but then other issues become more likely, and it keeps asking for a new password.
    Sometimes the Server is down for maintenance. Sometimes something is configured wrong. Some services do this on purpose to get you to use WebMail (pick up your Mail with your Browser) so they can show you some ads.

  • I have a brand new macbook pro that i was doing a data transfer from an old macbook, it got stopped/cable pulled out, now have spinning wheel of death that wont stop, how do i reboot/stop the wheel of death and start again?

    i have a brand new macbook pro that i was doing a data transfer via firewire from an old macbook, it got stopped/cable pulled out, now have spinning wheel of death that wont stop, how do i reboot/stop the wheel of death and start again? (this time il use time machine transfer)

    Just power off the machine(s). Shut them down. Migration Assistant gets 'stuck' sometimes - best way to migrate really isn't over Firewire, though it will certainly work, but with both machines hardwired via Ethernet to the same router. You can use a TM backup, too, of course, provided that it's recent. Which is the best? Your choice. I've done it both ways and have a preference for MA, but TM restore can be a bit faster and less quarrelsome.
    Clinton

  • I have messed my MacBook Pro attempting to customize it. I am far from savvy with technology and I would like to erase and reset it to out of the box brand new and start over

    I have messed my MacBook Pro attempting to customize it. I am far from savvy with technology and I would like to erase and reset it to out of the box brand new and start over

    Polly,
    usually there are multiple models of MacBook Pro per model number, but in the case of your model number (A1502), there’s currently only one model for that model number: 13-inch Late 2013.
    To reset your MacBook Pro, you’ll need to boot into Recovery mode by holding down a Command key and the R key as you start it up. When the Mac OS X Utilities menu appears, select Disk Utility. On the left-hand side of the Disk Utility window, select your internal disk (most likely the top item of the list). On the right-hand side, select the Erase tab. For the Format dropdown, select “Mac OS Extended (Journaled)”. For the Name input box, “Macintosh HD” has traditionally been the default name — I don’t know if that’s still the case for the Late 2013 models. After that, press the Erase… button, and erase its entire internal disk. When it’s finished with the erasure, exit Disk Utility, and select Shut Down from the Apple menu. When you start it up again, OS X Internet Recovery will redownload Mavericks from Apple’s servers and reïnstall it on your internal disk. Once it has reïnstalled, run Software Update to get it up to date, and adjust the System Preferences to your taste.

  • I have a Macbook pro mid 2011 and just bought the Apple TV. While watching program or movie from any of the apps such as Watch ABC, the program keeps stopping and starting constantly.

    I have a Macbook pro mid 2011 and just bought the Apple TV. While watching program or movie from any of the apps such as Watch ABC, the program keeps stopping and starting constantly.

    That would indicate a network issue.
    Reboot ATV and router
    Make sure DNS is set to auto
    Ensure router is up to date, if on wifi try ethernet
    Go to istumbler.net to get a report of the network, look for signal strength and noise

  • Tell me please, is there any way to unlock my iPhone, if the contract is ended and I moved to Ukraine

    Tell me please, is there any way to unlock my iPhone, if the contract is ended and I moved to Ukraine

    1. Try doing a hard reset:
    Press and hold both the Home button and the Sleep/wake button simultaneously for about 15 seconds and release when the Apple logo appears.
    2. If that doesn't solve the issue, backup the device and restore it as new.
    In that case, use: http://support.apple.com/kb/HT4137
    NB: set up as a NEW device because a software issue will be in the backup. If the issue persists after restoring as new, you should offer the device for service.
    If you get specific error messages/codes in iTunes when updating/restoring, check this: http://support.apple.com/kb/ts3694 for causes and solutions
    Good luck
    Stijn

  • Every time I get to the stage "uploading artwork and remaining songs" I get the following error :  "ITunes as stopped working"

    I have an issue with ITunes match. Every time I get to the stage "uploading artwork and remaining songs" after 5-10 items have been uploaded I get the following error message :
    "ITunes as stopped working. a problem caused the program to stop working correctly."
    _ Windows 7 (up to date)
    _ ITunes => up to date  => 11.0.2.26
    _ I've already re-installed ITunes and all his components => same issue
    _ this error only appear at the stage "uploading artwork and remaining songs"
    errors found in Windows logs :
    1/ Bonjour Service :
    Client application bug: DNSServiceResolve(d8:d1:cb:e8:f5:14@fe80::dad1:cbff:fee8:f514._apple-mobdev._tc p.local.) active for over two minutes. This places considerable burden on the network.
    2/ Application error:
    "Faulting application name: iTunes.exe, version: 11.0.2.26, time stamp: 0x51253247
    Faulting module name: KERNELBASE.dll, version: 6.1.7601.18015, time stamp: 0x50b83b16
    Exception code: 0x80000003
    Fault offset: 0x0003491e
    Faulting process id: 0xf34
    Faulting application start time: 0x01ce2bc093c6d4b0
    Faulting application path: C:\Program Files\iTunes\iTunes.exe
    Faulting module path: C:\Windows\system32\KERNELBASE.dll
    Report Id: 5e7e1edc-97ba-11e2-9678-00123f3961ed

    Hope that the following can help some of you having the same issue :
    When I run the Network Diagnostics in iTunes. And I got the following error : 
    "Secure link to iTunes Store failed".
    So I followed this tread and this is what I tried so far :
    https://discussions.apple.com/thread/3911927?start=0&tstart=0
    ipconfig /flushdns         => same issue
    netsh winsock reset       => same issue
    Followed the kb TS4123  => no other Winsock Providers that Bonjour
    SFC /SCANNOW    => same issue
    ipconfig /release    => same issue  
    ipconfig /renew         => same issue
    netsh winsock reset catalog   => same issue
    After doing all this tests when I run the Network Diagnostics I still get the same error : 
    "Secure link to iTunes Store failed".
    The strange thing is that I tried to start again the ITunes match and it's seems to work so far. 41 items uploaded and no crash so far (before it was  always crashing before I could reach 10 upload).

  • TS1307 My email won't send as when it was set up an extra letter was accidentally inserted in the address. I need to know how to remove the entire email address and start a fresh.

    My email won't send as when it was set up an extra letter was accidentally inserted in the address. I need to know how to remove the entire email address and start a fresh.

    Launch Mail.app, select Mail > Preferences... > Accounts and select the account you need to edit in the left column.
    The receiving information will be displayed for the selected Account, with a pop-up selector for the Outgoing Mail Server (SMTP) toward the bottom.  That selector shows which mail server will be used with this account; to send mail. 
    Click and hold on that selector, and scroll down (holding the mouse or trackpad clicked) to Edit Mail Server List... and you'll get a sheet dropping down with the mail servers listed. 
    Select the problematic mail server, and edit it using the Account Information and Advanced items on that sheet.

  • I want to be able to clear the bookmarks on icloud and start again

    i want to be able to clear the bookmarks on icloud and start again, ive tried deleteting all my favorites in ie10 and then merging, but it still keeps some.
    i have cleared my iphone and stopped merging, i have deleted al my favorites and merged the empty favorites, but i have favorits that keep coming back
    help

    This won't be real-time as you record, but you could tweak the EQ in real-time after the recording thus:
    Record what you want to tweak into GB with no effects.
    Solo the track and output it into something like Audacity.
    Start Audacity recording, then play your track in GB as you make those tweaks. That's what Audacity will record.
    Get that file from Audacity and put it into GB, then you'll have that effect.
    Sorry if it's complicated, but that's what came to mind. Hope it works.

  • Curve 8900 won't get past the T-Mobile screen on start-up

    I am hoping that someone out there can help. My T-Mobile BlackBerry Curve 8900 does not make it past the T-Mobile screen on start-up. The battery was fully charged when this happened. Personally, I think it has to do with iHeart Radio crashing, but I could be wrong. I have tried to plug the USB cord into a rear port on my laptop and launch the Blackberry Desktop Manager to see if I could do anything, but nothing happens. The BB Desktop Manager does not connect to the phone, because it is not getting past the T-Mobile screen on start-up. Not sure what to try.

    Hey VTX1300R,
    Do you have a recent backup of you device? If so the you may want to try to do a reset to factory on the device. Have a look at this article to see how to do it. http://bit.ly/98bCNO
    -SR
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

Maybe you are looking for

  • What is the best way to capture the Form data Temporarly

    Hi, I have a form with lot of validations. Suppose user entered some of the fields and he decided to fill rest of the field later on. So he now want to save the record temporarly without applying any validation and next time when user logs in, the fo

  • Why cann't I make calls even though I have subscri...

    I just subscribed for a month unlimited. I made three calls to China. But after that I cannot call any number no matter it's China or America. Who can help me? Thanks!

  • How to set a backgound pic for the panel

    I use a JTable as a member of a JPanel Object, and I want to set a backgound pic for the panel ,How to?

  • Recommendation for storing/archiving AVCHD material

    I'm sure this isn't a new question but after a bit of searching I still wasn't able to find it on this forum. I have one of the newish Sony consumer cameras with flash memory. I use Log and Transfer in FCE to import the footage and that's all good. H

  • Time machine lost back ups after Mavericks "upgrade"

    I upgraded to mavericks yesterday after doing a time machine back up. Installation went well but this morning my imac had to back up 500GB and when that was done all of my old back ups are gone. When I enter time machine it just has 3 hours of back u