001package horstmann.ch08_graphed2;
002import java.awt.BasicStroke;
003import java.awt.Stroke;
004
005/**
006   This class defines line styles of various shapes.
007 */
008public enum LineStyle
009{
010        SOLID, DOTTED;
011
012        /**
013      Gets a stroke with which to draw this line style.
014      @return the stroke object that strokes this line style
015         */
016        public Stroke getStroke()
017        {
018                if (this == DOTTED) return DOTTED_STROKE;
019                if (this == SOLID) return SOLID_STROKE;
020                return null;
021        }
022
023        private static Stroke SOLID_STROKE = new BasicStroke();
024        private static Stroke DOTTED_STROKE = new BasicStroke(
025                        1.0f,
026                        BasicStroke.CAP_SQUARE,
027                        BasicStroke.JOIN_MITER,
028                        10.0f,
029                        new float[] { 3.0f, 3.0f },
030                        0.0f);
031}