List of usage examples for java.awt Graphics drawLine
public abstract void drawLine(int x1, int y1, int x2, int y2);
(x1, y1)
and (x2, y2)
in this graphics context's coordinate system. From source file:MyCanvas.java
public void paint(Graphics g) { g.drawLine(20, 20, 200, 200); }
From source file:MainClass.java
public void paint(Graphics g) { g.drawLine(25, 25, 120, 120); }
From source file:org.kalypso.ogc.gml.map.widgets.advanced.utils.GeometryPainter.java
public static void drawLineString(final IMapPanel mapPanel, final Graphics g, final Point[] myPoints, final Color color) throws GM_Exception { final List<java.awt.Point> awtPoints = new ArrayList<>(); final Set<Coordinate> coordinates = new LinkedHashSet<>(); for (final Point point : myPoints) { coordinates.add(point.getCoordinate()); final GM_Point gmp = (GM_Point) JTSAdapter.wrap(point); final java.awt.Point awt = MapUtilities.retransform(mapPanel, gmp); awtPoints.add(awt);/*from w ww .j ava 2 s .co m*/ } final Color original = g.getColor(); g.setColor(color); for (int i = 0; i < awtPoints.size() - 1; i++) { final java.awt.Point p1 = awtPoints.get(i); final java.awt.Point p2 = awtPoints.get(i + 1); g.drawLine(Double.valueOf(p1.getX()).intValue(), Double.valueOf(p1.getY()).intValue(), Double.valueOf(p2.getX()).intValue(), Double.valueOf(p2.getY()).intValue()); } g.setColor(original); }
From source file:XORModePaintWithMouse.java
public void paint(Graphics g) { g.drawLine(0, 0, 100, 100); g.drawLine(0, 100, 100, 0);// ww w . j av a2 s. c om g.setColor(Color.blue); g.drawLine(40, 25, 250, 180); g.drawLine(75, 90, 400, 400); g.setColor(Color.green); // xor cross hairs g.setXORMode(Color.black); g.drawLine(chsX - 10, chsY, chsX + 10, chsY); g.drawLine(chsX, chsY - 10, chsX, chsY + 10); g.setPaintMode(); }
From source file:Main.java
protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawLine(x1, y1, x2, y2); }
From source file:com.klwork.common.utils.WebUtils.java
/** * ???/* w w w . j a va2s .com*/ * @param request * @param response */ public static void VerificationCode(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); // int width = 60, height = 20; BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ? Graphics g = image.getGraphics(); // ?? Random random = new Random(); // g.setColor(getRandColor(200, 250)); g.fillRect(0, 0, width, height); // g.setFont(new Font("Times New Roman", Font.PLAIN, 18)); // // g.setColor(new Color()); // g.drawRect(0,0,width-1,height-1); // ?155????? g.setColor(getRandColor(160, 200)); for (int i = 0; i < 155; i++) { int x = random.nextInt(width); int y = random.nextInt(height); int xl = random.nextInt(12); int yl = random.nextInt(12); g.drawLine(x, y, x + xl, y + yl); } String base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQUSTUVWXYZ0123456789"; // ????(4?) String sRand = ""; for (int i = 0; i < 4; i++) { int start = random.nextInt(base.length()); String rand = base.substring(start, start + 1); sRand = sRand.concat(rand); // ?? g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110))); g.drawString(rand, 13 * i + 6, 16); } // ??SESSION request.getSession().setAttribute("entrymrand", sRand); // g.dispose(); OutputStream out = response.getOutputStream(); // ? ImageIO.write(image, "JPEG", out); out.flush(); out.close(); }
From source file:Main.java
public void add(int dx, int dy) { endPoint.x += dx;//from www . j ava2 s .c o m endPoint.y += dy; Graphics g = getGraphics(); g.drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y); g.dispose(); startPoint.x = endPoint.x; startPoint.y = endPoint.y; }
From source file:Main.java
public void paint(Graphics g) { super.paint(g); Rectangle r = g.getClipBounds(); g.drawLine(0, 0, r.width, r.height); }
From source file:Main.java
public void paint(Graphics g) { g.drawString(s, x, y); g.drawLine(x, y + 2, x + getFontMetrics(getFont()).stringWidth(s), y + 2); }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.red);//from w ww. j a va 2 s. c om g.drawLine(0, 0, getWidth(), getHeight()); g.drawLine(getWidth(), 0, 0, getHeight()); }