本文整理匯總了Java中org.eclipse.swt.events.PaintEvent類的典型用法代碼示例。如果您正苦於以下問題:Java PaintEvent類的具體用法?Java PaintEvent怎麽用?Java PaintEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PaintEvent類屬於org.eclipse.swt.events包,在下文中一共展示了PaintEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPaint
import org.eclipse.swt.events.PaintEvent; //導入依賴的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);
}
}
示例2: paintElement
import org.eclipse.swt.events.PaintEvent; //導入依賴的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);
}
示例3: paintElement
import org.eclipse.swt.events.PaintEvent; //導入依賴的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);
}
}
示例4: paintVerticalRuler
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
/**
* Handle paint requests for vertical ruler.
*/
protected void paintVerticalRuler(PaintEvent event) {
// FIXME - not i18n safe!!
String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$
if (disk.getBitmapLabels().length == 2) {
label = (disk.getBitmapLabels()[1] + "s").toUpperCase(); //$NON-NLS-1$
}
StringBuffer buf = new StringBuffer();
for (int i=0; i<label.length(); i++) {
if (i>0) buf.append("\n"); //$NON-NLS-1$
buf.append(label.charAt(i));
}
label = buf.toString();
Canvas canvas = (Canvas) event.widget;
Rectangle area = canvas.getClientArea();
event.gc.drawLine(area.x + area.width/2, area.y, area.x + area.width/2, area.y + area.height);
Point size = event.gc.textExtent(label);
event.gc.drawText(label, area.x + area.width/2 - size.x/2, area.y + area.height/2 - size.y/2);
}
示例5: paintBlockMap
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
/**
* Paint a block map.
*/
private void paintBlockMap(PaintEvent event) {
Canvas canvas = (Canvas) event.widget;
Rectangle area = canvas.getClientArea();
double blocks = disk.getBitmapLength();
double width = area.width;
double height = area.height;
double factor = Math.sqrt(blocks / (width * height));
int xdim = (int) (width * factor + 0.5);
int ydim = (int) (height * factor + 0.5);
if (xdim * ydim < blocks) {
xdim++;
}
if (xdim * ydim < blocks) {
ydim++;
}
paintDiskMap(xdim, ydim, event);
}
示例6: SWTStrokeCanvas
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
/**
* Creates a new instance.
*
* @param parent the parent.
* @param style the style.
*/
public SWTStrokeCanvas(Composite parent, int style) {
super(parent, style);
addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
BasicStroke stroke = (BasicStroke) getStroke();
if (stroke != null) {
int x, y;
Rectangle rect = getClientArea();
x = (rect.width - 100) / 2;
y = (rect.height - 16) / 2;
Transform swtTransform = new Transform(e.gc.getDevice());
e.gc.getTransform(swtTransform);
swtTransform.translate(x, y);
e.gc.setTransform(swtTransform);
swtTransform.dispose();
e.gc.setBackground(getDisplay().getSystemColor(
SWT.COLOR_BLACK));
e.gc.setLineWidth((int) stroke.getLineWidth());
e.gc.drawLine(10, 8, 90, 8);
}
}
});
}
示例7: main
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell(display, SWT.DIALOG_TRIM);
shell.setLayout(new FillLayout());
Composite c = new Composite(shell, SWT.BORDER);
c.setLayout(new FillLayout());
c.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
e.gc.drawLine(0, 0, 100, 50);
}
});
Label lbl = new Label(c, SWT.NONE);
lbl.setText("text");
shell.open();
while (!shell.isDisposed()) {
if (display.readAndDispatch()) {
display.sleep();
}
}
}
示例8: SWTBenchTest
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
/**
* Create a new Piccolo2D SWT benchmarking test suite with the specified parent and style.
*
* @param parent parent
* @param style style
*/
private SWTBenchTest(final Composite parent, final int style) {
super(parent, style);
testImageOpaque = loadImage(getDisplay(), "opaque.jpg");
testImageBitmask = loadImage(getDisplay(), "bitmask.gif");
testImageTranslucent = loadImage(getDisplay(), "translucent.png");
testImageARGB = new Image(getDisplay(), 128, 128);
final GC tmpGC = new GC(testImageARGB);
tmpGC.drawImage(testImageTranslucent, 0, 0);
tmpGC.dispose();
addPaintListener(new PaintListener() {
public void paintControl(final PaintEvent pe) {
runAll(new SWTGraphics2D(pe.gc, getDisplay()));
}
});
}
示例9: paintControl
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
@Override
public void paintControl(final PaintEvent e) {
/*
* We get a paint event when the shell containing this control loses
* or gains focus. Unfortunately, we are not guaranteed to paint our
* entire control, so we force a redraw to guarantee a full
* painting.
*/
if (hasPainted && shellFocusChanged()) {
redraw();
return;
}
final Image buttonImage = getImage();
if (buttonImage != null && !e.gc.isDisposed()) {
e.gc.drawImage(buttonImage, 0, 0);
}
hasPainted = true;
}
示例10: CustomSeparator
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
public CustomSeparator( Composite parent, int style) {
super(parent, style = checkStyle(style));
this.style = style;
if ((style & SWT.SHADOW_IN) != 0 || (style & SWT.SHADOW_OUT) != 0)
lineSize = 2;
else
lineSize = 1;
addPaintListener(new PaintListener() {
public void paintControl( PaintEvent event){
onPaint(event);
}
});
}
示例11: init
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
public void init() {
if(TuxGuitar.getInstance().getConfig().getBooleanValue(TGConfigKeys.SHOW_SPLASH)){
final Image image = TuxGuitar.getInstance().getIconManager().getAppSplash();
this.shell = new Shell(TuxGuitar.getInstance().getDisplay(), SWT.NO_TRIM | SWT.NO_BACKGROUND);
this.shell.setLayout(new FillLayout());
this.shell.setBounds(getBounds(image));
this.shell.setImage(TuxGuitar.getInstance().getIconManager().getAppIcon());
this.shell.setText(TuxGuitar.APPLICATION_NAME);
this.shell.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
TGPainter painter = new TGPainterImpl(e.gc);
painter.drawImage(new TGImageImpl(image), 0, 0);
}
});
this.shell.open();
this.shell.redraw();
this.shell.update();
}
}
示例12: init
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
public void init() {
this.setLayout(new GridLayout(1,true));
this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
((GridData)this.getLayoutData()).widthHint = 600;
this.composite = new Composite(this,SWT.BORDER | SWT.DOUBLE_BUFFERED);
this.composite.setBackground(this.getDisplay().getSystemColor(SWT.COLOR_WHITE));
this.composite.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
TGPainterImpl painter = new TGPainterImpl(e.gc);
TGTunerRoughWidget.this.paintWidget(painter);
}
});
GridData data = new GridData(SWT.FILL,SWT.FILL,true,true);
data.minimumHeight = MIN_HEIGHT;
data.grabExcessHorizontalSpace = true;
this.composite.setLayoutData(data);
}
示例13: createContents
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
/**
* Create contents of the shell.
*/
protected void createContents() {
setText("SWT Application");
setSize(673, 173);
windowLocation.showWindowOnScreenCenter(this);
addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
// TODO Auto-generated method stub
e.gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
e.gc.drawString(infotext, 20, getSize().y-20,true);
}
});
}
示例14: RotatedLabel
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
public RotatedLabel(Composite parent, int style) {
super(parent, style);
this.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
paint(e);
}
});
this.addListener(SWT.MouseDown, new Listener() {
@Override
public void handleEvent(Event event) {
if (switchListener != null && !isDefinitionSectionExpanded)
switchListener.handleSelection();
}
});
}
示例15: drawResultText
import org.eclipse.swt.events.PaintEvent; //導入依賴的package包/類
/**
* Draws the result text centered in the specified component.
*
* @param e
* The paint event to draw in.
* @param text
* The text to draw.
*/
protected void drawResultText(PaintEvent e, String text) {
if (text != null) {
e.gc.setForeground(Raptor.getInstance().getPreferences().getColor(
PreferenceKeys.RESULTS_COLOR));
e.gc.setFont(getResultFont(e.height));
Point extent = e.gc.stringExtent(text);
if (frame != -1) {
e.gc.setAdvanced(true);
e.gc.setAlpha((int)(255.0/ANIMATION_STAGES * frame));
e.gc.drawString(text, e.width / 2 - extent.x / 2, e.height / 2
- extent.y / 2, true);
e.gc.setAlpha(255);
} else {
e.gc.drawString(text, e.width / 2 - extent.x / 2, e.height / 2
- extent.y / 2, true);
}
}
}