1: import java.awt.*; 2: import java.io.*; 4: /** 5: This class defines line styles of various shapes. 6: */ 7: public enum LineStyle 8: { 9: SOLID, DOTTED; 11: /** 12: Gets a stroke with which to draw this line style. 13: @return the stroke object that strokes this line style 14: */ 15: public Stroke getStroke() 16: { 17: if (this == DOTTED) return DOTTED_STROKE; 18: if (this == SOLID) return SOLID_STROKE; 19: return null; 20: } 22: private static Stroke SOLID_STROKE = new BasicStroke(); 23: private static Stroke DOTTED_STROKE = new BasicStroke( 24: 1.0f, 25: BasicStroke.CAP_SQUARE, 26: BasicStroke.JOIN_MITER, 27: 10.0f, 28: new float[] { 3.0f, 3.0f }, 29: 0.0f); 30: }