Draw a diagonal cross at a specified location with a gap around the center - Java java.awt

Java examples for java.awt:Graphics2D

Description

Draw a diagonal cross at a specified location with a gap around the center

Demo Code

/* Copyright (c) 2001-2011, David A. Clunie DBA Pixelmed Publishing. All rights reserved. */
//package com.java2s;

import java.awt.Point;

import java.awt.geom.Line2D;
import java.util.Vector;

public class Main {
    /**//from   w  ww  . ja va2  s .  c om
     * Draw a diagonal cross at a specified location with a gap around the center
     *
     * @param   shapes      a vector of Shape to add to
     * @param   x         the x cross center
     * @param   y         the y cross center
     * @param   crossSize   the length of one arm of the cross from end to center
     * @param   crossGap   the gap in one arm of the cross from end to center (included in crossSize)
     */
    public static void addDiagonalCross(Vector shapes, int x, int y,
            int crossSize, int crossGap) {
        shapes.add(new Line2D.Float(
                new Point(x - crossSize, y - crossSize), new Point(x
                        - crossGap, y - crossGap)));
        shapes.add(new Line2D.Float(new Point(x + crossGap, y + crossGap),
                new Point(x + crossSize, y + crossSize)));
        shapes.add(new Line2D.Float(
                new Point(x + crossSize, y - crossSize), new Point(x
                        + crossGap, y - crossGap)));
        shapes.add(new Line2D.Float(new Point(x - crossGap, y + crossGap),
                new Point(x - crossSize, y + crossSize)));
    }
}

Related Tutorials