Invalid transform on JavaFX shape after creation

Hello,
I am working on a UI in JavaFX and create several instances of a custom control class. The control consists of a Pane which wraps several other containers, one of which contains a Circle shape.
At one point, I instance this control and access the Circle shape directly. I transform it's center coordinates (which are always {0.0, 0.0} ) to Scene coordinates.  The problem is, the transformation always yields coordinates that correspond to the upper left corner of the control's root pane.
In other words, it's as if the Circle is positioned at the upper left corner of the custom control (when, in fact, it's positioned near the lower right corner).
I have other instanced controls already in the scene, and they do not have this issue - converting the Circle's coordinates to scene coordinates works as it should.
It seems obvious that I'm accessing the Circle too soon - that perhaps the scene graph hasn't been fully traversed for the control and the Circle's position within the control's hierarchy hasn't been updated.  I've verified that my attempt to access the Circle's center coordinates occurs after the control's initialize() method is executed, so I'm at a bit of a loss to figure out how to ensure the control's scene graph has been fully updated before I try to manipulate the control...
Any thoughts?

You can read up on how to generate a layout pass.
Most of the time, you don't need to generate a layout pass. 
You could probably modify your logic so that an explicit layout pass request is not needed.

Similar Messages

  • Doing one transform on a shape after another...

    Hi - I am writing a program to create computer artwork and have run into a problem. If I start with a shape (such as a square) and then do a rotation on it I get a diamond... fine... but now what I want to do is stretch the diamond in the x and y directions. For this I'd use scale, but, my problem is that, because the coordinate system was shiftted by the first transform, when I scale in y (for example) the diamond doesn't become stretched, but instead stretches along the old co-ordinate system, so in fact you can see that it is in fact stretching the original square, rather than the new diamond.
    I thought about creating a buffered image from the shape and then stretching that but it's not really great to do that in terms of the rest of my program. Is there any way of doing one transform and then resetting the co-ordinate system so that any further transform I do will apply to the new shape rather than the old one?
    Thanks in advance for any help - I'm really stuck here and I can't believe that you can't do this in Java!
    Olly

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.AffineTransform;
    import javax.swing.*;
    public class TransformTest extends JPanel
        Shape shape;
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(shape == null)
                initShape();
            g2.draw(shape);
            double theta = -Math.PI/4.0;
            Rectangle r = shape.getBounds();
            AffineTransform at =
                AffineTransform.getRotateInstance(theta, r.getCenterX(), r.getCenterY());
            Shape diamond = at.createTransformedShape(shape);
            g2.setPaint(Color.red);
            g2.draw(diamond);
            double xScale = 1.5;
            double yScale = 1.0;
            r = diamond.getBounds();
            double x = (1.0 - xScale) * r.getCenterX();
            double y = (1.0 - yScale) * r.getCenterY();
            at.setToTranslation(x, y);
            at.scale(xScale, yScale);
            diamond = at.createTransformedShape(diamond);
            g2.setPaint(Color.blue);
            g2.draw(diamond);
        private void initShape()
            int w = getWidth();
            int h = getHeight();
            int s = Math.min(w,h)/3;
            int x = (w - s)/2;
            int y = (h - s)/2;
            shape = new Rectangle(x, y, s, s);
        public static void main(String[] args)
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(new TransformTest());
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • Can't edit masks or shapes after creation..?

    I have no idea why... it used to work fine.
    When I make a mask, and finish connecting it, I can't edit it afterwards...I can't select anything, any of the corners, I can move it around but that's about it.
    Yes I'm using the right tool, and I have handles and lines enabled...I don't know what to do but I really need this fixed.
    Any help is appreciated.. Thanks

    Apparently.
    I've not seen this problem. Is there anything you've changed since it worked? New Mouse? Any updates? Anything?
    And I know you said you are using the right tool, just wanna make sure it's this one:
    Patrick

  • How to Click on Shape After Rotating it?

    In trying to answer a question on another forum ([java-forums question|http://www.java-forums.org/awt-swing/20517-how-select-shape-object-after-rotation.html]) on how to click on a shape after it has been rotated, I created an SSCCE (actually a little too big for one, sorry), and got a solution by re-rotating the shape in the mouse listener, but is this a decent solution? Are there better solutions? My so-called SSCCE:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.ArrayList;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.*;
    public class RotateShape {
       private static final int PANEL_WIDTH = 500;
       private static final int SHAPE_WIDTH = 100;
       private static final Dimension MAIN_SIZE =
          new Dimension(PANEL_WIDTH, PANEL_WIDTH);
       private static final int SLIDER_MIN = -180;
       private static final int SIDER_MAX = 180;
       private static final int MAJOR_TICK = 30;
       private static final int MINOR_TICK = 15;
       private List<MyShape> myShapeList = new ArrayList<MyShape>();
       private JPanel mainPanel = new JPanel();
       private JPanel drawingPanel = createDrawingPanel();
       private AffineTransform transform = new AffineTransform();
       private JSlider rotationSlider;
       public RotateShape() {
          mainPanel.setLayout(new BorderLayout());
          mainPanel.add(drawingPanel, BorderLayout.CENTER);
          mainPanel.add(createTransformPanel(), BorderLayout.SOUTH);
       private JPanel createTransformPanel() {
          rotationSlider = new JSlider(SLIDER_MIN, SIDER_MAX, 0);
          rotationSlider.setMajorTickSpacing(MAJOR_TICK);
          rotationSlider.setMinorTickSpacing(MINOR_TICK);
          rotationSlider.setPaintLabels(true);
          rotationSlider.setPaintTicks(true);
          rotationSlider.setPaintTrack(true);
          rotationSlider.setSnapToTicks(true);
          rotationSlider.addChangeListener(new SliderListener());
          JPanel transformingPanel = new JPanel(new BorderLayout());
          transformingPanel.setBorder(BorderFactory.createEtchedBorder());
          transformingPanel.add(rotationSlider);
          return transformingPanel;
       @SuppressWarnings("serial")
       private JPanel createDrawingPanel() {
          if (drawingPanel != null) {
             return drawingPanel;
          drawingPanel = new JPanel() {
             @Override
             protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                myPaint(g);
          int leftUpperCenter = PANEL_WIDTH / 4;
          int x = leftUpperCenter - SHAPE_WIDTH / 2;
          int y = x;
          MyShape rect = new MyShape(
                new Rectangle2D.Double(x, y, SHAPE_WIDTH, SHAPE_WIDTH));
          MyShape circle = new MyShape(
                new Ellipse2D.Double(PANEL_WIDTH - x - SHAPE_WIDTH,
                      y, SHAPE_WIDTH, SHAPE_WIDTH));
          MyShape roundedRect = new MyShape(new RoundRectangle2D.Double(x,
                PANEL_WIDTH - y - SHAPE_WIDTH, SHAPE_WIDTH, SHAPE_WIDTH, 30, 30));
          myShapeList.add(rect);
          myShapeList.add(circle);
          myShapeList.add(roundedRect);
          drawingPanel.setPreferredSize(MAIN_SIZE);
          drawingPanel.addMouseListener(new MouseAdapter() {
             public void mousePressed(MouseEvent e) {
                myMousePressed(e);
          return drawingPanel;
       private void myMousePressed(MouseEvent e) {
          for (MyShape myShape : myShapeList) {
             if (myShape.contains(e.getPoint(), transform)) {
                // toggle fill if shape is clicked
                myShape.setFill(!myShape.isFilled());
          drawingPanel.repaint();
       private void myPaint(Graphics g) {
          Graphics2D g2 = (Graphics2D) g;
          g2.setStroke(new BasicStroke(3));
          g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
          AffineTransform oldTransform = g2.getTransform();
          if (transform != null) {
             g2.setTransform(transform);
          g2.setColor(Color.red);
          for (MyShape myShape : myShapeList) {
             if (myShape.isFilled()) {
                myShape.fill(g2);
          g2.setColor(Color.blue);
          for (MyShape myShape : myShapeList) {
             myShape.draw(g2);
          g2.setTransform(oldTransform);
       public JComponent getPanel() {
          return mainPanel;
       private class SliderListener implements ChangeListener {
          public void stateChanged(ChangeEvent e) {
             double theta = Math.PI * rotationSlider.getValue() / 180;
             double center = (double) PANEL_WIDTH / 2;
             transform = AffineTransform.getRotateInstance(theta, center, center);
             drawingPanel.repaint();
       private static void createAndShowGUI() {
          JFrame frame = new JFrame("RotateShape Application");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().add(new RotateShape().getPanel());
          frame.pack();
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
       public static void main(String[] args) {
          javax.swing.SwingUtilities.invokeLater(new Runnable() {
             public void run() {
                createAndShowGUI();
    * Holds a Shape and a boolean filled that tells if Shape is to be filled or not
    class MyShape {
       private Shape shape;
       private boolean filled = false;
       public MyShape(Shape shape) {
          this.shape = shape;
       public boolean isFilled() {
          return filled;
       public void setFill(boolean fill) {
          this.filled = fill;
       public Shape getShape() {
          return shape;
       public void draw(Graphics2D g2) {
          g2.draw(shape);
       public void fill(Graphics2D g2) {
          g2.fill(shape);
       public boolean contains(Point2D p) {
          return shape.contains(p);
       public boolean contains(Point2D p, AffineTransform at) {
          Shape s = at.createTransformedShape(shape);
          return s.contains(p);
    }Many thanks!
    edit: code change -- MyShape has its own draw, fill, contains(point2d), and contains({Point2D, AffineTransform) methods.
    Edited by: Encephalopathic on Aug 13, 2009 5:47 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

        public boolean contains(Point2D p, AffineTransform at) {
         try {
             return shape.contains(at.inverseTransform(p, null));
         } catch (NoninvertibleTransformException e) {
             e.printStackTrace();
             return false;
         // Shape s = at.createTransformedShape(shape);
         // return s.contains(p);
        }Piet
    Edited by: pietblok on 20-aug-2009 6:51
    Changed return value on exception

  • Document Series Error after creation of a new Posting Period

    Hi
    While Creation of a new Document Series for user created UDO (after creation of new Posting Period
    with Period Indicator) on update its showing a message box
    "Application Error occurred, Dump file created in path  C\Program Files\SAP\..\Log......"
    And soon SAP B1 gets exit.
    Can any one help me to come out of this problem.

    Hi,
    Whenever Dump file created, it is high time to log a message to SAP support.  This problem is beyond forum function.
    Thanks,
    Gordon

  • Runtime error while saving the billing document after creation

    hi friends ,
    while saving the billing document after creation , the fallowing discriptive runtime error has come.
    Run time errors    -
      SAPSQL_INVALID_TABLENAME
    Except.              -
      CX_SY_DYNAMIC_OSQL_SEMANTICS

    Dear Unnam,
    There may be several reasons...
    1. If u have enhanced the tcode with some z tables,and that might not be moved properly to prod or not active in data dictonary.
    2. u may not be entering proper data to the input fields.
    3. please check if u have added any z tables to the std tcode.I am exepcting this prob.u may not moved the table or enhancement properly to prod server,
    Please check it...
    Thanks N Regards
    SettyKY

  • Baseline date in Accounting document changed after creation of Invoice List

    Hi all,
    1) User Requirement:-
    Creation of Invoice document(using VF01), Transfer u201CGoods Issue Dateu201D to FI accounting as a Baseline date instead of Invoice creation date.
    To meet the above requirement I did enhancement name: SDVFX008 user exit: EXIT_SAPLV60B_008.
    Its working fine and transfered goods issue date to Accounting(as baseline date) insted of  invoice date.
    2) Problem:-
    After Creation of Invoice List (VF21) system again overwriting baseline date iwith invoice list date.
    Does anyone know how to Stop overwriting baseline date in accounting while creation of invoice list.
    Thanks & Regards
    Sudheer

    Hi Valerie,
    do you recall the User Exit?
    Thanks

  • Purchase order rate change after creation of gr.

    In t- code ME22N PO line item Rate change is possible after creation of GR against that line item.
    We want to restrict the po line item rate change after creation of goods receipt against that line item.
    Please suggest.

    solution 1 : Do not give authorization for ME22
    solution 2 : Grey out price chage , it should only be possible thru info records, and give authorization of info records in secured hands.
    You should not totally restrict price change after GR because there are possibilities that you might require to change rate after goods receipt also. In that case you have to change rate and then have to give restrospective effect to GR.
    try above 2 solutions which are simple

  • How to trigger an SMS after creation of Activity / Interaction Record

    Dear Experts,
    Our Client requirement is to trigger an SMS immediately after creation of an Interaction Record. I want to define an Action for this.
    But what processing type should I use for SMS, (like Method Call, Smart Forms Mail / Fax / Print and Workflow). We are using an external service provider domain to send SMS to our customers. It has been configured in SCOT.
    But from CRM configuration front there is no specific processing type for SMS. then how system reads telephone number from the BP master.
    Kindly help me to resolve the issue, your suggestions will be highly appreciated.
    Best regards
    Raghu ram

    Raghu,
    In your case you could copy a "print" action method class and create a z-version.  Then modify the print action method so that the smartform output triggers a call to your output type.
    Or you could just code a new method that creates a new BCS send request using the CL_BCS document and your output type.
    It just depends on how whether you want to use smartforms to build the message or build it in some other method.
    Take care,
    Stephen

  • Configuration steps involved after creation of new personnel subarea in sap hr module

    Dear Friends,
    Let me know what all config to be done after creation of a new personnel sub area in SAP HR module?
    So that all infotypes including IT0007 & IT0008 are captured for hiring an employee & running the payroll ?
    Reg,
    TD

    Hi Tanuja,
    Normal customization only you have to do for every PA & PSA. if you don't have the steps i will give you the steps.

  • Auto Creation of Delivery with PGI and Billing after creation of Sale Order

    Dear Experts,
    I am having one Req. like...After creation of sales order ..automatic Delivery and Billing should be done.
    Right now i m able to create automatic Delivery but PGI is not happening for that delivery.
    Is there any configuration I have to do ... or by any user exit we can get the solution.
    Can u please provide me solution for this.
    Regards,
    Sanket.

    Hello,
    yes, you can create the PGI Atomatically by BATCH JOB using the program nder the VL23 transaction code.
    Goto the Transaction code SM36 to create a job for the program  SAPMSSY0 which is the program for the AUTO PGI
    create a variant for the Delivery document types and sales organisation combinatioans and add this variant to the bath job created in SM36.
    Set the time of the Job to run after every 5 minutes, so once the job exected it will pcik all the Deliveries which are pending for the PGI.
    After the PGI done you can run SDBILLDL program to create the Billing for all the document which were cleared and due for Billing.
    Hope it is clear for yo, please revert if you need frther clarification .
    santosh

  • No cubes are reflecting in XIP ,after creation of manual IDOC

    Hi Experts,
    I am got a mail from client saying that "No cubes are reflecting in XIP ,after creation of manual IDOC"..
    Please tell me weather this is issue is related to XI or not if it so, Can you please anybody tell me how to look into this type of issue...
    Please help me..
    Many thanks in advance..
    Regards
    Raj

    Hi ,
    Thank you Sourabh, so I need to get the IDOC basic type from customer and need to check the IDOC using IDX5. Please correct me if I am wrong..
    With Warm Regards
    Raj

  • Serial Numbers are not downloading after creation of Delivery in ECC

    Dear all,
    As per client business process, we need to download Serial numbers after creation of Outbound delivery.
    I could see the generated Serial numbers in ECC Delivery document, but those Serial numbers are not downloading into CRM.
    I have already done initial download for SERIALNUMBER object and I could see downloaded serial numbers in COM_TA_R3_ID Table.
    But after creation of Outbound delivery in ECC, those delivered serialnumbers are not available in CRM system, even after successful data transfer of Sales Order, Delivery, PGI and Invoice documents Information.
    Kindly help me in resolving the above issue
    Best regards
    Raghu ram

    Hi
    1.Check in material master whether serial number management is active in Plant data/stor Tab and serial number profile is assigned
    2. Check while doing MIGO once if u enter the material and transfer qty you are getting the serial number tab or not
    3. If everything is ok, then after posting the document check the serial number status in IQ09, check the stock type and the storgae location in the serdata tab
    Regards
    Amuthan M

  • Can i edit a vector shape after it's been deselected?

    can i edit a vector shape after it's been deselected?
    the properties palette seems to loose it's values apart from density and feather. Can I not return to a shape to add rounded corners etc?

    That's because you're on the mask pane instead of the object properties pane in the properties panel.
    Look at the icons at the top of the panel that show different panes.

  • Report or table Customer have no transactions after creation

    Hi Friends,
    We have around 1500 customers in the system. Is there any standard report which we know that customers have no transactions after creation or we extract the data from table.
    Thanks & Regards,
    Pankaj

    Please do V look up in the excel between original customer list and BSID and BSAD customer list.
    There is one transaction but it'll show the accounts with out sales S_ALR_87012186 - Customer Sales
    Rgds
    Murali. N

Maybe you are looking for

  • PSE 11 Guided Edit will not initialize

    I've installed PSE 11 on my iMac running OS 10.7.5. Guided edit hangs after initializing about 75% when I try to run it from my main user (administrator) account. It works fine from a second user account. Does anyone have any ideas about getting it t

  • Text Member Director bug?

    Hi there, Whilst trying to track down what I though was my own bug, I discovered that with Director 8.5's text member charPosToLoc() function I seem to have found a strange anomaly.... 1. Create a text member. Set framing to Adjust To Fit and wordWra

  • WHENEVER SQLERROR Problem

    Below is my sql saved as testing.sql SET PAGESIZE 0 WHENEVER SQLERROR EXIT SQL.SQLCODE; WHENEVER OSERROR EXIT SQL.OSCODE; SPOOL /u021/idaho/load_scripts/ebiz_ctgry_prodfam/build_ebiz_ctgry_prodfam_1.og select productid, categoryid, sequence, inherit

  • Events Triggered

    hi  guys i am not understand why the out put is 1,2,99. please explain me Events Triggered in the Order Dictated by the Driver Program 1  report ztx1702. 2  data f1 type i value 1. 3 4  end-of-selection. 5    write: / '3.  f1 =', f1. 6 7  start-of-se

  • InDesign v 8.0.1 crashing when I try to package or pdf

    I am recently upgraded to InDesign version 8.0.1, running on a Macbook Air with Mountain Lion 10.8.2. I opened a file I created in InDesign CS3. It opened fine, no issues at all except having to relink a few things and resolve some font conflicts. Ho