All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, AppFrame, Hidable, FileDropHandler.FileImporter

public class TFrame extends OSPFrame implements PropertyChangeListener, FileDropHandler.FileImporter
This is the main frame for Tracker.
Author:
Douglas Brown
See Also:
  • Field Details

    • textLayoutFont

      public static Font textLayoutFont
    • PROPERTY_TFRAME_TAB

      public static final String PROPERTY_TFRAME_TAB
      See Also:
    • PROPERTY_TFRAME_RADIANANGLES

      public static final String PROPERTY_TFRAME_RADIANANGLES
      See Also:
    • PROPERTY_TFRAME_WINDOWFOCUS

      public static final String PROPERTY_TFRAME_WINDOWFOCUS
      See Also:
    • HELP_PATH

      protected static final String HELP_PATH
      See Also:
    • WEB_HELP_PATH

      protected static final String WEB_HELP_PATH
      See Also:
    • YELLOW

      protected static final Color YELLOW
    • DEFAULT_VIEWS

      protected static final int DEFAULT_VIEWS
      See Also:
    • OTHER_VIEWS

      protected static final int OTHER_VIEWS
      See Also:
    • DEFAULT_MAIN_DIVIDER

      protected static final double DEFAULT_MAIN_DIVIDER
      See Also:
    • DEFAULT_RIGHT_DIVIDER

      protected static final double DEFAULT_RIGHT_DIVIDER
      See Also:
    • DEFAULT_LEFT_DIVIDER

      protected static final double DEFAULT_LEFT_DIVIDER
      See Also:
    • DEFAULT_BOTTOM_DIVIDER

      protected static final double DEFAULT_BOTTOM_DIVIDER
      See Also:
    • DEFAULT_FRAME_WIDTH

      protected static final double DEFAULT_FRAME_WIDTH
      See Also:
    • MAXIMIZED_FRAME_WIDTH

      protected static final double MAXIMIZED_FRAME_WIDTH
      See Also:
    • DEFAULT_FRAME_HEIGHT

      protected static final double DEFAULT_FRAME_HEIGHT
      See Also:
    • MAXIMIZED_FRAME_HEIGHT

      protected static final double MAXIMIZED_FRAME_HEIGHT
      See Also:
    • DEFAULT_FRAME_CEILING

      protected static final int DEFAULT_FRAME_CEILING
      See Also:
    • MAXIMIZED_FRAME_CEILING

      protected static final int MAXIMIZED_FRAME_CEILING
      See Also:
    • isPortraitOrientation

      protected static boolean isPortraitOrientation
    • isLayoutAdaptive

      protected static boolean isLayoutAdaptive
    • haveExportDialog

      public static boolean haveExportDialog
    • haveThumbnailDialog

      public static boolean haveThumbnailDialog
    • maximize

      public static boolean maximize
    • clipboardListener

      protected org.opensourcephysics.cabrillo.tracker.ClipboardListener clipboardListener
    • libraryBrowser

      protected LibraryBrowser libraryBrowser
    • helpLauncher

      protected Launcher helpLauncher
    • helpDialog

      protected JDialog helpDialog
    • dataToolDialog

      protected JDialog dataToolDialog
    • prefsDialog

      protected PrefsDialog prefsDialog
    • fileDropHandler

      protected FileDropHandler fileDropHandler
    • tabbedPane

      protected JTabbedPane tabbedPane
    • saveNotesAction

      protected Action saveNotesAction
    • openRecentAction

      protected Action openRecentAction
    • loadedFiles

      protected ArrayList<String> loadedFiles
    • tabsetFile

      protected File tabsetFile
    • currentLangugae

      protected String currentLangugae
    • prevPanelID

      protected Integer prevPanelID
    • maximizedView

      protected int maximizedView
    • framesLoaded

      protected int framesLoaded
    • prevFramesLoaded

      protected int prevFramesLoaded
    • splashing

      protected boolean splashing
    • STATE_ACTIVE

      public static final int STATE_ACTIVE
      See Also:
    • STATE_BLOCKED

      public static final int STATE_BLOCKED
      See Also:
    • STATE_REMOVING

      public static final int STATE_REMOVING
      See Also:
    • SPLIT_MAIN_RIGHT

      protected static final int SPLIT_MAIN_RIGHT
      See Also:
    • SPLIT_PLOT_TABLE

      protected static final int SPLIT_PLOT_TABLE
      See Also:
    • SPLIT_MAIN_BOTTOM

      protected static final int SPLIT_MAIN_BOTTOM
      See Also:
    • SPLIT_WORLD_PAGE

      protected static final int SPLIT_WORLD_PAGE
      See Also:
    • SIDEVIEW_RIGHT_TOP

      protected static final int SIDEVIEW_RIGHT_TOP
      See Also:
    • SIDEVIEW_RIGHT_BOTTOM

      protected static final int SIDEVIEW_RIGHT_BOTTOM
      See Also:
    • SIDEVIEW_BOTTOM_LEFT

      protected static final int SIDEVIEW_BOTTOM_LEFT
      See Also:
    • SIDEVIEW_BOTTOM_RIGHT

      protected static final int SIDEVIEW_BOTTOM_RIGHT
      See Also:
    • DEFAULT_ORDER

      protected static final int[] DEFAULT_ORDER
    • PORTRAIT_VIEW_ORDER

      protected static final int[] PORTRAIT_VIEW_ORDER
    • PORTRAIT_DIVIDER_ORDER

      protected static final int[] PORTRAIT_DIVIDER_ORDER
    • ADD_NOREFRESH

      public static final int ADD_NOREFRESH
      See Also:
    • ADD_NOSELECT

      public static final int ADD_NOSELECT
      See Also:
    • ADD_SELECT

      public static final int ADD_SELECT
      See Also:
    • ADD_REFRESH

      public static final int ADD_REFRESH
      See Also:
    • whenObjectLoadingComplete

      public Function<List<String>,Void> whenObjectLoadingComplete
      runnable for when loadObject is complete, from TrackerIO
  • Constructor Details

    • TFrame

      public TFrame()
      Constructs an empty TFrame.
    • TFrame

      public TFrame(TrackerPanel trackerPanel)
      Constructs a TFrame with the specified tracker panel.
      Parameters:
      trackerPanel - the tracker panel
    • TFrame

      public TFrame(Map<String,Object> options)
      Parameters:
      options - include optional -dim Dimension [-video Video | -panel TrackerPanel]
  • Method Details

    • getAdaptiveBounds

      protected Rectangle getAdaptiveBounds(boolean isInit)
    • repaint

      public void repaint(long time, int x, int y, int w, int h)
      All repaints funnel through this method
      Overrides:
      repaint in class JFrame
    • repaintT

      public static void repaintT(Component c)
      For optimization, finding out exactly who is repainting.
      Parameters:
      c -
    • update

      public void update(Graphics g)
      Swing does not use this method. It's only for AWT.
      Overrides:
      update in class JFrame
    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class Window
    • addTab

      public void addTab(TrackerPanel trackerPanel, int addMode, Runnable whenDone)
      Adds a tab that displays the specified tracker panel.
      Parameters:
      trackerPanel - the tracker panel
      addMode - ADD_SELECT | ADD_REFRESH
      whenDone -
    • saveAllTabs

      public void saveAllTabs(boolean isExit, Function<Integer,Void> whenEachApproved, Runnable whenAllApproved, Runnable whenCanceled)
      Saves all tabs if user approved. Stops if any is canceled.
      Parameters:
      isExit - TODO
      whenEachApproved - Function to apply to each TrackerPanel unless canceled
      whenAllApproved - Runnable to run after all have run whenEachApproved
      whenCanceled - Runnable to run if canceled
    • relaunchCurrentTabs

      protected void relaunchCurrentTabs()
    • removeAllTabs

      public void removeAllTabs(boolean isExit)
      Removes all tabs.
    • getState

      public int getState()
      Overrides:
      getState in class Frame
    • isRemovingAll

      public boolean isRemovingAll()
    • doCloseAction

      public boolean doCloseAction(TrackerPanel trackerPanel)
      Removes a tracker panel tab. This method is called from Tracker.testFinal as well as action listeners for the tab popup menu and File close menu items.
      Parameters:
      trackerPanel - the tracker panelf
    • removeTabSynchronously

      public void removeTabSynchronously(TrackerPanel trackerPanel)
    • getTab

      public int getTab(Integer panelID)
      Returns the tab index for the specified tracker panel, or -1 if no tab is found.
      Parameters:
      ppanel - the tracker panel
      Returns:
      the tab index
    • getTabForID

      public int getTabForID(Integer panelID)
      Returns the tab index for the specified tracker panel based on panelID, or -1 if no tab is found.
      Parameters:
      tp - the tracker panel
      Returns:
      the tab index
    • getTab

      public int getTab(File dataFile)
      Returns the tab index for the specified data file, or -1 if no tab is found.
      Parameters:
      dataFile - the data file used to load the tab
      Returns:
      the tab index
    • getTabCount

      public int getTabCount()
      Gets the tab count.
      Returns:
      the tab count
    • getSelectedTab

      public int getSelectedTab()
      Gets the selected tab index.
      Returns:
      the tab index
    • setSelectedTab

      public void setSelectedTab(int tab)
      Sets the selected tab index.
      Parameters:
      tab - the tab index
    • setSelectedTab

      public void setSelectedTab(File dataFile)
    • setSelectedTab

      public void setSelectedTab(TrackerPanel trackerPanel)
      Sets the selected tab specified by tracker panel.
      Parameters:
      trackerPanel - the tracker panel
    • getTrackerPanelForTab

      public TrackerPanel getTrackerPanelForTab(int tab)
      Gets the tracker panel at the specified tab index.
      Parameters:
      tab - the tab index
      Returns:
      the tracker panel
    • getSelectedPanel

      public TrackerPanel getSelectedPanel()
      Gets the panel of the selected tab, if a tab is selected.
      Returns:
      the selected panel or null if no tab is selected
    • addTrackerPanel

      public void addTrackerPanel(boolean changedState, Runnable whenDone)
    • getTabTitle

      public String getTabTitle(int tab)
      Gets the title of the specified tab.
      Parameters:
      tab - the tab index
      Returns:
      the title
    • refreshTab

      public void refreshTab(TrackerPanel panel)
      Refreshes the tab for the specified tracker panel.
      Parameters:
      panel - the tracker panel
    • setTabTitle

      public void setTabTitle(int tab, String title)
      Sets the title of the specified tab.
      Parameters:
      tab - the tab index
      title - the title
    • placeViews

      public void placeViews(org.opensourcephysics.cabrillo.tracker.TFrame.TTabPanel tabPanel, TrackerPanel trackerPanel, TViewChooser[] viewChoosers)
      Places the views in an appropriate order for the specified trackerPanel.
      Parameters:
      trackerPanel - the trackerPanel
      viewChoosers - an array of up to 4 TViewChoosers
    • getTabPanel

      public org.opensourcephysics.cabrillo.tracker.TFrame.TTabPanel getTabPanel(TrackerPanel trackerPanel)
    • arrangeViews

      public void arrangeViews(TrackerPanel trackerPanel, boolean showDefaultViews, boolean showOtherViews)
      Arranges the views for a tracker panel, showing default views under or beside the video and the opposite for non-default views.
      Parameters:
      trackerPanel - the tracker panel
      showDefaultViews - true to show default views
      showOtherViews - true to show non-default views
    • getTViews

      public TView[][] getTViews(TrackerPanel trackerPanel, boolean customOnly)
      Gets the TViews for the specified tracker panel.
      Parameters:
      trackerPanel - the tracker panel
      customOnly - true to return only customized views
      Returns:
      TView[4][4], may be null
    • getTViews

      public List<TView> getTViews(Integer panelID, int viewType, List<TView> list)
      Find all selected panels of the given type and add them to the list. Use VIEW_UNSET to get all views.
      Parameters:
      panelID -
      viewType - [ VIEW_PLOT VIEW_TEXT VIEW_WORLD VIEW_PAGE VIEW_UNSET ]
      list - the return list, or null to start a new list
      Returns:
      list
    • getSelectedViewTypes

      public int[] getSelectedViewTypes(TrackerPanel trackerPanel)
      Gets the selected TViewTypes for the specified tracker panel.
      Parameters:
      trackerPanel - the tracker panel
      Returns:
      int[4] of types selected in the TViewChoosers
    • getSelectedTrackViews

      public String getSelectedTrackViews(TrackerPanel trackerPanel)
      Gets the selected TrackView names for the specified tracker panel.
      Parameters:
      trackerPanel - the tracker panel
      Returns:
      String[4][2] of track names selected in {plot, table}
    • isViewPaneVisible

      public boolean isViewPaneVisible(int position, Integer panelID)
      Determines whether a view pane is visible for the specified trackerPanel tab.
      Parameters:
      position - the view position index, a number from 0 to 3
      tp - the trackerPanel
      Returns:
      true if it is visible
    • areViewsVisible

      public boolean areViewsVisible(int whichViews, TrackerPanel trackerPanel)
      Determines whether the specified views are visible in a trackerPanel tab. Views may be DEFAULT_VIEWS (TViewChoosers[0/1]) or OTHER_VIEWS (TViewChoosers[2/3])
      Parameters:
      whichViews - DEFAULT_VIEWS or OTHER_VIEWS
      trackerPanel - the trackerPanel
      Returns:
      true if views are visible
    • setDividerLocation

      public void setDividerLocation(TrackerPanel trackerPanel, int paneIndex, double loc)
      Sets the location of a splitpane divider for a tracker panel
      Parameters:
      trackerPanel - the tracker panel
      paneIndex - the index of the split pane
      loc - the desired fractional divider location
    • setDividerLocation

      public void setDividerLocation(TrackerPanel trackerPanel, int paneIndex, int loc)
      Sets the location of a splitpane divider for a tracker panel
      Parameters:
      trackerPanel - the tracker panel
      paneIndex - the index of the split pane
      loc - the desired absolute divider location
    • getMainView

      public MainTView getMainView(TrackerPanel trackerPanel)
      Gets the main view for the specified tracker panel.
      Parameters:
      trackerPanel - the tracker panel
      Returns:
      a MainTView
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Responds to property change events.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      e - the property change event
    • setVisible

      public void setVisible(boolean visible)
      Description copied from class: OSPFrame
      Shows or hides this component depending on the value of parameter b and the keepHidden flag. OSP Applets often keep windows hidden.
      Overrides:
      setVisible in class OSPFrame
    • isAnglesInRadians

      public boolean isAnglesInRadians()
    • setAnglesInRadians

      public void setAnglesInRadians(boolean inRadians)
      Sets the display units for angles.
      Parameters:
      inRadians - true to display radians, false to display degrees
    • getPrefsDialog

      public PrefsDialog getPrefsDialog()
      Gets the preferences dialog.
      Returns:
      the preferences dialog
    • showPrefsDialog

      public void showPrefsDialog()
      Shows the preferences dialog.
    • showPrefsDialog

      public void showPrefsDialog(String tabName)
      Shows the preferences dialog set to a specified tab.
      Parameters:
      tabName - the name of the tab: config, runtime, video, general, display
    • getMaximizedView

      public int getMaximizedView()
    • getTrackBar

      public TTrackBar getTrackBar(Integer panelID, boolean forceNew)
      Gets the trackbar for the specified tracker panel.
      Parameters:
      ppanel - the tracker panel
      forceNew - true to create a new trackbar if null; false to return null
      Returns:
      a TTrackBar
    • getToolBar

      public TToolBar getToolBar(Integer panelID, boolean forceNew)
      Gets the toolbar for the specified tracker panel.
      Parameters:
      ppanel - the tracker panel
      forceNew - true to create a new toolbar if null; false to return null
      Returns:
      a TToolBar
    • setToolBar

      public void setToolBar(TrackerPanel trackerPanel, TToolBar toolbar)
      From TrackPanel.Loader. This will load into the objects[] array for the tab as soon as it is available.
      Parameters:
      trackerPanel -
      toolbar -
    • getMenuBar

      public TMenuBar getMenuBar(Integer panelID, boolean forceNew)
      Gets the menubar for the specified tracker panel.
      Parameters:
      ppanel - the tracker panel
      forceNew - true to create a new bar if null; false to return null
      Returns:
      a TMenuBar
    • refreshOpenRecentMenu

      public void refreshOpenRecentMenu(JMenu menu)
      Refreshes the open recent files menu.
      Parameters:
      menu - the menu to refresh
    • doRecentFiles

      protected void doRecentFiles(String path)
    • refresh

      public void refresh()
      Refreshes the GUI.
    • setFontLevel

      public void setFontLevel(int level)
      Sets the font level.
      Overrides:
      setFontLevel in class OSPFrame
      Parameters:
      level - the desired font level
    • getLibraryBrowser

      protected LibraryBrowser getLibraryBrowser()
      Gets the library browser.
      Returns:
      the library browser
    • getPropertiesDialog

      protected PropertiesDialog getPropertiesDialog(TrackerPanel trackerPanel)
      Gets the properties dialog for a specified TrackerPanel.
      Parameters:
      trackerPanel -
      Returns:
      the properties dialog
    • getHelpDialog

      protected Component getHelpDialog()
      Gets the help dialog.
      Returns:
      the help dialog
    • showHelp

      protected void showHelp(String selectedNode)
      Shows a specified help topic.
      Parameters:
      selectedNode - the name of the help node to be displayed
    • showHelp

      protected void showHelp(String keywords, int pageNumber)
      Shows a specified help topic by keyword: gettingstarted, install, linux, GUI, video, filters, tracks, coords, axes, tape, offset, calibration, pointmass, cm, vector, vectorsum, profile, rgbregion, particle, plot, datatable, xml, etc.
      Parameters:
      keywords - the keywords of the help node to be displayed
      pageNumber - the html page number
    • getObjects

      public Object[] getObjects(int tab)
    • getClipboardListener

      protected org.opensourcephysics.cabrillo.tracker.ClipboardListener getClipboardListener()
      Gets the (singleton) clipboard listener.
      Returns:
      the ClipboardListener
    • getAlwaysListenToClipboard

      public boolean getAlwaysListenToClipboard()
    • setAlwaysListenToClipboard

      public void setAlwaysListenToClipboard(boolean b)
    • checkClipboardListener

      protected void checkClipboardListener()
      Starts or ends the clipboard listener as needed.
    • getNotes

      protected org.opensourcephysics.cabrillo.tracker.TFrame.Notes getNotes()
    • doTabStateChanged

      protected void doTabStateChanged()
    • frameResized

      protected void frameResized()
    • isPortraitLayout

      protected static boolean isPortraitLayout()
    • getConvertedDividerLoc

      protected double getConvertedDividerLoc(int splitPaneIndex, double loc)
      Converts and returns converted divider location (0.0 <= loc <= 1.0). No conversion is made if not portrait layout.
      Parameters:
      splitPaneIndex - 0-3
      loc - the divider loc
      Returns:
      the converted divider loc
    • holdPainting

      public void holdPainting(boolean b)
      Increment/decrement the paintHold counter. Will not decrement below 0.
      Parameters:
      b - true to increment the counter; false to decrement
    • isPaintable

      public boolean isPaintable()
      check the paintHold counter
      Returns:
      true if paintHold is zero
    • hasPaintHold

      public boolean hasPaintHold()
    • clearHoldPainting

      public void clearHoldPainting()
      For emergency use only!
    • addFollower

      public ComponentListener addFollower(Component c, Point ignored)
      Adds a component to those following this frame. When the frame is displaced the component will be displaced equally. THIS WAS A MEMORY LEAK. It is the responsibility of the follower to detach itself when appropriate.
      Parameters:
      c - the component
      pt0 - the initial location of this frame
    • addMenuListener

      public static void addMenuListener(JMenu m, Runnable r)
    • removeEmptyTabIfTabCountGreaterThan

      public void removeEmptyTabIfTabCountGreaterThan(int n)
      Remove the first tab if it is empty and there are at least n tabs (1 or 2)
    • removeTabNow

      public void removeTabNow(int i)
    • loadExperimentURL

      public void loadExperimentURL(String path)
      Replace any open tabs with a single tab loaded with the given path. JavaScript only? Called from Tracker (for JavaScript) and TMenuBar (for testing in Java)
      Parameters:
      path -
    • loadLibraryRecord

      protected void loadLibraryRecord(LibraryResource record)
    • openLibraryResource

      public void openLibraryResource(LibraryResource record, Runnable whenDone)
    • setCursor

      public void setCursor(Cursor c)
      Overrides:
      setCursor in class Window
    • doOpenExportedAndUpdateLibrary

      public void doOpenExportedAndUpdateLibrary(String path)
      Java only; from ExportVideoDialog
      Parameters:
      path -
    • doOpenFileFromDialog

      public void doOpenFileFromDialog()
    • doOpenURL

      public void doOpenURL(String url)
    • addTabFromLoader

      public void addTabFromLoader(TrackerPanel trackerPanel)
    • getLoader

      public static XML.ObjectLoader getLoader()
      Returns an ObjectLoader to save and load data for this class.
      Returns:
      the object loader
    • setFrameBlocker

      public void setFrameBlocker(boolean blocking, TrackerPanel panel)
    • setNotesVisible

      public void setNotesVisible(boolean b)
    • setJMenuBar

      public void setJMenuBar(JMenuBar bar)
      Overrides:
      setJMenuBar in class JFrame
    • checkLocale

      protected void checkLocale()
    • setLanguage

      protected void setLanguage(String language)
    • disposeOf

      public void disposeOf(TrackerPanel trackerPanel)
    • getViewChoosers

      public TViewChooser[] getViewChoosers(TrackerPanel trackerPanel)
      Gets the TViewChoosers for the specified tracker panel.
      Parameters:
      trackerPanel - the tracker panel
      Returns:
      array of TViewChooser
    • getViewChoosers

      public TViewChooser[] getViewChoosers(Integer panelID)
    • getVisibleChoosers

      public TViewChooser[] getVisibleChoosers(Integer panelID)
    • removeTabSynchronously

      public void removeTabSynchronously(Integer panelID)
    • refreshMenus

      public void refreshMenus(TrackerPanel trackerPanel, String whereFrom)
    • allocatePanel

      public Integer allocatePanel(TrackerPanel trackerPanel)
    • deallocatePanelID

      public void deallocatePanelID(Integer panelID)
    • deallocate

      public void deallocate(OSPRuntime.Disposable obj)
    • getTrackerPanelForID

      public TrackerPanel getTrackerPanelForID(Integer panelID)
    • startMemoryTimer

      public void startMemoryTimer()
    • main

      public static void main(String[] args)
    • sayFileNotFound

      public void sayFileNotFound(String path)
    • importData

      public boolean importData(Object data, Component component)
      Specified by:
      importData in interface FileDropHandler.FileImporter