Search in sources :

Example 66 with PathClass

use of qupath.lib.objects.classes.PathClass in project qupath by qupath.

the class ColorToolsFX method getDisplayedColorARGB.

/**
 * Get the color with which an object should be displayed, as a packaged ARGB integer.
 *
 * This could be stored internally, or obtained from its PathClass.
 *
 * If neither of these produces a result, a default color will be returned based on PathPrefs
 * for the specific (Java) class of the PathObject.
 *
 * Assuming PathPrefs does not contain any nulls, this will therefore not return nulls either.
 *
 * @param pathObject
 * @return
 */
public static Integer getDisplayedColorARGB(final PathObject pathObject) {
    // Check if any color has been set - if so, return it
    Integer color = pathObject.getColorRGB();
    if (color != null)
        return color;
    // Check if any class has been set, if so then use its color
    PathClass pathClass = pathObject.getPathClass();
    if (pathClass != null)
        color = pathClass.getColor();
    if (color != null)
        return color;
    if (pathObject instanceof PathTileObject)
        return PathPrefs.colorTileProperty().getValue();
    if (pathObject instanceof TMACoreObject) {
        if (((TMACoreObject) pathObject).isMissing())
            return PathPrefs.colorTMAMissingProperty().getValue();
        else
            return PathPrefs.colorTMAProperty().getValue();
    }
    return PathPrefs.colorDefaultObjectsProperty().getValue();
}
Also used : PathClass(qupath.lib.objects.classes.PathClass) PathTileObject(qupath.lib.objects.PathTileObject) TMACoreObject(qupath.lib.objects.TMACoreObject)

Aggregations

PathClass (qupath.lib.objects.classes.PathClass)66 ArrayList (java.util.ArrayList)42 PathObject (qupath.lib.objects.PathObject)34 List (java.util.List)29 Map (java.util.Map)25 IOException (java.io.IOException)21 Logger (org.slf4j.Logger)20 LoggerFactory (org.slf4j.LoggerFactory)20 Collections (java.util.Collections)17 Collectors (java.util.stream.Collectors)17 BufferedImage (java.awt.image.BufferedImage)16 LinkedHashMap (java.util.LinkedHashMap)16 ROI (qupath.lib.roi.interfaces.ROI)16 HashMap (java.util.HashMap)15 ImageData (qupath.lib.images.ImageData)15 PathClassFactory (qupath.lib.objects.classes.PathClassFactory)15 PathObjectHierarchy (qupath.lib.objects.hierarchy.PathObjectHierarchy)15 ParameterList (qupath.lib.plugins.parameters.ParameterList)15 Collection (java.util.Collection)14 TreeMap (java.util.TreeMap)11