当前位置: 首页>>代码示例>>Java>>正文


Java Path.lineTo方法代码示例

本文整理汇总了Java中org.eclipse.swt.graphics.Path.lineTo方法的典型用法代码示例。如果您正苦于以下问题:Java Path.lineTo方法的具体用法?Java Path.lineTo怎么用?Java Path.lineTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.graphics.Path的用法示例。


在下文中一共展示了Path.lineTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:39,代码来源:SWTGraphics2D.java

示例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;
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:39,代码来源:SWTGraphics2D.java

示例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;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:44,代码来源:SWTGraphics2D.java

示例4: paintLeftArrow

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
protected void paintLeftArrow(Graphics graphics){
	int width = pagingControlHeight / 4;
	Rectangle r = getBounds().getCopy();
	Point start = new Point(r.getRight().x - 10, r.getCenter().y);
	Path triangle = new Path(null);
	triangle.moveTo(start.x, start.y);
	triangle.lineTo(start.x - width, start.y - pagingControlHeight/2);
	triangle.lineTo(start.x - width, start.y + pagingControlHeight/2);
	graphics.fillPath(triangle);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:11,代码来源:ScrollableViewFigureAndroid.java

示例5: paintRightArrow

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
protected void paintRightArrow(Graphics graphics){
	int width = pagingControlHeight / 4;
	Rectangle r = getBounds().getCopy();
	Point start = new Point(r.x + 10, r.getCenter().y);
	Path triangle = new Path(null);
	triangle.moveTo(start.x, start.y);
	triangle.lineTo(start.x + width, start.y - pagingControlHeight/2);
	triangle.lineTo(start.x + width, start.y + pagingControlHeight/2);
	graphics.fillPath(triangle);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:11,代码来源:ScrollableViewFigureAndroid.java

示例6: getTopRoundedRectangle

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public static Path getTopRoundedRectangle(PrecisionRectangle tempRect, float radius,boolean drawLeftSide,boolean drawRightSide){
	if (radius <= 0) return getRoundedRectangle(tempRect, radius,drawLeftSide,drawRightSide);
	float width = radius * 2;
	float dy = radius - tempRect.height;
	float dx = radius - (float) Math.sqrt(radius*radius - dy*dy);
	float alpha =  dy > 0 ? (float)(Math.acos(dy/radius)*180/Math.PI) : 90;
	Path p = new Path(null);
	float x = (float) tempRect.preciseX;
	float y = (float) tempRect.preciseY;
	float right = (float) tempRect.preciseRight();
	float bottom = (float) tempRect.preciseBottom();
	
	if (dy < 0){
		p.moveTo(x, y + radius);
	} else {
		p.moveTo(x + dx, y - dy);
	}
	p.addArc(x, y, width, width, 90 + alpha, -alpha);
	p.addArc(right-width, y, width, width, 90, -alpha);
	
	if (dy < 0){
		p.lineTo(right, bottom);//rightBottom
		p.lineTo(x, bottom);//leftBottom
	}
			
	return p;
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:28,代码来源:Drawer.java

示例7: getBottomRoundedRectangle

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public static Path getBottomRoundedRectangle(PrecisionRectangle tempRect, float radius,boolean drawLeftSide,boolean drawRightSide){
	if (radius <= 0) return getRoundedRectangle(tempRect, radius,drawLeftSide,drawRightSide);
	float width = radius * 2;
	float dy = radius - tempRect.height;
	float dx = radius - (float) Math.sqrt(radius*radius - dy*dy);
	float alpha =  dy > 0 ? (float)(Math.acos(dy/radius)*180/Math.PI) : 90;
	Path p = new Path(null);
	float x = (float) tempRect.preciseX;
	float y = (float) tempRect.preciseY;
	float right = (float) tempRect.preciseRight();
	float bottom = (float) tempRect.preciseBottom();
	
	if (dy < 0){
		p.moveTo(x, bottom - radius);
	} else {
		p.moveTo(x + dx, y);
	}
	p.addArc(x, bottom - 2*radius, width, width, 270 - alpha, alpha);
	p.addArc(right-width, bottom - 2*radius, width, width, 270, alpha);
	
	if (dy < 0){
		p.lineTo(right, y);//rightTop
		p.lineTo(x, y);//leftTop
	}
			
	return p;
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:28,代码来源:Drawer.java

示例8: paintButton

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
protected void paintButton(Graphics graphics) {
	graphics.setBackgroundColor(ColorConstants.black);
	Rectangle bounds = getBounds().getCopy();
	Path path = new Path(null);
	path.moveTo(bounds.right() - BUTTON_SIZE.width / 2,
			bounds.getCenter().y - BUTTON_SIZE.height / 2);
	path.lineTo(bounds.right()- 3*BUTTON_SIZE.width / 2,
			bounds.getCenter().y - BUTTON_SIZE.height / 2);
	path.lineTo(bounds.right() - BUTTON_SIZE.width,
			bounds.getCenter().y + BUTTON_SIZE.height / 2);
	graphics.fillPath(path);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:13,代码来源:PickerFigure.java

示例9: paintScale

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
void paintScale(final GC gc) {
	gc.setBackground(IGamaColors.BLACK.color());
	final int BAR_WIDTH = 1;
	final int BAR_HEIGHT = 8;
	final int x = 0;
	final int y = 0;
	final int margin = 20;
	final int width = scalebar.getBounds().width - 2 * margin;
	final int height = scalebar.getBounds().height;
	final int barStartX = x + 1 + BAR_WIDTH / 2 + margin;
	final int barStartY = y + height - BAR_HEIGHT / 2;

	final Path path = new Path(WorkbenchHelper.getDisplay());
	path.moveTo(barStartX, barStartY - BAR_HEIGHT + 2);
	path.lineTo(barStartX, barStartY + 2);
	path.moveTo(barStartX, barStartY - BAR_HEIGHT / 2 + 2);
	path.lineTo(barStartX + width, barStartY - BAR_HEIGHT / 2 + 2);
	path.moveTo(barStartX + width, barStartY - BAR_HEIGHT + 2);
	path.lineTo(barStartX + width, barStartY + 2);

	gc.setForeground(IGamaColors.WHITE.color());
	gc.setLineStyle(SWT.LINE_SOLID);
	gc.setLineWidth(BAR_WIDTH);
	gc.drawPath(path);
	gc.setFont(coord.getFont());
	drawStringCentered(gc, "0", barStartX, barStartY - 6, false);
	drawStringCentered(gc, getScaleRight(), barStartX + width, barStartY - 6, false);
	path.dispose();
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:30,代码来源:DisplayOverlay.java

示例10: paintTurtle

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
private void paintTurtle(GC gc, Point p)
{
	Path path = new Path(getDisplay());
	int x;
	int y;
	x = p.x - (int)Math.round(Math.cos(Math.toRadians(_turtle.getAngle() + 90)) * 5);
	y = p.y - (int)Math.round(Math.sin(Math.toRadians(_turtle.getAngle() + 90)) * 5);
	Point p1 = new Point(x, y);
	x = p.x + (int)Math.round(Math.cos(Math.toRadians(_turtle.getAngle() + 90)) * 5);
	y = p.y + (int)Math.round(Math.sin(Math.toRadians(_turtle.getAngle() + 90)) * 5);
	Point p2 = new Point(x, y);
	x = p.x + (int)Math.round(Math.cos(Math.toRadians(_turtle.getAngle())) * 10);
	y = p.y + (int)Math.round(Math.sin(Math.toRadians(_turtle.getAngle())) * 10);
	Point p3 = new Point(x, y);
	path.moveTo(p1.x, p1.y);
	path.lineTo(p2.x, p2.y);
	path.lineTo(p3.x, p3.y);
	path.lineTo(p1.x, p1.y);
	if (_turtle.isPenDown())
	{
		gc.setBackground(_turtleColor);
	}
	else
	{
		gc.setBackground(getBackground());
	}
	gc.fillPath(path);
	gc.setForeground(new Color(getDisplay(), 0, 0, 0));
	gc.drawPath(path);
}
 
开发者ID:yinonavraham,项目名称:myLOGO,代码行数:31,代码来源:TurtleCanvas.java

示例11: 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;
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:45,代码来源:ScaledGraphics.java

示例12: performRender

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
@Override
protected void performRender ( final Graphics g, final Rectangle clientRect )
{

    final Path path = g.createPath ();

    try
    {
        // eval min/max
        final XAxis xAxis = this.seriesData.getXAxis ();
        final YAxis yAxis = this.seriesData.getYAxis ();

        final SortedSet<DataEntry> entries = this.seriesData.getViewData ().getEntries ();
        if ( entries.isEmpty () )
        {
            return;
        }

        boolean first = true;

        final DataPoint point = new DataPoint ();

        for ( final DataEntry entry : entries )
        {
            final boolean hasData = translateToPoint ( clientRect, xAxis, yAxis, point, entry );
            if ( hasData )
            {
                if ( first )
                {
                    first = false;
                    path.moveTo ( point.x, point.y );
                }
                else
                {
                    path.lineTo ( point.x, point.y );
                }
            }
            else
            {
                first = true;
            }
        }
        g.setAlpha ( 255 );
        g.setLineAttributes ( this.lineAttributes );
        g.setForeground ( this.lineColor );

        g.setClipping ( clientRect );
        g.drawPath ( path );
    }
    finally
    {
        path.dispose ();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:55,代码来源:LinearRenderer.java

示例13: fillRectangle

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public void fillRectangle( RectangleRenderEvent rre ) throws ChartException
{
	iv.modifyEvent( rre  );
	final Fill flBackground = validateMultipleFill( rre.getBackground( ) );

	if ( isFullTransparent( flBackground ) )
	{
		return;
	}

	final Bounds bo = normalizeBounds( rre.getBounds( ) );
	final Rectangle r = new Rectangle( (int) ( ( bo.getLeft( ) + dTranslateX ) * dScale ),
			(int) ( ( bo.getTop( ) + dTranslateY ) * dScale ),
			(int) Math.ceil( bo.getWidth( ) * dScale ),
			(int) Math.ceil( bo.getHeight( ) * dScale ) );

	final Path pt = new Path( ( (SwtDisplayServer) _ids ).getDevice( ) );
	pt.moveTo( r.x, r.y );
	pt.lineTo( r.x, r.y + r.height );
	pt.lineTo( r.x + r.width, r.y + r.height );
	pt.lineTo( r.x + r.width, r.y );

	try
	{
		if ( flBackground instanceof ColorDefinition )
		{				
			fillPathColor( pt, (ColorDefinition) flBackground );
		}
		if ( flBackground instanceof Gradient )
		{
			fillPathGradient( pt, (Gradient) flBackground, r );
		}
		else if ( flBackground instanceof org.eclipse.birt.chart.model.attribute.Image )
		{
			fillPathImage( pt,
					(org.eclipse.birt.chart.model.attribute.Image) flBackground );
		}
	}
	finally
	{
		pt.dispose( );
	}
	

}
 
开发者ID:eclipse,项目名称:birt,代码行数:46,代码来源:SwtRendererImpl.java

示例14: fillPolygon

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public void fillPolygon( PolygonRenderEvent pre ) throws ChartException
{
	iv.modifyEvent( pre );
	
	// DUE TO RESTRICTIVE SWT API, WE SET A CLIPPED POLYGON REGION
	// AND RENDER THE POLYGON BY RENDERING A CONTAINING RECTANGLE WHERE
	// THE RECTANGLE BOUNDS CORRESPOND TO THE POLYGON BOUNDS
	// NOTE: SOME INCOMPLETE PAINTING ERRORS SEEM TO EXIST FOR GRADIENT POLY
	// FILLS

	final Fill flBackground = validateMultipleFill( pre.getBackground( ) );

	if ( isFullTransparent( flBackground ) )
	{
		return;
	}

	final Bounds bo = normalizeBounds( pre.getBounds( ) );
	final Rectangle r = new Rectangle( (int) ( ( bo.getLeft( ) + dTranslateX ) * dScale ),
			(int) ( ( bo.getTop( ) + dTranslateY ) * dScale ),
			(int) Math.ceil( bo.getWidth( ) * dScale ),
			(int) Math.ceil( bo.getHeight( ) * dScale ) );
	
	float[] points = convertDoubleToFloat( getDoubleCoordinatesAsInts( pre.getPoints( ),
			TRUNCATE,
			dTranslateX,
			dTranslateY,
			dScale ) );
	if ( points.length < 1 )
	{
		return;
	}
	final Path pt = new Path( ( (SwtDisplayServer) _ids ).getDevice( ) );
	pt.moveTo( points[0], points[1] );
	for ( int i = 1; i < points.length / 2; i++ )
	{
		pt.lineTo( points[2 * i], points[2 * i + 1] );
	}
	
	try
	{
		if ( flBackground instanceof ColorDefinition )
		{
			fillPathColor( pt, (ColorDefinition) flBackground );
		}
		else if ( flBackground instanceof Gradient )
		{
			fillPathGradient( pt, (Gradient) flBackground, r );
		}
		else if ( flBackground instanceof org.eclipse.birt.chart.model.attribute.Image )
		{
			fillPathImage( pt,
					(org.eclipse.birt.chart.model.attribute.Image) flBackground );
		}
	}
	finally
	{
		pt.dispose( );
	}
	

}
 
开发者ID:eclipse,项目名称:birt,代码行数:63,代码来源:SwtRendererImpl.java

示例15: drawArea

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public void drawArea( AreaRenderEvent are ) throws ChartException
{
	iv.modifyEvent( are );
	
	// CHECK IF THE LINE ATTRIBUTES ARE CORRECTLY DEFINED
	final LineAttributes lia = are.getOutline( );
	if ( !validateLineAttributes( are.getSource( ), lia ) )
	{
		return;
	}

	// SETUP THE FOREGROUND COLOR (DARKER BACKGROUND IF DEFINED AS NULL)
	final Color cFG = (Color) validateEdgeColor( lia.getColor( ),
			are.getBackground( ),
			_ids );
	if ( cFG == null ) // IF UNDEFINED, EXIT
	{
		return;
	}

	// BUILD THE GENERAL PATH STRUCTURE
	final Path gp = new Path( ( (SwtDisplayServer) _ids ).getDevice( ) );
	PrimitiveRenderEvent pre;
	for ( int i = 0; i < are.getElementCount( ); i++ )
	{
		pre = are.getElement( i );
		if ( pre instanceof ArcRenderEvent )
		{
			final ArcRenderEvent acre = (ArcRenderEvent) pre;

			gp.addArc( (float) acre.getTopLeft( ).getX( ),
					(float) acre.getTopLeft( ).getY( ),
					(float) acre.getWidth( ),
					(float) acre.getHeight( ),
					(float) acre.getStartAngle( ),
					(float) acre.getAngleExtent( ) );
		}
		else if ( pre instanceof LineRenderEvent )
		{
			final LineRenderEvent lre = (LineRenderEvent) pre;
			gp.moveTo( (float) lre.getStart( ).getX( ),
					(float) lre.getStart( ).getY( ) );
			gp.lineTo( (float) lre.getEnd( ).getX( ), (float) lre.getEnd( )
					.getY( ) );
		}
	}

	// DRAW THE PATH
	final int iOldLineStyle = _gc.getLineStyle( );
	final int iOldLineWidth = _gc.getLineWidth( );
	int iLineStyle = SWT.LINE_SOLID;
	switch ( lia.getStyle( ).getValue( ) )
	{
		case ( LineStyle.DOTTED                                                                                                                                                                                                                                                                  ) :
			iLineStyle = SWT.LINE_DOT;
			break;
		case ( LineStyle.DASH_DOTTED                                                                                                                                                                                                                                                                  ) :
			iLineStyle = SWT.LINE_DASHDOT;
			break;
		case ( LineStyle.DASHED                                                                                                                                                                                                                                                                  ) :
			iLineStyle = SWT.LINE_DASH;
			break;
	}
	_gc.setLineStyle( iLineStyle );
	_gc.setLineWidth( lia.getThickness( ) );
	_gc.setForeground( cFG );

	R31Enhance.setAlpha( _gc, lia.getColor( ) );

	_gc.drawPath( gp );

	// Restore state
	_gc.setLineStyle( iOldLineStyle );
	_gc.setLineWidth( iOldLineWidth );

	// Free resource
	gp.dispose( );
	cFG.dispose( );

}
 
开发者ID:eclipse,项目名称:birt,代码行数:81,代码来源:SwtRendererImpl.java


注:本文中的org.eclipse.swt.graphics.Path.lineTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。