Source code: jplot/PlotPoint.java
1 /*
2 * JPLOT -- Java Plotting Interface for any programme or
3 * as an independent GUI
4 *
5 * Copyright (C) 1999 Jan van der Lee
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 *
22 * Send bugs, suggestions or queries to <jplot@cig.ensmp.fr>
23 * The latest releases are found at
24 * http://www.cig.ensmp.fr/~vanderlee/jplot.html
25 *
26 * Initally developed for use by the Centre d'Informatique Geologique
27 * Ecole des Mines de Paris, Fontainebleau, France.
28 */
29
30 package jplot;
31
32 import java.util.*;
33 import java.awt.*;
34
35 /**
36 * The <code>PlotPoint</code> defines a plot point in terms
37 * of it's X- and Y value. Also sets the lift-pen attribute,
38 * which, if true, will lift the pen after having plot this point.
39 */
40 public class PlotPoint {
41
42 protected double x;
43 protected double y;
44 protected boolean lift;
45
46 /**
47 * Default constructor, initializes the class x- and y values.
48 * @param x x-value;
49 * @param y y-value;
50 */
51 public PlotPoint(double x, double y) {
52 setPoint(x,y);
53 lift = false;
54 }
55
56 /**
57 * Initializes the class x- and y values and sets the lift attribute.
58 * @param x x-value;
59 * @param y y-value;
60 * @param liftNow true if the pen should lift at this point
61 */
62 public PlotPoint(double x, double y, boolean liftNow) {
63 setPoint(x,y);
64 lift = liftNow;
65 }
66
67 /**
68 * Another constructor, initializes the class x- and y values.
69 * @param pp PlotPoint instance
70 */
71 public PlotPoint(PlotPoint pp) {
72 setPoint(pp);
73 lift = false;
74 }
75
76 /**
77 * Sets x- and y values.
78 * @param x x-value;
79 * @param y y-value;
80 */
81 public void setPoint(double x, double y) {
82 this.x = x;
83 this.y = y;
84 }
85
86 /**
87 * Sets x- and y values.
88 * @param pp PlotPoint instance
89 */
90 public void setPoint(PlotPoint pp) {
91 this.x = pp.getX();
92 this.y = pp.getY();
93 }
94
95 /**
96 * returns x- and y values.
97 * @return a PlotPoint instance with the current X- and Y values
98 */
99 public PlotPoint getPoint() {
100 return new PlotPoint(x,y);
101 }
102
103 /**
104 * Return the current X-value.
105 * @return the current value of x
106 */
107 public double getX() {
108 return x;
109 }
110
111 /**
112 * Return the current Y-value.
113 * @return the current value of y
114 */
115 public double getY() {
116 return y;
117 }
118
119 /**
120 * Sets whether or not the drawing pen should be lifted after this point.
121 * @param b true if the pen should lift
122 */
123 public void setLiftPen(boolean b) {
124 lift = b;
125 }
126
127 /**
128 * @return true if the pen should be lift after this point.
129 */
130 public boolean liftPen() {
131 return lift;
132 }
133 }
134