コード例 #1
0
  public boolean generateCustomSetValue(
      final LwComponent lwComponent,
      final InstrumentationClassFinder.PseudoClass componentClass,
      final LwIntrospectedProperty property,
      final GeneratorAdapter generator,
      final int componentLocal,
      final String formClassName) {
    FontDescriptor descriptor = (FontDescriptor) property.getPropertyValue(lwComponent);
    if (descriptor.isFixedFont() && !descriptor.isFullyDefinedFont()) {
      generator.loadLocal(componentLocal);
      generatePushFont(
          generator, componentLocal, lwComponent, descriptor, property.getReadMethodName());

      Method setFontMethod =
          new Method(property.getWriteMethodName(), Type.VOID_TYPE, new Type[] {ourFontType});
      Type componentType = AsmCodeGenerator.typeFromClassName(lwComponent.getComponentClassName());
      generator.invokeVirtual(componentType, setFontMethod);
      return true;
    }
    return false;
  }
コード例 #2
0
  public static void generatePushFont(
      final GeneratorAdapter generator,
      final int componentLocal,
      final LwComponent lwComponent,
      final FontDescriptor descriptor,
      final String readMethodName) {
    final int fontLocal = generator.newLocal(ourFontType);

    generator.loadLocal(componentLocal);
    Type componentType = AsmCodeGenerator.typeFromClassName(lwComponent.getComponentClassName());
    Method getFontMethod = new Method(readMethodName, ourFontType, new Type[0]);
    generator.invokeVirtual(componentType, getFontMethod);
    generator.storeLocal(fontLocal);

    generator.newInstance(ourFontType);
    generator.dup();
    if (descriptor.getFontName() != null) {
      generator.push(descriptor.getFontName());
    } else {
      generator.loadLocal(fontLocal);
      generator.invokeVirtual(ourFontType, ourGetNameMethod);
    }

    if (descriptor.getFontStyle() >= 0) {
      generator.push(descriptor.getFontStyle());
    } else {
      generator.loadLocal(fontLocal);
      generator.invokeVirtual(ourFontType, ourGetStyleMethod);
    }

    if (descriptor.getFontSize() >= 0) {
      generator.push(descriptor.getFontSize());
    } else {
      generator.loadLocal(fontLocal);
      generator.invokeVirtual(ourFontType, ourGetSizeMethod);
    }
    generator.invokeConstructor(ourFontType, ourInitMethod);
  }