public class ImageShape extends Object implements TurtleShape
Modifier and Type | Class and Description |
---|---|
static class |
ImageShape.Builder
The builder of ImageShape class instances.
|
Constructor and Description |
---|
ImageShape(File imageFile)
Constructs a turtle shape from an image file.
|
ImageShape(File imageFile,
double xCenter,
double yCenter)
Constructs a turtle shape from an image file.
|
ImageShape(String imageLocation)
Constructs a turtle shape from image at a specified location.
|
ImageShape(String imageLocation,
double xCenter,
double yCenter)
Constructs a turtle shape from image at a specified location.
|
ImageShape(String packageName,
String fileName)
Constructs a turtle shape from an image resource located in specified
package and a given filename.The center of the shape is set to the center
of the image.
|
ImageShape(URL imageURL)
Constructs a turtle shape from an image.
|
ImageShape(URL imageURL,
double xCenter,
double yCenter)
Constructs a turtle shape from an image.
|
Modifier and Type | Method and Description |
---|---|
Point2D |
getCenter()
Returns coordinates of the shape center.
|
int |
getFrameCount()
Returns immutable number of animation frames defined for each view of the
shape.
|
long |
getFrameDuration()
Returns immutable animation delay (time period between animation frames)
in milliseconds.
|
int |
getHeight()
Returns the height of each frame in this shape.
|
int |
getViewCount()
Returns immutable number of views provided by the shape.
|
int |
getWidth()
Returns the width of each frame in this shape.
|
double |
getXCenter()
Returns the X-coordinate of the shape center.
|
double |
getYCenter()
Returns the Y-coordinate of the shape center.
|
boolean |
isPointOfShape(Turtle t,
double x,
double y)
Returns whether a given point is internal point of current turtle's
shape.
|
void |
paintTurtle(Turtle t,
Graphics2D g)
Paints shape of a turtle to a given graphics.
|
public ImageShape(URL imageURL, double xCenter, double yCenter)
imageURL
- the URL of an image with the shapexCenter
- the X-coordinate of the shape centeryCenter
- the Y-coordinate of the shape centerpublic ImageShape(URL imageURL)
imageURL
- the URL of an image with the shapepublic ImageShape(File imageFile, double xCenter, double yCenter)
imageFile
- file with image for the shapexCenter
- the X-coordinate of the shape centeryCenter
- the Y-coordinate of the shape centerpublic ImageShape(File imageFile)
imageFile
- file with the image for the shapepublic ImageShape(String imageLocation, double xCenter, double yCenter)
imageLocation
- the string with location of an image (file or resource)xCenter
- the X-coordinate of the shape centeryCenter
- the Y-coordinate of the shape centerpublic ImageShape(String imageLocation)
imageLocation
- the string with location of an image (file or resource)public ImageShape(String packageName, String fileName)
packageName
- the package where resource file is searchedfileName
- the filename (in the package given by parameter packageName)public int getWidth()
public int getHeight()
public Point2D getCenter()
public double getXCenter()
public double getYCenter()
public void paintTurtle(Turtle t, Graphics2D g)
paintTurtle
in interface TurtleShape
t
- the turtle whose shape is drawn.g
- the graphic where the shape is drawn.public int getViewCount()
TurtleShape
getViewCount
in interface TurtleShape
public int getFrameCount()
TurtleShape
getFrameCount
in interface TurtleShape
public boolean isPointOfShape(Turtle t, double x, double y)
TurtleShape
isPointOfShape
in interface TurtleShape
t
- the turtle whose shape is consideredx
- the x coordinate of pointy
- the y coordinate of pointpublic long getFrameDuration()
TurtleShape
getFrameDuration
in interface TurtleShape
Copyright © 2017. All rights reserved.