本文整理汇总了Java中org.eclipse.swt.graphics.Path.close方法的典型用法代码示例。如果您正苦于以下问题:Java Path.close方法的具体用法?Java Path.close怎么用?Java Path.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.Path
的用法示例。
在下文中一共展示了Path.close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toSwtPath
import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
/**
* Converts an AWT <code>Shape</code> into a SWT <code>Path</code>.
*
* @param shape the shape.
*
* @return The path.
*/
private Path toSwtPath(Shape shape) {
int type;
float[] coords = new float[6];
Path path = new Path(this.gc.getDevice());
PathIterator pit = shape.getPathIterator(null);
while (!pit.isDone()) {
type = pit.currentSegment(coords);
switch (type) {
case (PathIterator.SEG_MOVETO):
path.moveTo(coords[0], coords[1]);
break;
case (PathIterator.SEG_LINETO):
path.lineTo(coords[0], coords[1]);
break;
case (PathIterator.SEG_QUADTO):
path.quadTo(coords[0], coords[1], coords[2], coords[3]);
break;
case (PathIterator.SEG_CUBICTO):
path.cubicTo(coords[0], coords[1], coords[2],
coords[3], coords[4], coords[5]);
break;
case (PathIterator.SEG_CLOSE):
path.close();
break;
default:
break;
}
pit.next();
}
return path;
}
示例2: toSwtPath
import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
/**
* Converts an AWT <code>Shape</code> into a SWT <code>Path</code>.
*
* @param shape the shape (<code>null</code> not permitted).
*
* @return The path.
*/
private Path toSwtPath(Shape shape) {
int type;
float[] coords = new float[6];
Path path = new Path(this.gc.getDevice());
PathIterator pit = shape.getPathIterator(null);
while (!pit.isDone()) {
type = pit.currentSegment(coords);
switch (type) {
case (PathIterator.SEG_MOVETO):
path.moveTo(coords[0], coords[1]);
break;
case (PathIterator.SEG_LINETO):
path.lineTo(coords[0], coords[1]);
break;
case (PathIterator.SEG_QUADTO):
path.quadTo(coords[0], coords[1], coords[2], coords[3]);
break;
case (PathIterator.SEG_CUBICTO):
path.cubicTo(coords[0], coords[1], coords[2],
coords[3], coords[4], coords[5]);
break;
case (PathIterator.SEG_CLOSE):
path.close();
break;
default:
break;
}
pit.next();
}
return path;
}
示例3: pathIterator2Path
import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
/**
* Converts a java 2d path iterator to a SWT path.
*
* @param iter specifies the iterator to be converted.
* @return the corresponding path object. Must be disposed() when no longer
* used.
*/
private Path pathIterator2Path(final PathIterator iter) {
final float[] coords = new float[6];
final Path path = new Path(device);
while (!iter.isDone()) {
final int type = iter.currentSegment(coords);
switch (type) {
case PathIterator.SEG_MOVETO:
path.moveTo(coords[0], coords[1]);
break;
case PathIterator.SEG_LINETO:
path.lineTo(coords[0], coords[1]);
break;
case PathIterator.SEG_CLOSE:
path.close();
break;
case PathIterator.SEG_QUADTO:
path.quadTo(coords[0], coords[1], coords[2], coords[3]);
break;
case PathIterator.SEG_CUBICTO:
path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
break;
default:
// log this?
}
iter.next();
}
return path;
}
示例4: createScaledPath
import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
/**
* Scales given path by zoom factor
*
* @param path
* Path to be scaled
* @return Scaled path
*/
private Path createScaledPath(Path path) {
PathData p = path.getPathData();
for (int i = 0; i < p.points.length; i += 2) {
p.points[i] = (float) (p.points[i] * zoom + fractionalX);
p.points[i + 1] = (float) (p.points[i + 1] * zoom + fractionalY);
}
Path scaledPath = new Path(path.getDevice());
int index = 0;
for (int i = 0; i < p.types.length; i++) {
byte type = p.types[i];
switch (type) {
case SWT.PATH_MOVE_TO:
scaledPath.moveTo(p.points[index], p.points[index + 1]);
index += 2;
break;
case SWT.PATH_LINE_TO:
scaledPath.lineTo(p.points[index], p.points[index + 1]);
index += 2;
break;
case SWT.PATH_CUBIC_TO:
scaledPath.cubicTo(p.points[index], p.points[index + 1],
p.points[index + 2], p.points[index + 3],
p.points[index + 4], p.points[index + 5]);
index += 6;
break;
case SWT.PATH_QUAD_TO:
scaledPath.quadTo(p.points[index], p.points[index + 1],
p.points[index + 2], p.points[index + 3]);
index += 4;
break;
case SWT.PATH_CLOSE:
scaledPath.close();
break;
}
}
return scaledPath;
}
示例5: drawPie
import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public static void
drawPie(
GC gc,Image image, int x, int y,int width,int height,int percent, boolean draw_border )
{
Rectangle image_size = image.getBounds();
int width_pad = ( width - image_size.width )/2;
int height_pad = ( height - image_size.height )/2;
int angle = (percent * 360) / 100;
if(angle<4){
angle = 0; // workaround fillArc rendering bug
}
Region old_clipping = new Region();
gc.getClipping(old_clipping);
Path path_done = new Path(gc.getDevice());
path_done.addArc(x,y,width,height,90,-angle);
path_done.lineTo( x+width/2, y+height/2);
path_done.close();
gc.setClipping( path_done );
gc.drawImage(image, x+width_pad, y+height_pad+1);
Path path_undone = new Path(gc.getDevice());
path_undone.addArc(x,y,width,height,90-angle,angle-360);
path_undone.lineTo( x+width/2, y+height/2);
path_undone.close();
gc.setClipping( path_undone );
gc.setAlpha( 75 );
gc.drawImage(image, x+width_pad, y+height_pad+1);
gc.setAlpha( 255 );
gc.setClipping( old_clipping );
if ( draw_border ){
gc.setForeground(Colors.blue);
if ( percent == 100 ){
gc.drawOval(x , y , width-1, height-1);
}else{
if ( angle > 0 ){
gc.drawPath( path_done );
}
}
}
path_done.dispose();
path_undone.dispose();
old_clipping.dispose();
}
示例6: drawPie
import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public static void
drawPie(
GC gc,Image image, int x, int y,int width,int height,int percent, boolean draw_border )
{
Rectangle image_size = image.getBounds();
int width_pad = ( width - image_size.width )/2;
int height_pad = ( height - image_size.height )/2;
int angle = (percent * 360) / 100;
if(angle<4){
angle = 0; // workaround fillArc rendering bug
}
Region old_clipping = new Region();
gc.getClipping(old_clipping);
Path path_done = new Path(gc.getDevice());
path_done.addArc(x,y,width,height,90,-angle);
path_done.lineTo( x+width/2, y+height/2);
path_done.close();
gc.setClipping( path_done );
gc.drawImage(image, x+width_pad, y+height_pad+1);
Path path_undone = new Path(gc.getDevice());
path_undone.addArc(x,y,width,height,90-angle,angle-360);
path_undone.lineTo( x+width/2, y+height/2);
path_undone.close();
gc.setClipping( path_undone );
gc.setAlpha( 75 );
gc.drawImage(image, x+width_pad, y+height_pad+1);
gc.setAlpha( 255 );
gc.setClipping( old_clipping );
if ( draw_border ){
gc.setForeground(Colors.blue);
if ( percent == 100 ){
gc.drawOval(x , y , width-1, height-1);
}else{
if ( angle > 0 ){
gc.drawPath( path_done );
}
}
}
path_done.dispose();
path_undone.dispose();
old_clipping.dispose();
}