Java Reference
In-Depth Information
directly support it. Don't let that graphical definition model Gradient Facet ele-
ment fool you—it is not yet implemented. Worse, this property is not available
to the figure code-generation templates even if we did try to use it. So we're left
to find our own way to implement gradients in our archetypes, to give them a
fresh appearance.
The fillShape() method of our archetype figure gives us the place to add
a gradient. Simply overriding this method and adding a call to fillGradient()
does the trick, except that gradients in GEF do not respect the corners of a
RoundedRectangle figure. This effectively reduces our rounded rectangles to
regular rectangles, though with gradient. Instead of spending time figuring how
to implement gradients for rounded rectangles, we can be creative and adjust the
starting point of the gradient to between the archetype name and the stereotype
label. (Recall the hint earlier regarding the placement of these labels?) Not only
does this give us a striking visual appearance, but it also has the effect of nearly
eliminating the problems GEF in respect to the corners: The top no longer has
gradient applied, and it's faded enough by the bottom to make it hardly notice-
able that it extends beyond the curve. Figure 4-44 is an example of the gradient,
although the archetype does not yet define our foreground color. This illustrates
the reason for the stereotype labels, however. Black-and-white print of our color
diagrams makes it difficult to distinguish the archetypes otherwise. Additionally,
the stereotypes let us distinguish between archetypes of the same color, such as
Party, Place, and Thing, which are all green.
ARole
AMomentInterval
IAdapt
APackage
«role»
«moment-interval»
«plugin-point»
«package»
Figure 4-44
Color archetypes
This is the code modification required to create the effect:
protected void fillShape(Graphics graphics) {
graphics.fillGradient(bounds.x, bounds.y + 24,
bounds.width, bounds.height, true );
}
 
Search WWH ::




Custom Search