Java Code Examples for java.awt.geom.GeneralPath#WIND_EVEN_ODD
The following examples show how to use
java.awt.geom.GeneralPath#WIND_EVEN_ODD .
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: Cursor.java From freerouting with GNU General Public License v3.0 | 6 votes |
public void draw(Graphics p_graphics) { if (!location_initialized) { return; } Graphics2D g2 = (Graphics2D)p_graphics; init_graphics(g2); GeneralPath draw_path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); draw_path.append(VERTICAL_LINE, false); draw_path.append(HORIZONTAL_LINE, false); draw_path.append(RIGHT_DIAGONAL_LINE, false); draw_path.append(LEFT_DIAGONAL_LINE, false); g2.translate(this.x_coor, this.y_coor); g2.draw(draw_path); }
Example 2
Source File: Cursor.java From Freerouting with GNU General Public License v3.0 | 6 votes |
public void draw(Graphics p_graphics) { if (!location_initialized) { return; } Graphics2D g2 = (Graphics2D)p_graphics; init_graphics(g2); GeneralPath draw_path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); draw_path.append(VERTICAL_LINE, false); draw_path.append(HORIZONTAL_LINE, false); draw_path.append(RIGHT_DIAGONAL_LINE, false); draw_path.append(LEFT_DIAGONAL_LINE, false); g2.translate(this.x_coor, this.y_coor); g2.draw(draw_path); }
Example 3
Source File: Draw.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
/** * Fill polygon * * @param points The points array * @param g Graphics2D * @param aPGB Polygon break */ public static void fillPolygon(PointF[] points, Graphics2D g, PolygonBreak aPGB) { GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length); for (int i = 0; i < points.length; i++) { if (i == 0) { path.moveTo(points[i].X, points[i].Y); } else { path.lineTo(points[i].X, points[i].Y); } } path.closePath(); if (aPGB != null) { if (aPGB.isUsingHatchStyle()) { int size = aPGB.getStyleSize(); BufferedImage bi = getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor()); Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size); g.setPaint(new TexturePaint(bi, rect)); g.fill(path); } else { g.fill(path); } } else { g.fill(path); } }
Example 4
Source File: CurtainTransitionEffect.java From weblaf with GNU General Public License v3.0 | 6 votes |
private Shape getCurtainProgressShape ( final int[] curtainProgress, final ImageTransition imageTransition ) { final GeneralPath gp = new GeneralPath ( GeneralPath.WIND_EVEN_ODD ); for ( int i = 0; i < curtainProgress.length; i++ ) { if ( direction.isVertical () ) { gp.append ( new Rectangle ( 0, i * size, imageTransition.getWidth (), curtainProgress[ i ] ), false ); } else { gp.append ( new Rectangle ( i * size, 0, curtainProgress[ i ], imageTransition.getHeight () ), false ); } } return gp; }
Example 5
Source File: Draw.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
/** * Draw polyline * * @param points The points array * @param g Graphics2D * @param mvIdx Missing value index list */ public static void drawPolyline(PointF[] points, Graphics2D g, List<Integer> mvIdx) { GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length - mvIdx.size()); boolean isNew = true; for (int i = 0; i < points.length; i++) { if (mvIdx.contains(i)) { isNew = true; continue; } if (isNew) { path.moveTo(points[i].X, points[i].Y); isNew = false; } else { path.lineTo(points[i].X, points[i].Y); } } g.draw(path); }
Example 6
Source File: Polygon.java From gama with GNU General Public License v3.0 | 5 votes |
@Override protected void build() throws SVGException { super.build(); final StyleAttribute sty = new StyleAttribute(); if (getPres(sty.setName("points"))) { pointsStrn = sty.getStringValue(); } final String fillRuleStrn = getStyle(sty.setName("fill-rule")) ? sty.getStringValue() : "nonzero"; fillRule = fillRuleStrn.equals("evenodd") ? GeneralPath.WIND_EVEN_ODD : GeneralPath.WIND_NON_ZERO; buildPath(); }
Example 7
Source File: PixelToShapeConverter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private Shape makePoly(int xPoints[], int yPoints[], int nPoints, boolean close) { GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD); if (nPoints > 0) { gp.moveTo(xPoints[0], yPoints[0]); for (int i = 1; i < nPoints; i++) { gp.lineTo(xPoints[i], yPoints[i]); } if (close) { gp.closePath(); } } return gp; }
Example 8
Source File: PixelToShapeConverter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private Shape makePoly(int xPoints[], int yPoints[], int nPoints, boolean close) { GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD); if (nPoints > 0) { gp.moveTo(xPoints[0], yPoints[0]); for (int i = 1; i < nPoints; i++) { gp.lineTo(xPoints[i], yPoints[i]); } if (close) { gp.closePath(); } } return gp; }
Example 9
Source File: PixelToShapeConverter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private Shape makePoly(int xPoints[], int yPoints[], int nPoints, boolean close) { GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD); if (nPoints > 0) { gp.moveTo(xPoints[0], yPoints[0]); for (int i = 1; i < nPoints; i++) { gp.lineTo(xPoints[i], yPoints[i]); } if (close) { gp.closePath(); } } return gp; }
Example 10
Source File: Draw.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
/** * Draw polyline * * @param points The points * @param pbc The polyline break collection * @param g Graphics2D */ public static void drawPolyline(PointF[] points, ColorBreakCollection pbc, Graphics2D g) { GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length); PointF p; PolylineBreak aPLB; List<PointF> drawPs = new ArrayList<>(); for (int i = 0; i < points.length; i++) { p = points[i]; if (i == 0) { path.moveTo(p.X, p.Y); } else { path.lineTo(p.X, p.Y); aPLB = (PolylineBreak) pbc.get(i); Color aColor = aPLB.getColor(); Float size = aPLB.getWidth(); float[] dashPattern = getDashPattern(aPLB.getStyle()); BasicStroke pen = new BasicStroke(size, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f); g.setColor(aColor); g.setStroke(pen); g.draw(path); path.reset(); path.moveTo(p.X, p.Y); //Draw symbol if (aPLB.getDrawSymbol()) { Object rend = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); for (int j = 0; j < drawPs.size(); j++) { Draw.drawPoint(aPLB.getSymbolStyle(), p, aPLB.getSymbolFillColor(), aPLB.getSymbolColor(), aPLB.getSymbolSize(), true, aPLB.isFillSymbol(), g); } g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rend); } } drawPs.add(p); } }
Example 11
Source File: PixelToShapeConverter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private Shape makePoly(int xPoints[], int yPoints[], int nPoints, boolean close) { GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD); if (nPoints > 0) { gp.moveTo(xPoints[0], yPoints[0]); for (int i = 1; i < nPoints; i++) { gp.lineTo(xPoints[i], yPoints[i]); } if (close) { gp.closePath(); } } return gp; }
Example 12
Source File: Draw.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
/** * Draw arraw * * @param g Graphics2D * @param sP Start point * @param angle Angle * @param size Arrow size */ public static void drawArraw(Graphics2D g, PointF sP, double angle, int size) { GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 5); Rectangle.Float rect = new Rectangle.Float(-size, -size, size * 2, size * 2); PointF[] pt = new PointF[5]; pt[0] = new PointF(rect.x, rect.y); pt[1] = new PointF(rect.x + rect.width, rect.y + (rect.height / 2)); pt[2] = new PointF(rect.x, rect.y + rect.height); pt[3] = new PointF(rect.x + rect.width / 2, pt[1].Y); pt[4] = pt[0]; path.moveTo(pt[0].X, pt[0].Y); for (int i = 1; i < 5; i++) { path.lineTo(pt[i].X, pt[i].Y); } AffineTransform tempTrans = g.getTransform(); if (angle != 0) { //AffineTransform myTrans = new AffineTransform(); AffineTransform myTrans = (AffineTransform) tempTrans.clone(); //myTrans.translate(tempTrans.getTranslateX() + sP.X, tempTrans.getTranslateY() + sP.Y); myTrans.translate(sP.X, sP.Y); double angle1 = angle - 90; myTrans.rotate(angle1 * Math.PI / 180); g.setTransform(myTrans); } path.closePath(); g.fill(path); if (angle != 0) { g.setTransform(tempTrans); } }
Example 13
Source File: PixelToShapeConverter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private Shape makePoly(int xPoints[], int yPoints[], int nPoints, boolean close) { GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD); if (nPoints > 0) { gp.moveTo(xPoints[0], yPoints[0]); for (int i = 1; i < nPoints; i++) { gp.lineTo(xPoints[i], yPoints[i]); } if (close) { gp.closePath(); } } return gp; }
Example 14
Source File: Draw.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
/** * Draw polyline * * @param points The points array * @param g Graphics2D */ public static void drawPolyline(PointF[] points, Graphics2D g) { GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length); for (int i = 0; i < points.length; i++) { if (i == 0) { path.moveTo(points[i].X, points[i].Y); } else { path.lineTo(points[i].X, points[i].Y); } } g.draw(path); }
Example 15
Source File: PixelToShapeConverter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private Shape makePoly(int xPoints[], int yPoints[], int nPoints, boolean close) { GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD); if (nPoints > 0) { gp.moveTo(xPoints[0], yPoints[0]); for (int i = 1; i < nPoints; i++) { gp.lineTo(xPoints[i], yPoints[i]); } if (close) { gp.closePath(); } } return gp; }
Example 16
Source File: AbstractPopupPainter.java From weblaf with GNU General Public License v3.0 | 4 votes |
/** * Creates and returns dropdown style corner shape. * It is used to paint corner fill when menu item at the same as corner side of popup menu is selected. * * @param popupMenu popup menu * @param menuSize menu size * @param fill whether it is a fill shape or not * @return dropdown style corner shape */ protected GeneralPath createDropdownCornerShape ( final C popupMenu, final Dimension menuSize, final boolean fill ) { final boolean topCorner = cornerSide == TOP; final boolean bottomCorner = cornerSide == BOTTOM; final boolean leftCorner = cornerSide == LEFT || cornerSide == LEADING; final boolean rightCorner = cornerSide == RIGHT || cornerSide == TRAILING; // Painting shear final int shear = fill ? 1 : 0; // Side width final int sideWidth = getSideWidth (); // Corner left spacing final int cornerShear = sideWidth + shear + round + cornerWidth * 2; final int length = topCorner || bottomCorner ? menuSize.width : menuSize.height; final int spacing; if ( cornerAlignment == CENTER || length < sideWidth * 2 + round * 2 + cornerWidth * 4 ) { spacing = length / 2 - sideWidth - round - cornerWidth * 2; } else if ( cornerAlignment == LEFT || cornerAlignment == LEADING && ltr || cornerAlignment == TRAILING && !ltr ) { spacing = 0; } else if ( cornerAlignment == RIGHT || cornerAlignment == TRAILING && ltr || cornerAlignment == LEADING && !ltr ) { spacing = length - cornerShear * 2; } else { spacing = relativeCorner < sideWidth + round + cornerWidth * 2 ? 0 : Math.min ( relativeCorner - cornerShear, length - cornerShear * 2 ); } // Side spacings final int top = sideWidth + shear; final int right = menuSize.width - 1 - sideWidth; final int bottom = menuSize.height - 1 - sideWidth; final int left = sideWidth + shear; final GeneralPath shape = new GeneralPath ( GeneralPath.WIND_EVEN_ODD ); if ( topCorner ) { // Top corner shape.moveTo ( left + round + spacing + cornerWidth, top ); shape.lineTo ( left + round + spacing + cornerWidth * 2, top - cornerWidth ); shape.lineTo ( left + round + spacing + cornerWidth * 2 + 1, top - cornerWidth ); shape.lineTo ( left + round + spacing + cornerWidth * 3 + 1, top ); shape.closePath (); } if ( rightCorner ) { // Right corner shape.lineTo ( right, top + round + spacing + cornerWidth ); shape.lineTo ( right + cornerWidth, top + round + spacing + cornerWidth * 2 ); shape.lineTo ( right + cornerWidth, top + round + spacing + cornerWidth * 2 + 1 ); shape.lineTo ( right, top + round + spacing + cornerWidth * 3 + 1 ); } if ( bottomCorner ) { // Bottom corner shape.moveTo ( left + round + spacing + cornerWidth * 3 + 1, bottom ); shape.lineTo ( left + round + spacing + cornerWidth * 2 + 1, bottom + cornerWidth ); shape.lineTo ( left + round + spacing + cornerWidth * 2, bottom + cornerWidth ); shape.lineTo ( left + round + spacing + cornerWidth, bottom ); shape.closePath (); } if ( leftCorner ) { // Left corner shape.lineTo ( left, top + round + spacing + cornerWidth * 3 + 1 ); shape.lineTo ( left - cornerWidth, top + round + spacing + cornerWidth * 2 + 1 ); shape.lineTo ( left - cornerWidth, top + round + spacing + cornerWidth * 2 ); shape.lineTo ( left, top + round + spacing + cornerWidth ); } return shape; }
Example 17
Source File: Draw.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
/** * Draw arraw * * @param g Graphics2D * @param sP Start point * @param angle Angle * @param length Arrow length * @param width Arrow width * @param overhang Overhang * @param fillColor Arrow fill color * @param outlineColor Arrow outline color */ public static void drawArraw(Graphics2D g, PointF sP, double angle, float length, float width, float overhang, Color fillColor, Color outlineColor) { PointF[] pt; float x = -length; float y = -width * 0.5f; //Rectangle.Float rect = new Rectangle.Float(x, y, length, width); if (overhang == 1) { pt = new PointF[3]; pt[0] = new PointF(x, y); pt[1] = new PointF(x + length, 0); pt[2] = new PointF(x, y + width); } else { pt = new PointF[5]; pt[0] = new PointF(x, y); pt[1] = new PointF(x + length, 0); pt[2] = new PointF(x, y + width); pt[3] = new PointF(x + length * overhang, pt[1].Y); pt[4] = pt[0]; } GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, pt.length); path.moveTo(pt[0].X, pt[0].Y); for (int i = 1; i < pt.length; i++) { path.lineTo(pt[i].X, pt[i].Y); } AffineTransform tempTrans = g.getTransform(); //AffineTransform myTrans = new AffineTransform(); AffineTransform myTrans = (AffineTransform) tempTrans.clone(); //myTrans.translate(tempTrans.getTranslateX() + sP.X, tempTrans.getTranslateY() + sP.Y); myTrans.translate(sP.X, sP.Y); double angle1 = angle - 90; if (angle1 != 0) { myTrans.rotate(angle1 * Math.PI / 180); } g.setTransform(myTrans); if (overhang == 1) { g.setColor(fillColor); g.draw(path); } else { if (fillColor != null) { path.closePath(); g.setColor(fillColor); g.fill(path); } if (outlineColor != null) { g.setColor(outlineColor); g.draw(path); } } g.setTransform(tempTrans); }
Example 18
Source File: PeakXICComponent.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public void paint(Graphics g) { super.paint(g); // use Graphics2D for antialiasing Graphics2D g2 = (Graphics2D) g; // turn on antialiasing g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // get canvas size Dimension size = getSize(); // get scan numbers, one data point per each scan RawDataFile dataFile = peak.getDataFile(); int scanNumbers[] = peak.getScanNumbers(); // If we have no data, just return if (scanNumbers.length == 0) return; // for each datapoint, find [X:Y] coordinates of its point in painted // image int xValues[] = new int[scanNumbers.length]; int yValues[] = new int[scanNumbers.length]; // find one datapoint with maximum intensity in each scan for (int i = 0; i < scanNumbers.length; i++) { double dataPointIntensity = 0; DataPoint dataPoint = peak.getDataPoint(scanNumbers[i]); if (dataPoint != null) dataPointIntensity = dataPoint.getIntensity(); // get retention time (X value) double retentionTime = dataFile.getScan(scanNumbers[i]).getRetentionTime(); // calculate [X:Y] coordinates final double rtLen = rtRange.upperEndpoint() - rtRange.lowerEndpoint(); xValues[i] = (int) Math.floor((retentionTime - rtRange.lowerEndpoint()) / rtLen * (size.width - 1)); yValues[i] = size.height - (int) Math.floor(dataPointIntensity / maxIntensity * (size.height - 1)); } // create a path for a peak polygon GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); path.moveTo(xValues[0], size.height - 1); // add data points to the path for (int i = 0; i < (xValues.length - 1); i++) { path.lineTo(xValues[i + 1], yValues[i + 1]); } path.lineTo(xValues[xValues.length - 1], size.height - 1); // close the path to form a polygon path.closePath(); // fill the peak area g2.setColor(XICColor); g2.fill(path); }
Example 19
Source File: AbstractGisFeature.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Convert this GisFeature to a java.awt.Shape. The data coordinate system * is in the coordinates of dataProject, and the screen is in the coordinates of * displayProject. So: * displayProject.latLonToProj( dataProject.projToLatLon(gisFeature(x,y))) -> screen(x,y). * * @param dataProject data Projection to use. * @param displayProject display Projection to use. * @return shape corresponding to this feature */ public Shape getProjectedShape(ProjectionImpl dataProject, ProjectionImpl displayProject) { ProjectionPoint lastW = ProjectionPoint.create(); GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, getNumPoints()); boolean showPts = ucar.ui.prefs.Debug.isSet("projection/showPoints"); java.util.Iterator pi = getGisParts(); while (pi.hasNext()) { GisPart gp = (GisPart) pi.next(); double[] xx = gp.getX(); double[] yy = gp.getY(); boolean skipPrev = false; int count = 0; for (int i = 0; i < gp.getNumPoints(); i++) { ProjectionPoint pt1 = ProjectionPoint.create(xx[i], yy[i]); LatLonPoint llpt = dataProject.projToLatLon(pt1); ProjectionPoint pt2 = displayProject.latLonToProj(llpt); if (showPts) { System.out.println("AbstractGisFeature getProjectedShape 2 " + xx[i] + " " + yy[i] + " === " + pt2.getX() + " " + pt2.getY()); if (displayProject.crossSeam(pt2, lastW)) System.out.println("***cross seam"); } // deal with possible NaNs if (Double.isNaN(pt2.getX()) || Double.isNaN(pt2.getY())) { skipPrev = true; continue; } if ((count == 0) || skipPrev || displayProject.crossSeam(pt2, lastW)) path.moveTo((float) pt2.getX(), (float) pt2.getY()); else path.lineTo((float) pt2.getX(), (float) pt2.getY()); count++; skipPrev = false; lastW = pt2; } } return path; }
Example 20
Source File: FeatureStateBackground.java From weblaf with GNU General Public License v3.0 | 4 votes |
@Override public void paint ( @NotNull final Graphics2D g2d, @NotNull final Rectangle bounds, @NotNull final PreviewPanel previewPanel, @NotNull final D decoration, @NotNull final Shape shape ) { final FeatureState featureState = previewPanel.getState (); if ( featureState != FeatureState.common ) { final float opacity = getOpacity ( previewPanel, decoration ); if ( opacity > 0 ) { final Composite oc = GraphicsUtils.setupAlphaComposite ( g2d, opacity, opacity < 1f ); final Object aa = GraphicsUtils.setupAntialias ( g2d ); final int shift = ( ( WebShape ) decoration.getShape () ).getRound ( previewPanel, decoration ).topLeft * 2; final Rectangle bb = shape.getBounds (); final GeneralPath gp = new GeneralPath ( GeneralPath.WIND_EVEN_ODD ); if ( previewPanel.getComponentOrientation ().isLeftToRight () ) { gp.moveTo ( bb.x, bb.y + shift ); gp.lineTo ( bb.x + shift, bb.y ); gp.lineTo ( bb.x + shift * 2, bb.y ); gp.lineTo ( bb.x, bb.y + shift * 2 ); } else { final int cornerX = bb.x + bb.width; gp.moveTo ( cornerX - shift * 2, bb.y ); gp.lineTo ( cornerX - shift, bb.y ); gp.lineTo ( cornerX, bb.y + shift ); gp.lineTo ( cornerX, bb.y + shift * 2 ); } gp.closePath (); g2d.setPaint ( getColor ( previewPanel, decoration ) ); g2d.fill ( gp ); GraphicsUtils.restoreAntialias ( g2d, aa ); GraphicsUtils.restoreComposite ( g2d, oc, opacity < 1f ); } } }