!******************************************************************************!
! This demonstrates the issue observed in NXM-2981 where there are redraw issues associated with
! the use of a JInternalFrame.
!
! @author J. Czechowski IV
! @since  NeXtMidas 3.7.1
!******************************************************************************!
startmacro
  switch INTERACTIVE  interAct     GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch COREGRAPHICS coreGraphics GET DEF=FALSE SDEF=TRUE  ! for a quick check of graphics - more extreme tests - since 3.8.1

  if interAct or coreGraphics then
    res oldLookAndFeel env.theme
    lookandfeel Ocean
    call setDatDir

    invoke z:jvmHangFix nxm.sys.lib.Shell.getJVMHangWorkaround()
    res z:mytrue true
    invoke ,, nxm.sys.lib.Shell.setJVMHangWorkaround(^mytrue)

    pipe on
      include "datasim.inc"

      panel/jsetup="nxm.sys.test.test_plot_jinternalframe"
      plot/theme=WoB/ID=northWestPlot _psdThin  TYPE=Line
      plot/theme=WoB/ID=southWestPlot _psdThin  TYPE=Raster
      plot/theme=WoB/ID=southEastPlot ^{datDir}.apenny.prm
      plot/theme=WoB/ID=topPlot       world.shp{LAYER={LABEL=NAME}}

      feature label=aircraft table={NAME="AIRCRAFT",TYPE="SYMBOL",X=15,Y=15,COLOR="GREEN",&
                                    SYMBOL="AERO",SYMBOLFILL="TRUE",SYMBOLHEADING=90,SYMBOLSIZE=15} plot=topPlot

      set aircraft reg.topPlot.features.aircraft
      set this.timers   1
      set this.timer(0) 0.5
    pipe off

    lookandfeel oldLookAndFeel
    invoke ,, nxm.sys.lib.Shell.setJVMHangWorkaround(^jvmHangFix)
  endif
endmacro

! Process messages received.
! @param msg The message received.
procedure processMessage m:msg
  !say "Got message name=^msg.name info=^msg.info data=^msg.data fid=^msg.fid"
  if msg.name EQS "MAIN" then
    assert/text="^reg.main.name: User-indicated tests" "PASS" SUBS msg.data
    pipe stop

  elseif msg.name EQS "TIMER" then
    calc aircraft.x aircraft.x 5 +
    if (aircraft.x >= 180.0) then
      calc aircraft.x -180.0
    endif

  else
    !say "^reg.main.name: Unhandled message name=^msg.name info=^msg.info data=^msg.data"
  endif
return

!******************************************************************************!
! Set the dat directory
!******************************************************************************!
procedure setDatDir
  invoke nxmMajor env.nmversion.subString(0,1)
  invoke major java.lang.Integer.valueOf(nxmMajor)
  if major GE 4 then
    invoke s:datDir           nxm.sys.test.DatLocator.getDatDirLocation()
    invoke s:datDirSlash      nxm.sys.test.DatLocator.getDatDirSlashLocation()
    invoke z:sysDatFull       nxm.sys.test.DatLocator.sysDatFull()
    invoke z:sysTestDatExists nxm.sys.test.DatLocator.sysTestDatExists()
  else
    set s:datDir           "nxm.sys.dat"
    set s:datDirSlash      "nxm/sys/dat"
    set z:sysDatFull       true
    set z:sysTestDatExists false
  endif
return
