论坛首页 Java企业应用论坛

gmf中用fillShape()加了阴影后,怎么把框置到内部!!

浏览 1934 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-10-31  
我在做Eclipse插件过程中,需要在已经有的UML类图中添加阴影效果,以显现立体效果。加了阴影效果后,graphic的图表框确还在外边。怎么把外边的框添加到阴影的里边去(不是阴影的外部)?我的UML效果图是:(见附件)
我的添加阴影的方法是:protected void fillShape(Graphics graphics)
         {
/** don't modify the r directly */
Rectangle r = getBounds();

Rectangle.SINGLETON.setBounds(r);
Rectangle.SINGLETON.y -= 1;
Rectangle.SINGLETON.width += 1;
Rectangle.SINGLETON.height += 1;

int shadowDepth = 10;
int rectangleWidth = r.width - shadowDepth;
int rectangleHeight = r.height -shadowDepth;

Color foreground = graphics.getForegroundColor();
Color background = graphics.getBackgroundColor(), shadow = ColorUtilities.darker(foreground);

int x = r.x + shadowDepth;
int y = r.y + shadowDepth;

/**
* trace shadow
*/
for (int i = shadowDepth - 1; i >= 0; i--)
{
shadow = lighter(background, i, shadowDepth);
graphics.setBackgroundColor(shadow);
graphics.fillRectangle(x, y, rectangleWidth, rectangleHeight);
if (i > 0)
{
x--;
if (fillBottom)
y--;
}
}
graphics.setBackgroundColor(background);
graphics.setForegroundColor(foreground);
graphics.fillRectangle(x, y, rectangleWidth, rectangleHeight);
}
  • 描述: 不显示outline但显示ComparterOutline的类图
  • 大小: 9.8 KB
  • 描述: 选中时的效果,显示了外边的NodeFigure
  • 大小: 143.7 KB
  • 描述: 显示选中第一个CompartMent的区域。
  • 大小: 194.2 KB
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics