public final class PlotPoint
extends java.lang.Object
implements java.io.Serializable
Represents a single point on the plot.
This class is final because extending it is prone to introducing bugs.
For example consider this case: you want to have some extra fields on PlotPoints. You create a class PointExt that extends PlotPoint and adds some fields. Then you play with it a bit and finally you change color of the point. But you accidentally change color the PointExt point instead of PlotPoint and it has no effect.
The solution is to add original PlotPoint as PointExt's field, but then what's the point of extending PlotPoint if you can simply manipulate the underlying point?
Constructor and Description |
---|
PlotPoint(double x,
double y)
Creates point with default color.
|
PlotPoint(double x,
double y,
javafx.scene.paint.Color color) |
Modifier and Type | Method and Description |
---|---|
double |
distanceFrom(double x,
double y)
Calculate distance from this point to provided coordinate.
|
javafx.scene.paint.Color |
getColor() |
double |
getX() |
double |
getY() |
void |
moveTo(double x,
double y)
Change both coordinates of this point at once.
|
void |
setColor(javafx.scene.paint.Color color)
Change this point's color.
|
void |
setX(double x)
Change X coordinate of this point.
|
void |
setY(double y)
Change Y coordinate of this point.
|
java.lang.String |
toString() |
public PlotPoint(double x, double y)
x
- X coordinatey
- Y coordinatepublic PlotPoint(double x, double y, javafx.scene.paint.Color color)
x
- X coordinatey
- Y coordinatecolor
- point colorpublic double getX()
public void setX(double x)
x
- new X coordinate valuepublic double getY()
public void setY(double y)
y
- new Y coordinate valuepublic void moveTo(double x, double y)
x
- new X coordinate valuey
- new Y coordinate valuepublic javafx.scene.paint.Color getColor()
public void setColor(javafx.scene.paint.Color color)
color
- new colorpublic double distanceFrom(double x, double y)
x
- X coordinate of the second pointy
- Y coordinate of the second pointpublic java.lang.String toString()
toString
in class java.lang.Object