Me n My Programming

If Only I Have TIme

Marama Code 106 ~ How to create simulation in your diagram

First of all, credit to Jun for helping me with this. He’s the one who code the async for marama, I just supplied the idea and thread sleeping code.


read all shape in digram

place shape in a list

for each shape in list

read n store shape color in buffer

change shape color

delay 1o seconds

revert to original color



First method:

MaramaDiagram diagram = this.getDiagram(); // get the diagram

try {
Thread t = new Thread(new Y(diagram, EclipseHelper.getWorkingWindowShell())); // invoke first thread
t.start(); // star the thread
} catch (Exception e) { e.printStackTrace(); }

Second method:

for (MaramaShape s: d.getChildren()) { // get each shape

RGB col = (RGB)s.getPropertyValue(“color”); // get shape original colour

sh.getDisplay().asyncExec(new X(s, simulationColor)); // invoke second thread ~ change to simulation colour

try {
Thread.currentThread().sleep(700); // get the second thread to sleep
} catch (InterruptedException e) { e.printStackTrace(); }

sh.getDisplay().asyncExec(new X(s, col)); // invoke third thread ~ revert back to original colour

try {
Thread.currentThread().sleep(700); // get the third thread to sleep
} catch (InterruptedException e) { e.printStackTrace();    }


Third method:

mu.changeShapeColour(s, “color”, col); // change the shape colour

I think the most important part is to know which shape you want to simulate and when to simulate it (set aside the java code to call async and thread). I hope this will help some of you if you like to have a simple something like simulation inside your marama diagram. Good luck!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


This entry was posted on August 17, 2010 by in Life on Marama.
%d bloggers like this: