1 package org.columba.core.print; 17 18 import java.awt.BasicStroke ; 19 import java.awt.Color ; 20 import java.awt.Graphics2D ; 21 import java.awt.Stroke ; 22 import java.awt.geom.Line2D ; 23 24 25 public class cLine extends cPrintObject { 26 private double thickness; 27 28 public cLine() { 29 super(); 30 31 thickness = 1.0; 32 color = Color.black; 33 } 34 35 public void setThickness(double t) { 36 thickness = t; 37 } 38 39 public double getThickness() { 40 return thickness; 41 } 42 43 public void print(Graphics2D g) { 44 computePositionAndSize(); 45 46 double x1 = getDrawingOrigin().getX().getPoints(); 47 double x2 = x1 + getDrawingSize().getWidth().getPoints(); 48 49 Line2D.Double line = new Line2D.Double (x1, 50 getDrawingOrigin().getY().getPoints(), x2, 51 getDrawingOrigin().getY().getPoints()); 52 53 Stroke lineStroke = new BasicStroke ((float) thickness); 54 g.setStroke(lineStroke); 55 56 Color saveForeground = g.getColor(); 57 58 g.setColor(color); 59 g.draw(line); 60 g.setColor(saveForeground); 61 } 62 63 public cSize getSize(cUnit width) { 64 cUnit height = new cPointUnit(thickness); 65 height.addI(topMargin); 66 height.addI(bottomMargin); 67 68 return new cSize(width, height); 69 } 70 } 71 | Popular Tags |