package csa.tiletools.sprites;


import csa.config.Configuration;
import csa.gui.Windowable;
import csa.gui.components.CSATableModel;
import csa.gui.components.CSATablePanel;
import csa.gui.components.CSAView;
import csa.gui.components.DoubleClickAction;
import csa.gui.dialogs.InternalFrameFileChoser;
import csa.gui.dialogs.ShowInfoDialog;
import csa.tiletools.graphics.BaseImageData;
import csa.tiletools.graphics.ImageComponent;
import csa.tiletools.graphics.ImageSequence;
import csa.tiletools.graphics.ImageSequenceData;
import csa.tiletools.graphics.ImageSequenceDataPool;
import csa.tiletools.map.TMap;
import csa.tiletools.script.ExportFrame;
import csa.tiletools.tiles.AttributeBundleData;
import csa.tiletools.tiles.AttributeBundleDataPool;
import csa.util.UtilityString;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.io.File;
import java.util.*;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.AbstractTableModel;

public class SpriteDataPanel extends javax.swing.JPanel implements
        Windowable{
    /**
    SpriteData
     each "Action" has an action name like: RUN, WALK, JUMP
     each "Action" has 9 directions
     all image information is saved for actions combined with direction!
     each 
    
    
    **/
    private CSATablePanel csaPanel = null;

    Vector <SpriteData> mAllSpritesInClass = new Vector <SpriteData>();

    // current working tile
    Sprite mCurrentSprite=null;
    
    private SpriteDataPool mSpriteDataPool = null;
    private int mClassSetting=0;

    Vector <SpriteAttribute> mAttributeData = new Vector <SpriteAttribute>();
    private AttributeBundleData mAttributeBundleData = new AttributeBundleData();

    SpriteAttribute mCurrentAttributeData = new SpriteAttribute();
    // event gotten row / column of double clicked tableentry
    private int mRow=-1;
    private int mCol=-1;

    // current working grafix
    private ImageSequenceData mData = new ImageSequenceData();
    private ImageSequenceDataPool mImageSequenceDataPool = null;

    private AttributeBundleDataPool mAttributeBundleDataPool = null;
    JPanel[] directionPanels = new JPanel[32];



    private CSAView mParent = null;
    private javax.swing.JMenuItem mParentMenuItem = null;

    @Override
    public void closing(){}
    @Override
    public void setParentWindow(CSAView jpv)
    {
        mParent = jpv;
    }
    @Override
    public void setMenuItem(javax.swing.JMenuItem item)
    {
        mParentMenuItem = item;
        mParentMenuItem.setText("Sprite Manager");
    }
    @Override
    public javax.swing.JMenuItem getMenuItem()
    {
        return mParentMenuItem;
    }
    @Override
    public javax.swing.JPanel getPanel()
    {
        return this;
    }

    /** Creates new form TileDataPanel */
    public SpriteDataPanel() {
        initComponents();
        mAttributeBundleDataPool = new AttributeBundleDataPool("SpriteAttributes.xml");

        
        resetConfigPool(false, "", "");
        resetAttributePool();



        class MyTransferHandler extends TransferHandler
        {
            public MyTransferHandler()
            {
            }
            @Override
            public boolean canImport(TransferHandler.TransferSupport support)
            {
                return true;
            }
            @Override
            public boolean importData(TransferHandler.TransferSupport support)
            {
                try
                {
                    DataFlavor stringFlavor = DataFlavor.stringFlavor;
                    Component c = support.getComponent(); // target
                    Transferable t = support.getTransferable();
                    String data = t.getTransferData(stringFlavor).toString();
                    //System.out.println("Dropped: " + data);


                    int number = -1;

                    for (int i=1; i<32; i++)
                    {
                        if (directionPanels[i] == (JPanel)c)
                        {
                            number = i;
                            break;
                        }
                    }
                    setDirectionAnimation(data, (JPanel)c, true, number);

                }
                catch (Throwable e)
                {
                    e.printStackTrace();
                }

                return true;
            }
        }

        class MyVariationTransferHandler extends TransferHandler
        {
            public MyVariationTransferHandler()
            {
            }
            @Override
            public boolean canImport(TransferHandler.TransferSupport support)
            {
                return true;
            }
            @Override
            public boolean importData(TransferHandler.TransferSupport support)
            {
                try
                {
                    DataFlavor stringFlavor = DataFlavor.stringFlavor;
                    Transferable t = support.getTransferable();
                    String data = t.getTransferData(stringFlavor).toString();
                }
                catch (Throwable e)
                {
                    e.printStackTrace();
                }

                return true;
            }
        }

        directionPanels[0] = null;
        directionPanels[1] = jPanelNW;
        directionPanels[2] = jPanelN;
        directionPanels[3] = jPanelNE;
        directionPanels[4] = jPanelW;
        directionPanels[5] = jPanelE;
        directionPanels[6] = jPanelC;
        directionPanels[7] = jPanelSE;
        directionPanels[8] = jPanelS;
        directionPanels[9] = jPanelSW;


        for (int i=0; i<32; i++)
        {
            if (directionPanels[i] != null)
                directionPanels[i].setTransferHandler(new MyTransferHandler());
        }
        clearAll(); // init to no sprite!
    }


    private void resetAttributePool() /* allneeded*/
    {
        mClassSetting++;
        String klasse = "ALL";

        Collection<AttributeBundleData> colC = mAttributeBundleDataPool.getMapForKlasse(klasse).values();
        Iterator<AttributeBundleData> iterC = colC.iterator();

        jComboBoxAttribute.removeAllItems();
        int i = 0;
        jComboBoxAttribute.addItem("");
        while (iterC.hasNext())
        {
            AttributeBundleData item = iterC.next();
            jComboBoxAttribute.addItem(item.mName);
            i++;
        }
        jComboBoxAttribute.setSelectedIndex(-1);
        mClassSetting--;
    }

    // Config Pool for TileMap
    boolean inConfig = false;
    private void resetConfigPool(boolean select, String klasseToSet, String spriteToSet) /* allneeded*/
    {
        if (inConfig) return;
        inConfig = true;
        mClassSetting++;

        jComboBoxKlasse.removeAllItems();
        mClassSetting--;
        jTextFieldKlasse.setText("");
        if (mSpriteDataPool == null)
        {
            inConfig = false;
            return;
        }

        mClassSetting++;
        Collection<String> collectionKlasse = mSpriteDataPool.getKlassenHashMap().values();
        Iterator<String> iterKlasse = collectionKlasse.iterator();
        int i = 0;
        String klasse = "";

        while (iterKlasse.hasNext())
        {
            String item = iterKlasse.next();
            jComboBoxKlasse.addItem(item);
            if (select)
            {
                if (klasseToSet.length()==0)
                {
                    if (i==0)
                    {
                        // allow event to happen
                        mClassSetting--;
                        jComboBoxKlasse.setSelectedIndex(i);
                        mClassSetting++;
                        jTextFieldKlasse.setText(item);
                        klasse = item;
                    }
                }
                else
                {
                    if (klasseToSet.equalsIgnoreCase(item))
                    {
                        // allow event to happen
                        mClassSetting--;
                        jComboBoxKlasse.setSelectedIndex(i);
                        mClassSetting++;
                        jTextFieldKlasse.setText(item);
                        klasse = item;
                    }
                }
            }
            i++;
        }
        mClassSetting--;
        if ((select) && (klasse.length()==0))
        {
            if (jComboBoxKlasse.getItemCount()>0)
            {
                jComboBoxKlasse.setSelectedIndex(0);
                jTextFieldKlasse.setText(jComboBoxKlasse.getSelectedItem().toString());
                klasse = jComboBoxKlasse.getSelectedItem().toString();
            }
        }
        if (!select)  jComboBoxKlasse.setSelectedIndex(-1);


        if (!select)
        {
            removeAllGraphics(true);
        }
        resetSpriteList(spriteToSet);
        inConfig = false;
    }

    private void clearAll() /* allneeded*/
    {
        mClassSetting++;
        mCurrentSprite = Sprite.buildSprite(new SpriteData());
        
        jTextFieldKlasse.setText("");
        jComboBoxKlasse.setSelectedIndex(-1);
        setAllFromCurrent();
        mClassSetting--;
    }

    private void setAllFromCurrent() /* allneeded*/
    {
        mClassSetting++;
        jComboBoxKlasse.setSelectedItem(mCurrentSprite.data.mClass);
        jTextFieldKlasse.setText(mCurrentSprite.data.mClass);
        mClassSetting--;
    }

    private void readAllToCurrentSpriteSet() /* allneeded*/
    {
        mCurrentSprite.data.mClass = jTextFieldKlasse.getText();
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton3 = new javax.swing.JButton();
        lateBorderPanel1 = new csa.gui.panels.LateBorderPanel();
        jPanel1 = new javax.swing.JPanel();
        jComboBoxKlasse = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldKlasse = new javax.swing.JTextField();
        jButtonNew = new javax.swing.JButton();
        jButtonSaveTileSet = new javax.swing.JButton();
        jButtonSaveAsNew = new javax.swing.JButton();
        jButtonDelete = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldTileFile = new javax.swing.JTextField();
        jButtonFileSelect1 = new javax.swing.JButton();
        jButtonExport = new javax.swing.JButton();
        jPanel14 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jTextFieldGraphicsIMageCount = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldGraphicsHeight = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldGraphicsWidth = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jTextFieldGraphicsDelay = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jComboBoxNameGraphic = new javax.swing.JComboBox();
        jComboBoxKlasseGraphic = new javax.swing.JComboBox();
        jTextFieldGraphicFile = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jCheckBoxScaled = new javax.swing.JCheckBox();
        jScrollPane5 = new javax.swing.JScrollPane();
        imageComponent1 = new csa.tiletools.graphics.ImageComponent();
        jButtonFileSelect2 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jPanelIMageCollection = new javax.swing.JPanel();
        jPanel13 = new javax.swing.JPanel();
        jPanel15 = new javax.swing.JPanel();
        jPanel16 = new javax.swing.JPanel();
        jScrollPane9 = new javax.swing.JScrollPane();
        jPanelIMageCollection1 = new javax.swing.JPanel();
        jPanel17 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jPanel12 = new javax.swing.JPanel();
        jTextFieldAttributeValue = new javax.swing.JTextField();
        jComboBoxAttributeType = new javax.swing.JComboBox();
        jComboBoxAttributeName = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jButtonAddOneAttribute = new javax.swing.JButton();
        jButtonNewAttribute = new javax.swing.JButton();
        jButtonDeleteSelectedAttributes = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        jTableAttributeTable = new javax.swing.JTable();
        jButtonSaveAttributeBundle = new javax.swing.JButton();
        jComboBoxAttribute = new javax.swing.JComboBox();
        jTextFieldAttributeBundleName = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jButtonReplaceAttribute = new javax.swing.JButton();
        jTextFieldTileName = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jTextFieldTileID = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTextAreaDescription = new javax.swing.JTextArea();
        jTextFieldGraphicsHeightTile = new javax.swing.JTextField();
        jTextFieldGraphicsWidthTile = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jCheckBoxForceTileSize = new javax.swing.JCheckBox();
        jPanel7 = new javax.swing.JPanel();
        jComboBoxAction = new javax.swing.JComboBox();
        jLabel127 = new javax.swing.JLabel();
        jPanelNW = new javax.swing.JPanel();
        jPanelN = new javax.swing.JPanel();
        jPanelNE = new javax.swing.JPanel();
        jPanelW = new javax.swing.JPanel();
        jPanelE = new javax.swing.JPanel();
        jPanelSE = new javax.swing.JPanel();
        jPanelC = new javax.swing.JPanel();
        jPanelSW = new javax.swing.JPanel();
        jPanelS = new javax.swing.JPanel();
        jLabel128 = new javax.swing.JLabel();
        jCheckBoxAbsolutSteps = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        mapPanel = new csa.tiletools.map.MapPanel();
        jLabel17 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jPanel3 = new javax.swing.JPanel();
        animationStepPanel1 = new csa.tiletools.sprites.AnimationStepPanel();
        jLabel129 = new javax.swing.JLabel();
        jComboBoxAction1 = new javax.swing.JComboBox();
        jCheckBox2 = new javax.swing.JCheckBox();
        jButton2 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jCheckBox3 = new javax.swing.JCheckBox();
        jCheckBoxAutoMovment = new javax.swing.JCheckBox();
        jCheckBoxUpdateWhenNotInViewport = new javax.swing.JCheckBox();
        jCheckBoxBackShadow = new javax.swing.JCheckBox();
        jTextFieldBackThick = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jTextFieldBackAliase = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jTextFieldBack_R = new javax.swing.JTextField();
        jTextFieldBack_G = new javax.swing.JTextField();
        jTextFieldBack_B = new javax.swing.JTextField();
        jPanel8 = new javax.swing.JPanel();
        lateBorderPanel2 = new csa.gui.panels.LateBorderPanel();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jComboBox1 = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jButtonRemoveOneTile = new javax.swing.JButton();
        jButtonNewTile = new javax.swing.JButton();
        jButtonAddOneTile = new javax.swing.JButton();

        jButton3.setText("jButton3");

        javax.swing.GroupLayout lateBorderPanel1Layout = new javax.swing.GroupLayout(lateBorderPanel1);
        lateBorderPanel1.setLayout(lateBorderPanel1Layout);
        lateBorderPanel1Layout.setHorizontalGroup(
            lateBorderPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        lateBorderPanel1Layout.setVerticalGroup(
            lateBorderPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Sprite Set"));

        jComboBoxKlasse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxKlasseActionPerformed(evt);
            }
        });

        jLabel4.setText("Class");

        jButtonNew.setText("SpriteSet");
        jButtonNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNewActionPerformed(evt);
            }
        });

        jButtonSaveTileSet.setText("Save SpriteSet");
        jButtonSaveTileSet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaveTileSetActionPerformed(evt);
            }
        });

        jButtonSaveAsNew.setText("Save as new TileSet");
        jButtonSaveAsNew.setEnabled(false);
        jButtonSaveAsNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaveAsNewActionPerformed(evt);
            }
        });

        jButtonDelete.setText("Delete TileSet");
        jButtonDelete.setEnabled(false);
        jButtonDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDeleteActionPerformed(evt);
            }
        });

        jLabel5.setText("Filename");

        jTextFieldTileFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldTileFileActionPerformed(evt);
            }
        });
        jTextFieldTileFile.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldTileFileFocusLost(evt);
            }
        });

        jButtonFileSelect1.setText("...");
        jButtonFileSelect1.setMargin(new java.awt.Insets(0, 1, 0, -1));
        jButtonFileSelect1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonFileSelect1ActionPerformed(evt);
            }
        });

        jButtonExport.setText("User Export");
        jButtonExport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExportActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5))
                .addGap(1, 1, 1)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTextFieldKlasse)
                    .addComponent(jTextFieldTileFile, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonFileSelect1)
                    .addComponent(jComboBoxKlasse, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButtonSaveTileSet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButtonNew, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButtonSaveAsNew, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButtonDelete, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(30, 30, 30)
                .addComponent(jButtonExport)
                .addGap(220, 220, 220))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButtonDelete)
                                .addComponent(jButtonExport))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButtonSaveTileSet)
                                .addComponent(jButtonSaveAsNew)))
                        .addComponent(jButtonNew))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldTileFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5)
                            .addComponent(jButtonFileSelect1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTextFieldKlasse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel4))
                            .addComponent(jComboBoxKlasse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder("Image data"));

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jTextFieldGraphicsIMageCount.setEditable(false);

        jLabel7.setText("Width");

        jLabel8.setText("Height");

        jTextFieldGraphicsHeight.setEditable(false);

        jLabel6.setText("Image count");

        jTextFieldGraphicsWidth.setEditable(false);

        jLabel9.setText("Delay");

        jTextFieldGraphicsDelay.setEditable(false);

        jLabel22.setText("(max size)");

        jLabel23.setText("(max size)");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8))
                .addGap(40, 40, 40)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jTextFieldGraphicsHeight, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel23))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jTextFieldGraphicsWidth, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel22)))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextFieldGraphicsIMageCount, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldGraphicsDelay, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldGraphicsHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel23))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldGraphicsWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel22))
                .addGap(109, 109, 109))
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldGraphicsIMageCount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTextFieldGraphicsDelay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel1.setText("Image-File");

        jLabel2.setText("Class");

        jComboBoxNameGraphic.setEnabled(false);
        jComboBoxNameGraphic.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxNameGraphicActionPerformed(evt);
            }
        });

        jComboBoxKlasseGraphic.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxKlasseGraphicActionPerformed(evt);
            }
        });

        jTextFieldGraphicFile.setToolTipText("A xml- file which holds graphics data  information as provided by images-resourcer.");
        jTextFieldGraphicFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldGraphicFileActionPerformed(evt);
            }
        });
        jTextFieldGraphicFile.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldGraphicFileFocusLost(evt);
            }
        });

        jLabel3.setText("Name");

        jCheckBoxScaled.setText("scaled");
        jCheckBoxScaled.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxScaledActionPerformed(evt);
            }
        });

        jScrollPane5.setPreferredSize(new java.awt.Dimension(106, 106));

        imageComponent1.setPreferredSize(new java.awt.Dimension(102, 102));

        javax.swing.GroupLayout imageComponent1Layout = new javax.swing.GroupLayout(imageComponent1);
        imageComponent1.setLayout(imageComponent1Layout);
        imageComponent1Layout.setHorizontalGroup(
            imageComponent1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 104, Short.MAX_VALUE)
        );
        imageComponent1Layout.setVerticalGroup(
            imageComponent1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 104, Short.MAX_VALUE)
        );

        jScrollPane5.setViewportView(imageComponent1);

        jButtonFileSelect2.setText("...");
        jButtonFileSelect2.setMargin(new java.awt.Insets(0, 1, 0, -1));
        jButtonFileSelect2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonFileSelect2ActionPerformed(evt);
            }
        });

        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        jPanelIMageCollection.setMinimumSize(new java.awt.Dimension(15, 62));
        jPanelIMageCollection.setLayout(new java.awt.FlowLayout(3));

        jPanel13.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel13.setPreferredSize(new java.awt.Dimension(52, 52));

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 50, Short.MAX_VALUE)
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 50, Short.MAX_VALUE)
        );

        jPanelIMageCollection.add(jPanel13);

        jPanel15.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel15.setPreferredSize(new java.awt.Dimension(52, 52));

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 50, Short.MAX_VALUE)
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 50, Short.MAX_VALUE)
        );

        jPanelIMageCollection.add(jPanel15);

        jScrollPane2.setViewportView(jPanelIMageCollection);

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel14Layout.createSequentialGroup()
                                .addGap(26, 26, 26)
                                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel3)))
                            .addGroup(jPanel14Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(jCheckBoxScaled)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jComboBoxNameGraphic, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(jPanel14Layout.createSequentialGroup()
                                .addComponent(jTextFieldGraphicFile, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonFileSelect2))
                            .addComponent(jComboBoxKlasseGraphic, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(12, 12, 12)
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane2)))
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel14Layout.createSequentialGroup()
                                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1)
                                    .addComponent(jTextFieldGraphicFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButtonFileSelect2))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jComboBoxKlasseGraphic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jComboBoxNameGraphic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jCheckBoxScaled))
                            .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel14Layout.createSequentialGroup()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanel16.setBorder(javax.swing.BorderFactory.createTitledBorder("Sprite Collection"));
        jPanel16.setAlignmentX(1.0F);

        jScrollPane9.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane9.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        jPanelIMageCollection1.setMinimumSize(new java.awt.Dimension(20, 20));
        jPanelIMageCollection1.setLayout(null);

        jPanel17.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel17.setPreferredSize(new java.awt.Dimension(52, 52));

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 50, Short.MAX_VALUE)
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 50, Short.MAX_VALUE)
        );

        jPanelIMageCollection1.add(jPanel17);
        jPanel17.setBounds(5, 5, 52, 52);

        jScrollPane9.setViewportView(jPanelIMageCollection1);

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane9)
        );

        jTabbedPane1.setAlignmentY(1.0F);

        jLabel14.setText("Name");

        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder("Attributes"));

        jComboBoxAttributeType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Integer", "Boolean", "String" }));

        jComboBoxAttributeName.setEditable(true);

        jLabel11.setText("Name");

        jLabel12.setText("Type");

        jLabel13.setText("Value");

        jButtonAddOneAttribute.setText("Add");
        jButtonAddOneAttribute.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAddOneAttributeActionPerformed(evt);
            }
        });

        jButtonNewAttribute.setText("New");
        jButtonNewAttribute.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNewAttributeActionPerformed(evt);
            }
        });

        jButtonDeleteSelectedAttributes.setText("Delete selection");
        jButtonDeleteSelectedAttributes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDeleteSelectedAttributesActionPerformed(evt);
            }
        });

        jTableAttributeTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane8.setViewportView(jTableAttributeTable);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 496, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)
        );

        jButtonSaveAttributeBundle.setText("Save as Attribute bundle");
        jButtonSaveAttributeBundle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaveAttributeBundleActionPerformed(evt);
            }
        });

        jComboBoxAttribute.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBoxAttribute.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxAttributeActionPerformed(evt);
            }
        });

        jLabel10.setText("Attribute bundle");

        jButtonReplaceAttribute.setText("Replace");
        jButtonReplaceAttribute.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonReplaceAttributeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jComboBoxAttributeName, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextFieldAttributeValue)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jComboBoxAttributeType, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jButtonAddOneAttribute)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonReplaceAttribute))
                    .addComponent(jButtonNewAttribute))
                .addContainerGap())
            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addComponent(jButtonDeleteSelectedAttributes)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 190, Short.MAX_VALUE)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBoxAttribute, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextFieldAttributeBundleName, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonSaveAttributeBundle))
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jComboBoxAttributeName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(jComboBoxAttributeType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonAddOneAttribute)
                    .addComponent(jButtonReplaceAttribute))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jTextFieldAttributeValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonNewAttribute))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButtonDeleteSelectedAttributes)
                        .addComponent(jButtonSaveAttributeBundle)
                        .addComponent(jTextFieldAttributeBundleName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel10))
                    .addComponent(jComboBoxAttribute, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jLabel15.setText("ID ");

        jLabel16.setText("Description");

        jTextAreaDescription.setColumns(20);
        jTextAreaDescription.setLineWrap(true);
        jTextAreaDescription.setRows(3);
        jTextAreaDescription.setTabSize(4);
        jTextAreaDescription.setWrapStyleWord(true);
        jScrollPane7.setViewportView(jTextAreaDescription);

        jTextFieldGraphicsHeightTile.setToolTipText("If size is not the same as graphic, the grafix will be scaled to this size!");

        jTextFieldGraphicsWidthTile.setToolTipText("If size is not the same as graphic, the grafix will be scaled to this size!");

        jLabel19.setText("height");

        jLabel20.setText("width");

        jCheckBoxForceTileSize.setText("Force");
        jCheckBoxForceTileSize.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxForceTileSizeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldTileName, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(4, 4, 4)
                        .addComponent(jLabel15))
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldTileID, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(116, 116, 116)
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldGraphicsHeightTile, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel20)
                .addGap(1, 1, 1)
                .addComponent(jTextFieldGraphicsWidthTile, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCheckBoxForceTileSize)
                .addGap(79, 79, 79))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addGap(22, 22, 22))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(jTextFieldTileName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15)
                            .addComponent(jTextFieldTileID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel16))
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextFieldGraphicsHeightTile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jCheckBoxForceTileSize)
                        .addComponent(jTextFieldGraphicsWidthTile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel20)
                        .addComponent(jLabel19)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Sprite base data", jPanel4);

        jComboBoxAction.setEditable(true);
        jComboBoxAction.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Stand", "Walk", "Talk", "Run", "Attack", "Been Hit", "Die", "Shoot", "Paused", "Shoot", "Running", "Stopped" }));
        jComboBoxAction.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxActionActionPerformed(evt);
            }
        });

        jLabel127.setText("Action");

        jPanelNW.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanelNW.setName("nw"); // NOI18N
        jPanelNW.setPreferredSize(new java.awt.Dimension(40, 40));

        javax.swing.GroupLayout jPanelNWLayout = new javax.swing.GroupLayout(jPanelNW);
        jPanelNW.setLayout(jPanelNWLayout);
        jPanelNWLayout.setHorizontalGroup(
            jPanelNWLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );
        jPanelNWLayout.setVerticalGroup(
            jPanelNWLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );

        jPanelN.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanelN.setName("n"); // NOI18N
        jPanelN.setPreferredSize(new java.awt.Dimension(40, 40));

        javax.swing.GroupLayout jPanelNLayout = new javax.swing.GroupLayout(jPanelN);
        jPanelN.setLayout(jPanelNLayout);
        jPanelNLayout.setHorizontalGroup(
            jPanelNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );
        jPanelNLayout.setVerticalGroup(
            jPanelNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );

        jPanelNE.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanelNE.setName("ne"); // NOI18N
        jPanelNE.setPreferredSize(new java.awt.Dimension(40, 40));

        javax.swing.GroupLayout jPanelNELayout = new javax.swing.GroupLayout(jPanelNE);
        jPanelNE.setLayout(jPanelNELayout);
        jPanelNELayout.setHorizontalGroup(
            jPanelNELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );
        jPanelNELayout.setVerticalGroup(
            jPanelNELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );

        jPanelW.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanelW.setName("w"); // NOI18N
        jPanelW.setPreferredSize(new java.awt.Dimension(40, 40));

        javax.swing.GroupLayout jPanelWLayout = new javax.swing.GroupLayout(jPanelW);
        jPanelW.setLayout(jPanelWLayout);
        jPanelWLayout.setHorizontalGroup(
            jPanelWLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );
        jPanelWLayout.setVerticalGroup(
            jPanelWLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );

        jPanelE.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanelE.setName("e"); // NOI18N
        jPanelE.setPreferredSize(new java.awt.Dimension(40, 40));

        javax.swing.GroupLayout jPanelELayout = new javax.swing.GroupLayout(jPanelE);
        jPanelE.setLayout(jPanelELayout);
        jPanelELayout.setHorizontalGroup(
            jPanelELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );
        jPanelELayout.setVerticalGroup(
            jPanelELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );

        jPanelSE.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanelSE.setName("se"); // NOI18N
        jPanelSE.setPreferredSize(new java.awt.Dimension(40, 40));

        javax.swing.GroupLayout jPanelSELayout = new javax.swing.GroupLayout(jPanelSE);
        jPanelSE.setLayout(jPanelSELayout);
        jPanelSELayout.setHorizontalGroup(
            jPanelSELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );
        jPanelSELayout.setVerticalGroup(
            jPanelSELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );

        jPanelC.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanelC.setName("c"); // NOI18N
        jPanelC.setPreferredSize(new java.awt.Dimension(40, 40));

        javax.swing.GroupLayout jPanelCLayout = new javax.swing.GroupLayout(jPanelC);
        jPanelC.setLayout(jPanelCLayout);
        jPanelCLayout.setHorizontalGroup(
            jPanelCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );
        jPanelCLayout.setVerticalGroup(
            jPanelCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );

        jPanelSW.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanelSW.setName("sw"); // NOI18N
        jPanelSW.setPreferredSize(new java.awt.Dimension(40, 40));

        javax.swing.GroupLayout jPanelSWLayout = new javax.swing.GroupLayout(jPanelSW);
        jPanelSW.setLayout(jPanelSWLayout);
        jPanelSWLayout.setHorizontalGroup(
            jPanelSWLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );
        jPanelSWLayout.setVerticalGroup(
            jPanelSWLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );

        jPanelS.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanelS.setName("s"); // NOI18N
        jPanelS.setPreferredSize(new java.awt.Dimension(40, 40));

        javax.swing.GroupLayout jPanelSLayout = new javax.swing.GroupLayout(jPanelS);
        jPanelS.setLayout(jPanelSLayout);
        jPanelSLayout.setHorizontalGroup(
            jPanelSLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );
        jPanelSLayout.setVerticalGroup(
            jPanelSLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );

        jLabel128.setText("selected animation");

        jCheckBoxAbsolutSteps.setSelected(true);
        jCheckBoxAbsolutSteps.setText("Steps absolut");
        jCheckBoxAbsolutSteps.setToolTipText("Steps absolut or in regard to scaling of image!");

        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel2.setPreferredSize(new java.awt.Dimension(140, 140));

        javax.swing.GroupLayout mapPanelLayout = new javax.swing.GroupLayout(mapPanel);
        mapPanel.setLayout(mapPanelLayout);
        mapPanelLayout.setHorizontalGroup(
            mapPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 138, Short.MAX_VALUE)
        );
        mapPanelLayout.setVerticalGroup(
            mapPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 138, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mapPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mapPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jLabel17.setText("animation test:");

        jButton1.setText("reset");

        jScrollPane3.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        jPanel3.setMinimumSize(new java.awt.Dimension(100, 96));
        jPanel3.setPreferredSize(new java.awt.Dimension(476, 96));
        jPanel3.setLayout(null);
        jPanel3.add(animationStepPanel1);
        animationStepPanel1.setBounds(0, 0, 52, 84);

        jScrollPane3.setViewportView(jPanel3);

        jLabel129.setText("Subsequent Action");

        jComboBoxAction1.setEditable(true);
        jComboBoxAction1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Stand", "Walk", "Talk", "Run", "Attack", "Been Hit", "Die", "Shoot", "Paused", "Shoot", "Running", "Stopped" }));
        jComboBoxAction1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxAction1ActionPerformed(evt);
            }
        });

        jCheckBox2.setText("no subsequent action - loop!");
        jCheckBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox2ActionPerformed(evt);
            }
        });

        jButton2.setText("Try auto actions");
        jButton2.setToolTipText("<html>\nIf this is pressed, the current image data is searched for names, <BR>\nwhich have \"_ACTION\" and \"_DIRECTION\" in its name.<BR>\nIf encountered, the corresponding images are set to corresponding action/directions.\n</html>\n");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton4.setText("remove selected");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jCheckBox3.setText("Out of Bounds");

        jCheckBoxAutoMovment.setSelected(true);
        jCheckBoxAutoMovment.setText("enable automatic movement");
        jCheckBoxAutoMovment.setToolTipText("<html>\nIf checked, the sprite will be moved according to its animation delta settings, when an action is executed.<BR>\nMeaning its coordinates are updated.\n</html>\n");

        jCheckBoxUpdateWhenNotInViewport.setSelected(true);
        jCheckBoxUpdateWhenNotInViewport.setText("enable updates when not in viewport");
        jCheckBoxUpdateWhenNotInViewport.setToolTipText("<html>\nIf checked, the sprite data and appearance will be updated, even if not currently visible.<BR>\nIf not checked, the sprite will cease to have updates when not visble.\n</html>\n");

        jCheckBoxBackShadow.setText("back shadows");
        jCheckBoxBackShadow.setToolTipText("In order for changes to have an effect, press \"add sprite\" once (This resets the current image data).");

        jTextFieldBackThick.setText("1");
        jTextFieldBackThick.setToolTipText("");

        jLabel18.setText("Thickness:");

        jLabel21.setText("Antialiase:");
        jLabel21.setToolTipText("");

        jTextFieldBackAliase.setText("3");
        jTextFieldBackAliase.setToolTipText("");

        jLabel24.setText("RGB:");

        jTextFieldBack_R.setText("0");
        jTextFieldBack_R.setToolTipText("");

        jTextFieldBack_G.setText("0");
        jTextFieldBack_G.setToolTipText("");

        jTextFieldBack_B.setText("0");
        jTextFieldBack_B.setToolTipText("");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel129)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addGap(49, 49, 49)
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jCheckBox2)
                                    .addComponent(jComboBoxAction1, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel7Layout.createSequentialGroup()
                                        .addComponent(jLabel21)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jTextFieldBackAliase, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel7Layout.createSequentialGroup()
                                        .addComponent(jLabel18)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jTextFieldBackThick, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(3, 3, 3)
                                .addComponent(jLabel24)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldBack_R, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jCheckBoxAutoMovment)
                            .addComponent(jCheckBoxAbsolutSteps)
                            .addComponent(jCheckBoxUpdateWhenNotInViewport)
                            .addComponent(jCheckBoxBackShadow))
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 64, Short.MAX_VALUE)
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel17)
                                    .addComponent(jButton1)
                                    .addComponent(jCheckBox3))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldBack_G, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldBack_B, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(38, 38, 38))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel127)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboBoxAction, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jPanelW, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanelNW, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jPanelN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanelC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPanelSE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanelNE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanelE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(jPanelSW, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jPanelS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel128)
                                    .addComponent(jButton2))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(jButton4)
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addContainerGap())))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel127)
                                .addComponent(jComboBoxAction, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                                .addComponent(jLabel128)
                                .addGap(1, 1, 1)))
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jPanelNW, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanelN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanelNE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel7Layout.createSequentialGroup()
                                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jPanelW, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jPanelC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel7Layout.createSequentialGroup()
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jPanelSW, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel7Layout.createSequentialGroup()
                                                .addGap(6, 6, 6)
                                                .addComponent(jPanelS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                    .addGroup(jPanel7Layout.createSequentialGroup()
                                        .addComponent(jPanelE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jPanelSE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addGap(38, 38, 38)
                                .addComponent(jButton2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton4))))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(jLabel17)
                                .addGap(9, 9, 9)
                                .addComponent(jButton1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jCheckBox3))
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jLabel129)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxAction1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox2))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jCheckBoxAbsolutSteps)
                        .addGap(5, 5, 5)
                        .addComponent(jCheckBoxAutoMovment)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBoxUpdateWhenNotInViewport)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBoxBackShadow)
                        .addGap(3, 3, 3)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel18)
                            .addComponent(jTextFieldBackThick, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel24)
                            .addComponent(jTextFieldBack_R, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldBack_G, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldBack_B, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel21)
                            .addComponent(jTextFieldBackAliase, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(35, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Actions & Animations", jPanel7);

        lateBorderPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Test"));

        jButton5.setText("jButton5");

        jButton6.setText("jButton6");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout lateBorderPanel2Layout = new javax.swing.GroupLayout(lateBorderPanel2);
        lateBorderPanel2.setLayout(lateBorderPanel2Layout);
        lateBorderPanel2Layout.setHorizontalGroup(
            lateBorderPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, lateBorderPanel2Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jButton6))
            .addGroup(lateBorderPanel2Layout.createSequentialGroup()
                .addGroup(lateBorderPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton5)
                    .addGroup(lateBorderPanel2Layout.createSequentialGroup()
                        .addGap(140, 140, 140)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        lateBorderPanel2Layout.setVerticalGroup(
            lateBorderPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lateBorderPanel2Layout.createSequentialGroup()
                .addGroup(lateBorderPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(lateBorderPanel2Layout.createSequentialGroup()
                        .addComponent(jButton5)
                        .addGap(36, 36, 36)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 71, Short.MAX_VALUE)
                .addComponent(jButton6))
        );

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addComponent(lateBorderPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(341, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(lateBorderPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(119, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("tab3", jPanel8);

        jButtonRemoveOneTile.setText("remove sprite");
        jButtonRemoveOneTile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRemoveOneTileActionPerformed(evt);
            }
        });

        jButtonNewTile.setText("new sprite");
        jButtonNewTile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNewTileActionPerformed(evt);
            }
        });

        jButtonAddOneTile.setText("add sprite");
        jButtonAddOneTile.setToolTipText("Adds tile to current list. Replaces if Name is the same!");
        jButtonAddOneTile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAddOneTileActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jButtonRemoveOneTile, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonAddOneTile, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonNewTile, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonAddOneTile)
                        .addGap(6, 6, 6)
                        .addComponent(jButtonRemoveOneTile)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonNewTile))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTabbedPane1))))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewActionPerformed
        mClassSetting++;
        mAllSpritesInClass = new Vector <SpriteData>();
        clearAll();
        resetConfigPool(false, "", "");
        mClassSetting--;
}//GEN-LAST:event_jButtonNewActionPerformed

    private void showMessage(String title, String message)
    {
        ShowInfoDialog.showInfoDialog(title, message);
    }
    private void jButtonSaveTileSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveTileSetActionPerformed

        if (jTextFieldTileFile.getText().trim().length()==0)
        {   
            showMessage("Not Saved!", "No filename given!");
            return;
        }

        if (jTextFieldKlasse.getText().trim().length()==0)
        {   
            showMessage("Not Saved!", "No class name given!");
            return;
        }

        if (mSpriteDataPool == null)
        {
            mSpriteDataPool = new SpriteDataPool("Sprite"+File.separator+jTextFieldTileFile.getText().trim()+".xml", true);
        }
        else
        {
            if (!mSpriteDataPool.getFilename().equals("Sprite"+File.separator+jTextFieldTileFile.getText().trim()+".xml"))
            {
                mSpriteDataPool = new SpriteDataPool("Sprite"+File.separator+jTextFieldTileFile.getText().trim()+".xml", true);
            }
        }

        // starting really fresh
        if (mCurrentSprite == null)
        {
            mCurrentSprite = Sprite.buildSprite(new SpriteData());
        }

        
        String action = "";
        String direction = "";
        if (currentSelectedAnimationImagePanel!= null)
        {
            int x=0;
            int y=0;
            Object see = jComboBoxAction.getEditor().getItem();
            if (see==null) 
                return;
            action = see.toString();
            direction = currentSelectedAnimationImagePanel.getName();
        }
        
        
                
        readCurrentAttributeData();
        readCurrentSpriteInfo();
        readAllToCurrentSpriteSet();
        
        mCurrentSprite.toData();
        
        mCurrentSprite.data.mPoolName = jTextFieldTileFile.getText().trim();

        mSpriteDataPool.put(mCurrentSprite.data); // removes via name old tile, so using a copy here is ok!

        Collection<SpriteData> collectionKlasse = mSpriteDataPool.getHashMap().values();
        Iterator<SpriteData> iter = collectionKlasse.iterator();

        while (iter.hasNext())
        {
            SpriteData item = iter.next();
//            item.mSpriteSetFileName= jTextFieldTileFile.getText().trim();
        }

        mSpriteDataPool.save();
        String name = mCurrentSprite.data.mName;
        resetConfigPool(true, mCurrentSprite.data.mClass, name);
       
        
        selectActionDirection(action, direction);
    }//GEN-LAST:event_jButtonSaveTileSetActionPerformed

    private void jButtonSaveAsNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveAsNewActionPerformed
    }//GEN-LAST:event_jButtonSaveAsNewActionPerformed

    private void jButtonDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteActionPerformed
        readAllToCurrentSpriteSet();

        mSpriteDataPool.remove(mCurrentSprite.data); // remove is done via mCurrentTile.mName, so passing a copy of original here is ok
        mSpriteDataPool.save();

        mClassSetting++;
        String klasse = jTextFieldKlasse.getText();
        resetConfigPool(true,klasse, "");
        //clearTileData();
        mClassSetting--;
}//GEN-LAST:event_jButtonDeleteActionPerformed

    private void jComboBoxKlasseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxKlasseActionPerformed
        if (mClassSetting >0 ) return;
        mClassSetting++;

        String selected = jComboBoxKlasse.getSelectedItem().toString();
        int ind = jComboBoxKlasse.getSelectedIndex();
        clearAll();

        jComboBoxKlasse.setSelectedIndex(ind);
        resetConfigPool(true, selected, "");
        jTextFieldKlasse.setText(selected);

        mClassSetting--;
    }//GEN-LAST:event_jComboBoxKlasseActionPerformed

    private void jTextFieldTileFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldTileFileActionPerformed
        
        loadSpriteCollection();
    }//GEN-LAST:event_jTextFieldTileFileActionPerformed

    private void jTextFieldTileFileFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldTileFileFocusLost
        // if enabled, switching to another tab also loses focus
        //jTextFieldTileFileActionPerformed(null);
    }//GEN-LAST:event_jTextFieldTileFileFocusLost

    private void jButtonFileSelect1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFileSelect1ActionPerformed
        InternalFrameFileChoser fc = new csa.gui.dialogs.InternalFrameFileChoser();
        fc.setCurrentDirectory(new java.io.File("xml"+File.separator+"Sprite"));
        FileNameExtensionFilter  filter = new  FileNameExtensionFilter("xml", "xml");
        fc.setFileFilter(filter);
        int r = fc.showOpenDialog(Configuration.getConfiguration().getMainFrame());
        if (r != InternalFrameFileChoser.APPROVE_OPTION) return;
        String name = fc.getSelectedFile().getName();
        jTextFieldTileFile.setText(csa.util.UtilityString.replace(name, ".xml",""));
        jTextFieldTileFileActionPerformed(null);
    }//GEN-LAST:event_jButtonFileSelect1ActionPerformed

    private void jComboBoxNameGraphicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxNameGraphicActionPerformed
        if (!getGraphicPool()) {
            return;
        }
        if (mClassSetting > 0) {
            return;
        }
        String key = jComboBoxNameGraphic.getSelectedItem().toString();
        mData = mImageSequenceDataPool.get(key);
        setGraphicsDataFromCurrent();
    }//GEN-LAST:event_jComboBoxNameGraphicActionPerformed

    private void jComboBoxKlasseGraphicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxKlasseGraphicActionPerformed
        if (!getGraphicPool()) {
            return;
        }
        if (mClassSetting > 0) {
            return;
        }
        mClassSetting++;

        String selected = jComboBoxKlasseGraphic.getSelectedItem().toString();
        clearGraphicsData();
        removeAllGraphics(false);

        resetGraphicsPool(true, selected, "");
        setAllGraphics();



        jComboBoxNameGraphic.setSelectedIndex(-1);
        mClassSetting--;
    }//GEN-LAST:event_jComboBoxKlasseGraphicActionPerformed

    private void jTextFieldGraphicFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldGraphicFileActionPerformed
        mClassSetting++;
        jComboBoxKlasseGraphic.removeAllItems();
        jComboBoxNameGraphic.removeAllItems();
        setPoolOnly();
        mClassSetting--;
    }//GEN-LAST:event_jTextFieldGraphicFileActionPerformed

    private void jTextFieldGraphicFileFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldGraphicFileFocusLost
        jTextFieldGraphicFileActionPerformed(null);
    }//GEN-LAST:event_jTextFieldGraphicFileFocusLost

    private void jCheckBoxScaledActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxScaledActionPerformed
        imageComponent1.setScaled(jCheckBoxScaled.isSelected(), 100, 100);
    }//GEN-LAST:event_jCheckBoxScaledActionPerformed

    private void jButtonFileSelect2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFileSelect2ActionPerformed

        InternalFrameFileChoser fc = new csa.gui.dialogs.InternalFrameFileChoser();
        fc.setCurrentDirectory(new java.io.File("xml" + File.separator + "Graphics"));
        FileNameExtensionFilter filter = new FileNameExtensionFilter("xml", "xml");
        fc.setFileFilter(filter);
        int r = fc.showOpenDialog(Configuration.getConfiguration().getMainFrame());
        if (r != InternalFrameFileChoser.APPROVE_OPTION) {
            return;
        }
        String name = fc.getSelectedFile().getName();
        jTextFieldGraphicFile.setText(csa.util.UtilityString.replace(name, ".xml", ""));
        jTextFieldGraphicFileActionPerformed(null);
    }//GEN-LAST:event_jButtonFileSelect2ActionPerformed

    private void jButtonAddOneAttributeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddOneAttributeActionPerformed
        readCurrentAttributeData();
        jComboBoxAttributeName.setSelectedItem(null);
        jTextFieldAttributeValue.setText("");
    }//GEN-LAST:event_jButtonAddOneAttributeActionPerformed

    private void jButtonNewAttributeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewAttributeActionPerformed
        mCurrentAttributeData = new SpriteAttribute();
        setCurrentAttributeData();

    }//GEN-LAST:event_jButtonNewAttributeActionPerformed

    private void jButtonDeleteSelectedAttributesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteSelectedAttributesActionPerformed


        int[] rows = csaPanel.getTable().getSelectedRows();
        if (rows.length == 0) {
            return;
        }

        Vector<SpriteAttribute> toDelete = new Vector<SpriteAttribute>();
        for (int i = rows.length - 1; i >= 0; i--) {
            int sel = csaPanel.convertRowIndexToModel(rows[i]);
            SpriteAttribute attr = mAttributeData.elementAt(sel);
            toDelete.addElement(attr);
        }

        for (int i = 0; i < toDelete.size(); i++) {
            SpriteAttribute id = toDelete.elementAt(i);
            mAttributeData.removeElement(id);
        }

        csaPanel.deleteSelected();
        SpriteAttribute.fillSprite(mAttributeData, mCurrentSprite.data);
    }//GEN-LAST:event_jButtonDeleteSelectedAttributesActionPerformed

    private void jButtonAddOneTileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddOneTileActionPerformed
        String action = "";
        String direction = "";
        if (currentSelectedAnimationImagePanel!= null)
        {
            int x=0;
            int y=0;
            Object see = jComboBoxAction.getEditor().getItem();
            if (see==null) 
                return;
            action = see.toString();
            direction = currentSelectedAnimationImagePanel.getName();
        }
        readCurrentSpriteInfo();
        SpriteAttribute.fillSprite(mAttributeData, mCurrentSprite.data);
        readMovementToSprite();
        
        mCurrentSprite.toData();
        addSprite(mCurrentSprite.data);
        resetSpriteList(mCurrentSprite.data.mName);
        
        
        selectActionDirection(action, direction);
        
    }//GEN-LAST:event_jButtonAddOneTileActionPerformed

    private void jCheckBoxForceTileSizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxForceTileSizeActionPerformed
        readCurrentSpriteInfo();
        setSpriteView();
    }//GEN-LAST:event_jCheckBoxForceTileSizeActionPerformed

    private void jButtonRemoveOneTileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRemoveOneTileActionPerformed
        mSpriteDataPool.remove(mCurrentSprite.data); // remove geht über name!
        mCurrentSprite = Sprite.buildSprite(new SpriteData());
        resetSpriteList("");
    }//GEN-LAST:event_jButtonRemoveOneTileActionPerformed

    private void jButtonNewTileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewTileActionPerformed
        mCurrentSprite = Sprite.buildSprite(new SpriteData());
        
        jComboBoxAction.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Stand", "Walk", "Talk", "Run", "Attack", "Been Hit", "Die", "Shoot", "Paused", "Shoot", "Running", "Stopped" }));
        jComboBoxAction1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Stand", "Walk", "Talk", "Run", "Attack", "Been Hit", "Die", "Shoot", "Paused", "Shoot", "Running", "Stopped" }));
        setCurrentSpriteInfo();

    }//GEN-LAST:event_jButtonNewTileActionPerformed

    private void jButtonSaveAttributeBundleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveAttributeBundleActionPerformed

        readAllAttribute();
        
        mAttributeBundleDataPool.put(mAttributeBundleData);
        mAttributeBundleDataPool.save();
        mClassSetting++;
        resetAttributePool();
        
        jComboBoxAttribute.setSelectedItem(mAttributeBundleData.mName);
        mClassSetting--;
    }//GEN-LAST:event_jButtonSaveAttributeBundleActionPerformed

    private void jComboBoxAttributeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxAttributeActionPerformed

        if (mClassSetting>0) return;
        if (jComboBoxAttribute.getSelectedIndex() == -1) return;
        String name = jComboBoxAttribute.getSelectedItem().toString();
        if (name.trim().length()==0) return;

        AttributeBundleData aData = mAttributeBundleDataPool.get(name);

        for(int i=0; i < aData.mAtrributeName.size(); i++)
        {
            SpriteAttribute ta  = new SpriteAttribute();

            ta.name = aData.mAtrributeName.elementAt(i);
            ta.type = aData.mAttributeType.elementAt(i);

            ta.setSVal(aData.mAttributeValue.elementAt(i), ta.type);

            mAttributeData.addElement(ta);
        }
        resetAttributeTable();
    }//GEN-LAST:event_jComboBoxAttributeActionPerformed

    private void jButtonExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExportActionPerformed

        String klasse = jTextFieldKlasse.getText().trim();
        if (klasse.length() == 0) {
            return;
        }

        ExportFrame exportFrame = new ExportFrame(mAllSpritesInClass);

        exportFrame.setVisible(true);


    }//GEN-LAST:event_jButtonExportActionPerformed

    private void jButtonReplaceAttributeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonReplaceAttributeActionPerformed

        mAttributeData.remove(mCurrentAttributeData);
        readCurrentAttributeData();
        jComboBoxAttributeName.setSelectedItem(null);
        jTextFieldAttributeValue.setText("");
    }//GEN-LAST:event_jButtonReplaceAttributeActionPerformed

    
    
    private void jComboBoxActionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxActionActionPerformed
//        if (mClassSetting>0) return;
        if (inSetting>0) return;
        Object see = jComboBoxAction.getEditor().getItem();
        if (see==null) 
            return;
        String action = see.toString();

        selectActionDirection(action,  "");
    }//GEN-LAST:event_jComboBoxActionActionPerformed

    private void jComboBoxAction1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxAction1ActionPerformed
        if (mClassSetting>0) return;
        if (jComboBoxAction1.getSelectedIndex() == -1) return;
        //if (jComboBoxAction.getSelectedIndex() == -1) return;
        Object see = jComboBoxAction.getEditor().getItem();
        if (see==null) 
            return;
        String action = see.toString();
 
        mCurrentSprite.setSubsequentAction(action, jComboBoxAction1.getSelectedItem().toString());
    }//GEN-LAST:event_jComboBoxAction1ActionPerformed

    private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox2ActionPerformed
        if (mClassSetting>0) return;

        Object see = jComboBoxAction.getEditor().getItem();
        if (see==null) 
            return;
        String action = see.toString();
        
        mCurrentSprite.setActionLoop(action, jCheckBox2.isSelected());
    }//GEN-LAST:event_jCheckBox2ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        int actionSize = jComboBoxAction.getModel().getSize();
        String[] actions = new String[actionSize];
        String[] directions = {"n", "s", "w", "e", "c", "ne", "nw", "sw", "se"};
        
        
        String actionNow=""; 
        Object see = jComboBoxAction.getEditor().getItem();
        if (see==null) 
            return;
        actionNow = see.toString();
        
        for (int i=0;i<actionSize; i++)
        {
            actions[i] = jComboBoxAction.getModel().getElementAt(i).toString();
            if (actions[i].equals(actionNow)) actionNow = null;
        }
        if (actionNow != null)
        {
            actions = new String[actionSize+1];
            actions[0] = actionNow;
            for (int i=0;i<actionSize; i++)
            {
                actions[i+1] = jComboBoxAction.getModel().getElementAt(i).toString();
            }
        }
        
        
        for (int a = 0; a<actions.length; a++)
        {
            String action = actions[a].toUpperCase();
            boolean actionDone = false;
            for (int d = 0; d<directions.length; d++)
            {
                String direction = directions[d].toUpperCase();
                String composite = action+"_"+direction;
                ImageSequenceData iSData = getISData(composite);
                if (iSData==null) continue;
                actionDone = true;
                mCurrentSprite.addReplaceImage(actions[a], directions[d], jTextFieldGraphicFile.getText(), iSData);
            }
            if (!actionDone)
            {
                action+="ING";
                for (int d = 0; d<directions.length; d++)
                {
                    String direction = directions[d].toUpperCase();
                    String composite = action+"_"+direction;
                    // and again
                    ImageSequenceData iSData = getISData(composite);
                     if (iSData==null) continue;
                     actionDone = true;
                     mCurrentSprite.addReplaceImage(actions[a], directions[d], jTextFieldGraphicFile.getText(), iSData);
                }
            }
        }
        jButtonAddOneTileActionPerformed(null);                                                  
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // remove animation
        // if last -> remove action!
                
        if (currentSelectedAnimationImagePanel.getComponentCount()<= 0) return;
        Component bla = currentSelectedAnimationImagePanel.getComponent(0);
        if (!(bla instanceof ImageComponent)) return;
        ImageComponent ic = (ImageComponent) bla;
        
        ImageSequence is = ic.getSequence();
        if (is == null) return;
        
        Object see = jComboBoxAction.getEditor().getItem();
        if (see==null) 
            return;
        String action = see.toString();
        String direction = currentSelectedAnimationImagePanel.getName();

        boolean lastdirection = mCurrentSprite.removeImage(action, direction);
        if (lastdirection)
        {
            mClassSetting++;
            mCurrentSprite.removeAction(action);
            jComboBoxAction1.removeItem(action);
            jComboBoxAction.removeItem(action);
            mClassSetting--;
            jButtonAddOneTileActionPerformed(null);
        }
        else
        {
            jComboBoxActionActionPerformed(null);
        }
        
    }//GEN-LAST:event_jButton4ActionPerformed
    private ImageSequenceData getISData(String composite)
    {
        if (!getGraphicPool()) return null;
        if (mImageSequenceDataPool == null) return null;
        String klasse = "";
        if (jComboBoxKlasseGraphic.getSelectedIndex() < 0) return null;
        klasse = (String) jComboBoxKlasseGraphic.getSelectedItem();
        if (klasse.length()==0) return null;

        
	HashMap<String, ImageSequenceData> map = mImageSequenceDataPool.getMapForKlasse(klasse);
        
        Set entries = map.entrySet();
        Iterator it = entries.iterator();
        while (it.hasNext())
        {
            Map.Entry entry = (Map.Entry) it.next();
            ImageSequenceData value = (ImageSequenceData) entry.getValue();
            String key = (String) entry.getKey();
            if (key.toUpperCase().endsWith(composite))
            {
                return value;
            }
        }
        return null;
    }

    void setToPanel(JPanel panel, ImageSequenceData iData, String imagePoolname)
    {

        panel.removeAll();
        panel.invalidate();
        panel.validate();
        panel.repaint();
        //panel.setName("");
        if (iData==null) return;
        
        String name = "Graphics"+File.separator+imagePoolname+".xml";
        if (name.trim().length() == 0) return;
        boolean mustLoadPool=true;
        if (mImageSequenceDataPool!=null)
            if (mImageSequenceDataPool.getFilename().equals(name)) mustLoadPool = false;
        if (mustLoadPool)
            mImageSequenceDataPool = new ImageSequenceDataPool(name);
        

        //panel.setName(""+tname);
        panel.setPreferredSize(new java.awt.Dimension(40, 40));
        panel.setLayout(new BorderLayout());
        ImageComponent mip = new ImageComponent();

        panel.add(mip, BorderLayout.CENTER);
        mip.setSequence(new ImageSequence(iData));
        panel.setBounds(0, 0, 40, 40);
        mip.setDelay(iData.getDelay());

        mip.setScaled(true, 40, 40);
        mip.setVisible(true);

        
        mip.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mousePressed(java.awt.event.MouseEvent evt) {
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                JComponent c = (JComponent) evt.getSource();
                c = (JComponent) c.getParent();
                JPanel newSelectedImagePanel = (JPanel) c;
                if (newSelectedImagePanel == currentSelectedAnimationImagePanel) return;
                if (currentSelectedAnimationImagePanel != null)
                {
                    currentSelectedAnimationImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                }
                currentSelectedAnimationImagePanel = newSelectedImagePanel;
                currentSelectedAnimationImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(Color.ORANGE));
                selectAnimation(newSelectedImagePanel);
            }
        });
        JPanel newSelectedImagePanel = (JPanel) panel;
        if (currentSelectedAnimationImagePanel != null)
        {
            currentSelectedAnimationImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        }
        currentSelectedAnimationImagePanel = newSelectedImagePanel;
        currentSelectedAnimationImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(Color.ORANGE));
    }
    
    
    void readAllAttribute()
    {
        // allways new - dont overwrite old ones
        mAttributeBundleData = new AttributeBundleData();

        for (int i = 0; i < mAttributeData.size(); i++)
        {
            SpriteAttribute tileAttribute = mAttributeData.elementAt(i);
            mAttributeBundleData.mAtrributeName.addElement(tileAttribute.name);
            mAttributeBundleData.mAttributeType.addElement(tileAttribute.type);
            mAttributeBundleData.mAttributeValue.addElement(tileAttribute.sVal());
        }
        mAttributeBundleData.mClass="ALL";
        mAttributeBundleData.mName=jTextFieldAttributeBundleName.getText();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private csa.tiletools.sprites.AnimationStepPanel animationStepPanel1;
    private csa.tiletools.graphics.ImageComponent imageComponent1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButtonAddOneAttribute;
    private javax.swing.JButton jButtonAddOneTile;
    private javax.swing.JButton jButtonDelete;
    private javax.swing.JButton jButtonDeleteSelectedAttributes;
    private javax.swing.JButton jButtonExport;
    private javax.swing.JButton jButtonFileSelect1;
    private javax.swing.JButton jButtonFileSelect2;
    private javax.swing.JButton jButtonNew;
    private javax.swing.JButton jButtonNewAttribute;
    private javax.swing.JButton jButtonNewTile;
    private javax.swing.JButton jButtonRemoveOneTile;
    private javax.swing.JButton jButtonReplaceAttribute;
    private javax.swing.JButton jButtonSaveAsNew;
    private javax.swing.JButton jButtonSaveAttributeBundle;
    private javax.swing.JButton jButtonSaveTileSet;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JCheckBox jCheckBox3;
    private javax.swing.JCheckBox jCheckBoxAbsolutSteps;
    private javax.swing.JCheckBox jCheckBoxAutoMovment;
    private javax.swing.JCheckBox jCheckBoxBackShadow;
    private javax.swing.JCheckBox jCheckBoxForceTileSize;
    private javax.swing.JCheckBox jCheckBoxScaled;
    private javax.swing.JCheckBox jCheckBoxUpdateWhenNotInViewport;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBoxAction;
    private javax.swing.JComboBox jComboBoxAction1;
    private javax.swing.JComboBox jComboBoxAttribute;
    private javax.swing.JComboBox jComboBoxAttributeName;
    private javax.swing.JComboBox jComboBoxAttributeType;
    private javax.swing.JComboBox jComboBoxKlasse;
    private javax.swing.JComboBox jComboBoxKlasseGraphic;
    private javax.swing.JComboBox jComboBoxNameGraphic;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel127;
    private javax.swing.JLabel jLabel128;
    private javax.swing.JLabel jLabel129;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanelC;
    private javax.swing.JPanel jPanelE;
    private javax.swing.JPanel jPanelIMageCollection;
    private javax.swing.JPanel jPanelIMageCollection1;
    private javax.swing.JPanel jPanelN;
    private javax.swing.JPanel jPanelNE;
    private javax.swing.JPanel jPanelNW;
    private javax.swing.JPanel jPanelS;
    private javax.swing.JPanel jPanelSE;
    private javax.swing.JPanel jPanelSW;
    private javax.swing.JPanel jPanelW;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTableAttributeTable;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextAreaDescription;
    private javax.swing.JTextField jTextFieldAttributeBundleName;
    private javax.swing.JTextField jTextFieldAttributeValue;
    private javax.swing.JTextField jTextFieldBackAliase;
    private javax.swing.JTextField jTextFieldBackThick;
    private javax.swing.JTextField jTextFieldBack_B;
    private javax.swing.JTextField jTextFieldBack_G;
    private javax.swing.JTextField jTextFieldBack_R;
    private javax.swing.JTextField jTextFieldGraphicFile;
    private javax.swing.JTextField jTextFieldGraphicsDelay;
    private javax.swing.JTextField jTextFieldGraphicsHeight;
    private javax.swing.JTextField jTextFieldGraphicsHeightTile;
    private javax.swing.JTextField jTextFieldGraphicsIMageCount;
    private javax.swing.JTextField jTextFieldGraphicsWidth;
    private javax.swing.JTextField jTextFieldGraphicsWidthTile;
    private javax.swing.JTextField jTextFieldKlasse;
    private javax.swing.JTextField jTextFieldTileFile;
    private javax.swing.JTextField jTextFieldTileID;
    private javax.swing.JTextField jTextFieldTileName;
    private csa.gui.panels.LateBorderPanel lateBorderPanel1;
    private csa.gui.panels.LateBorderPanel lateBorderPanel2;
    private csa.tiletools.map.MapPanel mapPanel;
    // End of variables declaration//GEN-END:variables

    public void addSprite(SpriteData sprite)
    {
        String file = jTextFieldTileFile.getText().trim();
        String _class = jTextFieldKlasse.getText().trim();
        if (file.length() == 0) return;
        if (_class.length() == 0) return;
        sprite.mClass = _class;

        if (mSpriteDataPool == null)
        {
            mSpriteDataPool = new SpriteDataPool("Sprite"+File.separator+jTextFieldTileFile.getText().trim()+".xml", false);
        }
        else
        {
            if (!mSpriteDataPool.getFilename().equals("Sprite"+File.separator+jTextFieldTileFile.getText().trim()+".xml"))
            {
                mSpriteDataPool = new SpriteDataPool("Sprite"+File.separator+jTextFieldTileFile.getText().trim()+".xml", false);
            }
        }
        
        if (mSpriteDataPool == null) return;

        mSpriteDataPool.put(sprite);
        readAllToCurrentSpriteSet();
    }

    public void loadSpriteCollection()
    {
        String file = jTextFieldTileFile.getText().trim();
        String _class = jTextFieldKlasse.getText().trim();
        if (file.length() == 0) return;

        mSpriteDataPool = new SpriteDataPool("Sprite"+File.separator+file+".xml");
        if (mSpriteDataPool == null) return;

        resetConfigPool(true, _class, "");
    }
    String getSpriteClass()
    {
        String _class = jTextFieldKlasse.getText().trim();
        return _class;
    }

    SpriteDataPool getPool()
    {
        return mSpriteDataPool;
    }

    void setSpriteView()
    {
        if (mCurrentSprite == null) return;
        
        jCheckBoxForceTileSize.setEnabled(true);
        jButtonFileSelect2.setEnabled(true);
        jTextFieldGraphicFile.setEnabled(true);
        jComboBoxKlasseGraphic.setEnabled(true);
  

        resetAttributeTable();
    }

    void readCurrentSpriteInfo()
    {
         if (mCurrentSprite == null) return;
         mCurrentSprite.data.mName = jTextFieldTileName.getText();
         mCurrentSprite.data.mID = jTextFieldTileID.getText();
         mCurrentSprite.data.mDescription = jTextAreaDescription.getText();
         mCurrentSprite.data.mWidth = UtilityString.Int0(jTextFieldGraphicsWidthTile.getText());
         mCurrentSprite.data.mHeight = UtilityString.Int0(jTextFieldGraphicsHeightTile.getText());
         mCurrentSprite.data.mForceSpriteSize =jCheckBoxForceTileSize.isSelected();
         mCurrentSprite.data.mStepsAbsolut =jCheckBoxAbsolutSteps.isSelected();
         mCurrentSprite.data.mAutomaticMovment =jCheckBoxAutoMovment.isSelected();
         mCurrentSprite.data.mUpdateWhenNotInViewport =jCheckBoxUpdateWhenNotInViewport.isSelected();
         mCurrentSprite.data.mBackShadow =jCheckBoxBackShadow.isSelected();
    
         mCurrentSprite.data.mBackThickness = UtilityString.IntX(jTextFieldBackThick.getText(), 1);
         mCurrentSprite.data.mBackAntialiazing = UtilityString.IntX(jTextFieldBackAliase.getText(), 3);
         mCurrentSprite.data.mBack_R = UtilityString.Int0(jTextFieldBack_R.getText());
         mCurrentSprite.data.mBack_G = UtilityString.Int0(jTextFieldBack_G.getText());
         mCurrentSprite.data.mBack_B = UtilityString.Int0(jTextFieldBack_B.getText());
    }

    
    void setCurrentSpriteInfo()
    {
         if (mCurrentSprite == null) return;

         mAttributeData = SpriteAttribute.getVector(mCurrentSprite.data);

         jTextFieldTileName.setText(mCurrentSprite.data.mName);
         jTextFieldTileID.setText(mCurrentSprite.data.mID);
         jTextAreaDescription.setText(mCurrentSprite.data.mDescription);
         jCheckBoxForceTileSize.setSelected(mCurrentSprite.data.mForceSpriteSize);
         jTextFieldGraphicsHeightTile.setText(""+mCurrentSprite.data.mHeight);
         jTextFieldGraphicsWidthTile.setText(""+mCurrentSprite.data.mWidth);
         jCheckBoxAbsolutSteps.setSelected(mCurrentSprite.data.mStepsAbsolut);
         jCheckBoxAutoMovment.setSelected(mCurrentSprite.data.mAutomaticMovment);
         jCheckBoxUpdateWhenNotInViewport.setSelected(mCurrentSprite.data.mUpdateWhenNotInViewport);
         jCheckBoxBackShadow.setSelected(mCurrentSprite.data.mBackShadow);
    
         if (mCurrentSprite.getActions().size()>0)
         {
            jComboBoxAction.setModel(new DefaultComboBoxModel(mCurrentSprite.getActions()));
            jComboBoxAction1.setModel(new DefaultComboBoxModel(mCurrentSprite.getActions()));
         }
         
         jTextFieldBackThick.setText(""+mCurrentSprite.data.mBackThickness);
         jTextFieldBackAliase.setText(""+mCurrentSprite.data.mBackAntialiazing);
         jTextFieldBack_R.setText(""+mCurrentSprite.data.mBack_R);
         jTextFieldBack_G.setText(""+mCurrentSprite.data.mBack_G);
         jTextFieldBack_B.setText(""+mCurrentSprite.data.mBack_B);
         
         setSpriteView();
         jComboBoxAction.setSelectedIndex(0);
    }

    
    private JPanel currentSelectedAnimationImagePanel = null;
    private void resetAnimationBorders()
    {
        if (currentSelectedAnimationImagePanel != null)
        {
            currentSelectedAnimationImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        }
        currentSelectedAnimationImagePanel = null;
    }
    private void setDirectionAnimation(String tname, JPanel panel, boolean setToData, int number)
    {
        int selectedIndex =jComboBoxAction.getSelectedIndex();
        Object se = jComboBoxAction.getSelectedItem();
        Object see = jComboBoxAction.getEditor().getItem();
        
        
        if (see == null) return;

        // Sets the animation grafics: tName (String), to a animation directionPanel: panel, Panel number:number in direction array
        // a) upon GUI init from data
        // b) from a drag
        //
        // to GUI
        // and to current tile (if neccessary)

        panel.removeAll();
        resetAnimationBorders();
        //panel.setName("");

        if (!getGraphicPool()) return;
        if (mImageSequenceDataPool == null) return;
        String klasse = "";
        if (jComboBoxKlasseGraphic.getSelectedIndex() < 0) return;
        klasse = (String) jComboBoxKlasseGraphic.getSelectedItem();
        if (klasse.length()==0) return;

        ImageSequenceData iSData = mImageSequenceDataPool.get(tname);

        //panel.setName(""+tname);
        panel.setPreferredSize(new java.awt.Dimension(40, 40));
        panel.setLayout(new BorderLayout());
        ImageComponent mip = new ImageComponent();

        panel.add(mip, BorderLayout.CENTER);
        mip.setSequence(new ImageSequence(iSData));
        panel.setBounds(0, 0, 40, 40);
        mip.setDelay(iSData.getDelay());

        mip.setScaled(true, 40, 40);
        mip.setVisible(true);

        
        mip.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mousePressed(java.awt.event.MouseEvent evt) {
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                JComponent c = (JComponent) evt.getSource();
                c = (JComponent) c.getParent();
                JPanel newSelectedImagePanel = (JPanel) c;
                if (newSelectedImagePanel == currentSelectedAnimationImagePanel) return;
                if (currentSelectedAnimationImagePanel != null)
                {
                    currentSelectedAnimationImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                }
                currentSelectedAnimationImagePanel = newSelectedImagePanel;
                currentSelectedAnimationImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(Color.ORANGE));
                selectAnimation(newSelectedImagePanel);
            }
        });
        JPanel newSelectedImagePanel = (JPanel) panel;
        if (currentSelectedAnimationImagePanel != null)
        {
            currentSelectedAnimationImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        }
        currentSelectedAnimationImagePanel = newSelectedImagePanel;
        currentSelectedAnimationImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(Color.ORANGE));
        selectAnimation(newSelectedImagePanel);

        if (setToData)
        {
            String action = see.toString();
            String direction = newSelectedImagePanel.getName();
            mCurrentSprite.addReplaceImage(action, direction, jTextFieldGraphicFile.getText(), iSData);
        }
        //if (selectedIndex==-1)
        {
            // redraw, since new action was "invoked"
            mClassSetting++;

            int actionSize = jComboBoxAction.getModel().getSize();
            boolean found = false;
            for (int i=0;i<actionSize; i++)
            {
                String actions = jComboBoxAction.getModel().getElementAt(i).toString();
                if (actions.equals(see))
                    found = true;
            }
            if (!found)
                jComboBoxAction.addItem(see);

            
            
            mClassSetting--;
            jComboBoxAction.setSelectedItem(see);
            
//jComboBoxActionActionPerformed(null);
        }
    }

    void setCurrentAttributeData()
    {
        jComboBoxAttributeName.setSelectedItem(mCurrentAttributeData.name);
        jComboBoxAttributeType.setSelectedItem(mCurrentAttributeData.type);
        jTextFieldAttributeValue.setText(mCurrentAttributeData.sVal());
    }
    void readCurrentAttributeData()
    {
        Object o = jComboBoxAttributeName.getSelectedItem();
        if (o == null) return;
        String aName = o.toString();

        if (jTextFieldAttributeValue.getText().length() == 0) return;

        mCurrentAttributeData = new SpriteAttribute();
        mCurrentAttributeData.name = aName;
        mCurrentAttributeData.type = (String ) jComboBoxAttributeType.getSelectedItem();
        mCurrentAttributeData.setSVal(jTextFieldAttributeValue.getText(), mCurrentAttributeData.type);

        mAttributeData.addElement(mCurrentAttributeData);

        SpriteAttribute.fillSprite(mAttributeData, mCurrentSprite.data);
        resetAttributeTable();
    }

    private void tableDoubleClicked()
    {
        if (mRow <0) return;
        mCurrentAttributeData = mAttributeData.elementAt(mRow);
        setCurrentAttributeData();
    }

    javax.swing.table.TableModel getTableModel()
    {
        AbstractTableModel model = new
         AbstractTableModel() {
            @Override public String getColumnName(int col)
            {
                if (col==0) return "Name";
                if (col==1) return "Type";
                if (col==2) return "Value";
                return "";
            }
            @Override
            public int getRowCount()
            {
                return mAttributeData.size();
            }
            @Override
            public int getColumnCount() { return 3;}
            @Override
            public Object getValueAt(int row, int col)
            {

                if (col==0) return mAttributeData.elementAt(row).name;
                if (col==1) return mAttributeData.elementAt(row).type;
                if (col==2) return mAttributeData.elementAt(row).sVal();
                return "";
            }
            @Override public boolean isCellEditable(int row, int col)
                { return false; }
            @Override public Class getColumnClass(int col)
            {
                return String.class;
            }
        };
        return model;
    }

    void resetAttributeTable()
    {
        CSATableModel t = CSATableModel.buildTableModel(getTableModel());
        csaPanel = new CSATablePanel(t);
        csaPanel.setXMLId("ImageAttributes");
        csaPanel.setTableStyleSwitchingEnabled(false);
        csaPanel.setTablePopupEnabled(true);
        csaPanel.setDoubleClickAction(new DoubleClickAction()
        {
            @Override
            public void doIt()
            {
                JTable table = (JTable) evt.getSource();
                mRow = table.convertRowIndexToModel(table.rowAtPoint(evt.getPoint()));
                mCol = table.convertColumnIndexToModel(table.columnAtPoint(evt.getPoint()));
                mCol = csaPanel.getModel().convertEnabledColToRealCol(mCol);
                tableDoubleClicked();
            }
        });

        jPanel6.removeAll();
        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(csaPanel)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(csaPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE)
        );
    }




    void resetSpriteList(String selectName)
    {
        mAllSpritesInClass = new Vector <SpriteData>();

        String _class = getSpriteClass();
        SpriteDataPool pool = getPool();

        if (pool == null) return;

        Collection<SpriteData> colDk = pool.getMapForKlasse(_class).values();
        Iterator<SpriteData> iterDk = colDk.iterator();
        /** Sorting */  Vector<String> names = new Vector<String>();
        while (iterDk.hasNext())
        {
            SpriteData deck = iterDk.next();
            mAllSpritesInClass.addElement(deck);
            names.addElement(deck.mName);

        }
        Collections.sort(names, new Comparator<String>() {@Override
                public int compare(String s1, String s2) { return s1.compareTo(s2); } });
        Collections.sort(mAllSpritesInClass, new Comparator<SpriteData>() {@Override
            public int compare(SpriteData s1, SpriteData s2) { return s1.mName.compareTo(s2.mName); } });
        setAllSprites(selectName);
    }

    boolean getGraphicPool()
    {
        String name = "Graphics"+File.separator+jTextFieldGraphicFile.getText()+".xml";
        if (name.trim().length() == 0) return false;
        if (mImageSequenceDataPool!=null)
            if (mImageSequenceDataPool.getFilename().equals(name)) return true;

        mImageSequenceDataPool = new ImageSequenceDataPool(name);
        return true;
    }
    void setPoolOnly()
    {
        if (!getGraphicPool()) return;
        if (mImageSequenceDataPool == null) return;

        String selection = (String) jComboBoxKlasseGraphic.getSelectedItem();
        mClassSetting++;
        jComboBoxKlasseGraphic.removeAllItems();
        Collection<String> collectionKlasse = mImageSequenceDataPool.getKlassenHashMap().values();
        Iterator<String> iterC = collectionKlasse.iterator();
        /** Sorting */  Vector<String> cnames = new Vector<String>(); while (iterC.hasNext()) cnames.addElement(iterC.next()); Collections.sort(cnames, new Comparator<String>() {@Override
            public int compare(String s1, String s2) { return s1.compareTo(s2); } });
        for (int j = 0; j < cnames.size(); j++)
        {
            String string = cnames.elementAt(j);
            jComboBoxKlasseGraphic.addItem(string);
        }

        if (selection!=null) jComboBoxKlasseGraphic.setSelectedItem(selection);
        else
            jComboBoxKlasseGraphic.setSelectedIndex(-1);
        jComboBoxNameGraphic.removeAllItems();
        mClassSetting--;
    }

    void clearGraphicsData()
    {
        jTextFieldGraphicsHeight.setText("");
        jTextFieldGraphicsWidth.setText("");
        jTextFieldGraphicsIMageCount.setText("");
        jTextFieldGraphicsDelay.setText("");

        imageComponent1.setVisible(false);
    }

    void setGraphicsDataFromCurrent()
    {
        if (mData == null) return;
        if (mData.getHeight().isEmpty()) return;

        jTextFieldGraphicsHeight.setText(""+mData.getMaxHeight());
        jTextFieldGraphicsWidth.setText(""+mData.getMaxWidth());
        jTextFieldGraphicsIMageCount.setText(""+mData.size());
        jTextFieldGraphicsDelay.setText(""+mData.getDelay());

        boolean sizesDiffer=false;

        int h = mData.getHeight().elementAt(0);
        int w = mData.getWidth().elementAt(0);
        for (int i =1; i < mData.getHeight().size(); i++)
        {
            if (h != mData.getHeight().elementAt(i))
            {
                sizesDiffer = true;
                break;
            }
            if (w != mData.getWidth().elementAt(i))
            {
                sizesDiffer = true;
                break;
            }
        }


        Vector<Image> images = new Vector<Image>();

        Vector <BaseImageData> mBData = BaseImageData.toBase(mData);
        for (int i = 0; i < mBData.size(); i++)
        {
            BaseImageData baseImageData = mBData.elementAt(i);
            images.addElement(baseImageData.image);
        }

        //imageComponent1.setImages(images);
        imageComponent1.setSequence(new ImageSequence(mData));

        imageComponent1.setScaled(jCheckBoxScaled.isSelected(), 100,100);
        imageComponent1.setVisible(true);

        imageComponent1.setDelay(mData.getDelay());

    }

    private void resetGraphicsPool(boolean select, String klasseToSet, String nameToSet)
    {
        if (!getGraphicPool()) return;
        if (mImageSequenceDataPool == null) return;
        mClassSetting++;

        setPoolOnly();
        String klasse = "";
        if (select)
        {
            if (klasseToSet.length()==0)
            {
                if (jComboBoxKlasseGraphic.getItemCount()>0)
                {
                    jComboBoxKlasseGraphic.setSelectedIndex(0);
                    klasse = (String) jComboBoxKlasseGraphic.getSelectedItem();
                }
            }
            else
            {
                jComboBoxKlasseGraphic.setSelectedItem(klasseToSet);
                klasse = klasseToSet;
            }
        }

        if ((select) && (klasse.length()==0))
        {
            if (jComboBoxKlasseGraphic.getItemCount()>0)
            {
                jComboBoxKlasseGraphic.setSelectedIndex(0);
                klasse = jComboBoxKlasseGraphic.getSelectedItem().toString();
            }
        }
        if ((select) && (klasse.length()!=0))
        {
            jComboBoxNameGraphic.removeAllItems();
            Collection<ImageSequenceData> collectionName = mImageSequenceDataPool.getMapForKlasse(klasse).values();
            Iterator<ImageSequenceData> iterN = collectionName.iterator();
            /** Sorting */  Vector<String> nnames = new Vector<String>(); while (iterN.hasNext()) nnames.addElement(iterN.next().mName); Collections.sort(nnames, new Comparator<String>() {@Override
                public int compare(String s1, String s2) { return s1.compareTo(s2); } });
            for (int j = 0; j < nnames.size(); j++)
            {
                String string = nnames.elementAt(j);
                jComboBoxNameGraphic.addItem(string);
                if (select)
                {
                    if (nameToSet.length() == 0)
                    {
                        if (j== 0) jComboBoxNameGraphic.setSelectedIndex(0);
                    }
                    else
                    {
                        if (nameToSet.equals(string))
                            jComboBoxNameGraphic.setSelectedIndex(j);

                    }

                }
            }
        }
        else
        {
            jComboBoxNameGraphic.removeAllItems();
            Collection<ImageSequenceData> collectionName = mImageSequenceDataPool.getHashMap().values();
            Iterator<ImageSequenceData> iterN = collectionName.iterator();
            /** Sorting */  Vector<String> nnames = new Vector<String>(); while (iterN.hasNext()) nnames.addElement(iterN.next().mName); Collections.sort(nnames, new Comparator<String>() {@Override
                public int compare(String s1, String s2) { return s1.compareTo(s2); } });
            for (int j = 0; j < nnames.size(); j++)
            {
                String string = nnames.elementAt(j);
                jComboBoxNameGraphic.addItem(string);
                if (select)
                {
                    if (nameToSet.length() == 0)
                    {
                        if (j== 0) jComboBoxNameGraphic.setSelectedIndex(0);
                    }
                    else
                    {
                        if (nameToSet.equals(string))
                            jComboBoxNameGraphic.setSelectedIndex(j);

                    }

                }
            }
        }

        if (!select)  jComboBoxKlasseGraphic.setSelectedIndex(-1);
        if (!select)  jComboBoxNameGraphic.setSelectedIndex(-1);


        mClassSetting--;
    }
   int getI(JTextField t)
    {
        return getI(t.getText());
    }

    int getI(String t)
    {
        return  getI(t, 0);
    }
    int getI(String t, int _default)
    {
        int i=_default;
        try
        {
            i = Integer.parseInt(t);
        }
        catch (Throwable e){ }
        return i;
    }

    boolean notDragged = true;
    void setAllSprites(String selectName)
    {
        jPanelIMageCollection1.removeAll();
        currentSelectedSpriteImagePanel = null;

        int selected = 0;
        for (int t = 0; t < mAllSpritesInClass.size(); t++)
        {
            SpriteData spriteData = mAllSpritesInClass.elementAt(t);
            if ((t == 0) && (selectName.length()==0))
            {
                selectName = spriteData.mName;
            }
            else if (spriteData.mName.equals(selectName))
            {
                selected = t;
                break;
            }
        }
        int x = 5;
        int y = 5;
    
        for (int t = 0; t < mAllSpritesInClass.size(); t++)
        {
            SpriteData spriteData = mAllSpritesInClass.elementAt(t);
            ImageSequenceData iSData = getImageSequenceDataForSprite(spriteData);
            String name = spriteData.mName;

            JPanel ipanel = new JPanel();


            ipanel.setName(""+name);
            ipanel.setPreferredSize(new java.awt.Dimension(52, 52));
            ipanel.setLayout(new BorderLayout());

            ImageComponent mip = new ImageComponent();
            ipanel.add(mip, BorderLayout.CENTER);

            mip.addMouseListener(new java.awt.event.MouseAdapter() {
                @Override
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    notDragged = true;
                }
                public void mouseReleased(java.awt.event.MouseEvent evt) {
                    if (notDragged)
                        jPanelMouseTileClickedImageVertical(evt);
                }
            });
            

            if (iSData != null)
            {
                Vector <BaseImageData> data = BaseImageData.toBase(iSData);
                if (data.size()>0)
                {
                    Vector<Image> images = new Vector<Image>();
                    for (int i = 0; i < data.size(); i++)
                    {
                        BaseImageData baseImageData = data.elementAt(i);
                        images.addElement(baseImageData.image);
                    }
                    mip.setSequence(new ImageSequence(iSData));
                    mip.setDelay(iSData.getDelay());
                }
            }
            ipanel.setBounds(x, y, 52, 52);
            jPanelIMageCollection1.add(ipanel);

            if (t==selected)
            {
                //currentSelectedSpriteImagePanel = ipanel;
                //ipanel.setBorder(javax.swing.BorderFactory.createLineBorder(Color.ORANGE));
                mCurrentSprite = Sprite.buildSprite(spriteData);
                
                mClassSetting++;
                setCurrentSpriteInfo();
                mClassSetting--;
                
                currentSelectedSpriteImagePanel = null; // reset display in any Case!
                selectSprite(ipanel);
            }
            else
                ipanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
            
            y += 52;
            y += 5;
            mip.setScaled(true, 52, 52);
            mip.setVisible(true);
        }

        jPanelIMageCollection1.setBounds(0,0,62,y);
        jPanelIMageCollection1.setPreferredSize(new Dimension(62,y));
        jPanelIMageCollection1.invalidate();
        jPanelIMageCollection1.validate();
        jPanelIMageCollection1.repaint();


        repaint();
    }
    JPanel currentSelectedSpriteImagePanel = null;

    
    private void selectSprite(JPanel newSelectedImagePanel)
    {
        resetAnimationBorders();
        if (newSelectedImagePanel == currentSelectedSpriteImagePanel) return;

        if (currentSelectedSpriteImagePanel != null)
        {
            currentSelectedSpriteImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        }

        currentSelectedSpriteImagePanel = newSelectedImagePanel;

        currentSelectedSpriteImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(Color.ORANGE));
        String name  = currentSelectedSpriteImagePanel.getName();

        for (int t = 0; t < mAllSpritesInClass.size(); t++)
        {
            SpriteData tileData = mAllSpritesInClass.elementAt(t);
            if (tileData.mName.equals(name))
            {
                mCurrentSprite = Sprite.buildSprite(tileData);
                setCurrentSpriteInfo();
                break;
            }
        }
//    CSA    jComboBoxAction.setSelectedItem("Stand");
    }
    private void jPanelMouseTileClickedImageVertical(java.awt.event.MouseEvent evt) {
        JComponent c = (JComponent) evt.getSource();
        c = (JComponent) c.getParent();
        JPanel newSelectedImagePanel = (JPanel) c;
        
        selectSprite( newSelectedImagePanel);
        
    }

    void removeAllGraphics(boolean clearClassesTo)
    {
        mClassSetting++;
        jPanelIMageCollection.removeAll();
        currentSelectedImagePanel = null;

        jTextFieldGraphicsHeight.setText("");
        jTextFieldGraphicsWidth.setText("");
        jTextFieldGraphicsIMageCount.setText("");
        jTextFieldGraphicsDelay.setText("");
        if (clearClassesTo)
        {
            jComboBoxNameGraphic.removeAllItems();
            jComboBoxNameGraphic.setSelectedIndex(-1);
            jComboBoxKlasseGraphic.removeAllItems();
            jComboBoxKlasseGraphic.setSelectedIndex(-1);
            jTextFieldGraphicFile.setText("");
            mImageSequenceDataPool = null;
        }
        mClassSetting--;
    }
    void setAllGraphics()
    {
        jPanelIMageCollection.removeAll();
        JPanel newSelection = null;

        if (!getGraphicPool()) return;
        if (mImageSequenceDataPool == null) return;
        String klasse = "";
        if (jComboBoxKlasseGraphic.getSelectedIndex() < 0) return;
        klasse = (String) jComboBoxKlasseGraphic.getSelectedItem();
        if (klasse.length()==0) return;

        Collection<ImageSequenceData> collectionName = mImageSequenceDataPool.getMapForKlasse(klasse).values();
        Iterator<ImageSequenceData> iterN = collectionName.iterator();
            /** Sorting */  Vector<String> nnames = new Vector<String>(); while (iterN.hasNext()) nnames.addElement(iterN.next().mName); Collections.sort(nnames, new Comparator<String>() {@Override
                public int compare(String s1, String s2) { return s1.compareTo(s2); } });


        int x = 5;
        int y = 5;
        for (int j = 0; j < nnames.size(); j++)
        {
            String name = nnames.elementAt(j);
            ImageSequenceData iSData = mImageSequenceDataPool.get(name);

            Vector <BaseImageData> data = BaseImageData.toBase(iSData);
            if (data.size()>0)
            {
                Vector<Image> images = new Vector<Image>();
                for (int i = 0; i < data.size(); i++)
                {
                    BaseImageData baseImageData = data.elementAt(i);
                    images.addElement(baseImageData.image);
                }

                JPanel ipanel = new JPanel();
                if (j==0)
                {
                    currentSelectedImagePanel = ipanel;
                    mData = mImageSequenceDataPool.get(name);
                    ipanel.setBorder(javax.swing.BorderFactory.createLineBorder(Color.ORANGE));
                }
                else
                    ipanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

                ipanel.setName(""+name);
                ipanel.setPreferredSize(new java.awt.Dimension(52, 52));
                ipanel.setLayout(new BorderLayout());
                ImageComponent mip = new ImageComponent();

                ipanel.add(mip, BorderLayout.CENTER);
                //mip.setImages(images);
                mip.setSequence(new ImageSequence(iSData));


        /////////////////
                class MyTransferHandler extends TransferHandler
                {
                    JPanel me;
                    public MyTransferHandler(JPanel c)
                    {
                        me = c;
                    }
                    public int getSourceActions(JComponent c)
                    {
                        return TransferHandler.MOVE;
                    }
                    public  Transferable createTransferable(JComponent c)
                    {
                        return new StringSelection(me.getName());
                    }
                    public void exportDone(JComponent source, Transferable data, int action)
                    {

                    }
                }

                mip.setTransferHandler(new MyTransferHandler(ipanel));
                mip.addMouseMotionListener(new MouseMotionListener(){
                    @Override
                    public void mouseDragged(MouseEvent e)
                    {
                        notDragged = false;
                        e.consume();
                        JComponent c =(JComponent) e.getSource();
                        TransferHandler handler = c.getTransferHandler();
                        handler.exportAsDrag(c,e,TransferHandler.MOVE);
                        System.out.println("Draging?");
                    }
                    @Override public void mouseMoved(MouseEvent e) { }
                });

                mip.addMouseListener(new java.awt.event.MouseAdapter() {
                    @Override
                    public void mousePressed(java.awt.event.MouseEvent evt) {
                        notDragged = true;
                    }
                    @Override
                    public void mouseReleased(java.awt.event.MouseEvent evt) {
                        if (notDragged)
                            jPanelMouseClickedImageHorizontal(evt);
                    }
                });

                ipanel.setBounds(x, y, 52, 52);

                jPanelIMageCollection.add(ipanel);
//                if (jToggleButtonPlayAnimMain.isSelected())
//                {
                    mip.setDelay(iSData.getDelay());
//                }
//                else
//                {
//                    mip.setDelay(-1);
//                }

                mip.setScaled(true, 52, 52);
                mip.setVisible(true);
                x += 52;
                x += 5;

            }

        }
        setGraphicsDataFromCurrent();
//        jPanelIMageCollection.setBounds(0,0,62,y);
//        jPanelIMageCollection.setPreferredSize(new Dimension(62,y));
        jPanelIMageCollection.invalidate();
        jPanelIMageCollection.validate();
        jPanelIMageCollection.repaint();


        repaint();

    }
    JPanel currentSelectedImagePanel = null;

    private void jPanelMouseClickedImageHorizontal(java.awt.event.MouseEvent evt) {
        JComponent c = (JComponent) evt.getSource();
        c = (JComponent) c.getParent();
        JPanel newSelectedImagePanel = (JPanel) c;
        selectImage(newSelectedImagePanel);
    }

    private void selectImage(JPanel newSelectedImagePanel)
    {
        if (newSelectedImagePanel == currentSelectedImagePanel)
        {
            return;
        }

        if (currentSelectedImagePanel != null)
        {
            currentSelectedImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        }

        currentSelectedImagePanel = newSelectedImagePanel;

        currentSelectedImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(Color.ORANGE));
        String name  = currentSelectedImagePanel.getName();
        if (name.trim().length() == 0)
        {
            jComboBoxNameGraphic.setSelectedIndex(-1);
            jTextFieldGraphicsHeight.setText("");
            jTextFieldGraphicsWidth.setText("");
            jTextFieldGraphicsIMageCount.setText("");
            jTextFieldGraphicsDelay.setText("");
            mData = null;
        }
        else
        {
            mData = mImageSequenceDataPool.get(name);
            jComboBoxNameGraphic.setSelectedItem(name);
            setGraphicsDataFromCurrent();
        }
    }

    ImageSequenceData getImageSequenceDataForSprite(SpriteData spriteData)
    {
        Vector<String> poolNames = spriteData.getImageSetName();
        if (poolNames.size()==0) return null; // keine image daten in dem sprite vorhanden!
        
        String imagePoolFilename = poolNames.elementAt(0); // erstes element liefert die Anzeige daten!
        if (imagePoolFilename.trim().length()==0) return null;

        String imageFilename = "Graphics"+File.separator+imagePoolFilename+".xml";
        ImageSequenceDataPool imagePool = new ImageSequenceDataPool(imageFilename);
        if (imagePool == null) return null;
        
        Vector<String> actionNames = spriteData.getActionDirectionImageName(); // get the first available action
        if (actionNames.size()==0) return null; // keine image daten in dem sprite vorhanden!
        
        String nameToSet = Sprite.getImageFromImageActionDirection(actionNames.elementAt(0));
        return imagePool.get(nameToSet);
    }

    public void selectAnimation(JPanel animationPanel)
    {
        jPanel3.removeAll();
        jPanel3.invalidate();
        jPanel3.validate();
        jPanel3.repaint();
        if (animationPanel==null)
        {
            return;
        }
        
        if (animationPanel.getComponentCount()<= 0) return;
        Component bla = animationPanel.getComponent(0);
        if (!(bla instanceof ImageComponent)) return;
        ImageComponent ic = (ImageComponent) bla;
        
        ImageSequence is = ic.getSequence();
        if (is == null) return;
        
        int c = is.getImageCount();
        
        int x=0;
        int y=0;
        Object see = jComboBoxAction.getEditor().getItem();
        if (see==null) 
            return;
        String action = see.toString();
        
        String direction = animationPanel.getName();
        for (int i=0; i< c; i++)
        {
            AnimationStepPanel stepPanel = new AnimationStepPanel();
            stepPanel.init(is, i);
            stepPanel.setBounds(x,y,stepPanel.getWidth(), stepPanel.getHeight());
            stepPanel.setBounds(x,y,52, 84);
            x += stepPanel.getWidth()+2;
            jPanel3.add(stepPanel);

            // set current movement deltas
            Dimension dim = mCurrentSprite.getMovement(action, direction, i);
            stepPanel.setXMovement(dim.width);
            stepPanel.setYMovement(dim.height);
        }
        jPanel3.setPreferredSize(new Dimension(x+52+2,84));
        jPanel3.invalidate();
        jPanel3.validate();
        jPanel3.repaint();
        
        setGraphicsData(action, direction);
        doExample(action, direction);
    }
    private void readMovementToSprite()
    {
        if (jComboBoxAction.getSelectedIndex()==-1) return;
        String action = jComboBoxAction.getSelectedItem().toString();

        if (currentSelectedAnimationImagePanel==null) return;
        String direction = currentSelectedAnimationImagePanel.getName();
        
        if (jPanel3.getComponentCount()<= 0) return;

        int c = jPanel3.getComponentCount();
        
        for (int i=0; i< c; i++)
        {
            Component bla = jPanel3.getComponent(i);
            if (!(bla instanceof AnimationStepPanel)) continue;
            AnimationStepPanel aPanel = (AnimationStepPanel)bla;
            int x=aPanel.getXMovement();
            int y=aPanel.getYMovement();
            mCurrentSprite.setMovement(action, direction, i, x, y);
        }
    }
    private void setGraphicsData(String action, String direction)
    {
        String filename = mCurrentSprite.getImagePoolname(action, direction);
        String imageSequenceName = mCurrentSprite.getImagename(action, direction);
        if (filename == null) return;
        if (imageSequenceName == null) return;
        


        // select imagefile
        jTextFieldGraphicFile.setText(csa.util.UtilityString.replace(filename, ".xml", ""));
        jTextFieldGraphicFileActionPerformed(null);


        // select image class
        String imageClassName="";
        Collection<ImageSequenceData> collectionKlasse = mImageSequenceDataPool.getHashMap().values();
        Iterator<ImageSequenceData> iterC = collectionKlasse.iterator();

        while (iterC.hasNext())
        {
            ImageSequenceData d = iterC.next();
            if (d.getName().equals(imageSequenceName))
            {
                imageClassName = d.getCClass();
                break;
            }
        }
        if (imageClassName.length()==0) return;
        mClassSetting++;
        jComboBoxKlasseGraphic.setSelectedItem(imageClassName);
        mClassSetting--;
        
        // force selection
        int save = mClassSetting;
        mClassSetting = 0;
        jComboBoxKlasseGraphicActionPerformed(null);
        mClassSetting = save;

        // select image sequence
        for(int i=0; i< jPanelIMageCollection.getComponentCount(); i++)
        {
            String thisname = jPanelIMageCollection.getComponent(i).getName();
            if (imageSequenceName.equals(thisname))
            {
                selectImage((JPanel) jPanelIMageCollection.getComponent(i));
                break;
            }
        }
        
    }
    private void doExample(String action, String direction)
    {
        TMap map = new TMap();
        mapPanel.setMap(map);
        mapPanel.setGrid(null, false);

        mCurrentSprite.setDisplay(mapPanel);
        mCurrentSprite.setActiveActionDirection(action, direction);
        
        int height = mCurrentSprite.getMaxHeight();
        int width = mCurrentSprite.getMaxWidth();
        mCurrentSprite.setX(70-width/2);
        mCurrentSprite.setY(70-height/2);
        
        
        // adds a "clone"
        final Sprite sprite = map.getCurrentLayer().addSprite(mCurrentSprite);
        sprite.addPositionListener(new PositionListener()
        {
            boolean inListening = false; 
            public void positionChanged()
            {
                if (!jCheckBox3.isSelected()) return;
                if(inListening) return;
                inListening = true;
                if (sprite.getX() > 140)
                    sprite.setX(0-sprite.getMaxWidth()+1);
                if (sprite.getX()+sprite.getMaxWidth() < 0)
                    sprite.setX(140);
                if (sprite.getY() > 140)
                    sprite.setY(0-sprite.getMaxHeight()+1);
                if (sprite.getY()+sprite.getMaxHeight() < 0)
                    sprite.setY(140);
                inListening = false;
            }
        });
        
        map.getCurrentLayer().getData().setisBackground(jCheckBoxBackShadow.isSelected());
        map.getCurrentLayer().getData().setbackgroundColor(255*256*256+255*256+255);
        mapPanel.initBackground();
        
        //mapPanel.setMap(map);    
    }

    int inSetting=0;
    private void selectActionDirection(String action, String direction)
    {
        if (action == null) return;
        if (action.length() == 0) return;
        
        inSetting++;
        jComboBoxAction.setSelectedItem(action);
        inSetting--;
        
        JPanel dirToSelect=null;
        
        setToPanel(jPanelN, mCurrentSprite.getImageSequenceData(action,"n"), mCurrentSprite.getImagePoolname(action,"n"));
        if (direction.equals("n")) dirToSelect = currentSelectedAnimationImagePanel;
        setToPanel(jPanelS, mCurrentSprite.getImageSequenceData(action,"s"), mCurrentSprite.getImagePoolname(action,"s"));
        if (direction.equals("s")) dirToSelect = currentSelectedAnimationImagePanel;
        setToPanel(jPanelW, mCurrentSprite.getImageSequenceData(action,"w"), mCurrentSprite.getImagePoolname(action,"w"));
        if (direction.equals("w")) dirToSelect = currentSelectedAnimationImagePanel;
        setToPanel(jPanelE, mCurrentSprite.getImageSequenceData(action,"e"), mCurrentSprite.getImagePoolname(action,"e"));
        if (direction.equals("e")) dirToSelect = currentSelectedAnimationImagePanel;
        setToPanel(jPanelNE, mCurrentSprite.getImageSequenceData(action,"ne"), mCurrentSprite.getImagePoolname(action,"ne"));
        if (direction.equals("ne")) dirToSelect = currentSelectedAnimationImagePanel;
        setToPanel(jPanelNW, mCurrentSprite.getImageSequenceData(action,"nw"), mCurrentSprite.getImagePoolname(action,"nw"));
        if (direction.equals("nw")) dirToSelect = currentSelectedAnimationImagePanel;
        setToPanel(jPanelSE, mCurrentSprite.getImageSequenceData(action,"se"), mCurrentSprite.getImagePoolname(action,"se"));
        if (direction.equals("se")) dirToSelect = currentSelectedAnimationImagePanel;
        setToPanel(jPanelSW, mCurrentSprite.getImageSequenceData(action,"sw"), mCurrentSprite.getImagePoolname(action,"sw"));
        if (direction.equals("sw")) dirToSelect = currentSelectedAnimationImagePanel;
        setToPanel(jPanelC, mCurrentSprite.getImageSequenceData(action,"c"), mCurrentSprite.getImagePoolname(action,"c"));
        if (direction.equals("c")) dirToSelect = currentSelectedAnimationImagePanel;
        
        if (dirToSelect!=null)
        {
            if (currentSelectedAnimationImagePanel != null)
            {
                currentSelectedAnimationImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
            }
            currentSelectedAnimationImagePanel = dirToSelect;
            currentSelectedAnimationImagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(Color.ORANGE));
        }
        
        
        //        select action and display direction data
        selectAnimation(currentSelectedAnimationImagePanel);
        mClassSetting++;
        String subsequentAction = mCurrentSprite.getSubsequentAction(action);
        jComboBoxAction1.setSelectedItem(subsequentAction);
        boolean loop = mCurrentSprite.isActionLoop(action);
        jCheckBox2.setSelected(loop);
        mClassSetting--;        
    }
    
}
