- All Implemented Interfaces:
javafx.css.Styleable,javafx.event.EventTarget
- Direct Known Subclasses:
CompletionRateWidget,DateWidget,HomeScreenQuickActionButtons,ImmediateTasksWidget,TaskDistributionWidget,UnassignedTasksWidget
BaseComponent to provide a styled widget with designated dimensions,
container setup, and common behaviors for widgets in an application.
The `BaseWidget` sets up a consistent structure for child widgets, including predefined dimensions, styled containers, and lifecycle methods inherited from the base class. Supports customization through extensions.
-
Property Summary
PropertiesTypePropertyDescriptionjavafx.beans.property.StringPropertyReturns the description property.javafx.beans.property.StringPropertyReturns the title property.Properties inherited from class javafx.scene.layout.HBox
alignment, fillHeight, spacingProperties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, widthProperties inherited from class javafx.scene.Parent
needsLayoutProperties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected final javafx.scene.layout.VBoxprotected final Textprotected final intprotected final doubleprotected final javafx.scene.layout.VBoxprotected final TextFields inherited from class no.ntnu.principes.components.BaseComponent
parentScreenFields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZEFields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT -
Constructor Summary
ConstructorsConstructorDescriptionBaseWidget(String componentId, String widgetHeader, String widgetDescription, BaseScreen parentScreen) Constructs a new `BaseWidget` with a title and optional description.BaseWidget(String componentId, String widgetHeader, BaseScreen parentScreen) Constructs a new `BaseWidget` with just a title header. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.StringPropertyReturns the description property.protected voidAdjusts the height of the content area to match the widget's height.Gets the current description value.getTitle()Gets the current title value.protected voidInitialize the component.protected voidExecuted when the component or object is destroyed.protected voidonMount()Executed when the component or object is initialized and added to its parent or context.protected voidExecuted when the component or object is removed from its parent or context.booleanrefresh()Refreshes the widget's data or state.voidsetDescription(String description) Sets a new description value.voidSets a new title value.protected voidConfigures the layout and styling of the `contentContainer` for the widget.voidsetWidgetHeight(double height) Set the widget's height in pixels.voidsetWidgetWidth(double width) Set the widget's width in pixels.javafx.beans.property.StringPropertyReturns the title property.Methods inherited from class no.ntnu.principes.components.BaseComponent
destroy, hashCode, isDestroyed, isInitialized, mount, setupEventHandlers, unmountMethods inherited from class javafx.scene.layout.HBox
alignmentProperty, clearConstraints, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, fillHeightProperty, getAlignment, getBaselineOffset, getClassCssMetaData, getContentBias, getCssMetaData, getHgrow, getMargin, getSpacing, isFillHeight, layoutChildren, requestLayout, setAlignment, setFillHeight, setHgrow, setMargin, setSpacing, spacingPropertyMethods inherited from class javafx.scene.layout.Pane
getChildrenMethods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthPropertyMethods inherited from class javafx.scene.Parent
getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestParentLayout, setNeedsLayout, updateBoundsMethods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isFocusVisible, isFocusWithin, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visiblePropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
title
public javafx.beans.property.StringProperty titlePropertyReturns the title property.- See Also:
-
description
public javafx.beans.property.StringProperty descriptionPropertyReturns the description property.- See Also:
-
-
Field Details
-
BORDER_RADIUS
protected final int BORDER_RADIUS- See Also:
-
FONT_SIZE
protected final int FONT_SIZE- See Also:
-
SUB_FONT_SIZE_SCALE
protected final double SUB_FONT_SIZE_SCALE- See Also:
-
contentContainer
protected final javafx.scene.layout.VBox contentContainer -
textContainer
protected final javafx.scene.layout.VBox textContainer -
titleText
-
descriptionText
-
-
Constructor Details
-
BaseWidget
Constructs a new `BaseWidget` with just a title header.- Parameters:
componentId- a unique identifier for this widget instance.widgetHeader- the text to display as the widget's header.parentScreen- the parentBaseScreento which this widget belongs.
-
BaseWidget
public BaseWidget(String componentId, String widgetHeader, String widgetDescription, BaseScreen parentScreen) Constructs a new `BaseWidget` with a title and optional description.- Parameters:
componentId- a unique identifier for this widget instance.widgetHeader- the text to display as the widget's header.widgetDescription- the text to display as the widget's description. Can be empty.parentScreen- the parentBaseScreento which this widget belongs.
-
-
Method Details
-
titleProperty
public javafx.beans.property.StringProperty titleProperty()Returns the title property.- Returns:
- the title property
- See Also:
-
getTitle
Gets the current title value.- Returns:
- the current title
-
setTitle
Sets a new title value.- Parameters:
title- the new title
-
descriptionProperty
public javafx.beans.property.StringProperty descriptionProperty()Returns the description property.- Returns:
- the description property
- See Also:
-
getDescription
Gets the current description value.- Returns:
- the current description
-
setDescription
Sets a new description value. If the description is null or empty, the description text will be hidden. Otherwise, it will be shown.- Parameters:
description- the new description
-
initializeComponent
protected void initializeComponent()Initialize the component. This method is called when the component is created. Subclasses should override this method to perform any initialization- Specified by:
initializeComponentin classBaseComponent
-
setupContainer
protected void setupContainer()Configures the layout and styling of the `contentContainer` for the widget.Sets up alignment, padding, spacing, preferred dimensions, and visual styles such as borders and background. This method ensures that the widget's content container adheres to consistent design rules and dimensions across all widgets.
Subclasses can override this method to provide custom styling or layout behaviors if needed.
-
onMount
protected void onMount()Description copied from class:BaseComponentExecuted when the component or object is initialized and added to its parent or context.This method should be overridden by subclasses to define specific mount behavior.
This method is part of the component lifecycle and should not be called directly.
- Specified by:
onMountin classBaseComponent
-
onUnmount
protected void onUnmount()Description copied from class:BaseComponentExecuted when the component or object is removed from its parent or context.This method should be overridden by subclasses to define specific unmount behavior.
This method is part of the component lifecycle and should not be called directly.
- Specified by:
onUnmountin classBaseComponent
-
onDestroy
protected void onDestroy()Description copied from class:BaseComponentExecuted when the component or object is destroyed.This method should be overridden by subclasses to define specific destroy behavior.
This method is part of the component lifecycle and should not be called directly.
- Specified by:
onDestroyin classBaseComponent
-
setWidgetWidth
public void setWidgetWidth(double width) Set the widget's width in pixels.- Parameters:
width- the desired width for the widget, in pixels. Must be a positive value.
-
setWidgetHeight
public void setWidgetHeight(double height) Set the widget's height in pixels.- Parameters:
height- the desired height for the widget, in pixels. Must be a positive value.
-
fitContent
protected void fitContent()Adjusts the height of the content area to match the widget's height. -
refresh
public boolean refresh()Refreshes the widget's data or state.
-