edu.brook.ascape.view
Class ViewFrameBridge

edu.brook.ascape.view.ViewFrameBridge

public class ViewFrameBridge
implements java.io.Serializable

A class allowing Frame, JFrame, and JInternalFrame to be used interchangebly, and providing general support for frame management. This class also ends up mediating and centralizing all swing/non-swong deployment issues. All Swing related environment calls are sent to this class so that all swing functionality can be removed in one place. This will change once the majority of browsers support Swing.

Since:
1.2
Version:
1.2
See Also:
Serialized Form

Field Summary
protected static ModelApplet applet
          The applet the scape is running within, if any.
static int APPLET_VIEW_MODE
          Symbol indicating the manager is supporting an applet view.
protected static PanelImp appletModelPanel
          The applet panel this scape will be displayed within.
protected static ViewFrameBridge controlBarFrame
          Store the last control bar (there should really only be one) so that we can make sure its always sent to the front when another view is added.
static int DEBUG_RUNTIME_MODE
          Symbol indicating the current runtime viewMode is setup for debug.
protected static edu.brook.ascape.view.Desktop desktop
          The applet the scape is running within, if any.
 java.awt.Container frameImp
          The backing frame providing the frame implementation.
protected static java.util.Vector frames
           
static int GRID_MULTIVIEW_MODE
          Symbol indicating that views added should be put into a grid layout.
static int INTERNAL_VIEW_MODE
          Symbol indicating the manager is supporting a swing internal frames view, using javax.swing.JIntenralFrame; [Internal frames are not quite ready for prime time.]
protected static int multiViewMode
          Multiview mode.
static int NON_SWING_VIEW_MODE
          Symbol indicating the manager is supporting a non-swing external frames view, using java.awt.Frame;
static int RELEASE_RUNTIME_MODE
          Symbol indicating the current viewMode is setup for release.
protected static int runtimeMode
          Runtime viewMode; one of debug or release.
protected static java.awt.Dimension screenBuffer
          The extra space used in the screen.
protected  boolean showBar
          Should the control bar be displayed? (No longer supported.)
static int STANDARD_VIEW_MODE
          Symbol indicating the manager is supporting a swing external frames view, using javax.swing.JFrame;
static int TABBED_MULTIVIEW_MODE
          Symbol indicating that views added should be put into a tabbed layout.
protected static int viewMode
          The mode the manager is currently supporting, standard by default.
 
Constructor Summary
ViewFrameBridge()
          Construct a frame bridge.
ViewFrameBridge(ComponentView view)
          Construct a frame bridge.
ViewFrameBridge(ComponentView[] views)
          Construct a frame bridge.
 
Method Summary
static CellCustomizer createCellCustomizer(BaseCellView view)
          Returns a new CellCustomizer.
static ViewCustomizer createViewCustomizer(BaseCellView view)
          Returns a new ViewCustomizer.
static void defaultSetup(Scape model)
          Setup up a basic interactive run time environment for a model application.
 void displayAboutDialog(Scape scape)
          Displays a standard about dialog.
 void dispose()
          Closes and frees the frame.
static java.util.Vector getAllFrames()
          Returns the actual frame implementation.
static ModelApplet getApplet()
          If model is running in an applet vm context, returns the applet.
static PanelImp getAppletModelPanel()
          If model is running in an applet vm context, returns the applet.
 java.awt.Container getContentPane()
          Returns the contentPane object for the frame.
 java.awt.Container getFrameImp()
          Returns the actual frame implementation.
static javax.swing.ImageIcon getIcon(java.lang.String imageName)
          Utility method to return an image icon.
static java.awt.Image getImage(java.lang.String string)
          Utility method to return an image resource as specified according to the rules of Class.getResource.
static int getMultiViewMode()
          Returns the multi view mode that will be used when adding any new windows.
static int getRuntimeMode()
          Returns the run time mode being used.
 java.lang.String getTitle()
          Gets the title of the frame.
static int getViewMode()
          Returns the view viewMode being used.
 ComponentView[] getViews()
          Returns the views displayed in this window.
static boolean isInApplet()
          Are we in an applet vm context? returns true if this scape is viewed in an applet, false otherwise
 boolean isVisible()
          Is the frame currently visible?
 void newSizeNotified(edu.brook.ascape.view.QTImageDrawer drawer, java.awt.Dimension d)
           
static void onNewModel()
           
static java.lang.String openDialog()
          Gets the users models name from a dialog and validates that it is a legitimate class name.
 void pack()
          Packs the delegate frame.
 java.awt.Rectangle[] paint(java.awt.Graphics g)
           
 void placeRandomLocation()
          Places the window in a random location.
static void placeRandomLocation(java.lang.Object frameImp)
          Places the window in a random location.
protected  void selectFrameImp()
          An internal method that picks the approriate frame for the applet mode.
static void setApplet(ModelApplet _applet)
          Sets the applet scape views are to be displayed within, indicating that we are in an applet vm context.
 void setDefaultCloseOperation(int closeOp)
           
static void setMultiViewMode(int _multiViewMode)
          Sets the multi view to use when adding a new window.
static void setRuntimeMode(int _runtimeMode)
          Sets the runtime to use.
 void setTitle(java.lang.String title)
          Sets the title for this frame to the specified string.
 void setView(ComponentView view)
          Sets the view to display in this window.
static void setViewMode(int _viewMode)
          Sets the viewMode to use.
 void setViews(ComponentView[] views)
          Sets the view to display in this window.
 void setVisible(boolean b)
          Makes the frame visible or invisible.
static void showErrorDialog(Scape scape, java.lang.RuntimeException e)
           
static boolean supportsSwing()
          Returns the view viewMode being used.
 void toFront()
          Brings the frame to the front.
 java.lang.String toString()
          Returns a string represenetation of the view frame.
 

Field Detail

APPLET_VIEW_MODE

public static final int APPLET_VIEW_MODE
Symbol indicating the manager is supporting an applet view.

STANDARD_VIEW_MODE

public static final int STANDARD_VIEW_MODE
Symbol indicating the manager is supporting a swing external frames view, using javax.swing.JFrame;

NON_SWING_VIEW_MODE

public static final int NON_SWING_VIEW_MODE
Symbol indicating the manager is supporting a non-swing external frames view, using java.awt.Frame;

INTERNAL_VIEW_MODE

public static final int INTERNAL_VIEW_MODE
Symbol indicating the manager is supporting a swing internal frames view, using javax.swing.JIntenralFrame; [Internal frames are not quite ready for prime time.]

viewMode

protected static int viewMode
The mode the manager is currently supporting, standard by default.

DEBUG_RUNTIME_MODE

public static final int DEBUG_RUNTIME_MODE
Symbol indicating the current runtime viewMode is setup for debug.

RELEASE_RUNTIME_MODE

public static final int RELEASE_RUNTIME_MODE
Symbol indicating the current viewMode is setup for release.

runtimeMode

protected static int runtimeMode
Runtime viewMode; one of debug or release.

TABBED_MULTIVIEW_MODE

public static final int TABBED_MULTIVIEW_MODE
Symbol indicating that views added should be put into a tabbed layout.

GRID_MULTIVIEW_MODE

public static final int GRID_MULTIVIEW_MODE
Symbol indicating that views added should be put into a grid layout.

multiViewMode

protected static int multiViewMode
Multiview mode. By default GRID_MULTIVIEW_MODE.

applet

protected static ModelApplet applet
The applet the scape is running within, if any. Should be ok to have this static, since a vm should always either be running as an applet or an application.

appletModelPanel

protected static PanelImp appletModelPanel
The applet panel this scape will be displayed within. See above.

desktop

protected static edu.brook.ascape.view.Desktop desktop
The applet the scape is running within, if any. Should be ok to have this static, since a vm should always either be running as an applet or an application. Comment out for web.

controlBarFrame

protected static ViewFrameBridge controlBarFrame
Store the last control bar (there should really only be one) so that we can make sure its always sent to the front when another view is added.

frameImp

public java.awt.Container frameImp
The backing frame providing the frame implementation.

screenBuffer

protected static java.awt.Dimension screenBuffer
The extra space used in the screen.

showBar

protected boolean showBar
Should the control bar be displayed? (No longer supported.)

frames

protected static java.util.Vector frames
Constructor Detail

ViewFrameBridge

public ViewFrameBridge()
Construct a frame bridge.

ViewFrameBridge

public ViewFrameBridge(ComponentView[] views)
Construct a frame bridge.

ViewFrameBridge

public ViewFrameBridge(ComponentView view)
Construct a frame bridge.
Method Detail

selectFrameImp

protected void selectFrameImp()
An internal method that picks the approriate frame for the applet mode.

setDefaultCloseOperation

public void setDefaultCloseOperation(int closeOp)

setView

public void setView(ComponentView view)
Sets the view to display in this window. Sets the size to the view preferred size plus the window insets size. Sets the component's view frame to this. Gives the window a random loation on the user's (primary?) monitor.

getViews

public ComponentView[] getViews()
Returns the views displayed in this window.

setViews

public void setViews(ComponentView[] views)
Sets the view to display in this window. Sets the size to the view preferred size plus the window insets size. Sets the component's view frame to this. Gives the window a random loation on the user's (primary?) monitor.

placeRandomLocation

public void placeRandomLocation()
Places the window in a random location.

placeRandomLocation

public static void placeRandomLocation(java.lang.Object frameImp)
Places the window in a random location.

getApplet

public static ModelApplet getApplet()
If model is running in an applet vm context, returns the applet.

setApplet

public static void setApplet(ModelApplet _applet)
Sets the applet scape views are to be displayed within, indicating that we are in an applet vm context.

getAppletModelPanel

public static PanelImp getAppletModelPanel()
If model is running in an applet vm context, returns the applet.

onNewModel

public static void onNewModel()

showErrorDialog

public static void showErrorDialog(Scape scape,
                                   java.lang.RuntimeException e)

openDialog

public static java.lang.String openDialog()
Gets the users models name from a dialog and validates that it is a legitimate class name. Returns the validated mdoel name, or null if the user cancelled. This feature only works with Swing..will generate exception if called in other contexts.

createViewCustomizer

public static ViewCustomizer createViewCustomizer(BaseCellView view)
Returns a new ViewCustomizer. The only reason this c ode is in ViewFrameBridge is to centralize web only code.

createCellCustomizer

public static CellCustomizer createCellCustomizer(BaseCellView view)
Returns a new CellCustomizer. The only reason this c ode is in ViewFrameBridge is to centralize web only code.

displayAboutDialog

public void displayAboutDialog(Scape scape)
Displays a standard about dialog.

defaultSetup

public static void defaultSetup(Scape model)
Setup up a basic interactive run time environment for a model application.

isInApplet

public static boolean isInApplet()
Are we in an applet vm context? returns true if this scape is viewed in an applet, false otherwise

supportsSwing

public static boolean supportsSwing()
Returns the view viewMode being used.

getViewMode

public static int getViewMode()
Returns the view viewMode being used.

setViewMode

public static void setViewMode(int _viewMode)
Sets the viewMode to use.

getRuntimeMode

public static int getRuntimeMode()
Returns the run time mode being used. If RELEASE_RUNTIME_MODE, Ascape will attempt to deal gracefully with any exceptions, providing a user dialog to report them. If DEBUG_RELEASE_MODE, Ascape will not trap exceptions so that normal debugging operations will not be interferred with.

setRuntimeMode

public static void setRuntimeMode(int _runtimeMode)
Sets the runtime to use. If RELEASE_RUNTIME_MODE, Ascape will attempt to deal gracefully with any exceptions, providing a user dialog to report them. If DEBUG_RELEASE_MODE, Ascape will not trap exceptions so that normal debugging operations will not be interferred with.

getMultiViewMode

public static int getMultiViewMode()
Returns the multi view mode that will be used when adding any new windows. If TABBED_MULTIVIEW_MODE, views that are added together will be placed in seperate tabbed panels (viewable individually, taking up much less space.) If GRID_MULTIVIEW_MODE, views that are added together will be placed in a girdlayout (viewable all at once, taking up much more space.) Default is grid view for compatibility, but this may be changed. It is better to set the mode when you add multiple views.

setMultiViewMode

public static void setMultiViewMode(int _multiViewMode)
Sets the multi view to use when adding a new window. If TABBED_MULTIVIEW_MODE, views that are added together will be placed in seperate tabbed panels (viewable individually, taking up much less space.) If GRID_MULTIVIEW_MODE, views that are added together will be placed in a girdlayout (viewable all at once, taking up much more space.)

getFrameImp

public java.awt.Container getFrameImp()
Returns the actual frame implementation. Use sparingly, and only if you know the view context you will be using!

getAllFrames

public static java.util.Vector getAllFrames()
Returns the actual frame implementation. Use sparingly, and only if you know the view context you will be using!

getImage

public static java.awt.Image getImage(java.lang.String string)
Utility method to return an image resource as specified according to the rules of Class.getResource.
Parameters:
String - the resource reference of the image to load

getIcon

public static javax.swing.ImageIcon getIcon(java.lang.String imageName)
Utility method to return an image icon. The image icon must be in the [lib]/edu/brook/ascape/view/images directory, and it must be a gif, ending \".gif.\" Comment out for web.
Parameters:
String - the name (without extension) specifiying the image icon to return

getContentPane

public java.awt.Container getContentPane()
Returns the contentPane object for the frame. (In the case of Frame, will return the Frame itself.)

getTitle

public java.lang.String getTitle()
Gets the title of the frame. The title is displayed in the frame's border.

setTitle

public void setTitle(java.lang.String title)
Sets the title for this frame to the specified string.
Parameters:
title - the title to be displayed in the frame's border

setVisible

public void setVisible(boolean b)
Makes the frame visible or invisible.

isVisible

public boolean isVisible()
Is the frame currently visible?

toFront

public void toFront()
Brings the frame to the front.

pack

public void pack()
Packs the delegate frame.

newSizeNotified

public void newSizeNotified(edu.brook.ascape.view.QTImageDrawer drawer,
                            java.awt.Dimension d)

paint

public java.awt.Rectangle[] paint(java.awt.Graphics g)

dispose

public void dispose()
Closes and frees the frame.

toString

public java.lang.String toString()
Returns a string represenetation of the view frame.

(c) 1998-2000 The Brookings Insitution
Webpage