public class HTMLGridPanel extends Object implements ImageObserver
Copyright (c) 2002-2019 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.
| Modifier and Type | Field and Description |
|---|---|
static int |
DOWN
the DOWN directions for moving/zooming.
|
protected Rectangle2D |
extent
the extent of this panel.
|
protected NumberFormat |
formatter
the formatter to use.
|
protected static Color |
GRIDCOLOR
gridColor.
|
protected double |
gridSize
the gridSize in world Units.
|
protected Rectangle2D |
homeExtent
the extent of this panel.
|
protected HTMLGraphics2D |
htmlGraphics2D
the HTMLGraphics2D 'shadow' canvas.
|
protected Dimension |
lastDimension
the last computed Dimension.
|
static int |
LEFT
the LEFT directions for moving/zooming.
|
protected Dimension |
preferredSize
the last computed Dimension.
|
static int |
RIGHT
the RIGHT directions for moving/zooming.
|
protected boolean |
showGrid
show the grid.
|
protected boolean |
showToolTip
whether to show a tooltip with the coordinates or not.
|
protected Dimension |
size
the last computed Dimension.
|
static int |
UP
the UP directions for moving/zooming.
|
protected Point2D |
worldCoordinate
the last known world coordinate of the mouse.
|
static double |
ZOOMFACTOR
the ZOOM factor.
|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
HTMLGridPanel(Rectangle2D extent)
constructs a new GridPanel.
|
HTMLGridPanel(Rectangle2D extent,
Dimension size)
constructs a new GridPanel.
|
| Modifier and Type | Method and Description |
|---|---|
void |
displayWorldCoordinateToolTip()
Display a tooltip with the last known world coordinates of the mouse, in case the tooltip should be displayed.
|
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.
|
Color |
getBackground() |
String |
getDrawingCommands()
Return the set of drawing commands.
|
Rectangle2D |
getExtent()
returns the extent of this panel.
|
Font |
getFont() |
FontMetrics |
getFontMetrics(Font font) |
int |
getHeight() |
Dimension |
getPreferredSize() |
Dimension |
getSize() |
String |
getToolTipText() |
int |
getWidth() |
Point2D |
getWorldCoordinate() |
void |
home()
resets the panel to its original extent.
|
boolean |
imageUpdate(Image img,
int infoflags,
int x,
int y,
int width,
int height) |
boolean |
isDirty() |
boolean |
isShowGrid() |
boolean |
isShowing() |
boolean |
isShowToolTip() |
void |
paintComponent(HTMLGraphics2D g)
Draw the grid.
|
void |
pan(int direction,
double percentage)
pans the panel in a specified direction.
|
void |
repaint()
Repaint the shadow canvas.
|
void |
setBackground(Color background) |
void |
setFont(Font font) |
void |
setPreferredSize(Dimension preferredSize) |
void |
setShowGrid(boolean showGrid) |
void |
setShowing(boolean showing) |
void |
setShowToolTip(boolean showToolTip) |
void |
setSize(Dimension size) |
void |
setToolTipText(String toolTipText) |
void |
setWorldCoordinate(Point2D point)
Set the world coordinates based on a mouse move.
|
void |
showGrid(boolean bool)
show the grid?
|
void |
zoom(double factor)
zooms in/out.
|
void |
zoom(double factor,
int mouseX,
int mouseY)
zooms in/out.
|
public static final int UP
public static final int DOWN
public static final int LEFT
public static final int RIGHT
public static final double ZOOMFACTOR
protected static final Color GRIDCOLOR
protected Rectangle2D extent
protected Rectangle2D homeExtent
protected boolean showGrid
protected double gridSize
protected NumberFormat formatter
protected Dimension lastDimension
protected Dimension size
protected Dimension preferredSize
protected Point2D worldCoordinate
protected boolean showToolTip
protected HTMLGraphics2D htmlGraphics2D
public HTMLGridPanel(Rectangle2D extent)
extent - Rectangle2D; the extent to show.public HTMLGridPanel(Rectangle2D extent, Dimension size)
extent - Rectangle2D; the initial extent.size - Dimension; the size of the panel in pixels.public String getDrawingCommands()
public void paintComponent(HTMLGraphics2D g)
g - HTMLGraphics2D; the virtual Graphics2D canvas to enable writing to the browserpublic final void showGrid(boolean bool)
bool - boolean; true/falsepublic final Rectangle2D getExtent()
public final void setWorldCoordinate(Point2D point)
point - Point2D; the x,y world coordinatespublic final Point2D getWorldCoordinate()
public final void displayWorldCoordinateToolTip()
public final boolean isShowToolTip()
public final void setShowToolTip(boolean showToolTip)
showToolTip - boolean; set showToolTippublic final void pan(int direction,
double percentage)
direction - int; the directionpercentage - double; the percentagepublic final void home()
public final boolean isShowGrid()
public final void setShowGrid(boolean showGrid)
showGrid - boolean; The showGrid to set.public final void zoom(double factor)
factor - double; The zoom factorpublic final void zoom(double factor,
int mouseX,
int mouseY)
factor - double; The zoom factormouseX - int; x-position of the mouse around which we zoommouseY - int; y-position of the mouse around which we zoomprotected void drawGrid(Graphics g)
g - Graphics; the graphics objectpublic void repaint()
public final Dimension getSize()
public final void setSize(Dimension size)
size - Dimension; set sizepublic final Color getBackground()
public final void setBackground(Color background)
background - Color; set backgroundpublic final int getWidth()
public final int getHeight()
public final Dimension getPreferredSize()
public final void setPreferredSize(Dimension preferredSize)
preferredSize - Dimension; set preferredSizepublic final String getToolTipText()
public final void setToolTipText(String toolTipText)
toolTipText - String; set toolTipTextpublic final boolean isShowing()
public final void setShowing(boolean showing)
showing - boolean; set showingpublic final Font getFont()
public final void setFont(Font font)
font - Font; set fontpublic final FontMetrics getFontMetrics(Font font)
font - Font; the font to calculate the fontmetrics forpublic final boolean isDirty()
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height)
imageUpdate in interface ImageObserverCopyright © 2014–2019 Delft University of Technology. All rights reserved.