示例#1
0
  /**
   * Parse the text then draw it.
   *
   * @param g Graphics context
   * @param x pixel position of the text
   * @param y pixel position of the text
   * @param j justification of the text
   */
  public void draw(Graphics g, int x, int y, int j) {
    justification = j;

    if (g == null) return;

    draw(g, x, y);
  }
示例#2
0
 /**
  * A hook into the Graph2D.paint method. This is called after everything has been drawn. The
  * rectangle passed is the dimension of the data window.
  *
  * @params g Graphics state
  * @params r Rectangle containing the data
  */
 public void paintLast(Graphics g, Rectangle r) {
   if (lastText != null) {
     lastText.draw(g, r.width / 2, r.height / 2, TextLine.CENTER);
   }
 }
示例#3
0
  /**
   * Draw a legend for this Vector set
   *
   * @param g Graphics context
   * @param w Data Window
   */
  protected void draw_legend(Graphics g, Rectangle w) {
    Color c = g.getColor();
    TextLine value = new TextLine();
    double dx;
    int ix, iy;
    int length;

    if (!drawlegend) return;
    /*
     ** Calculate the vector magnitude of a line legend_length
     ** pixels long. This will be our standard vector
     */

    dx = xrange * ((double) legend_length) / ((double) w.width) / getScaleFactor();

    value.parseDouble(dx, 3);
    /*
     ** Calculate the length of the legend
     */
    length = legend_length + value.getWidth(g) + value.charWidth(g, ' ');
    /*
     ** Calculate the position of the legend if needed.
     */

    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);
    } else if (legend_ix == -1 && legend_iy == -1) {
      legend_ix = w.x + w.width / 2 - length / 2;
      legend_iy = w.y - value.getAscent(g) / 2;
    }

    /*
     ** In what follows the vector tail is the zero point. It is on
     ** the right - the vector points to the left
     */
    if (linecolor != null) g.setColor(linecolor);
    /*
     ** Draw the standard vector
     */

    g.drawLine(legend_ix, legend_iy, legend_ix + legend_length, legend_iy);

    ix = legend_ix + (int) (0.25 * (double) legend_length + 0.5);
    iy = legend_iy - (int) (0.25 * (double) legend_length + 0.5);

    g.drawLine(legend_ix, legend_iy, ix, iy);

    ix = legend_ix + (int) (0.25 * (double) legend_length + 0.5);
    iy = legend_iy + (int) (0.25 * (double) legend_length + 0.5);

    g.drawLine(legend_ix, legend_iy, ix, iy);
    /*
     ** Add the value of the standard vector. To the right of the vector
     */
    value.draw(g, legend_ix + legend_length + value.charWidth(g, ' '), iy, TextLine.LEFT);
    /*
     ** Add any legend text (above the vector) that might have been
     ** defined.
     */

    g.setColor(c);

    if (legend_text != null && !legend_text.isNull()) {

      legend_text.draw(
          g,
          legend_ix + length / 2,
          iy - value.getAscent(g) - legend_text.getDescent(g) - legend_text.getLeading(g),
          TextLine.CENTER);
    }
  }