Example #1
0
  /**
   * Draw the caption of this association
   *
   * @param f The font to use
   * @param fc The font color to draw with
   * @param fheight The height of the font
   */
  private void drawCaption(Font f, Color fc, long fheight) {
    long w;
    double vx, vy, len;

    // Remove old text glyphs
    if (gName != null) owner.getActiveDisplay().getVirtualSpace().destroyGlyph(gName);
    if (rect != null) owner.getActiveDisplay().getVirtualSpace().destroyGlyph(rect);

    gName = new VText(caption);
    gName.setSpecialFont(f);
    gName.setColor(fc);

    w = owner.getActiveDisplay().getFontWidth(f, caption);

    // Compute Vector
    vx =
        ((ConnectionPoint) line.getPoints().get(1)).getX()
            - ((ConnectionPoint) line.getPoints().get(0)).getX();
    vy =
        ((ConnectionPoint) line.getPoints().get(1)).getY()
            - ((ConnectionPoint) line.getPoints().get(0)).getY();

    // Compute length of Vector
    len = Math.sqrt(vx * vx + vy * vy);

    // Normalize Vector
    vx = vx / len;
    vy = vy / len;

    // For the beginning of the Line
    // if (line != null) gName.moveTo(x
    // + Math.round(Math.round(vx * xoff + px * 20 - w / 2)), y
    // + Math.round(Math.round(vy * 40 + py * 20 - fheight / 2)));
    if (line != null) {
      gName.moveTo(line.getMiddle().x - w / 2, line.getMiddle().y);

      // Draw underlying rectangle
      rect =
          new VRectangleST(
              line.getMiddle().x, Math.round(line.getMiddle().y + 8), 0, w / 2, 12, Color.WHITE);
      rect.setPaintBorder(false);
      rect.setTransparencyValue((float) 0.6);

      owner
          .getActiveDisplay()
          .getVirtualSpaceManager()
          .addGlyph(rect, owner.getActiveDisplay().getVirtualSpace());
    }

    owner
        .getActiveDisplay()
        .getVirtualSpaceManager()
        .addGlyph(gName, owner.getActiveDisplay().getVirtualSpace());
  }
Example #2
0
 /**
  * (non-Javadoc)
  *
  * @see fuml.graphic.model.abstraction.AbstractModelElement#show()
  */
 public void show() {
   super.show();
   line.show();
   if (gName != null) gName.setVisible(true);
 }
Example #3
0
 /**
  * (non-Javadoc)
  *
  * @see fuml.graphic.model.abstraction.AbstractModelElement#hide()
  */
 public void hide() {
   super.hide();
   line.hide();
   if (gName != null) gName.setVisible(false);
 }