01: /*
02: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
07: *
08: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
09: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
10: * the license for the specific language governing your rights and limitations.
11: *
12: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
13: */
14: package org.pentaho.reportdesigner.crm.report.tests;
15:
16: import org.jetbrains.annotations.NotNull;
17: import org.jfree.report.util.geom.StrictGeomUtility;
18:
19: import javax.swing.*;
20: import java.awt.*;
21: import java.awt.geom.AffineTransform;
22: import java.awt.geom.Line2D;
23:
24: /**
25: * User: Martin
26: * Date: 15.02.2006
27: * Time: 20:23:05
28: */
29: @SuppressWarnings({"ALL"})
30: public class LineProblemTest {
31: public static void main(@NotNull
32: String[] args) {
33: double v = 19500 / 1000f;
34: System.out.println(Double.toHexString(v));
35:
36: double v2 = 19500 / 1000d - 0.00000000000001;
37: System.out.println(Double.toHexString(v2));
38:
39: JFrame frame = new JFrame();
40: frame.getContentPane().setLayout(new GridLayout(0, 1));
41: //frame.getContentPane().add(new JPanel()
42: //{
43: // protected void paintComponent(@NotNull Graphics g)
44: // {
45: // Graphics2D g2 = (Graphics2D) g;
46: // Line2D.Double line = new Line2D.Double(19.5, 1.5, 19.5, 31.5);
47: // g2.draw(line);
48: // }
49: //});
50:
51: frame.getContentPane().add(new JPanel() {
52: protected void paintComponent(@NotNull
53: Graphics g) {
54: Graphics2D g2 = (Graphics2D) g;
55: //Line2D.Double line1 = new Line2D.Double(17.5, 1.5, 17.5, 31.5);
56: //g2.draw(line1);
57: //
58: AffineTransform origAT = g2.getTransform();
59: ////g2.translate(23.5, 43.20000076293945);
60: //g2.transform(AffineTransform.getTranslateInstance(StrictGeomUtility.toExternalValue(19500),
61: // StrictGeomUtility.toExternalValue(1500)));
62: g2.setColor(Color.GRAY);
63: Line2D.Double line1 = new Line2D.Double(20 + 20.0 - 1,
64: 20 + 1.5, 20 + 20.0 - 1, 20 + 11.5);
65: g2.draw(line1);
66: //g2.setTransform(origAT);
67:
68: g2
69: .transform(AffineTransform.getScaleInstance(
70: 1.0, 1.0));
71: g.setColor(Color.BLACK);
72: g2.translate(-0, -0);
73: g2.transform(AffineTransform.getTranslateInstance(20.0,
74: 20.0));
75: g2.transform(AffineTransform.getTranslateInstance(
76: 0f - StrictGeomUtility.toExternalValue(0L),
77: 0f - StrictGeomUtility.toExternalValue(0L)));
78: g2.transform(AffineTransform.getTranslateInstance(
79: StrictGeomUtility.toExternalValue(19500L),
80: StrictGeomUtility.toExternalValue(1500L)));
81: Line2D.Double line = new Line2D.Double(0.5, 0.0, 0.5,
82: 10);
83: g2.draw(line);
84: g2.transform(AffineTransform.getTranslateInstance(
85: 0 - 20.0 + 0.0, 0 - 20.0 + 0.0));
86: g2.setTransform(AffineTransform.getTranslateInstance(
87: 20, 20));
88: g2.setTransform(origAT);
89: }
90: });
91:
92: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
93: frame.setBounds(200, 200, 300, 100);
94: frame.setVisible(true);
95:
96: }
97: }
|