Gridarta Editor
net.sf.gridarta.gui.misc.MapPreview Class Reference

The map preview of the level editor. More...

+ Inheritance diagram for net.sf.gridarta.gui.misc.MapPreview:
+ Collaboration diagram for net.sf.gridarta.gui.misc.MapPreview:

Public Member Functions

 MapPreview (@NotNull final Image original)
 Constructs the user interface. More...
 
void paintComponent (@NotNull final Graphics g)
 
void zoom0 () throws OutOfMemoryError
 Zoom to 24x24. More...
 
void zoom100 () throws OutOfMemoryError
 Zoom to 100%. More...
 
void zoom12 () throws OutOfMemoryError
 Zoom to 12.5%. More...
 
void zoom150 () throws OutOfMemoryError
 Zoom to 150%. More...
 
void zoom200 () throws OutOfMemoryError
 Zoom to 200%. More...
 
void zoom25 () throws OutOfMemoryError
 Zoom to 25%. More...
 
void zoom250 () throws OutOfMemoryError
 Zoom to 250%. More...
 
void zoom300 () throws OutOfMemoryError
 Zoom to 300%. More...
 
void zoom400 () throws OutOfMemoryError
 Zoom to 400%. More...
 
void zoom50 () throws OutOfMemoryError
 Zoom to 50%. More...
 
void zoomAlgAreaAveraging () throws OutOfMemoryError
 Zoom Algorithm: Area Averaging. More...
 
void zoomAlgDefault () throws OutOfMemoryError
 Zoom Algorithm: Default. More...
 
void zoomAlgFast () throws OutOfMemoryError
 Zoom Algorithm: Fast. More...
 
void zoomAlgReplicate () throws OutOfMemoryError
 Zoom Algorithm: Replicate. More...
 
void zoomAlgSmooth () throws OutOfMemoryError
 Zoom Algorithm: Smooth. More...
 
void zoomClose ()
 Close the preview. More...
 
void zoomSave () throws IOException, OutOfMemoryError
 Zoom save. More...
 

Private Member Functions

void rescale () throws OutOfMemoryError
 Recalculate the image. More...
 
void setAlgorithm (final int algorithm)
 Set the algorithm. More...
 
void setScale (final double scale) throws OutOfMemoryError
 Set the scale factor to be used for displaying the image. More...
 
void setScale (final int width, final int height)
 Set the scale factor to a specific size. More...
 

Private Attributes

int algorithm = Image.SCALE_DEFAULT
 The currently used algorithm. More...
 
final JFrame frame
 The preview frame. More...
 
int height
 The currently used height. More...
 
Image image
 The currently displayed image. More...
 
final Image original
 The original image. More...
 
int width
 The currently used width. More...
 

Static Private Attributes

static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta")
 Action Builder. More...
 
static final long serialVersionUID = 1L
 The serial Version UID. More...
 

Detailed Description

The map preview of the level editor.

This allows the user to zoom in and out of the map.

Author
Peter Plischewsky
Christian Hujer
Todo:

add user definable previews

add zoom increase, zoom decrease

Definition at line 51 of file MapPreview.java.

Constructor & Destructor Documentation

◆ MapPreview()

net.sf.gridarta.gui.misc.MapPreview.MapPreview ( @NotNull final Image  original)

Constructs the user interface.

When image is not null it either increases or decreases the zoom. If m_Image is null the the program will wait for a zoom factor to be chosen.

Parameters
originalthe image to be displayed

Definition at line 109 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.ACTION_BUILDER, net.sf.gridarta.gui.misc.MapPreview.frame, net.sf.gridarta.gui.misc.MapPreview.height, net.sf.gridarta.gui.misc.MapPreview.image, net.sf.gridarta.gui.misc.MapPreview.original, net.sf.gridarta.gui.misc.MapPreview.rescale(), and net.sf.gridarta.gui.misc.MapPreview.width.

+ Here is the call graph for this function:

Member Function Documentation

◆ paintComponent()

void net.sf.gridarta.gui.misc.MapPreview.paintComponent ( @NotNull final Graphics  g)

Definition at line 378 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.image.

Referenced by net.sf.gridarta.gui.misc.MapPreview.zoomSave().

+ Here is the caller graph for this function:

◆ rescale()

void net.sf.gridarta.gui.misc.MapPreview.rescale ( ) throws OutOfMemoryError
private

Recalculate the image.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 359 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.algorithm, net.sf.gridarta.gui.misc.MapPreview.height, net.sf.gridarta.gui.misc.MapPreview.image, net.sf.gridarta.gui.misc.MapPreview.original, and net.sf.gridarta.gui.misc.MapPreview.width.

Referenced by net.sf.gridarta.gui.misc.MapPreview.MapPreview(), net.sf.gridarta.gui.misc.MapPreview.setAlgorithm(), and net.sf.gridarta.gui.misc.MapPreview.setScale().

+ Here is the caller graph for this function:

◆ setAlgorithm()

void net.sf.gridarta.gui.misc.MapPreview.setAlgorithm ( final int  algorithm)
private

◆ setScale() [1/2]

void net.sf.gridarta.gui.misc.MapPreview.setScale ( final double  scale) throws OutOfMemoryError
private

Set the scale factor to be used for displaying the image.

The viewport size is automatically updated.

Parameters
scalescale factor to be used
Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 328 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.height, net.sf.gridarta.gui.misc.MapPreview.original, net.sf.gridarta.gui.misc.MapPreview.rescale(), and net.sf.gridarta.gui.misc.MapPreview.width.

Referenced by net.sf.gridarta.gui.misc.MapPreview.zoom0(), net.sf.gridarta.gui.misc.MapPreview.zoom100(), net.sf.gridarta.gui.misc.MapPreview.zoom12(), net.sf.gridarta.gui.misc.MapPreview.zoom150(), net.sf.gridarta.gui.misc.MapPreview.zoom200(), net.sf.gridarta.gui.misc.MapPreview.zoom25(), net.sf.gridarta.gui.misc.MapPreview.zoom250(), net.sf.gridarta.gui.misc.MapPreview.zoom300(), net.sf.gridarta.gui.misc.MapPreview.zoom400(), and net.sf.gridarta.gui.misc.MapPreview.zoom50().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setScale() [2/2]

void net.sf.gridarta.gui.misc.MapPreview.setScale ( final int  width,
final int  height 
)
private

Set the scale factor to a specific size.

Parameters
widthwidth for scale
heightheight for scale

Definition at line 339 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.height, net.sf.gridarta.gui.misc.MapPreview.rescale(), and net.sf.gridarta.gui.misc.MapPreview.width.

+ Here is the call graph for this function:

◆ zoom0()

void net.sf.gridarta.gui.misc.MapPreview.zoom0 ( ) throws OutOfMemoryError

Zoom to 24x24.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 138 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setScale().

+ Here is the call graph for this function:

◆ zoom100()

void net.sf.gridarta.gui.misc.MapPreview.zoom100 ( ) throws OutOfMemoryError

Zoom to 100%.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 178 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setScale().

+ Here is the call graph for this function:

◆ zoom12()

void net.sf.gridarta.gui.misc.MapPreview.zoom12 ( ) throws OutOfMemoryError

Zoom to 12.5%.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 148 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setScale().

+ Here is the call graph for this function:

◆ zoom150()

void net.sf.gridarta.gui.misc.MapPreview.zoom150 ( ) throws OutOfMemoryError

Zoom to 150%.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 188 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setScale().

+ Here is the call graph for this function:

◆ zoom200()

void net.sf.gridarta.gui.misc.MapPreview.zoom200 ( ) throws OutOfMemoryError

Zoom to 200%.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 198 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setScale().

+ Here is the call graph for this function:

◆ zoom25()

void net.sf.gridarta.gui.misc.MapPreview.zoom25 ( ) throws OutOfMemoryError

Zoom to 25%.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 158 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setScale().

+ Here is the call graph for this function:

◆ zoom250()

void net.sf.gridarta.gui.misc.MapPreview.zoom250 ( ) throws OutOfMemoryError

Zoom to 250%.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 208 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setScale().

+ Here is the call graph for this function:

◆ zoom300()

void net.sf.gridarta.gui.misc.MapPreview.zoom300 ( ) throws OutOfMemoryError

Zoom to 300%.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 218 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setScale().

+ Here is the call graph for this function:

◆ zoom400()

void net.sf.gridarta.gui.misc.MapPreview.zoom400 ( ) throws OutOfMemoryError

Zoom to 400%.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 228 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setScale().

+ Here is the call graph for this function:

◆ zoom50()

void net.sf.gridarta.gui.misc.MapPreview.zoom50 ( ) throws OutOfMemoryError

Zoom to 50%.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 168 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setScale().

+ Here is the call graph for this function:

◆ zoomAlgAreaAveraging()

void net.sf.gridarta.gui.misc.MapPreview.zoomAlgAreaAveraging ( ) throws OutOfMemoryError

Zoom Algorithm: Area Averaging.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 317 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setAlgorithm().

+ Here is the call graph for this function:

◆ zoomAlgDefault()

void net.sf.gridarta.gui.misc.MapPreview.zoomAlgDefault ( ) throws OutOfMemoryError

Zoom Algorithm: Default.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 277 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setAlgorithm().

+ Here is the call graph for this function:

◆ zoomAlgFast()

void net.sf.gridarta.gui.misc.MapPreview.zoomAlgFast ( ) throws OutOfMemoryError

Zoom Algorithm: Fast.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 287 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setAlgorithm().

+ Here is the call graph for this function:

◆ zoomAlgReplicate()

void net.sf.gridarta.gui.misc.MapPreview.zoomAlgReplicate ( ) throws OutOfMemoryError

Zoom Algorithm: Replicate.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 307 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setAlgorithm().

+ Here is the call graph for this function:

◆ zoomAlgSmooth()

void net.sf.gridarta.gui.misc.MapPreview.zoomAlgSmooth ( ) throws OutOfMemoryError

Zoom Algorithm: Smooth.

Exceptions
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 297 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.setAlgorithm().

+ Here is the call graph for this function:

◆ zoomClose()

void net.sf.gridarta.gui.misc.MapPreview.zoomClose ( )

Close the preview.

Definition at line 267 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.frame.

◆ zoomSave()

void net.sf.gridarta.gui.misc.MapPreview.zoomSave ( ) throws IOException, OutOfMemoryError

Zoom save.

Exceptions
IOExceptionIn case of I/O problems.
OutOfMemoryErrorIn case this method runs out of memory, which really might happen, so callers are expected to handle this.

Definition at line 239 of file MapPreview.java.

References net.sf.gridarta.gui.misc.MapPreview.ACTION_BUILDER, net.sf.gridarta.gui.misc.MapPreview.frame, net.sf.gridarta.gui.misc.MapPreview.image, net.sf.gridarta.gui.misc.MapPreview.paintComponent(), and net.sf.gridarta.utils.FileFilters.PNG_FILE_FILTER.

+ Here is the call graph for this function:

Member Data Documentation

◆ ACTION_BUILDER

final ActionBuilder net.sf.gridarta.gui.misc.MapPreview.ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta")
staticprivate

◆ algorithm

int net.sf.gridarta.gui.misc.MapPreview.algorithm = Image.SCALE_DEFAULT
private

The currently used algorithm.

@serial

Definition at line 75 of file MapPreview.java.

Referenced by net.sf.gridarta.gui.misc.MapPreview.rescale(), and net.sf.gridarta.gui.misc.MapPreview.setAlgorithm().

◆ frame

final JFrame net.sf.gridarta.gui.misc.MapPreview.frame
private

◆ height

int net.sf.gridarta.gui.misc.MapPreview.height
private

◆ image

Image net.sf.gridarta.gui.misc.MapPreview.image
private

◆ original

final Image net.sf.gridarta.gui.misc.MapPreview.original
private

◆ serialVersionUID

final long net.sf.gridarta.gui.misc.MapPreview.serialVersionUID = 1L
staticprivate

The serial Version UID.

Definition at line 56 of file MapPreview.java.

◆ width

int net.sf.gridarta.gui.misc.MapPreview.width
private

The documentation for this class was generated from the following file: