@Override
 public void repaint() {
   super.repaint();
   if (imagePanel != null) {
     imagePanel.repaint();
   }
   if (gradient != null) {
     gradient.repaint();
   }
 }
  protected void createAndDrawImage() throws IOException {
    if (gradient != null) {
      remove(gradient);
    }
    createImage();
    drawDensityOnImage();
    if (imagePanel != null) {

      imagePanel.setPixPerCol(pixpercol);
      imagePanel.setPixPerRow(pixperrow);
      imagePanel.setBucketSize(wellDensity.getBucketSize());
      imagePanel.setImage(bimage);
      imagePanel.setCoordscale(coordscale);

    } else {

      imagePanel =
          new WellsImagePanel(
              expcontext,
              BORDER,
              bimage,
              pixpercol,
              pixperrow,
              wellDensity.getBucketSize(),
              this,
              nrWidgets);

      imagePanel.setCoordscale(coordscale);
      //   p("WellsImagePanel created");
      add("Center", imagePanel);

      imagePanel.addMouseListener(
          new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {

              processClick(e);
            }

            @Override
            public void mouseReleased(MouseEvent e) {

              processClick(e);
            }
          });
      imagePanel.addMouseListener(popAdapter);
    }

    afterImageCreated();
    add("East", gradient);
    gradient.repaint();
    imagePanel.repaint();
    this.repaint();
  }