01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16: 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: public class cLine extends cPrintObject {
25: private double thickness;
26:
27: public cLine() {
28: super ();
29:
30: thickness = 1.0;
31: color = Color.black;
32: }
33:
34: public void setThickness(double t) {
35: thickness = t;
36: }
37:
38: public double getThickness() {
39: return thickness;
40: }
41:
42: public void print(Graphics2D g) {
43: computePositionAndSize();
44:
45: double x1 = getDrawingOrigin().getX().getPoints();
46: double x2 = x1 + getDrawingSize().getWidth().getPoints();
47:
48: Line2D.Double line = new Line2D.Double(x1, getDrawingOrigin()
49: .getY().getPoints(), x2, getDrawingOrigin().getY()
50: .getPoints());
51:
52: Stroke lineStroke = new BasicStroke((float) thickness);
53: g.setStroke(lineStroke);
54:
55: Color saveForeground = g.getColor();
56:
57: g.setColor(color);
58: g.draw(line);
59: g.setColor(saveForeground);
60: }
61:
62: public cSize getSize(cUnit width) {
63: cUnit height = new cPointUnit(thickness);
64: height.addI(topMargin);
65: height.addI(bottomMargin);
66:
67: return new cSize(width, height);
68: }
69: }
|