Here you can find the source of drawTriangle(Graphics2D graphics, double x, double y, double height, double width)
public static Shape drawTriangle(Graphics2D graphics, double x, double y, double height, double width)
//package com.java2s; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.geom.GeneralPath; import java.awt.geom.Path2D; public class Main { public static Shape drawTriangle(Graphics2D graphics, double x, double y, double height, double width) { final GeneralPath triangle = new GeneralPath(); triangle.setWindingRule(Path2D.WIND_EVEN_ODD); triangle.moveTo(x - (width / 2.0), y - (height / 2)); triangle.lineTo(x + (width / 2.0), y - (height / 2)); triangle.lineTo(x + (width / 2.0), y + (height / 2)); triangle.lineTo(x - (width / 2.0), y - (height / 2)); triangle.closePath();/* w ww. jav a 2s. com*/ graphics.draw(triangle); return triangle; } }