Java Code Examples for java.awt.geom.GeneralPath#WIND_NON_ZERO

The following examples show how to use java.awt.geom.GeneralPath#WIND_NON_ZERO . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextLine.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Shape getOutline(AffineTransform tx) {

        GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];

            dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
        }

        if (tx != null) {
            dstShape.transform(tx);
        }
        return dstShape;
    }
 
Example 2
Source File: TextLine.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
public Shape getOutline(AffineTransform tx) {

        GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];

            dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
        }

        if (tx != null) {
            dstShape.transform(tx);
        }
        return dstShape;
    }
 
Example 3
Source File: TextLine.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Shape getOutline(AffineTransform tx) {

        GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];

            dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
        }

        if (tx != null) {
            dstShape.transform(tx);
        }
        return dstShape;
    }
 
Example 4
Source File: StandardGlyphVector.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Used by getOutline, getGlyphsOutline
 */
private Shape getGlyphsOutline(int start, int count, float x, float y) {
    setFRCTX();
    initPositions();

    GeneralPath result = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    for (int i = start, e = start + count, n = start * 2; i < e; ++i, n += 2) {
        float px = x + positions[n];
        float py = y + positions[n+1];

        getGlyphStrike(i).appendGlyphOutline(glyphs[i], result, px, py);
    }

    return result;
}
 
Example 5
Source File: StandardGlyphVector.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Used by getOutline, getGlyphsOutline
 */
private Shape getGlyphsOutline(int start, int count, float x, float y) {
    setFRCTX();
    initPositions();

    GeneralPath result = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    for (int i = start, e = start + count, n = start * 2; i < e; ++i, n += 2) {
        float px = x + positions[n];
        float py = y + positions[n+1];

        getGlyphStrike(i).appendGlyphOutline(glyphs[i], result, px, py);
    }

    return result;
}
 
Example 6
Source File: BorderRenderer.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Shape getBorderLeftShape() {
  if ( borderShapeLeft != null ) {
    return borderShapeLeft;
  }

  final StaticBoxLayoutProperties sblp = this.staticBoxLayoutProperties;
  final long halfBorderWidth = sblp.getBorderLeft() / 2;
  final long x = this.x;
  final long y = this.y;
  final long h = this.height;

  final Border border = boxDefinition.getBorder();
  final long topLeftWidth = border.getTopLeft().getWidth();
  final long topLeftHeight = border.getTopLeft().getHeight();
  final long bottomLeftWidth = border.getBottomLeft().getWidth();
  final long bottomLeftHeight = border.getBottomLeft().getHeight();

  if ( bottomLeftWidth == 0 && topLeftWidth == 0 && bottomLeftHeight == 0 && topLeftHeight == 0 ) {
    // Make a square corner
    final double lineX = StrictGeomUtility.toExternalValue( x + halfBorderWidth );
    final double lineY1 = StrictGeomUtility.toExternalValue( y );
    final double lineY2 = StrictGeomUtility.toExternalValue( y + h );
    borderShapeLeft = new Line2D.Double( lineX, lineY1, lineX, lineY2 );
    return borderShapeLeft;
  }

  // Make a rounded corner
  final GeneralPath generalPath = new GeneralPath( GeneralPath.WIND_NON_ZERO, 20 );
  generalPath.append( configureArc( x, y + h - 2 * bottomLeftHeight, 2 * bottomLeftWidth, 2 * bottomLeftHeight, -135,
      -45, Arc2D.OPEN ), true );
  generalPath.lineTo( (float) x, (float) ( y + topLeftHeight ) ); // 8
  generalPath.append( configureArc( x, y, 2 * topLeftWidth, 2 * topLeftHeight, -180, -45, Arc2D.OPEN ), true );
  generalPath.transform( BorderRenderer.scaleInstance );
  borderShapeLeft = generalPath;
  return generalPath;
}
 
Example 7
Source File: Util.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates an image that consists of {@code text} on a background containing a curved shape. The
 * returned image is appropriate for display in the header of a dialog to give it a "wizard-like"
 * look.
 */
public static Image getBanner(final String text) {
  // code stolen from swingx
  // swingx is lgpl, so no problems with copyright
  final int w = 530;
  final int h = 60;
  final BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
  final Graphics2D g2 = img.createGraphics();
  final Font font = new Font("Arial Bold", Font.PLAIN, 36);
  g2.setFont(font);
  g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g2.setRenderingHint(
      RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  g2.setRenderingHint(
      RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
  // draw a big square
  g2.setColor(Color.GRAY);
  g2.fillRect(0, 0, w, h);
  // create the curve shape
  final GeneralPath curveShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);
  curveShape.moveTo(0, h * .6f);
  curveShape.curveTo(w * .167f, h * 1.2f, w * .667f, h * -.5f, w, h * .75f);
  curveShape.lineTo(w, h);
  curveShape.lineTo(0, h);
  curveShape.lineTo(0, h * .8f);
  curveShape.closePath();
  // draw into the buffer a gradient (bottom to top), and the text "Login"
  final GradientPaint gp = new GradientPaint(0, h, Color.GRAY, 0, 0, Color.LIGHT_GRAY);
  g2.setPaint(gp);
  g2.fill(curveShape);
  // g2.setPaint(Color.white);
  g2.setColor(Color.WHITE);
  final float loginStringY = h * .75f;
  final float loginStringX = w * .05f;
  g2.drawString(text, loginStringX, loginStringY);
  return img;
}
 
Example 8
Source File: TextLine.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
public Shape getOutline(AffineTransform tx) {

        GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];

            dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
        }

        if (tx != null) {
            dstShape.transform(tx);
        }
        return dstShape;
    }
 
Example 9
Source File: TextLine.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public Shape getOutline(AffineTransform tx) {

        GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];

            dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
        }

        if (tx != null) {
            dstShape.transform(tx);
        }
        return dstShape;
    }
 
Example 10
Source File: StandardGlyphVector.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Used by getOutline, getGlyphsOutline
 */
private Shape getGlyphsOutline(int start, int count, float x, float y) {
    setFRCTX();
    initPositions();

    GeneralPath result = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    for (int i = start, e = start + count, n = start * 2; i < e; ++i, n += 2) {
        float px = x + positions[n];
        float py = y + positions[n+1];

        getGlyphStrike(i).appendGlyphOutline(glyphs[i], result, px, py);
    }

    return result;
}
 
Example 11
Source File: TextLine.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Shape getOutline(AffineTransform tx) {

        GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];

            dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
        }

        if (tx != null) {
            dstShape.transform(tx);
        }
        return dstShape;
    }
 
Example 12
Source File: TextLine.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public Shape getOutline(AffineTransform tx) {

        GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];

            dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
        }

        if (tx != null) {
            dstShape.transform(tx);
        }
        return dstShape;
    }
 
Example 13
Source File: StandardGlyphVector.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Used by getOutline, getGlyphsOutline
 */
private Shape getGlyphsOutline(int start, int count, float x, float y) {
    setFRCTX();
    initPositions();

    GeneralPath result = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    for (int i = start, e = start + count, n = start * 2; i < e; ++i, n += 2) {
        float px = x + positions[n];
        float py = y + positions[n+1];

        getGlyphStrike(i).appendGlyphOutline(glyphs[i], result, px, py);
    }

    return result;
}
 
Example 14
Source File: TextLine.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Shape getOutline(AffineTransform tx) {

        GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];

            dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
        }

        if (tx != null) {
            dstShape.transform(tx);
        }
        return dstShape;
    }
 
Example 15
Source File: StandardGlyphVector.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Used by getOutline, getGlyphsOutline
 */
private Shape getGlyphsOutline(int start, int count, float x, float y) {
    setFRCTX();
    initPositions();

    GeneralPath result = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    for (int i = start, e = start + count, n = start * 2; i < e; ++i, n += 2) {
        float px = x + positions[n];
        float py = y + positions[n+1];

        getGlyphStrike(i).appendGlyphOutline(glyphs[i], result, px, py);
    }

    return result;
}
 
Example 16
Source File: StandardGlyphVector.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Used by getOutline, getGlyphsOutline
 */
private Shape getGlyphsOutline(int start, int count, float x, float y) {
    setFRCTX();
    initPositions();

    GeneralPath result = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    for (int i = start, e = start + count, n = start * 2; i < e; ++i, n += 2) {
        float px = x + positions[n];
        float py = y + positions[n+1];

        getGlyphStrike(i).appendGlyphOutline(glyphs[i], result, px, py);
    }

    return result;
}
 
Example 17
Source File: StandardGlyphVector.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Used by getOutline, getGlyphsOutline
 */
private Shape getGlyphsOutline(int start, int count, float x, float y) {
    setFRCTX();
    initPositions();

    GeneralPath result = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    for (int i = start, e = start + count, n = start * 2; i < e; ++i, n += 2) {
        float px = x + positions[n];
        float py = y + positions[n+1];

        getGlyphStrike(i).appendGlyphOutline(glyphs[i], result, px, py);
    }

    return result;
}
 
Example 18
Source File: TextLine.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Shape getOutline(AffineTransform tx) {

        GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];

            dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
        }

        if (tx != null) {
            dstShape.transform(tx);
        }
        return dstShape;
    }
 
Example 19
Source File: Path.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void build() throws SVGException {
	super.build();

	final StyleAttribute sty = new StyleAttribute();

	final String fillRuleStrn = getStyle(sty.setName("fill-rule")) ? sty.getStringValue() : "nonzero";
	fillRule = fillRuleStrn.equals("evenodd") ? GeneralPath.WIND_EVEN_ODD : GeneralPath.WIND_NON_ZERO;

	if (getPres(sty.setName("d"))) {
		d = sty.getStringValue();
	}

	path = buildPath(d, fillRule);

}
 
Example 20
Source File: NestWorldMapPane.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
public static GeneralPath[] assemblePathList(GeoPos[] geoPoints) {
    final GeneralPath path = new GeneralPath(GeneralPath.WIND_NON_ZERO, geoPoints.length + 8);
    final ArrayList<GeneralPath> pathList = new ArrayList<>(16);

    if (geoPoints.length > 1) {
        double lon, lat;
        double minLon = 0, maxLon = 0;

        boolean first = true;
        for (GeoPos gp : geoPoints) {
            lon = gp.getLon();
            lat = gp.getLat();
            if (first) {
                minLon = lon;
                maxLon = lon;
                path.moveTo(lon, lat);
                first = false;
            }
            if (lon < minLon) {
                minLon = lon;
            }
            if (lon > maxLon) {
                maxLon = lon;
            }
            path.lineTo(lon, lat);
        }
        //path.closePath();

        int runIndexMin = (int) Math.floor((minLon + 180) / 360);
        int runIndexMax = (int) Math.floor((maxLon + 180) / 360);

        if (runIndexMin == 0 && runIndexMax == 0) {
            // the path is completely within [-180, 180] longitude
            pathList.add(path);
            return pathList.toArray(new GeneralPath[pathList.size()]);
        }

        final Area pathArea = new Area(path);
        final GeneralPath pixelPath = new GeneralPath(GeneralPath.WIND_NON_ZERO);
        for (int k = runIndexMin; k <= runIndexMax; k++) {
            final Area currentArea = new Area(new Rectangle2D.Float(k * 360.0f - 180.0f, -90.0f, 360.0f, 180.0f));
            currentArea.intersect(pathArea);
            if (!currentArea.isEmpty()) {
                pathList.add(areaToPath(currentArea, -k * 360.0, pixelPath));
            }
        }
    }
    return pathList.toArray(new GeneralPath[pathList.size()]);
}