Package com.kiancross.mandelbrot
Class ImageGenerator
- java.lang.Object
-
- com.kiancross.mandelbrot.ImageGenerator
-
public class ImageGenerator extends java.lang.Object
Manages the creation of the mandelbrot image, allowing parameters to be set to modify the resultant image.
-
-
Constructor Summary
Constructors Constructor Description ImageGenerator(ColorGradient initialColorTheme)
Construct an image generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRedo()
Check if the redo operation can be done.boolean
canUndo()
Check if the undo operation can be done.javafx.scene.paint.Color[][]
generate(int resolutionX, int resolutionY)
Generate an image of a given resolution.InformInitialObjectProperty<ImageConfiguration>
getCurrentConfigurationProperty()
Gets the current configuration property.double
getCurrentZoom(double rangeX, double rangeY)
Gets the current zoom amount.void
loadConfiguration(java.io.File file)
Loads the image configuration from a given file.void
pan(double rangeX, double rangeY, int xshift, int yshift)
Pans the view of the image a certain amount along the x-axis and y-axis.void
redo()
Redo the last undo.void
resetAll()
Reset all settings.void
saveConfiguration(java.io.File file)
Saves the image configuration to a given file.void
setColorTheme(ColorGradient theme)
Set the colour theme to use for the image.void
setEscapeRadius(double escapeRadius)
Set the escape radius to use when calculating the iteration values.void
setMaximumIterations(int maximumIterations)
Set the maximum number of iterations to use when calculating the iteration values.void
setOverlayZoom(boolean overlayZoom)
Set whether the zoom should be overlayed onto the image.void
undo()
Undo the last change.void
zoom(double rangeX, double rangeY, double minX, double maxX, double minY, double maxY)
Zooms in (scales) the image to be produced.
-
-
-
Constructor Detail
-
ImageGenerator
public ImageGenerator(ColorGradient initialColorTheme)
Construct an image generator.- Parameters:
initialColorTheme
- The initial colour theme that should be used.
-
-
Method Detail
-
zoom
public void zoom(double rangeX, double rangeY, double minX, double maxX, double minY, double maxY)
Zooms in (scales) the image to be produced.- Parameters:
rangeX
- The width of the x-axis.rangeY
- The width of the y-axis.minX
- The minimum value of x for which the image should show.maxX
- The maximum value of x for which the image should show.minY
- The minimum value of y for which the image should show.maxY
- The maximum value of y for which the image should show.
-
pan
public void pan(double rangeX, double rangeY, int xshift, int yshift)
Pans the view of the image a certain amount along the x-axis and y-axis. A positive value for xshift shifts the view right and therefore the image left. A positive value for yshift shifts the view up and therefore the image down.- Parameters:
rangeX
- The width of the x-axis.rangeY
- The width of the y-axis.xshift
- The amount to shift along the x-axis.yshift
- The amount to shift along the y-axis.
-
setMaximumIterations
public void setMaximumIterations(int maximumIterations)
Set the maximum number of iterations to use when calculating the iteration values.- Parameters:
maximumIterations
- The maximum number of iterations to use when calculating the iteration values.
-
setEscapeRadius
public void setEscapeRadius(double escapeRadius)
Set the escape radius to use when calculating the iteration values.- Parameters:
escapeRadius
- The escape radius to use when calculate the iteration values.
-
setColorTheme
public void setColorTheme(ColorGradient theme)
Set the colour theme to use for the image.- Parameters:
theme
- The colour theme to use for the image.
-
setOverlayZoom
public void setOverlayZoom(boolean overlayZoom)
Set whether the zoom should be overlayed onto the image.- Parameters:
overlayZoom
- Whether the zoom should be overlayed onto the image.
-
undo
public void undo()
Undo the last change.
-
redo
public void redo()
Redo the last undo.
-
resetAll
public void resetAll()
Reset all settings.
-
canUndo
public boolean canUndo()
Check if the undo operation can be done.
-
canRedo
public boolean canRedo()
Check if the redo operation can be done.
-
getCurrentConfigurationProperty
public InformInitialObjectProperty<ImageConfiguration> getCurrentConfigurationProperty()
Gets the current configuration property. A listener can be added that is called on changes.- Returns:
- The current configuration property.
-
getCurrentZoom
public double getCurrentZoom(double rangeX, double rangeY)
Gets the current zoom amount.- Parameters:
rangeX
- The width of the x-axis.rangeY
- The height of the y-axis.
-
saveConfiguration
public void saveConfiguration(java.io.File file) throws ImageConfigurationSaveException
Saves the image configuration to a given file.- Parameters:
file
- The file to save the image configuration to.- Throws:
ImageConfigurationSaveException
- Exception thrown if there was an error saving the configuration.
-
loadConfiguration
public void loadConfiguration(java.io.File file) throws ImageConfigurationLoadException
Loads the image configuration from a given file.- Parameters:
file
- The file to save the image configuration to.- Throws:
ImageConfigurationLoadException
- Exception thrown if there was an error loading the configuration.
-
generate
public javafx.scene.paint.Color[][] generate(int resolutionX, int resolutionY)
Generate an image of a given resolution.- Parameters:
resolutionX
- Number of pixels the width of the image should be.resolutionY
- Number of pixels the height of the image should be.- Returns:
- A 2D array of pixels.
-
-