Class LayeredSurfaceFrame

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants, EventListener

public class LayeredSurfaceFrame extends JInternalFrame implements EventListener
It is the Space Viewer window. It draws grid layers using a list of ILayerDrawer objects. See Layered<type>GridDrawer classes of this library. They are wrapper classes for Grid objects of the jas.space.* library and are able to plot their contents.

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

    • LayeredSurfaceFrame

      public LayeredSurfaceFrame(int width, int height)
      Create a new frame with given dimensions and a cell length of 4 pixels.
      Parameters:
      width - The width of the grid to plot.
      height - The height of the grid to plot.
      Throws:
      IllegalArgumentException - if width <= 0 || height <= 0.
    • LayeredSurfaceFrame

      public LayeredSurfaceFrame(int width, int height, int cellLength)
      Create a new frame 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.
      Throws:
      IllegalArgumentException - if width <= 0 || height <= 0.
    • LayeredSurfaceFrame

      public LayeredSurfaceFrame(int width, int height, int gridWidth, int gridHeight, int cellLength)
      Create a new frame with given dimensions, given cell length and given view-port dimensions.
      Parameters:
      width - The width of the viewable area in cells.
      height - The height of the viewable area in cells.
      gridWidth - The real width of the grid to plot.
      gridHeight - The real height of the grid to plot.
      cellLength - The lenght of a grid cell in pixels.
      Throws:
      IllegalArgumentException - if width <= 0 || height <= 0.
  • Method Details

    • setCellLength

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

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

      public void update()
      Repaint the plot area.
    • setSize

      public void setSize(int x, int y)
      Update the window size according to the parameters passed to the constructor.
      Overrides:
      setSize in class Component
      Parameters:
      x - It is ignored. The width is computed automatically.
      y - It is ignored. The height is computed automatically.
    • onEvent

      public void onEvent(Enum<?> type)
      React to system events.
      Specified by:
      onEvent in interface EventListener
      Parameters:
      type - Reacts to the Sim.EVENT_UPDATE event repainting the plot area.