Class ContourPlot.Lines
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.ContourPlot.Lines
-
- All Implemented Interfaces:
ContourPlot.Renderable
- Enclosing class:
- ContourPlot
public class ContourPlot.Lines extends java.lang.Object implements ContourPlot.Renderable
The Lines class is a collection of linear line segments. Each segment is defined by a 2D start and end point and can be colored per point. This means that when the colors at start and endpoint are different the line will be rendered with a linear color gradient which is interpolated between the two points. Per default the thickness of the line segments is 1 pixel but can be altered for all segments in aContourPlot.Lines
object (not per segment). Each segment has a single picking color. The picking color is the color with which the segment is rendered into the (invisible) picking color attachment of anFBO
. This color may serve as an identifier of the object that can be queried from a location of the rendering canvas. It may take on a value in range of 0xff000001 to 0xffffffff (16.777.214 possible values) or 0.There is also a global alpha multiplier (
#setGlobalAlphaMultiplier(double)
) which scales every segments color alpha value, which can be used to introduce transparency for all segments of this collection. This may come in handy to visualize density when plotting a huge amount of lines.
Similarly, the global thickness multiplier (setGlobalThicknessMultiplier(double)
) can be used to scale every segment's thickness of this Lines object by a specific factor.The segments of this object can be rendered using a stroke pattern (
#setStrokePattern(int)
) to draw dashed or dotted lines.- Author:
- hageldave
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.function.DoubleSupplier
globalAlphaMultiplier
protected java.util.function.DoubleSupplier
globalSaturationMultiplier
protected java.util.function.DoubleSupplier
globalThicknessMultiplier
protected boolean
hidden
protected boolean
isDirty
protected java.util.ArrayList<ContourPlot.SegmentDetails>
segments
protected float
strokeLength
protected short
strokePattern
protected boolean
useVertexRounding
-
Constructor Summary
Constructors Constructor Description Lines()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContourPlot.SegmentDetails
addSegment(double x1, double y1, double x2, double y2)
Adds a new line segment to this object.ContourPlot.SegmentDetails
addSegment(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
Adds a new line segment to this object.float
getGlobalAlphaMultiplier()
float
getGlobalSaturationMultiplier()
float
getGlobalThicknessMultiplier()
java.util.ArrayList<ContourPlot.SegmentDetails>
getSegments()
float
getStrokeLength()
Returns the stroke length in pixels, which is by default 16 pixels.short
getStrokePattern()
Returns thisContourPlot.Lines
object's stroke patternboolean
hasStrokePattern()
Whether this Lines object has a stroke pattern other than 0xffff (completely solid).boolean
intersects(java.awt.geom.Rectangle2D rect)
tests if thisContourPlot.Renderable
intersects or contains the specified rectangle.boolean
isDirty()
if true, indicates that a call to#updateGL(boolean)
is necessary to sync this objects GL resources to its current state.boolean
isHidden()
Indicates whether this Renderable is hidden i.e. will not be drawn.boolean
isVertexRoundingEnabled()
int
numSegments()
ContourPlot.Lines
removeAllSegments()
Removes all segments of this object.ContourPlot.Lines
setDirty()
Sets theisDirty()
state of this renderable to true.ContourPlot.Lines
setGlobalThicknessMultiplier(double thickness)
Sets the line thickness multiplier for thisContourPlot.Lines
object in pixels.ContourPlot.Lines
setGlobalThicknessMultiplier(java.util.function.DoubleSupplier thickness)
Sets the line thickness multiplier for thisContourPlot.Lines
object in pixels.ContourPlot.Lines
setVertexRoundingEnabled(boolean useVertexRounding)
En/Disables vertex rounding for this Lines object.
-
-
-
Field Detail
-
segments
protected java.util.ArrayList<ContourPlot.SegmentDetails> segments
-
globalSaturationMultiplier
protected java.util.function.DoubleSupplier globalSaturationMultiplier
-
globalThicknessMultiplier
protected java.util.function.DoubleSupplier globalThicknessMultiplier
-
isDirty
protected boolean isDirty
-
globalAlphaMultiplier
protected java.util.function.DoubleSupplier globalAlphaMultiplier
-
useVertexRounding
protected boolean useVertexRounding
-
strokePattern
protected short strokePattern
-
strokeLength
protected float strokeLength
-
hidden
protected boolean hidden
-
-
Method Detail
-
setDirty
public ContourPlot.Lines setDirty()
Sets theisDirty()
state of this renderable to true. This indicates that an#updateGL(boolean, double, double)
call is necessary to sync GL resources.- 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
-
numSegments
public int numSegments()
- Returns:
- the number of line segments in this
ContourPlot.Lines
object
-
addSegment
public ContourPlot.SegmentDetails addSegment(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
Adds a new line segment to this object. Sets theisDirty()
state to true.- Parameters:
p1
- start pointp2
- end point- Returns:
- the added segment
-
addSegment
public ContourPlot.SegmentDetails addSegment(double x1, double y1, double x2, double y2)
Adds a new line segment to this object. Sets theisDirty()
state to true.- Parameters:
x1
- x coordinate of start pointy1
- y coordinate of start pointx2
- x coordinate of end pointy2
- y coordinate of end point- Returns:
- the added segment
-
getSegments
public java.util.ArrayList<ContourPlot.SegmentDetails> getSegments()
- Returns:
- the line segments list.
Make sure to call
setDirty()
when manipulating.
-
getGlobalAlphaMultiplier
public float getGlobalAlphaMultiplier()
- Returns:
- the global alpha multiplier of the segments in this collection
-
removeAllSegments
public ContourPlot.Lines removeAllSegments()
Removes all segments of this object. Sets theisDirty()
state to true.- Returns:
- this for chaining
-
intersects
public boolean intersects(java.awt.geom.Rectangle2D rect)
Description copied from interface:ContourPlot.Renderable
tests if thisContourPlot.Renderable
intersects or contains the specified rectangle.- Specified by:
intersects
in interfaceContourPlot.Renderable
- Parameters:
rect
- rectangle to test- Returns:
- true when intersecting
-
isHidden
public boolean isHidden()
Description copied from interface:ContourPlot.Renderable
Indicates whether this Renderable is hidden i.e. will not be drawn.- Specified by:
isHidden
in interfaceContourPlot.Renderable
- Returns:
- true when hidden
-
setVertexRoundingEnabled
public ContourPlot.Lines setVertexRoundingEnabled(boolean useVertexRounding)
En/Disables vertex rounding for this Lines object. This indicates if theContourPlot.LinesRenderer
's shader will round vertex positions of the quad vertices (that a segment is expanded to) to integer values.This has the effect of sharpening horizontal and vertical lines, but can affect differently oriented lines to shrink in thickness or even vanish.
Also this only makes sense when the Lines object is of integer valued thickness.
- Parameters:
useVertexRounding
- will enable if true- Returns:
- this for chaining
-
setGlobalThicknessMultiplier
public ContourPlot.Lines setGlobalThicknessMultiplier(java.util.function.DoubleSupplier thickness)
Sets the line thickness multiplier for thisContourPlot.Lines
object in pixels. The effective thickness of a segment results from multiplication of its thickness with this value.- Parameters:
thickness
- of the lines, default is 1.- Returns:
- this for chaining
-
setGlobalThicknessMultiplier
public ContourPlot.Lines setGlobalThicknessMultiplier(double thickness)
Sets the line thickness multiplier for thisContourPlot.Lines
object in pixels. The effective thickness of a segment results from multiplication of its thickness with this value.- Parameters:
thickness
- of the lines, default is 1.- Returns:
- this for chaining
-
getGlobalThicknessMultiplier
public float getGlobalThicknessMultiplier()
- Returns:
- the line thickness multiplier of this
ContourPlot.Lines
object
-
hasStrokePattern
public boolean hasStrokePattern()
Whether this Lines object has a stroke pattern other than 0xffff (completely solid).- Returns:
- true when stroke pattern != 0xffff
-
getStrokePattern
public short getStrokePattern()
Returns thisContourPlot.Lines
object's stroke pattern- Returns:
- stroke pattern
-
getStrokeLength
public float getStrokeLength()
Returns the stroke length in pixels, which is by default 16 pixels.- Returns:
- stroke length
-
getGlobalSaturationMultiplier
public float getGlobalSaturationMultiplier()
- Returns:
- the saturation multiplier of this renderable
-
isVertexRoundingEnabled
public boolean isVertexRoundingEnabled()
- Returns:
- whether vertex rounding is enabled. This indicates if
the
ContourPlot.LinesRenderer
's shader will round vertex positions of the quad vertices (that a segment is expanded to) to integer values.This has the effect of sharpening horizontal and vertical lines, but can affect differently oriented lines to shrink in thickness or even vanish.
-
-