// Path: src/com/welty/nboard/gui/Align.java
// public enum Align {
//     LEFT(SwingConstants.LEFT) {
//         @Override public int stringStart(int x, int width, int stringWidth) {
//             return x;
//         }
//     },
// 
//     CENTER(SwingConstants.CENTER) {
//         @Override public int stringStart(int x, int width, int stringWidth) {
//             return x + ((width - stringWidth) >> 1);
//         }
//     },
//     RIGHT(SwingConstants.RIGHT) {
//         @Override public int stringStart(int x, int width, int stringWidth) {
//             return x + width - stringWidth;
//         }
//     };
//     private final int swingValue;
// 
//     private Align(int swingValue) {
//         this.swingValue = swingValue;
//     }
// 
//     abstract public int stringStart(int x, int width, int stringWidth);
// 
//     public int getSwingValue() {
//         return swingValue;
//     }
// }
// 
// Path: src/com/welty/nboard/gui/VAlign.java
// public enum VAlign {
//     TOP {
//         @Override public int stringY(int y, int height, int stringY, int stringHeight) {
//             return y - stringY;
//         }
//     },
// 
//     MIDDLE {
//         @Override public int stringY(int y, int height, int stringY, int stringHeight) {
//             return y-stringY + ((height - stringHeight)>>1);
//         }
//     },
//     BOTTOM  {
//         @Override public int stringY(int y, int height, int stringY, int stringHeight) {
//             return y-stringY + height - stringHeight;
//         }
//     };
// 
// 
//     /**
//      * @param y y-value at top of box
//      * @param height height of box
//      * @param stringY y-value of rectangle returned by FontMetrics.getStringBounds()
//      * @param stringHeight height of rectangle returned by FontMetrics.getStringBounds()
//      * @return y-value for baseline of string
//      */
//     abstract public int stringY(int y, int height, int stringY, int stringHeight);
// }


import com.welty.nboard.gui.Align;
import com.welty.nboard.gui.VAlign;
import javax.swing.*;
import java.awt.*;
/*
 * Copyright (c) 2014 Chris Welty.
 *
 * This is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This file 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.
 *
 * For the license, see <http://www.gnu.org/licenses/gpl.html>.
 */

package com.welty.nboard.nboard;



/**
 * Routines to simplify painting and text drawing
 */
public abstract class GraphicsUtils {
    public static void fillRect(Graphics gd, Rectangle rect, Color color) {
        gd.setColor(color);
        fillRect(gd, rect);
    }

    public static void fillRect(Graphics gd, Rectangle rect) {
        gd.fillRect(rect.x, rect.y, rect.width, rect.height);
    }

    public static void outlineRect(Graphics gd, Rectangle rect, Color color) {
        gd.setColor(color);
        gd.drawRect(rect.x, rect.y, rect.width, rect.height);
    }

    public static void fillEllipse(Graphics gd, Rectangle rect, Color color) {
        gd.setColor(color);
        fillEllipse(gd, rect);
    }

    private static void fillEllipse(Graphics gd, Rectangle rect) {
        gd.fillOval(rect.x, rect.y, rect.width, rect.height);
    }

    public static void outlineEllipse(Graphics gd, Rectangle rect, Color color) {
        gd.setColor(color);
        gd.drawOval(rect.x, rect.y, rect.width, rect.height);
    }

    public static void drawString(Graphics gd, String string, Rectangle rect) {
        drawString(gd, string, rect, Align.CENTER, VAlign.MIDDLE);
    }

// Path: src/com/welty/nboard/gui/Align.java
// public enum Align {
//     LEFT(SwingConstants.LEFT) {
//         @Override public int stringStart(int x, int width, int stringWidth) {
//             return x;
//         }
//     },
// 
//     CENTER(SwingConstants.CENTER) {
//         @Override public int stringStart(int x, int width, int stringWidth) {
//             return x + ((width - stringWidth) >> 1);
//         }
//     },
//     RIGHT(SwingConstants.RIGHT) {
//         @Override public int stringStart(int x, int width, int stringWidth) {
//             return x + width - stringWidth;
//         }
//     };
//     private final int swingValue;
// 
//     private Align(int swingValue) {
//         this.swingValue = swingValue;
//     }
// 
//     abstract public int stringStart(int x, int width, int stringWidth);
// 
//     public int getSwingValue() {
//         return swingValue;
//     }
// }
// 
// Path: src/com/welty/nboard/gui/VAlign.java
// public enum VAlign {
//     TOP {
//         @Override public int stringY(int y, int height, int stringY, int stringHeight) {
//             return y - stringY;
//         }
//     },
// 
//     MIDDLE {
//         @Override public int stringY(int y, int height, int stringY, int stringHeight) {
//             return y-stringY + ((height - stringHeight)>>1);
//         }
//     },
//     BOTTOM  {
//         @Override public int stringY(int y, int height, int stringY, int stringHeight) {
//             return y-stringY + height - stringHeight;
//         }
//     };
// 
// 
//     /**
//      * @param y y-value at top of box
//      * @param height height of box
//      * @param stringY y-value of rectangle returned by FontMetrics.getStringBounds()
//      * @param stringHeight height of rectangle returned by FontMetrics.getStringBounds()
//      * @return y-value for baseline of string
//      */
//     abstract public int stringY(int y, int height, int stringY, int stringHeight);
// }


// Path: src/com/welty/nboard/nboard/GraphicsUtils.java
import com.welty.nboard.gui.Align;
import com.welty.nboard.gui.VAlign;
import javax.swing.*;
import java.awt.*;

/*
 * Copyright (c) 2014 Chris Welty.
 *
 * This is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This file 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.
 *
 * For the license, see <http://www.gnu.org/licenses/gpl.html>.
 */

package com.welty.nboard.nboard;



/**
 * Routines to simplify painting and text drawing
 */
public abstract class GraphicsUtils {
    public static void fillRect(Graphics gd, Rectangle rect, Color color) {
        gd.setColor(color);
        fillRect(gd, rect);
    }

    public static void fillRect(Graphics gd, Rectangle rect) {
        gd.fillRect(rect.x, rect.y, rect.width, rect.height);
    }

    public static void outlineRect(Graphics gd, Rectangle rect, Color color) {
        gd.setColor(color);
        gd.drawRect(rect.x, rect.y, rect.width, rect.height);
    }

    public static void fillEllipse(Graphics gd, Rectangle rect, Color color) {
        gd.setColor(color);
        fillEllipse(gd, rect);
    }

    private static void fillEllipse(Graphics gd, Rectangle rect) {
        gd.fillOval(rect.x, rect.y, rect.width, rect.height);
    }

    public static void outlineEllipse(Graphics gd, Rectangle rect, Color color) {
        gd.setColor(color);
        gd.drawOval(rect.x, rect.y, rect.width, rect.height);
    }

    public static void drawString(Graphics gd, String string, Rectangle rect) {
        drawString(gd, string, rect, Align.CENTER, VAlign.MIDDLE);
    }

    public static void drawString(Graphics gd, String string, Rectangle rect, Align align, VAlign vAlign) {