Class LayerMultiObjectGridDrawer
java.lang.Object
microsim.gui.space.LayerMultiObjectGridDrawer
- All Implemented Interfaces:
ILayerDrawer, ILayerMouseListener
It is able to draw objects contained by a MultiObjGrid on a
LayeredSurfaceFrame.
When on a cell there is at least one object it is represented by a circle. The objects are drawn using one given color.
When on a cell there is at least one object it is represented by a circle. The objects are drawn using one given color.
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
-
Constructor Summary
ConstructorsConstructorDescriptionLayerMultiObjectGridDrawer(String name, MultiObjectSpace matrix, Color color) Create a new object drawer based on a given MultiObjGrid object.LayerMultiObjectGridDrawer(String name, MultiObjectSpace matrix, String agentProperty, ColorMap map) Create a new object drawer based on a given MultiObjGrid object. -
Method Summary
Modifier and TypeMethodDescriptionReturn the name of the layer.booleanReturn if the layer is currently displayed on the LayeredSurfaceFrame.voidDraw the layer using the given cell length.booleanperformDblClickActionAt(int atX, int atY) If a mouse listener has been defined the double-click event, it is passed to it, otherwise it is shown a CellObjectChooser that allows the user to choose which object to be probed.booleanperformMouseMovedFromTo(int fromX, int fromY, int toX, int toY) If a mouse listener has been defined the mouse dragging event, it is passed to it, otherwise it is returned false.booleanperformRightClickActionAt(int atX, int atY) If a mouse listener has been defined the right-click event, it is passed to it, otherwise it is returned false.voidsetDisplay(boolean display) Decide if layer has to be painted or not.voidsetMouseListener(ILayerMouseListener listener) Set a manager for mouse events.
-
Constructor Details
-
LayerMultiObjectGridDrawer
Create a new object drawer based on a given MultiObjGrid object. It plots the objects using the given color.- Parameters:
name- The string describing the layer.matrix- A MultiObjGrid object.color- The default color used to plot objects.
-
LayerMultiObjectGridDrawer
public LayerMultiObjectGridDrawer(String name, MultiObjectSpace matrix, String agentProperty, ColorMap map) Create a new object drawer based on a given MultiObjGrid object. It plots the objects using the color of the first object found on each cell.- Parameters:
name- The string describing the layer.matrix- A MultiObjGrid object.
-
-
Method Details
-
isDisplayed
public boolean isDisplayed()Return if the layer is currently displayed on the LayeredSurfaceFrame.- Specified by:
isDisplayedin interfaceILayerDrawer- Returns:
- True if it is currently painted, false otherwise.
-
setDisplay
public void setDisplay(boolean display) Decide if layer has to be painted or not.- Specified by:
setDisplayin interfaceILayerDrawer- Parameters:
display- True if you want the layer to be painted, false otherwise.
-
getDescription
Return the name of the layer.- Specified by:
getDescriptionin interfaceILayerDrawer- Returns:
- The name passed to the constructor.
-
paint
Draw the layer using the given cell length.- Specified by:
paintin interfaceILayerDrawer- Parameters:
g- The graphic context passed by container.cellLen- The length of a cell in pixels.
-
setMouseListener
Set a manager for mouse events. If not defined, mouse events are managed by the class itself.- Parameters:
listener- A ILayerMouseListener object.
-
performDblClickActionAt
public boolean performDblClickActionAt(int atX, int atY) If a mouse listener has been defined the double-click event, it is passed to it, otherwise it is shown a CellObjectChooser that allows the user to choose which object to be probed.- Specified by:
performDblClickActionAtin interfaceILayerMouseListener- Parameters:
atX- The x coordinate of the clicked cell.atY- The y coordinate of the clicked cell.- Returns:
- always true if no mouse listener is defined. This value is used by caller to know if the layer wants to manage the event.
-
performRightClickActionAt
public boolean performRightClickActionAt(int atX, int atY) If a mouse listener has been defined the right-click event, it is passed to it, otherwise it is returned false.- Specified by:
performRightClickActionAtin interfaceILayerMouseListener- Parameters:
atX- The x coordinate of the clicked cell.atY- The y coordinate of the clicked cell.- Returns:
- always false if no mouse listener is defined. This value is used by caller to know if the layer wants to manage the event.
-
performMouseMovedFromTo
public boolean performMouseMovedFromTo(int fromX, int fromY, int toX, int toY) If a mouse listener has been defined the mouse dragging event, it is passed to it, otherwise it is returned false.- Specified by:
performMouseMovedFromToin interfaceILayerMouseListener- Parameters:
fromX- The x coordinate of the starting cell.fromY- The y coordinate of the starting cell.toX- The x coordinate of the last dragged cell.toY- The y coordinate of the last dragged cell.- Returns:
- always false if no mouse listener is defined. This value is used by caller to know if the layer wants to manage the event.
-