fillpolygon java_Java GC.fillPolygon方法代碼示例

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);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值