file How to : Highlight an Element

5 years 9 months ago #2861 by Nico42
Hello,

I'd like to programmatically highlight an element like how it shows when you can graphically link an element.

Which object/interface can do that ?

thx.

Please Log in or Create an account to join the conversation.

5 years 8 months ago #2867 by ebr
Hi Nico,

please take a look at the diagram services API .

Hoping it helps,

EBR

Please Log in or Create an account to join the conversation.

5 years 8 months ago - 5 years 8 months ago #2879 by Nico42
Hmm i guess i need some help on that :
Quote code from the doc :

// loop on the static diagrams whose context is the root package (if some)
for (IStaticDiagram diagram : session.getModel()
.getUmlProject()
.getDiagramRoot()
.getDiagram(IStaticDiagram.class)) {{

But the method .getDiagram(..) has been removed, i've replaced it by getReferencedDiagram(..)
And there is no IStaticDiagram found when i execute it on my Diagram module or any already implemented diagram.

Do you see any reason ?

Please Log in or Create an account to join the conversation.

5 years 8 months ago #2881 by ebr
Hi Nico,

One quick question, do you develop a Module for Modelio 2.x or Modelio 3.x?

Your quote seems to come from a Modelio 2.x example where did you get it?

Please find below an example of Modelio 3 code just to give you some idea.
IModelingSession session = Modelio.getInstance ().getModelingSession();
      
     // loop on all existing  static diagrams 
        IDiagramService ds = Modelio.getInstance().getDiagramService();
        for (StaticDiagram diagram : session.findByClass(StaticDiagram.class)){   
          
            IDiagramHandle handler = ds.getDiagramHandle(diagram);
            IDiagramDG dg = handler.getDiagramNode();
            for (IDiagramNode node : dg.getNodes()){
                node.setLineWidth(3);
            }
            handler.save();
            handler.close();
            
        }

You said that you wanted to highlight an element, my first question is how did you get this element?

BR

EBR

Please Log in or Create an account to join the conversation.

5 years 8 months ago #2882 by Nico42
Hi ebr,

I'm using Modelio 2.x (i didn't had the choice when i started, i guess i'll open a new topic to ask how to convert a 2.x module to 3.x :oops: )

The quote is coming from the link on your previous post : diagram services API

This is how i get my elements :
public static List<IModelElement> findModelElement(
			Class<? extends IElement> classe, String stereotype) {
		List<IModelElement> elts = null;
		IModelingSession session = Modelio.getInstance().getModelingSession();
		IStereotype s = null;
		try {
			s = session.getMetamodelExtensions().getStereotype(classe,
					stereotype);
		} catch (StereotypeNotFoundException e) {			
			e.printStackTrace();
		}
		if (s != null && s.getExtendedElement() != null) {
			elts = s.getExtendedElement();
		}
		return elts;
	}

Please Log in or Create an account to join the conversation.

Moderators: tmachmaab
Time to create page: 0.041 seconds
^ Back to Top