use of org.eclipse.gmf.runtime.notation.ShapeStyle in project statecharts by Yakindu.
the class SimulationImageRenderer method highlightElements.
public void highlightElements(final List<? extends EObject> objects, final Diagram diagram) {
AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(TransactionUtil.getEditingDomain(diagram), "", null) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
// Init colors from preferences
RGB rgbForeGround = PreferenceConverter.getColor(SimulationActivator.getDefault().getPreferenceStore(), SimulationPreferenceConstants.STATE_FOREGROUND_HIGHLIGHTING_COLOR);
RGB rgbBackGround = PreferenceConverter.getColor(SimulationActivator.getDefault().getPreferenceStore(), SimulationPreferenceConstants.STATE_BACKGROUND_HIGHLIGHTING_COLOR);
RGB rgbTransitionActive = PreferenceConverter.getColor(SimulationActivator.getDefault().getPreferenceStore(), SimulationPreferenceConstants.TRANSITION_HIGHLIGHTING_COLOR);
Color color = new Color(Display.getDefault(), rgbForeGround);
Integer foreGround = FigureUtilities.colorToInteger(color);
color.dispose();
color = new Color(Display.getDefault(), rgbBackGround);
Integer background = FigureUtilities.colorToInteger(color);
color.dispose();
color = new Color(Display.getDefault(), rgbTransitionActive);
Integer transitionActive = FigureUtilities.colorToInteger(color);
color.dispose();
// Set styling
TreeIterator<EObject> eAllContents = diagram.eAllContents();
while (eAllContents.hasNext()) {
EObject next = eAllContents.next();
if (next instanceof View) {
for (EObject elementToHighlight : objects) {
EObject element = null;
if (next instanceof Node) {
element = ((Node) next).getElement();
} else if (next instanceof Edge) {
element = ((Edge) next).getElement();
}
if (element == null) {
// next instanceof BasicDecorationNode || next instanceof Shape
continue;
}
if (EcoreUtil.getURI(elementToHighlight).equals(EcoreUtil.getURI(element))) {
if (next instanceof Node) {
ShapeStyle style = (ShapeStyle) ((Node) next).getStyle(NotationPackage.Literals.SHAPE_STYLE);
if (style != null) {
style.setFillColor(background);
style.setLineColor(foreGround);
}
} else if (next instanceof Edge) {
ConnectorStyle style = (ConnectorStyle) ((View) next).getStyle(NotationPackage.Literals.CONNECTOR_STYLE);
if (style != null) {
style.setLineColor(transitionActive);
}
}
}
}
}
}
return CommandResult.newOKCommandResult();
}
};
try {
cmd.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
use of org.eclipse.gmf.runtime.notation.ShapeStyle in project statecharts by Yakindu.
the class EntryViewFactory method initializeFromPreferences.
@Override
protected void initializeFromPreferences(View view) {
super.initializeFromPreferences(view);
ShapeStyle style = (ShapeStyle) view.getStyle(NotationPackage.Literals.SHAPE_STYLE);
style.setFillColor(FigureUtilities.RGBToInteger(ColorConstants.black.getRGB()));
style.setLineColor(FigureUtilities.RGBToInteger(ColorConstants.white.getRGB()));
}
use of org.eclipse.gmf.runtime.notation.ShapeStyle in project statecharts by Yakindu.
the class StateViewFactory method decorateView.
@SuppressWarnings("unchecked")
@Override
protected void decorateView(View containerView, View view, IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
IAdaptable eObjectAdapter = null;
EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
if (eObject != null) {
eObjectAdapter = new EObjectAdapter(eObject);
}
// State name
FactoryUtils.createLabel(view, SemanticHints.STATE_NAME);
// Text compartment
getViewService().createNode(eObjectAdapter, view, SemanticHints.STATE_TEXT_COMPARTMENT, ViewUtil.APPEND, true, getPreferencesHint());
// Figure compartment
getViewService().createNode(eObjectAdapter, view, SemanticHints.STATE_FIGURE_COMPARTMENT, ViewUtil.APPEND, true, getPreferencesHint());
// Create a boolean value style that indicates the alignment of
// subregions
BooleanValueStyle layout = (BooleanValueStyle) NotationFactory.eINSTANCE.createBooleanValueStyle();
layout.setBooleanValue(true);
layout.setName(ALIGNMENT_ORIENTATION);
view.getStyles().add(layout);
IPreferenceStore store = (IPreferenceStore) getPreferencesHint().getPreferenceStore();
if (store == null) {
return;
}
// Create states default styles
ShapeStyle style = (ShapeStyle) view.getStyle(NotationPackage.Literals.SHAPE_STYLE);
RGB fillRGB = PreferenceConverter.getColor(store, StatechartPreferenceConstants.PREF_STATE_BACKGROUND);
style.setFillColor(FigureUtilities.RGBToInteger(fillRGB));
RGB lineRGB = PreferenceConverter.getColor(store, StatechartPreferenceConstants.PREF_STATE_LINE);
style.setLineColor(FigureUtilities.RGBToInteger(lineRGB));
}
use of org.eclipse.gmf.runtime.notation.ShapeStyle in project statecharts by Yakindu.
the class StatechartTextFactory method decorateView.
@Override
protected void decorateView(View containerView, View view, IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
IAdaptable eObjectAdapter = null;
EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
if (eObject != null) {
eObjectAdapter = new EObjectAdapter(eObject);
}
// Create the statechart name label
FactoryUtils.createLabel(view, STATECHART_NAME);
// create the expressions compartment
Node textCompartment = getViewService().createNode(eObjectAdapter, view, STATECHART_TEXT_EXPRESSION, ViewUtil.APPEND, true, getPreferencesHint());
Assert.isNotNull(textCompartment);
ShapeStyle style = (ShapeStyle) view.getStyle(NotationPackage.eINSTANCE.getShapeStyle());
style.setFillColor(FigureUtilities.RGBToInteger(ColorConstants.white.getRGB()));
}
use of org.eclipse.gmf.runtime.notation.ShapeStyle in project statecharts by Yakindu.
the class FactoryUtils method createLabel.
/**
* Creates a Label view
*
* @param owner
* @param hint
* @return
*/
@SuppressWarnings("unchecked")
public static Node createLabel(View owner, String hint) {
DecorationNode nameLabel = NotationFactory.eINSTANCE.createDecorationNode();
nameLabel.setType(hint);
ShapeStyle style = NotationFactory.eINSTANCE.createShapeStyle();
style.setFontColor(FigureUtilities.RGBToInteger(ColorConstants.black.getRGB()));
nameLabel.getStyles().add(style);
ViewUtil.insertChildView(owner, nameLabel, ViewUtil.APPEND, true);
nameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
return nameLabel;
}
Aggregations