private static Node createHUBNode(HUB hubObject, Pane canvas, ContextMenu contextMenu) {
    // each hub is represented by a blue rectangle
    Rectangle node = new Rectangle(Data.nodeLength, Data.nodeWidth);
    node.setFill(Color.AQUAMARINE);

    // the hub name in the rectangle
    Label lnodeName = new Label(hubObject.getName());

    // this stackpane stack the label on top of the rectangle to make them
    // one entity
    StackPane nodeContainer = new StackPane();
    nodeContainer.getChildren().addAll(node, lnodeName);
    nodeContainer.relocate(hubObject.getPosX(), hubObject.getPosY());

    // add a popover when one of the hub is clicked
    nodeContainer.addEventHandler(
        MouseEvent.MOUSE_CLICKED,
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            if (event.getButton() == MouseButton.PRIMARY) {
              PopOver popOver =
                  new PopOver(createHUBPopOverContent(hubObject, canvas, contextMenu));
              popOver.setDetachable(false);
              popOver.show(nodeContainer);
              popOver.setOnHiding(
                  new EventHandler<WindowEvent>() {
                    @Override
                    public void handle(WindowEvent e) {
                      hubNodeHidingListener(popOver, hubObject, canvas, contextMenu);
                    }
                  });
            }
            if (event.getButton() == MouseButton.SECONDARY) {
              // if user right click on a HUB then enable the "delete"
              // menu
              contextMenu.getItems().get(2).setDisable(false);
              // when user select an object to delete
              contextMenu
                  .getItems()
                  .get(2)
                  .setOnAction(
                      new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent e) {
                          String hubName = hubObject.getName();
                          TreeSet<String> interfaces = hubObject.getInfs();
                          for (String inf : interfaces) {
                            Pattern pat = Pattern.compile(Data.hubInfPattern);
                            Matcher matcher = pat.matcher(inf);
                            // delete the VM interface that is connected to
                            // the hub
                            if (matcher.find()) {
                              String vmName = matcher.group(1);
                              String vmEth = matcher.group(2);
                              Data.vmMap.get(vmName).removeInf(vmEth);
                            }
                          }
                          // delete the hub
                          Data.hubMap.remove(hubName);
                          draw(canvas, contextMenu);
                        }
                      });
              // disable the "delete option when the popover closes"
              contextMenu.setOnHidden(
                  new EventHandler<WindowEvent>() {
                    @Override
                    public void handle(WindowEvent e) {
                      contextMenu.getItems().get(2).setDisable(true);
                    }
                  });
            }
          }
        });

    return nodeContainer;
  }
  public static void draw(Pane canvas, ContextMenu contextMenu) {
    System.out.println("Number of Vm's Present " + application.Data.vmMap.keySet().size());
    System.out.println("Number of Hub's Present " + application.Data.hubMap.keySet().size());
    // the pane should be cleared each time
    canvas.getChildren().clear();

    // if(!Data.vmMap.isEmpty() && !Data.hubMap.isEmpty()) {
    // if(!(Data.hubMap.size() == 0)) {
    canvas.getChildren().add(createVlanNode("V2", canvas, contextMenu));
    // }

    // we don't actually want to change the value of Data.hubStartPosY
    // instead we initially set our tempPosY to the startPos and alter that
    int tempPosX = Data.hubStartPosX;
    int tempPosY = Data.hubStartPosY;
    // Draw a Blue rectangle for each hub
    for (Map.Entry<String, HUB> hubEntry : application.Data.hubMap.entrySet()) {

      String currentHubName = hubEntry.getKey();
      HUB currentHub = application.Data.hubMap.get(currentHubName);
      currentHub.setPosX(tempPosX);
      currentHub.setPosY(tempPosY);
      canvas.getChildren().add(application.Graphics.createHUBNode(currentHub, canvas, contextMenu));
      // cashe wither the hub has connections
      // if it don't then theres no need to draw the lines
      boolean haveConnections = !currentHub.getInfs().isEmpty();
      // ----- Draws a horizontal line from the hub to the middle of the space
      // between hubs and vms
      if (haveConnections) {
        drawLine(canvas, tempPosX + 100, tempPosY + 50, tempPosX + 150, tempPosY + 50);
      }

      // Draw a Red rectangle for each vm
      tempPosX += 200;
      for (Map.Entry<String, VM> vmEntry : application.Data.vmMap.entrySet()) {
        String currentVMName = vmEntry.getKey();
        VM currentVM = application.Data.vmMap.get(currentVMName);
        for (Map.Entry<String, String> vmInterface : currentVM.getInterfaces().entrySet()) {
          // If the the first three octals of the vm's interface match
          // the first three octals of the hub's subnet
          // Draw the vm to the left of the hub as they are connected
          int ipClass = Data.getIPClass(application.Data.hubMap.get(currentHubName).getNetmask());
          String replaceRegex = "\\.\\d{1," + String.valueOf(ipClass) + "}\\z";
          if (vmInterface
              .getValue()
              .replaceAll(replaceRegex, "")
              .equals(
                  application.Data.hubMap
                      .get(currentHubName)
                      .getSubnet()
                      .replaceAll(replaceRegex, ""))) {
            application.Data.hubMap
                .get(currentHubName)
                .addInf(currentVM.getName() + "." + vmInterface.getKey());
            currentVM.setPosX(tempPosX);
            currentVM.setPosY(tempPosY);
            canvas
                .getChildren()
                .add(application.Graphics.createVMNode(currentVM, canvas, contextMenu));

            // draws a horizontal line from each vm to the middle of
            // the space between hubs and vms
            if (haveConnections) {
              drawLine(canvas, tempPosX, tempPosY + 50, tempPosX - 50, tempPosY + 50);
            }

            tempPosY += 150;
          }
        }
      }
      if (!haveConnections) {
        tempPosY += 150;
      }

      // draw vertical in the middle of the space between hubs and vms
      if (haveConnections) {
        drawLine(canvas, tempPosX - 50, currentHub.getPosY() + 50, tempPosX - 50, tempPosY - 100);
      }
      // draw horizontal line from the vlan to the hub
      drawLine(
          canvas,
          Data.vlanstartPosX + 100,
          currentHub.getPosY() + 50,
          currentHub.getPosX(),
          currentHub.getPosY() + 50);
      tempPosX += 200;
      // tempPosY += 150;
    }
  }