Class ContourPlot
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.ContourPlot
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.awt.event.WindowListener,java.lang.Runnable,java.util.EventListener
public class ContourPlot extends AlgorithmBase
The Contours class provides methods to compute contour lines and contour bands from a 2D regular grid of scalar values. SeecomputeContourLines(double[][], double, int)andcomputeContourBands(double[][], double, double, int, int)- Author:
- hageldave
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceContourPlot.AdaptableViewThe AdaptableView interface defines theContourPlot.AdaptableView.setView(Rectangle2D)method.classContourPlot.BarycentricGradientPaintThe BarycentricGradientPaint class provides a way to fill aShapewith a triangular color gradient.classContourPlot.BarycentricGradientPaintContextThis class is implements thePaintContextforContourPlot.BarycentricGradientPaint.classContourPlot.BlankCanvasFallbackFallback implementation forBlankCanvasfor systems that do not support OpenGL 3 throughorg.lwjgl.opengl.awt.AWTGLCanvas(e.g. macOS).static classContourPlot.BufferedImageFactoryClass providing convenience methods for converting Images to BufferedImages.static classContourPlot.CharacterAtlasThe CharacterAtlas class is a texture atlas for looking up character textures.static interfaceContourPlot.ColorMapThe ColorMap interface defines discrete mapping from a fixed integer interval [0..N-1] to colors through theContourPlot.ColorMap.getColor(int)method.static classContourPlot.ColorOperationsThe ColorOperations class contains methods for manipulating 32bit ARGB color values.classContourPlot.ColorSchemeThe ColorScheme is responsible for storing and providing color information, which other components can use.classContourPlot.CompleteRendererTheContourPlot.CompleteRenderercomprises aContourPlot.LinesRenderer, aPointsRenderer, aContourPlot.TextRendererand aContourPlot.TrianglesRenderer.static interfaceContourPlot.CoordinateViewListenerThe CoordinateViewListener is a listener that listens on changes to aContourPlot.CoordSysRenderer's coordinate view (i.e.classContourPlot.CoordSysPanningThe CoordSysPanning class implements aMouseListenerandMouseMotionListenerthat realize panning functionality for the coordinate view of theContourPlot.CoordSysRenderer.classContourPlot.CoordSysRendererThe CoordSysRenderer is aContourPlot.Rendererthat displays a coordinate system.classContourPlot.CoordSysScrollZoomThe CoordSysScrollZoom class implements aMouseWheelListenerthat realize zooming functionality for the coordinate view of theContourPlot.CoordSysRenderer.static classContourPlot.DefaultColorMapstatic classContourPlot.DefaultColorSchemeEnum containing predefinedContourPlot.ColorSchemes, which can be accessed throughContourPlot.DefaultColorScheme.get().static classContourPlot.ExtendedWilkinsonImplementation of the extended Wilkinson algorithm for tick label positioning.static classContourPlot.FontProviderclassContourPlot.GenericKeyThe GenericKey class can be used as key inHashMaps when multiple objects should be combined to a single key.classContourPlot.GenericRenderer<T extends ContourPlot.Renderable>static interfaceContourPlot.GlyphThe Glyph interface has to be implemented by a class that realizes a graphical representation of a 2D point (e.g. a cross or a circle).static classContourPlot.ImageSaverClass providing convenience methods for saving Images to file.classContourPlot.ImgImage class with data stored in an int array.static interfaceContourPlot.ImgBase<P extends ContourPlot.PixelBase>Base interface for imagingkit's Img classes.static interfaceContourPlot.InteractionConstantsstatic classContourPlot.IteratorsClass holding all of theIteratorandSpliteratorclasses used in theContourPlot.ImgBaseinterface.static interfaceContourPlot.JPlotterCanvasThis interface defines the methods required by an implementation of a canvasComponentfor use with JPlotterContourPlot.Renderers such asBlankCanvasorContourPlot.BlankCanvasFallback.static classContourPlot.LegendThe Legend class isContourPlot.Renderableand its ownContourPlot.Rendererat once.classContourPlot.LinesThe Lines class is a collection of linear line segments.classContourPlot.LinesRendererThe LinesRenderer is an implementation of theContourPlot.GenericRendererforContourPlot.Lines.static classContourPlot.Pair<T1,T2>Pair class.classContourPlot.ParallelForEachExecutor<T>CountedCompleter class for multithreaded execution of a Consumer on a Spliterator.static interfaceContourPlot.PDFRendererThe PDFRenderer interface defines the methodContourPlot.PDFRenderer.renderPDF(PDDocument, PDPage, int, int, int, int)which 'renders' the PDFRenderers's content as pdf objects in content streams, i.e. fills content streams with elements and appends them to the specified page.classContourPlot.PixelPixel class for retrieving a value from anContourPlot.Img.static interfaceContourPlot.PixelBaseBasic interface for Pixel classes ofContourPlot.ImgBaseimplementations.static classContourPlot.PixelConvertingSpliterator<P extends ContourPlot.PixelBase,T>The PixelConvertingSpliterator enables iterating anContourPlot.Imgwith a different datatype thanContourPlot.Pixel(ContourPlot.ImgBase.spliterator()).static interfaceContourPlot.PixelManipulator<P extends ContourPlot.PixelBase,T>The PixelManipulator interface defines an action to be performed on a pixel.static classContourPlot.PointDetailsClass for storing all the details of a single point to be rendered.classContourPlot.PointeredPoint2DThe PointeredPoint2D class is an implementation of thePoint2Dclass that uses two double arrays of size 1 to store its x and y coordinate.classContourPlot.PointsThe Points class is a collection of 2D points that are to be represented using the sameContourPlot.Glyph(the graphical representation of a point).static interfaceContourPlot.RenderableInterface for an object that can be rendered by aContourPlot.Renderere.g. theContourPlot.GenericRenderer.static interfaceContourPlot.RendererThe Renderer interface defines methods to initialize the renderer, execute a rendering pass, close the renderer.classContourPlot.SegmentDetailsSpecification of a line segment which comprises vertex locations, colors, picking color, and thicknesses.static classContourPlot.SignedDistanceCharactersThe SignedDistanceCharacters class comprises signed distance fields of a set of characters.classContourPlot.SimpleColorMapImplementation of theContourPlot.ColorMapinterface.classContourPlot.TextAbstract class forContourPlot.Renderables representing text that can be rendered using theContourPlot.TextRenderer.classContourPlot.TextRendererThe TrianglesRenderer is an implementation of theContourPlot.GenericRendererforContourPlot.Text.static interfaceContourPlot.TickMarkGeneratorThe TickMarkGenerator interface provides theContourPlot.TickMarkGenerator.genTicksAndLabels(double, double, int, boolean)method.classContourPlot.TranslatedPoint2DThe TranslatedPoint2D is an implementation ofPoint2Dthat references another Point2D and has a certain fixed translation from that point.classContourPlot.TriangleDetailsSpecification of a triangle which comprises vertex locations, colors and picking color.classContourPlot.TrianglesThe Triangles class is a collection of 2D triangles.classContourPlot.TrianglesRendererThe TrianglesRenderer is an implementation of theContourPlot.GenericRendererforContourPlot.Triangles.static classContourPlot.UtilsClass containing utility methods
-
Field Summary
Fields Modifier and Type Field Description private static ContourPlotcpExample from source ContourPlot.java draws contour plot of function surface correctly.-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description ContourPlot()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static inta(int color)static doublea_normalized(int color)static intargb_bounded(int a, int r, int g, int b)Packs 8bit ARGB color components into a single 32bit integer value.static intargb_fast(int a, int r, int g, int b)Packs 8bit ARGB color components into a single 32bit integer value.static intargb_fromNormalized(double a, double r, double g, double b)Packs normalized ARGB color components (values in [0.0 .. 1.0]) into a single 32bit integer value.static intb(int color)static doubleb_normalized(int color)(package private) static intcelltype(boolean v1, boolean v2, boolean v3)(package private) static intcelltype(boolean v11, boolean v21, boolean v31, boolean v12, boolean v22, boolean v32)static doubleclamp_0_1(double val)Clamps a value to the range [0.0, 1.0].intclamp_0_255(int val)Clamps a value to the range [0,255].static java.util.List<ContourPlot.TriangleDetails>computeContourBands(double[][] X, double[][] Y, double[][] Z, double isoValue1, double isoValue2, int c1, int c2)Computes the contour bands from the grid samples of a bivariate function z(x,y).static java.util.List<ContourPlot.TriangleDetails>computeContourBands(double[][] uniformGridSamples, double isoValue1, double isoValue2, int c1, int c2)Computes the contour bands from the grid samples of a bivariate function z(x,y)
with implicit integer valued (x,y) = (i,j).
The resulting triangles are solutions to the equation { (x,y) | iso1 < z(x,y) < iso2 } within the grid.static java.util.List<ContourPlot.SegmentDetails>computeContourLines(double[][] X, double[][] Y, double[][] Z, double isoValue, int color)Computes the contour lines from the grid samples of a bivariate function z(x,y).static java.util.List<ContourPlot.SegmentDetails>computeContourLines(double[][] uniformGridSamples, double isoValue, int color)Computes the contour lines from the grid samples of a bivariate function z(x,y)
with implicit integer valued (x,y) = (i,j).
The resulting line segments are solutions to the equation { (x,y) | z(x,y)=iso } within the grid.static intg(int color)static doubleg_normalized(int color)static intinterpolateColor(int c1, int c2, double m)Linearly interpolates between the two specified colors.
c = c1*(1-m) + c2*m(package private) static doubleinterpolateToValue(double lower, double upper, double iso)Returns m of the equation: iso = lower*(1-m) + upper*m
which is: m = (iso-lower)/(upper-lower)static intr(int color)static doubler_normalized(int color)static voidrequireAreaInImageBounds(int xStart, int yStart, int width, int height, ContourPlot.ImgBase<?> img)Throws anIllegalArgumentExceptionwhen the specified area is not within the bounds of the specified image, or if the area is not positive.static intrgb_bounded(int r, int g, int b)Packs 8bit RGB color components into a single 32bit ARGB integer value with alpha=255 (opaque).static intrgb_fast(int r, int g, int b)Packs 8bit RGB color components into a single 32bit ARGB integer value with alpha=255 (opaque).static intrgb_fromNormalized(double r, double g, double b)Packs normalized ARGB color components (values in [0.0 .. 1.0]) into a single 32bit integer value with alpha=255 (opaque).voidrunAlgorithm()Actually runs the algorithm.voidtestContourPlot()voidtestIsolinesViz()-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, finalize, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
cp
private static ContourPlot cp
Example from source ContourPlot.java draws contour plot of function surface correctly. Need to work on example in IsolinesViz.java.
-
-
Method Detail
-
testIsolinesViz
public void testIsolinesViz()
-
testContourPlot
public void testContourPlot()
-
runAlgorithm
public void runAlgorithm()
Description copied from class:AlgorithmBaseActually runs the algorithm. Implemented by inheriting algorithms.- Specified by:
runAlgorithmin classAlgorithmBase
-
b
public static final int b(int color)
-
g
public static final int g(int color)
-
r
public static final int r(int color)
-
a
public static final int a(int color)
-
b_normalized
public static final double b_normalized(int color)
- Parameters:
color- ARGB(32bit) or RGB(24bit) value- Returns:
- normalized blue component of specified color
(value in [0.0 .. 1.0]). - Since:
- 1.2
- See Also:
#b(),r_normalized(int),g_normalized(int),a_normalized(int)
-
g_normalized
public static final double g_normalized(int color)
- Parameters:
color- ARGB(32bit) or RGB(24bit) value- Returns:
- normalized green component of specified color
(value in [0.0 .. 1.0]). - Since:
- 1.2
- See Also:
#g(),r_normalized(int),b_normalized(int),a_normalized(int)
-
r_normalized
public static final double r_normalized(int color)
- Parameters:
color- ARGB(32bit) or RGB(24bit) value- Returns:
- normalized red component of specified color
(value in [0.0 .. 1.0]). - Since:
- 1.2
- See Also:
#r(),b_normalized(int),g_normalized(int),a_normalized(int)
-
a_normalized
public static final double a_normalized(int color)
- Parameters:
color- ARGB(32bit) value- Returns:
- normalized alpha component of specified color
(value in [0.0 .. 1.0]). - Since:
- 1.2
- See Also:
#a(),r_normalized(int),g_normalized(int),a_normalized(int)
-
argb_fast
public static final int argb_fast(int a, int r, int g, int b)Packs 8bit ARGB color components into a single 32bit integer value. Components larger than 8bit are NOT truncated and will result in a broken, malformed value.- Parameters:
a- alphar- redg- greenb- blue- Returns:
- packed ARGB value
- Since:
- 1.0
- See Also:
#argb(int, int, int, int),argb_bounded(int, int, int, int),rgb_bounded(int, int, int),#rgb(int, int, int),rgb_fast(int, int, int),a(int),r(int),g(int),b(int)
-
argb_bounded
public static final int argb_bounded(int a, int r, int g, int b)Packs 8bit ARGB color components into a single 32bit integer value. Components are clamped to [0,255].- Parameters:
a- alphar- redg- greenb- blue- Returns:
- packed ARGB value
- Since:
- 1.0
- See Also:
#argb(int, int, int, int),argb_fast(int, int, int, int),rgb_bounded(int, int, int),#rgb(int, int, int),rgb_fast(int, int, int),a(int),r(int),g(int),b(int)
-
argb_fromNormalized
public static final int argb_fromNormalized(double a, double r, double g, double b)Packs normalized ARGB color components (values in [0.0 .. 1.0]) into a single 32bit integer value. Component values less than 0 or greater than 1 are clamped to fit the range.- Parameters:
a- alphar- redg- greenb- blue- Returns:
- packed ARGB value
- Since:
- 1.2
- See Also:
rgb_fromNormalized(double, double, double),#argb(int, int, int, int),a_normalized(int),r_normalized(int),g_normalized(int),b_normalized(int)
-
rgb_fast
public static final int rgb_fast(int r, int g, int b)Packs 8bit RGB color components into a single 32bit ARGB integer value with alpha=255 (opaque). Components larger than 8bit are NOT truncated and will result in a broken, malformed value.- Parameters:
r- redg- greenb- blue- Returns:
- packed ARGB value
- Since:
- 1.0
- See Also:
#argb(int, int, int, int),argb_bounded(int, int, int, int),argb_fast(int, int, int, int),rgb_bounded(int, int, int),#rgb(int, int, int),a(int),r(int),g(int),b(int)
-
rgb_bounded
public static final int rgb_bounded(int r, int g, int b)Packs 8bit RGB color components into a single 32bit ARGB integer value with alpha=255 (opaque). Components are clamped to [0,255].- Parameters:
r- redg- greenb- blue- Returns:
- packed ARGB value
- Since:
- 1.0
- See Also:
#argb(int, int, int, int),argb_bounded(int, int, int, int),argb_fast(int, int, int, int),#rgb(int, int, int),rgb_fast(int, int, int),a(int),r(int),g(int),b(int)
-
rgb_fromNormalized
public static final int rgb_fromNormalized(double r, double g, double b)Packs normalized ARGB color components (values in [0.0 .. 1.0]) into a single 32bit integer value with alpha=255 (opaque). Component values less than 0 or greater than 1 clamped to fit the range.- Parameters:
r- redg- greenb- blue- Returns:
- packed ARGB value
- Since:
- 1.2
- See Also:
argb_fromNormalized(double, double, double, double),#rgb(int, int, int),a_normalized(int),r_normalized(int),g_normalized(int),b_normalized(int)
-
interpolateColor
public static int interpolateColor(int c1, int c2, double m)Linearly interpolates between the two specified colors.
c = c1*(1-m) + c2*m- Parameters:
c1- integer packed ARGB color valuec2- integer packed ARGB color value, e.g. 0xff00ff00 for opaque greenm- in [0,1]- Returns:
- interpolated color
-
computeContourLines
public static java.util.List<ContourPlot.SegmentDetails> computeContourLines(double[][] X, double[][] Y, double[][] Z, double isoValue, int color)
Computes the contour lines from the grid samples of a bivariate function z(x,y). The resulting line segments are solutions to the equation { (x,y) | z(x,y)=iso } within the grid.About indices For cartesian or rectilinear grids, x varies with the inner index of the 2D array, y with the outer index:
Xij=X[i][j]=X[?][j].
Yij=Y[i][j]=Y[i][?]- Parameters:
X- x-coordinates of the grid points ( (x,y,z)ij = (Xij,Yij,Zij) )Y- y-coordinates of the grid points ( (x,y,z)ij = (Xij,Yij,Zij) )Z- z-coordinates of the grid points ( (x,y,z)ij = (Xij,Yij,Zij) )isoValue- the iso value for which the contour (iso) lines should be computedcolor- integer packed ARGB color value the returned line segments should have, e.g. 0xff00ff00 for opaque green.- Returns:
- list of line segments that form the contour lines. There is no particular order so subsequent segments are not necessarily adjacent.
-
computeContourBands
public static java.util.List<ContourPlot.TriangleDetails> computeContourBands(double[][] X, double[][] Y, double[][] Z, double isoValue1, double isoValue2, int c1, int c2)
Computes the contour bands from the grid samples of a bivariate function z(x,y). The resulting triangles are solutions to the equation { (x,y) | iso1 < z(x,y) < iso2 } within the grid.About indices For cartesian or rectilinear grids, x varies with the inner index of the 2D array, y with the outer index:
Xij=X[i][j]=X[?][j].
Yij=Y[i][j]=Y[i][?]- Parameters:
X- x-coordinates of the grid points ( (x,y,z)ij = (Xij,Yij,Zij) )Y- y-coordinates of the grid points ( (x,y,z)ij = (Xij,Yij,Zij) )Z- z-coordinates of the grid points ( (x,y,z)ij = (Xij,Yij,Zij) )isoValue1- the lower bound for values of the iso bandsisoValue2- the upper bound for values of the iso bandsc1- color for the isoValue1c2- color for the isoValue2, values in between iso1 and iso2 will have their color linearly interpolated- Returns:
- list of triangles that form the iso bands. The order of triangles does NOT imply any adjacency between them.
-
computeContourLines
public static java.util.List<ContourPlot.SegmentDetails> computeContourLines(double[][] uniformGridSamples, double isoValue, int color)
Computes the contour lines from the grid samples of a bivariate function z(x,y)
with implicit integer valued (x,y) = (i,j).
The resulting line segments are solutions to the equation { (x,y) | z(x,y)=iso } within the grid.The lines are computed using the Meandering Triangles algorithm which divides each square cell of the grid into 2 triangle cells first before computing isovalue intersections on the triangle sides. The more well known Marching Squares algorithm has significantly more cell cases to check, which is why Meandering Triangles was preferred here.
- Parameters:
uniformGridSamples- z-coordinates of the grid points ( (x,y,z)ij = (i,j,Zij) )isoValue- the iso value for which the contour (iso) lines should be computedcolor- integer packed ARGB color value the returned line segments should have, e.g. 0xff00ff00 for opaque green.- Returns:
- list of line segments that form the contour lines. There is no particular order so subsequent segments are not necessarily adjacent.
-
computeContourBands
public static java.util.List<ContourPlot.TriangleDetails> computeContourBands(double[][] uniformGridSamples, double isoValue1, double isoValue2, int c1, int c2)
Computes the contour bands from the grid samples of a bivariate function z(x,y)
with implicit integer valued (x,y) = (i,j).
The resulting triangles are solutions to the equation { (x,y) | iso1 < z(x,y) < iso2 } within the grid.The triangles are computed using the Meandering Triangles algorithm which divides each square cell of the grid into 2 triangle cells first before computing isovalue intersections on the triangle sides. The more well known Marching Squares algorithm has significantly more cell cases to check, which is why Meandering Triangles was preferred here.
- Parameters:
uniformGridSamples- z-coordinates of the grid points ( (x,y,z)ij = (i,j,Zij) )isoValue1- the lower bound for values of the iso bandsisoValue2- the upper bound for values of the iso bandsc1- color for the isoValue1c2- color for the isoValue2, values in between iso1 and iso2 will have their color linearly interpolated- Returns:
- list of triangles that form the iso bands. The order of triangles does NOT imply any adjacency between them.
-
celltype
static int celltype(boolean v1, boolean v2, boolean v3)
-
celltype
static int celltype(boolean v11, boolean v21, boolean v31, boolean v12, boolean v22, boolean v32)
-
interpolateToValue
static double interpolateToValue(double lower, double upper, double iso)Returns m of the equation: iso = lower*(1-m) + upper*m
which is: m = (iso-lower)/(upper-lower)- Parameters:
lower- valueupper- valueiso- value in between lower and upper- Returns:
- m
-
clamp_0_255
public final int clamp_0_255(int val)
Clamps a value to the range [0,255]. Returns 0 for values less than 0, 255 for values greater than 255, and the value it self when in range.- Parameters:
val- value to be clamped- Returns:
- value clamped to [0,255]
-
clamp_0_1
public static double clamp_0_1(double val)
Clamps a value to the range [0.0, 1.0]. Returns 0.0 for values less than 0, 1.0 for values greater than 1.0, and the value it self when in range.- Parameters:
val- value to be clamped- Returns:
- value clamped to [0.0, 1.0]
-
requireAreaInImageBounds
public static void requireAreaInImageBounds(int xStart, int yStart, int width, int height, ContourPlot.ImgBase<?> img)Throws anIllegalArgumentExceptionwhen the specified area is not within the bounds of the specified image, or if the area is not positive. This is used for parameter evaluation.- Parameters:
xStart- left boundary of the areayStart- top boundary of the areawidth- of the areaheight- of the areaimg- the area has to fit in.- Throws:
java.lang.IllegalArgumentException- when area not in image bounds or not area not positive
-
-