protected void processClick(MouseEvent e) {
    if (e.getButton() != MouseEvent.BUTTON1) {
      popcoord = imagePanel.getCoord(e.getPoint());
    }
    if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1) {
      p("GeneralDensityPanel.processClick");
      WellSelection sel = imagePanel.getWellSelection();
      if (sel == null && imagePanel.getWellCoordinate() == null) {
        p("GeneralDensityPanel.processClick. Got no well selection or coordinate");
        return;
      }
      p(
          "Got selection from image: "
              + ", sel is: "
              + sel
              + ", area offset="
              + imagePanel.getAreaOffsetX()
              + "/"
              + imagePanel.getAreaOffsetY());
      if (sel != null) {
        ArrayList<WellCoordinate> coords = getCoords(sel);
        sel.setAllWells(coords);
        p("publishing SELECTION");
        publishSelection(sel);
      }

      WellCoordinate coord = imagePanel.getWellCoordinate();

      if (wellcontext == null && expcontext != null) {
        wellcontext = expcontext.getWellContext();
      }
      if (coord != null && wellcontext != null) {
        wellcontext.setCoordinate(coord);
        wellcontext.loadMaskData(coord);
        p("publishing relative coord: " + coord);
        publishCoord(coord);
      }
    }
    return;
  }
  public void update(
      String region,
      String subtitle,
      WellContext context,
      HashMap<Integer, EnumMap<ResultType, WellFlowDataResult>> flowmap,
      ArrayList<Integer> flows) {
    this.context = context;
    this.region = region;
    this.subtitle = subtitle;
    //  this.file = file;
    this.flowmap = flowmap;
    this.flows = flows;

    this.coord = context.getCoordinate();

    if (chartPanel != null) {
      remove(chartPanel);
    }

    if (context == null) {
      err("NO context!");
      return;
    }

    if (flowmap == null || flowmap.size() < 1) {
      p("No flowmap, no data");
      return;
    }

    dataset = null;
    dataset = createDataset();
    chart = createChart(dataset);

    //   p("Got new dataset: flows=" + flows);
    chartPanel = new ChartPanel(chart, false);

    add("Center", chartPanel);
    //    chart.fireChartChanged();
    dataset.addChangeListener(chart.getPlot());
    //   chart.getPlot().datasetChanged(new DatasetChangeEvent(this, dataset));
    //   chart.setNotify(true);
    chartPanel.chartChanged(new ChartChangeEvent(dataset, chart));
    //  chartPanel.updateUI();
    chartPanel.repaint();
  }
  private XYSeriesCollection createDataset() {
    dataset = new XYSeriesCollection();
    // for (int series = 0; series < res.length; series++) {
    // one for each frame

    baselist = "";
    flowlist = "";
    EnumMap<ResultType, WellFlowDataResult> subresults = null;
    if (subtract > -1) {
      subresults = flowmap.get(subtract);
    }
    p("Creating dataset for flows " + flows);
    for (int flow : flows) {
      EnumMap<ResultType, WellFlowDataResult> results = flowmap.get(flow);
      boolean done = false;
      p("processing flow " + flow);
      if (results != null) {
        for (ResultType key : results.keySet()) {
          // p("got "+key.getName());
          if (key.isShow()) {
            String base = null;
            WellFlowDataResult dataresult = results.get(key);
            if (!done) {
              done = true;
              flowlist += flow + " ";
              if (dataresult.isPrerun()) {
                baselist = " prerun";
              } else if (dataresult.isBfPost()) {
                baselist = " bf post ";
              } else if (dataresult.isBfPre()) {
                baselist = " bf pre";
              }
              if (dataresult.isAcq()) {
                base = "" + context.getBase(flow);
                baselist += base;
              }
            }

            WellFlowDataResult subresult = null;
            if (subresults != null) {
              subresult = subresults.get(key);
            }
            //   p("adding to series " + dataresult.getName() + ":" +
            // Arrays.toString(dataresult.getData()));
            double[] nframedata = dataresult.getData();
            double[] ndata = new double[nframedata.length];
            double[] sdata = null;
            if (subresult != null) {
              p("SUBTRACTING FLOW " + subtract);
              sdata = subresult.getData();
            }
            String serieskey = dataresult.getName() + " flow " + dataresult.getFlow();
            if (base != null) {
              serieskey += " " + base;
            }
            XYSeries seriesres = new XYSeries(serieskey);
            seriesres.setKey(serieskey);
            for (int f = 0; f < nframedata.length; f++) {
              long ts = dataresult.getTimestamps()[f];
              ndata[f] = nframedata[f] - nframedata[0];
              if (sdata != null) {
                ndata[f] = ndata[f] - (sdata[f] - sdata[0]);
              }
              seriesres.add(ts, ndata[f]);
            }
            dataset.addSeries(seriesres);
          }
        }
        //  else p("Not showing "+key.getName());

      } else p("NO results for flow " + flow);
    }

    //   }
    return dataset;
  }