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


Java Path2D类代码示例

本文整理汇总了Java中java.awt.geom.Path2D的典型用法代码示例。如果您正苦于以下问题:Java Path2D类的具体用法?Java Path2D怎么用?Java Path2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Path2D类属于java.awt.geom包,在下文中一共展示了Path2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeEllipse

import java.awt.geom.Path2D; //导入依赖的package包/类
public Path2D makeEllipse(Complex G1, Complex G2, int m, double xOffset, double yOffset) {
	Path2D path = new Path2D.Float();
	int recPoints = Math.max(minReconstructionSamples, G.length * 3);
	for (int i = 0; i < recPoints; i++) {
		double t = (double) i / recPoints;
		Complex p1 = this.getEllipsePoint(G1, G2, m, t);
		double xt = p1.re();
		double yt = p1.im();
		if (i == 0) {
			path.moveTo(xt + xOffset, yt + yOffset);
		}
		else {
			path.lineTo(xt + xOffset, yt + yOffset);
		}
	}
	path.closePath();
	return path;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:19,代码来源:FourierDescriptor.java

示例2: print

import java.awt.geom.Path2D; //导入依赖的package包/类
public int print( Graphics graphics, PageFormat format, int index ) {
    Graphics2D g2d = (Graphics2D)graphics;

    double scalex = g2d.getTransform().getScaleX();
    double scaley = g2d.getTransform().getScaleY();

    double centerx = ( format.getImageableX() +
                     ( format.getImageableWidth() / 2 ) ) * scalex;
    double centery = ( format.getImageableY() +
                     ( format.getImageableHeight() / 2 ) ) * scaley;

    // The following 2 lines cause an error when printing in landscape.
    g2d.scale( 1 / scalex, 1 / scaley );
    g2d.translate( centerx, centery );

    Path2D.Double path = new Path2D.Double();
    path.moveTo( -scalex * 72, -scaley * 72 );
    path.lineTo( -scalex * 72, scaley * 72 );
    path.lineTo( scalex * 72, scaley * 72 );
    path.lineTo( scalex * 72, -scaley * 72 );
    path.closePath();

    g2d.draw( path );

    return index == 0 ? PAGE_EXISTS : NO_SUCH_PAGE;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:LandscapeStackOverflow.java

示例3: testAddClose

import java.awt.geom.Path2D; //导入依赖的package包/类
static void testAddClose(Path2D pathA, boolean isEmpty) {
    try {
        addClose(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddClose: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddClose: passed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:Path2DCopyConstructor.java

示例4: testAddLine

import java.awt.geom.Path2D; //导入依赖的package包/类
static void testAddLine(Path2D pathA, boolean isEmpty) {
    try {
        addLines(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddLine: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddLine: passed.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Path2DCopyConstructor.java

示例5: paintState

import java.awt.geom.Path2D; //导入依赖的package包/类
public void paintState(Graphics2D g2, ASVConfig s) {
	if (s == null) {
		return;
	}
	Path2D.Float path = new Path2D.Float();

	List<Point2D> points = s.getASVPositions();
	Point2D p = points.get(0);
	path.moveTo(p.getX(), p.getY());
	for (int i = 1; i < points.size(); i++) {
		p = points.get(i);
		path.lineTo(p.getX(), p.getY());
	}
	path.transform(transform);
	g2.draw(path);
	if (animating || !displayingSolution) {
		p = transform.transform(points.get(0), null);
		Color color = g2.getColor();
		Stroke stroke = g2.getStroke();
		g2.setColor(Color.BLACK);
		g2.setStroke(new BasicStroke(1));
		g2.draw(new Ellipse2D.Double(p.getX() - 4, p.getY() - 4, 8, 8));
		g2.setColor(color);
		g2.setStroke(stroke);
	}
}
 
开发者ID:moment-of-peace,项目名称:AI-RRT-Motion-Planning,代码行数:27,代码来源:VisualisationPanel.java

示例6: testGetBounds

import java.awt.geom.Path2D; //导入依赖的package包/类
static void testGetBounds(Path2D pathA, Path2D pathB) {
    final Rectangle rA = pathA.getBounds();
    final Rectangle rB = pathB.getBounds();

    if (!rA.equals(rB)) {
        throw new IllegalStateException("Bounds are not equals [" + rA
            + "|" + rB + "] !");
    }
    final Rectangle2D r2dA = pathA.getBounds2D();
    final Rectangle2D r2dB = pathB.getBounds2D();

    if (!equalsRectangle2D(r2dA, r2dB)) {
        throw new IllegalStateException("Bounds2D are not equals ["
            + r2dA + "|" + r2dB + "] !");
    }
    log("testGetBounds: passed.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:Path2DCopyConstructor.java

示例7: getPath2D

import java.awt.geom.Path2D; //导入依赖的package包/类
Path2D.Float getPath2D() {
    // resolve reference:
    Path2D.Float p2d
        = (refPath2D != null) ? refPath2D.get() : null;

    // create a new Path2D ?
    if (p2d == null) {
        p2d = new Path2D.Float(Path2D.WIND_NON_ZERO, INITIAL_EDGES_COUNT); // 32K

        // update weak reference:
        refPath2D = new WeakReference<Path2D.Float>(p2d);
    }
    // reset the path anyway:
    p2d.reset();
    return p2d;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:RendererContext.java

示例8: doShape

import java.awt.geom.Path2D; //导入依赖的package包/类
void doShape(SunGraphics2D sg2d, Shape s, boolean isfill) {
    Path2D.Float p2df;
    int transX;
    int transY;
    if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
        if (s instanceof Path2D.Float) {
            p2df = (Path2D.Float)s;
        } else {
            p2df = new Path2D.Float(s);
        }
        transX = sg2d.transX;
        transY = sg2d.transY;
    } else {
        p2df = new Path2D.Float(s, sg2d.transform);
        transX = 0;
        transY = 0;
    }
    try {
        doShape((GDIWindowSurfaceData)sg2d.surfaceData,
                sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
                transX, transY, p2df, isfill);
    } catch (ClassCastException e) {
        throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:GDIRenderer.java

示例9: drawPolyline

import java.awt.geom.Path2D; //导入依赖的package包/类
/**
 * Draws a sequence of connected lines defined by
 * arrays of <i>x</i> and <i>y</i> coordinates.
 * Each pair of (<i>x</i>,&nbsp;<i>y</i>) coordinates defines a point.
 * The figure is not closed if the first point
 * differs from the last point.
 * @param       xPoints an array of <i>x</i> points
 * @param       yPoints an array of <i>y</i> points
 * @param       nPoints the total number of points
 * @see         java.awt.Graphics#drawPolygon(int[], int[], int)
 * @since       1.1
 */
public void drawPolyline(int xPoints[], int yPoints[],
                         int nPoints) {

    if (nPoints == 2) {
        draw(new Line2D.Float(xPoints[0], yPoints[0],
                              xPoints[1], yPoints[1]));
    } else if (nPoints > 2) {
        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD, nPoints);
        path.moveTo(xPoints[0], yPoints[0]);
        for(int i = 1; i < nPoints; i++) {
            path.lineTo(xPoints[i], yPoints[i]);
        }
        draw(path);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:PathGraphics.java

示例10: testAddCubic

import java.awt.geom.Path2D; //导入依赖的package包/类
static void testAddCubic(Path2D pathA, boolean isEmpty) {
    try {
        addCubics(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddCubic: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddCubic: passed.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Path2DCopyConstructor.java

示例11: polygonClustering

import java.awt.geom.Path2D; //导入依赖的package包/类
private Map<Object, List<Fibre>> polygonClustering(final List<Path2D.Double> polygons, final Integer defaultPolygon,
        final List<Fibre> input, final List<String> attributes, final Map<OperationErrorCode, String> errors,
        final OperationContext context) {
    Map<Object, List<Fibre>> result;

    result = new ConcurrentHashMap<Object, List<Fibre>>();

    input.stream().forEach(le -> {
        List<Double> values = LoomQueryUtils.convertAttributesToNumbers(attributes, le, errors, context);
        int polygonIndex = this.findContainer(polygons, defaultPolygon, values.get(0), values.get(1));

        if (result.get(polygonIndex) == null) {
            result.put(polygonIndex, new LinkedList<Fibre>());
        }
        result.get(polygonIndex).add(le);
    });

    return result;
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:20,代码来源:PolygonClustering.java

示例12: main

import java.awt.geom.Path2D; //导入依赖的package包/类
public static void main(String[] argv) throws Exception {
    BufferedImage im = getWhiteImage(30, 30);
    Graphics2D g2 = (Graphics2D)im.getGraphics();
    g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE);
    g2.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    g2.setBackground(Color.white);
    g2.setColor(Color.black);

    Path2D p = getPath(0, 0, 20);
    g2.draw(p);

    if (!(new Color(im.getRGB(20, 19))).equals(Color.black)) {
        throw new Exception("This pixel should be black");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Test7019861.java

示例13: doPath

import java.awt.geom.Path2D; //导入依赖的package包/类
private void doPath(SunGraphics2D sg2d, Shape s, boolean isFill) {
    Path2D.Float p2df;
    int transx, transy;
    if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
        if (s instanceof Path2D.Float) {
            p2df = (Path2D.Float)s;
        } else {
            p2df = new Path2D.Float(s);
        }
        transx = sg2d.transX;
        transy = sg2d.transY;
    } else {
        p2df = new Path2D.Float(s, sg2d.transform);
        transx = 0;
        transy = 0;
    }
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDoPath(sg2d, sg2d.surfaceData.getNativeOps(), xgc,
                transx, transy, p2df, isFill);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:X11Renderer.java

示例14: doShape

import java.awt.geom.Path2D; //导入依赖的package包/类
void doShape(SunGraphics2D sg2d, Shape s, boolean isfill) {
    Path2D.Float p2df;
    int transX;
    int transY;
    if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
        if (s instanceof Path2D.Float) {
            p2df = (Path2D.Float)s;
        } else {
            p2df = new Path2D.Float(s);
        }
        transX = sg2d.transX;
        transY = sg2d.transY;
    } else {
        p2df = new Path2D.Float(s, sg2d.transform);
        transX = 0;
        transY = 0;
    }
    try {
        doShape((GDIWindowSurfaceData)sg2d.surfaceData,
                sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
                transX, transY, p2df, isfill);
    } catch (ClassCastException e) {
        throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:GDIRenderer.java

示例15: testAddQuad

import java.awt.geom.Path2D; //导入依赖的package包/类
static void testAddQuad(Path2D pathA, boolean isEmpty) {
    try {
        addQuads(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddQuad: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddQuad: passed.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Path2DCopyConstructor.java


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