Package romanemperorsscraper.ui.people
Class PersonCard
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Frame
-
- javax.swing.JFrame
-
- romanemperorsscraper.ui.people.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.JFrameClass 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.Window
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
-
-
Field Summary
Fields Modifier and Type Field Description private BackToGraphButtonbackToGraphButtonprivate javax.swing.JLabelbackToGraphLabelprivate java.awt.ContainerbuttonContainerprivate static java.awt.ImagedefaultImageprivate java.lang.StringdynastyPageUrlprivate GoToSuccessorButtongoToSuccessorButtonprivate javax.swing.JLabelgoToSuccessorLabelprivate javax.swing.JLabelimageprivate java.awt.ContainerimageButtonContainerprivate static java.util.HashMap<java.lang.String,java.awt.Image>imagesHashMapprivate javax.swing.JTextAreainformationprivate javax.swing.JScrollPaneinformationScrollPaneprivate Personpersonprivate PersonPageDatapersonPageData-
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
-
-
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.ImageadjustImageSize(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.StringBuilderappendStringToInformation(java.lang.StringBuilder information, java.lang.String fieldName, java.lang.String fieldValue)Append single information if it is not nullprivate static java.lang.StringBuilderappendStringToInformation(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 entryprivate static java.lang.StringBuilderappendStringToInformation(java.lang.StringBuilder information, java.lang.String fieldName, PersonNameUrl personNameUrl)Append a single relative's information if his/her PersonNameUrl existsvoidcreateButtonContainer()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.voidcreateImageButtonContainer()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 successorjava.lang.StringBuildercreateInformation(PersonPageData personPageData)Create a string representing all the information of a given PersonPageData instanceprivate voidcreateInformationScrollPane()Create a scrollPane containing the represented person's personal informationprivate voidcreateInformationTextArea()Create the text area containing the represented person's personal informationstatic java.lang.StringBuildercreateMultipleInformation(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 informationGoToSuccessorButtongetGoToSuccessorButton()javax.swing.JLabelgetGoToSuccessorLabel()javax.swing.JLabelgetImage()PersongetPerson()java.awt.ImagegetPersonImage(PersonPageData personPageData)Given a person's PersonPageData object, download his/her image from the imageUrl, if available, or get the default image otherwise.voidsetImage(javax.swing.ImageIcon image)voidsetInformation(java.lang.StringBuilder information)voidsetPerson(Person person)static voidupdateCard(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
-
-
-
-
Field Detail
-
dynastyPageUrl
private final java.lang.String dynastyPageUrl
-
person
private Person person
-
personPageData
private PersonPageData personPageData
-
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
-
backToGraphButton
private BackToGraphButton backToGraphButton
-
backToGraphLabel
private javax.swing.JLabel backToGraphLabel
-
goToSuccessorButton
private GoToSuccessorButton goToSuccessorButton
-
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 dynastyperson- the Person object of the person to be representedpeopleList- 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 informationfieldName- 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 informationfieldName- 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 informationfieldName- 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 updatedsuccessor- 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
-
-