Area.subtract( Shape ) doesn't work on Shape Line2D.Double?

Hi all,
I'm working on a method that will return a Shape from a BufferedImage that has transparent values, much like the one that dfgstg developed in [this thread|http://forums.sun.com/thread.jspa?messageID=9809317] . I'm having trouble understanding the difference between using this ( I'll call it line mode 1 ):Shape = Area.subtract( new Area( new Line2D().getBounds2D ) ) and this ( I'll call it line mode 2 ):Shape = Area.subtract( new Area( new Line2D().getBounds() ) ). When I use line mode 1, nothing gets subtracted when you use vertical or horizontal lines. When I use line mode 2, things show up, but I get the sense that it introduces artifacts into the resulting shape. Why is it necessary to turn a Line2D into a rectangle in order to subtract it from an Area? Line2D implements the Shape interface, so theoretically, it should be able to be subtracted from an Area. A program to demonstrate this problem ( between line mode 1 and line mode 2 ) is attached. Dfgstg uses line mode 2. Why is this necessary?
// ShapeTest2.java
// --- this code should compile ---
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
class ShapeTest2 extends JComponent
    public static final int LINE_MODE_1 = 1;
    public static final int LINE_MODE_2 = 2;
    Area _shape;   
    int _radius;
    int _diameter;
    Point2D.Double _center;
    ShapeTest2( int mode, int diameter )
        _diameter = diameter;
        _radius = _diameter/2;
        _center = new Point2D.Double( _diameter/2.0, _diameter/2.0 );
        setPreferredSize( new Dimension( _diameter, _diameter ) );
        _shape = new Area(
            new Ellipse2D.Double(
                0, 0, _diameter, _diameter 
        switch( mode )
            case LINE_MODE_1:lineMode1();break;
            case LINE_MODE_2:lineMode2();break;
            default: break;                          
    private void lineMode1()
        Point2D p1 = new Point2D.Double();
        Point2D p2 = new Point2D.Double();
        double random1, random2, random3;
        boolean inside;
        // make and subtract fifty lines
        for ( int i = 0; i < 50; i++ )
            inside = false;
            // search random points until you find two that are
            // less than the radius' distance from the center
            while( inside == false )
                random1 = Math.random()*_diameter;
                random2 = Math.random()*_diameter;
                random3 = Math.random()*_diameter;
                // make sure they are horizontally related
                // they have y in common
                p1 = new Point2D.Double( random1, random2 );
                p2 = new Point2D.Double( random3, random2 );
                if ( ( p1.distance( _center ) < _radius )
                        && ( p2.distance( _center ) < _radius ) )
                    inside = true;
            _shape.subtract(
                new Area(
                    // notice the getBounds2D - it returns a Rectangle2D
                    // it also doesn't show up for some reason
                    new Line2D.Double( p1, p2 ).getBounds2D()
    private void lineMode2()
        Point2D p1 = new Point2D.Double();
        Point2D p2 = new Point2D.Double();
        double random1, random2, random3;
        boolean inside;
        for ( int i = 0; i < 50; i++ )
            inside = false;
            while( inside == false )
                random1 = Math.random()*_diameter;
                random2 = Math.random()*_diameter;
                random3 = Math.random()*_diameter;
                // make sure they are horizontally related
                p1 = new Point2D.Double( random1, random2 );
                p2 = new Point2D.Double( random3, random2 );
                if ( ( p1.distance( _center ) < _radius )
                        && ( p2.distance( _center ) < _radius ) )
                    inside = true;
            _shape.subtract(
                new Area(
                    // getBounds() returns a rectangle
                    new Line2D.Double( p1, p2 ).getBounds()
    @Override
    protected void paintComponent( Graphics g )
        super.paintComponent( g );
        Graphics2D g2d = ( Graphics2D )g;
        g2d.setColor( Color.BLACK );
        g2d.draw( _shape );
    public static void main( String[] args )
        JFrame frame = new JFrame( "ShapeTest2" );
        int diameter = 300;
        ShapeTest2 lineMode1 =
            new ShapeTest2( ShapeTest2.LINE_MODE_1, diameter );
        ShapeTest2 lineMode2 =
            new ShapeTest2( ShapeTest2.LINE_MODE_2, diameter );
        frame.setLayout( new FlowLayout() );
        frame.add( lineMode1 );
        frame.add( lineMode2 );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.setLocation( 100, 100 );
        frame.pack();        
        frame.setVisible( true );
}

Keep all of your shapes right where they are! To make your text into hyperlinks then, just insert another shape...make it big or small enough to cover your text. Go ahead and drag it right over your text. Now attach the hyperlink to this shape. Now in the INspector,click over to the Graphics tab and change the opacity of this shape to 1%.
You have now created a "hotspot" hyperlink over your text! All without moving any of your other shapes around! Publish and see the results... Let me know if it works out for you!

Similar Messages

  • Sound on my ipad only works when I enter my pass code and when I play games. But when I typed, however, or try to listen to music/YouTube/Netflix, the sound doesn't work. When I double tap and go to the task manager, the volume slider has no dot. Help?

    I did not have this problem earlier today. I haven't dropped it recently or any such thing. I have, however, used two different audio jacks today. Although it makes keyboard sounds when I type in my pass code, it doesn't make the sounds otherwise. I also tested the sound on temple run and it worked. My slider key is set to mute, not to lock screen. When I try to adjust the volume, it'll say "sound effects" and the volume will be turned all the way down, but it won't let me turn it up. I got this iPad in December and unfortunately did not purchase AppleCare and I believe the warranty has passed. Any suggestions as to what's wrong?

    Try A and B
    (A) Restart iPad
    1. Hold down the Sleep/Wake button until the red slider appears.
    2. Drag the slider to turn off iPad.
    3. Turn iPad back on, hold down the Sleep/Wake until the Apple logo appears
    (B) Reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • Caps lock burn keyboard doesn't work

    Hey guys,
    do you know what is wrong with my macbook (MAC OS X,10.6.6) the key caps lock burn and it won't to turn off and the all keyboards doesn't work?
    Is it possible that that caps lock and this problem with all keys are connected,  keyboard doesn't work from when this caps lock burn. ?.
    I dont know what to do...
    do you know?
    Thank a lot for some advance!
    m.

    Hey reandel,
    I'd check out the recommended troubleshooting steps within the following document:
    One or more keys on the keyboard do not respond
    http://support.apple.com/kb/TS1381
    Welcome to Apple Support Communities!
    Best,
    Delgadoh

  • Finder show items in columns an item arrangement selected: Right size this column doesn't works

    like the title says, under these condition (note that an item arrangement must be selected) the “right sized” to the maximum width, necessary to display the longest item in the column, doesn't works even with a double click or choosing "Right size this column" option (in both cases the column is set to the default size).
    Anyone else experience this issue?

    You understand me well, sorry I'm not native English.
    Have you selected an item arrangement? if I select "None" it works for me too, the issue is when I select an item arrangement (arrange by Kind for example).
    My setting:
    Finder > View > Show View Options:
    - Always open in column views: SELECTED
    - Browse in column view: SELECTED
    - Arrange By: Kind
    - Sort By: Name
    - Text size: 12
    - the "three show" SELECTED
    Under the above conditions I've the issue, the column isn't resized.

  • International texting doesn't work?

    I have tried sending SMS to a mobile phone in Senegal and it doesn't work. I have double, triple, and quadruple checked the number.  The phone number is correct.
    Anyone else having a similar issue with other countries? This is the error I get every time: "SMS: Failed Try Again"
    It's such a specific error message too! /sarcasm -_-

    yes. i am having same problem. Tried texting to the Bahamas from the US using an iPhone.

  • LInks over shape doesn't work

    I just recently reformatted my iWeb pages and I love them. The problem is that most of them are buried under a pictures category (I want them that way). When I created hyperlinks in iWeb it changed the color of my font. So I inserted a shape behind the text and put the hyperlinks there.
    That doesn't work. I also tried putting the hyperlinks back on the text and when I publish, they don't work either. I like the shapes and don't want to remove them. How can I keep the pink shapes under my pictures page and keep the text white?
    http://web.mac.com/kryst1012/iWeb/Krystin/Photos.html

    Keep all of your shapes right where they are! To make your text into hyperlinks then, just insert another shape...make it big or small enough to cover your text. Go ahead and drag it right over your text. Now attach the hyperlink to this shape. Now in the INspector,click over to the Graphics tab and change the opacity of this shape to 1%.
    You have now created a "hotspot" hyperlink over your text! All without moving any of your other shapes around! Publish and see the results... Let me know if it works out for you!

  • Live Corner and Subtraction Shape Issue

    Having problem in Live Corner with Subtraction shape.
    Not sure if there is any setting to work on this.
    Please refer to my image attached. When using Pathfinder to subtract round corner shape made from Live Corner it come out with unexpected shape. Base on my images A became B, it should be look like C.
    if I dont use live corner and instead using Round Corder effect than expend, it will be work correctly.
    Anyone experienced with this issue?
    I've just Update my Illustrator CC too, but still no luck.
    Thanks for any help.
    Dara

    I just tried it and it appears there is no way that I can think of to kill the live effect. Expand does nothing.
    Using the pathfinder, the live effect alters the corners on the new object.
    However hold down alt/opt key with the minus front will give the shape you seam to be looking for.

  • Every time I ask Siri to find something near me, she says that she cannot find my location, and to turn on my location settings and siri settings. These are both on and after rebooting it still doesn't work. How do I fix this?

    Every time I ask Siri to find something near me, she says that she cannot find my location because I need to turn on location services in the settings menu and in siri. These are both on, and after rebooting my phone it still doesn't work correctly. How do I fix this?

    No, the app does not have to completely restart. It gets shifted in its open state into storage. Similar to how a computer uses the hard disk when it has insufficient memory.
    What complicates things is that sometimes memory does not get returned for reuse when you close an app. Thus yo should periodically double click the Home button and "delete" unnecessary apps from the multitasking dock and power off and then back on the iPod.

  • I had to change my Apple ID and password in itunes. Now my icloud doesn't work and I can't update my apps on my iPhone. I have looked at suggestions on the community pages and apple suggestions but none of them are relevant to iOS 8.1.2  icloud just

    I had to change my Apple ID and password in itunes. Now my icloud doesn't work and I can't update my apps on my iPhone. I have looked at suggestions on the community pages and apple suggestions but none of them are relevant to iOS 8.1.2
    icloud just keeps bringing up my old email address & asking for my old password which doesn't exist anymore and when I try to sign out of icloud it wants my old password, when I tried to change my primary email back to the old one it wants me to verify it through an email address that doesn't exist. Please can you help me sort out this nightmare.

    Hi skippy2012trev,
    Welcome to the Apple Support Communities!
    I understand that you updated your Apple Id and password but now you are being prompted for the old information in iCloud. You are on the right track by changing the Apple ID back to the previous email address temporarily so that you can sign out. You should not need to verify the email address. After you edit the Apple ID back to the old email address and then sign out of iCloud on your iPhone, edit the Apple ID back to the address you would currently like to use. There is no need to change the password again, only the email address, unless you prefer to update the password again.
    If you're asked for the password to your previous Apple ID when signing out of iCloud - Apple Support
    Change your Apple ID temporarily
    If signing out and back in to iMessage or FaceTime didn't help, try these steps:
    Change your Apple ID to the Apple ID you used previously. You shouldn't need to verify the email address.
    Tap Settings > iCloud. Complete these steps only if the Find My [Device] setting is turned on:
    Scroll down and tap Sign Out, then tap Sign Out to confirm. If you're using iOS 7 or earlier, tap Delete Account, then tap Delete to confirm.
    Tap Keep on My [Device] or Delete from My [Device]. In either case, your data remains in iCloud and will be updated on your device when you sign in to iCloud again.
    Enter the password for your previous Apple ID.
    Change your Apple ID to the new email address that you want to use. You'll need to verify the email address.
    Return to Settings > iCloud and sign in with your new Apple ID.
    Cheers,
    Joe

  • I would like to copy all the songs from one Ipod into another. All the songs are into my Itunes account, I tried to drag and drop the songs from the old Ipod to the new one but it doesn't work. Is there a way to do it ?

    Hello everybody,
    I would like to copy all the songs from one Ipod into another. All the songs are into my Itunes account, I tried to drag and drop the songs from the old Ipod to the new one but it doesn't work. Is there a way to do it ?
    I share one Itunes account with other people from my family and one person would like to keep the same songs on the new Ipod as the ones which were on the old one.
    Thanks in advance for your answer.
    Yan

    Hello Chris,
    Thanks for your answer. I was hoping for an easier answer. Too bad there is no drag and drop solution, it would have been much easier.
    Thanks for answering so fast.
    Bye.
    Yan

  • In my iTunes on the iPad I've got 95 items that are stuck and I tried swiping them to delete them but it doesn't work dose any one know how to empty the download tab

    In my iTunes on the iPad I've got 95 things that are stuck and I tried swiping them to delete them but it doesn't work dose any one know how to empty the download tab

    Thanks, but, using the "free" version of Reader, there is no opportunity to open nor import the xml data - the menu options do not exist - there is no import listed.
    If we try to open the xml file directly, then we get an error - something to the effect of "unsupported file type, or the file is corrupted".
    I just noticed in my Pro version that there is the command File ->Form Data ->Import Data to Form... command. Is this what you are referring to?
    What do you recommend? Perhaps the easiest thing to do would be to purchase a few copies of Acrobat Pro for the reservations people to use? I was hoping that the free version of reader would do it, but perhaps not?
    Thanks again,
    Rob

  • I cannot locate my cs6 redemption code and I just purchased a new computer because my old one doesn't work anymore. How can I get my photoshop on this computer? All my other products are registerd with a serial number

    I cannot locate my cs6 redemption code and I just purchased a new computer because my old one doesn't work anymore. How can I get my photoshop on this computer? All my other products are registerd with a serial number

    The activation servers for CS and CS2 stopped working and were taken down. You'll need to take a look at this link for your issue: https://helpx.adobe.com/x-productkb/policy-pricing/creative-suite-2-activation-end-life.ht ml
    Benjamin

  • I have an iPod 4th gen and the bottom part of it doesn't work where the space, .?123, and the go buttons are I droped it yesterday but it started doing this an hour ago I can slide to get in but it's stops working after that someone tell me how I fix this

    I have an iPod 4th gen and the bottom part of it doesn't work where the space, .?123, and the go buttons are not working I droped it yesterday but it started doing this an hour ago I can slide to get in but it's stops working after that someone tell me how I fix this

    Try:
    - Reset the iOS device. Nothing will be lost       
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup. See:                                                
    iOS: How to back up                                                                                     
    - Restore to factory settings/new iOS device.             
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
      Apple Retail Store - Genius Bar                                              

  • I'm using OS 10.6.8 and Mail 4.5. When I receive mails with attachments which are visible the save button doesn't work. Some contacts have problems opening files sent by me using Mail too. This was never a problem on pre-Intel. A real Mac **** up !

    I'm using OS 10.6.8 and Mail 4.5. When I receive mails with attachments which are visible the save button doesn't work. And some contacts occasionally have problems opening files sent by me using Mail too. This was never a problem on pre-Intel Mac. A real Mac **** up ! Any ideas ?

    Can you drag and drop the attachments visible in the email to the Desktop OK or does that fail ?
    Re the sending: Are these recipients on Mac's or PC's as the file type could be an issue, if on Mac's then try setting the Mail Preferences Composing setting to Plain Text not Rich Text and see if that improves things.

  • My pages are not working on Mountain Lion. I reinstalled iWork from the CD updated it  to 9.3 restarted computer and it still doesn't work. What else I can do? Heeelp!

    The Pages stop working on my computer when I upgraded OS to Mountain Lion. I reinstalled iWork from CD and updated to 9.3 version from Apple store. I also restarted computer before opening the iWork. It still doesn't work. It keeps giving me the error page. The same thing with Numbers. Only Keynotes opens.  What else can I do? Heeelp please! 

    We are not omniscient. Use screencapture on the error page. Shift + Command + 4 … then drag the cross-hairs around the error, and release. The Screen Shot will be written to your Desktop. Use the camera icon in this editor’s tool bar to embed that Screen Shot of your error in a follow-up post here.
    Did you move the Pages and Numbers applications out of /Application/iWork ’09 folder, where they are expected to reside? Did you run /Applications/Utilities/Disk Utility.app, and on your boot drive, verify/repair permissions?

Maybe you are looking for

  • Problem with Adobe Aplication Manger/Updater cs5

    i have just installed my CS5 Premium on my new (purchased used) macbook pro after a clean install (OSX 10.8.5) All the programs works fine but the Aplication Manger say there is updates for all the programs so i open it and and start the updates it d

  • OBIEE  not working-plz help me

    Hi My name is Priya I installed OBIEE 10.1.3.4.2 sucessfully on windows 7 ultimate OS and database Oracle 11g R2 11.2.0.1.0 but when I tried to Import SH schema from OBIEE Admin Tool the SH schema is not appearing in the select data source under conn

  • Migration from Photoshop Elements Windows to MAC

    Hi, I don't know if this question is answered already somewhere in this forum. I started a search without results. Maybe I'm wrong. If so, please apologize. I used Elements for years on my Windows box. Recently I bought an iMac and would like to know

  • Solaris 10 installation in Vitual PC 2007

    Anyone have success? I got to install but, it does this on boot: Warning: Time of Day clock error: reason [Stalled]. -- Stopped tracking Time of Day clock. Then seems to hang while using 50% CPU. Machine is HP m7580n, AMD X2 4600, 1 Gig memory alloca

  • IE v7 alignment issues

    My main content is out of alignment in IE7 but looks fine in Safari and Firefox  (big suprise there). http://fitnessworx.thehtmlcode.com/ I can't get the page to align (shrink to fit)  in IE like it does in Firefox or Safari. I used a template that s