コード例 #1
0
ファイル: TextLine.java プロジェクト: mytnyk/PRIAMUS
  /**
   * Copy the state of the parsed Textline into the existing object.
   *
   * @param t The TextLine to get the state information from.
   */
  public void copyState(TextLine t) {
    if (t == null) return;

    font = t.getFont();
    color = t.getColor();
    justification = t.getJustification();

    if (font == null) return;
    fontname = font.getName();
    fontstyle = font.getStyle();
    fontsize = font.getSize();

    parse = true;
  }
コード例 #2
0
ファイル: Graph2D.java プロジェクト: corywalker/simuconomy
 /**
  * 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
ファイル: VectorSet.java プロジェクト: mytnyk/PRIAMUS
  /**
   * 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);
    }
  }