Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7886247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:16:15+00:00 2026-06-03T05:16:15+00:00

I have a group of shapes like this: Group g = new Group(); Rectangle

  • 0

I have a group of shapes like this:

Group g = new Group();
Rectangle r = new Rectangle( 100, 100, 50, 50 );
Circle c = new Circle( 125, 125, 10 );
g.getChildren().addAll( r, c );

and a Line, which is not part of the group, that ends at the centre of the circle.

Line l = new Line( 0, 0, 125, 125 );

I have made it so that the group can be dragged around as per the Mouse Events demo in Ensemble (just a couple of mouse listeners that update the x and y translation property). What I would like though is for the end of the line to follow the centre of the circle. That means updating the endX and endY properties of the line.

The problem I’m having is that endX and endY are in scene local space (I think). When I drag the group around the screen the centerX and centerY properties of the circle don’t get updated. All I seem to get is changes to translationX and translationY on the group. I can’t figure out how I find the new centre of the circle after (and during) the drag operation.

Pointers very gratefully received as this has got me tearing my hair out!

The best solution I’ve come up with is to put a translation listener on the group, get the centre position of the circle and then add the translation of the group but the results aren’t exactly great the end of the line roughly follows the circle but jumps about and drifts away. Something like this:

translateXProperty().addListener( new ChangeListener<Number>() {
    public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number newValue) {
        Connector c = getInputConnectors().get( 0 );
        double x = circle.getCenterX();
        double y = circle.getCenterY();
        line.setEndX( x + newValue.doubleValue());
    }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:16:17+00:00Added an answer on June 3, 2026 at 5:16 am

    Use binding:

        l.endXProperty().bind(g.translateXProperty().add(c.centerXProperty()));
        l.endYProperty().bind(g.translateYProperty().add(c.centerYProperty()));
    

    P.S.: your way can work too, but note you should have listeners for both x and y property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a visual brush which is a group of shapes, the main colour
I have a shape in Visio which is a group. The group shape can
I have group of stored procedures with names like 'somename_%'. Are there any way
I have a group of three radio buttons. Depending on which radio button is
I have a group of buttons that should act like toggle buttons, but also
I have group of checkboxes nearly equals to 100 all are with name checkbox1...checkbox1oo.
This one's driving me crazy... I have a loop which adds an event listener
I have group of check boxes named as modules[]. I want to access them
currently in my update controller method I have: @group.attributes = { :title => params[:group][:title],
I have a group of links that I call fancybox on with the arrows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.