Class LayeredSurfacePanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class LayeredSurfacePanel extends JPanel
Not of interest for users. It is the panel drawing the Layer<type>Drawer objects added to the LayeredSurfaceFrame. It manages mouse events, too.

Title: JAS

Description: Java Agent-based Simulation library

Copyright (C) 2002 Michele Sonnessa

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
Author:
Michele Sonnessa

See Also:
  • Constructor Details

    • LayeredSurfacePanel

      public LayeredSurfacePanel()
      Create a panel with dimensions of (100, 100) and a cell length of 4 pixels.
    • LayeredSurfacePanel

      public LayeredSurfacePanel(int width, int height, int cellLength)
      Create a panel with given dimensions and given cell length.
      Parameters:
      width - The width of the grid to plot.
      height - The height of the grid to plot.
      cellLength - The lenght of a grid cell in pixels.
  • Method Details

    • getBackgroundColor

      public Color getBackgroundColor()
      Return the current background color.
      Returns:
      The current background color. Null if color has been not set.
    • setBackgroundColor

      public void setBackgroundColor(Color color)
      Set the current background color.
      Parameters:
      color - The current background color.
    • setVirtualSize

      public void setVirtualSize(int width, int height)
      Change the size of the grid.
      Parameters:
      width - The width of the grid to plot.
      height - The height of the grid to plot.
    • addLayer

      public void addLayer(ILayerDrawer layer)
      Add a ILayerDrawer to the layer list.
      Parameters:
      layer - The ILayerDrawer to be plotted.
    • getLayers

      public List<ILayerDrawer> getLayers()
      Return the list of current added layers.
      Returns:
      An ArrayList of ILayerDrawer objects.
    • setCellLength

      public void setCellLength(int cellLength)
      Change the current cell length.
      Parameters:
      cellLength - The new cell length in pixels.
    • paintComponent

      public void paintComponent(Graphics g)
      Draw the panel.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - The graphic context passed by container.