Exemplo n.º 1
0
  public Rect prepareDraw(Canvas _canvas) {
    if (isCollapsed()) {
      rect = Instruction.prepareDraw(_canvas, getCollapsedText(), this);
      return rect;
    }

    rect.top = 0;
    rect.left = 0;

    rect.right = 2 * Math.round(E_PADDING / 2);

    FontMetrics fm = _canvas.getFontMetrics(Element.font);

    rect.right = Math.round(2 * (Element.E_PADDING / 2));
    for (int i = 0; i < getText().count(); i++) {
      if (rect.right
          < getWidthOutVariables(_canvas, getText().get(i), this) + 2 * Math.round(E_PADDING / 2)) {
        rect.right =
            getWidthOutVariables(_canvas, getText().get(i), this) + 2 * Math.round(E_PADDING / 2);
      }
    }

    rect.bottom = 2 * Math.round(E_PADDING / 2) + getText().count() * fm.getHeight();

    r = q.prepareDraw(_canvas);

    rect.right = Math.max(rect.right, r.right + E_PADDING);
    rect.bottom += r.bottom + E_PADDING;
    return rect;
  }
Exemplo n.º 2
0
 public Element copy() {
   Element ele = new Subqueue();
   ele.setColor(this.getColor());
   for (int i = 0; i < children.size(); i++) {
     ((Subqueue) ele).addElement(((Element) children.get(i)).copy());
   }
   return ele;
 }
Exemplo n.º 3
0
  // START KGU 2015-10-11: Merged with getElementByCoord, which had to be overridden as well for
  // proper Comment popping
  //	public Element selectElementByCoord(int _x, int _y)
  //	{
  //		Element selMe = super.selectElementByCoord(_x,_y);
  //		Element sel = q.selectElementByCoord(_x,_y);
  //		if(sel!=null)
  //		{
  //			selected=false;
  //			selMe = sel;
  //		}
  //
  //		return selMe;
  //	}
  @Override
  public Element getElementByCoord(int _x, int _y, boolean _forSelection) {
    Element selMe = super.getElementByCoord(_x, _y, _forSelection);
    Element sel = q.getElementByCoord(_x, _y, _forSelection);
    if (sel != null) {
      if (_forSelection) selected = false;
      selMe = sel;
    }

    return selMe;
  }
Exemplo n.º 4
0
 public Element copy() {
   // Bugfix KGU#83 (bug #32) 2015-11-14: Instead of a Forever loop, a For loop had been created!
   Forever ele = new Forever(new StringList());
   ele.setComment(this.getComment().copy());
   ele.setColor(this.getColor());
   ele.q = (Subqueue) this.q.copy();
   ele.q.parent = ele;
   // START KGU#82 (bug #31) 2015-11-14
   ele.breakpoint = this.breakpoint;
   // END KGU#82 (bug #31) 2015-11-14
   return ele;
 }
Exemplo n.º 5
0
 public Forever(StringList _strings) {
   super(_strings);
   q.parent = this;
   setText(_strings);
 }
Exemplo n.º 6
0
 public Forever() {
   super();
   q.parent = this;
 }
Exemplo n.º 7
0
  public void draw(Canvas _canvas, Rect _top_left) {
    if (isCollapsed()) {
      Instruction.draw(_canvas, _top_left, getCollapsedText(), this);
      return;
    }

    Rect myrect = new Rect();
    // START KGU 2015-10-13: All highlighting rules now encapsulated by this new method
    // Color drawColor = getColor();
    Color drawColor = getFillColor();
    // END KGU 2015-10-13
    FontMetrics fm = _canvas.getFontMetrics(font);
    //		int p;
    //		int w;

    // START KGU 2015-10-13: Became obsolete by new method getFillColor() applied above now
    //		if (selected==true)
    //		{
    //			drawColor=Element.E_DRAWCOLOR;
    //		}
    // END KGU 2015-10-13

    Canvas canvas = _canvas;
    canvas.setBackground(drawColor);
    canvas.setColor(drawColor);

    // draw background
    myrect = _top_left.copy();
    canvas.fillRect(myrect);

    // draw shape
    rect = _top_left.copy();
    canvas.setColor(Color.BLACK);
    canvas.drawRect(_top_left);

    myrect = _top_left.copy();
    myrect.bottom =
        _top_left.top + fm.getHeight() * getText().count() + 2 * Math.round(Element.E_PADDING / 2);
    canvas.drawRect(myrect);

    myrect.bottom = _top_left.bottom;
    myrect.top = myrect.bottom - E_PADDING;
    canvas.drawRect(myrect);

    myrect = _top_left.copy();
    myrect.right = myrect.left + E_PADDING;
    canvas.drawRect(myrect);

    // fill shape
    canvas.setColor(drawColor);
    myrect.left = myrect.left + 1;
    myrect.top = myrect.top + 1;
    myrect.bottom = myrect.bottom;
    myrect.right = myrect.right - 1;
    canvas.fillRect(myrect);

    myrect = _top_left.copy();
    myrect.bottom =
        _top_left.top + fm.getHeight() * getText().count() + 2 * Math.round(E_PADDING / 2);
    myrect.left = myrect.left + 1;
    myrect.top = myrect.top + 1;
    myrect.bottom = myrect.bottom;
    myrect.right = myrect.right - 1;
    canvas.fillRect(myrect);

    myrect.bottom = _top_left.bottom;
    myrect.top = myrect.bottom - Element.E_PADDING;
    myrect.left = myrect.left + 1;
    myrect.top = myrect.top + 1;
    myrect.bottom = myrect.bottom;
    myrect.right = myrect.right;
    canvas.fillRect(myrect);

    // draw comment
    if (Element.E_SHOWCOMMENTS == true && !comment.getText().trim().equals("")) {
      // START KGU 2015-10-11: Use an inherited helper method now
      //			canvas.setBackground(E_COMMENTCOLOR);
      //			canvas.setColor(E_COMMENTCOLOR);
      //
      //			Rect someRect = _top_left.copy();
      //
      //			someRect.left+=2;
      //			someRect.top+=2;
      //			someRect.right=someRect.left+4;
      //			someRect.bottom-=1;
      //
      //			canvas.fillRect(someRect);
      this.drawCommentMark(canvas, _top_left);
      // END KGU 2015-10-11
    }
    // START KGU 2015-10-11
    // draw breakpoint bar if necessary
    this.drawBreakpointMark(canvas, _top_left);
    // END KGU 2015-10-11

    // draw text
    for (int i = 0; i < getText().count(); i++) {
      String text = this.getText().get(i);
      text = BString.replace(text, "<--", "<-");

      canvas.setColor(Color.BLACK);
      writeOutVariables(
          canvas,
          _top_left.left + Math.round(E_PADDING / 2),
          _top_left.top + Math.round(E_PADDING / 2) + (i + 1) * fm.getHeight(),
          text,
          this);
    }

    // draw children
    myrect = _top_left.copy();
    myrect.left = myrect.left + Element.E_PADDING - 1;
    myrect.top =
        _top_left.top + fm.getHeight() * getText().count() + 2 * Math.round(E_PADDING / 2) - 1;
    myrect.bottom = myrect.bottom - E_PADDING + 1;
    q.draw(_canvas, myrect);
  }