Class BaseWidget

java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.layout.Pane
javafx.scene.layout.HBox
no.ntnu.principes.components.BaseComponent
no.ntnu.principes.components.widgets.BaseWidget
All Implemented Interfaces:
javafx.css.Styleable, javafx.event.EventTarget
Direct Known Subclasses:
CompletionRateWidget, DateWidget, HomeScreenQuickActionButtons, ImmediateTasksWidget, TaskDistributionWidget, UnassignedTasksWidget

public class BaseWidget extends BaseComponent
Extends 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

    Properties
    Type
    Property
    Description
    javafx.beans.property.StringProperty
    Returns the description property.
    javafx.beans.property.StringProperty
    Returns the title property.

    Properties inherited from class javafx.scene.layout.HBox

    alignment, fillHeight, spacing

    Properties inherited from class javafx.scene.layout.Region

    background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width

    Properties inherited from class javafx.scene.Parent

    needsLayout

    Properties 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

    Fields
    Modifier and Type
    Field
    Description
    protected final int
     
    protected final javafx.scene.layout.VBox
     
    protected final Text
     
    protected final int
     
    protected final double
     
    protected final javafx.scene.layout.VBox
     
    protected final Text
     

    Fields inherited from class no.ntnu.principes.components.BaseComponent

    parentScreen

    Fields inherited from class javafx.scene.layout.Region

    USE_COMPUTED_SIZE, USE_PREF_SIZE

    Fields inherited from class javafx.scene.Node

    BASELINE_OFFSET_SAME_AS_HEIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseWidget(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 Type
    Method
    Description
    javafx.beans.property.StringProperty
    Returns the description property.
    protected void
    Adjusts the height of the content area to match the widget's height.
    Gets the current description value.
    Gets the current title value.
    protected void
    Initialize the component.
    protected void
    Executed when the component or object is destroyed.
    protected void
    Executed when the component or object is initialized and added to its parent or context.
    protected void
    Executed when the component or object is removed from its parent or context.
    boolean
    Refreshes the widget's data or state.
    void
    setDescription(String description)
    Sets a new description value.
    void
    Sets a new title value.
    protected void
    Configures the layout and styling of the `contentContainer` for the widget.
    void
    setWidgetHeight(double height)
    Set the widget's height in pixels.
    void
    setWidgetWidth(double width)
    Set the widget's width in pixels.
    javafx.beans.property.StringProperty
    Returns the title property.

    Methods inherited from class no.ntnu.principes.components.BaseComponent

    destroy, hashCode, isDestroyed, isInitialized, mount, setupEventHandlers, unmount

    Methods 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, spacingProperty

    Methods inherited from class javafx.scene.layout.Pane

    getChildren

    Methods 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, widthProperty

    Methods inherited from class javafx.scene.Parent

    getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestParentLayout, setNeedsLayout, updateBounds

    Methods 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, visibleProperty

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface javafx.css.Styleable

    getStyleableNode
  • Property Details

  • 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

      protected final Text titleText
    • descriptionText

      protected final Text descriptionText
  • Constructor Details

    • BaseWidget

      public BaseWidget(String componentId, String widgetHeader, BaseScreen parentScreen)
      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 parent BaseScreen to 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 parent BaseScreen to which this widget belongs.
  • Method Details

    • titleProperty

      public javafx.beans.property.StringProperty titleProperty()
      Returns the title property.
      Returns:
      the title property
      See Also:
    • getTitle

      public String getTitle()
      Gets the current title value.
      Returns:
      the current title
    • setTitle

      public void setTitle(String title)
      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

      public String getDescription()
      Gets the current description value.
      Returns:
      the current description
    • setDescription

      public void setDescription(String description)
      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:
      initializeComponent in class BaseComponent
    • 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: BaseComponent
      Executed 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:
      onMount in class BaseComponent
    • onUnmount

      protected void onUnmount()
      Description copied from class: BaseComponent
      Executed 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:
      onUnmount in class BaseComponent
    • onDestroy

      protected void onDestroy()
      Description copied from class: BaseComponent
      Executed 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:
      onDestroy in class BaseComponent
    • 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.