Class GlimpseLayout
- java.lang.Object
-
- com.metsci.glimpse.core.layout.GlimpseLayout
-
- All Implemented Interfaces:
GlimpseTarget,GlimpseKeyListener,Keyable,GlimpseMouseListener,GlimpseMouseMotionListener,GlimpseMouseWheelListener,Mouseable,GlimpsePainter
- Direct Known Subclasses:
GlimpseAxisLayout1D,GlimpseAxisLayout2D,GlimpseTouchLayout,GlimpseTouchWrapper,GlimpseVerticallyScrollableLayout,MultiAxisPlot2D,StackedPlot2D
public class GlimpseLayout extends Object implements GlimpsePainter, GlimpseTarget, Mouseable, Keyable
GlimpseLayout provides a means of rendering to specific areas of a GlimpseCanvas controlled by Mig Layout constraints. It also acts as a RenderTarget onto which other GlimpsePainters may be painted. GlimpseLayout satisfies the Glimpse-facing interfaces GlimpsePainter and RenderTarget.GlimpseLayout uses a delegate class
GlimpseLayoutDelegateto interface with Mig Layout and hold transient state during layout operations. The final results of the layout are stored in aLayoutCache.Don't forget the "bottomtotop" layout constraint for MiG, or things will be upside-down from what you probably expect.
- Author:
- osborn, ulman
- See Also:
GlimpseLayoutDelegate
-
-
Constructor Summary
Constructors Constructor Description GlimpseLayout()GlimpseLayout(GlimpseLayout parent)GlimpseLayout(GlimpseLayout parent, String name)GlimpseLayout(String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddGlimpseKeyListener(GlimpseKeyListener listener)voidaddGlimpseMouseAllListener(GlimpseMouseAllListener listener)voidaddGlimpseMouseListener(GlimpseMouseListener listener)voidaddGlimpseMouseMotionListener(GlimpseMouseMotionListener listener)voidaddGlimpseMouseWheelListener(GlimpseMouseWheelListener listener)voidaddLayout(GlimpseLayout layout)Adds a sub-layout to this GlimpseTarget which will only paint in a region of this GlimpseTarget based on its layout constraints.voidaddLayout(GlimpseLayout layout, int zOrder)voidaddLayout(GlimpseLayout layout, GlimpsePainterCallback callback)voidaddLayout(GlimpseLayout layout, GlimpsePainterCallback callback, int zOrder)voidaddLayout(Object key, GlimpseLayout layout, GlimpsePainterCallback callback, int zOrder)voidaddPainter(GlimpsePainter painter)voidaddPainter(GlimpsePainter painter, int zOrder)voidaddPainter(GlimpsePainter painter, GlimpsePainterCallback callback)voidaddPainter(GlimpsePainter painter, GlimpsePainterCallback callback, int zOrder)voidaddPainter(Object key, GlimpsePainter painter, int zOrder)voidaddPainter(Object key, GlimpsePainter painter, GlimpsePainterCallback callback, int zOrder)voiddispose(GlimpseContext context)Free GPU and CPU memory associated with this this GlimpsePainter.Collection<GlimpseKeyListener>getGlimpseKeyListeners()Collection<GlimpseMouseListener>getGlimpseMouseListeners()Collection<GlimpseMouseMotionListener>getGlimpseMouseMotionListeners()Collection<GlimpseMouseWheelListener>getGlimpseMouseWheelListeners()GlimpseLayoutgetLayoutByKey(Object key)GlimpseLayoutManagergetLayoutManager()ReentrantLockgetLock()StringgetName()GlimpsePaintergetPainterByKey(Object key)GlimpseBoundsgetTargetBounds(GlimpseTargetStack stack)Returns the cached or calculated bounds of this GlimpseTarget for a particular context.List<GlimpseTarget>getTargetChildren()voidinvalidateLayout()booleanisDisposed()booleanisEventConsumer()Event consumers do not pass on mouse events to their parents.booleanisEventGenerator()Event generators do not generate mouse events if they are the top layout when a mouse event occurs.booleanisVisible()If true, the GlimpseTarget should be drawn on the screen and mouse events should be dispatched for it.voidkeyPressed(GlimpseKeyEvent event)voidkeyReleased(GlimpseKeyEvent event)GlimpseBoundslayoutTo(GlimpseContext context)GlimpseBoundslayoutTo(GlimpseTargetStack stack)voidmouseEntered(GlimpseMouseEvent event)voidmouseExited(GlimpseMouseEvent event)voidmouseMoved(GlimpseMouseEvent event)voidmousePressed(GlimpseMouseEvent event)voidmouseReleased(GlimpseMouseEvent event)voidmouseWheelMoved(GlimpseMouseEvent event)voidpaintTo(GlimpseContext context)Renders this GlimpsePainter to the provided GlimpseContext.voidremoveAll()Deprecated.voidremoveAllGlimpseListeners()voidremoveAllLayouts()Removes all GlimpseLayouts added via#addLayout(GlimpseLayout).voidremoveGlimpseKeyListener(GlimpseKeyListener listener)voidremoveGlimpseMouseAllListener(GlimpseMouseAllListener listener)voidremoveGlimpseMouseListener(GlimpseMouseListener listener)voidremoveGlimpseMouseMotionListener(GlimpseMouseMotionListener listener)voidremoveGlimpseMouseWheelListener(GlimpseMouseWheelListener listener)voidremoveLayout(GlimpseLayout layout)Removes a previously added layout from this GlimpseTarget.voidremoveLayoutByKey(Object key)voidremovePainter(GlimpsePainter painter)voidremovePainterByKey(Object key)voidsetEventConsumer(boolean consume)Set whether or not this GlimpseTarget will consume or pass through mouse events.voidsetEventGenerator(boolean generate)Set whether or not this GlimpseTarget will generate GlimpseMouseEvents.voidsetLayoutData(Object layoutData)voidsetLayoutManager(GlimpseLayoutManager manager)voidsetLookAndFeel(LookAndFeel laf)Sets display options for the painter based on the provided LookAndFeel.voidsetName(String name)voidsetVisible(boolean visible)A painter which is set to non-visible should make no OpenGL calls when its paintTo method is called.voidsetZOrder(GlimpseLayout layout, int zOrder)voidsetZOrder(GlimpsePainter painter, int zOrder)Sets the relative ordering constant for this painter.StringtoString()
-
-
-
Constructor Detail
-
GlimpseLayout
public GlimpseLayout(GlimpseLayout parent, String name)
-
GlimpseLayout
public GlimpseLayout(GlimpseLayout parent)
-
GlimpseLayout
public GlimpseLayout(String name)
-
GlimpseLayout
public GlimpseLayout()
-
-
Method Detail
-
getLock
public ReentrantLock getLock()
-
getName
public String getName()
-
setName
public void setName(String name)
-
setLayoutManager
public void setLayoutManager(GlimpseLayoutManager manager)
-
setLayoutData
public void setLayoutData(Object layoutData)
-
removeLayout
public void removeLayout(GlimpseLayout layout)
Description copied from interface:GlimpseTargetRemoves a previously added layout from this GlimpseTarget.- Specified by:
removeLayoutin interfaceGlimpseTarget
-
removeLayoutByKey
public void removeLayoutByKey(Object key)
-
getLayoutByKey
public GlimpseLayout getLayoutByKey(Object key)
-
getPainterByKey
public GlimpsePainter getPainterByKey(Object key)
-
removeAllLayouts
public void removeAllLayouts()
Removes all GlimpseLayouts added via#addLayout(GlimpseLayout).- Specified by:
removeAllLayoutsin interfaceGlimpseTarget
-
removeAll
public void removeAll()
Deprecated.Historical accident caused removeAll() and removeAllLayouts() to both exist they are both retained for backwards compatibility.
-
setZOrder
public void setZOrder(GlimpseLayout layout, int zOrder)
- Specified by:
setZOrderin interfaceGlimpseTarget
-
setZOrder
public void setZOrder(GlimpsePainter painter, int zOrder)
Sets the relative ordering constant for this painter. Painters with low z order will be painter first (in the back) and those with high z order will be painted last (in the front).
The value itself has no meaning; it is relative to the z orders of the other painters in the GlimpseLayout. For
com.metsci.glimpse.layout.com.metsciGlimpseLayoutinstances, the z order also affects the order in which mouse events are delivered to overlapping components.The z order is set to 0 by default. GlimpsePainters with the same z order are painted in the order they were added to the GlimpseLayout. This means the first painters added will be obscured by later painters.
-
addLayout
public void addLayout(GlimpseLayout layout)
Description copied from interface:GlimpseTargetAdds a sub-layout to this GlimpseTarget which will only paint in a region of this GlimpseTarget based on its layout constraints. This same GlimpseLayout may be a child of any number of different GlimpseTargets.- Specified by:
addLayoutin interfaceGlimpseTarget
-
addLayout
public void addLayout(GlimpseLayout layout, GlimpsePainterCallback callback)
-
addLayout
public void addLayout(GlimpseLayout layout, int zOrder)
- Specified by:
addLayoutin interfaceGlimpseTarget
-
addLayout
public void addLayout(GlimpseLayout layout, GlimpsePainterCallback callback, int zOrder)
-
addLayout
public void addLayout(Object key, GlimpseLayout layout, GlimpsePainterCallback callback, int zOrder)
-
addPainter
public void addPainter(GlimpsePainter painter)
-
addPainter
public void addPainter(GlimpsePainter painter, GlimpsePainterCallback callback)
-
addPainter
public void addPainter(GlimpsePainter painter, int zOrder)
-
addPainter
public void addPainter(GlimpsePainter painter, GlimpsePainterCallback callback, int zOrder)
-
addPainter
public void addPainter(Object key, GlimpsePainter painter, int zOrder)
-
addPainter
public void addPainter(Object key, GlimpsePainter painter, GlimpsePainterCallback callback, int zOrder)
-
removePainterByKey
public void removePainterByKey(Object key)
-
removePainter
public void removePainter(GlimpsePainter painter)
-
invalidateLayout
public void invalidateLayout()
-
layoutTo
public GlimpseBounds layoutTo(GlimpseTargetStack stack)
-
layoutTo
public GlimpseBounds layoutTo(GlimpseContext context)
-
paintTo
public void paintTo(GlimpseContext context)
Description copied from interface:GlimpsePainterRenders this GlimpsePainter to the provided GlimpseContext. The context defines the GLContext to use. The GlimpseContext also specifies where this GlimpsePainter should be rendered via the RenderTarget contained in the GlimpseContext.- Specified by:
paintToin interfaceGlimpsePainter
-
getTargetBounds
public GlimpseBounds getTargetBounds(GlimpseTargetStack stack)
Description copied from interface:GlimpseTargetReturns the cached or calculated bounds of this GlimpseTarget for a particular context.- Specified by:
getTargetBoundsin interfaceGlimpseTarget- Returns:
- the bounds for the given stack
-
getTargetChildren
public List<GlimpseTarget> getTargetChildren()
- Specified by:
getTargetChildrenin interfaceGlimpseTarget- Returns:
- the list of children added through addLayout( GlimpseLayout ).
-
dispose
public void dispose(GlimpseContext context)
Description copied from interface:GlimpsePainterFree GPU and CPU memory associated with this this GlimpsePainter. After this call returns, the results of calling other GlimpsePainter methods besides isDisposed( ) are undefined.- Specified by:
disposein interfaceGlimpsePainter
-
isDisposed
public boolean isDisposed()
- Specified by:
isDisposedin interfaceGlimpsePainter
-
getGlimpseMouseListeners
public Collection<GlimpseMouseListener> getGlimpseMouseListeners()
- Specified by:
getGlimpseMouseListenersin interfaceMouseable
-
getGlimpseMouseMotionListeners
public Collection<GlimpseMouseMotionListener> getGlimpseMouseMotionListeners()
- Specified by:
getGlimpseMouseMotionListenersin interfaceMouseable
-
getGlimpseMouseWheelListeners
public Collection<GlimpseMouseWheelListener> getGlimpseMouseWheelListeners()
- Specified by:
getGlimpseMouseWheelListenersin interfaceMouseable
-
getGlimpseKeyListeners
public Collection<GlimpseKeyListener> getGlimpseKeyListeners()
- Specified by:
getGlimpseKeyListenersin interfaceKeyable
-
addGlimpseMouseListener
public void addGlimpseMouseListener(GlimpseMouseListener listener)
- Specified by:
addGlimpseMouseListenerin interfaceMouseable
-
addGlimpseMouseMotionListener
public void addGlimpseMouseMotionListener(GlimpseMouseMotionListener listener)
- Specified by:
addGlimpseMouseMotionListenerin interfaceMouseable
-
addGlimpseMouseWheelListener
public void addGlimpseMouseWheelListener(GlimpseMouseWheelListener listener)
- Specified by:
addGlimpseMouseWheelListenerin interfaceMouseable
-
addGlimpseMouseAllListener
public void addGlimpseMouseAllListener(GlimpseMouseAllListener listener)
- Specified by:
addGlimpseMouseAllListenerin interfaceMouseable
-
removeGlimpseMouseAllListener
public void removeGlimpseMouseAllListener(GlimpseMouseAllListener listener)
- Specified by:
removeGlimpseMouseAllListenerin interfaceMouseable
-
addGlimpseKeyListener
public void addGlimpseKeyListener(GlimpseKeyListener listener)
- Specified by:
addGlimpseKeyListenerin interfaceKeyable
-
removeGlimpseMouseListener
public void removeGlimpseMouseListener(GlimpseMouseListener listener)
- Specified by:
removeGlimpseMouseListenerin interfaceMouseable
-
removeGlimpseMouseMotionListener
public void removeGlimpseMouseMotionListener(GlimpseMouseMotionListener listener)
- Specified by:
removeGlimpseMouseMotionListenerin interfaceMouseable
-
removeGlimpseMouseWheelListener
public void removeGlimpseMouseWheelListener(GlimpseMouseWheelListener listener)
- Specified by:
removeGlimpseMouseWheelListenerin interfaceMouseable
-
removeGlimpseKeyListener
public void removeGlimpseKeyListener(GlimpseKeyListener listener)
- Specified by:
removeGlimpseKeyListenerin interfaceKeyable
-
removeAllGlimpseListeners
public void removeAllGlimpseListeners()
- Specified by:
removeAllGlimpseListenersin interfaceKeyable- Specified by:
removeAllGlimpseListenersin interfaceMouseable
-
getLayoutManager
public GlimpseLayoutManager getLayoutManager()
-
mouseEntered
public void mouseEntered(GlimpseMouseEvent event)
- Specified by:
mouseEnteredin interfaceGlimpseMouseListener
-
mouseExited
public void mouseExited(GlimpseMouseEvent event)
- Specified by:
mouseExitedin interfaceGlimpseMouseListener
-
mousePressed
public void mousePressed(GlimpseMouseEvent event)
- Specified by:
mousePressedin interfaceGlimpseMouseListener
-
mouseReleased
public void mouseReleased(GlimpseMouseEvent event)
- Specified by:
mouseReleasedin interfaceGlimpseMouseListener
-
mouseMoved
public void mouseMoved(GlimpseMouseEvent event)
- Specified by:
mouseMovedin interfaceGlimpseMouseMotionListener
-
mouseWheelMoved
public void mouseWheelMoved(GlimpseMouseEvent event)
- Specified by:
mouseWheelMovedin interfaceGlimpseMouseWheelListener
-
keyPressed
public void keyPressed(GlimpseKeyEvent event)
- Specified by:
keyPressedin interfaceGlimpseKeyListener
-
keyReleased
public void keyReleased(GlimpseKeyEvent event)
- Specified by:
keyReleasedin interfaceGlimpseKeyListener
-
setLookAndFeel
public void setLookAndFeel(LookAndFeel laf)
Description copied from interface:GlimpsePainterSets display options for the painter based on the provided LookAndFeel.- Specified by:
setLookAndFeelin interfaceGlimpsePainter- Specified by:
setLookAndFeelin interfaceGlimpseTarget
-
isEventConsumer
public boolean isEventConsumer()
Event consumers do not pass on mouse events to their parents.- Specified by:
isEventConsumerin interfaceGlimpseTarget- Returns:
- whether this target hides events from targets under it
-
setEventConsumer
public void setEventConsumer(boolean consume)
Description copied from interface:GlimpseTargetSet whether or not this GlimpseTarget will consume or pass through mouse events.- Specified by:
setEventConsumerin interfaceGlimpseTarget
-
isEventGenerator
public boolean isEventGenerator()
Event generators do not generate mouse events if they are the top layout when a mouse event occurs.- Specified by:
isEventGeneratorin interfaceGlimpseTarget- Returns:
- whether this target will generate GlimpseMouseEvents
-
setEventGenerator
public void setEventGenerator(boolean generate)
Description copied from interface:GlimpseTargetSet whether or not this GlimpseTarget will generate GlimpseMouseEvents.- Specified by:
setEventGeneratorin interfaceGlimpseTarget
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:GlimpsePainterA painter which is set to non-visible should make no OpenGL calls when its paintTo method is called.- Specified by:
setVisiblein interfaceGlimpsePainter
-
isVisible
public boolean isVisible()
Description copied from interface:GlimpseTargetIf true, the GlimpseTarget should be drawn on the screen and mouse events should be dispatched for it. Otherwise it is invisible and mouse events should not fire for the GlimpseTarget or its children.- Specified by:
isVisiblein interfaceGlimpsePainter- Specified by:
isVisiblein interfaceGlimpseTarget
-
-