// Path: liblab/src/com/sqrt/liblab/entry/graphics/FontGlyph.java
// public class FontGlyph {
//     /**
//      * The character code of this glyph (not necessarily ASCII)
//      */
//     public int index;
//     /**
//      * The width of this glyph
//      */
//     public int charWidth;
//     /**
//      * The x offset of this glyph
//      */
//     public int xOff;
//     /**
//      * The y offset of this glyph
//      */
//     public int yOff;
//     /**
//      * The glyph in ARGB with just the alpha value of each pixel set
//      */
//     public BufferedImage mask;
// }
// 
// Path: liblab/src/com/sqrt/liblab/entry/graphics/GrimFont.java
// public class GrimFont extends LabEntry {
//     /**
//      * The height of a line in this font
//      */
//     public int height;
//     /**
//      * The baseline for this font
//      */
//     public int yOffset;
//     /**
//      * The first character contained in this font
//      */
//     public int firstChar;
//     /**
//      * The last character contained in this font
//      */
//     public int lastChar;
//     // Todo: firstChar and lastChar needed?
//     /**
//      * The glyphs of this font
//      */
//     public List<FontGlyph> glyphs;
// 
//     /**
//      * Constructs a new font
//      * @param container the container of this font
//      * @param name the name of this font
//      * @param firstChar the first character contained within this font file
//      * @param lastChar the last character contained within this font file
//      * @param yOffset the baseline of this font
//      * @param height the height of this font
//      * @param glyphs the glyphs
//      */
//     public GrimFont(LabFile container, String name, int firstChar, int lastChar, int yOffset, int height, List<FontGlyph> glyphs) {
//         super(container, name);
//         this.firstChar = firstChar;
//         this.lastChar = lastChar;
//         this.yOffset = yOffset;
//         this.height = height;
//         this.glyphs = new LinkedList<FontGlyph>();
//         this.glyphs.addAll(glyphs);
//     }
// 
//     /**
//      * Returns the glyph that corresponds to the character code specified
//      * @param c the code
//      * @return the glyph or null if none was found
//      */
//     public FontGlyph getGlyph(char c) {
//         if(glyphs.get(c).index == c)
//             return glyphs.get(c);
//         for(FontGlyph g: glyphs) {
//             if(g.index == c)
//                 return g;
//         }
//         return null;
//     }
// }


import javax.swing.event.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Map;
import com.sqrt.liblab.entry.graphics.FontGlyph;
import com.sqrt.liblab.entry.graphics.GrimFont;
import javax.swing.*;
import javax.swing.border.TitledBorder;


/*
 * Copyright (C) 2014  James Lawrence.
 *
 *     This file is part of GrimEdi.
 *
 *     GrimEdi 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/>.
 */

/*
 * Created by JFormDesigner on Sat Mar 16 10:40:39 GMT 2013
 */

package com.sqrt4.grimedi.ui.editor;



/**
 * @author James Lawrence
 */
public class FontView extends EditorPanel<GrimFont> {
    private String _previewedText;
    private static final int mult = 8;
    private BufferedImage _glyphPreview;

    public FontView() {
        initComponents();
    }

    ImageIcon icon = new ImageIcon(getClass().getResource("/font.png"));
    public ImageIcon getIcon() {
        return icon;
    }

    private void updatePreview() {
        int height = data.height;
        int width = 0;
        int y = data.yOffset;
        int x = 0;
        String text = previewText.getText();
        char[] charArray = text.toCharArray();
        for (char c : charArray) {
// Path: liblab/src/com/sqrt/liblab/entry/graphics/FontGlyph.java
// public class FontGlyph {
//     /**
//      * The character code of this glyph (not necessarily ASCII)
//      */
//     public int index;
//     /**
//      * The width of this glyph
//      */
//     public int charWidth;
//     /**
//      * The x offset of this glyph
//      */
//     public int xOff;
//     /**
//      * The y offset of this glyph
//      */
//     public int yOff;
//     /**
//      * The glyph in ARGB with just the alpha value of each pixel set
//      */
//     public BufferedImage mask;
// }
// 
// Path: liblab/src/com/sqrt/liblab/entry/graphics/GrimFont.java
// public class GrimFont extends LabEntry {
//     /**
//      * The height of a line in this font
//      */
//     public int height;
//     /**
//      * The baseline for this font
//      */
//     public int yOffset;
//     /**
//      * The first character contained in this font
//      */
//     public int firstChar;
//     /**
//      * The last character contained in this font
//      */
//     public int lastChar;
//     // Todo: firstChar and lastChar needed?
//     /**
//      * The glyphs of this font
//      */
//     public List<FontGlyph> glyphs;
// 
//     /**
//      * Constructs a new font
//      * @param container the container of this font
//      * @param name the name of this font
//      * @param firstChar the first character contained within this font file
//      * @param lastChar the last character contained within this font file
//      * @param yOffset the baseline of this font
//      * @param height the height of this font
//      * @param glyphs the glyphs
//      */
//     public GrimFont(LabFile container, String name, int firstChar, int lastChar, int yOffset, int height, List<FontGlyph> glyphs) {
//         super(container, name);
//         this.firstChar = firstChar;
//         this.lastChar = lastChar;
//         this.yOffset = yOffset;
//         this.height = height;
//         this.glyphs = new LinkedList<FontGlyph>();
//         this.glyphs.addAll(glyphs);
//     }
// 
//     /**
//      * Returns the glyph that corresponds to the character code specified
//      * @param c the code
//      * @return the glyph or null if none was found
//      */
//     public FontGlyph getGlyph(char c) {
//         if(glyphs.get(c).index == c)
//             return glyphs.get(c);
//         for(FontGlyph g: glyphs) {
//             if(g.index == c)
//                 return g;
//         }
//         return null;
//     }
// }


// Path: grimedi/src/com/sqrt4/grimedi/ui/editor/FontView.java
import javax.swing.event.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Map;
import com.sqrt.liblab.entry.graphics.FontGlyph;
import com.sqrt.liblab.entry.graphics.GrimFont;
import javax.swing.*;
import javax.swing.border.TitledBorder;



/*
 * Copyright (C) 2014  James Lawrence.
 *
 *     This file is part of GrimEdi.
 *
 *     GrimEdi 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/>.
 */

/*
 * Created by JFormDesigner on Sat Mar 16 10:40:39 GMT 2013
 */

package com.sqrt4.grimedi.ui.editor;



/**
 * @author James Lawrence
 */
public class FontView extends EditorPanel<GrimFont> {
    private String _previewedText;
    private static final int mult = 8;
    private BufferedImage _glyphPreview;

    public FontView() {
        initComponents();
    }

    ImageIcon icon = new ImageIcon(getClass().getResource("/font.png"));
    public ImageIcon getIcon() {
        return icon;
    }

    private void updatePreview() {
        int height = data.height;
        int width = 0;
        int y = data.yOffset;
        int x = 0;
        String text = previewText.getText();
        char[] charArray = text.toCharArray();
        for (char c : charArray) {
            FontGlyph g = data.getGlyph(c);