当前位置: 首页>>代码示例>>Java>>正文


Java Anchor类代码示例

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


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

示例1: canCreate

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
@Override
public boolean canCreate(ICreateConnectionContext context) {
	Anchor srcAnchor = context.getSourceAnchor();
	Anchor tgtAnchor = context.getTargetAnchor();
	if (srcAnchor == null || tgtAnchor == null) {
		return false;
	}

	Object src = getBusinessObjectForPictogramElement(srcAnchor.getParent());
	Object tgt = getBusinessObjectForPictogramElement(tgtAnchor.getParent());

	if (src == null || tgt == null || src == tgt) {
		return false;
	} else if (src instanceof ProcessingUnit && tgt instanceof Medium) {
		return !areAlreadyLinked((ProcessingUnit) src, (Medium) tgt);
	} else if (tgt instanceof ProcessingUnit && src instanceof Medium) {
		return !areAlreadyLinked((ProcessingUnit) tgt, (Medium) src);
	} else {
		return false;
	}

}
 
开发者ID:turnus,项目名称:turnus,代码行数:23,代码来源:LinkPattern.java

示例2: deepContains

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
private static boolean deepContains(ContainerShape cs, Anchor a) {
  boolean result = cs.getAnchors().contains(a);
  if(!result) {
    AnchorContainer aContainer = a.getParent();
    while (!result) {
      if(aContainer==null) {
        break;
      }
      result = cs.getChildren().contains(aContainer);
      if(!result && (aContainer instanceof Shape)) {
        aContainer = ((Shape)aContainer).getContainer();
      }
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:17,代码来源:CompositeActorCollapseExpandFeature.java

示例3: updateNeeded

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的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

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的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: createAnchorsAndPortShapesForDirection

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
/**
 * 
 * @param context
 * @param containerShape
 * @param direction
 * @param portList
 */
private void createAnchorsAndPortShapesForDirection(IAddContext context, ContainerShape containerShape, Direction direction, List<Port> portList) {
  Map<String, Anchor> anchorMap = (Map<String, Anchor>) context.getProperty(FeatureConstants.ANCHORMAP_NAME);
  // The list should only contain pairs for which there are still ports on the actor.
  // But there may still be new ports for which no anchor is present yet in the graphical model.
  int portCount = portList.size();
  for (int i = 0; i < portCount; ++i) {
    Port p = portList.get(i);
    Anchor anchor = PortShapes.createAnchor(containerShape, direction, p, i, portCount);
    PortShapes.createPortShape(getDiagram(), anchor, direction, p);
    link(context, anchor, p, BoCategory.Port, PortCategory.valueOf(direction));
    if (anchorMap != null) {
      anchorMap.put(p.getFullName(), anchor);
    }
  }
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:23,代码来源:ActorAddFeature.java

示例6: create

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
@Override
public Connection create(final ICreateConnectionContext context) {
  Anchor _sourceAnchor = context.getSourceAnchor();
  AnchorContainer _parent = _sourceAnchor.getParent();
  Object _businessObjectForPictogramElement = this.getBusinessObjectForPictogramElement(_parent);
  final State source = ((State) _businessObjectForPictogramElement);
  Anchor _targetAnchor = context.getTargetAnchor();
  AnchorContainer _parent_1 = _targetAnchor.getParent();
  Object _businessObjectForPictogramElement_1 = this.getBusinessObjectForPictogramElement(_parent_1);
  final State target = ((State) _businessObjectForPictogramElement_1);
  final Transition transition = StatemachineFactory.eINSTANCE.createTransition();
  transition.setSourceState(source);
  transition.setTargetState(target);
  EObject _eContainer = source.eContainer();
  final Statemachine statemachine = ((Statemachine) _eContainer);
  EList<Transition> _transitions = statemachine.getTransitions();
  _transitions.add(transition);
  Anchor _sourceAnchor_1 = context.getSourceAnchor();
  Anchor _targetAnchor_1 = context.getTargetAnchor();
  final AddConnectionContext addContext = new AddConnectionContext(_sourceAnchor_1, _targetAnchor_1);
  addContext.setNewObject(transition);
  IFeatureProvider _featureProvider = this.getFeatureProvider();
  PictogramElement _addIfPossible = _featureProvider.addIfPossible(addContext);
  return ((Connection) _addIfPossible);
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:26,代码来源:CreateTransitionFeature.java

示例7: add

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
@Override
public PictogramElement add(final IAddContext context) {
  final IAddConnectionContext addConContext = ((IAddConnectionContext) context);
  Object _newObject = context.getNewObject();
  final Transition addedTransition = ((Transition) _newObject);
  Diagram _diagram = this.getDiagram();
  final FreeFormConnection connection = this._iPeCreateService.createFreeFormConnection(_diagram);
  Anchor _sourceAnchor = addConContext.getSourceAnchor();
  connection.setStart(_sourceAnchor);
  Anchor _targetAnchor = addConContext.getTargetAnchor();
  connection.setEnd(_targetAnchor);
  final Polyline polyline = this._iGaService.createPolyline(connection);
  Color _manageColor = this.manageColor(IColorConstant.DARK_GRAY);
  polyline.setForeground(_manageColor);
  this.link(connection, addedTransition);
  return connection;
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:18,代码来源:AddTransitionFeature.java

示例8: canCreate

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
@Override
public boolean canCreate(final ICreateConnectionContext context) {
	Anchor sourceAnchor = context.getSourceAnchor();
	Anchor targetAnchor = context.getTargetAnchor();
	if (!(sourceAnchor instanceof FixPointAnchor) || !(targetAnchor instanceof FixPointAnchor)) {
		return false;
	}
	Object sourceBo = getBusinessObjectForPictogramElement(sourceAnchor);
	Object targetBo = getBusinessObjectForPictogramElement(targetAnchor);
	if (sourceBo instanceof OutputModel && targetBo instanceof InputModel) {
		return ((OutputModel) sourceBo).isCompatible(((FeatureProvider) getFeatureProvider()).getRepository(),
				(InputModel) targetBo);
	} else if (sourceBo instanceof InputModel && targetBo instanceof OutputModel) {
		return ((InputModel) sourceBo).isCompatible(((FeatureProvider) getFeatureProvider()).getRepository(),
				(OutputModel) targetBo);
	}
	return false;
}
 
开发者ID:DesignAndDeploy,项目名称:dnd,代码行数:19,代码来源:CreateDataConnectionFeature.java

示例9: create

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
@Override
public Connection create(final ICreateConnectionContext context) {
	Anchor sourceAnchor = context.getSourceAnchor();
	Anchor targetAnchor = context.getTargetAnchor();
	if (getBusinessObjectForPictogramElement(sourceAnchor) instanceof InputModel) {
		Anchor temp = sourceAnchor;
		sourceAnchor = targetAnchor;
		targetAnchor = temp;
	}
	OutputModel output = (OutputModel) getBusinessObjectForPictogramElement(sourceAnchor);
	InputModel input = (InputModel) getBusinessObjectForPictogramElement(targetAnchor);
	if (input.getOutput() != null) {
		LOGGER.info("Removing old connection"); //$NON-NLS-1$
		IRemoveContext removeContext = new RemoveContext(targetAnchor.getIncomingConnections().get(0));
		IRemoveFeature removeFeature = new RemoveDataConnectionFeature(getFeatureProvider());
		if (removeFeature.canExecute(removeContext)) {
			removeFeature.execute(removeContext);
		} else {
			LOGGER.warn("could not remove"); //$NON-NLS-1$
		}
	}
	input.setOutput(output);
	AddConnectionContext addContext = new AddConnectionContext(sourceAnchor, targetAnchor);
	return (Connection) getFeatureProvider().addIfPossible(addContext);
}
 
开发者ID:DesignAndDeploy,项目名称:dnd,代码行数:26,代码来源:CreateDataConnectionFeature.java

示例10: createPortShape

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
/**
 * Creates a port shape matching the direction along its actor shape, the single/multi and the input/output types.
 * 
 * @param diagram
 * @param anchor the anchor on which the port shape must be created
 * @param direction
 * @param p
 * @return
 */
public static Polygon createPortShape(Diagram diagram, Anchor anchor, Direction direction, Port p) {
  IGaService gaService = Graphiti.getGaService();

  Collection<Point> portShapePoints = getPortShapeDefinition(direction, p);
  
  final Polygon portShape = gaService.createPlainPolygon(anchor, portShapePoints);
  portShape.setForeground(gaService.manageColor(diagram, PORT_FOREGROUND));
  IColorConstant portColour = p.isMultiPort() ? PORT_BACKGROUND_MULTIPORT : PORT_BACKGROUND_SINGLEPORT;
  portShape.setBackground(gaService.manageColor(diagram, portColour));
  portShape.setLineWidth(1);
  gaService.setLocationAndSize(portShape, 0, 0, PORT_SIZE, PORT_SIZE);
  
  return portShape;
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:24,代码来源:PortShapes.java

示例11: rotatePortShape

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
/**
 * Rotates the anchor's port shape to match the direction and port input/output type.
 * 
 * @param diagram
 * @param anchor
 * @param direction
 * @param p
 * @return
 */
public static Polygon rotatePortShape(Diagram diagram, Anchor anchor, Direction direction, Port p) {
  List<Point> portShapePoints = getPortShapeDefinition(direction, p);
  final Polygon portShape = (Polygon) anchor.getGraphicsAlgorithm();

  for(int i=0; i<portShape.getPoints().size(); ++i) {
    Point currPt = portShape.getPoints().get(i);
    Point newPt = portShapePoints.get(i);
    currPt.setX(newPt.getX());
    currPt.setY(newPt.getY());
  }
  
  return portShape;
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:23,代码来源:PortShapes.java

示例12: getAnchorBO

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
/**
 * Returns the Port or Vertex belonging to the anchor, or null if not available.
 */
private Linkable getAnchorBO(Anchor anchor) {
  if (anchor != null) {
    Object object = getBusinessObjectForPictogramElement(anchor);
    if (object instanceof Port) {
      return (Port) object;
    }
    if (object instanceof Vertex) {
      return (Vertex) object;
    } else {
      throw new IllegalArgumentException("Anchor " + anchor + " linked to invalid object "+object);
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:18,代码来源:ConnectionReconnectFeature.java

示例13: getAnchorBO

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
/**
 * Returns the Port or Vertex belonging to the anchor, or null if not available.
 */
private Linkable getAnchorBO(Anchor anchor) {
  if (anchor != null) {
    Object object = getBusinessObjectForPictogramElement(anchor);
    if (object instanceof Port) {
      return (Port) object;
    }
    if (object instanceof Vertex) {
      return (Vertex) object;
    } else {
      throw new IllegalArgumentException("Anchor " + anchor + " linked to invalid object " + object);
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:18,代码来源:ConnectionCreateFeature.java

示例14: add

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
  Vertex addedVertex = (Vertex) 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);

  int xy[] = new int[] { 6, 0, 12, 10, 6, 20, 0, 10 };
  Polygon diamond = gaService.createPolygon(containerShape, xy);
  diamond.setForeground(manageColor(VERTEX_BACKGROUND));
  diamond.setBackground(manageColor(VERTEX_BACKGROUND));
  gaService.setLocationAndSize(diamond, xLocation, yLocation, 12, 30);

  // add an anchor in the Vertex
  // TODO check if we need multiple anchors?
  ChopboxAnchor anchor = peCreateService.createChopboxAnchor(containerShape);
  anchor.setReferencedGraphicsAlgorithm(diamond);
  link(anchor, addedVertex, BoCategory.Relation);
  link(containerShape, addedVertex, BoCategory.Relation);

  Map<String, Anchor> anchorMap = (Map<String, Anchor>) context.getProperty(FeatureConstants.ANCHORMAP_NAME);
  if (anchorMap != null) {
    anchorMap.put(addedVertex.getFullName(), anchor);
  }

  layoutPictogramElement(containerShape);

  return containerShape;
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:35,代码来源:VertexAddFeature.java

示例15: getAnchorBO

import org.eclipse.graphiti.mm.pictograms.Anchor; //导入依赖的package包/类
/**
 * Returns the Port or Vertex belonging to the anchor, or null if not available.
 */
private NamedObj getAnchorBO(Anchor anchor) {
  if (anchor != null) {
    Object object = getBusinessObjectForPictogramElement(anchor);
    if (object instanceof Port) {
      return (Port) object;
    }
    if (object instanceof Vertex) {
      return (Vertex) object;
    } else {
      throw new IllegalArgumentException("Anchor " + anchor + " linked to invalid object " + object);
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:18,代码来源:ModelElementPasteFeature.java


注:本文中的org.eclipse.graphiti.mm.pictograms.Anchor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。