Class HtmlGridPanel
java.lang.Object
nl.tudelft.simulation.dsol.web.animation.d2.HtmlGridPanel
- All Implemented Interfaces:
ImageObserver
- Direct Known Subclasses:
HtmlAnimationPanel
The VisualizationPanel introduces the gridPanel.
Copyright (c) 2003-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. BSD-style license. See OpenTrafficSim License.
- Author:
- Niels Lang , Peter Jacobs
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
the DOWN directions for moving/zooming.protected org.djutils.draw.bounds.Bounds2d
the extent of this panel.protected NumberFormat
the formatter to use.protected static final Color
gridColor.protected double
the gridSize for the X-direction in world Units.protected double
the gridSize for the Y-direction in world Units.protected org.djutils.draw.bounds.Bounds2d
the extent of this panel.protected HtmlGraphics2d
the HTMLGraphics2D 'shadow' canvas.protected Dimension
the last computed Dimension.static final int
the LEFT directions for moving/zooming.protected Dimension
the last computed Dimension.protected nl.tudelft.simulation.dsol.animation.d2.RenderableScale
the renderable scale (X/Y ratio) to use.static final int
the RIGHT directions for moving/zooming.protected boolean
show the grid.protected boolean
whether to show a tooltip with the coordinates or not.protected Dimension
the last computed Dimension.static final int
the UP directions for moving/zooming.protected org.djutils.draw.point.Point2d
the last known world coordinate of the mouse.static final double
the ZOOM factor.Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorDescriptionHtmlGridPanel
(org.djutils.draw.bounds.Bounds2d extent) constructs a new VisualizationPanel.HtmlGridPanel
(org.djutils.draw.bounds.Bounds2d extent, Dimension size) constructs a new VisualizationPanel. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Display a tooltip with the last known world coordinates of the mouse, in case the tooltip should be displayed.protected void
Added to make sure the recursive render-call calls THIS render method instead of a potential super-class defined 'paintComponent' render method.final Color
Return the set of drawing commands.final org.djutils.draw.bounds.Bounds2d
returns the extent of this panel.final Font
getFont()
final FontMetrics
getFontMetrics
(Font font) final int
final Dimension
final nl.tudelft.simulation.dsol.animation.d2.RenderableScale
final Dimension
getSize()
final String
final int
getWidth()
final org.djutils.draw.point.Point2d
final void
home()
resets the panel to its original extent.boolean
imageUpdate
(Image img, int infoflags, int x, int y, int width, int height) final boolean
isDirty()
final boolean
final boolean
final boolean
void
Draw the grid.final void
pan
(int direction, double percentage) pans the panel in a specified direction.void
repaint()
Repaint the shadow canvas.final void
setBackground
(Color background) final void
setExtent
(org.djutils.draw.bounds.Bounds2d extent) set a new extent for this panel.final void
final void
setPreferredSize
(Dimension preferredSize) final void
setRenderableScale
(nl.tudelft.simulation.dsol.animation.d2.RenderableScale renderableScale) final void
setShowGrid
(boolean showGrid) final void
setShowing
(boolean showing) final void
setShowToolTip
(boolean showToolTip) final void
final void
setToolTipText
(String toolTipText) final void
setWorldCoordinate
(org.djutils.draw.point.Point2d point) Set the world coordinates based on a mouse move.final void
showGrid
(boolean bool) show the grid?final void
zoom
(double factor) zooms in/out.final void
zoom
(double factor, int mouseX, int mouseY) zooms in/out.
-
Field Details
-
UP
public static final int UPthe UP directions for moving/zooming.- See Also:
-
DOWN
public static final int DOWNthe DOWN directions for moving/zooming.- See Also:
-
LEFT
public static final int LEFTthe LEFT directions for moving/zooming.- See Also:
-
RIGHT
public static final int RIGHTthe RIGHT directions for moving/zooming.- See Also:
-
ZOOMFACTOR
public static final double ZOOMFACTORthe ZOOM factor.- See Also:
-
GRIDCOLOR
gridColor. -
extent
protected org.djutils.draw.bounds.Bounds2d extentthe extent of this panel. -
homeExtent
protected org.djutils.draw.bounds.Bounds2d homeExtentthe extent of this panel. -
showGrid
protected boolean showGridshow the grid. -
gridSizeX
protected double gridSizeXthe gridSize for the X-direction in world Units. -
gridSizeY
protected double gridSizeYthe gridSize for the Y-direction in world Units. -
formatter
the formatter to use. -
lastDimension
the last computed Dimension. -
size
the last computed Dimension. -
preferredSize
the last computed Dimension. -
worldCoordinate
protected org.djutils.draw.point.Point2d worldCoordinatethe last known world coordinate of the mouse. -
showToolTip
protected boolean showToolTipwhether to show a tooltip with the coordinates or not. -
htmlGraphics2D
the HTMLGraphics2D 'shadow' canvas. -
renderableScale
protected nl.tudelft.simulation.dsol.animation.d2.RenderableScale renderableScalethe renderable scale (X/Y ratio) to use.
-
-
Constructor Details
-
HtmlGridPanel
public HtmlGridPanel(org.djutils.draw.bounds.Bounds2d extent) constructs a new VisualizationPanel.- Parameters:
extent
- Bounds2d; the extent to show.
-
HtmlGridPanel
constructs a new VisualizationPanel.- Parameters:
extent
- Bounds2d; the initial extent.size
- Dimension; the size of the panel in pixels.
-
-
Method Details
-
getDrawingCommands
Return the set of drawing commands.- Returns:
- the set of drawing commands
-
paintComponent
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 org.djutils.draw.bounds.Bounds2d getExtent()returns the extent of this panel.- Returns:
- Bounds2d
-
setExtent
public final void setExtent(org.djutils.draw.bounds.Bounds2d extent) set a new extent for this panel.- Parameters:
extent
- Bounds2d; set a new extent
-
setWorldCoordinate
public final void setWorldCoordinate(org.djutils.draw.point.Point2d point) Set the world coordinates based on a mouse move.- Parameters:
point
- Point2d; the x,y world coordinates
-
getWorldCoordinate
public final org.djutils.draw.point.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 directionpercentage
- 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 factormouseX
- int; x-position of the mouse around which we zoommouseY
- int; y-position of the mouse around which we zoom
-
drawGrid
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
-
getRenderableScale
public final nl.tudelft.simulation.dsol.animation.d2.RenderableScale getRenderableScale()- Returns:
- renderableScale
-
setRenderableScale
public final void setRenderableScale(nl.tudelft.simulation.dsol.animation.d2.RenderableScale renderableScale) - Parameters:
renderableScale
- RenderableScale; set renderableScale
-
repaint
public void repaint()Repaint the shadow canvas. -
getSize
- Returns:
- size
-
setSize
- Parameters:
size
- Dimension; set size
-
getBackground
- Returns:
- background
-
setBackground
- Parameters:
background
- Color; set background
-
getWidth
public final int getWidth()- Returns:
- width
-
getHeight
public final int getHeight()- Returns:
- height
-
getPreferredSize
- Returns:
- preferredSize
-
setPreferredSize
- Parameters:
preferredSize
- Dimension; set preferredSize
-
getToolTipText
- Returns:
- toolTipText
-
setToolTipText
- 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
- Returns:
- font
-
setFont
- Parameters:
font
- Font; set font
-
getFontMetrics
- Parameters:
font
- Font; the font to calculate the fontmetrics for- Returns:
- fontMetrics
-
isDirty
public final boolean isDirty()- Returns:
- dirty
-
imageUpdate
- Specified by:
imageUpdate
in interfaceImageObserver
-