Tiled缺氧地图编辑器怎么用用

 上传我的文档
 下载
 收藏
该文档贡献者很忙,什么也没留下。
 下载此文档
正在努力加载中...
mapwin和Tiled(手机游戏地图编辑器)使用指南 doc
下载积分:400
内容提示:mapwin和Tiled(手机游戏地图编辑器)使用指南 doc
文档格式:PDF|
浏览次数:82|
上传日期: 04:35:17|
文档星级:
全文阅读已结束,如果下载本文需要使用
 400 积分
下载此文档
该用户还上传了这些文档
mapwin和Tiled(手机游戏地图编辑器)使用指南 doc
官方公共微信当前位置: &
& 查看源码
mapeditor.java
mapeditor.java:源码内容
&*&&Tiled&Map&Editor,&(c)&
&*&&This&program&is&free&&you&can&redistribute&it&and/or&modify
&*&&it&under&the&terms&of&the&GNU&General&Public&License&as&published&by
&*&&the&Free&Software&F&either&version&2&of&the&License,&or
&*&&(at&your&option)&any&later&version.
&*&&Adam&Turk&&&
&*&&Bjorn&Lindeijer&&b.lindeijer@xs4all.nl&
package&tiled.
import&java.awt.*;
import&java.awt.event.*;
import&java.awt.geom.A
import&java.awt.image.BufferedI
import&java.io.F
import&java.io.IOE
import&java.util.I
import&java.util.S
import&java.util.V
import&java.util.prefs.P
import&java.util.prefs.PreferenceChangeE
import&java.util.prefs.PreferenceChangeL
import&javax.imageio.ImageIO;
import&javax.swing.*;
import&javax.swing.event.*;
import&javax.swing.undo.UndoableEditS
import&tiled.core.*;
import&tiled.io.MapH
import&tiled.io.MapR
import&tiled.mapeditor.actions.*;
import&tiled.mapeditor.brush.*;
import&tiled.mapeditor.dialogs.*;
import&tiled.mapeditor.plugin.PluginClassL
import&tiled.mapeditor.selection.SelectionL
import&tiled.mapeditor.undo.*;
import&tiled.mapeditor.util.*;
import&tiled.mapeditor.widget.*;
import&tiled.util.TiledC
import&tiled.view.MapV
&*&The&main&class&for&the&Tiled&Map&Editor.
&*&@version&$Id:&MapEditor.java&689&&17:44:21Z&bjorn&$
public&class&MapEditor&implements&ActionListener,&MouseListener,
&&&&&&&&MouseMotionListener,&MapChangeListener,&ListSelectionListener,
&&&&&&&&ChangeListener,&ComponentListener
&&&&//&Constants&and&the&like
&&&&private&static&final&int&PS_POINT&&&=&0;
&&&&private&static&final&int&PS_PAINT&&&=&1;
&&&&private&static&final&int&PS_ERASE&&&=&2;
&&&&private&static&final&int&PS_POUR&&&&=&3;
&&&&private&static&final&int&PS_EYED&&&&=&4;
&&&&private&static&final&int&PS_MARQUEE&=&5;
&&&&private&static&final&int&PS_MOVE&&&&=&6;
&&&&private&static&final&int&PS_MOVEOBJ&=&7;
&&&&private&static&final&int&APP_WIDTH&=&600;
&&&&private&static&final&int&APP_HEIGHT&=&400;
&&&&private&Cursor&curD
&&&&private&Cursor&curP
&&&&private&Cursor&curE
&&&&private&Cursor&curP
&&&&private&Cursor&curE
&&&&private&Cursor&curM
&&&&/**&Current&release&version.&*/
&&&&public&static&final&String&version&=&&0.6.1&;
&&&&private&Map&currentM
&&&&private&MapView&mapV
&&&&private&final&UndoHandler&undoH
&&&&private&final&UndoableEditSupport&undoS
&&&&private&final&MapEventAdapter&mapEventA
&&&&private&final&PluginClassLoader&pluginL
&&&&private&final&Preferences&prefs&=&TiledConfiguration.root();
&&&&private&int&currentPointerS
&&&&private&Tile&currentT
&&&&private&int&currentLayer&=&-1;
&&&&private&boolean&bMouseIsDown,&bMouseIsD
&&&&private&SelectionLayer&cursorH
&&&&private&Point&mousePressLocation,&mouseInitialPressL
&&&&private&Point&moveD
&&&&private&int&mouseB
&&&&private&AbstractBrush&currentB
&&&&private&SelectionLayer&marqueeS
&&&&private&MapLayer&clipboardL
&&&&private&float&relativeMidX,&relativeMidY;
&&&&//&GUI&components
&&&&private&JPanel&&&&&&mainP
&&&&private&JPanel&&&&&&dataP
&&&&private&JPanel&&&&&&statusB
&&&&private&JMenuBar&&&&menuB
&&&&private&JCheckBoxMenuItem&gridMenuItem,&boundaryMenuItem,&cursorMenuI
&&&&private&JCheckBoxMenuItem&coordinatesMenuI
&&&&private&JMenu&&&&&&&recentM
&&&&private&JScrollPane&mapScrollP
&&&&private&JTable&&&&&&layerT
&&&&private&JList&&&&&&&editHistoryL
&&&&private&MiniMapViewer&miniM
&&&&private&TileButton&&tilePaletteB
&&&&private&JFrame&&&&&&appF
&&&&private&JSlider&&&&&opacityS
&&&&private&JLabel&&&&&&zoomLabel,&tileCoordsL
&&&&private&AbstractButton&paintButton,&eraseButton,&pourB
&&&&private&AbstractButton&eyedButton,&marqueeButton,&moveB
&&&&private&AbstractButton&objectMoveButton,&objectAddB
&&&&private&TilePaletteDialog&tilePaletteD
&&&&private&AboutDialog&aboutD
&&&&private&MapLayerEdit&paintE
&&&&/**&Available&brushes&*/
&&&&private&Vector&brushes&=&new&Vector();
&&&&private&Brush&eraserB
&&&&//&Actions
&&&&private&final&SaveAction&saveA
&&&&private&final&SaveAsAction&saveAsA
&&&&private&final&Action&exitA
&&&&private&final&Action&zoomInAction,&zoomOutAction,&zoomNormalA
&&&&private&final&Action&rot90Action,&rot180Action,&rot270A
&&&&private&final&Action&flipHorAction,&flipVerA
&&&&private&final&Action&selectAllAction,&inverseAction,&cancelSelectionA
&&&&private&final&Action&addLayerAction,&cloneLayerAction,&deleteLayerA
&&&&private&final&Action&moveLayerDownAction,&moveLayerUpA
&&&&private&final&Action&mergeLayerDownAction,&mergeAllLayersA
&&&&private&static&final&String&TOOL_PAINT&=&Resources.getString(&tool.paint.name&);
&&&&private&static&final&String&TOOL_ERASE&=&Resources.getString(&tool.erase.name&);
&&&&private&static&final&String&TOOL_FILL&=&Resources.getString(&tool.fill.name&);
&&&&private&static&final&String&TOOL_EYE_DROPPER&=&Resources.getString(&tool.eyedropper.name&);
&&&&private&static&final&String&TOOL_SELECT&=&Resources.getString(&tool.select.name&);
&&&&private&static&final&String&TOOL_MOVE_LAYER&=&Resources.getString(&tool.movelayer.name&);
&&&&private&static&final&String&TOOL_MOVE_OBJECT&=&Resources.getString(&tool.moveobject.name&);
&&&&public&MapEditor()&{
&&&&&&&&/*
&&&&&&&&eraserBrush&=&new&Eraser();
&&&&&&&&brushes.add(eraserBrush());
&&&&&&&&setBrush(eraserBrush);
&&&&&&&&*/
&&&&&&&&/*
&&&&&&&&try&{
&&&&&&&&&&&&Image&imgPaintCursor&=&Resources.getImage(&cursor-pencil.png&);
&&&&&&&&&&&&curPaint&=&Toolkit.getDefaultToolkit().createCustomCursor(
&&&&&&&&&&&&&&&&&&&&imgPaintCursor,&new&Point(0,0),&&paint&);
&&&&&&&&}&catch&(Exception&e)&{
&&&&&&&&&&&&System.out.println(&Error&while&loading&custom&cursors!&);
&&&&&&&&&&&&e.printStackTrace();
&&&&&&&&*/
&&&&&&&&curEyed&=&new&Cursor(Cursor.CROSSHAIR_CURSOR);
&&&&&&&&curDefault&=&new&Cursor(Cursor.DEFAULT_CURSOR);
&&&&&&&&undoHandler&=&new&UndoHandler(this);
&&&&&&&&undoSupport&=&new&UndoableEditSupport();
&&&&&&&&undoSupport.addUndoableEditListener(undoHandler);
&&&&&&&&cursorHighlight&=&new&SelectionLayer(1,&1);
&&&&&&&&cursorHighlight.select(0,&0);
&&&&&&&&cursorHighlight.setVisible(prefs.getBoolean(&cursorhighlight&,&true));
&&&&&&&&mapEventAdapter&=&new&MapEventAdapter();
&&&&&&&&//&Create&the&actions
&&&&&&&&saveAction&=&new&SaveAction(this);
&&&&&&&&saveAsAction&=&new&SaveAsAction(this);
&&&&&&&&exitAction&=&new&ExitAction(this,&saveAction);
&&&&&&&&zoomInAction&=&new&ZoomInAction();
&&&&&&&&zoomOutAction&=&new&ZoomOutAction();
&&&&&&&&zoomNormalAction&=&new&ZoomNormalAction();
&&&&&&&&rot90Action&=&new&LayerTransformAction(MapLayer.ROTATE_90);
&&&&&&&&rot180Action&=&new&LayerTransformAction(MapLayer.ROTATE_180);
&&&&&&&&rot270Action&=&new&LayerTransformAction(MapLayer.ROTATE_270);
&&&&&&&&flipHorAction&=&new&LayerTransformAction(MapLayer.MIRROR_HORIZONTAL);
&&&&&&&&flipVerAction&=&new&LayerTransformAction(MapLayer.MIRROR_VERTICAL);
&&&&&&&&selectAllAction&=&new&SelectAllAction();
&&&&&&&&cancelSelectionAction&=&new&CancelSelectionAction();
&&&&&&&&inverseAction&=&new&InverseSelectionAction();
&&&&&&&&addLayerAction&=&new&AddLayerAction(this);
&&&&&&&&cloneLayerAction&=&new&CloneLayerAction(this);
&&&&&&&&deleteLayerAction&=&new&DeleteLayerAction(this);
&&&&&&&&moveLayerUpAction&=&new&MoveLayerUpAction(this);
&&&&&&&&moveLayerDownAction&=&new&MoveLayerDownAction(this);
&&&&&&&&mergeLayerDownAction&=&new&MergeLayerDownAction(this);
&&&&&&&&mergeAllLayersAction&=&new&MergeAllLayersAction(this);
&&&&&&&&//&Create&our&frame
&&&&&&&&appFrame&=&new&JFrame(Resources.getString(&dialog.main.title&));
&&&&&&&&appFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
&&&&&&&&appFrame.addWindowListener(new&WindowAdapter()&{
&&&&&&&&&&&&public&void&windowClosing(WindowEvent&event)&{
&&&&&&&&&&&&&&&&exitAction.actionPerformed(null);
&&&&&&&&&&&&}
&&&&&&&&});
&&&&&&&&appFrame.setContentPane(createContentPane());
&&&&&&&&createMenuBar();
&&&&&&&&appFrame.setJMenuBar(menuBar);
&&&&&&&&appFrame.setSize(APP_WIDTH,&APP_HEIGHT);
&&&&&&&&tilePaletteDialog&=
&&&&&&&&&&&&new&TilePaletteDialog(this,&currentMap);
&&&&&&&&setCurrentMap(null);
&&&&&&&&updateRecent(null);
&&&&&&&&appFrame.setVisible(true);
&&&&&&&&//&Restore&the&state&of&the&main&frame.&This&needs&to&happen&after
&&&&&&&&//&making&the&frame&visible,&otherwise&it&has&no&effect&(in&Linux).
&&&&&&&&Preferences&mainDialogPrefs&=&prefs.node(&dialog/main&);
&&&&&&&&int&state&=&mainDialogPrefs.getInt(&state&,&Frame.NORMAL);
&&&&&&&&if&(state&!=&Frame.ICONIFIED)&{
&&&&&&&&&&&&appFrame.setExtendedState(state);
&&&&&&&&//&Load&plugins
&&&&&&&&pluginLoader&&=&PluginClassLoader.getInstance();
&&&&&&&&try&{
&&&&&&&&&&&&pluginLoader.readPlugins(null,&appFrame);
&&&&&&&&}&catch&(Exception&e)&{
&&&&&&&&&&&&e.printStackTrace();
&&&&&&&&&&&&JOptionPane.showMessageDialog(appFrame,
&&&&&&&&&&&&&&&&&&&&e.toString(),&&Plugin&loader&,
&&&&&&&&&&&&&&&&&&&&JOptionPane.WARNING_MESSAGE);
&&&&&&&&MapHelper.init(pluginLoader);
&&&&&&&&//&Make&sure&the&map&view&is&redrawn&when&grid&preferences&change.
&&&&&&&&//&todo:&move&this&functionality&out&of&here&somehow,&but&not&back&into&MapView
&&&&&&&&final&Preferences&display&=&prefs.node(&display&);
&&&&&&&&display.addPreferenceChangeListener(new&PreferenceChangeListener()&{
&&&&&&&&&&&&public&void&preferenceChange(PreferenceChangeEvent&event)&{
&&&&&&&&&&&&&&&&if&(mapView&==&null)&
&&&&&&&&&&&&&&&&String&key&=&event.getKey();
&&&&&&&&&&&&&&&&if&(&gridOpacity&.equals(key))&{
&&&&&&&&&&&&&&&&&&&&mapView.setGridOpacity(display.getInt(&gridOpacity&,&255));
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&else&if&(&gridAntialias&.equals(key))&{
&&&&&&&&&&&&&&&&&&&&mapView.setAntialiasGrid(display.getBoolean(&gridAntialias&,&true));
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&else&if&(&gridColor&.equals(key))&{
&&&&&&&&&&&&&&&&&&&&mapView.setGridColor(new&Color(display.getInt(&gridColor&,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&MapView.DEFAULT_GRID_COLOR.getRGB())));
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&else&if&(&showGrid&.equals(key))&{
&&&&&&&&&&&&&&&&&&&&mapView.setShowGrid(display.getBoolean(&showGrid&,&false));
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}
&&&&&&&&});
&&&&private&JPanel&createContentPane()&{
&&&&&&&&mapScrollPane&=&new&JScrollPane(
&&&&&&&&&&&&&&&&JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
&&&&&&&&&&&&&&&&JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
&&&&&&&&mapScrollPane.setBorder(null);
&&&&&&&&createData();
&&&&&&&&createStatusBar();
&&&&&&&&JSplitPane&mainSplit&=&new&JSplitPane(
&&&&&&&&&&&&&&&&JSplitPane.HORIZONTAL_SPLIT,&false,&mapScrollPane,&dataPanel);
&&&&&&&&mainSplit.setResizeWeight(1.0);
&&&&&&&&mainPanel&=&new&JPanel(new&BorderLayout());
&&&&&&&&mainPanel.add(createToolBar(),&BorderLayout.WEST);
&&&&&&&&mainPanel.add(mainSplit);
&&&&&&&&mainPanel.add(statusBar,&BorderLayout.SOUTH);
&&&&&&&&return&mainP
&&&&&*&Creates&all&the&menus&and&submenus&of&the&top&menu&bar.&Handles
&&&&&*&assigning&listeners&and&tooltips&as&well.
&&&&private&void&createMenuBar()&{
&&&&&&&&JMenuItem&save&=&new&TMenuItem(saveAction);
&&&&&&&&JMenuItem&saveAs&=&new&TMenuItem(saveAsAction);
&&&&&&&&JMenuItem&saveAsImage&=&createMenuItem(Resources.getString(&menu.file.image&),&null,
Resources.getString(&menu.file.image.tooltip&),&&control&shift&I&);
&&&&&&&&JMenuItem&close&=&new&TMenuItem(new&CloseMapAction(this,&saveAction));
&&&&&&&&recentMenu&=&new&JMenu(Resources.getString(&menu.file.recent&));
&&&&&&&&mapEventAdapter.addListener(save);
&&&&&&&&mapEventAdapter.addListener(saveAs);
&&&&&&&&mapEventAdapter.addListener(saveAsImage);
&&&&&&&&mapEventAdapter.addListener(close);
&&&&&&&&JMenu&fileMenu&=&new&JMenu(Resources.getString(&menu.file&));
&&&&&&&&fileMenu.add(new&TMenuItem(new&NewMapAction(this,&saveAction)));
&&&&&&&&fileMenu.add(new&TMenuItem(new&OpenMapAction(this,&saveAction)));
&&&&&&&&fileMenu.add(recentMenu);
&&&&&&&&fileMenu.add(save);
&&&&&&&&fileMenu.add(saveAs);
&&&&&&&&fileMenu.add(saveAsImage);
&&&&&&&&fileMenu.addSeparator();
&&&&&&&&fileMenu.add(close);
&&&&&&&&fileMenu.add(new&TMenuItem(exitAction));
&&&&&&&&JMenuItem&copyMenuItem&=&new&TMenuItem(new&CopyAction());
&&&&&&&&JMenuItem&cutMenuItem&=&new&TMenuItem(new&CutAction());
&&&&&&&&JMenuItem&pasteMenuItem&=&new&TMenuItem(new&PasteAction());
&&&&&&&&copyMenuItem.setEnabled(false);
&&&&&&&&cutMenuItem.setEnabled(false);
&&&&&&&&pasteMenuItem.setEnabled(false);
&&&&&&&&JMenu&transformSub&=&new&JMenu(Resources.getString(&menu.edit.transform&));
&&&&&&&&transformSub.add(new&TMenuItem(rot90Action,&true));
&&&&&&&&transformSub.add(new&TMenuItem(rot180Action,&true));
&&&&&&&&transformSub.add(new&TMenuItem(rot270Action,&true));
&&&&&&&&transformSub.addSeparator();
&&&&&&&&transformSub.add(new&TMenuItem(flipHorAction,&true));
&&&&&&&&transformSub.add(new&TMenuItem(flipVerAction,&true));
&&&&&&&&mapEventAdapter.addListener(transformSub);
&&&&&&&&JMenu&editMenu&=&new&JMenu(Resources.getString(&menu.edit&));
&&&&&&&&editMenu.add(new&TMenuItem(undoHandler.getUndoAction()));
&&&&&&&&editMenu.add(new&TMenuItem(undoHandler.getRedoAction()));
&&&&&&&&editMenu.addSeparator();
&&&&&&&&editMenu.add(copyMenuItem);
&&&&&&&&editMenu.add(cutMenuItem);
&&&&&&&&editMenu.add(pasteMenuItem);
&&&&&&&&editMenu.addSeparator();
&&&&&&&&editMenu.add(transformSub);
&&&&&&&&editMenu.addSeparator();
&&&&&&&&editMenu.add(createMenuItem(Resources.getString(&menu.edit.preferences&),
&&&&&&&&&&&&&&&&&&&&null,&Resources.getString(&menu.edit.preferences.tooltip&),&null));
&&&&&&&&editMenu.add(createMenuItem(Resources.getString(&menu.edit.brush&),&null,
Resources.getString(&menu.edit.brush.tooltip&),
&&&&&&&&&&&&&&&&&&&&&control&B&));
&&&&&&&&//&todo&:&enable/disable&undo/redo&depending&on&whether&a&map&is&loaded
&&&&&&&&mapEventAdapter.addListener(copyMenuItem);
&&&&&&&&mapEventAdapter.addListener(cutMenuItem);
&&&&&&&&mapEventAdapter.addListener(pasteMenuItem);
&&&&&&&&JMenu&mapMenu&=&new&JMenu(Resources.getString(&menu.map&));
&&&&&&&&mapMenu.add(createMenuItem(Resources.getString(&menu.map.resize&),&null,
Resources.getString(&menu.map.resize.tooltip&)));
&&&&&&&&mapMenu.add(createMenuItem(Resources.getString(&menu.map.search&),&null,
Resources.getString(&menu.map.search.tooltip&)));
&&&&&&&&mapMenu.addSeparator();
&&&&&&&&mapMenu.add(createMenuItem(Resources.getString(&menu.map.properties&),&null,
Resources.getString(&menu.map.properties.tooltip&)));
&&&&&&&&mapEventAdapter.addListener(mapMenu);
&&&&&&&&JMenuItem&layerAdd&=&new&TMenuItem(addLayerAction);
&&&&&&&&mapEventAdapter.addListener(layerAdd);
&&&&&&&&JMenu&layerMenu&=&new&JMenu(Resources.getString(&menu.layer&));
&&&&&&&&layerMenu.add(layerAdd);
&&&&&&&&layerMenu.add(new&TMenuItem(cloneLayerAction));
&&&&&&&&layerMenu.add(new&TMenuItem(deleteLayerAction));
&&&&&&&&layerMenu.addSeparator();
&&&&&&&&layerMenu.add(new&TMenuItem(moveLayerUpAction));
&&&&&&&&layerMenu.add(new&TMenuItem(moveLayerDownAction));
&&&&&&&&layerMenu.addSeparator();
&&&&&&&&layerMenu.add(new&TMenuItem(mergeLayerDownAction));
&&&&&&&&layerMenu.add(new&TMenuItem(mergeAllLayersAction));
&&&&&&&&layerMenu.addSeparator();
&&&&&&&&layerMenu.add(createMenuItem(Resources.getString(&menu.layer.properties&),&null,
Resources.getString(&menu.layer.properties.tooltip&)));
&&&&&&&&JMenu&tilesetMenu&=&new&JMenu(Resources.getString(&menu.tilesets&));
&&&&&&&&tilesetMenu.add(createMenuItem(Resources.getString(&menu.tilesets.new&),&null,
Resources.getString(&menu.tilesets.new.tooltip&)));
&&&&&&&&tilesetMenu.add(createMenuItem(Resources.getString(&menu.tilesets.import&),&null,
Resources.getString(&menu.tilesets.import.tooltip&)));
&&&&&&&&tilesetMenu.addSeparator();
&&&&&&&&tilesetMenu.add(createMenuItem(Resources.getString(&menu.tilesets.manager&),&null,
Resources.getString(&menu.tilesets.manager.tooltip&)));
&&&&&&&&/*
&&&&&&&&objectMenu&=&new&JMenu(&Objects&);
&&&&&&&&objectMenu.add(createMenuItem(&Add&Object&,&null,&&Add&an&object&));
&&&&&&&&mapEventAdapter.addListener(objectMenu);
&&&&&&&&JMenu&modifySub&=&new&JMenu(&Modify&);
&&&&&&&&modifySub.add(createMenuItem(&Expand&Selection&,&null,&&&));
&&&&&&&&modifySub.add(createMenuItem(&Contract&Selection&,&null,&&&));
&&&&&&&&*/
&&&&&&&&JMenu&selectMenu&=&new&JMenu(Resources.getString(&menu.select&));
&&&&&&&&selectMenu.add(new&TMenuItem(selectAllAction,&true));
&&&&&&&&selectMenu.add(new&TMenuItem(cancelSelectionAction,&true));
&&&&&&&&selectMenu.add(new&TMenuItem(inverseAction,&true));
&&&&&&&&//selectMenu.addSeparator();
&&&&&&&&//selectMenu.add(modifySub);
&&&&&&&&gridMenuItem&=&new&JCheckBoxMenuItem(Resources.getString(&menu.view.grid&));
&&&&&&&&gridMenuItem.addActionListener(this);
&&&&&&&&gridMenuItem.setToolTipText(Resources.getString(&menu.view.grid.tooltip&));
&&&&&&&&gridMenuItem.setAccelerator(KeyStroke.getKeyStroke(&control&G&));
&&&&&&&&cursorMenuItem&=&new&JCheckBoxMenuItem(Resources.getString(&menu.view.cursor&));
&&&&&&&&cursorMenuItem.setSelected(prefs.getBoolean(&cursorhighlight&,&true));
&&&&&&&&cursorMenuItem.addActionListener(this);
&&&&&&&&cursorMenuItem.setToolTipText(
Resources.getString(&menu.view.cursor.tooltip&));
&&&&&&&&boundaryMenuItem&=&new&JCheckBoxMenuItem(Resources.getString(&menu.view.boundaries&));
&&&&&&&&boundaryMenuItem.addActionListener(this);
&&&&&&&&boundaryMenuItem.setToolTipText(Resources.getString(&menu.view.boundaries.tooltip&));
&&&&&&&&boundaryMenuItem.setAccelerator(KeyStroke.getKeyStroke(&control&E&));
&&&&&&&&coordinatesMenuItem&=&new&JCheckBoxMenuItem(Resources.getString(&menu.view.coordinates&));
&&&&&&&&coordinatesMenuItem.addActionListener(this);
&&&&&&&&coordinatesMenuItem.setToolTipText(Resources.getString(&menu.view.coordinates.tooltip&));
&&&&&&&&JMenu&viewMenu&=&new&JMenu(Resources.getString(&menu.view&));
&&&&&&&&viewMenu.add(new&TMenuItem(zoomInAction));
&&&&&&&&viewMenu.add(new&TMenuItem(zoomOutAction));
&&&&&&&&viewMenu.add(new&TMenuItem(zoomNormalAction));
&&&&&&&&viewMenu.addSeparator();
&&&&&&&&viewMenu.add(gridMenuItem);
&&&&&&&&viewMenu.add(cursorMenuItem);
&&&&&&&&//TODO:&Enable&when&boudary&drawing&code&finished.
&&&&&&&&//viewMenu.add(boundaryMenuItem);
&&&&&&&&viewMenu.add(coordinatesMenuItem);
&&&&&&&&mapEventAdapter.addListener(layerMenu);
&&&&&&&&mapEventAdapter.addListener(tilesetMenu);
&&&&&&&&mapEventAdapter.addListener(selectMenu);
&&&&&&&&mapEventAdapter.addListener(viewMenu);
&&&&&&&&JMenu&helpMenu&=&new&JMenu(Resources.getString(&menu.help&));
&&&&&&&&helpMenu.add(createMenuItem(Resources.getString(&menu.help.plugins&),&null,
Resources.getString(&menu.help.plugins.tooltip&)));
&&&&&&&&helpMenu.add(createMenuItem(Resources.getString(&menu.help.about&),&null,&Resources.getString(&menu.help.about.tooltip&)));
&&&&&&&&menuBar&=&new&JMenuBar();
&&&&&&&&menuBar.add(fileMenu);
&&&&&&&&menuBar.add(editMenu);
&&&&&&&&menuBar.add(selectMenu);
&&&&&&&&menuBar.add(viewMenu);
&&&&&&&&menuBar.add(mapMenu);
&&&&&&&&menuBar.add(layerMenu);
&&&&&&&&menuBar.add(tilesetMenu);
&&&&&&&&//menuBar.add(objectMenu);
&&&&&&&&menuBar.add(helpMenu);
&&&&&*&Creates&the&tool&bar.
&&&&private&JToolBar&createToolBar()&{
&&&&&&&&Icon&iconMove&=&Resources.getIcon(&gimp-tool-move-22.png&);
&&&&&&&&Icon&iconPaint&=&Resources.getIcon(&gimp-tool-pencil-22.png&);
&&&&&&&&Icon&iconErase&=&Resources.getIcon(&gimp-tool-eraser-22.png&);
&&&&&&&&Icon&iconPour&=&Resources.getIcon(&gimp-tool-bucket-fill-22.png&);
&&&&&&&&Icon&iconEyed&=&Resources.getIcon(&gimp-tool-color-picker-22.png&);
&&&&&&&&Icon&iconMarquee&=&Resources.getIcon(&gimp-tool-rect-select-22.png&);
&&&&&&&&Icon&iconMoveObject&=&Resources.getIcon(&gimp-tool-object-move-22.png&);
&&&&&&&&paintButton&=&createToggleButton(iconPaint,&&paint&,&TOOL_PAINT);
&&&&&&&&eraseButton&=&createToggleButton(iconErase,&&erase&,&TOOL_ERASE);
&&&&&&&&pourButton&=&createToggleButton(iconPour,&&pour&,&TOOL_FILL);
&&&&&&&&eyedButton&=&createToggleButton(iconEyed,&&eyed&,&TOOL_EYE_DROPPER);
&&&&&&&&marqueeButton&=&createToggleButton(iconMarquee,&&marquee&,&TOOL_SELECT);
&&&&&&&&moveButton&=&createToggleButton(iconMove,&&move&,&TOOL_MOVE_LAYER);
&&&&&&&&objectMoveButton&=&createToggleButton(iconMoveObject,&&moveobject&,&TOOL_MOVE_OBJECT);
&&&&&&&&mapEventAdapter.addListener(moveButton);
&&&&&&&&mapEventAdapter.addListener(paintButton);
&&&&&&&&mapEventAdapter.addListener(eraseButton);
&&&&&&&&mapEventAdapter.addListener(pourButton);
&&&&&&&&mapEventAdapter.addListener(eyedButton);
&&&&&&&&mapEventAdapter.addListener(marqueeButton);
&&&&&&&&mapEventAdapter.addListener(objectMoveButton);
&&&&&&&&JToolBar&toolBar&=&new&JToolBar(JToolBar.VERTICAL);
&&&&&&&&toolBar.setFloatable(true);
&&&&&&&&toolBar.add(moveButton);
&&&&&&&&toolBar.add(paintButton);
&&&&&&&&toolBar.add(eraseButton);
&&&&&&&&toolBar.add(pourButton);
&&&&&&&&toolBar.add(eyedButton);
&&&&&&&&toolBar.add(marqueeButton);
&&&&&&&&toolBar.add(Box.createRigidArea(new&Dimension(5,&5)));
&&&&&&&&//TODO:&put&this&back&when&working...
&&&&&&&&//toolBar.add(objectMoveButton);
&&&&&&&&//toolBar.add(Box.createRigidArea(new&Dimension(0,&5)));
&&&&&&&&toolBar.add(new&TButton(zoomInAction));
&&&&&&&&toolBar.add(new&TButton(zoomOutAction));
&&&&&&&&toolBar.add(Box.createRigidArea(new&Dimension(5,&5)));
&&&&&&&&toolBar.add(Box.createGlue());
&&&&&&&&tilePaletteButton&=&new&TileButton();
&&&&&&&&tilePaletteButton.setActionCommand(&palette&);
&&&&&&&&mapEventAdapter.addListener(tilePaletteButton);
&&&&&&&&tilePaletteButton.addActionListener(this);
&&&&&&&&toolBar.add(tilePaletteButton);
&&&&&&&&return&toolB
&&&&private&void&createData()&{
&&&&&&&&dataPanel&=&new&JPanel(new&BorderLayout());
&&&&&&&&//navigation&and&tool&options
&&&&&&&&//&TODO:&the&minimap&is&prohibitively&slow,&need&to&speed&this&up
&&&&&&&&//&before&it&can&be&used
&&&&&&&&miniMap&=&new&MiniMapViewer();
&&&&&&&&//miniMap.setMainPanel(mapScrollPane);
&&&&&&&&JScrollPane&miniMapSp&=&new&JScrollPane();
&&&&&&&&miniMapSp.getViewport().setView(miniMap);
&&&&&&&&miniMapSp.setMinimumSize(new&Dimension(0,&120));
&&&&&&&&//&Layer&table
&&&&&&&&layerTable&=&new&JTable(new&LayerTableModel(currentMap));
&&&&&&&&layerTable.getColumnModel().getColumn(0).setPreferredWidth(32);
&&&&&&&&layerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
&&&&&&&&layerTable.getSelectionModel().addListSelectionListener(this);
&&&&&&&&//&Opacity&slider
&&&&&&&&opacitySlider&=&new&JSlider(0,&100,&100);
&&&&&&&&opacitySlider.addChangeListener(this);
&&&&&&&&JLabel&opacityLabel&=&new&JLabel(
&&&&&&&&&&&&&&&&Resources.getString(&dialog.main.opacity.label&));
&&&&&&&&opacityLabel.setLabelFor(opacitySlider);
&&&&&&&&JPanel&sliderPanel&=&new&JPanel();
&&&&&&&&sliderPanel.setLayout(new&BoxLayout(sliderPanel,&BoxLayout.X_AXIS));
&&&&&&&&sliderPanel.setBorder(BorderFactory.createEmptyBorder(0,&3,&0,&3));
&&&&&&&&sliderPanel.add(opacityLabel);
&&&&&&&&sliderPanel.add(opacitySlider);
&&&&&&&&sliderPanel.setMaximumSize(new&Dimension(Integer.MAX_VALUE,
&&&&&&&&&&&&&&&&&&&&sliderPanel.getPreferredSize().height));
&&&&&&&&//&Layer&buttons
&&&&&&&&AbstractButton&layerAddButton&=&new&TButton(addLayerAction);
&&&&&&&&mapEventAdapter.addListener(layerAddButton);
&&&&&&&&JPanel&layerButtons&=&new&JPanel();
&&&&&&&&layerButtons.setLayout(new&GridBagLayout());
&&&&&&&&GridBagConstraints&c&=&new&GridBagConstraints();
&&&&&&&&c.fill&=&GridBagConstraints.BOTH;
&&&&&&&&c.weightx&=&1;
&&&&&&&&layerButtons.add(layerAddButton,&c);
&&&&&&&&layerButtons.add(new&TButton(moveLayerUpAction),&c);
&&&&&&&&layerButtons.add(new&TButton(moveLayerDownAction),&c);
&&&&&&&&layerButtons.add(new&TButton(cloneLayerAction),&c);
&&&&&&&&layerButtons.add(new&TButton(deleteLayerAction),&c);
&&&&&&&&layerButtons.setMaximumSize(new&Dimension(Integer.MAX_VALUE,
&&&&&&&&&&&&&&&&&&&&layerButtons.getPreferredSize().height));
&&&&&&&&//&Edit&history
&&&&&&&&/*
&&&&&&&&JScrollPane&editSp&=&new&JScrollPane();
&&&&&&&&editHistoryList&=&new&JList();
&&&&&&&&editSp.setHorizontalScrollBarPolicy(
&&&&&&&&&&&&&&&&JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
&&&&&&&&editSp.getViewport().setView(editHistoryList);
&&&&&&&&*/
&&&&&&&&JPanel&layerPanel&=&new&JPanel();
&&&&&&&&layerPanel.setLayout(new&GridBagLayout());
&&&&&&&&layerPanel.setPreferredSize(new&Dimension(120,&120));
&&&&&&&&c&=&new&GridBagConstraints();
&&&&&&&&c.insets&=&new&Insets(3,&0,&0,&0);&c.weightx&=&1;&c.weighty&=&0;
&&&&&&&&c.fill&=&GridBagConstraints.BOTH;
&&&&&&&&c.gridx&=&0;&c.gridy&=&0;
&&&&&&&&//layerPanel.add(miniMapSp,&c);
&&&&&&&&c.weighty&=&0;&c.gridy&+=&1;
&&&&&&&&layerPanel.add(sliderPanel,&c);
&&&&&&&&c.weighty&=&1;&c.gridy&+=&1;
&&&&&&&&layerPanel.add(new&JScrollPane(layerTable),&c);
&&&&&&&&c.weighty&=&0;&c.insets&=&new&Insets(0,&0,&0,&0);&c.gridy&+=&1;
&&&&&&&&layerPanel.add(layerButtons,&c);
&&&&&&&&/*
&&&&&&&&c.weighty&=&0.25;&c.insets&=&new&Insets(3,&0,&0,&0);&c.gridy&+=&1;
&&&&&&&&layerPanel.add(editSp,&c);
&&&&&&&&*/
&&&&&&&&//&Create&paint&panel
&&&&&&&&TilePalettePanel&tilePalettePanel&=&new&TilePalettePanel();
&&&&&&&&JPanel&brushesPanel&=&new&JPanel();
&&&&&&&&JTabbedPane&paintPanel&=&new&JTabbedPane();
&&&&&&&&paintPanel.add(&Palette&,&tilePalettePanel);
&&&&&&&&paintPanel.add(&Brushes&,&brushesPanel);
&&&&&&&&paintPanel.setSelectedIndex(1);
&&&&&&&&JToolBar&tabsPanel&=&new&JToolBar();
&&&&&&&&tabsPanel.add(paintPanel);
&&&&&&&&dataPanel.add(layerPanel);
&&&&private&void&createStatusBar()&{
&&&&&&&&statusBar&=&new&JPanel();
&&&&&&&&statusBar.setLayout(new&BoxLayout(statusBar,&BoxLayout.X_AXIS));
&&&&&&&&zoomLabel&=&new&JLabel(&100%&);
&&&&&&&&zoomLabel.setPreferredSize(zoomLabel.getPreferredSize());
&&&&&&&&tileCoordsLabel&=&new&JLabel(&&&,&SwingConstants.CENTER);
&&&&&&&&statusBar.setBorder(BorderFactory.createEmptyBorder(2,&5,&2,&5));
&&&&&&&&JPanel&largePart&=&new&JPanel();
&&&&&&&&statusBar.add(largePart);
&&&&&&&&statusBar.add(tileCoordsLabel);
&&&&&&&&statusBar.add(Box.createRigidArea(new&Dimension(20,&0)));
&&&&&&&&statusBar.add(zoomLabel);
&&&&private&void&updateLayerTable()&{
&&&&&&&&int&cl&=&currentL
&&&&&&&&if&(layerTable.isEditing())&{
&&&&&&&&&&&&layerTable.getCellEditor(layerTable.getEditingRow(),
&&&&&&&&&&&&&&&&&&&&layerTable.getEditingColumn()).cancelCellEditing();
&&&&&&&&((LayerTableModel)layerTable.getModel()).setMap(currentMap);
&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&if&(currentMap.getTotalLayers()&&&0&&&&cl&==&-1)&{
&&&&&&&&&&&&&&&&cl&=&0;
&&&&&&&&&&&&}
&&&&&&&&&&&&setCurrentLayer(cl);
&&&&&&&&updateLayerOperations();
&&&&private&void&updateLayerOperations()&{
&&&&&&&&int&nrLayers&=&0;
&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&nrLayers&=&currentMap.getTotalLayers();
&&&&&&&&boolean&validSelection&=&currentLayer&&=&0;
&&&&&&&&boolean&notBottom&=&currentLayer&&&0;
&&&&&&&&boolean&notTop&=&currentLayer&&&nrLayers&-&1&&&&validS
&&&&&&&&cloneLayerAction.setEnabled(validSelection);
&&&&&&&&deleteLayerAction.setEnabled(validSelection);
&&&&&&&&moveLayerUpAction.setEnabled(notTop);
&&&&&&&&moveLayerDownAction.setEnabled(notBottom);
&&&&&&&&mergeLayerDownAction.setEnabled(notBottom);
&&&&&&&&mergeAllLayersAction.setEnabled(nrLayers&&&1);
&&&&&&&&opacitySlider.setEnabled(validSelection);
&&&&private&JMenuItem&createMenuItem(String&name,&Icon&icon,&String&tt)&{
&&&&&&&&JMenuItem&menuItem&=&new&JMenuItem(name);
&&&&&&&&menuItem.addActionListener(this);
&&&&&&&&if&(icon&!=&null)&{
&&&&&&&&&&&&menuItem.setIcon(icon);
&&&&&&&&if&(tt&!=&null)&{
&&&&&&&&&&&&menuItem.setToolTipText(tt);
&&&&&&&&return&menuI
&&&&private&JMenuItem&createMenuItem(String&name,&Icon&icon,&String&tt,
&&&&&&&&&&&&String&keyStroke)&{
&&&&&&&&JMenuItem&menuItem&=&createMenuItem(name,&icon,&tt);
&&&&&&&&menuItem.setAccelerator(KeyStroke.getKeyStroke(keyStroke));
&&&&&&&&return&menuI
&&&&private&AbstractButton&createToggleButton(Icon&icon,&String&command,
&&&&&&&&&&&&String&tt)&{
&&&&&&&&AbstractButton&
&&&&&&&&button&=&new&JToggleButton(&&,&icon);
&&&&&&&&button.setMargin(new&Insets(0,&0,&0,&0));
&&&&&&&&button.setActionCommand(command);
&&&&&&&&button.addActionListener(this);
&&&&&&&&if&(tt&!=&null)&{
&&&&&&&&&&&&button.setToolTipText(tt);
&&&&&&&&return&
&&&&&*&Returns&the&currently&selected&tile.
&&&&&*&@return&the&currently&selected&tile
&&&&public&Tile&getCurrentTile()&{
&&&&&&&&return&currentT
&&&&&*&Returns&the&current&map.
&&&&&*&@return&the&currently&selected&map
&&&&&*&@see&#setCurrentMap(Map)
&&&&public&Map&getCurrentMap()&{
&&&&&&&&return&currentM
&&&&&*&Returns&the&currently&selected&layer.
&&&&&*&@return&the&currently&selected&layer
&&&&public&MapLayer&getCurrentLayer()&{
&&&&&&&&return&currentMap.getLayer(currentLayer);
&&&&&*&Returns&the&currently&selected&layer&index.
&&&&&*&@return&the&currently&selected&layer&index
&&&&public&int&getCurrentLayerIndex()&{
&&&&&&&&return&currentL
&&&&&*&Returns&the&{@link&UndoableEditSupport}&instance.
&&&&&*&@return&the&undo&support
&&&&public&UndoableEditSupport&getUndoSupport()&{
&&&&&&&&return&undoS
&&&&&*&Returns&the&{@link&UndoHandler}&instance.
&&&&&*&@return&the&undo&stack
&&&&public&UndoHandler&getUndoHandler()&{
&&&&&&&&return&undoH
&&&&&*&Returns&the&{@link&PluginClassLoader}&instance.
&&&&&*&@return&the&plugin&class&loader
&&&&public&PluginClassLoader&getPluginLoader()&{
&&&&&&&&return&pluginL
&&&&&*&Returns&the&main&application&frame.
&&&&&*&@return&the&frame&of&the&main&application
&&&&public&Frame&getAppFrame()&{
&&&&&&&&return&appF
&&&&private&void&doMouse(MouseEvent&event)&{
&&&&&&&&if&(currentMap&==&null&||&currentLayer&&&0)&{
&&&&&&&&&&&&
&&&&&&&&Point&tile&=&mapView.screenToTileCoords(event.getX(),&event.getY());
&&&&&&&&MapLayer&layer&=&getCurrentLayer();
&&&&&&&&if&(layer&==&null)&{
&&&&&&&&&&&&
&&&&&&&&}&else&if&(mouseButton&==&MouseEvent.BUTTON3)&{
&&&&&&&&&&&&if&(layer&instanceof&TileLayer)&{
&&&&&&&&&&&&&&&&if&(!bMouseIsDragging)&{
&&&&&&&&&&&&&&&&&&&&Tile&newTile&=&((TileLayer)layer).getTileAt(tile.x,&tile.y);
&&&&&&&&&&&&&&&&&&&&setCurrentTile(newTile);
&&&&&&&&&&&&&&&&}&else&if&(currentPointerState&==&PS_PAINT)&{
&&&&&&&&&&&&&&&&&&&&//in&case&we&are&dragging&to&create&a&custom&brush,&let&the&user
&&&&&&&&&&&&&&&&&&&&//know&where&we&are&creating&it&from
&&&&&&&&&&&&&&&&&&&&if&(marqueeSelection&==&null)&{
&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection&=&new&SelectionLayer(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&currentMap.getWidth(),&currentMap.getHeight());
&&&&&&&&&&&&&&&&&&&&&&&&currentMap.addLayerSpecial(marqueeSelection);
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&Point&limp&=&mouseInitialPressL
&&&&&&&&&&&&&&&&&&&&Rectangle&oldArea&=
&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedAreaBounds();
&&&&&&&&&&&&&&&&&&&&int&minx&=&Math.min(limp.x,&tile.x);
&&&&&&&&&&&&&&&&&&&&int&miny&=&Math.min(limp.y,&tile.y);
&&&&&&&&&&&&&&&&&&&&Rectangle&selRect&=&new&Rectangle(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&minx,&miny,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&(Math.max(limp.x,&tile.x)&-&minx)+1,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&(Math.max(limp.y,&tile.y)&-&miny)+1);
&&&&&&&&&&&&&&&&&&&&marqueeSelection.selectRegion(selRect);
&&&&&&&&&&&&&&&&&&&&if&(oldArea&!=&null)&{
&&&&&&&&&&&&&&&&&&&&&&&&oldArea.add(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedAreaBounds());
&&&&&&&&&&&&&&&&&&&&&&&&mapView.repaintRegion(oldArea);
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}&else&if&(layer&instanceof&ObjectGroup&&&&!bMouseIsDragging)&{
&&&&&&&&&&&&&&&&//&TODO:&Add&support&for&ObjectGroups&here
&&&&&&&&&&&&}
&&&&&&&&}&else&if&(mouseButton&==&MouseEvent.BUTTON1)&{
&&&&&&&&&&&&switch&(currentPointerState)&{
&&&&&&&&&&&&&&&&case&PS_PAINT:
&&&&&&&&&&&&&&&&&&&&paintEdit.setPresentationName(TOOL_PAINT);
&&&&&&&&&&&&&&&&&&&&if&(layer&instanceof&TileLayer)&{
&&&&&&&&&&&&&&&&&&&&&&&&try&{
&&&&&&&&&&&&&&&&&&&&&&&&&&&&mapView.repaintRegion(currentBrush.doPaint(tile.x,&tile.y));
&&&&&&&&&&&&&&&&&&&&&&&&}&catch&(Exception&e)&{
&&&&&&&&&&&&&&&&&&&&&&&&&&&&e.printStackTrace();
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&case&PS_ERASE:
&&&&&&&&&&&&&&&&&&&&paintEdit.setPresentationName(TOOL_ERASE);
&&&&&&&&&&&&&&&&&&&&if&(layer&instanceof&TileLayer)&{
&&&&&&&&&&&&&&&&&&&&&&&&((TileLayer)&layer).setTileAt(tile.x,&tile.y,&null);
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&mapView.repaintRegion(new&Rectangle(tile.x,&tile.y,&1,&1));
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&case&PS_POUR:&&//&POUR&only&works&on&TileLayers
&&&&&&&&&&&&&&&&&&&&paintEdit&=&
&&&&&&&&&&&&&&&&&&&&if&(layer&instanceof&TileLayer)&{
&&&&&&&&&&&&&&&&&&&&&&&&Tile&oldTile&=&((TileLayer)layer).getTileAt(tile.x,&tile.y);
&&&&&&&&&&&&&&&&&&&&&&&&pour((TileLayer)&layer,&tile.x,&tile.y,&currentTile,&oldTile);
&&&&&&&&&&&&&&&&&&&&&&&&mapView.repaint();
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&case&PS_EYED:
&&&&&&&&&&&&&&&&&&&&if&(layer&instanceof&TileLayer)&{
&&&&&&&&&&&&&&&&&&&&&&&&Tile&newTile&=&((TileLayer)layer).getTileAt(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&tile.x,&tile.y);
&&&&&&&&&&&&&&&&&&&&&&&&setCurrentTile(newTile);
&&&&&&&&&&&&&&&&&&&&}&else&if&(layer&instanceof&ObjectGroup)&{
&&&&&&&&&&&&&&&&&&&&&&&&//&TODO:&Add&support&for&ObjectGroups&here
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&case&PS_MOVE:
&&&&&&&&&&&&&&&&&&&&Point&translation&=&new&Point(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&tile.x&-&mousePressLocation.x,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&tile.y&-&mousePressLocation.y);
&&&&&&&&&&&&&&&&&&&&layer.translate(translation.x,&translation.y);
&&&&&&&&&&&&&&&&&&&&moveDist.translate(translation.x,&translation.y);
&&&&&&&&&&&&&&&&&&&&mapView.repaint();
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&case&PS_MARQUEE:
&&&&&&&&&&&&&&&&&&&&if&(marqueeSelection&!=&null)&{
&&&&&&&&&&&&&&&&&&&&&&&&Point&limp&=&mouseInitialPressL
&&&&&&&&&&&&&&&&&&&&&&&&Rectangle&oldArea&=
&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedAreaBounds();
&&&&&&&&&&&&&&&&&&&&&&&&int&minx&=&Math.min(limp.x,&tile.x);
&&&&&&&&&&&&&&&&&&&&&&&&int&miny&=&Math.min(limp.y,&tile.y);
&&&&&&&&&&&&&&&&&&&&&&&&Rectangle&selRect&=&new&Rectangle(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&minx,&miny,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&(Math.max(limp.x,&tile.x)&-&minx)+1,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&(Math.max(limp.y,&tile.y)&-&miny)+1);
&&&&&&&&&&&&&&&&&&&&&&&&if&(event.isShiftDown())&{
&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.add(new&Area(selRect));
&&&&&&&&&&&&&&&&&&&&&&&&}&else&if&(event.isControlDown())&{
&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.subtract(new&Area(selRect));
&&&&&&&&&&&&&&&&&&&&&&&&}&else&{
&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.selectRegion(selRect);
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&&&&&if&(oldArea&!=&null)&{
&&&&&&&&&&&&&&&&&&&&&&&&&&&&oldArea.add(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedAreaBounds());
&&&&&&&&&&&&&&&&&&&&&&&&&&&&mapView.repaintRegion(oldArea);
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&}
&&&&public&void&mouseExited(MouseEvent&e)&{
&&&&&&&&tileCoordsLabel.setText(&&&);
&&&&public&void&mouseClicked(MouseEvent&e)&{
&&&&public&void&mouseEntered(MouseEvent&e)&{
&&&&public&void&mousePressed(MouseEvent&e)&{
&&&&&&&&Point&tile&=&mapView.screenToTileCoords(e.getX(),&e.getY());
&&&&&&&&mouseButton&=&e.getButton();
&&&&&&&&bMouseIsDown&=&
&&&&&&&&bMouseIsDragging&=&
&&&&&&&&mousePressLocation&=&mapView.screenToTileCoords(e.getX(),&e.getY());
&&&&&&&&mouseInitialPressLocation&=&mousePressL
&&&&&&&&if&(mouseButton&==&MouseEvent.BUTTON1)&{
&&&&&&&&&&&&switch&(currentPointerState)&{
&&&&&&&&&&&&&&&&case&PS_PAINT:
&&&&&&&&&&&&&&&&&&&&currentBrush.startPaint(currentMap,&tile.x,&tile.y,&mouseButton,&currentLayer);
&&&&&&&&&&&&&&&&case&PS_ERASE:
&&&&&&&&&&&&&&&&case&PS_POUR:
&&&&&&&&&&&&&&&&&&&&MapLayer&layer&=&getCurrentLayer();
&&&&&&&&&&&&&&&&&&&&paintEdit&=
&&&&&&&&&&&&&&&&&&&&&&&&new&MapLayerEdit(layer,&createLayerCopy(layer),&null);
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&default:
&&&&&&&&&&&&}
&&&&&&&&if&(currentPointerState&==&PS_MARQUEE)&{
&&&&&&&&&&&&if&(marqueeSelection&==&null)&{
&&&&&&&&&&&&&&&&marqueeSelection&=&new&SelectionLayer(
&&&&&&&&&&&&&&&&&&&&&&&&currentMap.getWidth(),&currentMap.getHeight());
&&&&&&&&&&&&&&&&currentMap.addLayerSpecial(marqueeSelection);
&&&&&&&&&&&&}
&&&&&&&&}&else&if&(currentPointerState&==&PS_MOVE)&{
&&&&&&&&&&&&//&Initialize&move&distance&to&(0,&0)
&&&&&&&&&&&&moveDist&=&new&Point(0,&0);
&&&&&&&&doMouse(e);
&&&&public&void&mouseReleased(MouseEvent&event)&{
&&&&&&&&MapLayer&layer&=&getCurrentLayer();
&&&&&&&&Point&limp&=&mouseInitialPressL
&&&&&&&if&(currentPointerState&==&PS_MARQUEE)&{
&&&&&&&&&&&Point&tile&=&mapView.screenToTileCoords(event.getX(),&event.getY());
&&&&&&&&&&&if&(tile.y&-&limp.y&==&0&&&&tile.x&-&limp.x&==&0)&{
&&&&&&&&&&&&&&&if&(marqueeSelection&!=&null)&{
&&&&&&&&&&&&&&&&&&&currentMap.removeLayerSpecial(marqueeSelection);
&&&&&&&&&&&&&&&&&&&marqueeSelection&=&
&&&&&&&&&&&&&&&}
&&&&&&&&&&&}
&&&&&&&&}&else&if&(currentPointerState&==&PS_MOVE)&{
&&&&&&&&&&&&if&(layer&!=&null&&&&moveDist.x&!=&0&||&moveDist.x&!=&0)&{
&&&&&&&&&&&&&&&&undoSupport.postEdit(new&MoveLayerEdit(layer,&moveDist));
&&&&&&&&&&&&}
&&&&&&&&}&else&if&(currentPointerState&==&PS_PAINT)&{
&&&&&&&&&&&&currentBrush.endPaint();
&&&&&&&//STAMP
&&&&&&&if&(bMouseIsDragging&&&&mouseButton&==&MouseEvent.BUTTON3&&&
&&&&&&&&&&&&&&&getCurrentLayer()&instanceof&TileLayer&&&
&&&&&&&&&&&&&&&currentPointerState&==&PS_PAINT)
&&&&&&&&&&&Point&tile&=&mapView.screenToTileCoords(event.getX(),&event.getY());
&&&&&&&&&&&int&minx&=&Math.min(limp.x,&tile.x);
&&&&&&&&&&&int&miny&=&Math.min(limp.y,&tile.y);
&&&&&&&&&&&Rectangle&bounds&=&new&Rectangle(
&&&&&&&&&&&&&&&&&&&minx,&miny,
&&&&&&&&&&&&&&&&&&&(Math.max(limp.x,&tile.x)&-&minx)+1,
&&&&&&&&&&&&&&&&&&&(Math.max(limp.y,&tile.y)&-&miny)+1);
&&&&&&&&&&&//&Right&mouse&button&dragged:&create&and&set&custom&brush
&&&&&&&&&&&MultilayerPlane&mlp&=
&&&&&&&&&&&&&&&new&MultilayerPlane(bounds.width,&bounds.height);
&&&&&&&&&&&TileLayer&brushLayer&=&new&TileLayer(bounds);
&&&&&&&&&&&brushLayer.copyFrom(getCurrentLayer());
&&&&&&&&&&&//do&a&quick&check&to&make&sure&the&selection&is&not&empty
&&&&&&&&&&&if(brushLayer.isEmpty())&{
&&&&&&&& &&&JOptionPane.showMessageDialog(appFrame,
&&&Resources.getString(&dialog.selection.empty&),
&&&Resources.getString(&dialog.selection.empty&),
&&&&&&&&&&&&&&&&&&&&&&&JOptionPane.WARNING_MESSAGE);
&&&&&&&&&&&}&else&{
&&&&&&&& &&&mlp.addLayer(brushLayer);
&&&&&&&& &&&setBrush(new&CustomBrush(mlp));
&&&&&&&&&&&}
&&&&&&&&&&&//get&rid&of&any&visible&marquee
&&&&&&&&&&&if&(marqueeSelection&!=&null)&{
&&&&&&&&&&&&&&&currentMap.removeLayerSpecial(marqueeSelection);
&&&&&&&&&&&&&&&marqueeSelection&=&
&&&&&&&&&&&}
&&&&&&&&if&(paintEdit&!=&null)&{
&&&&&&&&&&&&if&(layer&!=&null)&{
&&&&&&&&&&&&&&&&try&{
&&&&&&&&&&&&&&&&&&&&MapLayer&endLayer&=&paintEdit.getStart().createDiff(layer);
&&&&&&&&&&&&&&&&&&&&paintEdit.end(endLayer);
&&&&&&&&&&&&&&&&&&&&undoSupport.postEdit(paintEdit);
&&&&&&&&&&&&&&&&}&catch&(Exception&e)&{
&&&&&&&&&&&&&&&&&&&&e.printStackTrace();
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}
&&&&&&&&&&&&paintEdit&=&
&&&&&&&&mouseButton&=&MouseEvent.NOBUTTON;
&&&&&&&&bMouseIsDown&=&
&&&&&&&&bMouseIsDragging&=&
&&&&public&void&mouseMoved(MouseEvent&e)&{
&&&&&&&&if&(bMouseIsDown)&{
&&&&&&&&&&&&doMouse(e);
&&&&&&&&Point&tile&=&mapView.screenToTileCoords(e.getX(),&e.getY());
&&&&&&&&if&(currentMap.inBounds(tile.x,&tile.y))&{
&&&&&&&&&&&&tileCoordsLabel.setText(String.valueOf(tile.x)&+&&,&&&+&tile.y);
&&&&&&&&}&else&{
&&&&&&&&&&&&tileCoordsLabel.setText(&&&);
&&&&&&&&updateCursorHighlight(tile);
&&&&public&void&mouseDragged(MouseEvent&e)&{
&&&&&&&&bMouseIsDragging&=&
&&&&&&&&doMouse(e);
&&&&&&&&mousePressLocation&=&mapView.screenToTileCoords(e.getX(),&e.getY());
&&&&&&&&Point&tile&=&mapView.screenToTileCoords(e.getX(),&e.getY());
&&&&&&&&if&(currentMap.inBounds(tile.x,&tile.y))&{
&&&&&&&&&&&&tileCoordsLabel.setText(String.valueOf(tile.x)&+&&,&&&+&tile.y);
&&&&&&&&}&else&{
&&&&&&&&&&&&tileCoordsLabel.setText(&&&);
&&&&&&&&updateCursorHighlight(tile);
&&&&private&void&updateCursorHighlight(Point&tile)&{
&&&&&&&&if&(prefs.getBoolean(&cursorhighlight&,&true))&{
&&&&&&&&&&&&Rectangle&redraw&=&cursorHighlight.getBounds();
&&&&&&&&&&&&Rectangle&brushRedraw&=&currentBrush.getBounds();
&&&&&&&&&&&&brushRedraw.x&=&tile.x&-&brushRedraw.width&/&2;
&&&&&&&&&&&&brushRedraw.y&=&tile.y&-&brushRedraw.height&/&2;
&&&&&&&&&&&&if&(!redraw.equals(brushRedraw))&{
&&&&&&&&&&&& mapView.repaintRegion(redraw);
&&&&&&&&&&&& cursorHighlight.setOffset(brushRedraw.x,&brushRedraw.y);
&&&&&&&&&&&&&&&&//cursorHighlight.selectRegion(currentBrush.getShape());
&&&&&&&&&&&& mapView.repaintRegion(brushRedraw);
&&&&&&&&&&&& /*if(currentBrush&instanceof&CustomBrush)&{
&&&&&&&&&&&&
mapView.paintSubMap(currentBrush,&null,&0.5f);
&&&&&&&&&&&& }*/
&&&&&&&&&&&&}
&&&&public&void&actionPerformed(ActionEvent&event)&{
&&&&&&&&String&command&=&event.getActionCommand();
&&&&&&&&if&(command.equals(&paint&))&{
&&&&&&&&&&&&setCurrentPointerState(PS_PAINT);
&&&&&&&&&&&&resetBrush();
&&&&&&&&}&else&if&(command.equals(&erase&))&{
&&&&&&&&&&&&setCurrentPointerState(PS_ERASE);
&&&&&&&&&&&&resetBrush();
&&&&&&&&}&else&if&(command.equals(&point&))&{
&&&&&&&&&&&&setCurrentPointerState(PS_POINT);
&&&&&&&&&&&&resetBrush();
&&&&&&&&}&else&if&(command.equals(&pour&))&{
&&&&&&&&&&&&setCurrentPointerState(PS_POUR);
&&&&&&&&&&&&resetBrush();
&&&&&&&&}&else&if&(command.equals(&eyed&))&{
&&&&&&&&&&&&setCurrentPointerState(PS_EYED);
&&&&&&&&&&&&resetBrush();
&&&&&&&&}&else&if&(command.equals(&marquee&))&{
&&&&&&&&&&&&setCurrentPointerState(PS_MARQUEE);
&&&&&&&&&&&&resetBrush();
&&&&&&&&}&else&if&(command.equals(&move&))&{
&&&&&&&&&&&&setCurrentPointerState(PS_MOVE);
&&&&&&&&&&&&resetBrush();
&&&&&&&&}&else&if&(command.equals(&moveobject&))&{
&&&&&&&&&&&&setCurrentPointerState(PS_MOVEOBJ);
&&&&&&&&&&&&resetBrush();
&&&&&&&&}&else&if&(command.equals(&palette&))&{
&&&&&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&&&&&if&(tilePaletteDialog&==&null)&{
&&&&&&&&&&&&&&&&&&&&tilePaletteDialog&=
&&&&&&&&&&&&&&&&&&&&&&&&new&TilePaletteDialog(this,&currentMap);
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&tilePaletteDialog.setVisible(true);
&&&&&&&&&&&&}
&&&&&&&&}&else&{
&&&&&&&&&&&&handleEvent(event);
&&&&//&TODO:&Most&if&not&all&of&the&below&should&be&moved&into&action&objects,
&&&&//&TODO:&and&properly&internationalized.
&&&&private&void&handleEvent(ActionEvent&event)&{
&&&&&&&&String&command&=&event.getActionCommand();
&&&&&&&&if&(command.equals(Resources.getString(&menu.edit.brush&)))&{
&&&&&&&&&&&&BrushDialog&bd&=&new&BrushDialog(this,&appFrame,&currentBrush);
&&&&&&&&&&&&bd.setVisible(true);
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.tilesets.new&)))&{
&&&&&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&&&&&NewTilesetDialog&dialog&=
&&&&&&&&&&&&&&&&&&&&new&NewTilesetDialog(appFrame,&currentMap);
&&&&&&&&&&&&&&&&TileSet&newSet&=&dialog.create();
&&&&&&&&&&&&&&&&if&(newSet&!=&null)&{
&&&&&&&&&&&&&&&&&&&&currentMap.addTileset(newSet);
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.tilesets.import&)))&{
&&&&&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&&&&&JFileChooser&ch&=&new&JFileChooser(currentMap.getFilename());
&&&&&&&&&&&&&&&&MapReader[]&readers&=&pluginLoader.getReaders();
&&&&&&&&&&&&&&&&for&(int&i&=&0;&i&&&readers.&i++)&{
&&&&&&&&&&&&&&&&&&&&try&{
&&&&&&&&&&&&&&&&&&&&&&&&ch.addChoosableFileFilter(new&TiledFileFilter(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&readers[i].getFilter(),
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&readers[i].getName()));
&&&&&&&&&&&&&&&&&&&&}&catch&(Exception&e)&{
&&&&&&&&&&&&&&&&&&&&&&&&e.printStackTrace();
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&ch.addChoosableFileFilter(
&&&&&&&&&&&&&&&&&&&&&&&&new&TiledFileFilter(TiledFileFilter.FILTER_TSX));
&&&&&&&&&&&&&&&&int&ret&=&ch.showOpenDialog(appFrame);
&&&&&&&&&&&&&&&&if&(ret&==&JFileChooser.APPROVE_OPTION)&{
&&&&&&&&&&&&&&&&&&&&String&filename&=&ch.getSelectedFile().getAbsolutePath();
&&&&&&&&&&&&&&&&&&&&try&{
&&&&&&&&&&&&&&&&&&&&&&&&TileSet&set&=&MapHelper.loadTileset(filename);
&&&&&&&&&&&&&&&&&&&&&&&&currentMap.addTileset(set);
&&&&&&&&&&&&&&&&&&&&}&catch&(Exception&e)&{
&&&&&&&&&&&&&&&&&&&&&&&&e.printStackTrace();
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.tilesets.manager&)))&{
&&&&&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&&&&&TilesetManager&manager&=&new&TilesetManager(appFrame,&currentMap);
&&&&&&&&&&&&&&&&manager.setVisible(true);
&&&&&&&&&&&&}
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.file.image&)))&{
&&&&&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&&&&&saveMapImage(null);
&&&&&&&&&&&&}
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.map.properties&)))&{
&&&&&&&&&&&&PropertiesDialog&pd&=&new&PropertiesDialog(appFrame,
&&&&&&&&&&&&&&&&&&&&currentMap.getProperties());
&&&&&&&&&&&&pd.setTitle(Resources.getString(&dialog.properties.map.title&));
&&&&&&&&&&&&pd.getProps();
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.layer.properties&)))&{
&&&&&&&&&&&&MapLayer&layer&=&getCurrentLayer();
&&&&&&&&&&&&PropertiesDialog&lpd&=
&&&&&&&&&&&&&&&&new&PropertiesDialog(appFrame,&layer.getProperties());
&&&&&&&&&&&&lpd.setTitle(layer.getName()&+&&&&&+&Resources.getString(&dialog.properties.title&));
&&&&&&&&&&&&lpd.getProps();
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.view.boundaries&))&||
&&&&&&&&&&&&&&&&command.equals(&Hide&Boundaries&))&{
&&&&&&&&&&&&mapView.toggleMode(MapView.PF_BOUNDARYMODE);
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.view.grid&)))&{
&&&&&&&&&&&&//&Toggle&grid
&&&&&&&&&&&&Preferences&displayPrefs&=&prefs.node(&display&);
&&&&&&&&&&&&boolean&showGrid&=&displayPrefs.getBoolean(&showGrid&,&false);
&&&&&&&&&&&&displayPrefs.putBoolean(&showGrid&,&!showGrid);
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.view.coordinates&)))&{
&&&&&&&&&&&&//&Toggle&coordinates
&&&&&&&&&&&&mapView.toggleMode(MapView.PF_COORDINATES);
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.view.cursor&)))&{
&&&&&&&&&&&&prefs.putBoolean(&cursorhighlight&,&cursorMenuItem.isSelected());
&&&&&&&&&&&&cursorHighlight.setVisible(cursorMenuItem.isSelected());
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.map.resize&)))&{
&&&&&&&&&&&&ResizeDialog&rd&=&new&ResizeDialog(appFrame,&this);
&&&&&&&&&&&&rd.setVisible(true);
&&&&&&&&}&&else&if&(command.equals(Resources.getString(&menu.map.search&)))&{
&&&&&&&&&&&&SearchDialog&sd&=&new&SearchDialog(appFrame,&currentMap);
&&&&&&&&&&&&sd.setVisible(true);
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.help.about&)))&{
&&&&&&&&&&&&if&(aboutDialog&==&null)&{
&&&&&&&&&&&&&&&&aboutDialog&=&new&AboutDialog(appFrame);
&&&&&&&&&&&&}
&&&&&&&&&&&&aboutDialog.setVisible(true);
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.help.plugins&)))&{
&&&&&&&&&&&&PluginDialog&pluginDialog&=
&&&&&&&&&&&&&&&&new&PluginDialog(appFrame,&pluginLoader);
&&&&&&&&&&&&pluginDialog.setVisible(true);
&&&&&&&&}&else&if&(command.equals(Resources.getString(&menu.edit.preferences&)))&{
&&&&&&&&&&&&ConfigurationDialog&d&=&new&ConfigurationDialog(appFrame);
&&&&&&&&&&&&d.configure();
&&&&&&&&}&else&{
&&&&&&&&&&&&System.out.println(event);
&&&&public&void&componentHidden(ComponentEvent&event)&{
&&&&public&void&componentMoved(ComponentEvent&event)&{
&&&&public&void&componentResized(ComponentEvent&event)&{
&&&&&&&&//&This&can&currently&only&happen&when&the&map&changes&size
&&&&&&&&String&s&=&String.valueOf((int)&(mapView.getZoom()&*&100))&+&&%&;
&&&&&&&&zoomLabel.setText(s);
&&&&&&&&//&Restore&the&midpoint
&&&&&&&&JViewport&mapViewPort&=&mapScrollPane.getViewport();
&&&&&&&&Rectangle&viewRect&=&mapViewPort.getViewRect();
&&&&&&&&int&absMidX&=&Math.max(0,&Math.round(relativeMidX&*&mapView.getWidth())&-&viewRect.width&/&2);
&&&&&&&&int&absMidY&=&Math.max(0,&Math.round(relativeMidY&*&mapView.getHeight())&-&viewRect.height&/&2);
&&&&&&&&mapViewPort.setViewPosition(new&Point(absMidX,&absMidY));
&&&&public&void&componentShown(ComponentEvent&event)&{
&&&&public&void&mapChanged(MapChangedEvent&e)&{
&&&&&&&&if&(e.getMap()&==&currentMap)&{
&&&&&&&&&&&&mapScrollPane.setViewportView(mapView);
&&&&&&&&&&&&updateLayerTable();
&&&&&&&&&&&&if&(tilePaletteDialog&!=&null)&{
&&&&&&&&&&&&&&&&tilePaletteDialog.setMap(currentMap);
&&&&&&&&&&&&}
&&&&&&&&&&&&mapView.repaint();
&&&&public&void&valueChanged(ListSelectionEvent&e)&{
&&&&&&&&int&selectedRow&=&layerTable.getSelectedRow();
&&&&&&&&//&At&the&moment,&this&can&only&be&a&new&layer&selection
&&&&&&&&if&(currentMap&!=&null&&&&selectedRow&&=&0)&{
&&&&&&&&&&&&currentLayer&=&currentMap.getTotalLayers()&-&selectedRow&-&1;
&&&&&&&&&&&&float&opacity&=&getCurrentLayer().getOpacity();
&&&&&&&&&&&&opacitySlider.setValue((int)(opacity&*&100));
&&&&&&&&}&else&{
&&&&&&&&&&&&currentLayer&=&-1;
&&&&&&&&updateLayerOperations();
&&&&public&void&stateChanged(ChangeEvent&e)&{
&&&&&&&&JViewport&mapViewport&=&mapScrollPane.getViewport();
&&&&&&&&if&(e.getSource()&==&opacitySlider)&{
&&&&&&&&&&&&if&(currentMap&!=&null&&&&currentLayer&&=&0)&{
&&&&&&&&&&&&&&&&MapLayer&layer&=&getCurrentLayer();
&&&&&&&&&&&&&&&&layer.setOpacity(opacitySlider.getValue()&/&100.0f);
&&&&&&&&&&&&&&&&/*
&&&&&&&&&&&&&&&&MapLayerStateEdit&mlse&=&new&MapLayerStateEdit(currentMap);
&&&&&&&&&&&&&&&&mlse.setPresentationName(&Opacity&Change&);
&&&&&&&&&&&&&&&&undoSupport.postEdit(mlse);
&&&&&&&&&&&&&&&&*/
&&&&&&&&&&&&}
&&&&&&&&else&if&(e.getSource()&==&mapViewport&&&&mapView&!=&null)&{
&&&&&&&&&&&&//&Store&the&point&in&the&middle&for&zooming&purposes
&&&&&&&&&&&&Rectangle&viewRect&=&mapViewport.getViewRect();
&&&&&&&&&&&&relativeMidX&=&Math.min(1,&(viewRect.x&+&viewRect.width&/&2)&/&(float)mapView.getWidth());
&&&&&&&&&&&&relativeMidY&=&Math.min(1,&(viewRect.y&+&viewRect.height&/&2)&/&(float)mapView.getHeight());
&&&&&*&Returns&the&map&view.&Currently&only&used&by&the&{@link&UndoHandler}
&&&&&*&to&be&able&to&order&a&repaint&when&doing&an&undo&or&redo.&This&should
&&&&&*&become&obsolete&when&we&add&automatic&repainting&based&on&layer
&&&&&*&changes.
&&&&&*&@return&the&map&view.
&&&&public&MapView&getMapView()&{
&&&&&&&&return&mapV
&&&&&*&Called&when&the&editor&is&exiting.
&&&&public&void&shutdown()&{
&&&&&&&&//&Save&the&extended&window&state&if&the&window&isn't&minimized
&&&&&&&&int&extendedState&=&appFrame.getExtendedState();
&&&&&&&&prefs.node(&dialog/main&).putInt(&state&,&extendedState);
&&&&&&&&//&Allow&the&the&tile&palette&dialog&to&save&its&prefs&(because&it's
&&&&&&&&//&common&to&tweak&this&to&a&certain&width&for&convenient&tileset
&&&&&&&&//&display)
&&&&&&&&//&todo:&would&be&nicer&to&introduce&a&ShutdownListener&interface
&&&&&&&&if&(tilePaletteDialog&!=&null)&{
&&&&&&&&&&&&tilePaletteDialog.shutdown();
&&&&private&class&LayerTransformAction&extends&AbstractAction&{
&&&&&&&&private&final&int&
&&&&&&&&public&LayerTransformAction(int&transform)&{
&&&&&&&&&&&&this.transform&=&
&&&&&&&&&&&&switch&(transform)&{
&&&&&&&&&&&&&&&&case&MapLayer.ROTATE_90:
&&&&&&&&&&&&&&&&&&&&putValue(NAME,&Resources.getString(&action.layer.transform.rotate90.name&));
&&&&&&&&&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.layer.transform.rotate90.tooltip&));
&&&&&&&&&&&&&&&&&&&&putValue(SMALL_ICON,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Resources.getIcon(&gimp-rotate-90-16.png&));
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&case&MapLayer.ROTATE_180:
&&&&&&&&&&&&&&&&&&&&putValue(NAME,&Resources.getString(&action.layer.transform.rotate180.name&));
&&&&&&&&&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.layer.transform.rotate180.tooltip&));
&&&&&&&&&&&&&&&&&&&&putValue(SMALL_ICON,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Resources.getIcon(&gimp-rotate-180-16.png&));
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&case&MapLayer.ROTATE_270:
&&&&&&&&&&&&&&&&&&&&putValue(NAME,&Resources.getString(&action.layer.transform.rotate270.name&));
&&&&&&&&&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.layer.transform.rotate270.tooltip&));
&&&&&&&&&&&&&&&&&&&&putValue(SMALL_ICON,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Resources.getIcon(&gimp-rotate-270-16.png&));
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&case&MapLayer.MIRROR_VERTICAL:
&&&&&&&&&&&&&&&&&&&&putValue(NAME,&Resources.getString(&action.layer.transform.vertical.name&));
&&&&&&&&&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,&Resources.getString(&action.layer.transform.vertical.tooltip&));
&&&&&&&&&&&&&&&&&&&&putValue(SMALL_ICON,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Resources.getIcon(&gimp-flip-vertical-16.png&));
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&case&MapLayer.MIRROR_HORIZONTAL:
&&&&&&&&&&&&&&&&&&&&putValue(NAME,&Resources.getString(&action.layer.transform.horizontal.name&));
&&&&&&&&&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,&Resources.getString(&action.layer.transform.horizontal.tooltip&));
&&&&&&&&&&&&&&&&&&&&putValue(SMALL_ICON,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&Resources.getIcon(&gimp-flip-horizontal-16.png&));
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&}
&&&&&&&&public&void&actionPerformed(ActionEvent&evt)&{
&&&&&&&&&&&&MapLayer&currentLayer&=&getCurrentLayer();
&&&&&&&&&&&&MapLayer&layer&=&currentL
&&&&&&&&&&&&MapLayerEdit&transE
&&&&&&&&&&&&transEdit&=&new&MapLayerEdit(
&&&&&&&&&&&&&&&&&&&&currentLayer,&createLayerCopy(currentLayer));
&&&&&&&&&&&&if&(marqueeSelection&!=&null)&{
&&&&&&&&&&&&&&&&if&(currentLayer&instanceof&TileLayer)&{
&&&&&&&&&&&&&&&&&&&&layer&=&new&TileLayer(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedAreaBounds());
&&&&&&&&&&&&&&&&}&else&if&(currentLayer&instanceof&ObjectGroup)&{
&&&&&&&&&&&&&&&&&&&&layer&=&new&ObjectGroup(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedAreaBounds());
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&layer.setMap(currentMap);
&&&&&&&&&&&&&&&&layer.maskedCopyFrom(
&&&&&&&&&&&&&&&&&&&&&&&&currentLayer,
&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedArea());
&&&&&&&&&&&&}
&&&&&&&&&&&&switch&(transform)&{
&&&&&&&&&&&&&&&&case&MapLayer.ROTATE_90:
&&&&&&&&&&&&&&&&case&MapLayer.ROTATE_180:
&&&&&&&&&&&&&&&&case&MapLayer.ROTATE_270:
&&&&&&&&&&&&&&&&&&&&transEdit.setPresentationName(&Rotate&);
&&&&&&&&&&&&&&&&&&&&layer.rotate(transform);
&&&&&&&&&&&&&&&&&&&&//if(marqueeSelection&!=&null)&marqueeSelection.rotate(transform);
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&case&MapLayer.MIRROR_VERTICAL:
&&&&&&&&&&&&&&&&&&&&transEdit.setPresentationName(&Vertical&Flip&);
&&&&&&&&&&&&&&&&&&&&layer.mirror(MapLayer.MIRROR_VERTICAL);
&&&&&&&&&&&&&&&&&&&&//if(marqueeSelection&!=&null)&marqueeSelection.mirror(transform);
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&case&MapLayer.MIRROR_HORIZONTAL:
&&&&&&&&&&&&&&&&&&&&transEdit.setPresentationName(&Horizontal&Flip&);
&&&&&&&&&&&&&&&&&&&&layer.mirror(MapLayer.MIRROR_HORIZONTAL);
&&&&&&&&&&&&&&&&&&&&//if(marqueeSelection&!=&null)&marqueeSelection.mirror(transform);
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&}
&&&&&&&&&&&&if&(marqueeSelection&!=&null&)&{
&&&&&&&&&&&&&&&&layer.mergeOnto(currentLayer);
&&&&&&&&&&&&}
&&&&&&&&&&&&transEdit.end(createLayerCopy(currentLayer));
&&&&&&&&&&&&undoSupport.postEdit(transEdit);
&&&&&&&&&&&&mapView.repaint();
&&&&private&class&CancelSelectionAction&extends&AbstractAction&{
&&&&&&&&public&CancelSelectionAction()&{
&&&&&&&&&&&&super(Resources.getString(&action.select.none.name&));
&&&&&&&&&&&&putValue(ACCELERATOR_KEY,
&&&&&&&&&&&&&&&&&&&&KeyStroke.getKeyStroke(&control&shift&A&));
&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.select.none.tooltip&));
&&&&&&&&public&void&actionPerformed(ActionEvent&e)&{
&&&&&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&&&&&if&(marqueeSelection&!=&null)&{
&&&&&&&&&&&&&&&&&&&&currentMap.removeLayerSpecial(marqueeSelection);
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&marqueeSelection&=&
&&&&&&&&&&&&}
&&&&private&class&SelectAllAction&extends&AbstractAction&{
&&&&&&&&public&SelectAllAction()&{
&&&&&&&&&&&&super(Resources.getString(&action.select.all.name&));
&&&&&&&&&&&&putValue(ACCELERATOR_KEY,
&&&&&&&&&&&&&&&&&&&&KeyStroke.getKeyStroke(&control&A&));
&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.select.all.tooltip&));
&&&&&&&&public&void&actionPerformed(ActionEvent&e)&{
&&&&&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&&&&&if&(marqueeSelection&!=&null)&{
&&&&&&&&&&&&&&&&&&&&currentMap.removeLayerSpecial(marqueeSelection);
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&marqueeSelection&=&new&SelectionLayer(
&&&&&&&&&&&&&&&&&&&&&&&&currentMap.getWidth(),&currentMap.getHeight());
&&&&&&&&&&&&&&&&marqueeSelection.selectRegion(marqueeSelection.getBounds());
&&&&&&&&&&&&&&&&currentMap.addLayerSpecial(marqueeSelection);
&&&&&&&&&&&&}
&&&&private&class&InverseSelectionAction&extends&AbstractAction&{
&&&&&&&&public&InverseSelectionAction()&{
&&&&&&&&&&&&super(Resources.getString(&action.select.invert.name&));
&&&&&&&&&&&&putValue(ACCELERATOR_KEY,
&&&&&&&&&&&&&&&&&&&&KeyStroke.getKeyStroke(&control&I&));
&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.select.invert.tooltip&));
&&&&&&&&public&void&actionPerformed(ActionEvent&e)&{
&&&&&&&&&&&&if&(marqueeSelection&!=&null)&{
&&&&&&&&&&&&&&&&marqueeSelection.invert();
&&&&&&&&&&&&&&&&mapView.repaint();
&&&&&&&&&&&&}
&&&&private&class&ZoomInAction&extends&AbstractAction&{
&&&&&&&&public&ZoomInAction()&{
&&&&&&&&&&&&super(Resources.getString(&action.zoom.in.name&));
&&&&&&&&&&&&putValue(ACCELERATOR_KEY,
&&&&&&&&&&&&&&&&&&&&KeyStroke.getKeyStroke(&control&EQUALS&));
&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.zoom.in.tooltip&));
&&&&&&&&&&&&putValue(SMALL_ICON,&Resources.getIcon(&gnome-zoom-in.png&));
&&&&&&&&public&void&actionPerformed(ActionEvent&evt)&{
&&&&&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&&&&&zoomOutAction.setEnabled(true);
&&&&&&&&&&&&&&&&if&(!mapView.zoomIn())&{
&&&&&&&&&&&&&&&&&&&&setEnabled(false);
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&zoomNormalAction.setEnabled(mapView.getZoomLevel()&!=
&&&&&&&&&&&&&&&&&&&&&&&&MapView.ZOOM_NORMALSIZE);
&&&&&&&&&&&&}
&&&&private&class&ZoomOutAction&extends&AbstractAction&{
&&&&&&&&public&ZoomOutAction()&{
&&&&&&&&&&&&super(Resources.getString(&action.zoom.out.name&));
&&&&&&&&&&&&putValue(ACCELERATOR_KEY,
&&&&&&&&&&&&&&&&&&&&KeyStroke.getKeyStroke(&control&MINUS&));
&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.zoom.out.tooltip&));
&&&&&&&&&&&&putValue(SMALL_ICON,&Resources.getIcon(&gnome-zoom-out.png&));
&&&&&&&&public&void&actionPerformed(ActionEvent&evt)&{
&&&&&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&&&&&zoomInAction.setEnabled(true);
&&&&&&&&&&&&&&&&if&(!mapView.zoomOut())&{
&&&&&&&&&&&&&&&&&&&&setEnabled(false);
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&zoomNormalAction.setEnabled(mapView.getZoomLevel()&!=
&&&&&&&&&&&&&&&&&&&&&&&&MapView.ZOOM_NORMALSIZE);
&&&&&&&&&&&&}
&&&&private&class&ZoomNormalAction&extends&AbstractAction&{
&&&&&&&&public&ZoomNormalAction()&{
&&&&&&&&&&&&super(Resources.getString(&action.zoom.normal.name&));
&&&&&&&&&&&&putValue(ACCELERATOR_KEY,
&&&&&&&&&&&&&&&&&&&&KeyStroke.getKeyStroke(&control&0&));
&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.zoom.normal.tooltip&));
&&&&&&&&public&void&actionPerformed(ActionEvent&evt)&{
&&&&&&&&&&&&if&(currentMap&!=&null)&{
&&&&&&&&&&&&&&&&zoomInAction.setEnabled(true);
&&&&&&&&&&&&&&&&zoomOutAction.setEnabled(true);
&&&&&&&&&&&&&&&&setEnabled(false);
&&&&&&&&&&&&&&&&mapView.setZoomLevel(MapView.ZOOM_NORMALSIZE);
&&&&&&&&&&&&}
&&&&private&class&CopyAction&extends&AbstractAction&{
&&&&&&&&public&CopyAction()&{
&&&&&&&&&&&&super(Resources.getString(&action.copy.name&));
&&&&&&&&&&&&putValue(ACCELERATOR_KEY,
&&&&&&&&&&&&&&&&&&&&KeyStroke.getKeyStroke(&control&C&));
&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.copy.tooltip&));
&&&&&&&&public&void&actionPerformed(ActionEvent&evt)&{
&&&&&&&&&&&&if&(currentMap&!=&null&&&&marqueeSelection&!=&null)&{
&&&&&&&&&&&&&&&&if&(getCurrentLayer()&instanceof&TileLayer)&{
&&&&&&&&&&&&&&&&&&&&clipboardLayer&=&new&TileLayer(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedAreaBounds());
&&&&&&&&&&&&&&&&}&else&if&(getCurrentLayer()&instanceof&ObjectGroup)&{
&&&&&&&&&&&&&&&&&&&&clipboardLayer&=&new&ObjectGroup(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedAreaBounds());
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&clipboardLayer.maskedCopyFrom(
&&&&&&&&&&&&&&&&&&&&&&&&getCurrentLayer(),
&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedArea());
&&&&&&&&&&&&}
&&&&private&class&CutAction&extends&AbstractAction&{
&&&&&&&&public&CutAction()&{
&&&&&&&&&&&&super(Resources.getString(&action.cut.name&));
&&&&&&&&&&&&putValue(ACCELERATOR_KEY,
&&&&&&&&&&&&&&&&&&&&KeyStroke.getKeyStroke(&control&X&));
&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.cut.tooltip&));
&&&&&&&&public&void&actionPerformed(ActionEvent&evt)&{
&&&&&&&&&&&&if&(currentMap&!=&null&&&&marqueeSelection&!=&null)&{
&&&&&&&&&&&&&&&&MapLayer&ml&=&getCurrentLayer();
&&&&&&&&&&&&&&&&if&(getCurrentLayer()&instanceof&TileLayer)&{
&&&&&&&&&&&&&&&&&&&&clipboardLayer&=&new&TileLayer(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedAreaBounds());
&&&&&&&&&&&&&&&&}&else&if&(getCurrentLayer()&instanceof&ObjectGroup)&{
&&&&&&&&&&&&&&&&&&&&clipboardLayer&=&new&ObjectGroup(
&&&&&&&&&&&&&&&&&&&&&&&&&&&&marqueeSelection.getSelectedAreaBounds());
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&clipboardLayer.maskedCopyFrom(
&&&&&&&&&&&&&&&&&&&&&&&&ml,&marqueeSelection.getSelectedArea());
&&&&&&&&&&&&&&&&Rectangle&area&=&marqueeSelection.getSelectedAreaBounds();
&&&&&&&&&&&&&&&&Area&mask&=&marqueeSelection.getSelectedArea();
&&&&&&&&&&&&&&&&if&(ml&instanceof&TileLayer)&{
&&&&&&&&&&&&&&&&&&&&TileLayer&tl&=&(TileLayer)
&&&&&&&&&&&&&&&&&&&&for&(int&i&=&area.y;&i&&&area.height+area.y;&i++)&{
&&&&&&&&&&&&&&&&&&&&&&&&for&(int&j&=&area.x;&j&&&area.width&+&area.x;&j++){
&&&&&&&&&&&&&&&&&&&&&&&&&&&&if&(mask.contains(j,i))&{
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&tl.setTileAt(j,&i,&null);
&&&&&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&mapView.repaintRegion(area);
&&&&&&&&&&&&}
&&&&private&class&PasteAction&extends&AbstractAction&{
&&&&&&&&public&PasteAction()&{
&&&&&&&&&&&&super(Resources.getString(&action.paste.name&));
&&&&&&&&&&&&putValue(ACCELERATOR_KEY,
&&&&&&&&&&&&&&&&&&&&KeyStroke.getKeyStroke(&control&V&));
&&&&&&&&&&&&putValue(SHORT_DESCRIPTION,
&&&&&&&&&&&&&&&&&&&&&Resources.getString(&action.paste.tooltip&));
&&&&&&&&public&void&actionPerformed(ActionEvent&evt)&{
&&&&&&&&&&&&if&(currentMap&!=&null&&&&clipboardLayer&!=&null)&{
&&&&&&&&&&&&&&&&Vector&layersBefore&=&currentMap.getLayerVector();
&&&&&&&&&&&&&&&&MapLayer&ml&=&createLayerCopy(clipboardLayer);
&&&&&&&&&&&&&&&&ml.setName(Resources.getString(&general.layer.layer&)+&&&&+&currentMap.getTotalLayers());
&&&&&&&&&&&&&&&&currentMap.addLayer(ml);
&&&&&&&&&&&&&&&&undoSupport.postEdit(
&&&&&&&&&&&&&&&&&&&&&&&&new&MapLayerStateEdit(currentMap,&layersBefore,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&new&Vector(currentMap.getLayerVector()),
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&Paste&Selection&));
&&&&&&&&&&&&}
&&&&private&void&pour(TileLayer&layer,&int&x,&int&y,
&&&&&&&&&&&&Tile&newTile,&Tile&oldTile)&{
&&&&&&&&if&(newTile&==&oldTile&||&layer.getLocked())&
&&&&&&&&Rectangle&
&&&&&&&&TileLayer&before&=&new&TileLayer(layer);
&&&&&&&&TileLayer&
&&&&&&&&if&(marqueeSelection&==&null)&{
&&&&&&&&&&&&area&=&new&Rectangle(new&Point(x,&y));
&&&&&&&&&&&&Stack&stack&=&new&Stack();
&&&&&&&&&&&&stack.push(new&Point(x,&y));
&&&&&&&&&&&&while&(!stack.empty())&{
&&&&&&&&&&&&&&&&//&Remove&the&next&tile&from&the&stack
&&&&&&&&&&&&&&&&Point&p&=&(Point)stack.pop();
&&&&&&&&&&&&&&&&//&If&the&tile&it&meets&the&requirements,&set&it&and&push&its
&&&&&&&&&&&&&&&&//&neighbouring&tiles&on&the&stack.
&&&&&&&&&&&&&&&&if&(layer.contains(p.x,&p.y)&&&
&&&&&&&&&&&&&&&&&&&&&&&&layer.getTileAt(p.x,&p.y)&==&oldTile)
&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&layer.setTileAt(p.x,&p.y,&newTile);
&&&&&&&&&&&&&&&&&&&&area.add(p);
&&&&&&&&&&&&&&&&&&&&stack.push(new&Point(p.x,&p.y&-&1));
&&&&&&&&&&&&&&&&&&&&stack.push(new&Point(p.x,&p.y&+&1));
&&&&&&&&&&&&&&&&&&&&stack.push(new&Point(p.x&+&1,&p.y));
&&&&&&&&&&&&&&&&&&&&stack.push(new&Point(p.x&-&1,&p.y));
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}
&&&&&&&&}&else&{
&&&&&&&&&&&&if&(marqueeSelection.getSelectedArea().contains(x,&y))&{
&&&&&&&&&&&&&&&&area&=&marqueeSelection.getSelectedAreaBounds();
&&&&&&&&&&&&&&&&for&(int&i&=&area.y;&i&&&area.height&+&area.y;&i++)&{
&&&&&&&&&&&&&&&&&&&&for&(int&j&=&area.x;&j&&&area.width&+&area.x;&j++)&{
&&&&&&&&&&&&&&&&&&&&&&&&if&(marqueeSelection.getSelectedArea().contains(j,&i)){
&&&&&&&&&&&&&&&&&&&&&&&&&&&&layer.setTileAt(j,&i,&newTile);
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}&else&{
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&}
&&&&&&&&Rectangle&bounds&=&new&Rectangle(
&&&&&&&&&&&&&&&&area.x,&area.y,&area.width&+&1,&area.height&+&1);
&&&&&&&&after&=&new&TileLayer(bounds);
&&&&&&&&after.copyFrom(layer);
&&&&&&&&MapLayerEdit&mle&=&new&MapLayerEdit(layer,&before,&after);
&&&&&&&&mle.setPresentationName(TOOL_FILL);
&&&&&&&&undoSupport.postEdit(mle);
&&&&public&void&resetBrush()&{
&&&&&&&&//FIXME:&this&is&an&in-elegant&hack,&but&it&gets&the&user&out
&&&&&&&&//&&&&&&&of&custom&brush&mode
&&&&&&&&//(reset&the&brush&if&necessary)
&&&&&&&&if&(currentBrush&instanceof&CustomBrush)&{
&}

我要回帖

更多关于 魔兽地图编辑器怎么用 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信