Package gov.nih.mipav.model.algorithms
Class ContourPlot.Triangles
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.ContourPlot.Triangles
-
- All Implemented Interfaces:
ContourPlot.Renderable
- Enclosing class:
- ContourPlot
public class ContourPlot.Triangles extends java.lang.Object implements ContourPlot.Renderable
The Triangles class is a collection of 2D triangles. A single triangle consists of three 2D points where each of these points can be colored differently which leads to the triangle area being colored by interpolating using barycentric coordinates. Also a triangle can have a single picking color, which is the color with which the triangle 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 parameter which scales every triangle's color alpha value, which can be used to introduce transparency for all triangles of this collection. This may come in handy to let other rendered content under a triangle 'shine through'.
- Author:
- hageldave
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.function.DoubleSupplierglobalAlphaMultiplierprotected java.util.function.DoubleSupplierglobalSaturationMultiplierprotected booleanhiddenprotected booleanisDirtyprotected java.util.ArrayList<ContourPlot.TriangleDetails>trianglesprotected booleanuseAAinFallbackprotected booleanuseCrispEdgesForSVG
-
Constructor Summary
Constructors Constructor Description Triangles()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatgetGlobalAlphaMultiplier()floatgetGlobalSaturationMultiplier()java.util.List<ContourPlot.TriangleDetails>getIntersectingTriangles(java.awt.geom.Rectangle2D rect)Returns the triangles that intersect or contain the specified rectangle.java.util.ArrayList<ContourPlot.TriangleDetails>getTriangleDetails()booleanintersects(java.awt.geom.Rectangle2D rect)tests if thisContourPlot.Renderableintersects or contains the specified rectangle.booleanisAAinFallbackEnabled()Return true when anti-aliasing is enabled for fallback (AWT) rendering (default=false).booleanisDirty()if true, indicates that a call to#updateGL(boolean)is necessary to sync this objects GL resources to its current state.booleanisHidden()Indicates whether this Renderable is hidden i.e. will not be drawn.intnumTriangles()ContourPlot.TrianglesremoveAllTriangles()Removes all TriangleDetails from this collection.ContourPlot.TrianglessetDirty()Sets theisDirty()state of thisContourPlot.Trianglesobject to true.ContourPlot.TrianglessetGlobalAlphaMultiplier(double globalAlphaMultiplier)Sets the global alpha multiplier parameter of thisContourPlot.Trianglesobject.ContourPlot.TrianglessetGlobalAlphaMultiplier(java.util.function.DoubleSupplier globalAlphaMultiplier)Sets the global alpha multiplier parameter of thisContourPlot.Trianglesobject.
-
-
-
Field Detail
-
isDirty
protected boolean isDirty
-
globalAlphaMultiplier
protected java.util.function.DoubleSupplier globalAlphaMultiplier
-
globalSaturationMultiplier
protected java.util.function.DoubleSupplier globalSaturationMultiplier
-
triangles
protected java.util.ArrayList<ContourPlot.TriangleDetails> triangles
-
useCrispEdgesForSVG
protected boolean useCrispEdgesForSVG
-
useAAinFallback
protected boolean useAAinFallback
-
hidden
protected boolean hidden
-
-
Method Detail
-
numTriangles
public int numTriangles()
- Returns:
- the number of triangles in this collection.
-
intersects
public boolean intersects(java.awt.geom.Rectangle2D rect)
Description copied from interface:ContourPlot.Renderabletests if thisContourPlot.Renderableintersects or contains the specified rectangle.- Specified by:
intersectsin interfaceContourPlot.Renderable- Parameters:
rect- rectangle to test- Returns:
- true when intersecting
-
isHidden
public boolean isHidden()
Description copied from interface:ContourPlot.RenderableIndicates whether this Renderable is hidden i.e. will not be drawn.- Specified by:
isHiddenin interfaceContourPlot.Renderable- Returns:
- true when hidden
-
getTriangleDetails
public java.util.ArrayList<ContourPlot.TriangleDetails> getTriangleDetails()
- Returns:
- the list of triangle details.
Make sure to callsetDirty()when manipulating.
-
setGlobalAlphaMultiplier
public ContourPlot.Triangles setGlobalAlphaMultiplier(double globalAlphaMultiplier)
Sets the global alpha multiplier parameter of thisContourPlot.Trianglesobject. The value will be multiplied with each vertex' alpha color value when rendering. The triangle will then be rendered with the opacityalpha = globalAlphaMultiplier * point.alpha.- Parameters:
globalAlphaMultiplier- of the triangles in this collection- Returns:
- this for chaining
-
getGlobalSaturationMultiplier
public float getGlobalSaturationMultiplier()
- Returns:
- the saturation multiplier of this renderable
-
setGlobalAlphaMultiplier
public ContourPlot.Triangles setGlobalAlphaMultiplier(java.util.function.DoubleSupplier globalAlphaMultiplier)
Sets the global alpha multiplier parameter of thisContourPlot.Trianglesobject. The value will be multiplied with each vertex' alpha color value when rendering. The triangle will then be rendered with the opacityalpha = globalAlphaMultiplier * point.alpha.- Parameters:
globalAlphaMultiplier- of the triangles in this collection- Returns:
- this for chaining
-
getGlobalAlphaMultiplier
public float getGlobalAlphaMultiplier()
- Returns:
- the global alpha multiplier of the triangles in this collection
-
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
-
isAAinFallbackEnabled
public boolean isAAinFallbackEnabled()
Return true when anti-aliasing is enabled for fallback (AWT) rendering (default=false).Especially for triangle grids/meshes this option should be disabled to avoid visible triangle edges inside the grid/mesh. When triangles are not connected, this option can be enabled to get anti-aliased edges.
- Returns:
- true when enabled
-
getIntersectingTriangles
public java.util.List<ContourPlot.TriangleDetails> getIntersectingTriangles(java.awt.geom.Rectangle2D rect)
Returns the triangles that intersect or contain the specified rectangle.- Parameters:
rect- rectangle to test intersection- Returns:
- list of intersecting triangles
-
removeAllTriangles
public ContourPlot.Triangles removeAllTriangles()
Removes all TriangleDetails from this collection. Sets theisDirty()state to true.- Returns:
- this for chaining
-
setDirty
public ContourPlot.Triangles setDirty()
Sets theisDirty()state of thisContourPlot.Trianglesobject to true.- Returns:
- this for chaining
-
-