-
Notifications
You must be signed in to change notification settings - Fork 0
Image
The Image class represents an image that can be drawn onto a graphical window. It supports resizing, scaling, alignment, rotation, and outlining.
-
private Point position
The position of the image in the graphical window. -
private int width, height
The dimensions of the image. -
private BufferedImage image
The buffered image to be rendered. -
private GraphWin canvas
The graphical window where the image is drawn. -
private Color outlineColor
The color of the image's outline (default:null). -
private int outlineWidth
The width of the outline (default:1). -
private String alignment
The alignment of the image:"top-left","top-right","bottom-left","bottom-right", or"center"(default:"center"). -
private double rotation
The rotation angle of the image in degrees (default:0). -
private BufferedImage original
A copy of the original image before any transformations. -
private double scale
The scale factor of the image.
Constructs an Image object from a file path with a specified position.
Parameters:
-
position- The position of the image as aPointobject. -
filePath- The file path to the image.
Constructs an Image object from a URL with a specified position.
Parameters:
-
position- The position of the image as aPointobject. -
filePath- The URL pointing to the image file.
Sets the outline color of the image.
Parameters:
-
color- The outline color.
Sets the width of the image's outline.
Parameters:
-
width- The outline width.
Moves the image by the given offsets.
Parameters:
-
dx- The change in the x position. -
dy- The change in the y position.
Sets the size of the image.
Parameters:
-
width- The new width of the image. -
height- The new height of the image.
Scales the image by a given factor.
Parameters:
-
scaleFactor- The scale factor (e.g.,2.0doubles the size,0.5halves it).
Sets the alignment of the image.
Parameters:
-
alignment- The alignment of the image ("top-left","top-right","bottom-left","bottom-right","center").
Rotates the image by the given angle in degrees.
Parameters:
-
angle- The angle in degrees.
Draws the image onto a GraphWin canvas.
Parameters:
-
canvas- TheGraphWininstance where the image will be drawn.
Removes the image from the graphical window.
Renders the image onto a Graphics2D panel, including alignment and outline.
Parameters:
-
graphics- TheGraphics2Dobject used for rendering.