| Constructor and Description |
|---|
CoordinateSystemPainter()
Creates a new default coordinate system painter
|
| Modifier and Type | Method and Description |
|---|---|
LabelPainter |
getLabelPainterX()
Returns the
LabelPainter that is used for painting the labels
along the x-axis |
LabelPainter |
getLabelPainterY()
Returns the
LabelPainter that is used for painting the labels
along the y-axis |
void |
paint(java.awt.Graphics2D g,
java.awt.geom.AffineTransform worldToScreen,
double w,
double h)
Perform the painting operations on the given Graphics.
|
protected void |
paintAxisY(java.awt.Graphics2D g,
java.awt.geom.AffineTransform worldToScreen)
Paint the y-axis.
|
void |
setAxisColorX(java.awt.Color axisColorX)
Set the color for the x-axis.
|
void |
setAxisColorY(java.awt.Color axisColorY)
Set the color for the y-axis.
|
void |
setAxisLocationX(double worldYofX)
Set the location where the x-axis should be painted
|
void |
setAxisLocationY(double worldXofY)
Set the location where the y-axis should be painted
|
void |
setAxisRangeX(double worldMinAxisX,
double worldMaxAxisX)
Set the range of the x-axis that should be displayed.
|
void |
setAxisRangeY(double worldMinAxisY,
double worldMaxAxisY)
Set the range of the y-axis that should be displayed.
|
void |
setFixedWorldTickDistanceX(double fixedWorldTickDistanceX)
Set the fixed distance between ticks on the x-axis, in world coordinates.
|
void |
setFixedWorldTickDistanceY(double fixedWorldTickDistanceY)
Set the fixed distance between ticks on the y-axis, in world coordinates.
|
void |
setGridColorX(java.awt.Color gridColorX)
Set the color for the grid lines that should be painted at the x-axis
ticks in the background.
|
void |
setGridColorY(java.awt.Color gridColorY)
Set the color for the grid lines that should be painted at the y-axis
ticks in the background.
|
void |
setLabelFormatterX(java.util.function.DoubleFunction<java.lang.String> labelFormatterX)
Set the formatter that will receive x-values for ticks, and return
the string that should be painted at this coordinate.
|
void |
setLabelFormatterY(java.util.function.DoubleFunction<java.lang.String> labelFormatterY)
Set the formatter that will receive y-values for ticks, and return
the string that should be painted at this coordinate.
|
void |
setScreenAxisLayoutX(java.util.function.IntSupplier supplierScreenMinX,
java.util.function.IntSupplier supplierScreenMaxX,
java.util.function.IntSupplier supplierScreenY)
Set the layout for the x-axis.
|
void |
setScreenAxisLayoutY(java.util.function.IntSupplier supplierScreenMinY,
java.util.function.IntSupplier supplierScreenMaxY,
java.util.function.IntSupplier supplierScreenX)
Set the layout for the y-axis.
|
public CoordinateSystemPainter()
public LabelPainter getLabelPainterX()
LabelPainter that is used for painting the labels
along the x-axisLabelPainterpublic void setLabelFormatterX(java.util.function.DoubleFunction<java.lang.String> labelFormatterX)
labelFormatterX - The formatterpublic LabelPainter getLabelPainterY()
LabelPainter that is used for painting the labels
along the y-axisLabelPainterpublic void setLabelFormatterY(java.util.function.DoubleFunction<java.lang.String> labelFormatterY)
labelFormatterY - The formatterpublic void setFixedWorldTickDistanceX(double fixedWorldTickDistanceX)
fixedWorldTickDistanceX - The tick distancejava.lang.IllegalArgumentException - If the given distance is not positivepublic void setFixedWorldTickDistanceY(double fixedWorldTickDistanceY)
fixedWorldTickDistanceY - The tick distancejava.lang.IllegalArgumentException - If the given distance is not positivepublic void setGridColorX(java.awt.Color gridColorX)
null, then
the grid lines will not be painted.gridColorX - The grid colorpublic void setGridColorY(java.awt.Color gridColorY)
null, then
the grid lines will not be painted.gridColorY - The grid colorpublic void setAxisColorX(java.awt.Color axisColorX)
null, then
the x-axis will not be painted.axisColorX - The color for the x-axispublic void setAxisRangeX(double worldMinAxisX,
double worldMaxAxisX)
Double.NaN, then the minimum
or maximum value of the currently visible world area will be
used, respectivelyworldMinAxisX - The minimum value, in world coordinatesworldMaxAxisX - The maximum value, in world coordinatespublic void setAxisLocationX(double worldYofX)
worldYofX - The y-coordinate where the x-axis should be paintedpublic void setScreenAxisLayoutX(java.util.function.IntSupplier supplierScreenMinX,
java.util.function.IntSupplier supplierScreenMaxX,
java.util.function.IntSupplier supplierScreenY)
null,
then the axis will be painted in world coordinates.supplierScreenMinX - The supplier for the x-coordinate on the
screen where the x-axis should startsupplierScreenMaxX - The supplier for the x-coordinate on the
screen where the x-axis should endsupplierScreenY - The supplier for the y-coordinate on the
screen where the x-axis should be locatedpublic void setAxisColorY(java.awt.Color axisColorY)
null, then
the y-axis will not be painted.axisColorY - The color for the y-axispublic void setAxisRangeY(double worldMinAxisY,
double worldMaxAxisY)
Double.NaN, then the minimum
or maximum value of the currently visible world area will be
used, respectivelyworldMinAxisY - The minimum value, in world coordinatesworldMaxAxisY - The maximum value, in world coordinatespublic void setAxisLocationY(double worldXofY)
worldXofY - The x-coordinate where the y-axis should be paintedpublic void setScreenAxisLayoutY(java.util.function.IntSupplier supplierScreenMinY,
java.util.function.IntSupplier supplierScreenMaxY,
java.util.function.IntSupplier supplierScreenX)
null,
then the axis will be painted in world coordinates.supplierScreenMinY - The supplier for the y-coordinate on the
screen where the y-axis should startsupplierScreenMaxY - The supplier for the y-coordinate on the
screen where the y-axis should endsupplierScreenX - The supplier for the x-coordinate on the
screen where the y-axis should be locatedpublic final void paint(java.awt.Graphics2D g,
java.awt.geom.AffineTransform worldToScreen,
double w,
double h)
PainterGraphics instance will be passed to
all painters. No painter should make any assumptions about the state of
the Graphics object. Changes in the given Graphics object will affect
painters that are called subsequently. This refers to configuration
settings, like the rendering hints, but also to the
transform of the Graphics.Viewer. If a painter modifies these settings, then it should
either restore the original settings afterwards, or create a local
copy of the Graphics object in order to avoid interferences with
other painters.
public void paint(
Graphics2D g, AffineTransform worldToScreen, double w, double h)
{
// Store the original transform
AffineTransform oldAT = g.getTransform();
// Perform custom transforms and painting
g.translate(100,100);
g.drawLine(10,20,30,40);
...
// Restore the original transform
g.setTransform(oldAT);
}
The AffineTransform that is passed to this method
may also be the same for multiple painters. Usually, the caller
should make sure that modifications of this transform do not
affect painters that are called subsequently, but in general,
it is not recommended to internally store or modify the given
affine transform object. paint in interface Painterg - The Graphics used for paintingworldToScreen - The world-to-screen transform. This transform
encapsulates the translation, rotation and scaling of the viewer
to which this painter belongs.w - The width of the area, in screen coordinates, in which
this painter operates. This is the screen size of the viewer to
which this painter belongs.h - The height of the area, in screen coordinates, in which
this painter operates. This is the screen size of the viewer to
which this painter belongs.protected void paintAxisY(java.awt.Graphics2D g,
java.awt.geom.AffineTransform worldToScreen)
g - The graphics to paint toworldToScreen - The world-to-screen transformCopyright © 2019. All Rights Reserved.