Java 8 Path2D - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Path2D class.

This code example shows how to use the following methods:closePath, lineTo, moveTo
   class Triangle extends SikuliGuideComponent { 
 
      GeneralPath gp;
      public Triangle() { 
         super();          
         gp = new GeneralPath();
         gp.moveTo(TRIANGLE_SIZE*0.45,0);
         gp.lineTo(TRIANGLE_SIZE*0.5,TRIANGLE_SIZE);
         gp.lineTo(TRIANGLE_SIZE*0.85,0);
         gp.closePath();
 
         setActualSize(new Dimension(TRIANGLE_SIZE,TRIANGLE_SIZE));
      } 
 
      public void rotate(double radius){
         AffineTransform rat = new AffineTransform();
         rat.rotate(radius, TRIANGLE_SIZE/2, TRIANGLE_SIZE/2);
         gp.transform(rat);
      } 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:closePath, lineTo, moveTo
//      g2d.setColor(Color.black); 
//      g2d.drawLine(0,0,(int)a0,(int)b0); 
//       
//       
//       
      GeneralPath flagShape = new GeneralPath();
         flagShape.moveTo(m,n);
         flagShape.lineTo(x1,y1);
         flagShape.lineTo(x2,y2);
         flagShape.closePath();
 
      g2d.fill(flagShape);
       
       
      g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 1.0f));        
       
      //Rectangle smaller = new Rectangle(rect); 
      ellipse =
         new Ellipse2D.Double(-r.width/2+3,-r.height/2+3,r.width-6,r.height-6);
      g2d.fill(ellipse);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:closePath, lineTo, moveTo, transform
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:closePath, transform, lineTo, moveTo
     */ 
    protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
                              Point2D rotate, double angle) {
 
        GeneralPath shape1 = new GeneralPath();
        GeneralPath shape2 = new GeneralPath();
        float minX = (float) plotArea.getMinX();
        float minY = (float) plotArea.getMinY();
        float maxX = (float) plotArea.getMaxX();
        float maxY = (float) plotArea.getMaxY();
        float midX = (float) (minX + (plotArea.getWidth() / 2));
        float midY = (float) (minY + (plotArea.getHeight() / 2));
 
        shape1.moveTo(minX, midY);
        shape1.lineTo(midX, minY);
        shape1.lineTo(maxX, midY);
        shape1.closePath();
 
        shape2.moveTo(minX, midY);
        shape2.lineTo(midX, maxY);

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:closePath, lineTo, moveTo
       gp.lineTo(-0.5f, -0.2f);
       ExplicitBoundsShape oarrow = new ExplicitBoundsShape(gp);
       oarrow.setBounds(new Rectangle2D.Double(-0.5, -0.5, 1, 1));
       shapes.put("oarrow", oarrow);
        
       gp = new GeneralPath();
       gp.moveTo(-0.5f, 0.2f);
       gp.lineTo(0, 0);
       gp.lineTo(-0.5f, -0.2f);
       gp.closePath();
       ExplicitBoundsShape carrow = new ExplicitBoundsShape(gp);
       carrow.setBounds(new Rectangle2D.Double(-0.5, -0.5, 1, 1));
       shapes.put("carrow", carrow);
        
       gp = new GeneralPath();
       gp.moveTo(-0.5f, 0.3f);
       gp.lineTo(0.5, 0);
       gp.lineTo(-0.5f, -0.3f);
       ExplicitBoundsShape coarrow = new ExplicitBoundsShape(gp);
       coarrow.setBounds(new Rectangle2D.Double(-0.5, -0.3, 1, 0.6));
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:append, closePath, transform
     * @param angle  the angle. 
     */ 
    protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
                              Point2D rotate, double angle) {
 
        GeneralPath shape = new GeneralPath();
        shape.append(new Arc2D.Double(-9.0, -7.0, 10, 14, 0.0, 25.5,
                Arc2D.OPEN), true);
        shape.append(new Arc2D.Double(0.0, -7.0, 10, 14, 154.5, 25.5,
                Arc2D.OPEN), true);
        shape.closePath();
        getTransform().setToTranslation(plotArea.getMinX(), plotArea.getMaxY());
        getTransform().scale(plotArea.getWidth(), plotArea.getHeight() / 3);
        shape.transform(getTransform());
 
        if ((rotate != null) && (angle != 0)) {
            /// we have rotation 
            getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
            shape.transform(getTransform());
        } 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:closePath, lineTo, moveTo
     */ 
    protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
                              Point2D rotate, double angle) {
 
        Area shape;
        GeneralPath pointer = new GeneralPath();
 
        int minY = (int) (plotArea.getMinY());
        //int maxX = (int) (plotArea.getMaxX()); 
        int maxY = (int) (plotArea.getMaxY());
        int midX = (int) (plotArea.getMinX() + (plotArea.getWidth() / 2));
        //int midY = (int) (plotArea.getMinY() + (plotArea.getHeight() / 2)); 
        int lenX = (int) (plotArea.getWidth() / 10);
        if (lenX < 2) {
            lenX = 2;
        } 
 
        pointer.moveTo(midX - lenX, maxY - lenX);
        pointer.lineTo(midX + lenX, maxY - lenX);
        pointer.lineTo(midX, minY + lenX);

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:closePath, lineTo, moveTo
                           XYURLGenerator urlGenerator) {
        super(); 
        this.showOutline = false;
        setBaseToolTipGenerator(labelGenerator);
        setURLGenerator(urlGenerator);
        GeneralPath area = new GeneralPath();
        area.moveTo(0.0f, -4.0f);
        area.lineTo(3.0f, -2.0f);
        area.lineTo(4.0f, 4.0f);
        area.lineTo(-4.0f, 4.0f);
        area.lineTo(-3.0f, -2.0f);
        area.closePath();
        this.legendArea = area;
    } 
 
    /** 
     * Returns a flag that controls whether or not outlines of the areas are 
     * drawn. 
     * 
     * @return The flag. 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:closePath, lineTo, moveTo
     * @param t  the thickness. 
     * 
     * @return A diagonal cross shape. 
     */ 
    public static Shape createDiagonalCross(final float l, final float t) {
        final GeneralPath p0 = new GeneralPath();
        p0.moveTo(-l - t, -l + t);
        p0.lineTo(-l + t, -l - t);
        p0.lineTo(0.0f, -t * SQRT2);
        p0.lineTo(l - t, -l - t);
        p0.lineTo(l + t, -l + t);
        p0.lineTo(t * SQRT2, 0.0f);
        p0.lineTo(l + t, l - t);
        p0.lineTo(l - t, l + t);
        p0.lineTo(0.0f, t * SQRT2);
        p0.lineTo(-l + t, l + t);
        p0.lineTo(-l - t, l - t);
        p0.lineTo(-t * SQRT2, 0.0f);
        p0.closePath();
        return p0;

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:closePath, lineTo, moveTo
     */ 
    protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
                              Point2D rotate, double angle) {
 
        Area shape;
        GeneralPath pointer = new GeneralPath();
 
        int minY = (int) (plotArea.getMinY());
        //int maxX = (int) (plotArea.getMaxX()); 
        int maxY = (int) (plotArea.getMaxY());
        int midY = ((maxY - minY) / 2) + minY;
 
        int midX = (int) (plotArea.getMinX() + (plotArea.getWidth() / 2));
        //int midY = (int) (plotArea.getMinY() + (plotArea.getHeight() / 2)); 
        int lenX = (int) (plotArea.getWidth() / 10);
        if (lenX < 2) {
            lenX = 2;
        } 
 
        pointer.moveTo(midX - lenX, midY - lenX);

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 Path2D Methods: