All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ngmf.ui.mms.MmsDimension Maven / Gradle / Ivy

There is a newer version: 0.8.1
Show newest version
/*
 * MMSDimension.java
 *
 * Created on June 23, 2005, 4:55 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package ngmf.ui.mms;

public class MmsDimension implements Dimension {
    private String name;
    private int size;
    private String[] item_names = null;
    private String[] item_desc = null;

    public MmsDimension(String n, int s) {
        name = n;
        size = s;
    }

    public String getName() {return (name);}
    public int getSize() {return (size);}

    public void setSize(int new_size) {
        if (item_names != null) {
            String[] new_item_names = new String[new_size];
            for (int i = 0; i < new_size; i++) {
                if (i < size) {
                    new_item_names[i] = item_names[i];
                } else {
                    new_item_names[i] = item_names[size - 1];
                }
            }
            item_names = null;
            item_names = new_item_names;
        }

        if (item_desc != null) {
            String[] new_item_desc = new String[new_size];
            for (int i = 0; i < new_size; i++) {
                if (i < size) {
                    new_item_desc[i] = item_desc[i];
                } else {
                    new_item_desc[i] = item_desc[size - 1];
                }
            }
            item_desc = null;
            item_desc = new_item_desc;
        }
        size = new_size;
    }

    public String[] getItemNames () {return item_names;}
    public String[] getItemDesc () {return item_desc;}
    public String toString () {return name;}

    public void addItemName(int i, String in, int size) {
        if (item_names == null) {
            item_names = new String[size];
        }
        item_names[i] = in;
    }

    public void addItemDesc(int i, String in, int size) {
        if (item_desc == null) {
            item_desc = new String[size];
        }
        item_desc[i] = in;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy