Package megamek.common.icons
Class Portrait
java.lang.Object
megamek.common.icons.AbstractIcon
megamek.common.icons.Portrait
- All Implemented Interfaces:
Serializable
Portrait is an implementation of AbstractIcon that contains and displays a Portrait from the Portrait Directory.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final Stringstatic final Stringstatic final StringFields inherited from class megamek.common.icons.AbstractIcon
DEFAULT_ICON_FILENAME, filename, ROOT_CATEGORY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()This is abstract to allow for different formats for determining the image in questiongetImage()booleanstatic PortraitparseFromXML(Node wn) voidsetFilename(String filename) voidwriteToXML(PrintWriter pw, int indent) Methods inherited from class megamek.common.icons.AbstractIcon
equals, getCategory, getFilename, getImage, getImage, getImage, getImageIcon, getImageIcon, hasDefaultCategory, hashCode, isDefault, isScaled, parseNode, parseNodes, scaleAndCenter, setCategory, toString, writeBodyToXML, writeToXML
-
Field Details
-
DEFAULT_PORTRAIT_FILENAME
- See Also:
-
NO_PORTRAIT_NAME
- See Also:
-
XML_TAG
- See Also:
-
DEFAULT_IMAGE_WIDTH
public static final int DEFAULT_IMAGE_WIDTH- See Also:
-
-
Constructor Details
-
Portrait
public Portrait() -
Portrait
-
Portrait
Constructs a new portrait with the given file. Even though a file is accepted, this can only be used for portraits of the directories that are parsed automatically, i.e. the MM-internal portrait dir, the user dir and the story arcs directory! This method tries to parse the filename to find the portrait. This requires replacing Windows backslashes with normal slashes in order to find the file in the way portraits are stored (seeAbstractDirectory)- Parameters:
file- The File, such as a file of "Female/Aerospace Pilot/ASF_F_3.png"
-
-
Method Details
-
setFilename
- Overrides:
setFilenamein classAbstractIcon
-
hasDefaultFilename
public boolean hasDefaultFilename()- Overrides:
hasDefaultFilenamein classAbstractIcon
-
getImage
- Overrides:
getImagein classAbstractIcon- Returns:
- the current image, scaled and centered to a width of 72 pixels
-
getBaseImage
Description copied from class:AbstractIconThis is abstract to allow for different formats for determining the image in question- Specified by:
getBaseImagein classAbstractIcon- Returns:
- the Image stored by the AbstractIcon
-
writeToXML
- Specified by:
writeToXMLin classAbstractIcon
-
parseFromXML
-
clone
-