title: Javafx drag and drop shapes on canvas
body: <p>I am quite beginner in Java and need some help with my application.
  I am would like to use drag and drop on custom made shapes with javafx canvas i.e multiple polygons that make up a bow tie.</p>
  
  <p>I have created a method that draws a bow tie that looks like this:</p>
  
  <pre><code>public void joonistaBowTie(GraphicsContext gc) {
  // Bowtie left side
  gc.setFill(Color.RED);
  double xpoints[] = { 242, 242, 200 };
  double ypoints[] = { 245, 290, 270 };
  int num = 3;
  gc.fillPolygon(xpoints, ypoints, num);
  // Bowtie right side
  gc.setFill(Color.RED);
  double xpoints1[] = { 160, 160, 200 };
  double ypoints1[] = { 245, 290, 270 };
  int num1 = 3;
  gc.fillPolygon(xpoints1, ypoints1, num1);
  // Bowtie middle part
  gc.setFill(Color.RED);
  gc.fillOval(190, 255, 20, 30);
  }
  </code></pre>
  
  <p>I have moved that method into a separate class called BowTie.
  I also have a main class that looks like this:</p>
  
  <pre><code>public class GraafikaNaide extends Application {
  Bowtie bowtie;
  
  @Override
  public void start(Stage primaryStage) {
      primaryStage.setTitle("JavaFX-iga joonistatud kloun");
      Group root = new Group();
      Canvas canvas = new Canvas(1000, 1000);
      GraphicsContext gc = canvas.getGraphicsContext2D();
      joonista(gc);
      root.getChildren().add(canvas);
      primaryStage.setScene(new Scene(root));
      primaryStage.show();
  }
  
  private void joonista(GraphicsContext gc) {
      Bowtie bowtie = new Bowtie();
      bowtie.joonistaBowTie(gc);
  
  }
  </code></pre>
  
  <p>I also found somewhat <a href="http://java-buddy.blogspot.com.ee/2013/07/javafx-drag-and-move-something.html" rel="nofollow">example</a> on how to do drag and drop, but i just lack knowledge on how to implement this code to mine.   </p>
  
  <p>Could someone please help me with this?</p>
  
  <p>Thanks</p>