コード例 #1
0
ファイル: PropertySetter.java プロジェクト: StigLau/vdvil
 private static TimingTarget getTargetHelper(
     final Object object,
     final String propertyName,
     final KeyFrames<?> keyFrames,
     final boolean isToAnimation) {
   if (object == null) throw new IllegalArgumentException(I18N.err(1, "object"));
   if (propertyName == null) throw new IllegalArgumentException(I18N.err(1, "propertyName"));
   if (keyFrames == null) throw new IllegalArgumentException(I18N.err(1, "keyFrames"));
   @SuppressWarnings("unchecked")
   final KeyFrames<Object> objectKeyFrames = (KeyFrames<Object>) keyFrames;
   /*
    * Find the setter method for the property.
    */
   Method propertySetter;
   final String firstChar = propertyName.substring(0, 1);
   final String remainder = propertyName.substring(1);
   final String propertySetterName = "set" + firstChar.toUpperCase(Locale.ENGLISH) + remainder;
   try {
     final PropertyDescriptor pd =
         new PropertyDescriptor(propertyName, object.getClass(), null, propertySetterName);
     propertySetter = pd.getWriteMethod();
   } catch (IntrospectionException e) {
     throw new IllegalArgumentException(
         I18N.err(30, propertySetterName, propertyName, object.toString()), e);
   }
   /*
    * Find the getter method for the property if this is a "to" animations
    */
   if (isToAnimation) {
     final String propertyGetterName = "get" + firstChar.toUpperCase(Locale.ENGLISH) + remainder;
     try {
       final PropertyDescriptor pd =
           new PropertyDescriptor(propertyName, object.getClass(), propertyGetterName, null);
       final Method propertyGetter = pd.getReadMethod();
       /*
        * Setup "to" animation.
        */
       return new PropertySetterToTimingTarget(
           objectKeyFrames, object, propertyGetter, propertySetter);
     } catch (IntrospectionException e) {
       throw new IllegalArgumentException(
           I18N.err(30, propertyGetterName, propertyName, object.toString()), e);
     }
   } else {
     /*
      * Setup animation.
      */
     return new PropertySetterTimingTarget(objectKeyFrames, object, propertySetter);
   }
 }
コード例 #2
0
ファイル: PropertySetter.java プロジェクト: StigLau/vdvil
 @Override
 public void valueAtTimingEvent(Object value, double fraction, Animator source) {
   try {
     f_propertySetter.invoke(f_object, value);
   } catch (Exception e) {
     throw new IllegalStateException(
         I18N.err(31, f_propertySetter.getName(), f_object.toString()), e);
   }
 }
コード例 #3
0
ファイル: PropertySetter.java プロジェクト: StigLau/vdvil
 @Override
 public void begin(Animator source) {
   try {
     final Object startValue = f_propertyGetter.invoke(f_object);
     final KeyFrames.Builder<Object> builder = new KeyFrames.Builder<Object>(startValue);
     boolean first = true;
     for (KeyFrames.Frame<Object> frame : getKeyFrames()) {
       if (first) first = false;
       else builder.addFrame(frame);
     }
     f_keyFrames.set(builder.build());
   } catch (Exception e) {
     throw new IllegalStateException(
         I18N.err(31, f_propertyGetter.getName(), f_object.toString()), e);
   }
 }
コード例 #4
0
ファイル: I18N.java プロジェクト: phil-brown/javaQuery
 /**
  * Gets and formats the string defined for the given error number from the i18 resource bundle.
  * Calling this method is equivalent to calling <tt>String.format(I18N.err(number), args).</tt>
  *
  * <p>The key for the error message in the <tt>Err</tt> properties file is
  * <tt>error.</tt><i>nnnnn</i>. For example, <tt>I18N.err(24, "bad")</tt> would result in the
  * string <tt>"(Timing Framework #24) A bad problem."</tt> if the line <tt>error.00024=A %s
  * problem.</tt> is contained in the <tt>Err</tt> properties file. If the key is not defined in
  * the <tt>Err</tt> properties file an exception is thrown.
  *
  * @param number the error message number.
  * @param args the variable arguments to format the resulting error message with.
  * @return the formatted error message for the given number.
  * @see String#format(String, Object...)
  */
 @RegionEffects("reads any(java.util.ResourceBundle):Instance")
 public static String err(final int number, Object... args) {
   return String.format(I18N.err(number), args);
 }