Beispiel #1
0
  /**
   * Draw a legend for this data set
   *
   * @param g Graphics context
   * @param w Data Window
   */
  protected void draw_legend(Graphics g, Rectangle w) {
    Color c = g.getColor();
    Markers m = null;

    if (legend_text == null) return;
    if (legend_text.isNull()) return;

    if (legend_ix == 0 && legend_iy == 0) {
      legend_ix = (int) (w.x + ((legend_dx - xmin) / xrange) * w.width);
      legend_iy = (int) (w.y + (1.0 - (legend_dy - ymin) / yrange) * w.height);
    }

    if (linestyle != DataSet.NOLINE) {
      if (linecolor != null) g.setColor(linecolor);
      g.drawLine(legend_ix, legend_iy, legend_ix + legend_length, legend_iy);
    }

    if (marker > 0) {
      m = g2d.getMarkers();
      if (m != null) {
        if (markercolor != null) g.setColor(markercolor);
        else g.setColor(c);

        m.draw(g, marker, 1.0, legend_ix + legend_length / 2, legend_iy);
      }
    }

    legend_text.draw(
        g,
        legend_ix + legend_length + legend_text.charWidth(g, ' '),
        legend_iy + legend_text.getAscent(g) / 3);

    g.setColor(c);
  }
Beispiel #2
0
  /**
   * Draw the markers. Only markers inside the specified range will be drawn. Also markers close the
   * edge of the clipping region will be clipped.
   *
   * @param g Graphics context
   * @param w data window
   * @see graph.Markers
   */
  protected void draw_markers(Graphics g, Rectangle w) {
    int x1, y1;
    int i;
    //     Calculate the clipping rectangle
    Rectangle clip = g.getClipRect();
    int xcmin = clip.x;
    int xcmax = clip.x + clip.width;
    int ycmin = clip.y;
    int ycmax = clip.y + clip.height;
    /*
     **        Load the marker specified for this data
     */
    Markers m = g2d.getMarkers();

    if (m == null) return;

    //          System.out.println("Drawing Data Markers!");

    for (i = 0; i < length; i += stride) {
      if (inside(data[i], data[i + 1])) {

        x1 = (int) (w.x + ((data[i] - xmin) / xrange) * w.width);
        y1 = (int) (w.y + (1.0 - (data[i + 1] - ymin) / yrange) * w.height);

        if (x1 >= xcmin && x1 <= xcmax && y1 >= ycmin && y1 <= ycmax)
          m.draw(g, marker, markerscale, x1, y1);
      }
    }
  }
  /** Query all genomic regions that intersect 'marker' */
  @Override
  public Markers query(Marker marker) {
    Markers markers = new Markers();

    for (Marker m : this) {
      if (m.intersects(marker)) {
        markers.add(m);

        Markers subMarkers = m.query(marker);
        if (subMarkers != null) markers.add(subMarkers);
      }
    }

    return markers;
  }
 /** A list of all markers in this transcript */
 public Markers markers() {
   Markers markers = new Markers();
   markers.addAll(subIntervals.values());
   return markers;
 }