01: import java.awt.*; 02: import java.awt.geom.*; 03: 04: /** 05: An edge that is shaped like a straight line. 06: */ 07: public class LineEdge extends AbstractEdge 08: { 09: public LineEdge() 10: { 11: lineStyle = LineStyle.SOLID; 12: } 13: 14: public void draw(Graphics2D g2) 15: { 16: Stroke oldStroke = g2.getStroke(); 17: g2.setStroke(lineStyle.getStroke()); 18: g2.draw(getConnectionPoints()); 19: g2.setStroke(oldStroke); 20: } 21: 22: public boolean contains(Point2D aPoint) 23: { 24: final double MAX_DIST = 2; 25: return getConnectionPoints().ptSegDist(aPoint) 26: < MAX_DIST; 27: } 28: 29: /** 30: Sets the line style property. 31: @param newValue the new value 32: */ 33: public void setLineStyle(LineStyle newValue) { lineStyle = newValue; } 34: 35: /** 36: Gets the line style property. 37: @return the line style 38: */ 39: public LineStyle getLineStyle() { return lineStyle; } 40: 41: private LineStyle lineStyle; 42: }