Class 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 a ContourPlot.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 an FBO. 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 Detail

      • 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
    • Constructor Detail

      • Lines

        public Lines()
    • Method Detail

      • setDirty

        public ContourPlot.Lines setDirty()
        Sets the isDirty() 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 interface ContourPlot.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 the isDirty() state to true.
        Parameters:
        p1 - start point
        p2 - 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 the isDirty() state to true.
        Parameters:
        x1 - x coordinate of start point
        y1 - y coordinate of start point
        x2 - x coordinate of end point
        y2 - y coordinate of end point
        Returns:
        the added segment
      • 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 the isDirty() state to true.
        Returns:
        this for chaining
      • setVertexRoundingEnabled

        public ContourPlot.Lines setVertexRoundingEnabled​(boolean useVertexRounding)
        En/Disables vertex rounding for this Lines object. 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.

        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 this ContourPlot.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 this ContourPlot.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 this ContourPlot.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.