Class Context
java.lang.Object
megalodonte.application.Context
Application context available to the startup handler. Provides access to the
primary
Stage, command-line arguments, and view/navigation methods.
Created once by Bootstrap.dispatch(Class, Stage, String[]) and passed to the application handler
via MegalodonteApp.run(Consumer, Consumer).
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionmegalodonte.contracts.BackendContractString[]getArgs()Returns the command-line arguments passed to the application.javafx.stage.StageReturns the primary JavaFX stage managed by this context.voidupdateView(ScreenComponent component) Re-renderscomponentin place — swaps the currentScene's root node, keeping the Stage's existing Scene, size and position untouched.useRouter(RouterBase router) Binds a router to this context and returns aContext.RouterBuilderto start navigation.voiduseView(Class<? extends ScreenComponent> componentClass) Instantiates aScreenComponentby class and renders it as the current view.voiduseView(ComponentInterface<?> component) Deprecated, for removal: This API element is subject to removal in a future version.voiduseView(ScreenComponent component) Renders aScreenComponentas the current view.voiduseView(ScreenComponent component, double sceneWidth, double sceneHeight) Creates the first scene at its intended size, avoiding native resize feedback at startup.voiduseView(RouteResult routeResult) Renders a route result, applying itsRouteProps(dimensions, title, icon, resizability) to the stage.
-
Field Details
-
width
public final double width- See Also:
-
height
public final double height- See Also:
-
-
Method Details
-
backendContract
public megalodonte.contracts.BackendContract backendContract() -
getArgs
Returns the command-line arguments passed to the application. @return the arguments array -
javafxStage
public javafx.stage.Stage javafxStage()Returns the primary JavaFX stage managed by this context. @return the primary stage -
useView
Instantiates aScreenComponentby class and renders it as the current view. Creates a newScenewith the default dimensions and centers the stage.- Parameters:
componentClass- the screen component class to instantiate- Throws:
RuntimeException- if instantiation fails
-
useView
Renders aScreenComponentas the current view. Creates a newScene, applies the theme font, sets it on the stage, and schedulesonMount.- Parameters:
component- the screen component to render
-
useView
Creates the first scene at its intended size, avoiding native resize feedback at startup. -
updateView
Re-renderscomponentin place — swaps the currentScene's root node, keeping the Stage's existing Scene, size and position untouched. UnlikeuseView(ScreenComponent), which creates a brand-newSceneand re-centers the window (right for the first render, since the Stage doesn't have a size to preserve yet), this is for reactive re-renders of an already-showing screen — e.g. switching themes — where the window visibly jumping/resizing would be a regression, not a feature.Deliberately does NOT call
component.onMount()— that hook is a one-time "just mounted" signal (e.g.HomeScreen.onMount()reopens the last saved layout from disk), not something that should re-fire on every re-render triggered by this method.Falls back to
useView(ScreenComponent)if the Stage has no Scene yet (nothing to swap the root of).- Parameters:
component- the screen component to re-render in place
-
useView
Renders a route result, applying itsRouteProps(dimensions, title, icon, resizability) to the stage. Does not callonMount— that is handled by the router.- Parameters:
routeResult- the resolved route to display
-
useView
Deprecated, for removal: This API element is subject to removal in a future version.Advise: onMount will not work using this method- Parameters:
component- the component to render (deprecated, useuseView(ScreenComponent))
-
useRouter
Binds a router to this context and returns aContext.RouterBuilderto start navigation.- Parameters:
router- the router to bind- Returns:
- a builder to call
Context.RouterBuilder.start()on
-