Package org.jhotdraw.draw

Examples of org.jhotdraw.draw.BezierFigure


  private static final long serialVersionUID = 1L;

  public static BezierFigure createArrowForLinePath(BezierFigure linePath, int direction, boolean isExit) {
    Double arrowPointPosition = new Double();
    BezierFigure arrow = new BezierFigure();
   
    if (isExit) {
      arrowPointPosition.x = linePath.getStartPoint().x;
      arrowPointPosition.y = linePath.getStartPoint().y;
    } else {
      arrowPointPosition.x = linePath.getEndPoint().x;
      arrowPointPosition.y = linePath.getEndPoint().y;
    }
   
    Double topArmEndPosition = new Double();

    topArmEndPosition.x = arrowPointPosition.x + (direction * -SVGConstants.DEFAULT_ARROW_LENGTH);
    topArmEndPosition.y = arrowPointPosition.y - SVGConstants.DEFAULT_ARROW_HEIGHT;

    arrow.addNode(new BezierPath.Node(arrowPointPosition));
    arrow.addNode(new BezierPath.Node(topArmEndPosition));

   
    Double bottomArmEndPosition = new Double();
    bottomArmEndPosition.x = arrowPointPosition.x + (direction * -SVGConstants.DEFAULT_ARROW_LENGTH);
    bottomArmEndPosition.y = arrowPointPosition.y + SVGConstants.DEFAULT_ARROW_HEIGHT;
    arrow.addNode(new BezierPath.Node(arrowPointPosition));
    arrow.addNode(new BezierPath.Node(bottomArmEndPosition));
   
    return arrow;
  }
View Full Code Here


    lifelineStartPosition.x = getLifelineHPos();
    lifelineStartPosition.y = instanceBox.getBounds().height;
    Double lifelineEndPosition = new Double();
    lifelineEndPosition.x = lifelineStartPosition.x;
    lifelineEndPosition.y = vEnd;
    BezierFigure pathFigure = new BezierFigure();
    pathFigure.addNode(new BezierPath.Node(lifelineStartPosition));
    pathFigure.addNode(new BezierPath.Node(lifelineEndPosition));
    lifeline.basicAdd(pathFigure);
   
    add(1, lifeline);
  }
View Full Code Here

      SVGPathFigure interactionLine = new SVGPathFigure();
      Double interactionLineStartPosition = new Double();
      interactionLineStartPosition.x = 0;
      interactionLineStartPosition.y = 0;

      BezierFigure linePath = new BezierFigure();
      linePath.addNode(new BezierPath.Node(interactionLineStartPosition));

      boolean selfCall = caller == target;

      if (selfCall) {
        Double selfCallIntermidiateTopPosition = new Double();
        length = heightIncrement;
        selfCallIntermidiateTopPosition.x = interactionLineStartPosition.x
            + length;
        selfCallIntermidiateTopPosition.y = interactionLineStartPosition.y;
        linePath.addNode(new BezierPath.Node(
            selfCallIntermidiateTopPosition));
        Double selfCallIntermidiateBottomPosition = new Double();
        height = heightIncrement;
        selfCallIntermidiateBottomPosition.x = interactionLineStartPosition.x
            + length;
        selfCallIntermidiateBottomPosition.y = interactionLineStartPosition.y
            + height;
        linePath.addNode(new BezierPath.Node(
            selfCallIntermidiateBottomPosition));
        length = 0;
      }

      Double interacitonlineEndPosition = new Double();
      interacitonlineEndPosition.x = interactionLineStartPosition.x
          + length;
      interacitonlineEndPosition.y = interactionLineStartPosition.y
          + height;

      linePath.addNode(new BezierPath.Node(interacitonlineEndPosition));
      interactionLine.basicAdd(linePath);

      int direction = (interacitonlineEndPosition.x > interactionLineStartPosition.x) ? 1
          : -1;
      if (modelInteraction.isExit()) {
        direction = -direction;
      }

      if (selfCall) {
        direction = -1;
      }

      SVGPathFigure interactionArrow = new SVGPathFigure();
      SVGTextFigure interactionLabel = new SVGTextFigure();
      String interactionText;

      if (modelInteraction.isExit()) {
        SVGAttributeKeys.STROKE_DASHES.set(interactionLine,
            SVGConstants.DEFAULT_INTERACTION_EXIT_DASHES);
        SVGAttributeKeys.STROKE_COLOR.set(interactionLine,
            SVGConstants.DEFAULT_EXIT_STROKE_COLOR);
        SVGAttributeKeys.STROKE_OPACITY.set(interactionLine,
            SVGConstants.DEFAULT_EXIT_STROKE_OPACITY);
        SVGAttributeKeys.STROKE_COLOR.set(interactionArrow,
            SVGConstants.DEFAULT_EXIT_STROKE_COLOR);
        SVGAttributeKeys.STROKE_OPACITY.set(interactionArrow,
            SVGConstants.DEFUALT_EXIT_ARROW_STROKE_OPACITY);
        SVGAttributeKeys.FILL_OPACITY.set(interactionLabel,
            SVGConstants.DEFAULT_EXIT_STROKE_OPACITY);
        interactionArrow.basicAdd(SVGArrow.createArrowForLinePath(
            linePath, direction, true && !selfCall));
        Instance result = modelInteraction.getResult();
        // TODO: check if null check is necessary
        if (result != null) {
          // TODO: this string format should be abstracted since the
          // parameters use the same format and might want to make
          // display configurable
          interactionText = result.getSimpleName() + ":"
              + result.getSimpleTypeName();
        } else {
          // TODO: initial implementation: verify this is ok
          interactionText = "null";
        }
      } else {
        SVGAttributeKeys.STROKE_COLOR.set(interactionLine,
            SVGConstants.DEFAULT_STROKE_COLOR);
        SVGAttributeKeys.STROKE_COLOR.set(interactionArrow,
            SVGConstants.DEFAULT_STROKE_COLOR);
        if (modelInteraction.isStatic()) {
          SVGAttributeKeys.FONT_ITALIC.set(interactionLabel, true);
        }
        interactionArrow.basicAdd(SVGArrow.createArrowForLinePath(
            linePath, direction, false));
        interactionText = String.format(
            SVGConstants.INTERACTION_LABEL_FORMAT, modelInteraction
                .getSimpleName());
        interactionText = String.format(
            SVGConstants.INTERACTION_LABEL_WITH_PARAMETERS_FORMAT,
            modelInteraction.getSimpleName(),
            createArgumentsString(modelInteraction.getArguments()));

      }

      interactionLabel.setText(interactionText);
      AffineTransform labelTransform = new AffineTransform();
      if (selfCall) {
        length = heightIncrement * 2;
      }
      double xTranslation = (length / 2)
          - interactionLabel.getBounds().getCenterX();
      double yTranslation = interactionLineStartPosition.y
          - (interactionLabel.getBounds().height / 2);
      labelTransform.setToTranslation(xTranslation, yTranslation);
      interactionLabel.transform(labelTransform);
      add(interactionLabel);

      AttributeKeys.FILL_COLOR.set(interactionLine, null);

      linePath.setClosed(false);
      add(interactionLine);
      add(interactionArrow);

      AffineTransform transform = new AffineTransform();
      transform.setToTranslation(callerHPosition, vPostion);
View Full Code Here

TOP

Related Classes of org.jhotdraw.draw.BezierFigure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.