本文整理汇总了Java中org.eclipse.swt.graphics.GC.setLineWidth方法的典型用法代码示例。如果您正苦于以下问题:Java GC.setLineWidth方法的具体用法?Java GC.setLineWidth怎么用?Java GC.setLineWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.GC
的用法示例。
在下文中一共展示了GC.setLineWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawRow
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private void drawRow ( final Device device, final GC gc, final String label, final List<Double> data, final Rectangle bounds, final double minX, final double maxX )
{
final Rectangle deviceBounds = device.getBounds ();
gc.setLineWidth ( 1 );
final int size = data.size ();
final double diff = maxX - minX;
Point lastPoint = null;
for ( int i = 0; i < size; i++ )
{
// final Value v = data[i];
final ValueInformation info = this.valueInformation.get ( i );
if ( info.getQuality () > 0.75 )
{
final double posX = (double)bounds.width / (double)size * i;
final double posY = data.get ( i ) / diff * bounds.height;
final Point point = new Point ( (int)posX + bounds.x, (int)posY + bounds.y );
if ( lastPoint != null )
{
gc.drawLine ( lastPoint.x, deviceBounds.height - lastPoint.y, point.x, deviceBounds.height - lastPoint.y );
gc.drawLine ( point.x, deviceBounds.height - lastPoint.y, point.x, deviceBounds.height - point.y );
}
lastPoint = point;
}
else
{
lastPoint = null;
}
}
}
示例2: saveEditorContentsAsImage
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private static void saveEditorContentsAsImage(IEditorPart editorPart, GraphicalViewer viewer, String saveFilePath, int format) {
ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer.getEditPartRegistry().get(LayerManager.ID);
IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);// rootEditPart.getFigure();
Rectangle rootFigureBounds = rootFigure.getBounds();
Control figureCanvas = viewer.getControl();
GC figureCanvasGC = new GC(figureCanvas);
Image img = new Image(null, rootFigureBounds.width, rootFigureBounds.height);
GC imageGC = new GC(img);
imageGC.setBackground(figureCanvasGC.getBackground());
imageGC.setForeground(figureCanvasGC.getForeground());
imageGC.setFont(figureCanvasGC.getFont());
imageGC.setLineStyle(figureCanvasGC.getLineStyle());
imageGC.setLineWidth(figureCanvasGC.getLineWidth());
imageGC.setXORMode(figureCanvasGC.getXORMode());
Graphics imgGraphics = new SWTGraphics(imageGC);
rootFigure.paint(imgGraphics);
ImageData[] imgData = new ImageData[1];
imgData[0] = img.getImageData();
ImageLoader imgLoader = new ImageLoader();
imgLoader.data = imgData;
imgLoader.save(saveFilePath, format);
figureCanvasGC.dispose();
imageGC.dispose();
img.dispose();
}
示例3: paintElement
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
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 button background
int selShift = 0;
if(mouseIsOver && !isSelected){
g.setBackground(this.meColorMouseOver);
}else{
g.setBackground(this.meColorUnselected);
}
if(isSelected){
selShift = MEB_SIDE_SPACE-1;
g.setBackground(this.meColorSelected);
}
g.fillRoundRectangle(-MEB_ARC_RADIUS,0,width-MEB_SIDE_SPACE+selShift+MEB_ARC_RADIUS, height-1, MEB_ARC_RADIUS, MEB_ARC_RADIUS);
// draw button outline
g.setLineWidth(1);
if(mouseIsOver){ // || isFocused, but not currently used
g.setForeground(this.meColorFocused);
}else{
g.setForeground(this.meColorOutline2);
}
g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1), height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1)-1, height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1)-2, height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
g.setForeground(this.meColorOutline);
g.setLineWidth(1);
g.drawRoundRectangle(-MEB_ARC_RADIUS,0,width-MEB_SIDE_SPACE+selShift+MEB_ARC_RADIUS, height-1, MEB_ARC_RADIUS, MEB_ARC_RADIUS);
//
// handle position of Text/Icon within MEButton
//
int usableHeight = height-4;
// draw button text
g.setForeground(this.meColorForeground);
FontData fd = new FontData();
fd.setHeight(8);
g.setFont(new Font(this.getDisplay(), fd));
Point textPt = g.textExtent(this.meLabel);
switch(this.meDispOptions){
case(MenuetElement.ME_ICON_ONLY): {
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-this.meIcon.getBounds().height)/2);
break;
}
case(MenuetElement.ME_TEXT_ONLY): {
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
break;
}
case(MenuetElement.ME_TRY_ICON): {
if(usableHeight >= (textPt.y+this.meIcon.getBounds().height+1)){
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2);
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2 + this.meIcon.getBounds().height+1);
}else{
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
}
break;
}
case(MenuetElement.ME_TRY_TEXT): {
if(usableHeight >= (textPt.y+this.meIcon.getBounds().height+1)){
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2);
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2 + this.meIcon.getBounds().height+1);
}else{
g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-this.meIcon.getBounds().height)/2);
}
break;
}
default:{
g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
break;
}
}
}