本文整理汇总了Java中org.eclipse.swt.graphics.GC.setClipping方法的典型用法代码示例。如果您正苦于以下问题:Java GC.setClipping方法的具体用法?Java GC.setClipping怎么用?Java GC.setClipping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.GC
的用法示例。
在下文中一共展示了GC.setClipping方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
*
*/
@Override
public void render(XCalendarFrame frame) {
// Background
final GC gc = frame.getGc();
final XCalendarModel model = popup.getModel();
final XCalendarTheme theme = model.getTheme();
final XVirtualCalendar calendar = model.getCalendar();
final ZonedDateTime d1 = calendar.getCalendarDateTime();
final ZonedDateTime d2 = query(calendar, model.getZoneId(), col, row);
boolean hovered = this.mouse.isEntered();
boolean same1 = isSameDate(d2, now(model.getZoneId()));
this.enabled = isValidDate(toDate(d2), calendar::isValid);
boolean selected = model.getDate() != null && isSameDate(d1, d2);
int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
gc.setBackground(theme.getBackground(enabled, selected, same1, hovered));
gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc());
// Foreground
String text = Strings.toString(d2.getDayOfMonth());
boolean same2 = isSameYearMonth(d2, calendar.getTravelDateTime());
gc.setForeground(theme.getForeground(this.enabled, selected, same2));
gc.setFont(model.getTheme().getFont()); final Point size = extent(gc, text);
gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1));
if(!same1) return; int c = w / 7;
gc.setClipping(x + c, y + c, w - 2 * c, h - 2 * c);
gc.setBackground(theme.getForeground(true, selected, false));
gc.fillPolygon(new int[] { x + w * 3 / 5, y + h, x + w, y + h, x + w, y + h * 3 / 5 });
gc.setClipping((Rectangle) null);
}
示例2: drawPie
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static void
drawPie(
GC gc,Image image, int x, int y,int width,int height,int percent, boolean draw_border )
{
Rectangle image_size = image.getBounds();
int width_pad = ( width - image_size.width )/2;
int height_pad = ( height - image_size.height )/2;
int angle = (percent * 360) / 100;
if(angle<4){
angle = 0; // workaround fillArc rendering bug
}
Region old_clipping = new Region();
gc.getClipping(old_clipping);
Path path_done = new Path(gc.getDevice());
path_done.addArc(x,y,width,height,90,-angle);
path_done.lineTo( x+width/2, y+height/2);
path_done.close();
gc.setClipping( path_done );
gc.drawImage(image, x+width_pad, y+height_pad+1);
Path path_undone = new Path(gc.getDevice());
path_undone.addArc(x,y,width,height,90-angle,angle-360);
path_undone.lineTo( x+width/2, y+height/2);
path_undone.close();
gc.setClipping( path_undone );
gc.setAlpha( 75 );
gc.drawImage(image, x+width_pad, y+height_pad+1);
gc.setAlpha( 255 );
gc.setClipping( old_clipping );
if ( draw_border ){
gc.setForeground(Colors.blue);
if ( percent == 100 ){
gc.drawOval(x , y , width-1, height-1);
}else{
if ( angle > 0 ){
gc.drawPath( path_done );
}
}
}
path_done.dispose();
path_undone.dispose();
old_clipping.dispose();
}