Class ContourPlot.CoordSysRenderer
- All Implemented Interfaces:
ContourPlot.PDFRenderer,ContourPlot.Renderer
- Enclosing class:
ContourPlot
ContourPlot.Renderer that displays a coordinate system.
This coordinate system is enclosed by 4 axes that form a rectangle around the
area that displays the contents of the coordinate system.
The upper x-axis and right y-axis feature the labels (names) of the axes.
The lower x-axis and the left y-axis feature tick marks and labels that
help to orientate and read off coordinates.
The positioning and labeling of the tick marks is done by a ContourPlot.TickMarkGenerator
which is per default an instance of ContourPlot.ExtendedWilkinson.
For each tick a vertical or horizontal guide line is drawn across the area of the
coordinate system.
What coordinate range the coordinate system area corresponds to is controlled by
the coordinate view (see setCoordinateView(double, double, double, double))
and defaults to [-1,1] for both axes.
The contents that are drawn inside the coordinate area are rendered by the content renderer
(see setContent(Renderer)).
If that renderer implements the ContourPlot.AdaptableView interface it will be passed the
view matrix corresponding to the coordinate view.
The content renderer will be able to draw within the viewport defined by the coordinate
system area of this CoordSysRenderer.
Optionally a ContourPlot.Renderer for drawing a legend (such as the ContourPlot.Legend class)
can be set to either the bottom or right hand side of the coordinate system (can also
use both areas at once).
Use
invalid reference
#setLegendBottom(Renderer)setLegendRight(Renderer) to do so.
The legend area size can be partially controlled by
invalid reference
#setLegendBottomHeight(int)setLegendRightWidth(int) if this is needed.
The overlay renderer (
invalid reference
#setOverlay(Renderer)
For interacting with this ContourPlot.CoordSysRenderer there already exist implementations of MouseListeners
for panning and zooming (see ContourPlot.CoordSysPanning and ContourPlot.CoordSysScrollZoom).
- Author:
- hageldave
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ContourPlot.Linesprotected ContourPlot.ColorSchemeprotected ContourPlot.Rendererprotected Rectangle2Dprotected ContourPlot.PointeredPoint2Dprotected ContourPlot.PointeredPoint2Dprotected ContourPlot.PointeredPoint2Dprotected ContourPlot.PointeredPoint2Dprotected ActionListenerprotected Rectangleprotected IntSupplierprotected ContourPlot.Linesprotected booleanprotected booleanprotected ContourPlot.Rendererprotected intprotected Rectangleprotected ContourPlot.Rendererprotected Rectangleprotected intprotected ContourPlot.Rendererprotected intprotected intprotected intprotected intprotected ContourPlot.LinesRendererprotected ContourPlot.TextRendererprotected ContourPlot.LinesRendererprotected ContourPlot.TextRendererprotected IntSupplierprotected IntSupplierprotected ContourPlot.TickMarkGeneratorprotected LinkedList<ContourPlot.Text> protected ContourPlot.Linesprotected intprotected intprotected Stringprotected ContourPlot.Textprotected double[]protected Stringprotected ContourPlot.Textprotected double[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds aContourPlot.CoordinateViewListenerto this renderer which will be notified whenever the coordinate view changes (i.e. whensetCoordinateView(double, double, double, double)is called)Returns the coordinate view, which is the range of x and y coordinates visible in the coordinate system.booleanWhether this renderer is enabled or not.Removes the specifiedContourPlot.CoordinateViewListenerfrom this renderer.voidrenderFallback(Graphics2D g, Graphics2D p, int w, int h) Renders thisContourPlot.Renderer's 'scene'.voidrenderPDF(org.apache.pdfbox.pdmodel.PDDocument doc, org.apache.pdfbox.pdmodel.PDPage page, int x, int y, int w, int h) Renders this PDFRenderers contents, that is creating pdf elements and appending them to the specified page within the corresponding document.setContent(ContourPlot.Renderer content) Sets the content renderer that will draw into the area of the coordinate system.setCoordinateView(double minX, double minY, double maxX, double maxY) Sets the coordinate view.setCoordinateView(Rectangle2D viewRect) Sets the coordinate view.protected ContourPlot.CoordSysRenderersetCoordinateViewRect(double x, double y, double w, double h) voidsetDirty()Sets theisDirtystate of this CoordSysRenderer to true.setLegendRight(ContourPlot.Renderer legend) Sets the renderer that will draw the legend to the right of the coordinate system.setLegendRightWidth(int legendRightWidth) Sets the width of the legend area right to the coordinate system.protected voidSets up pretty much everything.protected voidHelper method to setup the CoordSysRenderertransformAWT2CoordSys(Point2D awtPoint, int canvasheight) Transforms a location in AWT coordinates (y axis extends to bottom) on this renderer to the corresponding coordinates in the coordinate system view (in GL coords).transformGL2CoordSys(Point2D point) Transforms a location in GL coordinates on this renderer to the corresponding coordinates in the coordinate system view.protected ContourPlot.CoordSysRendererHelper method to update the colors if the color scheme is changed.protected void
-
Field Details
-
preContentLinesR
-
preContentTextR
-
postContentLinesR
-
postContentTextR
-
overlay
-
-
legendRight
-
legendBottom
-
legendRightWidth
protected int legendRightWidth -
legendBottomHeight
protected int legendBottomHeight -
legendRightViewPort
-
legendBottomViewPort
-
currentViewPort
-
coordinateView
-
tickMarkGenerator
-
axes
-
ticks
-
guides
-
tickMarkLabels
-
xAxisLabelText
-
yAxisLabelText
-
xticks
protected double[] xticks -
yticks
protected double[] yticks -
viewportwidth
protected int viewportwidth -
viewportheight
protected int viewportheight -
isDirty
protected boolean isDirty -
tickColor
-
guideColor
-
textColor
-
paddingLeft
protected int paddingLeft -
paddingRight
protected int paddingRight -
paddingTop
protected int paddingTop -
paddingBot
protected int paddingBot -
coordsysAreaLB
-
coordsysAreaRT
-
coordsysAreaLT
-
coordsysAreaRB
-
xAxisLabel
-
yAxisLabel
-
coordviewListener
-
isEnabled
protected boolean isEnabled -
colorScheme
-
-
Constructor Details
-
CoordSysRenderer
public CoordSysRenderer()Sets up a CoordSysRenderer with the default color scheme
-
-
Method Details
-
setupCoordSysRenderer
protected void setupCoordSysRenderer()Helper method to setup the CoordSysRenderer -
updateColors
Helper method to update the colors if the color scheme is changed.- Returns:
- this for chaining
-
setDirty
public void setDirty()Sets theisDirtystate of this CoordSysRenderer to true. This indicates that axis locations, tick marks, labels and guides have to be recomputed. The recomputing will be done duringwhich will set the isDirty state back to false.invalid reference
#render(int, int, int, int) -
updateLegendColorScheme
- Parameters:
legend- color scheme of the legend will be updated if it is from typeContourPlot.Legend
-
getColorScheme
- Returns:
- the
ContourPlot.ColorSchemeof the CoordSysRenderer.
-
setupAndLayout
protected void setupAndLayout()Sets up pretty much everything.- the bounds of the coordinate system frame (
coordsysAreaLB,coordsysAreaRT) - the tick mark values and labels
- the tick mark guides
- the location of the axis labels
- the areas for the legends (right and bottom legend)
- the bounds of the coordinate system frame (
-
renderFallback
Description copied from interface:ContourPlot.RendererRenders thisContourPlot.Renderer's 'scene'. This is the fallback path in case OpenGL based rendering throughis not available.invalid reference
#render(int, int, int, int)- Specified by:
renderFallbackin interfaceContourPlot.Renderer- Parameters:
g- main graphics object for drawing onto the framebufferp- graphics object for drawing onto the picking framebuffer (invisible but used for picking)w- width of the current viewport in pixelsh- height of the current viewport in pixels
-
renderPDF
public void renderPDF(org.apache.pdfbox.pdmodel.PDDocument doc, org.apache.pdfbox.pdmodel.PDPage page, int x, int y, int w, int h) Description copied from interface:ContourPlot.PDFRendererRenders this PDFRenderers contents, that is creating pdf elements and appending them to the specified page within the corresponding document.- Specified by:
renderPDFin interfaceContourPlot.PDFRenderer- Parameters:
doc- the PDF document holding the pagepage- page in pdf doc to which elements are to be appendedx- x coordinate of the current viewporty- y coordinate of the current viewportw- width of the current viewporth- height of the current viewport
-
isEnabled
public boolean isEnabled()Description copied from interface:ContourPlot.RendererWhether this renderer is enabled or not. By default a renderer is enabled and will render uponorinvalid reference
#render(int, int, int, int). When disabled those methods return right away and will not render anything.invalid reference
#renderSVG(org.w3c.dom.Document, org.w3c.dom.Element, int, int)- Specified by:
isEnabledin interfaceContourPlot.Renderer- Returns:
- true when active
-
getxAxisLabel
- Returns:
- "X" if
xAxisLabelis null or the actual axis label.
-
getyAxisLabel
- Returns:
- "Y" if
yAxisLabelis null or the actual axis label.
-
setCoordinateView
public ContourPlot.CoordSysRenderer setCoordinateView(double minX, double minY, double maxX, double maxY) Sets the coordinate view. This is the range of x and y coordinates that is displayed by thisContourPlot.CoordSysRenderer. It is not the rectangular area in which the content appears on screen but what coordinates that area corresponds to as a coordinate system.This determines what range of coordinates is visible when rendering the
content. By default the coordinate view covers the range [-1,1] for both x and y coordinates. When the resulting value ranges maxX-minX or maxY-minY fall below 1e-9, the method refuses to set the view accordingly to prevent unrecoverable zooming and inaccurate or broken renderings due to floating point precision.This method also sets the
isDirtystate of thisContourPlot.CoordSysRendererto true.When
ContourPlot.CoordinateViewListenerare registered to this renderer, they will be notified before this method returns.- Parameters:
minX- minimum x coordinate visible in the coordinate systemminY- minimum y coordinate visible in the coordinate systemmaxX- maximum x coordinate visible in the coordinate systemmaxY- maximum y coordinate visible in the coordinate system- Returns:
- this for chaining
-
setCoordinateView
Sets the coordinate view. This is the range of x and y coordinates that is displayed by thisContourPlot.CoordSysRenderer. It is not the rectangular area in which the content appears on screen but what coordinates that area corresponds to as a coordinate system.- Parameters:
viewRect- to set the view to- Returns:
- this for chaining
-
setCoordinateViewRect
protected ContourPlot.CoordSysRenderer setCoordinateViewRect(double x, double y, double w, double h) -
addCoordinateViewListener
Adds aContourPlot.CoordinateViewListenerto this renderer which will be notified whenever the coordinate view changes (i.e. whensetCoordinateView(double, double, double, double)is called)- Parameters:
l- listener- Returns:
- this for chaining
-
removeActionListener
Removes the specifiedContourPlot.CoordinateViewListenerfrom this renderer.- Parameters:
l- listener- Returns:
- this for chaining
-
getCoordinateView
Returns the coordinate view, which is the range of x and y coordinates visible in the coordinate system. SeesetCoordinateView(double, double, double, double).- Returns:
- the coordinate view
-
setContent
Sets the content renderer that will draw into the area of the coordinate system.- Parameters:
content- the content renderer- Returns:
- the previous content renderer (which may need to be closed to free GL resources), null if none was set
-
setLegendRight
Sets the renderer that will draw the legend to the right of the coordinate system. The view port area for this renderer will start at the top edge of the coordinate system, bewide and extend to the bottom (-padding).invalid reference
#getLegendRightWidth()- Parameters:
legend- renderer for right side of coordinate system- Returns:
- the previous legend renderer (which may need to be closed to free GL resources), null if none was set
-
setLegendRightWidth
Sets the width of the legend area right to the coordinate system. (height is determined by the space available until the bottom of the renderer's viewport)- Parameters:
legendRightWidth- width of the right legend area. (default is 70 px)- Returns:
- this for chaining
-
getCoordSysArea
- Returns:
- the area of this renderer in which the coordinate system contents are rendered.
It is the viewPort for the
contentrenderer which is enclosed by the coordinate system axes.
-
transformAWT2CoordSys
Transforms a location in AWT coordinates (y axis extends to bottom) on this renderer to the corresponding coordinates in the coordinate system view (in GL coords).- Parameters:
awtPoint- to be transformedcanvasheight- height of the canvas thisContourPlot.CoordSysRendereris drawn to- Returns:
- transformed location
-
transformGL2CoordSys
Transforms a location in GL coordinates on this renderer to the corresponding coordinates in the coordinate system view.- Parameters:
point- to be transformed- Returns:
- transformed location
-