Package gov.nih.mipav.model.algorithms
Class ContourPlot.Legend
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.ContourPlot.Legend
-
- All Implemented Interfaces:
ContourPlot.PDFRenderer
,ContourPlot.Renderable
,ContourPlot.Renderer
- Enclosing class:
- ContourPlot
public static class ContourPlot.Legend extends java.lang.Object implements ContourPlot.Renderable, ContourPlot.Renderer
The Legend class isContourPlot.Renderable
and its ownContourPlot.Renderer
at once. It is intended to be used to display labels and corresponding visual representatives such as a coloredContourPlot.Glyph
or line segment, in order to explain the meaning of the contents of a visualization.To add items to the legend, the methods
#addGlyphLabel(Glyph, int, String)
andaddLineLabel(double, int, String)
can be used. The layout of the items is very similar toFlowLayout
in which the items are positioned next to each other until no more space is available to the right and a line break happens, then positioning continues in the next row. A slight difference is that glyph labels are always first in order and followed by line labels. Layouting happens on#updateGL(boolean)
.- Author:
- hageldave
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ContourPlot.Legend.ColormapLabel
protected static class
ContourPlot.Legend.GlyphLabel
protected static class
ContourPlot.Legend.LineLabel
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<ContourPlot.Legend.ColormapLabel>
colormapLabels
protected ContourPlot.ColorScheme
colorScheme
protected ContourPlot.CompleteRenderer
delegate
protected java.util.Map<ContourPlot.Glyph,ContourPlot.Points>
glyph2points
protected java.util.ArrayList<ContourPlot.Legend.GlyphLabel>
glyphLabels
protected boolean
isDirty
protected boolean
isEnabled
protected java.util.ArrayList<ContourPlot.Legend.LineLabel>
lineLabels
protected java.util.Map<java.lang.Integer,ContourPlot.Lines>
pattern2lines
protected java.util.LinkedList<ContourPlot.Text>
texts
protected java.util.LinkedList<ContourPlot.Triangles>
triangles
protected int
viewPortHeight
protected int
viewPortWidth
-
Constructor Summary
Constructors Constructor Description Legend()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContourPlot.Legend
addLineLabel(double thickness, int color, int strokePattern, java.lang.String labeltxt, int pickColor)
Adds a label for a line to this legend.ContourPlot.Legend
addLineLabel(double thickness, int color, java.lang.String labeltxt)
Adds a label for a line to this legend.ContourPlot.Legend
addLineLabel(double thickness, int color, java.lang.String labeltxt, int pickColor)
Adds a label for a line to this legend.boolean
intersects(java.awt.geom.Rectangle2D rect)
Always return false.boolean
isDirty()
if true, indicates that a call to#updateGL(boolean)
is necessary to sync this objects GL resources to its current state.boolean
isEnabled()
Whether this renderer is enabled or not.void
renderFallback(java.awt.Graphics2D g, java.awt.Graphics2D p, int w, int h)
Renders thisContourPlot.Renderer
's 'scene'.void
renderPDF(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.void
setColorScheme(ContourPlot.ColorScheme colorScheme)
ContourPlot.Legend
setDirty()
Sets theisDirty()
state of this legend to true.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nih.mipav.model.algorithms.ContourPlot.Renderable
isHidden
-
-
-
-
Field Detail
-
glyphLabels
protected java.util.ArrayList<ContourPlot.Legend.GlyphLabel> glyphLabels
-
lineLabels
protected java.util.ArrayList<ContourPlot.Legend.LineLabel> lineLabels
-
colormapLabels
protected java.util.ArrayList<ContourPlot.Legend.ColormapLabel> colormapLabels
-
glyph2points
protected java.util.Map<ContourPlot.Glyph,ContourPlot.Points> glyph2points
-
pattern2lines
protected java.util.Map<java.lang.Integer,ContourPlot.Lines> pattern2lines
-
triangles
protected java.util.LinkedList<ContourPlot.Triangles> triangles
-
texts
protected java.util.LinkedList<ContourPlot.Text> texts
-
delegate
protected ContourPlot.CompleteRenderer delegate
-
isDirty
protected boolean isDirty
-
viewPortWidth
protected int viewPortWidth
-
viewPortHeight
protected int viewPortHeight
-
isEnabled
protected boolean isEnabled
-
colorScheme
protected ContourPlot.ColorScheme colorScheme
-
-
Method Detail
-
setColorScheme
public void setColorScheme(ContourPlot.ColorScheme colorScheme)
-
setDirty
public ContourPlot.Legend setDirty()
Sets theisDirty()
state of this legend to true. This indicates that a call to#updateGL(boolean)
is necessary to sync GL resources with this legends state.- Returns:
- this for chaining
-
isDirty
public boolean isDirty()
Description copied from interface:ContourPlot.Renderable
if true, indicates that a call to#updateGL(boolean)
is necessary to sync this objects GL resources to its current state.- Specified by:
isDirty
in interfaceContourPlot.Renderable
- Returns:
- true if dirty
-
renderFallback
public void renderFallback(java.awt.Graphics2D g, java.awt.Graphics2D p, int w, int h)
Description copied from interface:ContourPlot.Renderer
Renders thisContourPlot.Renderer
's 'scene'. This is the fallback path in case OpenGL based rendering through#render(int, int, int, int)
is not available.- Specified by:
renderFallback
in 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.PDFRenderer
Renders this PDFRenderers contents, that is creating pdf elements and appending them to the specified page within the corresponding document.- Specified by:
renderPDF
in 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.Renderer
Whether this renderer is enabled or not. By default a renderer is enabled and will render upon#render(int, int, int, int)
or#renderSVG(org.w3c.dom.Document, org.w3c.dom.Element, int, int)
. When disabled those methods return right away and will not render anything.- Specified by:
isEnabled
in interfaceContourPlot.Renderer
- Returns:
- true when active
-
intersects
public boolean intersects(java.awt.geom.Rectangle2D rect)
Always return false.- Specified by:
intersects
in interfaceContourPlot.Renderable
- Parameters:
rect
- rectangle to test- Returns:
- true when intersecting
-
addLineLabel
public ContourPlot.Legend addLineLabel(double thickness, int color, int strokePattern, java.lang.String labeltxt, int pickColor)
Adds a label for a line to this legend.- Parameters:
thickness
- of the line to appear in front of the label textcolor
- integer packed ARGB color value of the glyphstrokePattern
- lines stroke pattern (seeLines#setStrokePattern(int)
)labeltxt
- text of the labelpickColor
- picking color (seeFBOCanvas
)- Returns:
- this for chaining
-
addLineLabel
public ContourPlot.Legend addLineLabel(double thickness, int color, java.lang.String labeltxt, int pickColor)
Adds a label for a line to this legend.- Parameters:
thickness
- of the line to appear in front of the label textcolor
- integer packed ARGB color value of the glyphlabeltxt
- text of the labelpickColor
- picking color (seeFBOCanvas
)- Returns:
- this for chaining
-
addLineLabel
public ContourPlot.Legend addLineLabel(double thickness, int color, java.lang.String labeltxt)
Adds a label for a line to this legend.- Parameters:
thickness
- of the line to appear in front of the label textcolor
- integer packed ARGB color value of the glyphlabeltxt
- text of the label- Returns:
- this for chaining
-
-