Class HTMLGridPanel

java.lang.Object
nl.tudelft.simulation.dsol.web.animation.D2.HTMLGridPanel
All Implemented Interfaces:
ImageObserver
Direct Known Subclasses:
HTMLAnimationPanel

public class HTMLGridPanel
extends Object
implements ImageObserver
The GridPanel introduces the gridPanel.

Copyright (c) 2002-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://simulation.tudelft.nl/dsol/3.0/license.html.

Author:
Niels Lang , Peter Jacobs
  • Field Details

  • Constructor Details

    • HTMLGridPanel

      public HTMLGridPanel​(Rectangle2D extent)
      constructs a new GridPanel.
      Parameters:
      extent - Rectangle2D; the extent to show.
    • HTMLGridPanel

      public HTMLGridPanel​(Rectangle2D extent, Dimension size)
      constructs a new GridPanel.
      Parameters:
      extent - Rectangle2D; the initial extent.
      size - Dimension; the size of the panel in pixels.
  • Method Details

    • getDrawingCommands

      public String getDrawingCommands()
      Return the set of drawing commands.
      Returns:
      the set of drawing commands
    • paintComponent

      public void paintComponent​(HTMLGraphics2D g)
      Draw the grid.
      Parameters:
      g - HTMLGraphics2D; the virtual Graphics2D canvas to enable writing to the browser
    • showGrid

      public final void showGrid​(boolean bool)
      show the grid?
      Parameters:
      bool - boolean; true/false
    • getExtent

      public final Rectangle2D getExtent()
      returns the extent of this panel.
      Returns:
      Rectangle2D
    • setWorldCoordinate

      public final void setWorldCoordinate​(Point2D point)
      Set the world coordinates based on a mouse move.
      Parameters:
      point - Point2D; the x,y world coordinates
    • getWorldCoordinate

      public final Point2D getWorldCoordinate()
      Returns:
      worldCoordinate
    • displayWorldCoordinateToolTip

      public final void displayWorldCoordinateToolTip()
      Display a tooltip with the last known world coordinates of the mouse, in case the tooltip should be displayed.
    • isShowToolTip

      public final boolean isShowToolTip()
      Returns:
      showToolTip
    • setShowToolTip

      public final void setShowToolTip​(boolean showToolTip)
      Parameters:
      showToolTip - boolean; set showToolTip
    • pan

      public final void pan​(int direction, double percentage)
      pans the panel in a specified direction.
      Parameters:
      direction - int; the direction
      percentage - double; the percentage
    • home

      public final void home()
      resets the panel to its original extent.
    • isShowGrid

      public final boolean isShowGrid()
      Returns:
      Returns the showGrid.
    • setShowGrid

      public final void setShowGrid​(boolean showGrid)
      Parameters:
      showGrid - boolean; The showGrid to set.
    • zoom

      public final void zoom​(double factor)
      zooms in/out.
      Parameters:
      factor - double; The zoom factor
    • zoom

      public final void zoom​(double factor, int mouseX, int mouseY)
      zooms in/out.
      Parameters:
      factor - double; The zoom factor
      mouseX - int; x-position of the mouse around which we zoom
      mouseY - int; y-position of the mouse around which we zoom
    • drawGrid

      protected void drawGrid​(Graphics g)
      Added to make sure the recursive render-call calls THIS render method instead of a potential super-class defined 'paintComponent' render method.
      Parameters:
      g - Graphics; the graphics object
    • repaint

      public void repaint()
      Repaint the shadow canvas.
    • getSize

      public final Dimension getSize()
      Returns:
      size
    • setSize

      public final void setSize​(Dimension size)
      Parameters:
      size - Dimension; set size
    • getBackground

      public final Color getBackground()
      Returns:
      background
    • setBackground

      public final void setBackground​(Color background)
      Parameters:
      background - Color; set background
    • getWidth

      public final int getWidth()
      Returns:
      width
    • getHeight

      public final int getHeight()
      Returns:
      height
    • getPreferredSize

      public final Dimension getPreferredSize()
      Returns:
      preferredSize
    • setPreferredSize

      public final void setPreferredSize​(Dimension preferredSize)
      Parameters:
      preferredSize - Dimension; set preferredSize
    • getToolTipText

      public final String getToolTipText()
      Returns:
      toolTipText
    • setToolTipText

      public final void setToolTipText​(String toolTipText)
      Parameters:
      toolTipText - String; set toolTipText
    • isShowing

      public final boolean isShowing()
      Returns:
      showing
    • setShowing

      public final void setShowing​(boolean showing)
      Parameters:
      showing - boolean; set showing
    • getFont

      public final Font getFont()
      Returns:
      font
    • setFont

      public final void setFont​(Font font)
      Parameters:
      font - Font; set font
    • getFontMetrics

      public final FontMetrics getFontMetrics​(Font font)
      Parameters:
      font - Font; the font to calculate the fontmetrics for
      Returns:
      fontMetrics
    • isDirty

      public final boolean isDirty()
      Returns:
      dirty
    • imageUpdate

      public boolean imageUpdate​(Image img, int infoflags, int x, int y, int width, int height)
      Specified by:
      imageUpdate in interface ImageObserver