 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.action.exportmap;
22 import java.awt.Graphics2D;
23 import java.awt.Image;
24 import java.awt.image.BufferedImage;
25 import java.io.IOException;
26 import java.util.ArrayList;
27 import java.util.Collection;
28 import java.util.Collections;
29 import java.util.HashSet;
30 import java.util.Iterator;
31 import java.util.LinkedHashMap;
32 import java.util.List;
34 import java.util.Map.Entry;
50 import org.jetbrains.annotations.NotNull;
51 import org.jetbrains.annotations.Nullable;
61 private static final int SCALE = 32;
81 private final Map<MapFile, LayoutInfo>
layoutInfo =
new LinkedHashMap<>();
89 private final Map<MapFile, PendingInfo>
pending =
new LinkedHashMap<>();
96 private final Collection<MapFile>
done =
new HashSet<>();
147 progress.setMax(
done.size());
150 final Iterator<Entry<MapFile, PendingInfo>>
it =
pending.entrySet().iterator();
154 final Entry<MapFile, PendingInfo> mapFile2 =
it.next();
157 add(mapFile2.getKey(), includeTiledMaps, mapFile2.getValue());
158 progress.setMax(
done.size());
159 if (progress.cancel()) {
165 final Graphics2D graphics = image.createGraphics();
167 final List<LayoutInfo> tmp =
new ArrayList<>(
layoutInfo.values());
168 Collections.shuffle(tmp);
174 }
catch (
final IOException ex) {
175 System.err.println(
"cannot load map: " +
layoutInfo.getMapFile() +
": " + ex);
180 final BufferedImage tmp1Image = mapRenderer.
getFullImage();
181 final Image tmp2Image = tmp1Image.getScaledInstance(tmp1Image.getWidth() /
SCALE, tmp1Image.getHeight() /
SCALE, Image.SCALE_AREA_AVERAGING);
188 progress.setValue(
done, image);
189 if (progress.cancel()) {
205 private void add(@NotNull
final MapFile mapFile,
final boolean includeTiledMaps, @NotNull
final PendingInfo pendingInfo) {
209 }
catch (
final IOException ex) {
210 System.err.println(
"cannot load map: " + mapFile +
": " + ex);
216 final int width = imageSize.
getWidth();
217 final int height = imageSize.
getHeight();
219 final int x = pendingInfo.getX(width);
220 final int y = pendingInfo.getY(height);
223 }
else if (x + width >
maxX) {
228 }
else if (y + height >
maxY) {
233 if (includeTiledMaps) {
236 final String tilePath = mapArchObject.getTilePath(direction);
237 if (!tilePath.isEmpty()) {
247 if (
done.add(mapFile2)) {
274 throw new AssertionError(
"unexpected direction: " + direction);
int getWidth()
Returns the width of the area.
A MapModel reflects the data of a map.
Exception thrown if the destination path points to the source map.
Size2D getImageSize()
Returns the size of an image of the entire map view in pixels.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
A MapManager manages all opened maps.
final Map< MapFile, LayoutInfo > layoutInfo
Maps MapFile instance to the LayoutInfo for this map.
Base package of all Gridarta classes.
BufferedImage createImage(@NotNull final MapFile mapFile, final boolean includeTiledMaps, @NotNull final ExportMapProgress progress)
Creates an image from a map file.
static final int SCALE
The scale factor for the output image.
MapRenderer newSimpleMapRenderer(@NotNull MapModel< G, A, R > mapModel)
Creates a new map renderer instance which paints only squares but no grid, cursor,...
Preliminary layout information for a map.
Creates images from maps.
static MapPath newMapPath(@NotNull final String string)
Creates a MapPath instance from string representation.
Reflects a game object (object on a map).
Utility class for MapPath related functions.
final RendererFactory< G, A, R > rendererFactory
The RendererFactory for creating images from maps.
Graphical User Interface of Gridarta.
int minX
The minimum x coordinate of all maps in layoutInfo.
GameObjects are the objects based on Archetypes found on maps.
int getHeight()
Returns the height of the area.
final Collection< MapFile > done
Contains all MapFile instances which have been discovered and which are part of the final image.
Interface for receiving progress information while the map is exported.
final Map< MapFile, PendingInfo > pending
Maps MapFile instance to its preliminary layout position.
Interface for MapArchObjects.
MapControl< G, A, R > openMapFile(@NotNull MapFile mapFile, boolean interactive)
Loads a map file.
Represents a maps directory local map path.
MapImageCreator(@NotNull final MapManager< G, A, R > mapManager, @NotNull final RendererFactory< G, A, R > rendererFactory)
Creates a new instance.
final MapManager< G, A, R > mapManager
The MapManager for loading maps.
Exception thrown if an operation is attempted on an unsaved map.
int minY
The minimum y coordinate of all maps in layoutInfo.
The location of a map file with a map directory.
void release(@NotNull MapControl< G, A, R > mapControl)
Releases a MapControl instance.
int maxX
The maximum x coordinate of all maps in layoutInfo.
void add(@NotNull final MapFile mapFile, final boolean includeTiledMaps, @NotNull final PendingInfo pendingInfo)
Adds a new map file.
Factory for creating MapRenderer instances.
Base classes for rendering maps.
Currently nothing more than a marker interface for unification.
MapModel< G, A, R > getMapModel()
Returns the map model.
BufferedImage getFullImage()
Returns an image of the entire map view.
Common interface for renderers of map control instances.
MapFile getMapFile()
Returns the map file.
Stores layout information for maps.
The class Size2D represents a 2d rectangular area.
int maxY
The maximum y coordinate of all maps in layoutInfo.
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from please keep code indentation accurate This is not just good it helps to keep code readable and in that way dramatically decreases the chance for overlooked bugs Everyone is welcomed to correct indentation errors wherever they are spotted Before you start to do this please double check that your editor is really configured to insert spaces Line feeds may be checked in either in windows or in unix linux style All reasonable text and java editors can deal with both linefeed formats Converting line feeds is but in this case please make sure that only linefeed characters are changed and nothing else is affected Due to the platform independent nature of the editor has the potential to run on almost any given operating system the build process differs greatly between systems as well as java environments In the several people have attempted to add build scripts along with structural changes to optimize the setup on one particular system environment which has led to conflict Please do *not *attempt to change the structure or any directories for the mere purpose of improving a build process or performance in a java environment Build scripts may be placed in the root it would be especially fine if it is just one or two files but the latter is not required Please excuse me for placing such restriction I and many users of the editor greatly appreciate build scripts We just had some real troubles over this issue in the past and I don t want to have them repeated the editor has relatively high performance requirements I ve spent a lot of extra work to keep everything as fast and memory efficient as possible when you add new data fields or calculations in the archetype please make sure they are as efficient as possible and worth both the time and space they consume Now don t be afraid too much No development would be possible without adding calculations and data at all Just bear in mind unlike for many other open source performance does make a difference for the CrossfireEditor The for as many systems as possible In case you are unexperienced with java and note that the graphics look different on every and with every font They also have different sizes proportions and behave different A seemingly trivial and effectless change can wreck havoc for the same GUI run on another system please don t be totally afraid of it