org.stellarium
Class StelApp

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by org.stellarium.StelApp
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, ApplicationCallback
Direct Known Subclasses:
StelSdl

public abstract class StelApp
extends java.awt.event.MouseAdapter
implements java.awt.event.MouseMotionListener, java.awt.event.KeyListener, ApplicationCallback

Version:
0.8.2
Author:
Jerome Beau, Fred Simon

Nested Class Summary
static class StelApp.DATE_FORMAT
           
static class StelApp.DRAWMODE
          Possible drawing modes
static class StelApp.TIME_FORMAT
           
static class StelApp.TZ_FORMAT
           
 
Field Summary
private  StelCommandInterface commander
          interface to perform all UI and scripting actions
private  IniFileParser conf
           
private static StelCore core
          The associcated StelCore instance FRED: Made it static, you can have only one core, and too many parameters to pass the core elements...
(package private)  java.lang.String customTzName
          Something like "Europe/Paris"
private  StelApp.DATE_FORMAT dateFormat
           
private  ViewportDistorter distorter
           
private  StelApp.DRAWMODE drawMode
           
private  boolean enableMoveMouse
          allow mouse at edge of screen to move view
private  boolean flagTimePause
           
private  double fps
           
private  int frame
          Used for fps counter
(package private)  double gmtShift
          Time shift between GMT time and local time in hour.
protected  boolean initialized
           
private  boolean is_mouse_moving_horiz
           
private  boolean is_mouse_moving_vert
           
private  float maxFPS
           
private  float minFPS
           
private  int mouseZoom
           
private  java.lang.String positionFile
           
private  double presetSkyTime
           
protected  int screenH
          Screen size
protected  int screenW
          Screen size
private  ScriptMgr scripts
          manage playing and recording scripts
private  java.lang.String selectedScript
          script filename (without directory) selected in a UI to run when exit UI
private  java.lang.String selectedScriptDirectory
          script directory for same
private  java.lang.String startupTimeMode
           
private  double temp_time_velocity
           
private  int timeBase
          Used for fps counter
private  StelApp.TIME_FORMAT timeFormat
           
private  int timefr
          Used for fps counter
private  int timeMultiplier
          used for adjusting delta_time for script speeds
(package private)  StelApp.TZ_FORMAT timeZoneMode
          Can be the system default or a user defined value
private  StelUI ui
          The main User Interface
 
Constructor Summary
StelApp()
           
 
Method Summary
private  void appInitGL()
           
 double draw(int deltaTime)
          Draw all / Main drawinf function called at each frame
 java.lang.String getAppLanguage()
           
 StelCommandInterface getCommander()
           
 IniFileParser getConf()
           
static StelCore getCore()
           
 java.lang.String getCustomTzName()
           
 java.lang.String getDateFormatStr()
           
 double getFps()
           
 double getGMTShift(double jd)
          Return the current time shift at observator time zone with respect to GMT time
 double getGMTShift(double jd, boolean isLocal)
          Return the current time shift at observator time zone with respect to GMT time
 java.lang.String getISO8601TimeLocal(double JD)
           
 double getMouseCursorTimeout()
           
 int getMouseZoom()
           
 double getPresetSkyTime()
           
 java.lang.String getPrintableDateLocal(double jd)
          Return a String with the local date formated according to the date_format variable
 java.lang.String getPrintableDateUTC(double jd)
          Return a String with the UTC date formated according to the date_format variable
 java.lang.String getPrintableTimeLocal(double jd)
          Return a String with the local time (according to time_zone_mode variable) formated according to the time_format variable.
 java.lang.String getPrintableTimeUTC(double jd)
          Tree.Return a String with the UTC time formated according to the time_format variable
 ScriptMgr getScripts()
           
 java.lang.String getSelectedScript()
           
 java.lang.String getStartupTimeMode()
           
 double getTempTimeVelocity()
           
 java.lang.String getTimeFormatStr()
           
 int getTimeMultiplier()
           
(package private)  StelApp.TZ_FORMAT getTzFormat()
           
 StelUI getUi()
           
 java.util.List<java.lang.String> getVideoModeList()
          Return a list of working fullscreen hardware video modes (one per line)
 java.lang.String getViewPortDistorterType()
           
 boolean getVisionModeChart()
          Get flag for activating chart vision mode
 boolean getVisionModeNight()
          Get flag for activating night vision mode
 void init()
          Initialize application and core
 void initData()
           
protected  void initFromGLInit()
           
protected abstract  void initSDL(int screenW, int screenH, int bbpMode, boolean fullScreen)
           
 boolean isFlagTimePause()
           
 boolean isVisionModeNormal()
          Get flag for activating chart vision mode
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void playStartupScript()
           
 void quit()
          Quit the application
 void recordCommand(java.lang.String commandline)
          Required because stelcore doesn't have access to the script manager anymore!
 void restoreFrom2DfullscreenProjection()
          Restore previous projection mode
 void saveCurrentConfig(IniFileParser conf)
           
private  java.lang.String sDateFormatToString(StelApp.DATE_FORMAT df)
           
 void set2DfullscreenProjection()
          Set the drawing mode in 2D for drawing in the full screen
 void setAppLanguage(java.lang.String newAppLocaleName)
          Set the application language This applies to GUI, console messages etc..
 void setCustomTimezone(java.lang.String timeZoneId)
           
 void setCustomTzName(java.lang.String tzname)
          Set a custom time zone.
 void setDateFormatStr(java.lang.String df)
           
 void setFlagTimePause(boolean flagTimePause)
           
 void setGMTShift(int t)
          Set the current time shift at observator time zone with respect to GMT time
 void setPresetSkyTime(double presetSkyTime)
           
 void setSelectedScript(java.lang.String selectedScript)
           
 void setSelectedScriptDirectory(java.lang.String selectedScriptDirectory)
           
 void setStartupTimeMode(java.lang.String startupTimeMode)
           
 void setTempTimeVelocity(double tempTimeVelocity)
           
 void setTimeFormatStr(java.lang.String tf)
           
 void setTimeMultiplier(int timeMultiplier)
           
 void setViewPortDistorterType(java.lang.String type)
           
 void setVisionModeChart()
          Set flag for activating chart vision mode
 void setVisionModeNight()
          Set flag for activating night vision mode
 void setVisionModeNormal()
          Set flag for activating chart vision mode ["color" section name used for easier backward compatibility for older configs - Rob]
abstract  void startMainLoop()
          Start the main loop until the end of the execution
private  java.lang.String sTimeFormatToString(StelApp.TIME_FORMAT tf)
           
private  StelApp.DATE_FORMAT stringToSDateFormat(java.lang.String df)
          Convert the date format enum to its associated String and reverse
private  StelApp.TIME_FORMAT stringToSTimeFormat(java.lang.String tf)
          Convert the time format enum to its associated String and reverse
 void update(int deltaTime)
          Update all object according to the delta time
 
Methods inherited from class java.awt.event.MouseAdapter
mouseEntered, mouseExited, mousePressed, mouseReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.stellarium.ApplicationCallback
orderRepaint
 

Field Detail

conf

private IniFileParser conf

core

private static StelCore core
The associcated StelCore instance FRED: Made it static, you can have only one core, and too many parameters to pass the core elements...


selectedScript

private java.lang.String selectedScript
script filename (without directory) selected in a UI to run when exit UI


selectedScriptDirectory

private java.lang.String selectedScriptDirectory
script directory for same


positionFile

private java.lang.String positionFile

enableMoveMouse

private boolean enableMoveMouse
allow mouse at edge of screen to move view


presetSkyTime

private double presetSkyTime

startupTimeMode

private java.lang.String startupTimeMode

mouseZoom

private int mouseZoom

frame

private int frame
Used for fps counter


timefr

private int timefr
Used for fps counter


timeBase

private int timeBase
Used for fps counter


fps

private double fps

minFPS

private float minFPS

maxFPS

private float maxFPS

flagTimePause

private boolean flagTimePause

temp_time_velocity

private double temp_time_velocity

is_mouse_moving_horiz

private boolean is_mouse_moving_horiz

is_mouse_moving_vert

private boolean is_mouse_moving_vert

timeMultiplier

private int timeMultiplier
used for adjusting delta_time for script speeds


commander

private StelCommandInterface commander
interface to perform all UI and scripting actions


scripts

private ScriptMgr scripts
manage playing and recording scripts


ui

private StelUI ui
The main User Interface


distorter

private ViewportDistorter distorter

drawMode

private StelApp.DRAWMODE drawMode

initialized

protected boolean initialized

timeFormat

private StelApp.TIME_FORMAT timeFormat

dateFormat

private StelApp.DATE_FORMAT dateFormat

timeZoneMode

StelApp.TZ_FORMAT timeZoneMode
Can be the system default or a user defined value


customTzName

java.lang.String customTzName
Something like "Europe/Paris"


gmtShift

double gmtShift
Time shift between GMT time and local time in hour. (positive for Est of GMT)


screenW

protected int screenW
Screen size


screenH

protected int screenH
Screen size

Constructor Detail

StelApp

public StelApp()
        throws StellariumException
Throws:
StellariumException
Method Detail

getCore

public static StelCore getCore()

getPrintableDateUTC

public java.lang.String getPrintableDateUTC(double jd)
                                     throws StellariumException
Return a String with the UTC date formated according to the date_format variable

Parameters:
jd - The Julian day
Returns:
The date text, formatted according to the current date format
Throws:
StellariumException - If the current date format is not supported

getISO8601TimeLocal

public java.lang.String getISO8601TimeLocal(double JD)

getPrintableDateLocal

public java.lang.String getPrintableDateLocal(double jd)
                                       throws StellariumException
Return a String with the local date formated according to the date_format variable

Parameters:
jd - The Julian day
Returns:
The date text, formatted according to the current date format
Throws:
StellariumException - If the current date format is not supported

getPrintableTimeUTC

public java.lang.String getPrintableTimeUTC(double jd)
                                     throws StellariumException
Tree.Return a String with the UTC time formated according to the time_format variable

Parameters:
jd - The Julian day
Returns:
The time text, formatted according to the current time format
Throws:
StellariumException - If the current time format is not supported

stringToSDateFormat

private StelApp.DATE_FORMAT stringToSDateFormat(java.lang.String df)
Convert the date format enum to its associated String and reverse

Parameters:
df - The date format parameter ("system_default", "mmddyyyy", "ddmmyyyy", "yyyymmdd")
Returns:
The inferred date format constant

sDateFormatToString

private java.lang.String sDateFormatToString(StelApp.DATE_FORMAT df)

getPrintableTimeLocal

public java.lang.String getPrintableTimeLocal(double jd)
                                       throws StellariumException
Return a String with the local time (according to time_zone_mode variable) formated according to the time_format variable.

Parameters:
jd - The Julian day
Returns:
The time text, formatted according to the current time format
Throws:
StellariumException - If the current time format is not supported

setGMTShift

public void setGMTShift(int t)
Set the current time shift at observator time zone with respect to GMT time

Parameters:
t - The new value

getCustomTzName

public java.lang.String getCustomTzName()

getTzFormat

StelApp.TZ_FORMAT getTzFormat()

setCustomTzName

public void setCustomTzName(java.lang.String tzname)
Set a custom time zone.

Parameters:
tzname - The name of the time zone.

getGMTShift

public double getGMTShift(double jd)
Return the current time shift at observator time zone with respect to GMT time

Parameters:
jd - The Julian day
Returns:
the GMT shift value

getGMTShift

public double getGMTShift(double jd,
                          boolean isLocal)
Return the current time shift at observator time zone with respect to GMT time

Parameters:
jd - The Julian day
isLocal -
Returns:

stringToSTimeFormat

private StelApp.TIME_FORMAT stringToSTimeFormat(java.lang.String tf)
Convert the time format enum to its associated String and reverse

Parameters:
tf - The time format parameter ("system_default", "24h", "12h")
Returns:
The inferred time format constant

sTimeFormatToString

private java.lang.String sTimeFormatToString(StelApp.TIME_FORMAT tf)

setViewPortDistorterType

public void setViewPortDistorterType(java.lang.String type)
                              throws StellariumException
Throws:
StellariumException

getViewPortDistorterType

public java.lang.String getViewPortDistorterType()

init

public void init()
          throws StellariumException
Initialize application and core

Throws:
StellariumException

initData

public void initData()

initFromGLInit

protected void initFromGLInit()

appInitGL

private void appInitGL()

initSDL

protected abstract void initSDL(int screenW,
                                int screenH,
                                int bbpMode,
                                boolean fullScreen)

update

public void update(int deltaTime)
            throws StellariumException
Update all object according to the delta time

Parameters:
deltaTime - The time that elapsed.
Throws:
StellariumException

draw

public double draw(int deltaTime)
Draw all / Main drawinf function called at each frame

Returns:
the max squared distance in pixels that any object has travelled since the last update.

startMainLoop

public abstract void startMainLoop()
Start the main loop until the end of the execution


getTimeMultiplier

public int getTimeMultiplier()

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class java.awt.event.MouseAdapter

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

quit

public void quit()
Quit the application

Specified by:
quit in interface ApplicationCallback

playStartupScript

public void playStartupScript()

setAppLanguage

public void setAppLanguage(java.lang.String newAppLocaleName)
Set the application language This applies to GUI, console messages etc.. This function has no permanent effect on the global locale

Parameters:
newAppLocaleName - The name of the language (e.g fr) to use for GUI, TUI and console messages etc..

getAppLanguage

public java.lang.String getAppLanguage()

setVisionModeNight

public void setVisionModeNight()
                        throws StellariumException
Set flag for activating night vision mode

Throws:
StellariumException

getVisionModeNight

public boolean getVisionModeNight()
Get flag for activating night vision mode


setVisionModeChart

public void setVisionModeChart()
                        throws StellariumException
Set flag for activating chart vision mode

Throws:
StellariumException

getVisionModeChart

public boolean getVisionModeChart()
Get flag for activating chart vision mode

Returns:
If the vision draw mode is CHART

setVisionModeNormal

public void setVisionModeNormal()
                         throws StellariumException
Set flag for activating chart vision mode ["color" section name used for easier backward compatibility for older configs - Rob]

Throws:
StellariumException

isVisionModeNormal

public boolean isVisionModeNormal()
Get flag for activating chart vision mode


getConf

public IniFileParser getConf()

saveCurrentConfig

public void saveCurrentConfig(IniFileParser conf)
                       throws StellariumException
Throws:
StellariumException

getMouseCursorTimeout

public double getMouseCursorTimeout()

getVideoModeList

public java.util.List<java.lang.String> getVideoModeList()
Return a list of working fullscreen hardware video modes (one per line)


recordCommand

public void recordCommand(java.lang.String commandline)
Required because stelcore doesn't have access to the script manager anymore! Records a command if script recording is on

Specified by:
recordCommand in interface ApplicationCallback
Parameters:
commandline - The command text to record

getTimeFormatStr

public java.lang.String getTimeFormatStr()

setTimeFormatStr

public void setTimeFormatStr(java.lang.String tf)

getDateFormatStr

public java.lang.String getDateFormatStr()

setDateFormatStr

public void setDateFormatStr(java.lang.String df)

setCustomTimezone

public void setCustomTimezone(java.lang.String timeZoneId)

set2DfullscreenProjection

public void set2DfullscreenProjection()
Set the drawing mode in 2D for drawing in the full screen


restoreFrom2DfullscreenProjection

public void restoreFrom2DfullscreenProjection()
Restore previous projection mode


getFps

public double getFps()

getCommander

public StelCommandInterface getCommander()

getMouseZoom

public int getMouseZoom()

setPresetSkyTime

public void setPresetSkyTime(double presetSkyTime)

getPresetSkyTime

public double getPresetSkyTime()

setStartupTimeMode

public void setStartupTimeMode(java.lang.String startupTimeMode)

getStartupTimeMode

public java.lang.String getStartupTimeMode()

getSelectedScript

public java.lang.String getSelectedScript()

setSelectedScript

public void setSelectedScript(java.lang.String selectedScript)

setSelectedScriptDirectory

public void setSelectedScriptDirectory(java.lang.String selectedScriptDirectory)

setTimeMultiplier

public void setTimeMultiplier(int timeMultiplier)

getScripts

public ScriptMgr getScripts()

getUi

public StelUI getUi()

isFlagTimePause

public boolean isFlagTimePause()

setFlagTimePause

public void setFlagTimePause(boolean flagTimePause)

getTempTimeVelocity

public double getTempTimeVelocity()

setTempTimeVelocity

public void setTempTimeVelocity(double tempTimeVelocity)