What is the recommended method for managing events mouseclick for nodes custom subclass components?

Hello

I created a custom node that is a StackPane containing a label on top a polygon.

import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;


public class CustomHexagon extends StackPane {

    private Polygon hexagon;

    private Label overlayText;

    public CustomHexagon( String text, double... points ) {
        this.hexagon = new Polygon( points );
        this.overlayText = new Label( text );
        overlayText.setStyle( "-fx-font-weight: bold;" );
     
        hexagon.setStroke( Color.GREEN );
        hexagon.setStrokeWidth( 5.0 );
        hexagon.setFill( Color.WHITE );
     
        this.getChildren().addAll( hexagon, overlayText );
// Lays out the node where it should be according to the points provided for the Polygon.
        this.setLayoutX( points[0] - getLayoutBounds().getMinX() );
        this.setLayoutY( points[1] - getLayoutBounds().getMinY() );
// Show the border of the StackPane.
        this.setStyle( "-fx-border-color: black; -fx-border-width: 1; -fx-border-style: dashed;");
    }

    public String getOverlayText() {
        return overlayText.getText();
    }
}


I want to display a tesselation of these custom hexagons. Because a CustomHexagon is a StackPane, not a polygon, mouse click events can be picked up when clicking on the mouse out of the race in France, but still in the StackPane (which takes a bigger than the hexagon rectangle). The following program illustrates this.

public class Main extends Application {
  
    @Override
    public void start(Stage primaryStage) {      
        Group root = new Group();
      
        CustomHexagon[] hexagons = {
            new CustomHexagon( "00", 10.0, 10.0, 30.0, 10.0, 40.0, 27.3205080756, 30.0, 44.6410161512, 10.0, 44.6410161512, 0.0, 27.3205080756 ),
            new CustomHexagon( "01", 70.0, 10.0, 90.0, 10.0, 100.0, 27.3205080756, 90.0, 44.6410161512, 70.0, 44.6410161512, 60.0, 27.3205080756 ),
            new CustomHexagon( "02", 130.0, 10.0, 150.0, 10.0, 160.0, 27.3205080756, 150.0, 44.6410161512, 130.0, 44.6410161512, 120.0, 27.3205080756 ),
            new CustomHexagon( "03", 190.0, 10.0, 210.0, 10.0, 220.0, 27.3205080756, 210.0, 44.6410161512, 190.0, 44.6410161512, 180.0, 27.3205080756 ),
            new CustomHexagon( "04", 250.0, 10.0, 270.0, 10.0, 280.0, 27.3205080756, 270.0, 44.6410161512, 250.0, 44.6410161512, 240.0, 27.3205080756 ),
            new CustomHexagon( "10", 40.0, 27.3205080756, 60.0, 27.3205080756, 70.0, 44.6410161512, 60.0, 61.961524226799995, 40.0, 61.961524226799995, 30.0, 44.6410161512 ),
            new CustomHexagon( "11", 100.0, 27.3205080756, 120.0, 27.3205080756, 130.0, 44.6410161512, 120.0, 61.961524226799995, 100.0, 61.961524226799995, 90.0, 44.6410161512 ),
            new CustomHexagon( "12", 160.0, 27.3205080756, 180.0, 27.3205080756, 190.0, 44.6410161512, 180.0, 61.961524226799995, 160.0, 61.961524226799995, 150.0, 44.6410161512 ),
            new CustomHexagon( "13", 220.0, 27.3205080756, 240.0, 27.3205080756, 250.0, 44.6410161512, 240.0, 61.961524226799995, 220.0, 61.961524226799995, 210.0, 44.6410161512 ),
            new CustomHexagon( "14", 280.0, 27.3205080756, 300.0, 27.3205080756, 310.0, 44.6410161512, 300.0, 61.961524226799995, 280.0, 61.961524226799995, 270.0, 44.6410161512 ),
            new CustomHexagon( "20", 10.0, 44.6410161512, 30.0, 44.6410161512, 40.0, 61.961524226799995, 30.0, 79.2820323024, 10.0, 79.2820323024, 0.0, 61.961524226799995 ),
            new CustomHexagon( "21", 70.0, 44.6410161512, 90.0, 44.6410161512, 100.0, 61.961524226799995, 90.0, 79.2820323024, 70.0, 79.2820323024, 60.0, 61.961524226799995 ),
            new CustomHexagon( "22", 130.0, 44.6410161512, 150.0, 44.6410161512, 160.0, 61.961524226799995, 150.0, 79.2820323024, 130.0, 79.2820323024, 120.0, 61.961524226799995 ),
            new CustomHexagon( "23", 190.0, 44.6410161512, 210.0, 44.6410161512, 220.0, 61.961524226799995, 210.0, 79.2820323024, 190.0, 79.2820323024, 180.0, 61.961524226799995 ),
            new CustomHexagon( "24", 250.0, 44.6410161512, 270.0, 44.6410161512, 280.0, 61.961524226799995, 270.0, 79.2820323024, 250.0, 79.2820323024, 240.0, 61.961524226799995 ),
            new CustomHexagon( "30", 40.0, 61.961524226799995, 60.0, 61.961524226799995, 70.0, 79.2820323024, 60.0, 96.602540378, 40.0, 96.602540378, 30.0, 79.2820323024 ),
            new CustomHexagon( "31", 100.0, 61.961524226799995, 120.0, 61.961524226799995, 130.0, 79.2820323024, 120.0, 96.602540378, 100.0, 96.602540378, 90.0, 79.2820323024 ),
            new CustomHexagon( "32", 160.0, 61.961524226799995, 180.0, 61.961524226799995, 190.0, 79.2820323024, 180.0, 96.602540378, 160.0, 96.602540378, 150.0, 79.2820323024 ),
            new CustomHexagon( "33", 220.0, 61.961524226799995, 240.0, 61.961524226799995, 250.0, 79.2820323024, 240.0, 96.602540378, 220.0, 96.602540378, 210.0, 79.2820323024 ),
            new CustomHexagon( "34", 280.0, 61.961524226799995, 300.0, 61.961524226799995, 310.0, 79.2820323024, 300.0, 96.602540378, 280.0, 96.602540378, 270.0, 79.2820323024 ),
            new CustomHexagon( "40", 10.0, 79.2820323024, 30.0, 79.2820323024, 40.0, 96.602540378, 30.0, 113.9230484536, 10.0, 113.9230484536, 0.0, 96.602540378 ),
            new CustomHexagon( "41", 70.0, 79.2820323024, 90.0, 79.2820323024, 100.0, 96.602540378, 90.0, 113.9230484536, 70.0, 113.9230484536, 60.0, 96.602540378 ),
            new CustomHexagon( "42", 130.0, 79.2820323024, 150.0, 79.2820323024, 160.0, 96.602540378, 150.0, 113.9230484536, 130.0, 113.9230484536, 120.0, 96.602540378 ),
            new CustomHexagon( "43", 190.0, 79.2820323024, 210.0, 79.2820323024, 220.0, 96.602540378, 210.0, 113.9230484536, 190.0, 113.9230484536, 180.0, 96.602540378 ),
            new CustomHexagon( "44", 250.0, 79.2820323024, 270.0, 79.2820323024, 280.0, 96.602540378, 270.0, 113.9230484536, 250.0, 113.9230484536, 240.0, 96.602540378 )
        };
      
        EventHandler<MouseEvent> mouseClickedHandler = new EventHandler<MouseEvent>() {


            @Override
            public void handle(MouseEvent t) {
                CustomHexagon h = (CustomHexagon) t.getSource();
                System.out.println( h.getOverlayText() );
            }
          
        };
      
        for ( CustomHexagon hexagon : hexagons ) {
            hexagon.setOnMouseClicked( mouseClickedHandler );
        }


        root.getChildren().addAll( hexagons );
      
        Scene scene = new Scene(root, 400, 400);
      
        primaryStage.setTitle("Example");
        primaryStage.setScene(scene);
        primaryStage.show();
    }




    public static void main(String[] args) {
        launch(args);
    }
}


After execution of this program, when you click in the intersection of two StackPanes (borders, shown by dotted lines), the target of the mouse click event will be the StackPane on top, as determined by the order in which they were added to their parent. This is a problem because there is only a small "T" shaped region within each Hexagon that when you click on will target the hexagon with an event, rather than the adjacent nodes. I would be grateful any reccomendations for this problem. Thank you James Giller

Hello, this is a conifer. Simply call setPickOnBounds (false) on the CustomHexagon.

A follow-up of this problem problem is open here: https://javafx-jira.kenai.com/browse/RT-17024

Tags: Java

Similar Questions

  • What is the recommended method to organize your applications on 6 s more?

    What is the recommended method to arrange the icons on the iPhone

    Hello

    Simply move you them where you want on the screen of each apps

    Are in different places on the move of the screen by holding down until what they shake.

    See you soon

    Brian

  • What is the best method to manage more than 100 oracle instance?

    our company have run on the 100 on VM Linux oracle instance.

    What is the best method to manage more than 100 oracle instance? use Oracle Enterprise Manager?

    Thank you.

    How your company grow to 100 cases?  There would be some oversight in place as he grew.

    What do you exactly mean by "manage"?  Monitor?  Start/stop?  Performance optimization?  Add storage / Storage?  Backup?

    You may need a mixture of methods / facilities.  Again, it should be obvious that you have something in place already - if you replace it entirely?

    Hemant K Collette

  • What is the recommended API for reading/analysis of XML in Java files?

    Hello, everyone!

    In my application, I have to read a XML file. I think that Java has several APIs to parse XML files and as I am new to this, I would like to know from you what is the recommended Java for this API.

    Thank you.

    Marcos

    Unless you plan to edit nodes and I would recommend that you use a Sax parser, which is a lot less hunger of memory as a DOM parser. The DOM parser to read the entire document in memory for the manipulation of the user.
    If you are looking only to read the document and extract specific values then a DOM parser would be an exaggeration. If you are planning leave the document unchanged then a SAX parser is the way to go - a little more complex to write but worth the extra as it will be faster and more scalable.

  • What is the recommended method to shorten the strings for a given width

    I know how to detect the width required for a string using the font and size.

    I also know that the available width for the string

    If I detect that the width of the string is > available width what is better (or recommended) allows to shorten the chain?

    ex: 'It is my example text' is too long

    and 'it's maybe my examp... "fits exactly to the width that can be drawn from graphics

    is there an API for this, or should I reduce the length and try until his short enough?

    THX 4 info

    There is an API for just that - no need to mess with shortening of the chain yourself to all:

    Graphics.drawText(text, x, y, DrawStyle.ELLIPSIS, availableWidth)
    
  • What is the recommended method to configure a web proxy to another server on the LAN?

    Hello

    I use Server to manage incoming web traffic, but also have another server running I want to use outside.

    I work in directly modifying the site configuration file and adding the ProxyPass and ProxyPassReverse directives but these overwritten when the site configuration is changed in the.app

    I want to implement this in a way that is not crushed and is more robust.

    Any advice would be very welcome.

    Thank you

    Gary

    I'm certainly not an expert in the field, but I think you can do what you're asking using the functionality of the Web application.

    You bring a plist to webapps folder and a conf file in the apache folder and then using.app, edit your Web site, and then click Change advanced settings and select the Web application that you created. It should not then be written more if you make any changes.

    The content of the conf file would proxy information in it:

    # of http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass

    RewriteEngine on

    RewriteCond% {HTTPS} = off

    RewriteRule. -[E = Protocol: http, E = port: 8000]

    RewriteCond% {HTTPS} = we

    RewriteRule. -[E = Protocol: https, E = port: 8010]

    ProxyPassReverse / http://secondserver.example.com:8000 /

    ProxyPass / http://secondserver.example.com:8000 /

    and the plist would be something like this:

    <? XML version = "1.0" encoding = "UTF-8"? >

    <! DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0 / / IN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" > ""

    <!-see the manual pages for webapp.plist (5) and webappctl (8) for more information on this example webapp.plist->

    < plist version = "1.0" >

    < dict >

    includeFiles < key > < / key >

    < table > <! - include files are enabled in the virtual host then webapp - >

    < string > /Library/Server/Web/Config/apache2/httpd_yourwebapp.conf < / string > <! - name must match your conf file - >

    < / array >

    < key > name < / key >

    < string > com.example.secondserverwebapp < / string >

    displayName < key > < / key > <! - name displayed in app server - >

    < string > SecondServerWebApp < / string >

    installationIndicatorFilePath < key > < / key > <!-the presence of this file indicates web app is installed->

    < string > /Library/Server/Web/Config/apache2/httpd_yourwebapp.conf < / string >

    sslPolicy < key > < / key > <! - determines the behavior of the webapp SSL - >

    < number > 0 Integer < / integer > <!--0: by default, UseSSLWhenEnabled->

    <!--1: UseSSLAlways->

    <!--2: UseSSLOnlyWhenCertificateIsTrustable->

    <!--3: UseSSLNever->

    <!--4: UseSSLAndNonSSL->

    < / dict >

    < / plist >

    This is perhaps not completely right, but can direct you in the right direction, I hope that someone with more knowledge will be the chip in the meantime

  • What are the recommended settings for the export of photos for the web?

    I am a photographer, if the images would be used for my blog... and still need of decent looks.
    They are also the images that I approach clients, again, they need for decent, but would be the right size for the web.
    I played a bit, and when we maintain quality"to 100%, but the setting at 72 dpi, the image remains the same size at 300 dpi.
    So I got the quality up to 50%, but even slight vignetting seemed absolutely horrible. (Highly visible sections of different colors.)
    So now I'm stuck.
    72 dpi and 300 dpi made no difference in size (cannot explain this one.)
    100% quality seemed fine but was too big for the web.
    50% quality was mediocre at best.
    Any suggestions? What is the standard practice?
    Thanks in advance.

    I would use a quality of 70-80 and also resize the image under 'Image size' for example, you pick a long edge of (for example) 1200 pixels.

    The ppi (dpi not) makes absolutely no difference, it's completely out of words and useless in this situation, as you found it. Just ignore it.

  • What is the best method for a video output to a monitor on the new iMac?

    I noticed that the new iMacs don't have an HDMI port. How can I get a video signal to a monitor in the sequel of my editing?

    Thank you.

    Tom

    in the accessories kit was without adapter?

    Search on amazon for mini hdmi port, from display connector<10€>

  • What is the recommended method to disconnect from Firefox?

    I'm new to Firefox. I just installed Firefox v 9.0.1. Is it preferable that I sign out of Firefox before clicking on the Red 'X' button? I am using Windows 7 as my operating system.

    No need to disconnect anything either. You can simply click on the red x.

  • What is the recommended method to start automatically on PXE with Latitude Laptop?

    'Force PXE to the next boot' is not supported on Latitude systems more and we need to boot PXE while reinstalling the laptops.

    We can change the boot order so that NIC is the first, but it does not work because AssignedSequence-value of DCIM_OrderedComponent is equal to zero.

    Any help with this?

    The problem is that the NETWORK card is disabled as default boot device.  You will need to use CCTK to activate the NETWORK card as boot device and then set it as the primary boot device.  The next version of the OMCI will have the ability to configure it.

  • What is the best size for the gigantic memory file pagefile.sys virtual?

    pagefile.sys is gigantic 8 GB of files in Windows 7, I want free space of HDD on my SSD for faster backup purposes, but I don't want to hinder the performance that comes first.

    I have 8 GB of DDR3 memory. What is the recommended size for the pagefile.sys for optimal performance?

    Tuesday, April 6, 2010 20:44:59 + 0000, EcoWhale.com wrote:

    > I wonder what would be the best size to choose for the performance as I have 8 GB of physical memory (assuming an SSD with a lot of space)?

    I recommend leaving it alone and let windows decide for himself,
    rather than make any custom setting. It works very well.
    Ken Blake, Microsoft MVP (Windows desktop experience) since 2003
    Ken Blake

  • What is the recommended computer configuration - PC - first pro

    I'm shopping for a new computer. What is the recommended configuration for a PC that is running the first Pro CS6

    Please see the link: http://helpx.adobe.com/x-productkb/policy-pricing/system-requirements-premiere-pro.html#Ad obe Premiere Pro CS6 system requirements

  • Binds the exportXFAData(); method for the saveAs event

    I have an XFA form that was built with LiveCycle and I try to write javascript to Adobe who will export the form data to an XML file whenever a user manually saves the file in Acrobat. Preferably, this feature is easily sharable, because I have clients who need to have this ability.

    I'm a novice, but it seems that the interactive objects are grey and so I can not add a custom button. That's why I hope to link the exportXFAData(); method for the saveAs event. When a user does CTRL + S or file > save (sub)... the XML should be exported to the desktop.

    It seems that I have to use the exportXFAData() or exportAsXFDF() method.  I found something that says: " it is a very simple process to do this, use the method saveAs Doc object... " and copy the following code:


    this.saveAs ("/ c/temp/test.xml", "com.adobe.acrobat.xml - 1-00");

    I do not know where to write this code, or if it must be adapted (not to mention that the path) to accomplish what I asked above.

    Thank you very much,



    Carl


    It does not export form data, as far as I know, but another schema. There is a different method for acroforms export but I don't know for XFA forms. You should check the reference XFA JavaScript, not google.

    The example you found is not in any way binding to the SaveAs event. Rather, it uses a special feature of the document.saveAs method that allows you to save/export other formats instead of PDF, such as file options > save as. The code generally added to a button, but do not work (see below). I don't know if you can run this in an event WillSave or similar, that; s a separate exercise.

    Don't forget to read the XFA JavaScript document for this method since it will have security restrictions designed to stop incorporating any kind of back up/export to a file - because think havoc if a PDF file that you have downloaded begins to silently save/export the files to your computer. Do not try to use acroform rather documentation! And I see that what you quoted DC Acrobat SDK Documentation applies to the acroforms.

    For more specific help, I suggest the LiveCycle Designer forum. We are dealing here Acroforms.

  • What is the recommended for El Capitan recovery process?

    What is the recommended for El Capitan recovery process?

    I just upgraded directly from Mountain Lion, and I see that my recovery disc has disappeared.  My recovery disk wizard is only good for Lion and Mountain Lion.  I searched Apple.com and found a complicated process by which I could use the Console and create a bootdisk with the option reinstall, but I can't believe that this is the recommended option for a common user?

    So is time machine bygones?  I noticed that it is dimmed in the Menu bar?

    Certainly, you can restore El Capitan as you would with any other version of OS X - using the HD Recovery. I have no idea why your Recovery HD disappeared. Usually this would cause by user error. However, you can create a standalone install OS X on a USB FlashDrive for emergency use. This has been an option because at least Mavericks:

    Do your own installation of El Capitan using the El Capitan tool flash drive:

    You can create an installer of flash of El Capitan via the Terminal drive. El Capitan has its own manufacturer Installer integrated that you use via the Terminal:

    You'll need a freshly partitioned and formatted at least 8GBs. USB flash drive leave the name of the flash drive on the system by default, "Untitled." Do not change this name. Wait as the full process that will take some time.

    Open the Terminal in the Utilities folder. Copy and paste the following line in its entirety in the Terminal window.

    sudo/Applications/Install\ OS\ El\ Capitan.app/Contents/Resources/createinstallmedia--volume/Volumes/Untitled--applicationpath X\ "/ Applications/install OS X El Capitan.app.

    Press RETURN, enter the admin password (will not resonate to the window) then press RETURN again.

    You must have setup in your Applications folder or change the paths in the command line above.

    You can do the same thing for Yosemite by making the appropriate substitute for the installer in the above command line:

    Make your own Yosemite flash Installer drive using the tool of Yosemite:

    You can create an installer of the Yosemite via the Terminal flash drive. Yosemite has its own manufacturer Installer integrated that you use via the Terminal:

    You'll need a freshly partitioned and formatted at least 8GBs. USB flash drive leave the name of the flash drive on the system by default, "Untitled." Do not change this name. Wait as the full process that will take some time.

    Open the Terminal in the Utilities folder. Copy and paste the following line in its entirety in the Terminal window.

    sudo/Applications/Install\ OS\ Yosemite.app/Contents/Resources/createinstallmedia--volume/Volumes/Untitled--applicationpath/Applications/Install\ OS\ Yosemite.app X\ X\

    Press RETURN, enter the admin password (will not resonate to the window) then press RETURN again.

    You must have setup in your Applications folder or change the paths in the command line above.

    In addition, to Yosemite and earlier you can try using DiskMaker X.

  • What is the best software for imac photo management

    What is the best software for imac photo management

    This will depend on your needs.

    Looking for a database of professional for a huge collection of photos or photo is a simple tool to keep photos organized suffice?

    Software of Apple's professional photo 'Openness' is no longer sold. Professional software, you will need to look for software from third-party manufacturers - Lightroom, Capture One, to name a few.

    The News Photos of the Apple is still very basic and more suitable for an amateur user casual; you don't have much control over the design of the database of Photos.

Maybe you are looking for

  • Positioning widonw without scrolling, tittle, tool bars...

    I want to place the window of execution of a Subvi (only Panel) on the pixel (0,0), with a specific size. But it always appears with the name of the bar, toolbar... How can I show only the Panel? I am new to Labview, so the question is maybe stupid,

  • Driver package for Pro book 650 G1 (win7 x 86)

    Dear HP, I'm looking for a driver package for use in SCCM (System Center configuration manager) 2007 or 2012 through a softpaq. Model: Book Pro 650 G1 OS: windows 7 32-bit (x 86). I can't find or wwwsite, HP Softpaq Download Manager or ftp server. So

  • "Closing Windows.

    I wake up about 2 times a week, with a blue screen and the "closing windows" across the middle. After that, the button to turn off the computer does not close it. I need to unplug the power cord in order to power off the computer and start again. Why

  • updated to windows live mail.

    updated to windows live mail. Look a lot different. Always have the problem of sending well. Shows, sent, but does not go to the desired mailbox? Can send messages on the isp server. correct parameters. It must be something in live mail? Puzzled?

  • hpc6180

    I bought 2 ink cartrides black and each of them bled the cartridge ink in the printhead to the printer on the stand. Finally, I got an error message that says oxc18a0406. Then, I get a message of failure print on the display window. I tried to clean