• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java GraphicsAlgorithm类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm的典型用法代码示例。如果您正苦于以下问题:Java GraphicsAlgorithm类的具体用法?Java GraphicsAlgorithm怎么用?Java GraphicsAlgorithm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

GraphicsAlgorithm类属于org.eclipse.graphiti.mm.algorithms包,在下文中一共展示了GraphicsAlgorithm类的39个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: findPcFromIdentifier

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
/**
 * Search for a PictogramElement with given id as identifier. This method
 * check the given pe and its corresponding GraphicsAlgorithm. If the given
 * pe is a ContainerShape, children shapes are also checked.
 * 
 * @param pe
 *            A PictogramElement
 * @param id
 *            Identifier to found
 * @return A PropertyContainer or null if it can't be found
 */
public static PropertyContainer findPcFromIdentifier(final PictogramElement pe, final String id) {

	if (isExpectedPc(pe, id)) {
		return pe;
	}

	final GraphicsAlgorithm ga = pe.getGraphicsAlgorithm();
	if (ga != null) {
		final PropertyContainer pc = findPcFromIdentifier(ga, id);
		if (pc != null) {
			return pc;
		}
	}

	if (pe instanceof ContainerShape) {
		for (final Shape child : ((ContainerShape) pe).getChildren()) {
			final PropertyContainer foundPropertyContainer = findPcFromIdentifier(child, id);
			if (foundPropertyContainer != null) {
				return foundPropertyContainer;
			}
		}
	}

	return null;
}
 

开发者ID:turnus,
项目名称:turnus,
代码行数:37,
代码来源:PropertiesUtils.java

示例2: getToolTip

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public Object getToolTip(GraphicsAlgorithm ga) {
  PictogramElement pe = ga.getPictogramElement();
  Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
  if (bo instanceof Vertex) {
    // For a vertex, we want to show the name of the containing relation
    bo = ((Vertex) bo).getContainer();
  }
  if (bo instanceof NamedObj) {
    String name = ((NamedObj) bo).getName();
    if (name != null && !(name.length() == 0)) {
      return name;
    }
  }
  return super.getToolTip(ga);
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:17,
代码来源:TriqToolBehaviorProvider.java

示例3: updateNeeded

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public IReason updateNeeded(IUpdateContext context) {
  PictogramElement pictogramElement = context.getPictogramElement();
  Object bo = getBusinessObjectForPictogramElement(pictogramElement);
  Port p = null;
  if (bo instanceof Port && pictogramElement instanceof Anchor) {
    p = (Port) bo;
    Anchor anchor = (Anchor) pictogramElement;
    PortCategory anchorCategory = PortCategory.retrieveFrom(anchor);
    PortCategory portCategory = PortCategory.retrieveFrom(p);
    boolean portDirectionChange = portCategory != anchorCategory;
    
    // a bit more complex : check port colour and compare it to multiport property
    GraphicsAlgorithm portGA = anchor.getGraphicsAlgorithm();
    IColorConstant expectedPortBackgroundColor = p.isMultiPort() ? PORT_BACKGROUND_MULTIPORT : PORT_BACKGROUND_SINGLEPORT;
    boolean portMultiPortChange = !portGA.getBackground().equals(manageColor(expectedPortBackgroundColor));

    if (portDirectionChange || portMultiPortChange) {
      context.putProperty(PORT_CHANGED, p.getName());
      context.putProperty(PORT_CHANGED_IO, Boolean.toString(portDirectionChange));
      context.putProperty(PORT_CHANGED_MULTI, Boolean.toString(portMultiPortChange));
      return Reason.createTrueReason("Port change");
    }
  }
  return Reason.createFalseReason();
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:27,
代码来源:PortUpdateFeature.java

示例4: update

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean update(IUpdateContext context) {
  boolean result = false;
  PictogramElement pictogramElement = context.getPictogramElement();
  Object bo = getBusinessObjectForPictogramElement(pictogramElement);
  if (bo instanceof Port && pictogramElement instanceof Anchor) {
    Port p = (Port) bo;
    Anchor anchor = (Anchor) pictogramElement;
    GraphicsAlgorithm portGA = anchor.getGraphicsAlgorithm();
    boolean portInputOutputChange = Boolean.valueOf((String)context.getProperty(PORT_CHANGED_IO));
    if (portInputOutputChange) {
      // TODO reposition port on the correct side of the actor
      // this also impacts positioning of the other ports, so we'd better do this as an ActorUpdate...
      PictogramElement actorPE = anchor.getParent();
      getFeatureProvider().updateIfPossibleAndNeeded(new UpdateContext(actorPE));
    }
    boolean portMultiPortChange = Boolean.valueOf((String)context.getProperty(PORT_CHANGED_MULTI));
    if (portMultiPortChange) {
      IColorConstant portColour = p.isMultiPort() ? PORT_BACKGROUND_MULTIPORT : PORT_BACKGROUND_SINGLEPORT;
      portGA.setBackground(manageColor(portColour));
    }
  }
  return result;
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:25,
代码来源:PortUpdateFeature.java

示例5: layout

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean layout(ILayoutContext context) {
  boolean anythingChanged = false;
  ContainerShape containerShape = (ContainerShape) context.getPictogramElement();
  // the invisible rectangle contains the visible rectangle as its (first and only) child
  GraphicsAlgorithm invisibleRectangle = containerShape.getGraphicsAlgorithm();
  GraphicsAlgorithm rectangle = invisibleRectangle.getGraphicsAlgorithmChildren().get(0);

  // height of visible rectangle
  int rectangleHeight = invisibleRectangle.getHeight();
  if (rectangle.getHeight() != rectangleHeight) {
    rectangle.setHeight(rectangleHeight);
    anythingChanged = true;
  }

  // width of visible rectangle
  int rectangleWidth = invisibleRectangle.getWidth();
  if (rectangle.getWidth() != rectangleWidth) {
    rectangle.setWidth(rectangleWidth);
    anythingChanged = true;
  }

  return anythingChanged;
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:25,
代码来源:AttributeLayoutFeature.java

示例6: getGraphicsAlgorithmOfShape

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
/**
 *
 * @param shape
 * @param gaClass
 * @return the graphicsAlgorithm of the given class, contained in the shape or in child shapes
 */
@SuppressWarnings("unchecked")
public static <T extends GraphicsAlgorithm> T getGraphicsAlgorithmOfShape(Shape shape, Class<T> gaClass) {
  T ga = null;
  if (gaClass.isInstance(shape.getGraphicsAlgorithm())) {
    ga = (T) shape.getGraphicsAlgorithm();
  } else if (shape instanceof ContainerShape) {
    for (Shape childShape : ((ContainerShape) shape).getChildren()) {
      if (gaClass.isInstance(childShape.getGraphicsAlgorithm())) {
        ga = (T) childShape.getGraphicsAlgorithm();
        break;
      }
    }
  }
  return ga;
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:22,
代码来源:EditorUtils.java

示例7: update

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean update(final IUpdateContext context) {
  PictogramElement _pictogramElement = context.getPictogramElement();
  final ContainerShape containerShape = ((ContainerShape) _pictogramElement);
  String businessName = null;
  final Object bo = this.getBusinessObjectForPictogramElement(containerShape);
  if ((bo instanceof State)) {
    String _name = ((State)bo).getName();
    businessName = _name;
  }
  EList<Shape> _children = containerShape.getChildren();
  final Function1<Shape, GraphicsAlgorithm> _function = new Function1<Shape, GraphicsAlgorithm>() {
    @Override
    public GraphicsAlgorithm apply(final Shape it) {
      return it.getGraphicsAlgorithm();
    }
  };
  List<GraphicsAlgorithm> _map = ListExtensions.<Shape, GraphicsAlgorithm>map(_children, _function);
  Iterable<Text> _filter = Iterables.<Text>filter(_map, Text.class);
  Text _head = IterableExtensions.<Text>head(_filter);
  if (_head!=null) {
    _head.setValue(businessName);
  }
  return false;
}
 

开发者ID:spoenemann,
项目名称:xtext-gef,
代码行数:26,
代码来源:UpdateStateFeature.java

示例8: createEditPart

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public EditPart createEditPart(EditPart context, Object model) {
	EditPart ret = null;
	if (model instanceof PictogramElement) {
		ret = new PictogramElementTreeEditPart((PictogramElement) model);
	} else if (model instanceof GraphicsAlgorithm) {
		ret = new GraphicsAlgorithmTreeEditPart((GraphicsAlgorithm) model);
	} else if (model instanceof ConnectionDecorator) {
		ret = new ConnectionDecoratorTreeEditPart((ConnectionDecorator) model);
	} else if (model instanceof Point) {
		ret = new PointTreeEditPart((Point) model);
	} else if (model instanceof Color) {
		ret = new ColorTreeEditPart((Color) model);
	} else if (model instanceof Style) {
		ret = new StyleTreeEditPart((Style) model);
	}
	return ret;
}
 

开发者ID:logicalhacking,
项目名称:SecureBPMN,
代码行数:19,
代码来源:PictogramsTreeEditPartFactory.java

示例9: createInvisibleEllipse

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
public static Ellipse createInvisibleEllipse(GraphicsAlgorithmContainer gaContainer, IGaService gaService) {
  Ellipse ret = AlgorithmsFactory.eINSTANCE.createEllipse();
  ret.setX(0);
  ret.setY(0);
  ret.setWidth(0);
  ret.setHeight(0);
  ret.setFilled(false);
  ret.setLineVisible(false);
  if (gaContainer instanceof PictogramElement) {
    PictogramElement pe = (PictogramElement) gaContainer;
    pe.setGraphicsAlgorithm(ret);
  } else if (gaContainer instanceof GraphicsAlgorithm) {
    GraphicsAlgorithm parentGa = (GraphicsAlgorithm) gaContainer;
    parentGa.getGraphicsAlgorithmChildren().add(ret);
  }
  return ret;
}
 

开发者ID:logicalhacking,
项目名称:SecureBPMN,
代码行数:18,
代码来源:ActivitiUiUtil.java

示例10: canDirectEdit

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean canDirectEdit(IDirectEditingContext context) {
	PictogramElement pe = context.getPictogramElement();
	Object bo = getBusinessObjectForPictogramElement(pe);
	GraphicsAlgorithm ga = context.getGraphicsAlgorithm();
	// support direct editing, if it is a EClass, and the user clicked
	// directly on the text and not somewhere else in the rectangle
	if (bo instanceof PlatformService && ga instanceof Text) {
		// EClass eClass = (EClass) bo;
		// additionally the flag isFrozen must be false
		// return !eClass.isFrozen();
		return true;
	}
	// direct editing not supported in all other cases
	return false;
}
 

开发者ID:CloudScale-Project,
项目名称:Environment,
代码行数:17,
代码来源:DirectEditingFeature.java

示例11: layout

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
public boolean layout(ILayoutContext context) {
	ContainerShape containerShape = (ContainerShape) context.getPictogramElement();
	GraphicsAlgorithm containerGa = containerShape.getGraphicsAlgorithm();
	
	// Min size
	int width = Math.max( MIN_WIDTH, containerGa.getWidth());
	int height = Math.max( MIN_HEIGHT, containerGa.getHeight());
	Graphiti.getGaLayoutService().setSize(containerShape.getGraphicsAlgorithm(), width, height);
	
	// Center child : TODO: generalize
	GraphicsAlgorithm outerGraphicsAlgorithm = containerShape.getGraphicsAlgorithm();
	if (outerGraphicsAlgorithm instanceof RoundedRectangle) {
		RoundedRectangle roundedRectangle = (RoundedRectangle) outerGraphicsAlgorithm;
		EList<Shape> children = containerShape.getChildren();
		if (children.size() > 0) {
			Shape shape = children.get(0);
			GraphicsAlgorithm graphicsAlgorithm = shape.getGraphicsAlgorithm();
			if (graphicsAlgorithm instanceof Text) {
				Graphiti.getGaLayoutService().setLocationAndSize(graphicsAlgorithm, 0, 0, roundedRectangle.getWidth(), roundedRectangle.getHeight());
				return true;
			}
		}
	}
	return false;
}
 

开发者ID:CloudScale-Project,
项目名称:Environment,
代码行数:26,
代码来源:LayoutBasicFeature.java

示例12: getUpdateFeature

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
/**
 * Returns the UpdateFeature for FunctionBlocks.
 * 
 * @param context
 *            the context for which to return a feature
 * @return the UpdateFeature for FunctionBlocks
 */
@Override
public final IUpdateFeature getUpdateFeature(final IUpdateContext context) {
	PictogramElement pe = context.getPictogramElement();
	Object bo = getBusinessObjectForPictogramElement(pe);
	if (bo instanceof OptionModel) {
		return new UpdateOptionFeature(this);
	} else if (bo instanceof FunctionBlockModel) {
		GraphicsAlgorithm ga = pe.getGraphicsAlgorithm();
		if (TypePropertyUtil.isPositionText(ga)) {
			return new UpdatePositionFeature(this);
		} else if (TypePropertyUtil.isBlockNameText(ga)) {
			return new UpdateBlockNameFeature(this);
		} else if (TypePropertyUtil.isBlockShape(ga)) {
			return new UpdateBlockFeature(this);
		}
	}
	return super.getUpdateFeature(context);
}
 

开发者ID:DesignAndDeploy,
项目名称:dnd,
代码行数:26,
代码来源:FeatureProvider.java

示例13: getDirectEditingFeature

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
/**
 * Returns a DirectEditFeature for Options and positions.
 * 
 * @param context
 *            the context for which to return a feature
 * @return a matching DirectEditFeature
 */
@Override
public final IDirectEditingFeature getDirectEditingFeature(final IDirectEditingContext context) {
	LOGGER.entry(context);
	PictogramElement pe = context.getPictogramElement();
	Object bo = getBusinessObjectForPictogramElement(pe);
	IDirectEditingFeature feature = null;
	if (bo instanceof OptionModel) {
		feature = new EditOptionFeature(this);
	} else if (bo instanceof FunctionBlockModel) {
		GraphicsAlgorithm ga = pe.getGraphicsAlgorithm();
		if (TypePropertyUtil.isBlockNameText(ga)) {
			feature = new EditBlockNameFeature(this);
		} else if (TypePropertyUtil.isPositionText(ga)) {
			feature = new EditPositionFeature(this);
		}
	}
	if (feature == null) {
		feature = super.getDirectEditingFeature(context);
	}
	LOGGER.exit(feature);
	return feature;
}
 

开发者ID:DesignAndDeploy,
项目名称:dnd,
代码行数:30,
代码来源:FeatureProvider.java

示例14: canDirectEdit

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean canDirectEdit(final IDirectEditingContext context) {
	LOGGER.entry(context);
	PictogramElement pe = context.getPictogramElement();
	Object bo = getBusinessObjectForPictogramElement(pe);
	if (!(bo instanceof FunctionBlockModel)) {
		LOGGER.exit(false);
		return false;
	}
	GraphicsAlgorithm ga = pe.getGraphicsAlgorithm();
	if (!TypePropertyUtil.isBlockNameText(ga)) {
		LOGGER.exit(false);
		return false;
	}
	LOGGER.exit(true);
	return true;
}
 

开发者ID:DesignAndDeploy,
项目名称:dnd,
代码行数:18,
代码来源:EditBlockNameFeature.java

示例15: canDirectEdit

点赞 3

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean canDirectEdit(final IDirectEditingContext context) {
	LOGGER.entry(context);
	PictogramElement pe = context.getPictogramElement();
	Object bo = getBusinessObjectForPictogramElement(pe);
	if (!(bo instanceof FunctionBlockModel)) {
		LOGGER.exit(false);
		return false;
	}
	GraphicsAlgorithm ga = pe.getGraphicsAlgorithm();
	if (!TypePropertyUtil.isPositionText(ga)) {
		LOGGER.exit(false);
		return false;
	}
	LOGGER.exit(true);
	return true;
}
 

开发者ID:DesignAndDeploy,
项目名称:dnd,
代码行数:18,
代码来源:EditPositionFeature.java

示例16: getClickArea

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public GraphicsAlgorithm[] getClickArea(PictogramElement pe) {
  IFeatureProvider featureProvider = getFeatureProvider();
  Object bo = featureProvider.getBusinessObjectForPictogramElement(pe);
  if (bo instanceof Entity) {
    GraphicsAlgorithm invisible = pe.getGraphicsAlgorithm();
    if(invisible.getGraphicsAlgorithmChildren().size()>0) {
      return new GraphicsAlgorithm[] {invisible.getGraphicsAlgorithmChildren().get(0)};
    } else {
      return new GraphicsAlgorithm[] {invisible};
    }
  }
  return super.getClickArea(pe);
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:15,
代码来源:TriqToolBehaviorProvider.java

示例17: getSelectionBorder

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public GraphicsAlgorithm getSelectionBorder(PictogramElement pe) {
  if (pe instanceof ContainerShape) {
    GraphicsAlgorithm invisible = pe.getGraphicsAlgorithm();
    if (!invisible.getLineVisible()) {
      EList<GraphicsAlgorithm> graphicsAlgorithmChildren = invisible.getGraphicsAlgorithmChildren();
      if (!graphicsAlgorithmChildren.isEmpty()) {
        return graphicsAlgorithmChildren.get(0);
      }
    }
  }
  return super.getSelectionBorder(pe);
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:14,
代码来源:TriqToolBehaviorProvider.java

示例18: add

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
  Entity addedActor = (Entity) context.getNewObject();
  ContainerShape targetContainer = context.getTargetContainer();

  int xLocation = context.getX();
  int yLocation = context.getY();

  IPeCreateService peCreateService = Graphiti.getPeCreateService();
  IGaService gaService = Graphiti.getGaService();
  ContainerShape containerShape = peCreateService.createContainerShape(targetContainer, true);
  link(context, containerShape, addedActor, BoCategory.CompositeActor);

  GraphicsAlgorithm invisibleRectangle = null;
  invisibleRectangle = gaService.createInvisibleRectangle(containerShape);

  GraphicsAlgorithm actorShapeGA = null;

  String iconResource = (String) context.getProperty("icon");
  String iconType = (String) context.getProperty("iconType");

  switch (iconType) {
  case TriqFeatureProvider.ICONTYPE_SVG:
  case TriqFeatureProvider.ICONTYPE_PTOLEMY:
    actorShapeGA = buildExternallyDefinedShape(context, gaService, invisibleRectangle, containerShape, iconType, iconResource);
    break;
  default:
    actorShapeGA = buildDefaultShape(context, gaService, invisibleRectangle, containerShape, addedActor, iconResource);
  }

  int width = actorShapeGA.getWidth();
  int height = actorShapeGA.getHeight();
  gaService.setLocationAndSize(invisibleRectangle, xLocation, yLocation, width + 15, height);

  layoutPictogramElement(containerShape);

  return containerShape;
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:39,
代码来源:CompositeActorAddFeature.java

示例19: canDirectEdit

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean canDirectEdit(IDirectEditingContext context) {
  GraphicsAlgorithm ga = context.getGraphicsAlgorithm();
  BoCategory boCategory = BoCategory.retrieveFrom(context.getPictogramElement());
  // The name of an actor (or other model element) is the only
  // Text element that is linked to it as its business object
  return ((BoCategory.CompositeActor.equals(boCategory) || BoCategory.Actor.equals(boCategory) || BoCategory.Director.equals(boCategory) || (BoCategory.Port.equals(boCategory))) && (ga instanceof Text));
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:9,
代码来源:ModelElementNameDirectEditFeature.java

示例20: getTopLeftLocation

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
public static double[] getTopLeftLocation(Object[] selectedObjects) {
  boolean foundOneValidThing = false;
  double minX = Double.MAX_VALUE;
  double minY = Double.MAX_VALUE;

  if (selectedObjects != null && selectedObjects.length > 0) {
    for (Object object : selectedObjects) {
      double[] xy = null;
      if (object instanceof GraphicsAlgorithm) {
        xy = getLocation((GraphicsAlgorithm) object);
      } else if (object instanceof PictogramElement) {
        xy = getLocation((PictogramElement) object);
      } else if (object instanceof NamedObj) {
        xy = getLocation((NamedObj) object);
      } else if (object instanceof ptolemy.kernel.util.NamedObj) {
        xy = getLocation((ptolemy.kernel.util.NamedObj) object);
      }
      if (xy != null) {
        foundOneValidThing = true;
        minX = Math.min(xy[0], minX);
        minY = Math.min(xy[1], minY);
      }
    }
  }

  if (foundOneValidThing) {
    return new double[] { minX, minY };
  } else {
    return new double[] { 0, 0 };
  }
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:32,
代码来源:EditorUtils.java

示例21: updateNeeded

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public IReason updateNeeded(final IUpdateContext context) {
  PictogramElement _pictogramElement = context.getPictogramElement();
  final ContainerShape containerShape = ((ContainerShape) _pictogramElement);
  EList<Shape> _children = containerShape.getChildren();
  final Function1<Shape, GraphicsAlgorithm> _function = new Function1<Shape, GraphicsAlgorithm>() {
    @Override
    public GraphicsAlgorithm apply(final Shape it) {
      return it.getGraphicsAlgorithm();
    }
  };
  List<GraphicsAlgorithm> _map = ListExtensions.<Shape, GraphicsAlgorithm>map(_children, _function);
  Iterable<Text> _filter = Iterables.<Text>filter(_map, Text.class);
  Text _head = IterableExtensions.<Text>head(_filter);
  String _value = null;
  if (_head!=null) {
    _value=_head.getValue();
  }
  String pictogramName = _value;
  String businessName = null;
  final Object bo = this.getBusinessObjectForPictogramElement(containerShape);
  if ((bo instanceof State)) {
    String _name = ((State)bo).getName();
    businessName = _name;
  }
  boolean _notEquals = (!Objects.equal(pictogramName, businessName));
  if (_notEquals) {
    return Reason.createTrueReason("Name is out of date");
  } else {
    return Reason.createFalseReason();
  }
}
 

开发者ID:spoenemann,
项目名称:xtext-gef,
代码行数:33,
代码来源:UpdateStateFeature.java

示例22: getModelChildren

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
/**
 * Returns the children of this EditPart.
 * 
 * @see org.eclipse.gef.editparts.AbstractEditPart#getModelChildren()
 */
@Override
protected List<Object> getModelChildren() {
	List<Object> retList = new ArrayList<Object>();
	GraphicsAlgorithm graphicsAlgorithm = getGraphicsAlgorithm();
	if (graphicsAlgorithm != null && graphicsAlgorithm.eResource() != null) {
		final List<GraphicsAlgorithm> graphicsAlgorithmChildren = graphicsAlgorithm.getGraphicsAlgorithmChildren();
		addAllElementsIfNotNull(retList, graphicsAlgorithmChildren);
		if (graphicsAlgorithm instanceof Polyline) {
			Polyline pl = (Polyline) graphicsAlgorithm;
			addAllElementsIfNotNull(retList, pl.getPoints());
		}
	}
	return retList;
}
 

开发者ID:logicalhacking,
项目名称:SecureBPMN,
代码行数:20,
代码来源:GraphicsAlgorithmTreeEditPart.java

示例23: getModelChildren

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
/**
 * Returns the children of this EditPart.
 * 
 * @see org.eclipse.gef.editparts.AbstractEditPart#getModelChildren()
 */
@Override
protected List<Object> getModelChildren() {
	List<Object> retList = new ArrayList<Object>();
	if (getConnectionDecorator() != null) {
		ConnectionDecorator connectionDecorator = getConnectionDecorator();
		GraphicsAlgorithm ga = connectionDecorator.getGraphicsAlgorithm();
		if (ga != null) {
			retList.add(ga);
		}
	}

	return retList;
}
 

开发者ID:logicalhacking,
项目名称:SecureBPMN,
代码行数:19,
代码来源:ConnectionDecoratorTreeEditPart.java

示例24: getText

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public String getText(Object element) {
	String ret = "";
	if (element instanceof IContainerNode) {
		IContainerNode icn = (IContainerNode) element;
		ret = icn.getText();
	}
	if (element instanceof IFile) {
		IFile file = (IFile) element;
		return file.getName();
	}
	if (element instanceof Diagram) {
		Diagram diagram = (Diagram) element;
		if (diagram != null) {
			ret = createTextForDiagram(diagram);
		}
	}
	if (element instanceof BaseElement) {
		String name = ((BaseElement) element).getId();
		if (name == null) {
			name = "name not available";
		}
		return name;
	}
	if (element instanceof EObject && ret.length() <= 0) {
		EObject eObject = (EObject) element;
		ret = ret + eObject.getClass().getSimpleName();
		if (ret.endsWith(IMPL)) {
			ret = ret.substring(0, ret.length() - (IMPL.length()));
		}
	}
	if (element instanceof GraphicsAlgorithm && ret.length() > 0) {
		ret = ret + "   -   ";
		ret = ret + super.getText(element);
	}
	return ret;
}
 

开发者ID:logicalhacking,
项目名称:SecureBPMN,
代码行数:38,
代码来源:BpmnLabelProvider.java

示例25: setTransparencyAndLineWidth

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
private void setTransparencyAndLineWidth(ContainerShape parent, Diagram diagram) {
	List<Shape> shapes = parent.getChildren();
	for (Shape shape : shapes) {
     if(shape instanceof ContainerShape) {
     	GraphicsAlgorithm graphics = ((ContainerShape) shape).getGraphicsAlgorithm();
     	graphics.setLineWidth(1);
     	graphics.setTransparency(0.0);
     	List<GraphicsAlgorithm> graphicsChildren = graphics.getGraphicsAlgorithmChildren();
     	for (GraphicsAlgorithm graphicsAlgorithm : graphicsChildren) {
         if(graphicsAlgorithm.getLineWidth() == null ||  graphicsAlgorithm.getLineWidth() <= 1) {
         	graphicsAlgorithm.setLineWidth(1);
         }
         graphicsAlgorithm.setTransparency(0.0);
       }
     	setTransparencyAndLineWidth((ContainerShape) shape, diagram);
     
     } else if(shape.getGraphicsAlgorithm() != null && shape.getGraphicsAlgorithm() instanceof Text) {
     	if(parent.getLink().getBusinessObjects() != null && parent.getLink().getBusinessObjects().size() > 0) {
     		EObject object = parent.getLink().getBusinessObjects().get(0);
     		if(object instanceof Task) {
     			Text text = (Text) shape.getGraphicsAlgorithm();
         	MultiText multiText = Graphiti.getGaService().createDefaultMultiText(diagram, shape, text.getValue());
         	multiText.setStyle(text.getStyle());
         	multiText.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
         	multiText.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
         	multiText.setFont(text.getFont());
         	multiText.setX(text.getX());
         	multiText.setY(text.getY());
         	multiText.setHeight(30);
         	multiText.setWidth(text.getWidth());
         	shape.setGraphicsAlgorithm(multiText);
     		}
     	}
     }
   }
}
 

开发者ID:logicalhacking,
项目名称:SecureBPMN,
代码行数:37,
代码来源:ActivitiDiagramEditor.java

示例26: canDirectEdit

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean canDirectEdit(IDirectEditingContext context) {
	PictogramElement pe = context.getPictogramElement();
	Object bo = getBusinessObjectForPictogramElement(pe);
	GraphicsAlgorithm ga = context.getGraphicsAlgorithm();
	if (bo instanceof FlowElement && ga instanceof MultiText) {
		isMultiLine = true;
		return true;
	} else if (bo instanceof FlowElement && ga instanceof Text) {
		isMultiLine = false;
		return true;
	}
	// direct editing not supported in all other cases
	return false;
}
 

开发者ID:logicalhacking,
项目名称:SecureBPMN,
代码行数:16,
代码来源:DirectEditFlowElementFeature.java

示例27: resizeShape

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public void resizeShape(IResizeShapeContext context) {
  super.resizeShape(context);
  context.getShape().getGraphicsAlgorithm().setHeight(context.getHeight());
  context.getShape().getGraphicsAlgorithm().setWidth(context.getWidth());
  for (GraphicsAlgorithm graphicsAlgorithm : context.getShape().getGraphicsAlgorithm().getGraphicsAlgorithmChildren()) {
    graphicsAlgorithm.setHeight(context.getHeight());
    graphicsAlgorithm.setWidth(context.getWidth());
  }
}
 

开发者ID:logicalhacking,
项目名称:SecureBPMN,
代码行数:11,
代码来源:SubProcessResizeFeature.java

示例28: getToolTip

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public Object getToolTip(GraphicsAlgorithm ga) {
	PictogramElement pe = ga.getPictogramElement();
	Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
	if (bo instanceof Entity) {
		String name = ((Entity) bo).getName();
		if (name != null && !(name.length() == 0)) {
			return name;
		}
	}
	return super.getToolTip(ga);
}
 

开发者ID:CloudScale-Project,
项目名称:Environment,
代码行数:13,
代码来源:ToolBehaviorProvider.java

示例29: layout

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean layout(ILayoutContext context) {
	ContainerShape containerShape = (ContainerShape) context.getPictogramElement();

	//position name
	GraphicsAlgorithm containerGa = containerShape.getGraphicsAlgorithm();
	Graphiti.getGaLayoutService().setLocationAndSize(getName(containerShape).getGraphicsAlgorithm(),
			5, 5, containerGa.getWidth()-5, 20, true);
	return true;
}
 

开发者ID:CloudScale-Project,
项目名称:Environment,
代码行数:11,
代码来源:NodePattern.java

示例30: canUpdate

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean canUpdate(final IUpdateContext context) {
	LOGGER.entry(context);
	PictogramElement pe = context.getPictogramElement();
	GraphicsAlgorithm ga = pe.getGraphicsAlgorithm();
	Object bo = getBusinessObjectForPictogramElement(pe);
	LOGGER.debug("ga: {}, bo: {}", ga, bo);
	if (TypePropertyUtil.isBlockNameText(ga) && bo instanceof FunctionBlockModel) {
		LOGGER.exit(true);
		return true;
	}
	LOGGER.exit(false);
	return false;
}
 

开发者ID:DesignAndDeploy,
项目名称:dnd,
代码行数:15,
代码来源:UpdateBlockNameFeature.java

示例31: getToolTip

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public String getToolTip(final GraphicsAlgorithm ga) {
	PictogramElement pe = ga.getPictogramElement();
	Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
	String name = null;
	if (bo instanceof FunctionBlockModel) {
		if (ga instanceof Text) {
			if (TypePropertyUtil.isBlockNameText(ga)) {
				name = ((FunctionBlockModel) bo).getBlockName();
			} else if (TypePropertyUtil.isPositionText(ga)) {
				name = ((FunctionBlockModel) bo).getPosition();
			} else {
				name = ((Text) ga).getValue();
			}
		} else {
			name = ((FunctionBlockModel) bo).getTypeName();
		}
	} else if (bo instanceof OutputModel) {
		OutputModel output = (OutputModel) bo;
		name =
				output.getName() + Messages.Graphiti_SPACE + Messages.Graphiti_BRACE_LEFT
						+ getClassName(output.getType()) + Messages.Graphiti_BRACE_RIGHT; //$NON-NLS-1$ //$NON-NLS-2$
	} else if (bo instanceof InputModel) {
		InputModel input = (InputModel) bo;
		name =
				input.getName() + Messages.Graphiti_SPACE + Messages.Graphiti_BRACE_LEFT
						+ getClassName(input.getType()) + Messages.Graphiti_BRACE_RIGHT; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	} else if (ga instanceof Text) {
		name = ((Text) ga).getValue();
	}
	if (name != null && !name.isEmpty()) {
		return name;
	}
	final Object superTip = super.getToolTip(ga);
	return superTip instanceof String ? (String) superTip : Messages.Graphiti_EMPTYSTRING; //$NON-NLS-1$
}
 

开发者ID:DesignAndDeploy,
项目名称:dnd,
代码行数:37,
代码来源:ToolBehaviorProvider.java

示例32: canUpdate

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean canUpdate(final IUpdateContext context) {
	LOGGER.entry(context);
	PictogramElement pe = context.getPictogramElement();
	GraphicsAlgorithm ga = pe.getGraphicsAlgorithm();
	Object bo = getBusinessObjectForPictogramElement(pe);
	if (TypePropertyUtil.isPositionText(ga) && bo instanceof FunctionBlockModel) {
		LOGGER.exit(true);
		return true;
	}
	LOGGER.exit(false);
	return false;
}
 

开发者ID:DesignAndDeploy,
项目名称:dnd,
代码行数:14,
代码来源:UpdatePositionFeature.java

示例33: getName

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
private Text getName(final ContainerShape containerShape) {
	LOGGER.entry(containerShape);
	for (Shape shape : containerShape.getChildren()) {
		GraphicsAlgorithm ga = shape.getGraphicsAlgorithm();
		if (ga instanceof Text
				&& getBusinessObjectForPictogramElement(shape) == getBusinessObjectForPictogramElement(containerShape)) {
			LOGGER.exit(ga);
			return (Text) ga;
		}
	}
	LOGGER.exit(null);
	return null;
}
 

开发者ID:DesignAndDeploy,
项目名称:dnd,
代码行数:14,
代码来源:LayoutBlockFeature.java

示例34: canUpdate

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean canUpdate(IUpdateContext context) {
	LOGGER.entry(context);
	PictogramElement pe = context.getPictogramElement();
	GraphicsAlgorithm ga = pe.getGraphicsAlgorithm();
	Object bo = getBusinessObjectForPictogramElement(pe);
	LOGGER.debug("ga: {}, bo: {}", ga, bo);
	if (bo instanceof FunctionBlockModel) {
		LOGGER.exit(true);
		return true;
	}
	LOGGER.exit(false);
	return false;
}
 

开发者ID:DesignAndDeploy,
项目名称:dnd,
代码行数:15,
代码来源:UpdateBlockFeature.java

示例35: canUpdate

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public boolean canUpdate(final IUpdateContext context) {
	LOGGER.entry(context);
	PictogramElement pe = context.getPictogramElement();
	GraphicsAlgorithm ga = pe.getGraphicsAlgorithm();
	Object bo = getBusinessObjectForPictogramElement(pe);
	if (ga instanceof Text && bo instanceof OptionModel) {
		LOGGER.exit(true);
		return true;
	}
	LOGGER.exit(false);
	return false;
}
 

开发者ID:DesignAndDeploy,
项目名称:dnd,
代码行数:14,
代码来源:UpdateOptionFeature.java

示例36: setInitialSize

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
protected void setInitialSize(GraphicsAlgorithm ga, int width, int height) {
  if (!getGaProperty("renderDone").isPresent()) {
    final TransactionalEditingDomain editingDomain = dtp.getDiagramBehavior().getEditingDomain();
    final IFeatureProvider fp = dtp.getFeatureProvider();

    final RecordingCommand command = new RecordingCommand(editingDomain, getIconURI()) {
      private IStatus result = null;

      @Override
      protected void doExecute() {
        try {
          GraphicsAlgorithm parentGA = ga.getParentGraphicsAlgorithm();
          Shape pe = (Shape) parentGA.getPictogramElement();
          EObject bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(pe);
          ResizeShapeContext context = new ResizeShapeContext(pe);
          if (bo instanceof Entity) {
            context.setSize(width + 2*ActorShapes.ACTOR_X_MARGIN, height + 2*ActorShapes.ACTOR_Y_MARGIN);
          } else {
            context.setSize(width, height);
          }
          context.setX(parentGA.getX());
          context.setY(parentGA.getY());
          context.putProperty("forced", "true");
          IResizeShapeFeature resizeShapeFeature = fp.getResizeShapeFeature(context);
          if (resizeShapeFeature != null) {
            resizeShapeFeature.resizeShape(context);
          }
          addGaProperty("renderDone", "true");
          result = Status.OK_STATUS;
        } catch (OperationCanceledException e) {
          result = Status.CANCEL_STATUS;
        }
      }

      @Override
      public Collection<?> getResult() {
        return result == null ? Collections.EMPTY_LIST : Collections.singletonList(result);
      }
    };

    // Execute (synchronously) the defined command in a proper EMF transaction
    editingDomain.getCommandStack().execute(command);
  }
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:45,
代码来源:AbstractCustomModelElementShape.java

示例37: add

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
  Attribute addedAttribute = (Attribute) context.getNewObject();
  ContainerShape targetContainer = context.getTargetContainer();

  int xLocation = context.getX();
  int yLocation = context.getY();

  IPeCreateService peCreateService = Graphiti.getPeCreateService();
  IGaService gaService = Graphiti.getGaService();
  ContainerShape containerShape = peCreateService.createContainerShape(targetContainer, true);

  GraphicsAlgorithm invisibleRectangle = null;
  invisibleRectangle = gaService.createInvisibleRectangle(containerShape);

  GraphicsAlgorithm attributeShapeGA = null;

  String iconResource = (String) context.getProperty("icon");
  String iconType = (String) context.getProperty("iconType");

  switch (iconType) {
  case TriqFeatureProvider.ICONTYPE_SVG:
  case TriqFeatureProvider.ICONTYPE_PTOLEMY:
    attributeShapeGA = buildExternallyDefinedShape(gaService, invisibleRectangle, containerShape, iconType, iconResource);
    break;
  default:
    attributeShapeGA = buildDefaultShape(gaService, invisibleRectangle, containerShape, addedAttribute, iconResource);
  }

  int width = attributeShapeGA.getWidth();
  int height = attributeShapeGA.getHeight();
  gaService.setLocationAndSize(invisibleRectangle, xLocation, yLocation, width, height);

  if (addedAttribute instanceof Parameter) {
    link(containerShape, addedAttribute, BoCategory.Parameter);
  } else {
    link(containerShape, addedAttribute, BoCategory.Attribute);
  }

  layoutPictogramElement(containerShape);

  return containerShape;
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:44,
代码来源:AttributeAddFeature.java

示例38: add

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
  Entity addedActor = (Entity) context.getNewObject();
  ContainerShape targetContainer = context.getTargetContainer();

  // This should be a duplicate from what's in ModelElementCreateFeature,
  // to link the toplevel CompositeActor to the Diagram.
  // So let's try to do without this.
  // Object topLevelForDiagram = getBusinessObjectForPictogramElement(getDiagram());
  // if (topLevelForDiagram == null) {
  // link(getDiagram(), addedActor.getContainer());
  // }

  int xLocation = context.getX();
  int yLocation = context.getY();

  IPeCreateService peCreateService = Graphiti.getPeCreateService();
  IGaService gaService = Graphiti.getGaService();
  ContainerShape containerShape = peCreateService.createContainerShape(targetContainer, true);
  link(context, containerShape, addedActor, BoCategory.Actor);

  GraphicsAlgorithm invisibleRectangle = null;
  invisibleRectangle = gaService.createInvisibleRectangle(containerShape);

  GraphicsAlgorithm actorShapeGA = null;

  String iconResource = (String) context.getProperty("icon");
  String iconType = (String) context.getProperty("iconType");

  switch (iconType) {
  case TriqFeatureProvider.ICONTYPE_SVG:
  case TriqFeatureProvider.ICONTYPE_PTOLEMY:
    actorShapeGA = buildExternallyDefinedShape(context, gaService, invisibleRectangle, containerShape, iconType, iconResource);
    break;
  default:
    actorShapeGA = buildDefaultShape(context, gaService, invisibleRectangle, containerShape, addedActor, iconResource);
  }

  int width = actorShapeGA.getWidth();
  int height = actorShapeGA.getHeight();
  gaService.setLocationAndSize(invisibleRectangle, xLocation, yLocation, width + 2*ACTOR_X_MARGIN, height + 2*ACTOR_Y_MARGIN);

  // SHAPES FOR PORTS; added both on default shapes and on custom/externally-defined icons (SVG, ptolemy icons)
  Map<Direction, List<Port>> categorizedPorts = addedActor.getPorts().stream().collect(groupingBy(Port::getDirection, mapping(Function.identity(), toList())));
  categorizedPorts.forEach((direction, ports) -> createAnchorsAndPortShapesForDirection(context, containerShape, direction, ports));

  layoutPictogramElement(containerShape);

  return containerShape;
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:51,
代码来源:ActorAddFeature.java

示例39: getLocation

点赞 2

import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; //导入依赖的package包/类
public static double[] getLocation(GraphicsAlgorithm ga) {
  return new double[] { ga.getX(), ga.getY() };
}
 

开发者ID:eclipse,
项目名称:triquetrum,
代码行数:4,
代码来源:EditorUtils.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)