How to draw non intersecting area of two GeneralPath

Hi all ,
I have two generalpath GP1 and GP2 .
GP1 and Gp2 are overlapping.
Im able to draw the overlapping region between the two .
I want to make the non overlapping area between these two generalpath .
Is there any API or method to draw that
Thanks and regards
Anshuman Srivastava

Not tested.
    public static Shape createNonOverlappingArea(Shape GP1, Shape GP2) {
      * Create an area that contains the total of GP1 and GP2.
     Area rv = new Area(GP1);
     rv.add(new Area(GP2));
      * Create an area that contains the overlap.
     Area overlap = new Area(GP1);
     overlap.exclusiveOr(new Area(GP2));
      * Subtract the overlap from the total area.
     rv.subtract(overlap);
      * Now rv contains the non overlapping parts.
     return rv;
    }Piet

Similar Messages

  • How  to delete songs that are in two playlists?

    How do I delete one copy of a song that is in two p[aylists?

    You almost certainly only have one copy of the song in your library. The song listings in a playlist are just "pointers" to the song, not duplicate copies. So if you want to remove the song from one of the playlists, just highlight the song in that playlist and press the "Delete" key.
    If you want to remove the song from both playlists, then unless you want to remove the song completely from your iTunes library, you'll have to delete the song from each playlist separately.
    Regards.
    Message was edited by: Dave Sawyer

  • How to tap non node area in a JTree

    how can I trap area of a JTree which does not constitute the node rows???

    selPath.getPathForLocation(me.getX(),me.getY())
    this function returns null if there is no rows. you cant track by this.
    Raheel

  • How to draw circle if I have two points info and radius of the circle?

    Hi,
    I am trying to draw circle.
    Inputs I have is 1. Two points of the circle and
    2. Radius of the circle.
    Please let me know if u have solution using Shape, Graphics2D apis.
    Thanks in advance..
    Cheers,
    Somasekhar

    As far as the drawing is concerned, you would use Graphics# drawOval. There's no API method to draw a circle using the parameters of two points and a radius.
    You need to solve the problem on paper and work out the maths involved, then translate that math into working Java code.
    btw, you do realize that the information will give you zero to two valid circles, don't you?
    db

  • The intersection point of two lines in 3D

    How to calculate the intersection point of two lines in 3D?
    source code!

    this is actually a rather easy operation. lets look at some basic properties of lines / vectors in 3D space:
    1. If two lines intersect at a single point, then there must be exactly one plane in which the two lines are co-planar. This is pretty trivial to prove, but I won't bother here, because you can google to find out that two vectors that extend from a common point define a single plane.
    2. If you take the cross-product of two vectors, the resulting vector is guaranteed to be perpendicular to both lines (this is a basic property of a cross-product). If the two lines intersect, then this cross-product will be the normal vector to the plane in which both lines lie.
    3. Now transform (rotate) yours space such that your z-axis becomes parallel to the normal vector of that plane.
    Now, the parametric equation for a line in 3D space is this:
    (x, y, z) = (xo, yo, zo) + k(xd, yd, zd)
    After you have transformed your space, you will notice that the equation of each line will now be
    (x, y, z) = (xo, yo, zo) + k(xd, yd, 0)
    If zo is equal for both lines, then the two lines intersect. Otherwise, the two lines do not intersect.
    if the intersection exists, then to solve for it, you ignore the z coordinate, and treat it like a two dimensional system:
    (x, y) = (xo, yo) + k(xd, yd)
    you can use the basic 2D formula y - yo = m(x - xo), or y = m(x - xo) + yo
    you can calculate m = yd / xd.
    which simplifies to y = mx -mxo + yo, or 0 = mx - y + (yo - mxo)
    you now have two equations of the form Ax + By + C = 0.
    From there, you can use Cramer's rule to find the intersection of the two lines.
    It sounds kind of complicated when you read it as I have presented it, but it's actually extremely easy to write a program for, because each step is simple mathematic operation with basically no decisions involved (hence no if-structures, except at the one point where you actually need to determine if the lines intersect).
    So to reiterate, the steps required are:
    1. Check if lines are parallel. If yes, check if they are the same line, and then stop.
    2. If not parallel, cross-multiply the direction vectors of each line.
    3. Rotate your space such that z is parallel with cross-product of lines
    i. dot-product of z axis (0, 0, 1) with cross-product of lines gives angle*
    ii. cross-product of z axis (0, 0, 1) with cross-product of lines gives axis of rotation.
    iii. rotate your lines (i.e. point and direction vector) about that axis by negative of ange determined in (i).
    4. if z value of points from both lines is the different, no solution. stop.
    5. otherwise, apply Cramer's rule.
    6. done.
    * obtaining the angle of rotation with the dot product relies on the angle being less than 90 degrees, so check if z value of normal vector is + or -, and then perform dot product and cross-product on appropriate + or - z vector.
    - Adam

  • Function to calculate how many working date there are.

    Good morning,
    there is a Function/Object to calculate how many working days there are between two dates?
    thanks
    M

    If you have problems finding in the forum the answer to this question, please re-post it and mention how you searched and how the results didn't help.
    Thread locked.
    Rob

  • How to draw a line of sin x and its area under the line?

    Hi,
    I know how to draw a line from two points. However, I do not know how to draw a line of function sin(x) and its area under the line. Anyone know where to read or how can I draw it, please help me. Thanks !!
    Calvin

    use Graphics2D:: draw(Shape)
    create a class that implements Shape, and specifically the getPathIterator methods, in these methods you should return a path iterator that follows the sin/cos curve.
    All fairly simple to do.
    rob,

  • How can I tell if signals from two devices are truly synchronised?

    Hi there,
    How does one check that signals from two devices (two separate devices in a single X-series chassis) that should be synchronised actually are?   I am using a PXIe6361 and PXIe4331 on a PXIe-1073, with Labview 2001 SP1 64-bit. All devices are using the Sample Clock from the 4331 device, and an AI Start Trigger, so they should be synchronised.
    I thought that writing the signal data to file and checking the time stamp for each column of data would be the most accurate, but I have been told that timestamps are software created and therefore don't reflect the actual time that the signals were acquired by the hardware.  When I do this, the timestamps vary by up to 150ms which is larger than I expected.
    If I set the x-axis of the waveform graphs (on the GUI) to "Time" then it appears that the first data sample is taken at different times for the two plots (one plot per device).
    If I set the x-axis of the waveform graphs (on the GUI) to "Ignore time stamp" (so that the x-axis just starts from 0 rather than a date-time) then the first data point occurs at "0" for both graphs. However, I'm not sure that this reflects the actual alignment of the signal.
    What is the best way to check if signals collected on different devices in the same chassis are actually synchronised?
    Thanks,
    Claire.

    Hi Lynn,
    Thanks for your help and for sending the demo.
    I understand the concept of how the signals will look if they're not synchronised and your demo shows that nicely. I guess I have been perplexed by someone else telling me that the timestamps in the output file (and following from that I assume timestamps on a waveform graph) do not give an indication of whether signals are synchronised. The reason they gave for this was that the timestamps are manufactured by the software, not the DAQ hardware.  They suggested that I put the setting "ignore waveform timestamps" on my waveform graphs, and then check that both signals come in at the same time (i.e. both start at zero), but I'm not convinced about this. 
    When I use an analog trigger, neither the timestamps in my output file or on the two waveform graphs are synchronised. If I don't use the trigger, then there is far less disparity in the timestamps in the output file. I've attached two output files here, and my VI.
    This is my first attempt to synchronise a voltage module and a strain gauge module on an X-series chassis, so I want to make sure that I'm achieving the best synchronisation that I can, and the difference in behaviour with and without the trigger worries me.
    Thanks,
    Claire.
    Attachments:
    without trigger.txt ‏5 KB
    with trigger.txt ‏6 KB
    Multi-Device Synch-Analog Input-Finite Acq-Analog Start_Claire_wDigitalin_12June2012 PTbridge.vi ‏196 KB

  • How to get the intersection of two arraylist containing user defined obj??

    How to get the intersection of two arraylist containing user defined obj??
    I can easily get the intersection of two array list which containing some simple class(Integer, String). But how to get the intersection of two arrayList which contain user defined object?
    Here is the sample code..I can not run this out...anybody can help me? thank you very much..
    The correct result should be like this:
    2
    2
    but I can only get this:
    2
    0
    import java.util.*;
    public class testRetain{
         public static void main(String[] args){
              ArrayList a = new ArrayList();
              ArrayList b = new ArrayList();
              a.add( new dog(1,2,2) );
              a.add( new dog(1,2,1) );
    System.out.println(a.size() );
              b.add( new dog(1,2,2) );
              a.retainAll(b);
    System.out.println(a.size() );
    class dog implements Comparable{     
         int head;
         int arms;
         int legs;
         dog(int head, int arms, int legs){
              this.head = head;
              this.arms = arms;
              this.legs = legs;
         public int compareTo(Object o){
              if ( ((dog)o).head > this.head )
                   return -1;
              else if ( ((dog)o).head < this.head )
                   return 1;
              else
                   return 0;
    }

    @Op. Your classes should override equals and hashCode
    Kaj

  • I recently deleted many duplicate files. In the midst of it my Itunes songs are not in Itunes. They are in two different folders. One under 'Music' in my ID. And two under a MyMusic file in Documents. How do I know which one to import?

    I recently deleted many duplicate files. In the midst of it my Itunes songs are not in Itunes. They are in two different folders. One under 'Music' in my ID. And two under a MyMusic file in Documents. How do I know which one to import?

    Thanks, this is not an ideal answer but probably the most sensible one in my case.
    I will try it unless someone has a better suggestion, but I'll wait a bit as it will take me a few days anyway (I had actually tried to create a new smaller playlist or download by album, but at this stage the music app is not letting me queue a list of songs for download - I think I will have to disable and re-enable iTunes match which will probably delete all the songs).
    I have to say I am not very impressed with Apple here - having an online backup of all your data and beeing able to restore it to a new device easily was a strong selling point of iCloud. For music, they are Definitly not delivering at the stage.

  • I only want itunes to hold the lossless files which are in two different folders. How do I do that?

    I have thousands of MP3 files which I no longer use and which are in my itunes library.
    I want itunes (version 11) to have in it's library only the MS Lossless format and the ALAC lossless format which are in two different folders. How do I achieve this?

    Delete the files you don't want, or cut & paste them to an alternate location if you want to archive them.
    What MS Lossless format? .wav?
    iTunes doesn't have any custom organization features, but you can change the location of the media folder and then selectively consolidate content to the new folder. This creates copies so you have to manually delete the originals. Alternatively I have a script called ConsolidateByMoving which does what it suggests. Thiis could be used to split the media into parallel subfolders within your existing media folder if you disable iTunes "Keep iTunes Media folder organized" option.
    tt2

  • How to draw a line(shortest distance)  between two ellipse using SWING

    how to draw a line(should be shortest distance) between two ellipse using SWING
    any help will be appreciated
    regards

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class ELine extends JPanel {
        Ellipse2D.Double red = new Ellipse2D.Double(150,110,75,165);
        Ellipse2D.Double blue = new Ellipse2D.Double(150,50,100,50);
        Line2D.Double line = new Line2D.Double();
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(Color.green.darker());
            g2.draw(line);
            g2.setPaint(Color.blue);
            g2.draw(blue);
            g2.setPaint(Color.red);
            g2.draw(red);
        private void connect() {
            double flatness = 0.01;
            PathIterator pit = blue.getPathIterator(null, flatness);
            double[] coords = new double[2];
            double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
            double min = Double.MAX_VALUE;
            while(!pit.isDone()) {
                int type = pit.currentSegment(coords);
                switch(type) {
                    case PathIterator.SEG_MOVETO:
                    case PathIterator.SEG_LINETO:
                        Point2D.Double p = getClosestPoint(coords[0], coords[1]);
                        double dist = p.distance(coords[0], coords[1]);
                        if(dist < min) {
                            min = dist;
                            x1 = coords[0];
                            y1 = coords[1];
                            x2 = p.x;
                            y2 = p.y;
                        break;
                    case PathIterator.SEG_CLOSE:
                        break;
                    default:
                        System.out.println("blue type: " + type);
                pit.next();
            line.setLine(x1, y1, x2, y2);
        private Point2D.Double getClosestPoint(double x, double y) {
            double flatness = 0.01;
            PathIterator pit = red.getPathIterator(null, flatness);
            double[] coords = new double[2];
            Point2D.Double p = new Point2D.Double();
            double min = Double.MAX_VALUE;
            while(!pit.isDone()) {
                int type = pit.currentSegment(coords);
                switch(type) {
                    case PathIterator.SEG_MOVETO:
                    case PathIterator.SEG_LINETO:
                        double dist = Point2D.distance(x, y, coords[0], coords[1]);
                        if(dist < min) {
                            min = dist;
                            p.setLocation(coords[0], coords[1]);
                        break;
                    case PathIterator.SEG_CLOSE:
                        break;
                    default:
                        System.out.println("red type: " + type);
                pit.next();
            return p;
        public static void main(String[] args) {
            final ELine test = new ELine();
            test.addMouseListener(test.mia);
            test.addMouseMotionListener(test.mia);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(test);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    Graphics g = test.getGraphics();
                    g.drawString("drag me", 175, 80);
                    g.dispose();
        private MouseInputAdapter mia = new MouseInputAdapter() {
            Point2D.Double offset = new Point2D.Double();
            boolean dragging = false;
            public void mousePressed(MouseEvent e) {
                Point p = e.getPoint();
                if(blue.contains(p)) {
                    offset.x = p.x - blue.x;
                    offset.y = p.y - blue.y;
                    dragging = true;
            public void mouseReleased(MouseEvent e) {
                dragging = false;
            public void mouseDragged(MouseEvent e) {
                if(dragging) {
                    double x = e.getX() - offset.x;
                    double y = e.getY() - offset.y;
                    blue.setFrame(x, y, blue.width, blue.height);
                    connect();
                    repaint();
    }

  • I have an iPad and an iPhone 6. They are on two different Apple ids. How do I do I change the Apple id on my phone to match my iPad?

    I have an iPad and an iPhone 6. They are on two different Apple ids. How do I do I change the Apple id on my phone to match my iPad?

    On the phone, go to Settings, and change the iCloud and iTunes Store AppleIDs (sign out of the one you have, sign into the one you want). Note that you can't transfer apps from one AppleID to another, so you may still be prompted for your old AppleID password to update any apps that you installed under that ID.
    Matt

  • How to garantee IDOC types are the same on two communicating sap systems.

    Hi all:
        how to garantee IDOC types are the same on two communicating sap systems,  including segments and versions, using bd64?
        what's more, what bd64 using for besides generating parter profiles,  must we use bd64 for outbound idocs?
        Thank you very much
    best regards ?

    Hi jingying Sony 
    You can compare the Idoc type and Version between Sender System and Reciver System.
    Use TCode SCMP and Compare the Table EDIMSG in Both System.
    This will solve your issue.
    Thanks
    Ramesh

  • Draw circle, intersects Ellipse2D need help

    looks like have a few error... i have no idea how to fix it now. help plz.
    Circle class file.
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.geom.Ellipse2D;
    import javax.swing.JOptionPane;
    public class Circle
         private double radius;
         private int centerX, centerY;
         private Color fillColor;
         public Circle()
              radius=0;
              centerX=0;
              centerY=0;
         public double getRadius()
              return radius;
         public void setRadius(double newRadius)
              radius=newRadius;
         public int getCenterX()
              return centerX;
         public int getCenterY()
              return centerY;
         public void setCenterX(int newCenterX)
              centerX=newCenterX;
         public void setCenterY(int newCenterY)
              centerY=newCenterY;
         public void setFillColor(Color newColor)
              fillColor=newColor;
         public Color getFillColor()
              return fillColor;
         public void draw(Graphics g)
              Graphics2D g2= (Graphics2D) g;
              radii=this.getRadius()
              if( radius>=0 )
                   g2.fill( Ellipse2D.Double(radii*2,radii*2,this.centerX-radii,this.centerY-radii));
              else
                   g2.fill( Ellipse2D.Double(0,0,centerX,centerY));
         public boolean intersects(Circle circle2)
              double radiusLength1 = this.getRadius();
              double radiusLength2 = circle2.getRadius();
              double totalRadius = radiusLength1+radiusLength2;
              double distance = Math.sqrt(
                   (Math.pow(this.centerX-circle2.centerX,2))+
                   (Math.pow(this.centerY-circle2.centerY,2))
              return boolean totalRadius >= distance;
    CircleComponent class code
    import java.awt.Color;
    import java.util.Random;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.geom.Ellipse2D;
    import javax.swing.JOptionPane;
    import javax.swing.JComponent;
    public class CircleComponent extends JComponent
         public static void CircleComponent (String[] args)
              double radius;
              Circle circle1,circle2;x
              circle1=new Circle();
              circle2=new Circle();
              circle1.setCenterX(200);
              circle1.setCenterY(100);
              circle2.setCenterX(100);
              circle2.setCenterY(200);
              Random generator= new Random();
              Color color1 = new Color (generator.nextInt(256), generator.nextInt(256), generator.nextInt(256));
              circle1.setFillColor(color1);
              Color color2 = new Color (generator.nextInt(256), generator.nextInt(256), generator.nextInt(256));
              circle2.setFillColor(color2);
              String input=JOptionPane.showInputDialog("Set the circle1's radius ");
              radius = Integer.parseInt(input);
              circle1.setRadius(radius);
              input=JOptionPane.showInputDialog("Set the circle2's radius ");
              radius = Integer.parseInt(input);
              circle2.setRadius(radius);
         public void paintComponent (Graphics g)
              Graphics2D g2= (Graphics2D) g;
              g2.setColor(color1);
              g2.draw(circle1);
              g2.setColor(circle2.getFillColor());
              g2.draw(circle2);
              //draw String intersectsResult
              g2.setColor(Color.BLACK);
              String intersectsResult;
              if (circle1.intersects(circle2))
                   intersectsResult="Two circles intersected";
              else
                   intersectsResult="Two circles not intersected";
              g2.drawString(intersectsResult,20,380);
    }

    looks like have a few error... i have no idea howto fix it now. help plz.
    what are the errors?
    copy and paste themI think the code simply "does not work" as expected ;)

Maybe you are looking for

  • Problems with exporting .jpg file in Indesign CS3

    Hello! I've used Indesign to create a memory book I would like to now place in another program to have printed (blurb is the company I'm using). Now that I have created the spreads I need to export each page individually as .jpg files, so that I can

  • Load Balancing in Report Server

    I'm running Reports 6.0 and OAS 4.0.8 and am using client/server legacy forms & reports. I'm calling reports (with parameter file) from a form. I'm calling the form using show.web_product and paramform=html. My problem is that I can't get the server

  • I can't update my Ipod Touch 2nd Generation to IOS 5, why?

    I would really like to get IOS 5. But when I plug my scond gen. Ipod Touch into Itunes, it says that 4.3.1 is the latest update. Please Help, thanks in advance. P.S: my pc is a Toshiba Satilite, running Windows Vista Home Premium, and I have Itunes 1

  • 9.5 and 10.1.2 reader with IE 8 save

    Unable to save any adobe files when launched via a browser. A click on the save button does not do anything. I tried 10.1.2 and same problem. I had used a trial version of nitro pdf and I don't know whether that could have caused it. But I uninstalle

  • Pix240  ProRes timecode isn't recognized by Premiere

    I'm on the latest version of Premiere CC. We just shot a ton of media with the Pix240. The files are ProRes HQ 1080 23.98. In quicktime 7 I can see the timecode just fine. In premiere every clip starts at 00:00:00:00. If I get the properties of the c