// Path: src/ch/jbead/BeadSymbols.java
// public class BeadSymbols {
// 
//     public static final String MIDDLE_DOT = "\u00b7";
//     public static final String DEFAULT_SYMBOLS = MIDDLE_DOT + "abcdefghijklmnopqrstuvwxyz+-/\\*";
//     public static String SYMBOLS = DEFAULT_SYMBOLS;
//     public static String SAVED_SYMBOLS = DEFAULT_SYMBOLS;
// 
//     static {
//         reloadSymbols();
//     }
// 
//     public static void restoreDefaults() {
//         SYMBOLS = DEFAULT_SYMBOLS;
//     }
// 
//     public static void reloadSymbols() {
//         Settings settings = new Settings();
//         settings.setCategory("view");
//         SAVED_SYMBOLS = settings.loadString("symbols", DEFAULT_SYMBOLS);
//         SYMBOLS = SAVED_SYMBOLS;
//     }
// 
//     public static String get(byte index) {
//         if (index >= SYMBOLS.length()) return " ";
//         return SYMBOLS.substring(index, index + 1);
//     }
// 
// }


import java.awt.Color;
import java.io.IOException;
import ch.jbead.BeadSymbols;
/** jbead - http://www.jbead.ch
    Copyright (C) 2001-2012  Damian Brunold

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package ch.jbead.fileformat;



public class DbbMemento extends Memento {

    private static final int DBB_FIELD_SIZE = 25000;

    @Override
    public byte getMaxSupportedColors() {
        return 10;
    }

    @Override
    public boolean compactifyColors() {
        return true;
    }

    @Override
    public void save(JBeadOutputStream out) throws IOException {
        out.writeInt(width);
        out.write(data, 0, Math.min(DBB_FIELD_SIZE, data.length));
        if (data.length <= DBB_FIELD_SIZE) {
            for (int i = data.length; i < DBB_FIELD_SIZE; i++) {
                out.write(0);
            }
        }
        for (int i = 0; i < 10; i++) {
            if (i < colors.size()) {
                out.writeColor(colors.get(i));
            } else {
                out.writeColor(Color.WHITE);
            }
        }
        out.write(colorIndex);
        out.writeInt(zoomIndex);
        out.writeInt(shift);
// Path: src/ch/jbead/BeadSymbols.java
// public class BeadSymbols {
// 
//     public static final String MIDDLE_DOT = "\u00b7";
//     public static final String DEFAULT_SYMBOLS = MIDDLE_DOT + "abcdefghijklmnopqrstuvwxyz+-/\\*";
//     public static String SYMBOLS = DEFAULT_SYMBOLS;
//     public static String SAVED_SYMBOLS = DEFAULT_SYMBOLS;
// 
//     static {
//         reloadSymbols();
//     }
// 
//     public static void restoreDefaults() {
//         SYMBOLS = DEFAULT_SYMBOLS;
//     }
// 
//     public static void reloadSymbols() {
//         Settings settings = new Settings();
//         settings.setCategory("view");
//         SAVED_SYMBOLS = settings.loadString("symbols", DEFAULT_SYMBOLS);
//         SYMBOLS = SAVED_SYMBOLS;
//     }
// 
//     public static String get(byte index) {
//         if (index >= SYMBOLS.length()) return " ";
//         return SYMBOLS.substring(index, index + 1);
//     }
// 
// }


// Path: src/ch/jbead/fileformat/DbbMemento.java
import java.awt.Color;
import java.io.IOException;
import ch.jbead.BeadSymbols;

/** jbead - http://www.jbead.ch
    Copyright (C) 2001-2012  Damian Brunold

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package ch.jbead.fileformat;



public class DbbMemento extends Memento {

    private static final int DBB_FIELD_SIZE = 25000;

    @Override
    public byte getMaxSupportedColors() {
        return 10;
    }

    @Override
    public boolean compactifyColors() {
        return true;
    }

    @Override
    public void save(JBeadOutputStream out) throws IOException {
        out.writeInt(width);
        out.write(data, 0, Math.min(DBB_FIELD_SIZE, data.length));
        if (data.length <= DBB_FIELD_SIZE) {
            for (int i = data.length; i < DBB_FIELD_SIZE; i++) {
                out.write(0);
            }
        }
        for (int i = 0; i < 10; i++) {
            if (i < colors.size()) {
                out.writeColor(colors.get(i));
            } else {
                out.writeColor(Color.WHITE);
            }
        }
        out.write(colorIndex);
        out.writeInt(zoomIndex);
        out.writeInt(shift);
        out.writeInt(scroll);