There are 4 code examples for org.eclipse.swt.widgets.Canvas.
The API names are highlighted below.
You can use
button
to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.
Project Name: CodeAnalyzer Package: de.fzi.cloneanalyzer.annotation
Source Code: CloneAnnotation.java (Click to view .java file)
Method Code:
/**
* actually draws the lines on the screen
* is called by eclipse framework if repaint was determined
* after we have registered this CloneAnnotation
*/
public void paint(GC gc,Canvas canvas,Rectangle bounds){
try {
Color yellowColor=new Color(canvas.getDisplay(),255,255,0);
Color redColor=new Color(canvas.getDisplay(),255,0,0);
Color blueColor=new Color(canvas.getDisplay(),0,0,255);
if (ci == CloneAnalyzerPlugin.getDefault().getSelectedCloneInstance()) gc.setForeground(redColor);
else if (ci == CloneAnalyzerPlugin.getDefault().getCompareCloneInstance()) {
gc.setForeground(blueColor);
}
else {
gc.setForeground(yellowColor);
}
if (ci.isVisible()) {
int x=calculateX(bounds.x,ci.getAnnotationPosition());
gc.setLineWidth(LINE_WIDTH);
gc.drawLine(x,bounds.y + LINE_SPACER_H,x,bounds.y + bounds.height - LINE_SPACER_H);
}
}
catch ( Exception e) {
e.printStackTrace();
}
}
Project Name: CodeAnalyzer Package: de.fzi.cloneanalyzer.annotation
Source Code: CloneAnnotationAccessExt.java (Click to view .java file)
Method Code:
public void paint(Annotation annotation,GC gc,Canvas canvas,Rectangle bounds){
if (annotation instanceof CloneAnnotation) {
((CloneAnnotation)annotation).paint(gc,canvas,bounds);
}
}
Project Name: OpenII Package: org.mitre.openii.editors.unity
Source Code: Workspace.java (Click to view .java file)
Method Code:
public void removeFromWorkspace(int index){
workspaceTable.remove(index - 1);
Control[] buttons=buttonsD.getChildren();
buttons[buttons.length - 1].dispose();
if (buttons.length == 2) {
stackLayout.topControl=tempLabel;
}
workspace.getParent().layout();
unityCanvas.getTableView().resetTableView();
}
Project Name: codecover Package: org.codecover.eclipse.views.controls
Source Code: GridObject.java (Click to view .java file)
Method Code:
private Image createMouseOverImage(GC gc,Canvas canvas){
Image image=new Image(canvas.getDisplay(),canvas.getSize().x,canvas.getSize().y);
GC imageGC=new GC(image);
imageGC.setBackground(gc.getBackground());
imageGC.setForeground(gc.getForeground());
imageGC.setFont(gc.getFont());
Rectangle imageSize=image.getBounds();
final Color transparentColor=canvas.getDisplay().getSystemColor(SWT.COLOR_GRAY);
final Color mouseOverBorderColor=canvas.getDisplay().getSystemColor(SWT.COLOR_WHITE);
imageGC.setBackground(transparentColor);
imageGC.fillRectangle(imageSize);
imageGC.setBackground(mouseOverBorderColor);
imageGC.fillRectangle(0,0,imageSize.width,2);
imageGC.fillRectangle(0,0,2,imageSize.height);
imageGC.fillRectangle(0,imageSize.height - 2,imageSize.width,2);
imageGC.fillRectangle(imageSize.width - 2,0,2,imageSize.height);
imageGC.dispose();
ImageData imageData=image.getImageData();
imageData.transparentPixel=imageData.palette.getPixel(transparentColor.getRGB());
return new Image(canvas.getDisplay(),imageData);
}