public GridSampleDimension( String description, Category[] categories, double scale, double offset) { this(description, list(categories, null), scale, offset); }
/** * Constructs a sample dimension with a set of qualitative categories only. This constructor * expects only a sequence of category names for the values contained in a sample dimension. * This allows for names to be assigned to numerical values. The first entry in the sequence * relates to a cell value of zero. For example: [0]="Background", [1]="Water", [2]="Forest", * [3]="Urban". The created sample dimension will have no unit and a default set of colors. * * @param description The sample dimension title or description, or {@code null} for the default * (the name of what looks like the "main" category). This is the value to be returned by * {@link #getDescription}. * @param categoriesNames Sequence of category names for the values contained in a sample * dimension, as {@link String} or {@link InternationalString} objects. * @since 2.3 */ public GridSampleDimension( final CharSequence description, final CharSequence[] categoriesNames) { // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE #4093999 // ("Relax constraint on placement of this()/super() call in constructors"). this(description, list(categoriesNames), 1, 0); }
/** * Constructs a sample dimension with an arbitrary set of categories, which may be both * quantitative and qualitative. It is possible to specify more than one quantitative * categories, providing that their sample value ranges do not overlap. * * @param description The sample dimension title or description, or {@code null} for the default * (the name of what looks like the "main" category). This is the value to be returned by * {@link #getDescription}. * @param categories The list of categories. * @param units The unit information for this sample dimension. May be {@code null} if no * category has units. * @throws IllegalArgumentException if {@code categories} contains incompatible categories. If * may be the case for example if two or more categories have overlapping ranges of sample * values. * @since 2.3 */ public GridSampleDimension(CharSequence description, Category[] categories, Unit<?> units) throws IllegalArgumentException { // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE #4093999 // ("Relax constraint on placement of this()/super() call in constructors"). this(description, list(categories, units), 1, 0); this.units = units; }
/** * Constructs a sample dimension with a set of qualitative categories and colors. This * constructor expects a sequence of category names for the values contained in a sample * dimension. This allows for names to be assigned to numerical values. The first entry in the * sequence relates to a cell value of zero. For example: [0]="Background", [1]="Water", * [2]="Forest", [3]="Urban". The created sample dimension will have no unit and a default set * of colors. * * @param description The sample dimension title or description, or {@code null} for the default * (the name of what looks like the "main" category). This is the value to be returned by * {@link #getDescription}. * @param names Sequence of category names for the values contained in a sample dimension, as * {@link String} or {@link InternationalString} objects. * @param colors Color to assign to each category. This array must have the same length than * {@code names}. * @since 2.3 */ public GridSampleDimension( final CharSequence description, final CharSequence[] names, final Color[] colors) { // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE #4093999 // ("Relax constraint on placement of this()/super() call in constructors"). this(description, list(names, colors), 1, 0); }
/** Constructs a list of categories. Used by constructors only. */ private static CategoryList list(final CharSequence[] names) { final int length = names.length; final Color[] colors = new Color[length]; final double scale = 255.0 / length; for (int i = 0; i < length; i++) { final int r = (int) Math.round(scale * i); colors[i] = new Color(r, r, r); } return list(names, colors); }
/** Constructs a list of categories. Used by constructors only. */ private static CategoryList list(final CharSequence[] names, final Color[] colors) { if (names.length != colors.length) { throw new IllegalArgumentException(Errors.format(ErrorKeys.MISMATCHED_ARRAY_LENGTH)); } final int length = names.length; final Category[] categories = new Category[length]; for (int i = 0; i < length; i++) { categories[i] = new Category(names[i], colors[i], i); } return list(categories, null); }
/** * Constructs a sample dimension with a set of qualitative categories only. This constructor * expects only a sequence of category names for the values contained in a sample dimension. * This allows for names to be assigned to numerical values. The first entry in the sequence * relates to a cell value of zero. For example: [0]="Background", [1]="Water", [2]="Forest", * [3]="Urban". The created sample dimension will have no unit and a default set of colors. * * @param description * The sample dimension title or description, or {@code null} for the default * (the name of what looks like the "main" category). This is the value to be * returned by {@link #getDescription}. * @param categoriesNames * Sequence of category names for the values contained in a sample dimension, * as {@link String} or {@link InternationalString} objects. * * @since 2.3 */ public GridSampleDimension(final CharSequence description, final CharSequence[] categoriesNames) { // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE #4093999 // ("Relax constraint on placement of this()/super() call in constructors"). this(description, list(categoriesNames)); }
/** * Constructs a sample dimension with a set of qualitative categories only. * This constructor expects only a sequence of category names for the values * contained in a sample dimension. This allows for names to be assigned to * numerical values. The first entry in the sequence relates to a cell value * of zero. For example: [0]="Background", [1]="Water", [2]="Forest", * [3]="Urban". The created sample dimension will have no unit and a default * set of colors. * * @param description * The sample dimension title or description, or {@code null} for the default * (the name of what looks like the "main" category). This is the value to be * returned by {@link #getDescription}. * @param categoriesNames * Sequence of category names for the values contained in a * sample dimension, as {@link String} or * {@link InternationalString} objects. * * @since 2.3 */ public GridSampleDimension(final CharSequence description, final CharSequence[] categoriesNames) { // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE #4093999 // ("Relax constraint on placement of this()/super() call in constructors"). this(description, list(categoriesNames)); }
/** * Constructs a sample dimension with a set of qualitative categories and colors. This * constructor expects a sequence of category names for the values contained in a sample * dimension. This allows for names to be assigned to numerical values. The first entry in * the sequence relates to a cell value of zero. For example: [0]="Background", [1]="Water", * [2]="Forest", [3]="Urban". The created sample dimension will have no unit and a default * set of colors. * * @param description * The sample dimension title or description, or {@code null} for the default * (the name of what looks like the "main" category). This is the value to be * returned by {@link #getDescription}. * @param names * Sequence of category names for the values contained in a sample dimension, * as {@link String} or {@link InternationalString} objects. * @param colors * Color to assign to each category. This array must have the * same length than {@code names}. * * @since 2.3 */ public GridSampleDimension(final CharSequence description, final CharSequence[] names, final Color[] colors) { // TODO: 'list(...)' should be inlined there if only Sun was to fix RFE #4093999 // ("Relax constraint on placement of this()/super() call in constructors"). this(description, list(names, colors)); }
this(description, list(categories, units));
/** Constructs a list of categories. Used by constructors only. */ private static CategoryList list(final CharSequence[] names) { final int length = names.length; final Color[] colors = new Color[length]; final double scale = 255.0 / length; for (int i=0; i<length; i++) { final int r = (int) Math.round(scale * i); colors[i] = new Color(r, r, r); } return list(names, colors); }
this(description, list(names, colors));
this(description, list(categories, units));
/** Constructs a list of categories. Used by constructors only. */ private static CategoryList list(final CharSequence[] names) { final int length = names.length; final Color[] colors = new Color[length]; final double scale = 255.0 / length; for (int i = 0; i < length; i++) { final int r = (int) Math.round(scale * i); colors[i] = new Color(r, r, r); } return list(names, colors); }
/** Constructs a list of categories. Used by constructors only. */ private static CategoryList list(final CharSequence[] names, final Color[] colors) { if (names.length != colors.length) { throw new IllegalArgumentException(Errors.format(ErrorKeys.MISMATCHED_ARRAY_LENGTH)); } final int length = names.length; final Category[] categories = new Category[length]; for (int i=0; i<length; i++) { categories[i] = new Category(names[i], colors[i], i); } return list(categories, null); }
/** Constructs a list of categories. Used by constructors only. */ private static CategoryList list(final CharSequence[] names, final Color[] colors) { if (names.length != colors.length) { throw new IllegalArgumentException(Errors.format(ErrorKeys.MISMATCHED_ARRAY_LENGTH)); } final int length = names.length; final Category[] categories = new Category[length]; for (int i=0; i<length; i++) { categories[i] = new Category(names[i], colors[i], i); } return list(categories, null); }