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.Renderableand its ownContourPlot.Rendererat once. It is intended to be used to display labels and corresponding visual representatives such as a coloredContourPlot.Glyphor 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 toFlowLayoutin 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 classContourPlot.Legend.ColormapLabelprotected static classContourPlot.Legend.GlyphLabelprotected static classContourPlot.Legend.LineLabel
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<ContourPlot.Legend.ColormapLabel>colormapLabelsprotected ContourPlot.ColorSchemecolorSchemeprotected ContourPlot.CompleteRendererdelegateprotected java.util.Map<ContourPlot.Glyph,ContourPlot.Points>glyph2pointsprotected java.util.ArrayList<ContourPlot.Legend.GlyphLabel>glyphLabelsprotected booleanisDirtyprotected booleanisEnabledprotected java.util.ArrayList<ContourPlot.Legend.LineLabel>lineLabelsprotected java.util.Map<java.lang.Integer,ContourPlot.Lines>pattern2linesprotected java.util.LinkedList<ContourPlot.Text>textsprotected java.util.LinkedList<ContourPlot.Triangles>trianglesprotected intviewPortHeightprotected intviewPortWidth
-
Constructor Summary
Constructors Constructor Description Legend()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContourPlot.LegendaddLineLabel(double thickness, int color, int strokePattern, java.lang.String labeltxt, int pickColor)Adds a label for a line to this legend.ContourPlot.LegendaddLineLabel(double thickness, int color, java.lang.String labeltxt)Adds a label for a line to this legend.ContourPlot.LegendaddLineLabel(double thickness, int color, java.lang.String labeltxt, int pickColor)Adds a label for a line to this legend.booleanintersects(java.awt.geom.Rectangle2D rect)Always return false.booleanisDirty()if true, indicates that a call to#updateGL(boolean)is necessary to sync this objects GL resources to its current state.booleanisEnabled()Whether this renderer is enabled or not.voidrenderFallback(java.awt.Graphics2D g, java.awt.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.voidsetColorScheme(ContourPlot.ColorScheme colorScheme)ContourPlot.LegendsetDirty()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.Renderableif true, indicates that a call to#updateGL(boolean)is necessary to sync this objects GL resources to its current state.- Specified by:
isDirtyin 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.RendererRenders 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:
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 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:
isEnabledin interfaceContourPlot.Renderer- Returns:
- true when active
-
intersects
public boolean intersects(java.awt.geom.Rectangle2D rect)
Always return false.- Specified by:
intersectsin 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
-
-