public void setRegion(Region r) {
    super.setRegion(r);

    watsonProbes.clear();
    crickProbes.clear();
    points = null;
    scale.setScale(0.0, 1.0);

    Iterator<ExpressionProbe> probes = prober.execute(r);
    while (probes.hasNext()) {
      ExpressionProbe probe = probes.next();
      int bp = probe.getLocation();
      double value = probe.mean();

      if (!Double.isNaN(value)) {
        if (probe.getStrand() == '+') {
          watsonProbes.add(new Pair<Integer, Double>(bp, value));
        } else {
          crickProbes.add(new Pair<Integer, Double>(bp, value));
        }

        scale.updateScale(value);
      }
    }
  }
  public void paintItem(Graphics g, int x1, int y1, int x2, int y2) {

    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    PaintableScale xScale = getPropertyValue(xScaleKey);
    PaintableScale yScale = getPropertyValue(yScaleKey);
    Color color = getPropertyValue(colorKey);

    Double min = xScale.getMin(), max = xScale.getMax();
    Double range = max - min;
    int w = x2 - x1 + 1;
    int h = y2 - y1 + 1;

    int px = -1, py = -1;

    g.setColor(Color.black);
    if (xScale.getMin() < 0.0 && xScale.getMax() > 0.0) {
      double zf = xScale.fractionalOffset(0.0);
      int x = x1 + (int) Math.round(zf * (double) w);
      g.drawLine(x, y1, x, y2);
    }
    if (yScale.getMin() < 0.0 && yScale.getMax() > 0.0) {
      double zf = yScale.fractionalOffset(0.0);
      int y = y2 - (int) Math.round(zf * (double) h);
      g.drawLine(x1, y, x2, y);
    }

    g.setColor(color);

    for (int x = x1; x <= x2; x++) {
      Double xInput = min + ((double) (x - x1) / (double) w) * range;
      Double yOutput = function.eval(xInput);

      if (yOutput != null) {
        double yf = yScale.fractionalOffset(yOutput);
        int y = y2 - (int) Math.round(yf * (double) h);

        if (px != -1 && py != -1) {
          g.drawLine(px, py, x, y);
        }

        px = x;
        py = y;
      } else {
        px = py = -1;
      }
    }
  }
  public int getYOffset(double value) {
    double frac = scale.fractionalOffset(value);
    int pix = (int) Math.round(frac * (double) height);

    return pix;
  }
  public void paintRegion(Graphics2D g, int x1, int y1, int w, int h) {
    int h2 = h / 2;
    int rad = 3;
    int diam = rad * 2;

    Color lg = Color.cyan;
    Color dg = Color.orange;

    lg = new Color(lg.getRed(), lg.getGreen(), lg.getBlue(), 75);
    dg = new Color(dg.getRed(), dg.getGreen(), dg.getBlue(), 75);

    /*
     * Draw the Baseline
     */
    g.setColor(Color.black);
    g.drawLine(x1, y1 + h, x1 + w, y1 + h);

    Stroke oldStroke = g.getStroke();
    g.setStroke(new BasicStroke((float) 2.0));

    /*
     * Draw the datapoints
     */
    for (ExprPoint ep : points) {
      if (ep.strand == '+') {
        g.setColor(lg);
      } else {
        g.setColor(dg);
      }

      g.drawOval(x1 + ep.x - rad, y1 + ep.y - rad, diam, diam);
    }

    g.setStroke(oldStroke);

    /*
     * Paint the hash marks...
     */
    if (!displayOppositeChannel) {
      g.setColor(Color.black);
      boolean flipper = true;
      for (int value = 100;
          value <= scale.getMax();
          value *= (flipper ? 5 : 2), flipper = !flipper) {
        int yoff = getYOffset((double) value);
        String line = String.format("%d", value);
        int uy = y1 + h2 - yoff, ly = y1 + h2 + yoff;

        g.drawLine(x1, uy, x1 + 10, uy);
        g.drawString(line, x1 + 12, uy + 5);

        g.drawLine(x1, ly, x1 + 10, ly);
        g.drawString(line, x1 + 12, ly + 5);
      }
    }

    /*
     * Draw any selections.
     */

    g.setColor(Color.black);
    for (Point p : selections.keySet()) {
      ExprPoint ep = selections.get(p);
      g.drawLine(p.x, p.y, ep.x, ep.y);
      g.drawString(ep.getLabel(), p.x, p.y);
    }

    /*
     * Draw the label in the upper-right hand corner.
     */
    g.setColor(Color.black);
    Font oldFont = g.getFont();
    Font newFont = new Font("Arial", Font.BOLD, 24);
    g.setFont(newFont);
    FontMetrics fm = g.getFontMetrics();
    int lblHeight = fm.getAscent() + fm.getDescent();
    int lblWidth = fm.charsWidth(label.toCharArray(), 0, label.length());

    int padding = 5;
    int lblx = x1 + w - lblWidth - padding;
    int lbly = y1 + lblHeight + padding;

    g.drawString(label, lblx, lbly);

    g.setFont(oldFont);
  }