Java Reference
In-Depth Information
/**
* @generated
*/
public void setUseGradient(boolean useGradient) {
this.useGradient = useGradient;
}
/**
* @generated
*/
public boolean getUseGradient() {
return useGradient;
}
/**
* @generated
*/
protected void fillShape(org.eclipse.draw2d.Graphics graphics) {
if (useGradient) {
graphics.fillGradient(bounds.x, bounds.y + 24,
bounds.width, bounds.height, true);
}
}
« ENDDEFINE »
We can again transform our mapping model to the generator model, adding
our path to the figure template in the provisional GMFGraph Dynamic
Templates field, and regenerate our diagram code. Recall that figures are serial-
ized within the generator model by default, although we used the standalone fig-
ures method in the Scenario diagram that eliminates the need to regenerate all the
diagram code to see the change. Figure 4-44 shows the result, with the remain-
ing task of assigning the proper color for each archetype, based on its type. We
want to avoid hard-coding this into our figures, which we mentioned when cre-
ating the graphical definition model. Instead, let's see what is involved in adding
color preferences for each archetype that the Practitioner can change, if desired.
4.6.6 Color Preferences
Basing the color of an archetype on its type is straightforward enough, and you
can most easily accomplish this by overriding the setForegroundColor()
method in each Archetype EditPart class. Recall that the gradient effect goes
from our foreground to background color. For example, this simple implemen-
tation in our MomentIntervalEditPart class causes it to produce the desired
gradient effect:
Search WWH ::




Custom Search