List of usage examples for java.awt Graphics drawPolygon
public abstract void drawPolygon(int[] xPoints, int[] yPoints, int nPoints);
From source file:MyCanvas.java
public void paint(Graphics g) { int[] x = new int[] { 100, 200, 300, 400 }; int[] y = new int[] { 400, 300, 300, 100 }; g.drawPolygon(x, y, x.length); }
From source file:Main.java
public void paint(Graphics g) { int xpoints[] = { 25, 145, 25, 145, 25 }; int ypoints[] = { 25, 25, 145, 145, 25 }; int npoints = 5; g.drawPolygon(xpoints, ypoints, npoints); }
From source file:com.cburch.draw.shapes.Poly.java
@Override public void paint(Graphics g, HandleGesture gesture) { List<Handle> hs = getHandles(gesture); int[] xs = new int[hs.size()]; int[] ys = new int[hs.size()]; int i = -1;// w ww . jav a 2 s . c om for (Handle h : hs) { i++; xs[i] = h.getX(); ys[i] = h.getY(); } if (setForFill(g)) { g.fillPolygon(xs, ys, xs.length); } if (setForStroke(g)) { if (closed) g.drawPolygon(xs, ys, xs.length); else g.drawPolyline(xs, ys, xs.length); } }
From source file:edu.umn.cs.spatialHadoop.core.OGCESRIShape.java
@Override public void draw(Graphics g, Rectangle fileMBR, int imageWidth, int imageHeight, double scale) { OGCGeometry geom = this.geom; Color shape_color = g.getColor(); if (geom instanceof OGCGeometryCollection) { OGCGeometryCollection geom_coll = (OGCGeometryCollection) geom; for (int i = 0; i < geom_coll.numGeometries(); i++) { OGCGeometry sub_geom = geom_coll.geometryN(i); // Recursive call to draw each geometry new OGCESRIShape(sub_geom).draw(g, fileMBR, imageWidth, imageHeight, scale); }//ww w .j a v a 2 s . co m } else if (geom.getEsriGeometry() instanceof MultiPath) { MultiPath path = (MultiPath) geom.getEsriGeometry(); double sub_geom_alpha = path.calculateLength2D() * scale; int color_alpha = sub_geom_alpha > 1.0 ? 255 : (int) Math.round(sub_geom_alpha * 255); if (color_alpha == 0) return; int[] xpoints = new int[path.getPointCount()]; int[] ypoints = new int[path.getPointCount()]; for (int i = 0; i < path.getPointCount(); i++) { double px = path.getPoint(i).getX(); double py = path.getPoint(i).getY(); // Transform a point in the polygon to image coordinates xpoints[i] = (int) Math.round((px - fileMBR.x1) * imageWidth / fileMBR.getWidth()); ypoints[i] = (int) Math.round((py - fileMBR.y1) * imageHeight / fileMBR.getHeight()); } // Draw the polygon g.setColor(new Color((shape_color.getRGB() & 0x00FFFFFF) | (color_alpha << 24), true)); if (path instanceof Polygon) g.drawPolygon(xpoints, ypoints, path.getPointCount()); else if (path instanceof Polyline) g.drawPolyline(xpoints, ypoints, path.getPointCount()); } }
From source file:MyJava3D.java
public void drawFacet(Graphics graphics, GeometryArray geometryArray, int index, Point3d[] pointArray, int numPoints) { int intensity = computeIntensity(geometryArray, index, numPoints); if (drawBackface || intensity >= 1) { for (int n = 0; n < numPoints; n++) { xCoordArray[n] = (int) pointArray[n].x; yCoordArray[n] = (int) pointArray[n].y; }/*from w w w . j av a2 s . c om*/ graphics.setColor(new Color(intensity, intensity, intensity)); graphics.drawPolygon(xCoordArray, yCoordArray, numPoints); } }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.ElementGeometryBuilder.java
public void paint(final Graphics g, final GeoTransform projection, final Point currentPoint) { // IMPORTANT: we remember GM_Points (not Point's) and re-transform them for painting // because the projection depends on the current map-extent, so this builder // is stable in regard to zoom in/out final int[][] points = UtilMap.getPointArrays(currentPoint, m_nodes, projection); final int[] arrayX = points[0]; final int[] arrayY = points[1]; /* Paint a linestring. */ final Color color = g.getColor(); Color preViewColor;/*from www . ja v a2 s . c om*/ if (m_valid == true) preViewColor = new Color(100, 255, 100); else preViewColor = new Color(255, 100, 100); g.setColor(preViewColor); g.drawPolygon(arrayX, arrayY, arrayX.length); UtilMap.drawHandles(g, arrayX, arrayY); g.setColor(color); }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.grid.LinePointCollector.java
public void paint(final Graphics g, final GeoTransform projection, final GM_Point currentPoint, final int pointRectSize) { // IMPORTANT: we remeber GM_Points (not Point's) and retransform them for painting // because the projection depends on the current map-extent, so this builder // is stable in regard to zoom in/out if (!m_points.isEmpty()) { if (m_isSelected) { final int[][] points = getPointArrays(projection, null); final int[][] polygonPoints = toPolygonPoints(points, highlightDeltaX); g.drawPolygon(polygonPoints[0], polygonPoints[1], polygonPoints[0].length); g.fillPolygon(polygonPoints[0], polygonPoints[1], polygonPoints[0].length); drawHandles(g, points[0], points[1], pointRectSize, m_selection); } else {//from w w w .j av a2s .c o m // draw a line final int[][] points = getPointArrays(projection, currentPoint); final int[] arrayX = points[0]; final int[] arrayY = points[1]; /* Paint a linestring. */ g.drawPolyline(arrayX, arrayY, arrayX.length); drawHandles(g, arrayX, arrayY, pointRectSize, m_selection); } } }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.RefineFEGeometryWidget.java
@Override public void paint(final Graphics g) { /* always paint a small rectangle of current position */ if (m_currentMapPoint == null) return;/* w w w .jav a 2 s .c o m*/ final int[][] posPoints = UtilMap.getPointArrays(m_currentMapPoint); final int[] arrayX = posPoints[0]; final int[] arrayY = posPoints[1]; /* Paint as linestring. */ g.drawPolygon(arrayX, arrayY, arrayX.length); UtilMap.drawHandles(g, arrayX, arrayY); /* paint the snap */ if (m_pointSnapper != null) m_pointSnapper.paint(g); super.paint(g); final IMapPanel mapPanel = getMapPanel(); final Rectangle bounds = mapPanel.getScreenBounds(); final GeoTransform projection = mapPanel.getProjection(); m_toolTipRenderer.paintToolTip(new Point(5, bounds.height - 5), g, bounds); if (m_warning == true) m_warningRenderer.paintToolTip(new Point(5, bounds.height - 80), g, bounds); if (m_geometryBuilder != null) m_geometryBuilder.paint(g, projection, m_currentMapPoint); try { if (!ArrayUtils.isEmpty(m_objects)) drawRefinement(g, projection); } catch (final Exception e) { e.printStackTrace(); } }
From source file:org.kalypso.ogc.gml.map.widgets.AbstractCreateGeometeryWidget.java
/** * @see org.kalypso.ogc.gml.map.widgets.AbstractWidget#paint(java.awt.Graphics) *//*from w w w . j av a 2 s . co m*/ @Override public void paint(final Graphics g) { if (!canEdit()) return; if (!m_points.isEmpty() && m_currentPoint != null) { final int[][] lArrPositionToDrow = getXYArrayPixel(); final int[] arrayX = lArrPositionToDrow[0]; final int[] arrayY = lArrPositionToDrow[1]; final Class<? extends GM_Object> geoClass = getGeometryClass(); if (geoClass == GeometryUtilities.getPolygonClass()) { // paint polygon g.drawPolygon(arrayX, arrayY, arrayX.length); drawHandles(g, arrayX, arrayY); } else if (geoClass == GeometryUtilities.getLineStringClass()) { // paint linestring g.drawPolyline(arrayX, arrayY, arrayX.length); drawHandles(g, arrayX, arrayY); } else if (geoClass == GeometryUtilities.getPointClass()) { drawHandles(g, arrayX, arrayY); } } }
From source file:org.kalypso.ogc.gml.map.widgets.builders.PolygonGeometryBuilder.java
@Override public void paint(final Graphics g, final GeoTransform projection, final Point currentPoint) { // IMPORTANT: we remember GM_Points (not Point's) and retransform them for painting // because the projection depends on the current map-extent, so this builder // is stable in regard to zoom in/out if (!m_points.isEmpty()) { final int[][] points = getPointArrays(projection, currentPoint); final int[] arrayX = points[0]; final int[] arrayY = points[1]; /* Paint a polygon. */ g.drawPolygon(arrayX, arrayY, arrayX.length); drawHandles(g, arrayX, arrayY);/*www. jav a2s . c o m*/ } m_renderer.paint(g); }