Package edu.cnu.mdi.container
Interface IContainer
- All Known Implementing Classes:
BaseContainer,MapContainer
public interface IContainer
A 2D drawing container with a world coordinate system and conversion to pixel
(screen) coordinates. Implementations are typically Swing components that
render one or more
IDrawables.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe factor used for fixed zooms. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a z layer for containing items rendered on this container..booleanCheck whether at least one item on any item list is selected.doubleGet the approximate zoom factor based on the current and default world systems.voidDelete all selected items, across all item lists.voidfeedbackTrigger(MouseEvent mouseEvent, boolean dragging) Convenience method to update the location string in the toolbar.Get the annotation layer for this container.Get the underlying JComponentGet the connection layer for this container.Get the default user content layer for this container.getEnclosedItems(Rectangle rect) Obtain a collection of all enclosed items across all lists.Return the object that controls the container's feedback.Get the optional feedback pane.default HoverInfoWindowGet the hover info window for this container, if any.getImage()Get the background image.getItemAtPoint(Point lp) Find an item, if any, at the point.getItemsAtPoint(Point lp) Find all items, if any, at the point.getLayerByName(String name) Gets an z layer by name.Get all selected items, across all item lists.Get this container's tool bar interface.getView()Get the view (internal frame) that holds this container.Get the current world system.voidlocalToWorld(Point pp, Point2D.Double wp) This converts a screen or pixel point to a world point.voidlocalToWorld(Polygon polygon, WorldPolygon worldPolygon) This converts a screen or local polygon to a world polygon.voidThis converts a screen or local rectangle to a world rectangle.voidpan(int dh, int dv) Pan the container.voidPrepare for exiting the application.voidBegin preparations for a zoom.voidRecenter the container at the point of a click.voidrefresh()Refresh the container.voidresetWorldSystem(Rectangle2D.Double worldSystem) Reset the world system to a new value.voidRestore the default world.voidThis is called when we have completed a rubber banding.voidscale(double scaleFactor) Convenience routine to scale the container.voidselectAllItems(boolean select) Select or deselect all items, across all item lists.voidsetAfterDraw(IDrawable afterDraw) Set the after-draw drawable for this container.voidsetBeforeDraw(IDrawable beforeDraw) Set the before-draw drawable.voidsetDirty(boolean dirty) Convenience method for setting the dirty flag for all items on all item lists.voidsetFeedbackPane(FeedbackPane feedbackPane) Sets the feedback pane.voidsetToolBar(AToolBar toolBar) Set this container's tool bar.voidSet the container's view.voidSet the world system (does not cause redraw)voidUndo that last zoom.default voidupdateStatusText(Point pp, Point2D.Double wp) Update the status text in the toolbar, if any.voidworldToLocal(Point pp, double wx, double wy) This converts a world point to a screen or pixel point.voidworldToLocal(Point pp, Point2D.Double wp) This converts a world point to a screen or pixel point.voidworldToLocal(Polygon polygon, WorldPolygon worldPolygon) This converts a world polygon to a screen or pixel polygon.voidThis converts a world rectangle to a screen or pixel rectangle.voidzoom(double xmin, double xmax, double ymin, double ymax) Zooms to the specified area.
-
Field Details
-
FIXED_ZOOM_FACTOR
static final double FIXED_ZOOM_FACTORThe factor used for fixed zooms.- See Also:
-
-
Method Details
-
addLayer
Add a z layer for containing items rendered on this container..- Parameters:
layer- the layer to add.
-
getAnnotationLayer
Layer getAnnotationLayer()Get the annotation layer for this container.- Returns:
- the annotation layer for this container. All drawing tools draw on the annotation layer, which is kept on top.
-
getConnectionLayer
Layer getConnectionLayer()Get the connection layer for this container.- Returns:
- the connection layer for this container. Connection items are drawn on first, i.e. connections are under other items.
-
getDefaultLayer
Layer getDefaultLayer()Get the default user content layer for this container.- Returns:
- the default user content layer (never null after construction)
-
getLayerByName
Gets an z layer by name. Do not use for the annotation layer or connection layer-- for that use getAnnotationLayer() or getConnectionLayer().- Parameters:
name- the name of the layer.- Returns:
- the z layer, or
null.
-
localToWorld
This converts a screen or pixel point to a world point.- Parameters:
pp- contains the local (screen-pixel) point.wp- will hold the resultant world point.
-
worldToLocal
This converts a world point to a screen or pixel point.- Parameters:
pp- will hold the resultant local (screen-pixel) point.wp- contains world point.
-
worldToLocal
This converts a world rectangle to a screen or pixel rectangle.- Parameters:
r- will hold the resultant local (screen-pixel) rectangle.wr- contains the world rectangle.
-
localToWorld
This converts a screen or local rectangle to a world rectangle.- Parameters:
r- contains the local (screen-pixel) rectangle.wr- will hold the resultant world rectangle.
-
worldToLocal
This converts a world polygon to a screen or pixel polygon.- Parameters:
polygon- will hold the resultant local (screen-pixel) polygon.worldPolygon- contains the world polygon.
-
localToWorld
This converts a screen or local polygon to a world polygon.- Parameters:
polygon- contains the local (screen-pixel) polygon.worldPolygon- will hold the resultant world polygon.
-
worldToLocal
This converts a world point to a screen or pixel point.- Parameters:
pp- will hold the resultant local (screen-pixel) point.wx- the world x coordinate.wy- the world y coordinate.
-
pan
void pan(int dh, int dv) Pan the container.- Parameters:
dh- the horizontal step in pixels.dv- the vertical step in pixels.
-
recenter
Recenter the container at the point of a click.- Parameters:
pp- the point in question. It will be the new center.
-
prepareToZoom
void prepareToZoom()Begin preparations for a zoom. -
restoreDefaultWorld
void restoreDefaultWorld()Restore the default world. This gets us back to the original zoom level. -
resetWorldSystem
Reset the world system to a new value. Resets the default and previous world systems as well.- Parameters:
worldSystem- the new world system.
-
scale
void scale(double scaleFactor) Convenience routine to scale the container.- Parameters:
scaleFactor- the scale factor.
-
undoLastZoom
void undoLastZoom()Undo that last zoom. -
rubberBanded
This is called when we have completed a rubber banding. pane.- Parameters:
b- The rubber band bounds.
-
getItemAtPoint
Find an item, if any, at the point.- Parameters:
lp- The pixel point in question.- Returns:
- the topmost satisfying item, or null.
-
getEnclosedItems
Obtain a collection of all enclosed items across all lists.- Parameters:
rect- the rectangle in question.- Returns:
- all items on all item lists enclosed by the rectangle.
-
getItemsAtPoint
Find all items, if any, at the point.- Parameters:
lp- the pixel point in question.- Returns:
- all items across all item lists that contain the given point. It may
be an empty vector, but it won't be
null.
-
anySelectedItems
boolean anySelectedItems()Check whether at least one item on any item list is selected.- Returns:
trueif at least one item on any item list is selected.
-
deleteSelectedItems
void deleteSelectedItems()Delete all selected items, across all item lists. -
getSelectedItems
Get all selected items, across all item lists.- Returns:
- a list of all currently selected items; never
null
-
selectAllItems
void selectAllItems(boolean select) Select or deselect all items, across all item lists.- Parameters:
select- the selection flag.
-
zoom
void zoom(double xmin, double xmax, double ymin, double ymax) Zooms to the specified area.- Parameters:
xmin- minimum x coordinate.xmax- maximum x coordinate.ymin- minimum y coordinate.ymax- maximum y coordinate.
-
getToolBar
AToolBar getToolBar()Get this container's tool bar interface.- Returns:
- this container's tool bar, or
null.
-
setToolBar
Set this container's tool bar.- Parameters:
toolBar- the new toolbar interface.
-
updateStatusText
Update the status text in the toolbar, if any. This is a convenience method that callsgetToolBar().updateStatusText()if a toolbar is present.- Parameters:
pp- the pixel point to include in the status text.wp- the world point to include in the status text.
-
getHoverWindow
Get the hover info window for this container, if any.- Returns:
- the hover info window for this container, or
null.
-
feedbackTrigger
Convenience method to update the location string in the toolbar.- Parameters:
mouseEvent- the causal event.dragging-trueif we are dragging
-
getView
BaseView getView()Get the view (internal frame) that holds this container.- Returns:
- the view (internal frame) that holds this container.
-
setView
Set the container's view.- Parameters:
view- the view to set.
-
setFeedbackPane
Sets the feedback pane. This is an optional alternative to a HUD.- Parameters:
feedbackPane- the feedback pane.
-
getFeedbackPane
FeedbackPane getFeedbackPane()Get the optional feedback pane.- Returns:
- the feedbackPane
-
getFeedbackControl
FeedbackControl getFeedbackControl()Return the object that controls the container's feedback. You can and and remove feedback providers using this object.- Returns:
- the object that controls the container's feedback.
-
setDirty
void setDirty(boolean dirty) Convenience method for setting the dirty flag for all items on all item lists.- Parameters:
dirty- the new value of the dirty flag.
-
refresh
void refresh()Refresh the container. -
getComponent
Component getComponent()Get the underlying JComponent- Returns:
- the underlying component
-
getImage
BufferedImage getImage()Get the background image.- Returns:
- the fully painted background image.
-
setAfterDraw
Set the after-draw drawable for this container.- Parameters:
afterDraw- the new after-draw drawable.
-
setBeforeDraw
Set the before-draw drawable.- Parameters:
beforeDraw- the new before-draw drawable.
-
getWorldSystem
Rectangle2D.Double getWorldSystem()Get the current world system.Note: implementations may return the live, mutable rectangle backing the container's viewport, not a defensive copy (unlike
setWorldSystem(java.awt.geom.Rectangle2D.Double)andresetWorldSystem, which both copy). Mutating the returned rectangle directly can silently change the container's viewport without going throughsetDirty/refresh. Callers that need to keep a stable snapshot should copy it themselves.- Returns:
- the world system; may be the container's live instance
-
setWorldSystem
Set the world system (does not cause redraw)- Parameters:
wr- the new world system
-
approximateZoomFactor
double approximateZoomFactor()Get the approximate zoom factor based on the current and default world systems.- Returns:
- the approximate zoom factor
-
prepareForExit
void prepareForExit()Prepare for exiting the application. This is called from the main frame when the user tries to exit. It gives the container a chance to do things like prompt to save unsaved work or dispose of resources.
-