本文整理匯總了Java中org.eclipse.swt.events.PaintListener類的典型用法代碼示例。如果您正苦於以下問題:Java PaintListener類的具體用法?Java PaintListener怎麽用?Java PaintListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PaintListener類屬於org.eclipse.swt.events包,在下文中一共展示了PaintListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: SWTStrokeCanvas
import org.eclipse.swt.events.PaintListener; //導入依賴的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);
}
}
});
}
示例2: main
import org.eclipse.swt.events.PaintListener; //導入依賴的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();
}
}
}
示例3: SWTBenchTest
import org.eclipse.swt.events.PaintListener; //導入依賴的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()));
}
});
}
示例4: CustomSeparator
import org.eclipse.swt.events.PaintListener; //導入依賴的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);
}
});
}
示例5: init
import org.eclipse.swt.events.PaintListener; //導入依賴的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();
}
}
示例6: init
import org.eclipse.swt.events.PaintListener; //導入依賴的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);
}
示例7: createContents
import org.eclipse.swt.events.PaintListener; //導入依賴的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);
}
});
}
示例8: RotatedLabel
import org.eclipse.swt.events.PaintListener; //導入依賴的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();
}
});
}
示例9: createPartControl
import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
public void createPartControl(Composite parent) {
setTitleImage(Images.TYPE_ACTSPEED);
canvas = new Canvas(parent, SWT.DOUBLE_BUFFERED);
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
try {
area = canvas.getClientArea();
drawCanvasImage(e.gc);
} catch (Throwable t) {
t.printStackTrace();
}
}
});
window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
}
示例10: createUI_20_PageShellImage
import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
private Composite createUI_20_PageShellImage(final Composite parent) {
final Canvas resizeCanvas = new Canvas(//
parent,
// SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE//
SWT.NONE //
);
resizeCanvas.setLayout(new FillLayout());
// resizeCanvas.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_CYAN));
resizeCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(final PaintEvent e) {
onPaintShellImage(e);
}
});
return resizeCanvas;
}
示例11: CanvasImpl
import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
public CanvasImpl(
final IGenericWidgetFactory factory,
final Object parentUiReference,
final ICanvasSetupSpi setup,
final SwtImageRegistry imageRegistry) {
super(factory, new Canvas((Composite) parentUiReference, getStyle(setup)), imageRegistry);
getUiReference().setBackgroundMode(SWT.INHERIT_DEFAULT);
this.paintObservable = new PaintObservable();
getUiReference().addPaintListener(new PaintListener() {
@Override
public void paintControl(final PaintEvent e) {
final Dimension size = getSize();
final Rectangle bounds = new Rectangle(0, 0, size.getWidth(), size.getHeight());
final Rectangle clipBounds = new Rectangle(e.x, e.y, e.width, e.height);
final GraphicContextSpiImpl graphicContext = new GraphicContextSpiImpl(e.gc, bounds, imageRegistry);
paintObservable.firePaint(new PaintEventSpiImpl(graphicContext, clipBounds));
}
});
}
示例12: SpinnerProgress
import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
/**
* Constructor
*
* @param parent Parent
* @param style Style flags
*/
public SpinnerProgress(Composite parent, int style) {
super(parent, style);
// Add paint listener
addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
onPaint(e);
}
});
// Set font
setFont(parent.getFont());
// Create spoke colors
createColors(getDisplay());
// Compute spoke angles
computeSpokeAngles();
}
示例13: AnimateControl
import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
/**
* Constructor
*
* @param parent Parent
* @param image Image to display
*/
public AnimateControl(Composite parent, int style, Image[] images) {
super(parent, style);
// Image attributes
this.images = images;
imageWidth = images[0].getImageData().width;
imageHeight = images[0].getImageData().height;
// Add paint listener
addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
onPaint(e);
}
});
}
示例14: highlight
import org.eclipse.swt.events.PaintListener; //導入依賴的package包/類
protected void highlight(final Composite parent, final Label labelControl, final Combo comboBox, final int color) {
Object data= labelControl.getData();
if (data == null) {
if (color != HIGHLIGHT_NONE) {
PaintListener painter= new HighlightPainter(parent, labelControl, comboBox, color);
parent.addPaintListener(painter);
labelControl.setData(painter);
} else {
return;
}
} else {
if (color == HIGHLIGHT_NONE) {
parent.removePaintListener((PaintListener) data);
labelControl.setData(null);
} else if (color != ((HighlightPainter) data).fColor){
((HighlightPainter) data).fColor= color;
} else {
return;
}
}
parent.redraw();
}
示例15: main
import org.eclipse.swt.events.PaintListener; //導入依賴的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() {
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();
}
}
}