Here you can find the source of drawFilledOctagon(Graphics2D g, int x, int y, float size)
Parameter | Description |
---|---|
g | The graphics context to use |
x | The x position to draw at |
y | The y position to draw at |
size | The size of the octagon (width and height) |
public static void drawFilledOctagon(Graphics2D g, int x, int y, float size)
//package com.java2s; //License from project: Open Source License import java.awt.*; import java.awt.geom.*; public class Main { protected static Polygon octagon = null; /**/* www.ja v a2 s . c om*/ * Draw a filled octagon at the specified position with the specified size * @param g The graphics context to use * @param x The x position to draw at * @param y The y position to draw at * @param size The size of the octagon (width and height) */ public static void drawFilledOctagon(Graphics2D g, int x, int y, float size) { if (octagon == null) { octagon = new Polygon(); octagon.addPoint(-3, -7); // 1 octagon.addPoint(3, -7); // 2 octagon.addPoint(7, -3); // 3 octagon.addPoint(7, 3); // 4 octagon.addPoint(3, 7); // 5 octagon.addPoint(-3, 7); // 6 octagon.addPoint(-7, 3); // 7 octagon.addPoint(-7, -3); // 8 } AffineTransform oldTransform = g.getTransform(); g.transform(AffineTransform.getTranslateInstance(x, y)); g.transform(AffineTransform.getScaleInstance(size / 14, size / 14)); g.fill(octagon); g.setTransform(oldTransform); } }