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


Java Path2D.Double方法代码示例

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


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

示例1: 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

示例2: main

import java.awt.geom.Path2D; //导入方法依赖的package包/类
public static void main(final String[] args) {
    final Path2D path1 = new Path2D.Double(Path2D.WIND_EVEN_ODD, 0);
    path1.moveTo(10, 10);
    path1.lineTo(20, 20);
    final Path2D path2 = new Path2D.Float(Path2D.WIND_EVEN_ODD, 0);
    path2.moveTo(10, 10);
    path2.lineTo(20, 20);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:EmptyCapacity.java

示例3: createIntermediateShape

import java.awt.geom.Path2D; //导入方法依赖的package包/类
/**
 * Creates the shape for a single part of the intermediate bar.
 *
 * @param x
 * @param width
 * @param h
 * @param verticval
 * @return
 */
private Path2D createIntermediateShape(double x, double width, double h) {
	int offset = 10;

	Path2D path = new Path2D.Double();
	path.append(new Line2D.Double(x, h, x + offset, 0), true);
	path.append(new Line2D.Double(x + offset, 0, x + width + offset, 0), true);
	path.append(new Line2D.Double(x + width + offset, 0, x + width, h), true);
	path.append(new Line2D.Double(x + width, h, x, h), true);

	return path;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:21,代码来源:ProgressBarUI.java

示例4: createTopTabShape

import java.awt.geom.Path2D; //导入方法依赖的package包/类
/**
 * Creates the shape for a top tab.
 *
 * @param x
 * @param y
 * @param w
 * @param h
 * @param rTop
 * @param addBottom
 *            if {@code false}, the bottom line below the tab will not be added to the shape
 * @return
 */
private static Path2D createTopTabShape(int x, int y, int w, int h, double rTop, boolean addBottom) {
	Path2D path = new Path2D.Double();
	path.append(new Line2D.Double(x, y + h - 1, x, y + rTop), true);

	QuadCurve2D curve = new QuadCurve2D.Double(x, y + rTop, x, y, x + rTop, y);
	path.append(curve, true);

	path.append(new Line2D.Double(x + rTop, y, x + w - rTop, y), true);

	curve = new QuadCurve2D.Double(x + w - rTop, y, x + w, y, x + w, y + rTop);
	path.append(curve, true);

	path.append(new Line2D.Double(x + w, y + rTop, x + w, y + h), true);

	if (addBottom) {
		path.append(new Line2D.Double(x + w, y + h - 1, x, y + h - 1), true);
	}
	return path;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:32,代码来源:TabbedPaneUI.java

示例5: createLeftTabShape

import java.awt.geom.Path2D; //导入方法依赖的package包/类
/**
 * Creates the shape for a left tab.
 *
 * @param x
 * @param y
 * @param w
 * @param h
 * @param rLeft
 * @param addSide
 *            if {@code false}, the closing side line right of the tab will not be added to the
 *            shape
 * @return
 */
private static Path2D createLeftTabShape(int x, int y, int w, int h, double rLeft, boolean addSide) {
	Path2D path = new Path2D.Double();
	path.append(new Line2D.Double(x + w, y + h, x + rLeft, y + h), true);

	QuadCurve2D curve = new QuadCurve2D.Double(x + rLeft, y + h, x, y + h, x, y + h - rLeft);
	path.append(curve, true);

	path.append(new Line2D.Double(x, y + h - rLeft, x, y + rLeft), true);

	curve = new QuadCurve2D.Double(x, y + rLeft, x, y, x + rLeft, y);
	path.append(curve, true);

	path.append(new Line2D.Double(x + rLeft, y, x + w, y), true);

	if (addSide) {
		path.append(new Line2D.Double(x + w, y, x + w, y + h - 1), true);
	}
	return path;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:33,代码来源:TabbedPaneUI.java

示例6: GraphicsJLabel

import java.awt.geom.Path2D; //导入方法依赖的package包/类
/**
 * Creates a new GraphicsJLabel
 */
public GraphicsJLabel() {
    super();
    myPath = new Path2D.Double();
    xx = new double[]{0, 0, 0};
    yy = new double[]{0, 0, 0};
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:10,代码来源:GraphicsJLabel.java

示例7: renderCurvePath

import java.awt.geom.Path2D; //导入方法依赖的package包/类
private Shape renderCurvePath(int[] xPoints, int[] yPoints) {
    Path2D path = new Path2D.Double();
    path.moveTo(xPoints[0], yPoints[0]);

    int curveIndex;
    for (curveIndex = 0; curveIndex <= xPoints.length - 3; curveIndex += 3) {
        path.curveTo(xPoints[curveIndex], yPoints[curveIndex], xPoints[curveIndex + 1], yPoints[curveIndex + 1], xPoints[curveIndex + 2], yPoints[curveIndex + 2]);
    }

    if (xPoints.length >= 3 && xPoints.length - curveIndex == 2) {
        path.curveTo(xPoints[xPoints.length - 3], yPoints[xPoints.length - 3], xPoints[xPoints.length - 2], yPoints[xPoints.length - 2], xPoints[xPoints.length - 1], yPoints[xPoints.length - 1]);
    } else {
        path.lineTo(xPoints[xPoints.length - 1], yPoints[xPoints.length - 1]);
    }

    return path;
}
 
开发者ID:defano,项目名称:jmonet,代码行数:18,代码来源:CurveTool.java

示例8: addSelectionPoint

import java.awt.geom.Path2D; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void addSelectionPoint(Point initialPoint, Point newPoint, boolean isShiftKeyDown) {
    if (selectionBounds == null) {
        selectionBounds = new Path2D.Double();
        selectionBounds.moveTo(initialPoint.getX(), initialPoint.getY());
    }

    selectionBounds.lineTo(newPoint.x, newPoint.y);
}
 
开发者ID:defano,项目名称:jmonet,代码行数:11,代码来源:LassoTool.java

示例9: deserializeShape

import java.awt.geom.Path2D; //导入方法依赖的package包/类
private static Shape deserializeShape() {
    final Path2D.Double path = new Path2D.Double();

    for (int i = 0; i < SHAPE_TYPES.length; i++) {
        double[] coords = SHAPE_COORDS[i];

        switch (SHAPE_TYPES[i]) {
            case SEG_MOVETO:
                path.moveTo(coords[0], coords[1]);
                break;
            case SEG_LINETO:
                path.lineTo(coords[0], coords[1]);
                break;
            case SEG_QUADTO:
                path.quadTo(coords[0], coords[1],
                            coords[2], coords[3]);
                break;
            case SEG_CUBICTO:
                path.curveTo(coords[0], coords[1],
                             coords[2], coords[3],
                             coords[4], coords[5]);
                break;
            case SEG_CLOSE:
                path.closePath();
                break;
            default:
        }
    }

    return path;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:TextClipErrorTest.java

示例10: refreshShape

import java.awt.geom.Path2D; //导入方法依赖的package包/类
public void refreshShape() {
    int w = (int) window.getWidth(),     
        h = (int) window.getHeight();
    path = new Path2D.Double();
    path.moveTo(0,0);
    path.lineTo(w,0);
    path.lineTo(w,h-7);
    path.lineTo(w/2+7,h-7);
    path.lineTo(w/2,h);
    path.lineTo(w/2-7,h-7);
    path.lineTo(0,h-7);
    path.closePath();
    window.setShape(path);
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:15,代码来源:FlyingToolTip.java

示例11: findContainer

import java.awt.geom.Path2D; //导入方法依赖的package包/类
private int findContainer(final List<Path2D.Double> polygons, final Integer defaultPolygon, final double x,
        final double y) {
    int polygonIndex = defaultPolygon;

    for (int i = 0; i < polygons.size(); ++i) {
        Path2D.Double polygon = polygons.get(i);
        if (polygon.contains(x, y)) {
            polygonIndex = i;
            break;
        }
    }
    return polygonIndex;
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:14,代码来源:PolygonClustering.java

示例12: testDrawComplexAt

import java.awt.geom.Path2D; //导入方法依赖的package包/类
private static void testDrawComplexAt() {
    final int width = 400;
    final int height = 400;

    final BufferedImage image = new BufferedImage(width, height,
                                        BufferedImage.TYPE_INT_ARGB);

    final Graphics2D g2d = (Graphics2D) image.getGraphics();
    try {
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
                             RenderingHints.VALUE_STROKE_PURE);

        g2d.setBackground(Color.WHITE);
        g2d.clearRect(0, 0, width, height);

        final Path2D.Double path = new Path2D.Double();
        path.moveTo(100, 100);

        for (int i = 0; i < 20000; i++) {
            path.lineTo(110 + 0.01 * i, 110);
            path.lineTo(111 + 0.01 * i, 100);
        }

        path.lineTo(NaN, 200);
        path.lineTo(200, 200);
        path.lineTo(200, NaN);
        path.lineTo(300, 300);
        path.lineTo(NaN, NaN);
        path.lineTo(100, 200);
        path.closePath();

        final Path2D.Double path2 = new Path2D.Double();
        path2.moveTo(0, 0);
        path2.lineTo(100, height);
        path2.lineTo(0, 200);
        path2.closePath();

        // Define an non-uniform transform:
        g2d.scale(0.5, 1.0);
        g2d.rotate(Math.PI / 31);

        g2d.setColor(Color.BLACK);
        g2d.draw(path);
        g2d.draw(path2);

        if (SAVE_IMAGE) {
            try {
                final File file = new File("CrashNaNTest-draw.png");
                System.out.println("Writing file: "
                                   + file.getAbsolutePath());
                ImageIO.write(image, "PNG", file);
            } catch (IOException ex) {
                System.out.println("Writing file failure:");
                ex.printStackTrace();
            }
        }

        // Check image on few pixels:
        final Raster raster = image.getData();

        checkPixelNotWhite(raster, 40, 210);
        checkPixelNotWhite(raster, 44, 110);
        checkPixelNotWhite(raster, 60, 120);
        checkPixelNotWhite(raster, 89, 219);
        checkPixelNotWhite(raster, 28, 399);
        checkPixelNotWhite(raster, 134, 329);

    } finally {
        g2d.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:74,代码来源:CrashNaNTest.java

示例13: startPath

import java.awt.geom.Path2D; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void startPath(Graphics2D g, Stroke stroke, Paint paint, Point initialPoint) {
    path = new Path2D.Double();
    path.moveTo(initialPoint.getX(), initialPoint.getY());
}
 
开发者ID:defano,项目名称:jmonet,代码行数:7,代码来源:FreeformShapeTool.java

示例14: testFillDefaultAt

import java.awt.geom.Path2D; //导入方法依赖的package包/类
private static void testFillDefaultAt() {
    final int width = 400;
    final int height = 400;

    final BufferedImage image = new BufferedImage(width, height,
                                        BufferedImage.TYPE_INT_ARGB);

    final Graphics2D g2d = (Graphics2D) image.getGraphics();
    try {
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);

        g2d.setBackground(Color.WHITE);
        g2d.clearRect(0, 0, width, height);

        final Path2D.Double path = new Path2D.Double();
        path.moveTo(100, 100);

        for (int i = 0; i < 20000; i++) {
            path.lineTo(110 + 0.01 * i, 110);
            path.lineTo(111 + 0.01 * i, 100);
        }

        path.lineTo(NaN, 200);
        path.lineTo(200, 200);
        path.lineTo(200, NaN);
        path.lineTo(300, 300);
        path.lineTo(NaN, NaN);
        path.lineTo(100, 200);
        path.closePath();

        final Path2D.Double path2 = new Path2D.Double();
        path2.moveTo(0, 0);
        path2.lineTo(100, height);
        path2.lineTo(0, 200);
        path2.closePath();

        g2d.setColor(Color.BLUE);
        g2d.fill(path);
        g2d.setColor(Color.GREEN);
        g2d.fill(path2);

        g2d.setColor(Color.BLACK);
        g2d.draw(path);
        g2d.draw(path2);

        if (SAVE_IMAGE) {
            try {
                final File file = new File("CrashNaNTest-fill.png");
                System.out.println("Writing file: "
                                   + file.getAbsolutePath());
                ImageIO.write(image, "PNG", file);
            } catch (IOException ex) {
                System.out.println("Writing file failure:");
                ex.printStackTrace();
            }
        }

        // Check image on few pixels:
        final Raster raster = image.getData();

        checkPixel(raster, 200, 195, Color.BLUE.getRGB());
        checkPixel(raster, 105, 195, Color.BLUE.getRGB());
        checkPixel(raster, 286, 290, Color.BLUE.getRGB());

        checkPixel(raster, 108, 105, Color.WHITE.getRGB());
        checkPixel(raster, 205, 200, Color.WHITE.getRGB());

        checkPixel(raster, 5, 200, Color.GREEN.getRGB());

    } finally {
        g2d.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:75,代码来源:CrashNaNTest.java

示例15: getPath

import java.awt.geom.Path2D; //导入方法依赖的package包/类
private static Path2D getPath(int x, int y, int len) {
    Path2D p = new Path2D.Double();
    p.moveTo(x, y);
    p.quadTo(x + len, y, x + len, y + len);
    return p;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:Test7019861.java


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