Class IconPainter

  • All Implemented Interfaces:
    GlimpsePainter

    public class IconPainter
    extends GlimpsePainterBase
    A painter for efficiently painting large numbers of fixed pixel size icons at fixed locations in data (axis) space.
    Author:
    ulman
    • Constructor Detail

      • IconPainter

        public IconPainter​(int initialGroupSize,
                           boolean enablePicking)
      • IconPainter

        public IconPainter()
    • Method Detail

      • isPickingEnabled

        public boolean isPickingEnabled()
        Indicates whether picking support is enabled for this painter. If true, registered SpatialSelectionListener will be notified when the mouse is near an icon.
      • setPickingEnabled

        public void setPickingEnabled​(GlimpseLayout layout)
        Enables or disables picking support. If enabled, registered SpatialSelectionListener will be notified when the mouse is near an icon.
        Parameters:
        enable -
      • setPickingDisabled

        public void setPickingDisabled()
      • setGlobalScale

        public void setGlobalScale​(float scale)
        Sets the global scale factor for all icons (across all groups) rendered by this IconPainter. A scale of 1.0 indicates that icons should be draw at their true width and height in pixels.
        Parameters:
        scale - the scale factor to apply to the width and height of icons
      • addIconGroup

        public void addIconGroup​(Object iconGroupId,
                                 TextureAtlas atlas,
                                 int initialSize)
        Preallocates space for an icon group with the provided initial size. Useful if you know how many icons you'll be painting ahead of time and want to avoid unnecessary data array copies.
        Parameters:
        iconGroupId -
        initialSize -
      • ensureIconGroupSize

        public void ensureIconGroupSize​(Object iconGroupId,
                                        int minSize)
      • addIcon

        public void addIcon​(Object iconGroupId,
                            Object iconId,
                            float positionX,
                            float positionY,
                            float rotation)
        See Also:
        #addIcon( Object, Object, float, float, float, float, float )
      • addIcon

        public void addIcon​(Object iconGroupId,
                            Object iconId,
                            float positionX,
                            float positionY,
                            float rotation,
                            float scale)
        Adds the icon in the TextureAtlas referred to by iconId to iconGroupId at the provided coordinates. The icon must first be loaded using loadIcon( ). The iconGroupId can be any string, but efficient performance from this painter will only be achieved with a small number of groups. Entire groups of icons can be deleted or made invisible, but individual icons within groups cannot be removed or hidden. The scale parameter adjusts the size of the painted icon from the size stored in the TextureAtlas. A scale of 1.0 indicates that the pixel size stored in the texture atlas should bed used unchanged. The iconGroupId must correspond to a group that has already been added with addIconGroup(Object, TextureAtlas, int) or addIconGroup(Object, TextureAtlas).
        Parameters:
        iconGroupId - an arbitrary string creating an association between this icon and others in the same group
        iconId - the identifier of an icon in the underlying texture atlas loaded using loadIcon()
        positionX - a position in axis space to place the icon at
        positionY - a position in axis space to place the icon at
        rotation - rotation around center point of icon (CCW radians; 0 implies no rotation)
        scale - a scale adjustment to the icon size
      • addIcons

        public void addIcons​(Object iconGroupId,
                             Object iconId,
                             float[] positionX,
                             float[] positionY,
                             float[] rotation,
                             float[] scale)
        See Also:
        #addIcon( Object, Object, float[], float[], float[] )
      • addIcons

        public void addIcons​(Object iconGroupId,
                             Object iconId,
                             float[] positions)
        Loads icons into the IconPainter with x/y/rotation/scale quadruplets (one per icon) packed into a single float[] array.
        See Also:
        #addIcon( Object, Object, float[] )
      • addIcons

        public void addIcons​(Object iconGroupId,
                             Object iconId,
                             FloatBuffer positions,
                             int offset,
                             int vertexCount)
        Loads icons into the IconPainter with x/y/rot/scale interleaved in a single FloatBuffer in the same manner as #addIcons( Object, Object, float, float[] ). The offset provides the index of the first x coordinate to load into the painter and the vertex count provides the total number of x/y/rot/scale quadruplets to read from the FloatBuffer.
      • removeIconGroup

        public void removeIconGroup​(Object iconGroupId)
        Remove all the icons from the provided group.
        Parameters:
        iconGroupId -
      • showIconGroup

        public void showIconGroup​(Object iconGroupId,
                                  boolean show)
        Toggles whether or not a particular icon group is displayed. Hiding an icon group will not remove its underlying data.
        Parameters:
        iconGroupId -
        show -
      • showOnlyIconGroups

        public void showOnlyIconGroups​(Collection<? extends Object> iconGroupIds)
        Sets the visibility of all of this painter's icon-groups, so that a group is visible if and only if its ID is in the specified collection. Hiding an icon group will not remove its underlying data.
        Parameters:
        iconGroupId -
        show -