Class IconPainter
- java.lang.Object
-
- com.metsci.glimpse.core.painter.base.GlimpsePainterBase
-
- com.metsci.glimpse.core.support.atlas.painter.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
IconPainter.PickResult
-
Constructor Summary
Constructors Constructor Description IconPainter()
IconPainter(int initialGroupSize, boolean enablePicking)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIcon(Object iconGroupId, Object iconId, float positionX, float positionY, float rotation)
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.void
addIconGroup(Object iconGroupId, TextureAtlas atlas)
void
addIconGroup(Object iconGroupId, TextureAtlas atlas, int initialSize)
Preallocates space for an icon group with the provided initial size.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.void
addIcons(Object iconGroupId, Object iconId, float[] positionX, float[] positionY, float[] rotation, float[] scale)
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[] )
.void
addSpatialSelectionListener(SpatialSelectionListener<IconPainter.PickResult> listener)
void
doPaintTo(GlimpseContext context)
void
ensureIconGroupSize(Object iconGroupId, int minSize)
boolean
isPickingEnabled()
Indicates whether picking support is enabled for this painter.void
paintIcons(GlimpseContext context)
void
removeIconGroup(Object iconGroupId)
Remove all the icons from the provided group.void
removeSpatialSelectionListener(SpatialSelectionListener<IconPainter.PickResult> listener)
void
setGlobalScale(float scale)
Sets the global scale factor for all icons (across all groups) rendered by this IconPainter.void
setPickingDisabled()
void
setPickingEnabled(GlimpseLayout layout)
Enables or disables picking support.void
showIconGroup(Object iconGroupId, boolean show)
Toggles whether or not a particular icon group is displayed.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.-
Methods inherited from class com.metsci.glimpse.core.painter.base.GlimpsePainterBase
dispose, getAxis1D, getAxis2D, getBounds, getGL3, isDisposed, isVisible, paintTo, requireAxis1D, requireAxis2D, setLookAndFeel, setVisible
-
-
-
-
Method Detail
-
addSpatialSelectionListener
public void addSpatialSelectionListener(SpatialSelectionListener<IconPainter.PickResult> listener)
-
removeSpatialSelectionListener
public void removeSpatialSelectionListener(SpatialSelectionListener<IconPainter.PickResult> listener)
-
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)
-
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 withaddIconGroup(Object, TextureAtlas, int)
oraddIconGroup(Object, TextureAtlas)
.- Parameters:
iconGroupId
- an arbitrary string creating an association between this icon and others in the same groupiconId
- the identifier of an icon in the underlying texture atlas loaded using loadIcon()positionX
- a position in axis space to place the icon atpositionY
- a position in axis space to place the icon atrotation
- 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
-
-
doPaintTo
public void doPaintTo(GlimpseContext context)
-
paintIcons
public void paintIcons(GlimpseContext context)
-
-