Determine whether ellipse perimeter or GeneralPath is in a rectangle

Hi all,
I'm making a graphing program in which I can draw a number of shapes and lines (all members of java.awt.geom.*). Also, I have a selection tool. The selection tool draws a Rectangle2D over the canvas, and (in theory) any part of a shape or line which is inside the selection box ought to be selected.
Making this functionality for lines and rectangles was easy, as I could use the intersectsLine(line) method in Rectangle2D.
However, doing this for ellipses or GeneralPaths is proving to be much more difficult. As far as I can tell, both intersects(...) methods will return true even if I'm inside the object (I want it only to be true if I'm intersecting with a line itself).
I was wondering if I could use a PathIterator in some way, since they can both give me a PathIterator? Or is there something else I could use?
Any help would be very much appreciated!

If you need to check intersection with the perimeter of the shape then you can do the following,
Stroke stroke = new BasicStroke(1);
Shape outline = stroke.createStrokedShape(shape);Then test the 'outline' shape for intersection with your rectangle. Obviously you can adjust the stroke to suit.
Note that you might want to cache the stroked shapes if you're doing a lot of these tests.

Similar Messages

  • How to determine whether a file doesn't exist or doesn't have enough perms

    Hello everone,
    I am stuck in determining whether a file does not exist or does not have enough permissions so that access to this file is denied?". I am using
    java.io.File.exists() or java.io.File.canRead() methods to check this but both of them just return false in both above mentioned cases.
              In the documentation however its mentioned that these method throw SecurityException - If a security manager exists and its SecurityManager.checkRead(java.lang.String) method denies read access to the file. But then problem is to write a security manager which denies
    read access if the file does not have permissions so that exception can the thrown.
    Any suggestions or pointers will be highly appreciated.
    Thank You.
    Regards,
    Vikash Kumar

    Some platforms will let you rename or remove an open
    file.Unless those platforms support file locking, and the file has a lock on it.

  • What determines whether the Label name and/or Caption appears in the context help window but in other cases, both the label and caption appear in the context help window?

    I am trying to polish an application, and find that I cannot seem to reliably control which of the label or caption text appears in the context help window because I don't understand what rules are in place to determine which should appear. It seems like if I reate a named constant, then use it's right click menu command "Create Indicator" I get a control with only a Label (as long as I don't add a caption). This then appears in the context help window as the label name followed by the description text (after entering some description text). But if I add a caption, the label name is shown in bracket
    s which is a 'feature' I would like to avoid, because I have certain controls where I would like to use a descriptive variable name on the block diagram side without using so much space on the front panel. It seems like there is no way to avoid showing the Label name in the context help for a control/indicator. Is this true?
    I thought the purpose of having a seperate caption was to make the text that appears with a control programmatically controllable, but if that control is not extended to what appears in the context help window, it limits the usefulness of the caption and forces me to re-consider some Label names. However, the problem goes deeper than that because then even when I make the label and caption exactly the same, or if I delete (via a select caption text-backspace or select caption text- delete key .. sequence) the caption for a control, the label name in the context help window still appears in square brackets!
    Can I have complete control over the context help fo
    r a particular control (or has anyone found a third-party context help solution that functions compatibly with LabVIEW 7 in a built application that they will be so kind as to recommend?)
    I have used LabVIEW for three years, and I am now using LabVIEW 7.0.

    Sorry for that.. I was changing the text of my question and didn't read carefully enough in the preview stage. I wanted it to read "What determines whether the Label name and/or Caption appears in the context help window?"

  • I am writing to this forum to ask for help in determining whether Aperture will satisfy my needs when I switch from Windows to MAC in the near future.

     I am writing to this forum to ask for help in determining whether Aperture will satisfy my needs when I switch from Windows to MAC in the near future.  
    I am currently using Photoshop Elements 8 on Windows 7.  After several years of use, I am self taught and adequately proficient for an amateur.  What I didn't realize (until I started researching my upcoming migration on the Internet) is that I actually use PE8 for two functions: digital asset management and digital editing. 
    Regarding Digital Asset Management: My research leads me to understand that PE on MAC does not provide the same level of organizational capability that I am used to having on Windows, instead providing Adobe's Bridge which does not look very robust.  Furthermore, iPhoto, which come on MAC will not support the hierarchical keyword tagging that I require to organize my library of photos. The two SW applications which I am thinking of switching to are either Aperture or Adobe's Lightroom.  Frankly, I'm thinking that it would be smoother to stay within the Apple product line. 
    So the remaining question is whether Aperture will support my digital editing needs. The tweaks that I do to my photos are not very complex (no, I do not want to put people's heads on other animal bodies).  But could someone who uses Aperture tell me whether It will allow me to do the following kinds of edits?:
    - If I have a photo where someone's face is too shadowed, can I lighten just that person's face, and leave the rest of the photo as-is?  
    - if I have a photo where the background is cluttered (eg, 2 people in front of the Parthenon which is undergoing renovation), can I remove just the construction cranes?  
    - Can it splice together several separate photos to give a panoramic?  
    If, once I get Aperture, I find that it cannot enable the kinds of editing that I do, I would probably get PE11 in the future. However, if people in this forum tell me that Aperture will definitely not  support the kinds of editing which I've described in the previous paragraph, I would prefer to get PE11 with my initial configuration (since someone will be helping me with my migration).  
    Thanks in advance for your consideration and help! 

    I am concerned, however,  about using a non-Apple Digital Asset Manager in OSX. I would really like to avoid integration problems. Is using PE11 to import and catalog my digital photos likely to cause conflicts?
    Thanks for any insight on this
    Amy,
    Not so much conflicts as maybe a little less seamless integration with Apple software and perhaps some third-party software providers in the Mac App Store where some programs build in direct access to iPhoto and Aperture libraries for getting images into those programs easily. Typically, there is a manual command to go to Finder (think Windows Explorer) to browse folders.
    One caution to mention however, is that the organization you set-up in PE Organizer is unlikely to transfer over to either iPhoto or Aperture if you decide to change at some point.
    The only real stumbling block that I see in your opening comment is that you want hierarchical keywording (Kirby or Léonie can go into the details on keywording limitations as I stay at one level). If you can work with the keywording schemes of either iPhoto or Aperture, then using PE for your external editor (either program supports setting an external editor) would probably be ideal since you know PE well. This is the idea with the Mac App Store version of PE (editor with no organizer).
    Note - I use Photoshop CS6 (full version) with Aperture and it works really well. The only downside is that Aperture has to make either a TIFF or PSD file to send to an external editor so that the original file is protected by not sending it to the pixel editor. While TIFF or PSD files protect the integrity of the image information without degrading it, they are typically much larger file sizes on disk than either RAW or JPEG files. Therefore, your library size (iPhoto or Aperture) will balloon quite a bit if you send a lot of files to external editors.
    One other possibility for an external editor would be a program called Pixelmator. It is pretty similar to early versions of Photoshop, but built for Mac. Other than the panoramics you want, it will do most pixel editing that PE can do. It is not an organizer, so it is built to go with either iPhoto or Aperture. It does have differences in how you complete certain procedures, so there is bit of a learning curve when you are used to doing it the Adobe way.

  • How to determine whether a recordset is Empty or not ?

    Please see my snippet code below :
    <%     
         String sql="";
         String username="CDS";
         try
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con = DriverManager.getConnection("jdbc:odbc:Employees","","");
                Statement stmt = con.createStatement();
                ResultSet rs=null;
                   sql = "Select * from Employee where code='" + username + "'";
                   rs = stmt.executeQuery(sql);
                   rs.next();
                   if (rs==null)
                   %>
                        <jsp:forward page="Login.jsp?msg=Username not recognized"></jsp:forward>     
                   <%     
                else
                   %>
                        <jsp:forward page="Login.jsp?msg=Halo"></jsp:forward>
                   <%
              catch(ClassNotFoundException e)
                   out.println("Driver not found");
                    catch(SQLException e2)
                            out.println(e2.getMessage());
                            out.println("<BR>");
                            out.println("Wrong SQL Statement");
                            out.println("<BR>");
                            out.println(sql);
                            out.println("<BR>");
         %>How to determine whether a recordset has no result ?
    From the above code, i use if (rs==null) and that's not worked.
    Help me, guys.

    ResultSet rs = stmt.executeQuery(sql);
    if (rs.next()) {
    %>
        <jsp:forward page="Login.jsp?msg=Halo"/>
    <%
    } else {
    %>
        <jsp:forward page="Login.jsp?msg=Username not > recognized"/>
    <%
    }

  • The indicator to determine whether it is a case of the start or the finish

    Hello Gurus,
    In CJ20N, for internal activities, there is a "Person assignement" tab. And in this tab there is "date" field.
    The explaination of this date is:
    "Latest date for the start or finish of the split.
    You can use the indicator to determine whether it is a case of the start or the finish date."
    My problem is: where can I find the "indicator" mentioned?
    Thanks
    JM

    There is no specific indicator for this.
    Go to internal tab - you will see a field called DistKeyCapRqIn
    if this is blank then the system goes to the work centre master data for distribution of work load - if the work centre is blank then system defaults to earliest dates - which gets transferred to the person assignment tab.
    Now go bak to the internal tab and set field DistKeyCapRqIn to SAP030 - you will now see that the dates in the person assignment are showing latest dates.
    The dates for the activities can be seen based on scheduing in the dates tab

  • How do I determine whether I have PCI Express v1.1 or v2.0?

    This article in Mac Fixit states that computers with PCI Express v1.1 slots will NOT be able to take full advantage of OpenCL in Snow Leopard:
    http://www.macfixit.com/article.php?story=20090612121357227
    ... In terms of PCI Express, My Mac Pro is on the cusp. PCI 2.0 was announced in January 2007 and presumably made it's way onto the assembly line a few months after that. I bought my refurbished Mac Pro in June 2007. I can't determine in the System Profiler if I have PCIv1.1 or v2.0. Does anyone know how to find out? MacTracker and machistory.com haven't answered the question. It seems some of the MacPro1,1 models shipped with v1.1 and some with v2.0. How do I determine what I have? Thanks for your help!
    SPECS FROM MY SYSTEM PROFILER (SERIAL RM727......)
    GRAPHICS/DISPLAYS
    NVIDIA GeForce 7300 GT
    Chipset Model: NVIDIA GeForce 7300 GT
    Type: Display
    Bus: PCIe
    Slot: Slot-1
    PCIe Lane Width: x16
    VRAM (Total): 256 MB
    Vendor: NVIDIA (0x10de)
    Device ID: 0x0393
    Revision ID: 0x00a1
    ROM Revision: 3008
    PCI CARDS
    NVIDIA GeForce 7300 GT
    Name: NVDA,Display-B
    Type: display
    Bus: PCI
    Slot: Slot-1
    Vendor ID: 0x10de
    Device ID: 0x0393
    Subsystem Vendor ID: 0x0000
    Subsystem ID: 0x0010
    ROM Revision: 3008
    Revision ID: 0x00a1
    Link Width: x16

    How do I determine whether I have PCI Express v1.1 or v2.0?
    Hi,
    Open Apple System Profiler (About this Mac:More info) and look at the Hardware: Model Identifier. If it says Mac Pro 1,1 or Mac Pro 2,1 you have PCIe v1.1 slots.
    http://www.amug.org/amug-web/html/amug/reviews/articles/intel/macpro/
    If it says Mac Pro 3,1 you have PCIe v1.1 in slots 3 and 4 and PCIe v2.0 in slots 1 and 2.
    http://www.amug.org/amug-web/html/amug/reviews/articles/intel/macpro-2008/
    If it says Mac Pro 4,1 you have PCIe v2.0 in all four slots.
    http://www.amug.org/amug-web/html/amug/reviews/articles/intel/macpro-2009/
    Hope that helps!

  • File Repository Server error : Failed to determine whether there is enough

    Hi, We have setup a new server and while loading file we are getting following error message.
    File Repository Server error : Failed to determine whether there is enough disk space. We are on BOXI R2 SP3 on windows server 2003 with WAS on IIS 6.0.
    From CMC the error message is:
    There was an error while retrieving data from the server: Unable to open file C:\WINDOWS\TEMP\tmp875.txt.
    I ran Input FRS with a particular port and was able to ping FRS on that port. So port is opened.
    Does anyone know reason for this?
    Thanks,
    Kalpesh

    Can you elaborate exactly what you had to resolve this issue.
    Thanks, Mani

  • How to Determine Whether Columns Exist in a Table

    Greetings,
    Because of customizations to our product, certain database table structures vary between different client installations. Hence, in the code, I need to determine whether two columns exist in a certain table, in order to apply some business logic.
    Please suggest a way for me to determine whether two named columns appear in a specific table. In other words, for example, I need to discover whether both columns SAL_GRADE and BONUS appear in the EMP table, or not. Only if both columns are defined, can I apply my business logic.
    Thanks,
    Avi.

    Avi,
    Like this ?
    SQL> declare
      2    l_count number;
      3  begin
      4    select count(*)
      5      into l_count
      6      from user_tab_columns
      7     where table_name = 'EMP'
      8       and column_name in ('SALGRADE','BONUS')
      9    ;
    10    if l_count = 2
    11    then
    12      dbms_output.put_line('Both columns exist, so apply business logic');
    13    else
    14      dbms_output.put_line('One or both columns are missing, so don''t apply business logic');
    15    end if;
    16  end;
    17  /
    One or both columns are missing, so don't apply business logic
    PL/SQL-procedure is geslaagd.Regards,
    Rob.

  • Error determining whether the target server is already a domain controller: Failed to open the runspace pool

    Hi there , i already have some others DC running w2k12 R2 on the env, but when i was promoting another new DC running w2k12 R2 on the middle of the AD sync , the server encounter an error and rebooted it self ; after the server came back online , it keep
    saying that a configuration is required for AD Domain Services , like the step when you are about to promote the server , but when you try to promote it , the error "Error determining whether the target server is already a domain controller: Failed
    to open the runspace pool. The server manager winrm plug-in might be corrupted or missing."

    Hi,
    Thanks for your post.
    Please waitting for the replication is finished and rerun the domain prep command  to check the result.
    Regards.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Determine whether a client is a member of SCCM 2007 or 2012

    Hi,
    I would like to use PowerShell to query sccm to determine whether or not a client(s) has been successfully migrated to our 2012 environment or not. Is this possible somehow to do this? And this output this list? Or maybe using AD? Is there a way to determine
    this?
    Thank you.

    Yes, I know this is an old post, but I’m trying to clean them up.
    What you are asking for is NOT a simple query, you will need to query both the CM07 and CM12 db. I estimate that this would take several hour to setup and create a basic report.
     As such this is not the type of thing that is easily answered within the forums. I suggest talking to your DBA or hire someone that can write the report and the details on how to do this type of thing.
    Garth Jones | My blogs: Enhansoft and
    Old Blog site | Twitter:
    @GarthMJ

  • Determining whether form is valid or not

    Assuming I have a form with few input fields,
    I want to render a button only when the form is valid using ajax calls,
    Is it possible somehow to determine whether a form is valid or not?
    Thanks,
    Asaf.

    When a form is submitted and the JSF validation phase pass successfully and jsf cycle moves to the update model values,
    I have several rules like some required fields, several validators attached to input fields, etc...
    if all validators / required fields are set I would like to render a 'submit' button.
    Asaf.

  • The Server Behavior panel cannot determine whether "Command" or "Recordset (Query)" ...

    Suddenly getting this goofball message in DW5.5 on Win7:
    "The Server Behavior panel cannot determine whether "Command" or "Recordset (Query)" is applied to your page. Please select Edit Server Behaviors and change one of the two behaviors to ensure that each is uniquely identifiable."
    Crazy thing is, it only happens on my workstation.
    DW5.5 on my laptop opens the same .asp pages without this crazy message popping up.
    Anybody know what the issue is?

    I'd suggest that no answer means no answer yet. The person who can help may not have been on the forum the day the post was made.
    That said, I'm starting to suspect that the cause must be an extension. Both boxes have the same version of DW and the same OS but both don't have the exact same extensions installed. Will play around and see what happens.

  • Determine whether parameter is dynamic or static?

    I'm having some challenges with applying connection information to my reports. I'm seeing that I need to use one method for reports that contain dynamic parameters, and another method for ones that do not. It's insane to me how difficult it's been to find a solid way to handle setting connection information, and there appears to be a million ways to do it, but I digress.
    What's the best way to load a report and determine whether or not it contains parameters that are dynamic or not? Any advice would be appreciated!

    Ok... I'll take you down the rabbit hole, which will probably slightly change the topic of this thread This all stems from a post I made back in 2011 which you and Don were active on:
    http://scn.sap.com/thread/1887128
    I never did quite figure out the issue described in that thread, and finally began to tackle it again. My CR viewer needs to support reports that utilize ODBC (RDO) and OLE DB (ADO) connection types. As it turns out, reports utilizing OLE DB (ADO) connection types were actually working as expected, no login screen was being shown prior to the dynamic parameter being displayed, it was only reports utilizing the ODBC connection type. So I downloaded the "CodeBuilder-RasConnectionInfo" utility and worked with the code it generated, which looked like an entirely different method of setting the connection info. After using this new method, my ODBC based reports began to work just fine, whereas my OLE DB (ADO) reports were now displaying the logon prompt prior to displaying the dynamic parameters. The code I've been using all along has been working so well and is very trusted that thought one approach I would take is to detect if the crystal report contained dynamic parameters, and only use the new connection code if it did, otherwise it would revert back to what I was always using. I'm now changing my tune on this, and don't think that's the right approach. I'm actually comfortable with making the statement that my viewer only supports dynamic parameters when utilizing OLE DB (ADO) connection types. But just in case you are curious, here are the two blocks of code:
    Here is what I was always using, where dynamic parameters show a logon prompt for ODBC connections types, but not OLE DB (ADO) connection types:
    http://resources.rock-pond.com/orig.txt
    Here is what I used from the code generator, where dynamic parameters do not show a logon prompt for ODBC connection types, but do for OLE DB (ADO) connection types (In this example, there are minor changes to the code depending on whether the report utilizes ole db (ado) vs ODBC... The example here is for odbc
    http://resources.rock-pond.com/new.txt
    Ideally I would find one method that work work against both connection types and display dynamic parameters without the logon prompt, but I haven't found the answer yet.
    I'm currently using 13.0.5.891 on the development system, and am testing the functionality against a 13.0.8 version of the runtimes. If you've got any thoughts or direction I might take, let me know.

  • Side Effects using a UIInput  to determine whether a component is rendered

    Hi,
    I'm trying to use the value of a UIInput component to decide whether or not to render another component and am getting some strange side effects. When the hidden component is re-rendered after being hidden, the selected value is not displayed. This does not happen if I copy the value of a ValueChangeEvent and then use that as my return value. Any idea what is going on here? Switching the commented out line in getControllerValue in BackingBean.java should demonstrate the issue.
    Thanks,
    Pierce
    index.jsp<?xml version="1.0" encoding="UTF-8" ?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:h="http://java.sun.com/jsf/html"
         version="2.0">
         <jsp:directive.page contentType="text/html; charset=UTF-8" />
         <f:view>
              <html>
              <head>
              <title>test</title>
              </head>
              <body>
              <h:form id="testForm">
                   <h:panelGrid columns="2" columnClasses="labelColumn, inputColumn">
                        <!-- controlling input -->
                        <h:outputLabel value="Controller:"></h:outputLabel>
                        <h:selectOneMenu id="controller"
                             binding="#{backingBean.controller}"
                             valueChangeListener="#{backingBean.changeController}"
                             immediate="true" onchange="submit()" required="true">
                             <f:selectItems value="#{backingBean.controllerItems}" />
                        </h:selectOneMenu>
                        <!-- controlled input -->
                        <h:outputLabel for="hideme" value="Input to hide:"
                             rendered="#{(backingBean.controllerValue != 1) and (backingBean.controllerValue != 5)}"></h:outputLabel>
                        <h:selectOneRadio id="hideme" value="#{backingBean.hideme}"
                             required="true"
                             rendered="#{(backingBean.controllerValue != 1) and (backingBean.controllerValue != 5)}"
                             >
                             <f:selectItems value="#{backingBean.hidemeItems}" />
                        </h:selectOneRadio>
                   </h:panelGrid>
              </h:form>
              </body>
              </html>
         </f:view>
    </jsp:root>BackingBean.java
    package test;
    import java.util.LinkedList;
    import java.util.List;
    import javax.faces.component.UIInput;
    import javax.faces.component.html.HtmlSelectOneMenu;
    import javax.faces.event.ValueChangeEvent;
    import javax.faces.model.SelectItem;
    public class BackingBean {
         private UIInput controller = new HtmlSelectOneMenu();
         private Integer hideme = 2;
         private Integer copiedValue;
         private List<SelectItem> controllerItems = new LinkedList<SelectItem>();
        private List<SelectItem> hidemeItems = new LinkedList<SelectItem>();
        public BackingBean(){
             controller.setValue("3");
             controller.setSubmittedValue("3");
             copiedValue = 3;
             controllerItems.add(new SelectItem(1, "Controller 1"));
             controllerItems.add(new SelectItem(2, "Controller 2"));
             controllerItems.add(new SelectItem(3, "Controller 3"));
             controllerItems.add(new SelectItem(4, "Controller 4"));
             controllerItems.add(new SelectItem(5, "Controller 5"));
             hidemeItems.add(new SelectItem(1, "Hide Me 1"));
             hidemeItems.add(new SelectItem(2, "Hide Me 2"));
             hidemeItems.add(new SelectItem(3, "Hide Me 3"));
         public UIInput getController() {
              return controller;
         public void setController(UIInput controller) {
              this.controller = controller;
         public Integer getHideme() {
              return hideme;
         public void setHideme(Integer hideme) {
              this.hideme = hideme;
         public List<SelectItem> getControllerItems() {
              return controllerItems;
         public List<SelectItem> getHidemeItems() {
              return hidemeItems;
          * Value change listener
         public void changeController(ValueChangeEvent e){
              System.out.println((String)e.getNewValue());
              copiedValue = Integer.parseInt((String)e.getNewValue());
          * Helper
         public Integer getControllerValue(){
            // why does the following line not work?
         //     return Integer.parseInt((String)controller.getValue());
              return copiedValue;
    }

    This is a How to test a variable to determine whether it is a NUMBER.
    Cheers, APC

Maybe you are looking for

  • How to create a PDF that prints at actual size for all printers

    I create printable educational products for teachers and homeschoolers.  I need to be able to make some printable PDFs that have cards set to a specific dimension, say 3" x 3".  When I create PDFs in InDesign and print them, the printer tends to shri

  • Access JSP pages under WEB-INF

    Hello, I have a web application and i use Java,JSP, servlets etc. In my webpage i have three different categories of users *1)* Registered users *2)* Not Registered users *3)* Administrator I would like the welcome page index.jsp and register page be

  • I need a bit of theory: How are connections to the db created

    Hi I need network / docs resources to explain how connections to the oracle are made. Strangly enogh I can find it nowhere! Thanx in advance Paul

  • Errors in MS Office Excel save function

    When saving a file the save to function opens with a number of suggested locations. When one of those clicks the save box opens, however it doesn't open to the chosen location it opens to the last used location. When the file is saved the save box re

  • Problem with SQL loader - "maximum length"

    using SQL*Loader: Release 8.1.7.0.0 =================================== (full CTL enclosed below) I have a problem with several rows, in which I'm getting the "Field in data file exceeds maximum length" error. the DB field (referer) is a VARCHAR2(400