Java Code Examples for org.eclipse.emf.common.util.EList#addAll()

The following examples show how to use org.eclipse.emf.common.util.EList#addAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void execute(AbstractOperationAction operationAction, GraphicalModelState modelState) {
	if (!(operationAction instanceof RerouteConnectionOperationAction)) {
		throw new IllegalArgumentException("Unexpected action " + operationAction);
	}

	// check for null-values
	final RerouteConnectionOperationAction action = (RerouteConnectionOperationAction) operationAction;
	if (action.getConnectionElementId() == null || action.getRoutingPoints() == null) {
		throw new IllegalArgumentException("Incomplete reconnect connection action");
	}

	// check for existence of matching elements
	GModelIndex index = modelState.getIndex();
	Optional<GEdge> edge = index.findElementByClass(action.getConnectionElementId(), GEdge.class);
	if (!edge.isPresent()) {
		throw new IllegalArgumentException("Invalid edge: edge ID " + action.getConnectionElementId());
	}

	// reroute
	EList<GPoint> routingPoints = edge.get().getRoutingPoints();
	routingPoints.clear();
	routingPoints.addAll(action.getRoutingPoints());
}
 
Example 2
/**
 * Apply the computed ELK layout to the given sprotty edge.
 */
protected void transferEdgeLayout(GEdge gedge, ElkEdge elkEdge, LayoutContext context) {
	if (!elkEdge.getSections().isEmpty()) {
		GPoint offset = getOffset(gedge, elkEdge, context);
		ElkEdgeSection section = elkEdge.getSections().get(0);
		List<GPoint> newRoutingPoints = new ArrayList<>();
		GPoint p1 = point(section.getStartX() + offset.getX(), section.getStartY() + offset.getY());
		newRoutingPoints.add(p1);
		for (ElkBendPoint bendGPoint : section.getBendPoints()) {
			GPoint p2 = point(bendGPoint.getX() + offset.getX(), bendGPoint.getY() + offset.getY());
			newRoutingPoints.add(p2);
		}
		GPoint p3 = point(section.getEndX() + offset.getX(), section.getEndY() + offset.getY());
		newRoutingPoints.add(p3);
		EList<GPoint> routingPoints = gedge.getRoutingPoints();
		routingPoints.clear();
		routingPoints.addAll(newRoutingPoints);
	}
}
 
Example 3
private void addActionsToExitReaction(final List<Expression> actionsToAdd) {

		if (actionsToAdd.isEmpty()) {
			return;
		}

		EList<Expression> actionsOriginal = helper
				.getFirstExitActions(getContextObject());

		if (actionsOriginal == null) {
			actionsOriginal = createExitBlock(actionsToAdd);
		} else {
			actionsOriginal.addAll(actionsToAdd);
		}

	}
 
Example 4
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated NOT
 */
@Override
public EList<Endpoint> getEndpoints ()
{
    final EList<Endpoint> result = ECollections.newBasicEList ();
    for ( final Exporter exporter : getExporter () )
    {
        result.addAll ( exporter.getEndpoints () );
    }
    return result;
}
 
Example 5
Source Project: statecharts   File: StateImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * 
 * @generated NOT
 */
public EList<Reaction> getLocalReactions() {
	EList<Reaction> result = new BasicEList<Reaction>();
	EList<Scope> scopes = getScopes();
	for (Scope scope : scopes) {
		result.addAll(scope.getReactions());
	}
	return new EcoreEList.UnmodifiableEList<Reaction>(this,
			SGraphPackage.Literals.REACTIVE_ELEMENT__LOCAL_REACTIONS, result.size(), result.toArray());
}
 
Example 6
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public EList<Endpoint> getEndpoints ()
{
    final EList<Endpoint> result = ECollections.newBasicEList ();
    for ( final Exporter exporter : getExporter () )
    {
        result.addAll ( exporter.getEndpoints () );
    }
    return result;
}
 
Example 7
Source Project: neoscada   File: DaveDriverImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated NOT
 */
@Override
public EList<Endpoint> getEndpoints ()
{
    final EList<Endpoint> result = ECollections.newBasicEList ();
    for ( final Exporter exporter : getExporter () )
    {
        result.addAll ( exporter.getEndpoints () );
    }
    return result;
}
 
Example 8
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated NOT
 */
@Override
public EList<Endpoint> getEndpoints ()
{
    final EList<Endpoint> result = ECollections.newBasicEList ();
    for ( final Exporter exporter : getExporter () )
    {
        result.addAll ( exporter.getEndpoints () );
    }
    return result;
}
 
Example 9
protected EList<XExpression> createArgumentList(XExpression head, List<XExpression> tail) {
	// TODO investigate in optimized List impls like head -> tail
	EList<XExpression> result = new BasicEList<XExpression>(tail.size() + 1);
	result.add(head);
	result.addAll(tail);
	return result;
}
 
Example 10
@Override
public EList<EAttribute> getAllEAttributes() {
  EList<EAttribute> result = getEAttributes();
  for (Export export : ((ExportModel) eContainer()).getExports()) {
    if (export.getType().isSuperTypeOf(this.getType())) {
      result.addAll(export.getEAttributes());
    }
  }
  return result;
}
 
Example 11
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public EList<Reaction> getLocalReactions() {
	EList<Reaction> result = new BasicEList<Reaction>();
	EList<Scope> scopes = getScopes();
	for (Scope scope : scopes) {
		result.addAll(scope.getReactions());
	}
	return new EcoreEList.UnmodifiableEList<Reaction>(this,
			SGraphPackage.Literals.REACTIVE_ELEMENT__LOCAL_REACTIONS, result.size(), result.toArray());
}
 
Example 12
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public EList<Instance> getContents() {
    final EList<Instance> contents = new BasicEList<Instance>();
    for (final Slot slot : getSlots()) {
        if (slot instanceof ReferenceSlot) {
            final ReferenceSlot referenceSlot = (ReferenceSlot) slot;
            if (referenceSlot.getEReference().isContainment()) {
                contents.addAll(referenceSlot.getValues());
            }
        }
    }
    return contents;
}
 
Example 13
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public EList<EPackage> getEPackages() {
	final EList<EPackage> ePackages = new UniqueEList<EPackage>();
	for (final MetamodelResource resource : getResources()) {
		ePackages.addAll(resource.getRootPackages());
	}
	return ePackages;
}
 
Example 14
@Override
public EList<Annotation> getAnnotations() {
	EList<Annotation> result = new BasicEList<Annotation>();
	result.addAll(super.getAnnotations());
	if(getAnnotationInfo() != null) {
		result.addAll(getAnnotationInfo().getAnnotations());
	}
	return ECollections.unmodifiableEList(result);
}
 
Example 15
@Override
public EList<Annotation> getAnnotations() {
	EList<Annotation> result = new BasicEList<Annotation>();
	result.addAll(super.getAnnotations());
	if(getAnnotationInfo() != null) {
		result.addAll(getAnnotationInfo().getAnnotations());
	}
	return ECollections.unmodifiableEList(result);
}
 
Example 16
@Override
public EList<Annotation> getAnnotations() {
	EList<Annotation> result = new BasicEList<Annotation>();
	result.addAll(super.getAnnotations());
	if(getAnnotationInfo() != null) {
		result.addAll(getAnnotationInfo().getAnnotations());
	}
	return ECollections.unmodifiableEList(result);
}
 
Example 17
@Override
public EList<Annotation> getAnnotations() {
	EList<Annotation> result = new BasicEList<Annotation>();
	result.addAll(super.getAnnotations());
	if(getAnnotationInfo() != null) {
		result.addAll(getAnnotationInfo().getAnnotations());
	}
	return ECollections.unmodifiableEList(result);
}
 
Example 18
Source Project: Getaviz   File: BrickLayout.java    License: Apache License 2.0 4 votes vote down vote up
private static void seperateBuilding(final Building b) {
		// Don't build up bricks, if this building isn't visualized or isn't positioned (e.g. is an inner classes)
		if (b.getPosition() == null) {
			return;
		}

		// variables for brick algorithm
		int sc, 	// side capacity
			lc,		// layer capacity
			biws,	// brick index within side
			biwl,	// brick index within layer
			si,		// side index - north,east,...
			bsPosIndex_X, bsPosIndex_Y, bsPosIndex_Z;
		double b_lowerLeftX, b_upperY, b_lowerLeftZ;
		sc = b.getSideCapacity();

		// Get elements for modeling
		EList<BuildingSegment> classElements = new BasicEList<BuildingSegment>();
		switch (config.getClassElementsMode()) {
			case ATTRIBUTES_ONLY:
				classElements.addAll(b.getData());
				break;
			case METHODS_ONLY:
				classElements.addAll(b.getMethods());
				break;
			case METHODS_AND_ATTRIBUTES:
				classElements.addAll(b.getData());
				classElements.addAll(b.getMethods());
				break;
			default:
				classElements.addAll(b.getMethods());
				break;
		}

		// Sorting elements
		CityUtils.sortBuildingSegments(classElements);
		
		// coordinates of edges of building
		b_lowerLeftX = b.getPosition().getX() - b.getWidth()/2;
		b_lowerLeftZ = b.getPosition().getZ() - b.getLength()/2;
		b_upperY = b.getPosition().getY() + b.getHeight()/2;
//System.out.println("");
		BuildingSegment bs;
		// set positions for all methods in current class
		for(int i=0; i<classElements.size(); ++i) {
			bs = classElements.get(i);
			if(sc <= 1) {
				lc = 1;
				biws = 0;
				si = 0;
			} else {
				lc = (sc-1) * 4;
				biwl = i % lc;
				biws = biwl % (sc-1);
				si = biwl / (sc-1);
			}
//			System.out.println(bs.getType() + " " + bs.getValue() + " " + bs.getModifiers() + " " + bs.getNumberOfStatements());
			// calculating position for brick
			switch(si) {
				case 0:
					bsPosIndex_X = biws;
					bsPosIndex_Z = 0;
					break;
				case 1:
					bsPosIndex_X = sc - 1;
					bsPosIndex_Z = biws;
					break;
				case 2:
					bsPosIndex_X = sc - biws - 1;
					bsPosIndex_Z = sc - 1;
					break;
				default:
					bsPosIndex_X = 0;
					bsPosIndex_Z = sc - biws - 1;
					break;
			}
			bsPosIndex_Y = i / lc;

			// setting position for brick
			Position pos = cityFactory.createPosition();
			pos.setX(b_lowerLeftX + config.getBrickHorizontalMargin()
					+ (config.getBrickHorizontalGap() + config.getBrickSize()) * bsPosIndex_X
					+ config.getBrickSize() * 0.5);
			pos.setZ(b_lowerLeftZ + config.getBrickHorizontalMargin()
					+ (config.getBrickHorizontalGap() + config.getBrickSize()) * bsPosIndex_Z
					+ config.getBrickSize() * 0.5);
			pos.setY(b_upperY + config.getBrickVerticalMargin()
					+ (config.getBrickVerticalGap() + config.getBrickSize()) * bsPosIndex_Y
					+ config.getBrickSize() * 0.5);
			bs.setPosition(pos);
		}
	}
 
Example 19
Source Project: Getaviz   File: PlantLayout.java    License: Apache License 2.0 4 votes vote down vote up
private static Rectangle calculateMaxArea(Entity entity) {
	if (DEBUG) {
		System.out.println("\t\t" + info + "calculateMaxArea(" + entity.getFqn() + ")-arrival.");
	}

	EList<Entity> list = new BasicEList<Entity>();
	if (entity instanceof Stem) {
		Stem stem = (Stem) entity;
		list.addAll(stem.getJunctions());
	}
	if (entity instanceof Area) {
		Area area = (Area) entity;
		list.addAll(area.getEntities());
	}
	if (entity instanceof Junction) {
		Junction junction = (Junction) entity;
		list.addAll(junction.getJunctions());
	}

	EList<Entity> children = list;

	double sum_width = 0;
	double sum_length = 0;

	for (Entity child : children) {
		if (child.getType().equals("FAMIX.Namespace")) {
			if (DEBUG) {
				System.out.println("\t\t\t" + info + "layOut(" + child.getFqn() + ")-call, recursive.");
			}
			arrangeChildren(child);
		}

		sum_width += child.getWidth() + config.getPlantBuildingHorizontalGap();
		sum_length += child.getLength() + config.getPlantBuildingHorizontalGap();
		// sum_length += child.getHeight() +PlantSettings.BLDG_horizontalGap;
		if (DEBUG_Part1) {
			System.out.println("\t\t\t" + info + "Child " + child.getFqn() + " [modVALUES]: width="
					+ child.getWidth() + " length=" + child.getLength() + "|=> sum_width=" + sum_width
					+ " sum_length=" + sum_length);
		}
	}

	if (DEBUG_Part1) {
		System.out.println("\t\t\t" + info + "Entity " + entity.getFqn() + " [newVALUES]: width="
				+ entity.getWidth() + " length=" + entity.getLength());
	}
	if (DEBUG) {
		System.out.println("\t\t" + info + "calculateMaxArea(" + entity.getFqn() + ")-exit.");
	}
	return new Rectangle(0, 0, sum_width, sum_length, 1);
}
 
Example 20
Source Project: birt   File: PaletteImpl.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public final void update( int iIndex )
{
	final EList el = getEntries( );
	el.clear( );
	if ( iIndex < 0 )
	{
		// a rotation version of palette-0, rataion pos is the negatvie
		// index.
		ArrayList al = new ArrayList( );

		al.add( ColorDefinitionImpl.create( 80, 166, 218 ) );
		al.add( ColorDefinitionImpl.create( 242, 88, 106 ) );
		al.add( ColorDefinitionImpl.create( 232, 172, 57 ) );
		al.add( ColorDefinitionImpl.create( 128, 255, 128 ) );
		al.add( ColorDefinitionImpl.create( 64, 128, 128 ) );
		al.add( ColorDefinitionImpl.create( 128, 128, 192 ) );
		al.add( ColorDefinitionImpl.create( 170, 85, 85 ) );
		al.add( ColorDefinitionImpl.create( 128, 128, 0 ) );

		shiftList( al, -iIndex );

		el.addAll( al );
	}
	else if ( iIndex == 0 )
	{
		el.add( ColorDefinitionImpl.create( 80, 166, 218 ) );
		el.add( ColorDefinitionImpl.create( 242, 88, 106 ) );
		el.add( ColorDefinitionImpl.create( 232, 172, 57 ) );
		el.add( ColorDefinitionImpl.create( 128, 255, 128 ) );
		el.add( ColorDefinitionImpl.create( 64, 128, 128 ) );
		el.add( ColorDefinitionImpl.create( 128, 128, 192 ) );
		el.add( ColorDefinitionImpl.create( 170, 85, 85 ) );
		el.add( ColorDefinitionImpl.create( 128, 128, 0 ) );
	}
	else if ( iIndex == 1 )
	{
		el.add( ColorDefinitionImpl.create( 225, 225, 255 ) );
		el.add( ColorDefinitionImpl.create( 223, 197, 41 ) );
		el.add( ColorDefinitionImpl.create( 249, 225, 191 ) );
		el.add( ColorDefinitionImpl.create( 255, 205, 225 ) );
		el.add( ColorDefinitionImpl.create( 225, 255, 225 ) );
		el.add( ColorDefinitionImpl.create( 255, 191, 255 ) );
		el.add( ColorDefinitionImpl.create( 185, 185, 221 ) );
		el.add( ColorDefinitionImpl.create( 40, 255, 148 ) );
	}
	else
	{
		logger.log( ILogger.WARNING,
				Messages.getString( "error.unknown.palette", //$NON-NLS-1$ 
						new Object[]{
							Integer.valueOf( iIndex )
						},
						ULocale.getDefault( ) ) );
		update( 0 );
	}
}