type = ((Hints.Key) key).getValueClass(); } else { type = Factory.class; // Kind of unknown factory type...
return super.isCompatibleValue(value);
public static Hints.Key PRE_APPLIED_SCALE = new Hints.Key(Double[].class);
Hints.USE_JAI_IMAGEREAD.toString(), Boolean.class, new Boolean[] { Boolean.TRUE, Boolean.FALSE }, Boolean.TRUE); Hints.OVERVIEW_POLICY.toString(), OverviewPolicy.class, new OverviewPolicy[] { OverviewPolicy.IGNORE, OverviewPolicy.NEAREST, Hints.DECIMATION_POLICY.toString(), DecimationPolicy.class, new DecimationPolicy[] { DecimationPolicy.ALLOW, DecimationPolicy.DISALLOW }, DecimationPolicy.ALLOW);
final Class valueClass = key.getValueClass(); if (!category.isAssignableFrom(valueClass)) { if (debug) {
final Class<?> valueClass = key.getValueClass(); if (!category.isAssignableFrom(valueClass)) { if (debug) {
type = ((Hints.Key) key).getValueClass(); } else { type = Factory.class; // Kind of unknown factory type...
final RenderingHints.Key hintKey = (RenderingHints.Key) entry.getValue(); if (hintKey.getClass().equals(Hints.Key.class)) { final Class type = ((Hints.Key) hintKey).getValueClass(); if (type.equals(Boolean.class)) { value = Boolean.valueOf(property);
final RenderingHints.Key hintKey = entry.getValue(); if (hintKey.getClass().equals(Hints.Key.class)) { final Class<?> type = ((Hints.Key) hintKey).getValueClass(); if (type.equals(Boolean.class)) { value = Boolean.valueOf(property);
switch (t++) { case 0: type = Hints.class; break; case 1: type = getValueClass(); break; default: return super.toString();
/** * Returns {@code true} if the specified object is a valid value for * this key. The default implementation checks if the specified value * {@linkplain Class#isInstance is an instance} of the {@linkplain * #getValueClass value class}. * <p> * Note that many hint keys defined in the {@link Hints} class relax this rule and accept * {@link Class} object assignable to the expected {@linkplain #getValueClass value class} * as well. * * @param value * The object to test for validity. * @return {@code true} if the value is valid; {@code false} otherwise. * * @see Hints.ClassKey#isCompatibleValue * @see Hints.FileKey#isCompatibleValue * @see Hints.IntegerKey#isCompatibleValue * @see Hints.OptionKey#isCompatibleValue */ public boolean isCompatibleValue(final Object value) { return getValueClass().isInstance(value); }
/** * Returns {@code true} if the specified object is a valid value for * this key. The default implementation checks if the specified value * {@linkplain Class#isInstance is an instance} of the {@linkplain * #getValueClass value class}. * <p> * Note that many hint keys defined in the {@link Hints} class relax this rule and accept * {@link Class} object assignable to the expected {@linkplain #getValueClass value class} * as well. * * @param value * The object to test for validity. * @return {@code true} if the value is valid; {@code false} otherwise. * * @see Hints.ClassKey#isCompatibleValue * @see Hints.FileKey#isCompatibleValue * @see Hints.IntegerKey#isCompatibleValue * @see Hints.OptionKey#isCompatibleValue */ public boolean isCompatibleValue(final Object value) { return getValueClass().isInstance(value); }
/** * Utility method used to organize pairs into a Map. * * @param pairs * An array of Key/Value pairs * @return Map<Key,Value> * @throws ClassCastException * if Key/Value pairs do not match */ private static Map fromPairs(Object[] pairs) { Map map = new HashMap(); for (int i = 0; i < pairs.length; i += 2) { Key key = (Key) pairs[i]; Object value = pairs[i+1]; if (!key.isCompatibleValue(value)) { throw new ClassCastException(key + " requires " + key.getValueClass() + " - could cast " + value); } map.put(key, value); } return map; }
/** * Returns a string representation of this key. The string * representation is mostly for debugging purpose. The default * implementation tries to infer the key name using reflection. */ @Override public String toString() { int t = 0; while (true) { final Class<?> type; switch (t++) { case 0: type = Hints.class; break; case 1: type = getValueClass(); break; default: return super.toString(); } final String name = nameOf(type, this); if (name != null) { return name; } } } }
/** * Constructs a new key for values of the given class. The class is * specified by name instead of a {@link Class} object. This allows to * defer class loading until needed. * * @param className Name of base class for all valid values. */ Key(final String className) { super(count()); this.className = className; }
/** * Constructs a new key for values of the given class. The class is * specified by name instead of a {@link Class} object. This allows to * defer class loading until needed. * * @param className * Name of base class for all valid values. */ Key(final String className) { super(count()); this.className = className; }