use of org.eclipse.sirius.diagram.description.style.FlatContainerStyleDescription in project sirius-components by eclipse-sirius.
the class ContainerMappingStyleProviderTests method createFlatStyle.
private FlatContainerStyleDescription createFlatStyle(int red, int green, int blue) {
FlatContainerStyleDescription containerStyleDescription = StyleFactory.eINSTANCE.createFlatContainerStyleDescription();
FixedColor fixedColor = org.eclipse.sirius.viewpoint.description.DescriptionFactory.eINSTANCE.createFixedColor();
fixedColor.setRed(red);
fixedColor.setGreen(green);
fixedColor.setBlue(blue);
containerStyleDescription.setBorderColor(fixedColor);
return containerStyleDescription;
}
use of org.eclipse.sirius.diagram.description.style.FlatContainerStyleDescription in project sirius-components by eclipse-sirius.
the class ContainerMappingSizeProviderTests method createFlatStyle.
private FlatContainerStyleDescription createFlatStyle(int red, int green, int blue) {
FlatContainerStyleDescription containerStyleDescription = StyleFactory.eINSTANCE.createFlatContainerStyleDescription();
FixedColor fixedColor = org.eclipse.sirius.viewpoint.description.DescriptionFactory.eINSTANCE.createFixedColor();
fixedColor.setRed(red);
fixedColor.setGreen(green);
fixedColor.setBlue(blue);
containerStyleDescription.setBorderColor(fixedColor);
return containerStyleDescription;
}
use of org.eclipse.sirius.diagram.description.style.FlatContainerStyleDescription in project sirius-components by eclipse-sirius.
the class ContainerMappingSizeProviderTests method testSizeProviderWithProvidedSizeFromVSM.
@Test
public void testSizeProviderWithProvidedSizeFromVSM() {
ContainerMapping containerMapping = DescriptionFactory.eINSTANCE.createContainerMapping();
FlatContainerStyleDescription flatStyle = this.createFlatStyle(0, 0, 0);
flatStyle.setHeightComputationExpression(AQL_10);
flatStyle.setWidthComputationExpression(AQL_20);
containerMapping.setStyle(flatStyle);
VariableManager variableManager = new VariableManager();
AQLInterpreter interpreter = new AQLInterpreter(List.of(), List.of(EcorePackage.eINSTANCE));
var abstractNodeMappingSizeProvider = new AbstractNodeMappingSizeProvider(interpreter, containerMapping);
Size size = abstractNodeMappingSizeProvider.apply(variableManager);
assertThat(size).extracting(Size::getHeight).isEqualTo(100.0);
assertThat(size).extracting(Size::getWidth).isEqualTo(200.0);
}
use of org.eclipse.sirius.diagram.description.style.FlatContainerStyleDescription in project sirius-components by eclipse-sirius.
the class AbstractNodeMappingSizeProvider method apply.
@Override
public Size apply(VariableManager variableManager) {
LabelStyleDescription labelStyleDescription = new LabelStyleDescriptionProvider(this.interpreter, this.abstractNodeMapping).apply(variableManager);
Size size = Size.UNDEFINED;
if (labelStyleDescription instanceof SquareDescription) {
SquareDescription squareDescription = (SquareDescription) labelStyleDescription;
int width = squareDescription.getWidth() * SIZE_FACTOR;
int height = squareDescription.getHeight() * SIZE_FACTOR;
// expression to set the width and/or height
if (width == 0 || height == 0) {
Result result = this.interpreter.evaluateExpression(variableManager.getVariables(), squareDescription.getSizeComputationExpression());
int computedSize = result.asInt().getAsInt() * SIZE_FACTOR;
if (computedSize > 0) {
if (width == 0) {
width = computedSize;
}
if (height == 0) {
height = computedSize;
}
}
}
size = Size.of(width, height);
} else if (labelStyleDescription instanceof FlatContainerStyleDescription) {
int width = -1;
int height = -1;
FlatContainerStyleDescription flatContainerStyleDescription = (FlatContainerStyleDescription) labelStyleDescription;
Result result = this.interpreter.evaluateExpression(variableManager.getVariables(), flatContainerStyleDescription.getWidthComputationExpression());
int computedWidth = result.asInt().getAsInt();
if (computedWidth > 0) {
width = computedWidth * SIZE_FACTOR;
}
result = this.interpreter.evaluateExpression(variableManager.getVariables(), flatContainerStyleDescription.getHeightComputationExpression());
int computedHeight = result.asInt().getAsInt();
if (computedHeight > 0) {
height = computedHeight * SIZE_FACTOR;
}
size = Size.of(width, height);
} else if (labelStyleDescription instanceof DotDescription) {
int width = -1;
int height = -1;
DotDescription dotDescription = (DotDescription) labelStyleDescription;
Result result = this.interpreter.evaluateExpression(variableManager.getVariables(), dotDescription.getSizeComputationExpression());
int computedSize = result.asInt().getAsInt();
if (computedSize > 0) {
width = computedSize * SIZE_FACTOR;
height = computedSize * SIZE_FACTOR;
}
size = Size.of(width, height);
}
return size;
}
use of org.eclipse.sirius.diagram.description.style.FlatContainerStyleDescription in project sirius-components by eclipse-sirius.
the class AbstractNodeMappingStyleProvider method getNodeStyle.
private INodeStyle getNodeStyle(VariableManager variableManager, LabelStyleDescription nodeStyleDescription) {
INodeStyle style = null;
if (this.shouldBeConsideredAsListItemNodeStyle(variableManager, nodeStyleDescription)) {
style = this.createListItemNodeStyle(variableManager, nodeStyleDescription);
} else if (nodeStyleDescription instanceof SquareDescription) {
SquareDescription squareDescription = (SquareDescription) nodeStyleDescription;
style = this.createRectangularNodeStyle(variableManager, squareDescription);
} else if (nodeStyleDescription instanceof DotDescription) {
DotDescription dotDescription = (DotDescription) nodeStyleDescription;
style = this.createRectangularNodeStyle(variableManager, dotDescription);
} else if (nodeStyleDescription instanceof FlatContainerStyleDescription) {
FlatContainerStyleDescription flatContainerStyleDescription = (FlatContainerStyleDescription) nodeStyleDescription;
if (this.abstractNodeMapping instanceof ContainerMapping && new ContainerMappingQuery((ContainerMapping) this.abstractNodeMapping).isListContainer()) {
style = this.createListNodeStyle(variableManager, flatContainerStyleDescription);
} else {
style = this.createRectangularNodeStyle(variableManager, flatContainerStyleDescription);
}
} else if (nodeStyleDescription instanceof WorkspaceImageDescription) {
WorkspaceImageDescription workspaceImageDescription = (WorkspaceImageDescription) nodeStyleDescription;
WorkspaceImageDescriptionConverter workspaceImageDescriptionConverter = new WorkspaceImageDescriptionConverter(this.interpreter, variableManager, workspaceImageDescription);
style = workspaceImageDescriptionConverter.convert();
} else {
// Fallback on Rectangular node style for now, until other styles are supported
// @formatter:off
style = RectangularNodeStyle.newRectangularNodeStyle().color(// $NON-NLS-1$
"rgb(200, 200, 200)").borderColor(// $NON-NLS-1$
"rgb(0, 0, 0)").borderSize(1).borderStyle(LineStyle.Solid).build();
// @formatter:on
}
return style;
}
Aggregations