本文整理汇总了Java中org.eclipse.swt.graphics.GC.fillRectangle方法的典型用法代码示例。如果您正苦于以下问题:Java GC.fillRectangle方法的具体用法?Java GC.fillRectangle怎么用?Java GC.fillRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.GC
的用法示例。
在下文中一共展示了GC.fillRectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawButtonDeepDown
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static void drawButtonDeepDown(GC gc, String text, int textAlign,
Image image, int imageAlign, int x, int y, int w, int h) {
Display display = Display.getCurrent();
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
gc.drawLine(x, y, x + w - 2, y);
gc.drawLine(x, y, x, y + h - 2);
gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
gc.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
gc.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gc.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);
gc.drawLine(x + w - 2, y + h - 2, x + w - 2, y + 1);
//
gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gc.fillRectangle(x + 2, y + 2, w - 4, 1);
gc.fillRectangle(x + 1, y + 2, 2, h - 4);
//
gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
drawTextImage(gc, text, textAlign, image, imageAlign, x + 2 + 1,
y + 2 + 1, w - 4, h - 3 - 1);
}
示例2: onPaint
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
protected void onPaint(PaintEvent event) {
Rectangle rect = getClientArea();
GC gc = event.gc;
doCalculations();
if (m_Model != null) {
drawBottomSpace(gc);
drawCells(gc, gc.getClipping(), 0, m_Model.getFixedColumnCount(),
0, m_Model.getFixedRowCount());
drawCells(gc, gc.getClipping(), m_LeftColumn, m_Model
.getColumnCount(), 0, m_Model.getFixedRowCount());
drawCells(gc, gc.getClipping(), 0, m_Model.getFixedColumnCount(),
m_TopRow, m_TopRow + m_RowsVisible);
drawCells(gc, gc.getClipping(), m_LeftColumn, m_Model
.getColumnCount(), m_TopRow, m_TopRow + m_RowsVisible);
} else {
gc.fillRectangle(rect);
}
}
示例3: paintElement
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
void paintElement(PaintEvent e) {
GC g = e.gc;
g.setBackground(this.getBackground());
int width = this.getBounds().width;
int height = this.getBounds().height;
// clear entire canvas where button will be painted
g.fillRectangle(0, 0, width, height);
// draw text
g.setForeground(this.meColorForeground);
FontData fd = new FontData();
fd.setHeight(8);
if(textIsBold){
fd.setStyle(SWT.BOLD);
}else{
fd.setStyle(SWT.NORMAL);
}
g.setFont(new Font(this.getDisplay(), fd));
Point textPt = g.textExtent(this.meLabel);
g.drawText(this.meLabel, (width-textPt.x)/2, (height-textPt.y)/2);
}
示例4: paintElement
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
void paintElement(PaintEvent e) {
GC g = e.gc;
g.setBackground(this.getBackground());
int width = this.getBounds().width;
int height = this.getBounds().height;
// clear entire canvas where button will be painted
g.fillRectangle(0, 0, width, height);
if(showImage && meIcon != null){
Rectangle b = meIcon.getBounds();
int imageX = Math.max((width-b.width)/2, 1);
int imageY = Math.max((height-b.height)/2, 1);
g.drawImage(meIcon, imageX, imageY);
}
}
示例5: getMissingImage
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
* @return the small {@link Image} that can be used as placeholder for missing image.
*/
private static Image getMissingImage() {
Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
//
GC gc = new GC(image);
gc.setBackground(getColor(SWT.COLOR_RED));
gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
gc.dispose();
//
return image;
}
示例6: paintControl
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
* Handle paint events.
*/
public void paintControl(PaintEvent event) {
GC gc = event.gc;
gc.drawImage (image, 0, 0);
Rectangle rect = image.getBounds ();
Rectangle client = getClientArea();
int marginWidth = client.width - rect.width;
if (marginWidth > 0) {
gc.fillRectangle (rect.width, 0, marginWidth, client.height);
}
int marginHeight = client.height - rect.height;
if (marginHeight > 0) {
gc.fillRectangle (0, rect.height, client.width, marginHeight);
}
}
示例7: drawBox
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
* Draw a box on the screen. The shadowed box is only drawn if there is
* enough space within the box; otherwise, the box is just filled in with
* the fill color. Additionally, drawBox ensures that a square is drawn.
*/
protected void drawBox(Rectangle box, GC gc, Color fill, Color outline, Color shadow) {
if (box.width >= 10 && box.height >= 10) {
// square the rectangle shape:
int size = Math.min(box.height, box.width);
box.height = size + ((box.height - size) / 2);
box.width = size + ((box.width - size) / 2);
// offset internal box:
box.x+= 2;
box.y+= 2;
box.width-= 5;
box.height-= 5;
// draw!
gc.setBackground(shadow);
gc.fillRectangle(box);
box.x-= 2;
box.y-= 2;
gc.setBackground(fill);
gc.fillRectangle(box);
gc.setForeground(outline);
gc.drawRectangle(box);
} else {
// just fill:
gc.setBackground(fill);
gc.fillRectangle(box);
}
}
示例8: makePreview
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static Image makePreview ( final Display display, final LineAttributes lineAttributes, final Color lineColor, final Point p )
{
final Image img = new Image ( display, p.x, p.y );
final GC gc = new GC ( img );
try
{
gc.setForeground ( img.getDevice ().getSystemColor ( SWT.COLOR_WHITE ) );
gc.setBackground ( img.getDevice ().getSystemColor ( SWT.COLOR_WHITE ) );
gc.fillRectangle ( 0, 0, p.x, p.y );
gc.setLineAttributes ( lineAttributes );
if ( lineColor != null )
{
gc.setForeground ( lineColor );
}
gc.drawLine ( 0, p.y / 2, p.x, p.y / 2 );
}
finally
{
gc.dispose ();
}
return img;
}
示例9: drawTransparentImage
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static void drawTransparentImage(GC gc, Image image, int x, int y) {
if (image == null)
return;
Point imageSize = new Point(image.getBounds().width,
image.getBounds().height);
Image img = new Image(Display.getCurrent(), imageSize.x, imageSize.y);
GC gc2 = new GC(img);
gc2.setBackground(gc.getBackground());
gc2.fillRectangle(0, 0, imageSize.x, imageSize.y);
gc2.drawImage(image, 0, 0);
gc.drawImage(img, x, y);
gc2.dispose();
img.dispose();
}
示例10: drawImageVerticalAlign
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static void drawImageVerticalAlign(GC gc, Image image,
int imageAlign, int x, int y, int h) {
if (image == null)
return;
Point imageSize = new Point(image.getBounds().width,
image.getBounds().height);
//
if ((imageAlign & ALIGN_VERTICAL_MASK) == ALIGN_VERTICAL_TOP) {
drawTransparentImage(gc, image, x, y);
gc.fillRectangle(x, y + imageSize.y, imageSize.x, h - imageSize.y);
return;
}
if ((imageAlign & ALIGN_VERTICAL_MASK) == ALIGN_VERTICAL_BOTTOM) {
drawTransparentImage(gc, image, x, y + h - imageSize.y);
gc.fillRectangle(x, y, imageSize.x, h - imageSize.y);
return;
}
if ((imageAlign & ALIGN_VERTICAL_MASK) == ALIGN_VERTICAL_CENTER) {
int yOffset = (h - imageSize.y) / 2;
drawTransparentImage(gc, image, x, y + yOffset);
gc.fillRectangle(x, y, imageSize.x, yOffset);
gc.fillRectangle(x, y + yOffset + imageSize.y, imageSize.x, h
- (yOffset + imageSize.y));
return;
}
throw new SWTException(
"H: "
+ (imageAlign & ALIGN_VERTICAL_MASK));
}
示例11: drawButtonUp
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static void drawButtonUp(GC gc, String text, int textAlign,
Image image, int imageAlign, int x, int y, int w, int h,
Color face, Color shadowHigh, Color shadowNormal, Color shadowDark,
int leftMargin, int topMargin) {
Color prevForeground = gc.getForeground();
Color prevBackground = gc.getBackground();
try {
gc.setBackground(face);
gc.setForeground(shadowHigh);
gc.drawLine(x, y, x, y + h - 1);
gc.drawLine(x, y, x + w - 2, y);
gc.setForeground(shadowDark);
gc.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
gc.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
gc.setForeground(shadowNormal);
gc.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);
gc.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);
//
gc.fillRectangle(x + 1, y + 1, leftMargin, h - 3);
gc.fillRectangle(x + 1, y + 1, w - 3, topMargin);
gc.setForeground(prevForeground);
drawTextImage(gc, text, textAlign, image, imageAlign, x + 1
+ leftMargin, y + 1 + topMargin, w - 3 - leftMargin, h - 3
- topMargin);
} finally {
gc.setForeground(prevForeground);
gc.setBackground(prevBackground);
}
}
示例12: changeImageBackgroundColor
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
* Change the background color of an image and draw a rectangle on it that
* has the same bounds as the image. This effectively turns the image into
* the color supplied with the RGB.
* @param image The image to be painted.
* @param rgb The desired RGB for the image.
*/
protected void changeImageBackgroundColor(Image image, RGB rgb) {
Display display = this.shell.getDisplay();
GC gc = new GC(image);
gc.setBackground(new Color(display, rgb));
gc.fillRectangle(this.fileInspConstantClassImage.getBounds());
gc.dispose();
}
示例13: drawFlatButtonUp
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static void drawFlatButtonUp(GC gc, String text, int textAlign,
Image image, int imageAlign, int x, int y, int w, int h,
Color face, Color shadowLight, Color shadowNormal, int leftMargin,
int topMargin) {
Color prevForeground = gc.getForeground();
Color prevBackground = gc.getBackground();
try {
gc.setForeground(shadowLight);
gc.drawLine(x, y, x + w - 1, y);
gc.drawLine(x, y, x, y + h);
gc.setForeground(shadowNormal);
gc.drawLine(x + w, y, x + w, y + h);
gc.drawLine(x + 1, y + h, x + w, y + h);
//
gc.setBackground(face);
gc.fillRectangle(x + 1, y + 1, leftMargin, h - 1);
gc.fillRectangle(x + 1, y + 1, w - 1, topMargin);
//
gc.setBackground(face);
gc.setForeground(prevForeground);
drawTextImage(gc, text, textAlign, image, imageAlign, x + 1
+ leftMargin, y + 1 + topMargin, w - 1 - leftMargin, h - 1
- topMargin);
} finally {
gc.setForeground(prevForeground);
gc.setBackground(prevBackground);
}
}
示例14: draw
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private void draw(GC gc,float x,float y,float h,DHTControlContact contact,int distance,float error) {
if(x == 0 && y == 0) return;
if(error > 1) error = 1;
int errDisplay = (int) (100 * error);
int x0 = scale.getX(x,y);
int y0 = scale.getY(x,y);
Image img = ImageRepository.getCountryFlag( contact.getTransportContact().getTransportAddress().getAddress(), true );
if ( img != null ){
Rectangle bounds = img.getBounds();
int old = gc.getAlpha();
gc.setAlpha( 150 );
gc.drawImage( img, x0-bounds.width/2, y0-bounds.height);
gc.setAlpha( old );
}
gc.fillRectangle(x0-1,y0-1,3,3);
//int elevation =(int) ( 200*h/(scale.maxY-scale.minY));
//gc.drawLine(x0,y0,x0,y0-elevation);
//String text = /*contact.getTransportContact().getAddress().getAddress().getHostAddress() + " (" + */distance + " ms \nerr:"+errDisplay+"%";
String text = /*contact.getTransportContact().getAddress().getAddress().getHostAddress() + " (" + */distance + " ms "+errDisplay+"%";
int lineReturn = text.indexOf("\n");
int xOffset = gc.getFontMetrics().getAverageCharWidth() * (lineReturn != -1 ? lineReturn:text.length()) / 2;
gc.drawText(text,x0-xOffset,y0,true);
currentPositions.add( new Object[]{ x0, y0, h, contact, x, y, distance });
}
示例15: getMissingImage
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private static Image getMissingImage() {
Image image = new Image(Display.getCurrent(), IMAGE_SIZE, IMAGE_SIZE);
GC gc = new GC(image);
gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
gc.fillRectangle(0, 0, IMAGE_SIZE, IMAGE_SIZE);
gc.dispose();
return image;
}