Package org.eclipse.graphiti.services

Examples of org.eclipse.graphiti.services.IGaService


  public static Style getStyleForText(Diagram diagram) {
    Style parentStyle = getStyleForClass(diagram);
    Style s = findStyle(parentStyle, TEXT_ID);
   
    if(s == null) {
      IGaService gaService = Graphiti.getGaService();
      s = gaService.createStyle(diagram, TEXT_ID);
      s.setForeground(gaService.manageColor(diagram, CLASS_TEXT_FOREGROUND));
    }
   
    return s;
  }
View Full Code Here


    return null;
  }

  public static void applyBGStyle(GraphicsAlgorithm shape,
      AbstractFeature feature) {
    IGaService gaService = Graphiti.getGaService();
    shape.setStyle(StyleUtil.getStyleForClass(feature.getFeatureProvider().getDiagramTypeProvider().getDiagram()));
    shape.setFilled(true);
    AdaptedGradientColoredAreas gradient = PredefinedColoredAreas.getBlueWhiteAdaptions();
    gaService.setRenderingStyle(shape, gradient);
  }
View Full Code Here

    return container;
  }

  private static Dimension resize(ContainerShape container) {
    EObject elem = BusinessObjectUtil.getFirstElementOfType(container, BaseElement.class);
    IGaService service = Graphiti.getGaService();
    int height = 0;
    int width = container.getGraphicsAlgorithm().getWidth() - 15;

    EList<Shape> children = container.getChildren();
    ECollections.sort(children, new SiblingLaneComparator());
    for (Shape s : children) {
      Object bo = BusinessObjectUtil.getFirstElementOfType(s, BaseElement.class);
      if (bo != null && (bo instanceof Lane || bo instanceof Participant) && !bo.equals(elem)) {
        GraphicsAlgorithm ga = s.getGraphicsAlgorithm();
        service.setLocation(ga, 15, height);
        height += ga.getHeight() - 1;
        if (ga.getWidth() >= width) {
          width = ga.getWidth();
        } else {
          service.setSize(ga, width, ga.getHeight());
        }
      }
    }

    GraphicsAlgorithm ga = container.getGraphicsAlgorithm();

    if (height == 0) {
      return new Dimension(ga.getWidth(), ga.getHeight());
    } else {
      int newWidth = width + 15;
      int newHeight = height + 1;
      service.setSize(ga, newWidth, newHeight);

      for (Shape s : children) {
        GraphicsAlgorithm childGa = s.getGraphicsAlgorithm();
        if (childGa instanceof Text) {
          s.getGraphicsAlgorithm().setHeight(newHeight);
        } else if (childGa instanceof Polyline) {
          Polyline line = (Polyline) childGa;
          Point firstPoint = line.getPoints().get(0);
          Point newPoint = service.createPoint(firstPoint.getX(), newHeight);
          line.getPoints().set(1, newPoint);
        }
      }

      return new Dimension(newWidth, newHeight);
View Full Code Here

  }

  private static Dimension resizeRecursively(ContainerShape root) {
    BaseElement elem = BusinessObjectUtil.getFirstElementOfType(root, BaseElement.class);
    List<Dimension> dimensions = new ArrayList<Dimension>();
    IGaService service = Graphiti.getGaService();
    int foundContainers = 0;

    for (Shape s : root.getChildren()) {
      Object bo = BusinessObjectUtil.getFirstElementOfType(s, BaseElement.class);
      if (checkForResize(elem, s, bo)) {
        foundContainers += 1;
        Dimension d = resizeRecursively((ContainerShape) s);
        if (d != null) {
          dimensions.add(d);
        }
      }
    }

    if (dimensions.isEmpty()) {
      GraphicsAlgorithm ga = root.getGraphicsAlgorithm();
      for (Shape s : root.getChildren()) {
        GraphicsAlgorithm childGa = s.getGraphicsAlgorithm();
        if (childGa instanceof Text) {
          s.getGraphicsAlgorithm().setHeight(ga.getHeight());
        } else if (childGa instanceof Polyline) {
          Polyline line = (Polyline) childGa;
          Point firstPoint = line.getPoints().get(0);
          Point newPoint = service.createPoint(firstPoint.getX(), ga.getHeight());
          line.getPoints().set(1, newPoint);
        }
      }
      return new Dimension(ga.getWidth(), ga.getHeight());
    }
View Full Code Here

    return new Dimension(width, height);
  }

  private static void postResizeFixLenghts(ContainerShape root) {
    IGaService service = Graphiti.getGaService();
    BaseElement elem = BusinessObjectUtil.getFirstElementOfType(root, BaseElement.class);
    int width = root.getGraphicsAlgorithm().getWidth() - 15;

    for (Shape s : root.getChildren()) {
      Object o = BusinessObjectUtil.getFirstElementOfType(s, BaseElement.class);
      if (checkForResize(elem, s, o)) {
        GraphicsAlgorithm ga = s.getGraphicsAlgorithm();
        service.setSize(ga, width, ga.getHeight());
        postResizeFixLenghts((ContainerShape) s);
      }
    }
  }
View Full Code Here

  public IAddFeature getAddFeature(IFeatureProvider fp) {
    return new AddTaskFeature(fp) {

      @Override
      protected void decorateActivityRectangle(RoundedRectangle rect) {
        IGaService service = Graphiti.getGaService();
        Image img = service.createImage(rect, ImageProvider.IMG_16_SEND_TASK);
        service.setLocationAndSize(img, 2, 2, GraphicsUtil.TASK_IMAGE_SIZE, GraphicsUtil.TASK_IMAGE_SIZE);
      }
    };
  }
View Full Code Here

    public AnchorLocation locationType;
    public ILocation location;
  }

  public static FixPointAnchor createAnchor(Shape s, AnchorLocation loc, int x, int y) {
    IGaService gaService = Graphiti.getGaService();
    IPeService peService = Graphiti.getPeService();

    FixPointAnchor anchor = peService.createFixPointAnchor(s);
    peService.setPropertyValue(anchor, BOUNDARY_FIXPOINT_ANCHOR, loc.getKey());
    anchor.setLocation(gaService.createPoint(x, y));
    gaService.createInvisibleRectangle(anchor);

    return anchor;
  }
View Full Code Here

  @Override
  public IAddFeature getAddFeature(IFeatureProvider fp) {
    return new AddTaskFeature(fp) {
      @Override
      protected void decorateActivityRectangle(RoundedRectangle rect) {
        IGaService service = Graphiti.getGaService();
        Image img = service.createImage(rect, ImageProvider.IMG_16_MANUAL_TASK);
        service.setLocationAndSize(img, 2, 2, GraphicsUtil.TASK_IMAGE_SIZE, GraphicsUtil.TASK_IMAGE_SIZE);
      }
    };
  }
View Full Code Here

  }

  @Override
  public PictogramElement add(IAddContext context) {
    IPeService peService = Graphiti.getPeService();
    IGaService gaService = Graphiti.getGaService();

    BaseElement element = (BaseElement) context.getNewObject();
    IAddConnectionContext addConContext = (IAddConnectionContext) context;

    Connection connection = peService.createFreeFormConnection(getDiagram());

    Object importProp = context.getProperty(DIImport.IMPORT_PROPERTY);
    if (importProp != null && (Boolean) importProp) {
      connection.setStart(addConContext.getSourceAnchor());
      connection.setEnd(addConContext.getTargetAnchor());
    } else {
      ContainerShape sourceContainer = (ContainerShape) addConContext.getSourceAnchor().eContainer();
      ContainerShape targetContainer = (ContainerShape) addConContext.getTargetAnchor().eContainer();
      Tuple<FixPointAnchor, FixPointAnchor> anchors = AnchorUtil.getSourceAndTargetBoundaryAnchors(
          sourceContainer, targetContainer, connection);

      connection.setStart(anchors.getFirst());
      connection.setEnd(anchors.getSecond());
    }
   
    if (ModelUtil.hasName(element)) {
      ConnectionDecorator labelDecorator = Graphiti.getPeService().createConnectionDecorator(connection, true, 0.5, true);
      Text text = gaService.createText(labelDecorator, ModelUtil.getName(element));
      peService.setPropertyValue(labelDecorator, UpdateBaseElementNameFeature.TEXT_ELEMENT, Boolean.toString(true));
      text.setStyle(StyleUtil.getStyleForText(getDiagram()));
    }
   
    Polyline connectionLine = gaService.createPolyline(connection);
    connectionLine.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));

    decorateConnectionLine(connectionLine);

    createDIEdge(connection, element);
View Full Code Here

        int l = 8;
       
        ConnectionDecorator decorator = Graphiti.getPeService().createConnectionDecorator(connection, false,
            1.0, true);

        IGaService gaService = Graphiti.getGaService();
        Polyline arrow = gaService.createPolygon(decorator, new int[] { -l, w, 0, 0, -l, -w, -l, w });

        arrow.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
        arrow.setLineWidth(2);
      }
View Full Code Here

TOP

Related Classes of org.eclipse.graphiti.services.IGaService

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.