public void coloriseTokens(Transition t) { VisualStg visualStg = (VisualStg) getUnderlyingModel(); VisualTransition vt = visualStg.getVisualTransition(t); if (vt == null) return; Color tokenColor = Color.black; ColorGenerator tokenColorGenerator = vt.getTokenColorGenerator(); if (tokenColorGenerator != null) { // generate token colour tokenColor = tokenColorGenerator.updateColor(); } else { // combine preset token colours for (Connection c : visualStg.getConnections(vt)) { if ((c.getSecond() == vt) && (c instanceof VisualConnection)) { VisualConnection vc = (VisualConnection) c; if (vc.isTokenColorPropagator()) { if (vc.getFirst() instanceof VisualPlace) { VisualPlace vp = (VisualPlace) c.getFirst(); tokenColor = Coloriser.colorise(tokenColor, vp.getTokenColor()); } else if (vc instanceof VisualImplicitPlaceArc) { VisualImplicitPlaceArc vipa = (VisualImplicitPlaceArc) vc; tokenColor = Coloriser.colorise(tokenColor, vipa.getTokenColor()); } } } } } // propagate the colour to postset tokens for (Connection c : visualStg.getConnections(vt)) { if ((c.getFirst() == vt) && (c instanceof VisualConnection)) { VisualConnection vc = (VisualConnection) c; if (vc.isTokenColorPropagator()) { if (vc.getSecond() instanceof VisualPlace) { VisualPlace vp = (VisualPlace) c.getSecond(); vp.setTokenColor(tokenColor); } else if (vc instanceof VisualImplicitPlaceArc) { VisualImplicitPlaceArc vipa = (VisualImplicitPlaceArc) vc; vipa.setTokenColor(tokenColor); } } } } }