Class PersonCard

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

    public class PersonCard
    extends javax.swing.JFrame
    Class used to graphically visualize information contained in a PersonPageData object, which are the information relative to a member of a Roman Emperors Dynasty. It can be opened by the user by clicking on a PeopleListOpenButton in a DynastyTreeFrame.
    Author:
    Sara Lazzaroni, Matteo Collica, Ivan Dalla Ragione
    See Also:
    PersonPageData, PeopleListOpenButton, DynastyTreeFrame, Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JFrame

        javax.swing.JFrame.AccessibleJFrame
      • Nested classes/interfaces inherited from class java.awt.Frame

        java.awt.Frame.AccessibleAWTFrame
      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private BackToGraphButton backToGraphButton  
      private javax.swing.JLabel backToGraphLabel  
      private java.awt.Container buttonContainer  
      private static java.awt.Image defaultImage  
      private java.lang.String dynastyPageUrl  
      private GoToSuccessorButton goToSuccessorButton  
      private javax.swing.JLabel goToSuccessorLabel  
      private javax.swing.JLabel image  
      private java.awt.Container imageButtonContainer  
      private static java.util.HashMap<java.lang.String,​java.awt.Image> imagesHashMap  
      private javax.swing.JTextArea information  
      private javax.swing.JScrollPane informationScrollPane  
      private Person person  
      private PersonPageData personPageData  
      • Fields inherited from class javax.swing.JFrame

        accessibleContext, rootPane, rootPaneCheckingEnabled
      • Fields inherited from class java.awt.Frame

        CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
      • Fields inherited from class java.awt.Component

        BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
      • Fields inherited from interface javax.swing.WindowConstants

        DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
    • Constructor Summary

      Constructors 
      Constructor Description
      PersonCard​(java.lang.String dynastyPageUrl, Person person, PeopleList peopleList)
      Given a dynasty's Wikipedia page URL, a person to be represented and the PeopleList this person is included into, create a frame containing image, personal information, a button to go to his/her successors (if there are available) and a button to go back to the graph
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.awt.Image adjustImageSize​(java.awt.image.BufferedImage image)
      Scale / enlarge an image by a proportional constant so that its proportions are as much as possible maintained.
      private static java.lang.StringBuilder appendStringToInformation​(java.lang.StringBuilder information, java.lang.String fieldName, java.lang.String fieldValue)
      Append single information if it is not null
      private static java.lang.StringBuilder appendStringToInformation​(java.lang.StringBuilder information, java.lang.String fieldName, java.util.ArrayList<PersonNameUrl> arrayOfPersonNameUrls)
      Appends an ArrayList of relatives of a specific kinship degree if it exists and contains at least one entry
      private static java.lang.StringBuilder appendStringToInformation​(java.lang.StringBuilder information, java.lang.String fieldName, PersonNameUrl personNameUrl)
      Append a single relative's information if his/her PersonNameUrl exists
      void createButtonContainer()
      Create a container with a button used to go back to the graph and a button used to go to the successor if there is at least one.
      void createImageButtonContainer()
      Create a container with the person's image, if available, or a default image, the button to go back to the graph and, in case, the button to go to the successor
      java.lang.StringBuilder createInformation​(PersonPageData personPageData)
      Create a string representing all the information of a given PersonPageData instance
      private void createInformationScrollPane()
      Create a scrollPane containing the represented person's personal information
      private void createInformationTextArea()
      Create the text area containing the represented person's personal information
      static java.lang.StringBuilder createMultipleInformation​(java.util.ArrayList<PersonNameUrl> arrayOfPersonNameUrl, java.lang.StringBuilder information)
      Given the ArrayList of PersonNameUrl(s) of a specific kinship degree's relatives, add the list of their names to the string of personal information
      GoToSuccessorButton getGoToSuccessorButton()  
      javax.swing.JLabel getGoToSuccessorLabel()  
      javax.swing.JLabel getImage()  
      Person getPerson()  
      java.awt.Image getPersonImage​(PersonPageData personPageData)
      Given a person's PersonPageData object, download his/her image from the imageUrl, if available, or get the default image otherwise.
      void setImage​(javax.swing.ImageIcon image)  
      void setInformation​(java.lang.StringBuilder information)  
      void setPerson​(Person person)  
      static void updateCard​(PersonCard personCard, Person successor)
      Replace the represented person's personal information and image with her/his successor's
      • Methods inherited from class javax.swing.JFrame

        addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
      • Methods inherited from class java.awt.Frame

        addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.awt.MenuContainer

        getFont, postEvent
    • Field Detail

      • dynastyPageUrl

        private final java.lang.String dynastyPageUrl
      • person

        private Person person
      • imagesHashMap

        private static java.util.HashMap<java.lang.String,​java.awt.Image> imagesHashMap
      • defaultImage

        private static java.awt.Image defaultImage
      • image

        private javax.swing.JLabel image
      • information

        private javax.swing.JTextArea information
      • backToGraphLabel

        private javax.swing.JLabel backToGraphLabel
      • goToSuccessorLabel

        private javax.swing.JLabel goToSuccessorLabel
      • imageButtonContainer

        private java.awt.Container imageButtonContainer
      • buttonContainer

        private java.awt.Container buttonContainer
      • informationScrollPane

        private javax.swing.JScrollPane informationScrollPane
    • Constructor Detail

      • PersonCard

        public PersonCard​(java.lang.String dynastyPageUrl,
                          Person person,
                          PeopleList peopleList)
        Given a dynasty's Wikipedia page URL, a person to be represented and the PeopleList this person is included into, create a frame containing image, personal information, a button to go to his/her successors (if there are available) and a button to go back to the graph
        Parameters:
        dynastyPageUrl - the Wikipedia page URL of the person's dynasty
        person - the Person object of the person to be represented
        peopleList - the PeopleList instance this PersonCard is related to
    • Method Detail

      • createButtonContainer

        public void createButtonContainer()
        Create a container with a button used to go back to the graph and a button used to go to the successor if there is at least one. Add a descriptive label too for each button.
      • createImageButtonContainer

        public void createImageButtonContainer()
        Create a container with the person's image, if available, or a default image, the button to go back to the graph and, in case, the button to go to the successor
      • createInformationTextArea

        private void createInformationTextArea()
        Create the text area containing the represented person's personal information
      • createInformationScrollPane

        private void createInformationScrollPane()
        Create a scrollPane containing the represented person's personal information
      • adjustImageSize

        private static java.awt.Image adjustImageSize​(java.awt.image.BufferedImage image)
        Scale / enlarge an image by a proportional constant so that its proportions are as much as possible maintained. Useful to normalize all the images (especially the small ones) around a specific width and height without losing too much quality.
        Parameters:
        image - the image to be scaled
        Returns:
        the image's scaled instance
      • createInformation

        public java.lang.StringBuilder createInformation​(PersonPageData personPageData)
        Create a string representing all the information of a given PersonPageData instance
        Parameters:
        personPageData - the PersonPageData instance of the person to represent
        Returns:
        the created string of personal information
      • appendStringToInformation

        private static java.lang.StringBuilder appendStringToInformation​(java.lang.StringBuilder information,
                                                                         java.lang.String fieldName,
                                                                         java.lang.String fieldValue)
        Append single information if it is not null
        Parameters:
        information - the string of personal information
        fieldName - the field name (e.g. 'Birth Date')
        fieldValue - the field value
        Returns:
        the updated information
      • appendStringToInformation

        private static java.lang.StringBuilder appendStringToInformation​(java.lang.StringBuilder information,
                                                                         java.lang.String fieldName,
                                                                         PersonNameUrl personNameUrl)
        Append a single relative's information if his/her PersonNameUrl exists
        Parameters:
        information - the string of personal information
        fieldName - the single information's field name (e.g. 'Mother')
        personNameUrl - the relative's PersonNameUrl instance
        Returns:
        the updated information
      • appendStringToInformation

        private static java.lang.StringBuilder appendStringToInformation​(java.lang.StringBuilder information,
                                                                         java.lang.String fieldName,
                                                                         java.util.ArrayList<PersonNameUrl> arrayOfPersonNameUrls)
        Appends an ArrayList of relatives of a specific kinship degree if it exists and contains at least one entry
        Parameters:
        information - the string of personal information
        fieldName - the kinship degree type name (e.g. 'Children')
        arrayOfPersonNameUrls - the ArrayList of PersonNameUrl(s) of that specific kinship degree's relatives
        Returns:
        the updated information
      • createMultipleInformation

        public static java.lang.StringBuilder createMultipleInformation​(java.util.ArrayList<PersonNameUrl> arrayOfPersonNameUrl,
                                                                        java.lang.StringBuilder information)
        Given the ArrayList of PersonNameUrl(s) of a specific kinship degree's relatives, add the list of their names to the string of personal information
        Parameters:
        arrayOfPersonNameUrl - the ArrayList of PersonNameUrl(s)
        information - the string of personal information
        Returns:
        the updated information
      • getPersonImage

        public java.awt.Image getPersonImage​(PersonPageData personPageData)
        Given a person's PersonPageData object, download his/her image from the imageUrl, if available, or get the default image otherwise.
        Parameters:
        personPageData - the given PersonPageData object
        Returns:
        the image of the person represented by the PersonPageData object
      • updateCard

        public static void updateCard​(PersonCard personCard,
                                      Person successor)
        Replace the represented person's personal information and image with her/his successor's
        Parameters:
        personCard - the PersonCard instance to be updated
        successor - the Person object relative to the new person to represent
      • setImage

        public void setImage​(javax.swing.ImageIcon image)
        Parameters:
        image - the image to be set
      • setPerson

        public void setPerson​(Person person)
        Parameters:
        person - the Person object represented by this PersonCard instance to be set
      • setInformation

        public void setInformation​(java.lang.StringBuilder information)
        Parameters:
        information - the string to update personal information to
      • getGoToSuccessorButton

        public GoToSuccessorButton getGoToSuccessorButton()
        Returns:
        the button used to go to the represented person's successors
      • getPerson

        public Person getPerson()
        Returns:
        the represented person's Person object
      • getGoToSuccessorLabel

        public javax.swing.JLabel getGoToSuccessorLabel()
        Returns:
        the label of the GoToSuccessorButton
      • getImage

        public javax.swing.JLabel getImage()
        Returns:
        the label containing the represented person's image