Package org.eclipse.graphiti.datatypes

Examples of org.eclipse.graphiti.datatypes.IDimension


                    text.setValue(businessValue);
                 
                    //We can user the layoutservice to get the new size
                    //but it seems to be broken wrt new lines so we need
                    //to multiply up by number of lines.
                    IDimension dim = GraphitiUi.getUiLayoutService(
                        ).calculateTextSize(
                            businessValue, text.getFont());
                   
                    text.setHeight(2 + (dim.getHeight() *
                        businessValue.split("\n").length));
                    cs.getGraphicsAlgorithm().setHeight(text.getHeight());
                    if (cs.eContainer() instanceof ContainerShape) {
                      ((ContainerShape) cs.eContainer()
                          ).getGraphicsAlgorithm().setHeight(
View Full Code Here


        for (Shape shape : containerShape.getChildren()){

            GraphicsAlgorithm graphicsAlgorithm = shape.getGraphicsAlgorithm();
            IGaService gaService = Graphiti.getGaService();

            IDimension size =
                 gaService.calculateSize(graphicsAlgorithm);

            if (containerWidth != size.getWidth()) {

                if (graphicsAlgorithm instanceof Polyline) {

                    Polyline polyline = (Polyline) graphicsAlgorithm;
                    Point secondPoint = polyline.getPoints().get(1);
View Full Code Here

    // width of text and line (same as visible rectangle)
    for (Shape shape : containerShape.getChildren()) {
      GraphicsAlgorithm graphicsAlgorithm = shape.getGraphicsAlgorithm();
      IGaService gaService = Graphiti.getGaService();
      IDimension size = gaService.calculateSize(graphicsAlgorithm);
      if (rectangleWidth != size.getWidth()) {
        gaService.setWidth(graphicsAlgorithm, rectangleWidth);
        anythingChanged = true;
      }
    }
View Full Code Here

    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    // now try to use the image dimension as figure dimension plus some height spacing
    // for the display label
    Font f = StyleUtil.getStyleForCamelText(getDiagram()).getFont();
    IDimension fontDimension = GraphitiUi.getUiLayoutService().calculateTextSize(label, f);
    Dimension imageDimension = ImageUtils.getImageSize(addedClass.getIconName());

    int image_width = imageDimension.width;
    int image_height = imageDimension.height;
   
    int label_width = fontDimension.getWidth() + LABEL_SPACER_X + LABEL_SPACER_X;
    int label_height = Math.max(fontDimension.getHeight(), TEXT_LABEL_SIZE);

    int content_width = Math.max(Math.max(label_width, image_width), DEFAULT_FIGURE_CONTENT_WIDTH);
   
    // now lets define the shape dimensions
    org.eclipse.swt.graphics.Rectangle baseRect = new org.eclipse.swt.graphics.Rectangle(context.getX(), context.getY(), content_width + BASE_RECT_SPACE_X + BASE_RECT_SPACE_X + SHADOW_WIDTH + INVISIBLE_RIGHT_SPACE, BASE_RECT_SPACE_Y + BASE_RECT_SPACE_Y + image_height + SHADOW_HEIGHT + IMAGE_LABEL_SPACE + label_height + TOP_BOTTOM_SPACE + TOP_BOTTOM_SPACE);
View Full Code Here

      diElements.remove(bpmnShape);
      peService.deletePictogramElement(container);
    }

    GraphicsAlgorithm ga = choreographyContainer.getGraphicsAlgorithm();
    IDimension size = gaService.calculateSize(ga);

    List<ContainerShape> newContainers = new ArrayList<ContainerShape>();
    int y = 0;
    boolean first = true;

    List<InteractionNode> sources = new ArrayList<InteractionNode>();
    if (choreography instanceof ChoreographyTask) {
      for (MessageFlow message : ((ChoreographyTask) choreography).getMessageFlowRef()) {
        sources.add(message.getSourceRef());
      }
    }

    Iterator<Participant> iterator = newParticipants.iterator();
    while (iterator.hasNext()) {
      Participant participant = iterator.next();

      ContainerShape bandShape = peService.createContainerShape(choreographyContainer, true);

      ParticipantBandKind bandKind = getNewParticipantBandKind(choreography, participant, first,
          !iterator.hasNext());

      boolean multiple = participant.getParticipantMultiplicity() != null
          && participant.getParticipantMultiplicity().getMaximum() > 1;

      int w = size.getWidth();
      int h = multiple ? 40 : 20;

      BPMNShape bpmnShape = DIUtils.createDIShape(bandShape, participant, 0, y + h, w, h, fp, diagram);
      bpmnShape.setChoreographyActivityShape(BusinessObjectUtil.getFirstElementOfType(choreographyContainer,
          BPMNShape.class));
      bpmnShape.setIsMarkerVisible(multiple);
      bpmnShape.setParticipantBandKind(bandKind);
      bpmnShape.setIsMessageVisible(sources.contains(participant));
      createParticipantBandContainerShape(bandKind, choreographyContainer, bandShape, bpmnShape, showNames);
      if (multiple) {
        drawMultiplicityMarkers(bandShape);
      }
      newContainers.add(bandShape);

      y += h;
      first = false;
    }

    Tuple<List<ContainerShape>, List<ContainerShape>> topAndBottom = getTopAndBottomBands(newContainers);
    resizePartipantBandContainerShapes(size.getWidth(), size.getHeight(), topAndBottom.getFirst(),
        topAndBottom.getSecond(), diagram);
  }
View Full Code Here

    envelopeGa.line.setForeground(gaService.manageColor(diagram, StyleUtil.CLASS_FOREGROUND));
    AnchorUtil.addFixedPointAnchors(envelope, envelopeGa.rect);

    Shape textShape = peService.createShape(envelope, false);
    Text text = gaService.createDefaultText(diagram, textShape);
    IDimension size = GraphitiUi.getUiLayoutService().calculateTextSize(name, text.getFont());
    gaService.setLocationAndSize(text, ENV_W + 3, 3, size.getWidth(), size.getHeight());
    text.setValue(name);

    gaService.setSize(invisibleRectangle, ENV_W + size.getWidth() + 3, ENV_H);

    AnchorLocation envelopeAnchorLoc = null;
    if (boundaryAnchor.locationType == AnchorLocation.TOP) {
      envelopeAnchorLoc = AnchorLocation.BOTTOM;
    } else {
View Full Code Here

  public static void drawMultiplicityMarkers(ContainerShape container) {
    Diagram diagram = peService.getDiagramForPictogramElement(container);
    Shape multiplicityShape = peService.createShape(container, false);
    Rectangle rect = gaService.createInvisibleRectangle(multiplicityShape);

    IDimension size = gaService.calculateSize(container.getGraphicsAlgorithm());
    int w = 10;
    int h = 10;
    int x = (size.getWidth() / 2) - (w / 2);
    int y = size.getHeight() - h - 1;
    gaService.setLocationAndSize(rect, x, y, w, h);

    int[][] coorinates = { new int[] { 0, 0, 0, h }, new int[] { 4, 0, 4, h }, new int[] { 8, 0, 8, h } };
    for (int[] xy : coorinates) {
      Polyline line = gaService.createPolyline(rect, xy);
View Full Code Here

    while (iterator.hasNext()) {
      Shape shape = iterator.next();
      if (shape.getGraphicsAlgorithm() instanceof Text) {
        Text text = (Text) shape.getGraphicsAlgorithm();
        text.setValue(label);
        IDimension size = GraphitiUi.getUiLayoutService().calculateTextSize(label, text.getFont());
        gaService.setSize(containerShape.getGraphicsAlgorithm(), ENV_W + size.getWidth() + 3, ENV_H);
        gaService.setSize(text, size.getWidth(), size.getHeight());
        break;
      }
    }
  }
View Full Code Here

    int containerHeight = containerGa.getHeight();
    Iterator<Shape> iterator = containerShape.getChildren().iterator();
    while (iterator.hasNext()) {
      Shape shape = iterator.next();
      GraphicsAlgorithm ga = shape.getGraphicsAlgorithm();
      IDimension size = gaService.calculateSize(ga);
      if (containerHeight != size.getHeight()) {
        if (ga instanceof Polyline) {
          Polyline line = (Polyline) ga;
          Point firstPoint = line.getPoints().get(0);
          Point newPoint = gaService.createPoint(firstPoint.getX(), containerHeight);
          line.getPoints().set(1, newPoint);
View Full Code Here

    ContainerShape container = (ContainerShape) context.getPictogramElement();

    Shape textShape = getShape(container, UpdateBaseElementNameFeature.TEXT_ELEMENT, Boolean.toString(true));
    Text textGa = (Text) textShape.getGraphicsAlgorithm();
    String text = textGa.getValue() == null ? "" : textGa.getValue();
    IDimension size = GraphitiUi.getUiLayoutService().calculateTextSize(text, textGa.getFont());

    GraphicsAlgorithm parentGa = container.getGraphicsAlgorithm();

    if (size.getWidth() > getMinimumWidth()) {
      gaService.setSize(parentGa, size.getWidth() + 3, parentGa.getHeight());
    } else {
      gaService.setSize(parentGa, getMinimumWidth(), parentGa.getHeight());
    }

    gaService.setSize(textGa, size.getWidth() + 3, textGa.getHeight());

    return true;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.graphiti.datatypes.IDimension

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.