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

Java examples for java.awt:Graphics2D

Description

Draw a vertical 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 {
    /**//  ww w.  j  av  a  2s  . c  o m
     * Draw a vertical 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 addVerticalCross(Vector shapes, int x, int y,
            int crossSize, int crossGap) {
        shapes.add(new Line2D.Float(new Point(x - crossSize, y), new Point(
                x - crossGap, y)));
        shapes.add(new Line2D.Float(new Point(x + crossGap, y), new Point(x
                + crossSize, y)));
        shapes.add(new Line2D.Float(new Point(x, y - crossSize), new Point(
                x, y - crossGap)));
        shapes.add(new Line2D.Float(new Point(x, y + crossGap), new Point(
                x, y + crossSize)));
    }
}

Related Tutorials