Class SearchedItemPanel
java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.layout.Pane
javafx.scene.layout.HBox
org.troy.capstone.ui_components.items.SearchedItemPanel
- All Implemented Interfaces:
Styleable, EventTarget
The
SearchedItemPanel class represents a UI component that displays the details of a single item in the search results.-
Property Summary
Properties inherited from class HBox
alignment, fillHeight, spacingProperties inherited from class Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, widthProperties inherited from class Parent
needsLayoutProperties inherited from class 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 TypeFieldDescriptionprivate final AttributedItemContainerThe container for the attributed image of the item, displaying the item's image along with any relevant attributes.private static final SimpleDateFormatDate formatter for displaying the date added attribute of the item in a user-friendly format.static booleanStatic variable to track if the first instance ofSearchedItemPanelhas been created, used to assign an ID to the name label of the first instance for clicking on the instance in tests.private final List<SearchedItemPanelInteractor> List of interactors to handle interactions with the item panel, such as adding the item to theRecentlyViewedQueuewhen the panel is clicked.private final StringThe ID of the item being displayed in this panel.Fields inherited from class Region
USE_COMPUTED_SIZE, USE_PREF_SIZEFields inherited from class Node
BASELINE_OFFSET_SAME_AS_HEIGHT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSearchedItemPanel(Item item) Creates aSearchedItemPanelfor the given item, displaying its image and details in a structured layout. -
Method Summary
Modifier and TypeMethodDescriptionvoidSets aSearchedItemPanelInteractorto the panel to allow for interaction with the item panelstatic SearchedItemPanelFactory method to create aSearchedItemPanelinstance.private static LabelcreateLabel(String text) Helper method to create a label with consistent styling for the item details in the right panel.Getter for the item ID of the item being displayed in this panel, used for checking if the panel is in theRecentlyViewedQueue.static VBoxmakeRightPanel(Item item) Fills the right panel with some of the data from the item.voidStops the asynchronous loading of the image in theAttributedItemContainer.Methods inherited from class 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 Pane
getChildrenMethods inherited from class 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 Parent
getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestParentLayout, setNeedsLayout, updateBoundsMethods inherited from class 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Styleable
getStyleableNode
-
Field Details
-
interactors
List of interactors to handle interactions with the item panel, such as adding the item to theRecentlyViewedQueuewhen the panel is clicked. -
dateAddedFormatter
Date formatter for displaying the date added attribute of the item in a user-friendly format. The format used is "MMMM dd, yyyy" (e.g., "January 01, 2020"). -
attributedImage
The container for the attributed image of the item, displaying the item's image along with any relevant attributes. -
itemId
The ID of the item being displayed in this panel. Used for checking if the panel is in the recently viewed queue. -
firstInstanceMade
public static boolean firstInstanceMadeStatic variable to track if the first instance ofSearchedItemPanelhas been created, used to assign an ID to the name label of the first instance for clicking on the instance in tests.
-
-
Constructor Details
-
SearchedItemPanel
Creates aSearchedItemPanelfor the given item, displaying its image and details in a structured layout. The panel consists of a left side with the attributed image and a right side with textual details about the item. It also includes styling such as borders and spacing to enhance the visual presentation of the item information.- Parameters:
item- The item whose details are being displayed in this panel, used to populate both the attributed image and the other details.- Preconditions:
itemshould contain valid data for all attributes being displayed.
-
-
Method Details
-
create
Factory method to create aSearchedItemPanelinstance.- Parameters:
item- The item whose details are being displayed in this panel.- Returns:
- A new instance of
SearchedItemPanel.
-
addSearchedItemPanelInteractor
Sets aSearchedItemPanelInteractorto the panel to allow for interaction with the item panel- Parameters:
interactor- TheSearchedItemPanelInteractorto set for handling interactions with the item panel.- Preconditions:
interactorshould be properly implemented to handle interactions with the item panel, and theSearchedItemPanelshould be properly initialized to allow for setting the interactor.- Postconditions:
- The provided
interactoris set to theSearchedItemPanel, allowing it to receive interaction events from the item panel. This enables functionality such as adding the item to theRecentlyViewedQueuewhen the panel is clicked.
-
getItemId
Getter for the item ID of the item being displayed in this panel, used for checking if the panel is in theRecentlyViewedQueue.- Returns:
- The ID of the item being displayed in this panel.
-
stopLoadingImage
public void stopLoadingImage()Stops the asynchronous loading of the image in theAttributedItemContainer. This method can be called when the panel is no longer visible or needed, to free up resources and prevent unnecessary loading of images that are not being displayed.- Postconditions:
- The asynchronous image loading task for the
AttributedItemContaineris stopped, preventing any further loading of the image that is not being displayed.
-
makeRightPanel
Fills the right panel with some of the data from the item.- Parameters:
item- TheItemwhose data is being displayed in the right panel.- Returns:
- A
VBoxcontaining the labels with the item details, styled and formatted for display in the right panel of theSearchedItemPanel. - Preconditions:
- item should contain valid data for all the attributes being displayed.
rightPanelshould be properly initialized to add the labels to. - Postconditions:
rightPanelwill contain labels displaying the name, publisher, category, price, rating, stock quantity, and date added for the item, with consistent styling and formatting.
-
createLabel
Helper method to create a label with consistent styling for the item details in the right panel. This method sets properties such as wrapping, maximum width, and alignment to ensure that the labels are displayed consistently.- Parameters:
text- The text to display in the label.- Returns:
- A label with the specified text and consistent styling.
-