3 Replies - 699 Views - Last Post: 01 April 2017 - 05:59 AM Rate Topic: -----

#1 sunch0   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-March 17

FXML coordinate system

Posted 31 March 2017 - 03:08 PM

Hello,
I have to write a program that shows a circle in a window, the circle must touch both x and y axis. I try with different coordinates maybe gc.strokeOval(1,5,d,d) gives the closest result to what I have to do. But I really don't get it. Why?
How to determine x and y to the circle, my canvas is 450/550 if that matters.
Is This A Good Question/Topic? 0
  • +

Replies To: FXML coordinate system

#2 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3637
  • View blog
  • Posts: 16,703
  • Joined: 20-September 08

Re: FXML coordinate system

Posted 01 April 2017 - 01:38 AM

Please post your code
Was This Post Helpful? 0
  • +
  • -

#3 sunch0   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-March 17

Re: FXML coordinate system

Posted 01 April 2017 - 02:42 AM

That's the part of the code for drawing the circle
  void initialize() {
        assert canvas != null : "fx:id=\"canvas\" was not injected: check your FXML file 'FXMLdocument.fxml'.";
        GraphicsContext gc = canvas.getGraphicsContext2D();
        drawCircle(gc);
        drawLine(gc);
        intersectionDots(gc);
    }

     String input1 = JOptionPane.showInputDialog("Въведете радиус:");
     double r = Integer.parseInt(input1);
     String input2 = JOptionPane.showInputDialog("Въведете x координата:");
     double x = Integer.parseInt(input2);
   

    private void drawCircle(GraphicsContext gc) {

        double d = r * 2;
      
        gc.beginPath();
        gc.setStroke(Color.BLUE);
        gc.strokeOval(1, 5, d, d);
        gc.stroke();

    }

This post has been edited by CasiOo: 01 April 2017 - 07:24 AM
Reason for edit:: Please use code tags

Was This Post Helpful? 0
  • +
  • -

#4 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3637
  • View blog
  • Posts: 16,703
  • Joined: 20-September 08

Re: FXML coordinate system

Posted 01 April 2017 - 05:59 AM

I'm sort of out of my depth here, as i don't use JavaFX, but what you need to do is access the width and height properties of the component on which you're drawing in order to get the circle geometry
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1