Class BasicCanvasPane

  • All Implemented Interfaces:
    CanvasComponent, EventAcceptor

    public class BasicCanvasPane
    extends CanvasPane
    A basic implementation of a canvas pane, provided for simple applications. This class keeps a linear list of canvas layers, and provides a couple of methods so that layers can be added to it. Real applications will probably want to create their own CanvasPane subclass, instead of using this class.
    John Reekie
    • Constructor Detail

      • BasicCanvasPane

        public BasicCanvasPane()
        Create a new canvas pane with a single figure layer at index zero. This is a convenience constructor for test suites and simple demos -- in general, an application will want to construct a more sophisticated set of layers.
      • BasicCanvasPane

        public BasicCanvasPane​(CanvasLayer layer)
        Create a new canvas pane with the given layer at index zero.
    • Method Detail

      • addLayer

        public void addLayer​(CanvasLayer layer)
        Add the given layer to the list of layers. The new layer will be drawn over the top of any existing layers.
      • addLayer

        public void addLayer​(int index,
                             CanvasLayer layer)
        Insert the given layer into the list of layers at the given index. Lower indexes are drawn above higher indexes.
      • getLayer

        public FigureLayer getLayer​(int index)
        Get the layer at the given index.
      • indexOf

        public int indexOf​(CanvasLayer layer)
        Get the index of the given layer, or -1 if it is not in this pane.
      • layersFromFront

        public java.util.Iterator layersFromFront()
        Return an iteration of the layers, in event-processing order (that is, from front to back).
        Specified by:
        layersFromFront in class CanvasPane
        The iterator.
      • layersFromBack

        public java.util.Iterator layersFromBack()
        Return an iteration of the layers, in redraw order (that is, from back to front).
        Specified by:
        layersFromBack in class CanvasPane
        The iterator.
      • removeLayer

        public void removeLayer​(CanvasLayer layer)
        Remove the given layer. Do nothing if the layer is not in this pane.