/** * Fill the specified rectangle. */ public void fillRect(double[] topLeft, double[] rightBottom) { if (!(projection instanceof Projection2D)) { throw new UnsupportedOperationException("Only 2D graphics supports drawing rectangles."); } int[] sc = projection.screenProjection(topLeft); int[] sc2 = projection.screenProjection(rightBottom); g2d.fillRect(sc[0], sc[1], sc2[0] - sc[0], sc2[1] - sc[1]); }
/** * Draw the outline of the specified rectangle. */ public void drawRect(double[] topLeft, double[] rightBottom) { if (!(projection instanceof Projection2D)) { throw new UnsupportedOperationException("Only 2D graphics supports drawing rectangles."); } int[] sc = projection.screenProjection(topLeft); int[] sc2 = projection.screenProjection(rightBottom); g2d.drawRect(sc[0], sc[1], sc2[0] - sc[0], sc2[1] - sc[1]); }
/** * Draw poly line. The coordinates are in logical coordinates. */ public void drawLine(double[]... coord) { int[][] sc = new int[coord.length][]; for (int i = 0; i < sc.length; i++) { sc[i] = projection.screenProjection(coord[i]); } drawLine(sc); }
/** * Fill polygon. The coordinates are in logical coordinates. */ public void fillPolygon(double[]... coord) { int[][] c = new int[coord.length][2]; for (int i = 0; i < coord.length; i++) { c[i] = projection.screenProjection(coord[i]); } int[] x = new int[c.length]; for (int i = 0; i < c.length; i++) { x[i] = c[i][0]; } int[] y = new int[c.length]; for (int i = 0; i < c.length; i++) { y[i] = c[i][1]; } g2d.fillPolygon(x, y, c.length); }
/** * Draw polygon. The coordinates are in logical coordinates. */ public void drawPolygon(double[]... coord) { int[][] c = new int[coord.length][2]; for (int i = 0; i < coord.length; i++) { c[i] = projection.screenProjection(coord[i]); } int[] x = new int[c.length]; for (int i = 0; i < c.length; i++) { x[i] = c[i][0]; } int[] y = new int[c.length]; for (int i = 0; i < c.length; i++) { y[i] = c[i][1]; } g2d.drawPolygon(x, y, c.length); }
/** * Draw a string with given reference point and rotation angle. (0.5, 0.5) * is center, (0, 0) is lower left, (0, 1) is upper left, etc. The angle of * rotation is in radians. The coordinates are logical coordinates. */ public void drawText(String label, double horizontalReference, double verticalReference, double rotation, double[] coord) { int[] sc = projection.screenProjection(coord); int x = sc[0]; int y = sc[1]; AffineTransform transform = g2d.getTransform(); // Corner offset adjustment : Text Offset is used Here FontRenderContext frc = g2d.getFontRenderContext(); Font font = g2d.getFont(); double w = font.getStringBounds(label, frc).getWidth(); double h = font.getSize2D(); if (rotation != 0) { g2d.rotate(rotation, x, y); } x -= (int) (w * horizontalReference); y += (int) (h * verticalReference); g2d.drawString(label, x, y); g2d.setTransform(transform); }
/** * Fill polygon. The coordinates are in logical coordinates. This also supports * basic alpha compositing rules for combining source and destination * colors to achieve blending and transparency effects with graphics and images. * * @param alpha the constant alpha to be multiplied with the alpha of the * source. alpha must be a floating point number in the inclusive range * [0.0, 1.0]. */ public void fillPolygon(float alpha, double[]... coord) { int[][] c = new int[coord.length][2]; for (int i = 0; i < coord.length; i++) { c[i] = projection.screenProjection(coord[i]); } int[] x = new int[c.length]; for (int i = 0; i < c.length; i++) { x[i] = c[i][0]; } int[] y = new int[c.length]; for (int i = 0; i < c.length; i++) { y[i] = c[i][1]; } Composite cs = g2d.getComposite(); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); g2d.fillPolygon(x, y, c.length); g2d.setComposite(cs); }
int bigSize = 4; int[] sc = projection.screenProjection(coord);
int[] xy = g.projection.screenProjection(gridLabels[1].getCoordinate()); int prevx = xy[0]; int prevy = xy[1]; if (!gridLabels[i].text.isEmpty()) { double[] coord = gridLabels[i].getCoordinate(); xy = g.projection.screenProjection(coord); int x = xy[0]; int y = xy[1];