Package org.jfree.layouting.input.swing

Examples of org.jfree.layouting.input.swing.ConverterAttributeSet


   * @param cssAttr The current converted CSS attributes.
   * @return The conversion result or null if no converstion has been done.
   */
  private ConverterAttributeSet handleStringAttributes(final Object key, final Object value, final ConverterAttributeSet cssAttr)
  {
    final ConverterAttributeSet attr = new ConverterAttributeSet();

    final String styleKey = (String) key;

    if (styleKey.equals(RTF_PAGEWIDTH) || styleKey.equals(RTF_PAGEHEIGHT))
    {
      final float floatValue = ((Float) value).floatValue();
      final Object size = cssAttr.getAttribute(PageStyleKeys.SIZE.getName());
      double width = 0;
      double height = 0;

      if(size instanceof PageSize)
      {
        final PageSize pageSize = (PageSize)size;
        width = pageSize.getWidth();
        height = pageSize.getHeight();
      }
      else if(RTF_LANDSCAPE.equals(size))
      {
        if (styleKey.equals(RTF_PAGEWIDTH))
        {
          height = twipToInt(floatValue);
        }
        else
        {
          width = twipToInt(floatValue);
        }
      }
      else
      {
        if (styleKey.equals(RTF_PAGEWIDTH))
        {
          width = twipToInt(floatValue);
        }
        else
        {
          height = twipToInt(floatValue);
        }
      }

      attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), new PageSize(width, height));
    }
    else if(styleKey.equals(RTF_MARGINLEFT))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_LEFT.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_MARGINRIGHT))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_RIGHT.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_MARGINTOP))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_TOP.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_MARGINBOTTOM))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_BOTTOM.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_LANDSCAPE))
    {
      final Object size = cssAttr.getAttribute(PageStyleKeys.SIZE.getName());
      if(size instanceof PageSize)
      {
        final PageSize pageSize = (PageSize)size;
        attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), new PageSize(pageSize.getHeight(), pageSize.getWidth()));
      }
      else
      {
        attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), RTF_LANDSCAPE);
      }
    }
    else
    {
      DebugLog.log("Unkown type of document attribute: " + styleKey);
View Full Code Here


   * @return The conversion result or null if no converstion has been done.
   */
  protected ConverterAttributeSet handleFontConstants(final StyleConstants.FontConstants fontConstant,
                                                      final Object value)
  {
    final ConverterAttributeSet attr = new ConverterAttributeSet();

    if (fontConstant == StyleConstants.FontFamily)
    {
      // just attribute name conversion
      attr.addAttribute(FontStyleKeys.FONT_FAMILY.getName(), value);

    }
    else if (fontConstant == StyleConstants.FontSize)
    {
      // just attribute name conversion
      attr.addAttribute(FontStyleKeys.FONT_SIZE.getName(), value);
    }
    else if (fontConstant == StyleConstants.Bold)
    {
      final Boolean b = (Boolean) value;
      if (Boolean.TRUE.equals(b))
      {
        attr.addAttribute(FontStyleKeys.FONT_WEIGHT.getName(), FontWeight.BOLD);
      }
      else
      {
        attr.addAttribute(FontStyleKeys.FONT_WEIGHT.getName(), FontWeight.NORMAL);
      }
    }
    else if (fontConstant == StyleConstants.Italic)
    {
      final Boolean b = (Boolean) value;
      if (Boolean.TRUE.equals(b))
      {
        attr.addAttribute(FontStyleKeys.FONT_STYLE.getName(), FontStyle.ITALIC);
      }
      else
      {
        attr.addAttribute(FontStyleKeys.FONT_STYLE.getName(), FontStyle.NORMAL);
      }
    }
    else
    {
      DebugLog.log("Unkown type of font attribute: " + fontConstant);
View Full Code Here

   * @return The conversion result or null if no converstion has been done.
   */
  private ConverterAttributeSet handleColorConstants(final StyleConstants.ColorConstants colorConstant,
                                                     final Object value)
  {
    final ConverterAttributeSet attr = new ConverterAttributeSet();

    if (colorConstant == StyleConstants.Foreground)
    {
      final CSSColorValue cssColorValue = new CSSColorValue((Color) value);
      attr.addAttribute(ColorStyleKeys.COLOR.getName(), cssColorValue);
    }
    else if (colorConstant == StyleConstants.Background)
    {
      final CSSColorValue cssColorValue = new CSSColorValue((Color) value);
      attr.addAttribute(BorderStyleKeys.BACKGROUND_COLOR.getName(), cssColorValue);
    }
    else
    {
      DebugLog.log("Unkown type of color attribute " + colorConstant);
      return null;
View Full Code Here

      return handleCharacterConstants(characterConstant, value, cssAttr);
    }
    else if(key instanceof String)
    {
      final String constant = (String)key;
      final ConverterAttributeSet attr = new ConverterAttributeSet();
      if(constant.equals(RTF_SMALLCAPS))
      {
        final Boolean b = (Boolean)value;
        if(Boolean.TRUE.equals(b))
        {
          attr.addAttribute(FontStyleKeys.FONT_VARIANT.getName(), FontVariant.SMALL_CAPS);
        }
      }
      else if(constant.equals(RTF_CAPS))
      {
        final Boolean b = (Boolean)value;
        if(Boolean.TRUE.equals(b))
        {
          attr.addAttribute(TextStyleKeys.TEXT_TRANSFORM.getName(), TextTransform.CAPITALIZE);
        }
      }
      else if(constant.equals(RTF_OUTLINE))
      {
        final Boolean b = (Boolean)value;
        if(Boolean.TRUE.equals(b))
        {
          attr.addAttribute(FontStyleKeys.FONT_EFFECT, FontEffects.OUTLINE);
        }
      }
      else if(constant.equals(RTF_STRIKETRHOUGH))
      {
        final Object current = cssAttr.getAttribute(TEXT_DECORATION_KEY);
        attr.addAttribute(TEXT_DECORATION_KEY, mergeTextDecorationValues(current, LINETHROUGH_TEXT_DECORATION));
      }
      else
      {
        DebugLog.log("Unkown type of character attribute" + constant);
        return null;
View Full Code Here

   */
  private ConverterAttributeSet handleCharacterConstants (
          final StyleConstants.CharacterConstants characterConstant, final Object value,
          final ConverterAttributeSet cssAttr)
  {
    final ConverterAttributeSet attr = new ConverterAttributeSet();

    if(characterConstant == StyleConstants.Underline)
    {
      final Boolean b = (Boolean)value;
      if(Boolean.TRUE.equals(b))
      {
        final Object current = cssAttr.getAttribute(TEXT_DECORATION_KEY);
        attr.addAttribute(TEXT_DECORATION_KEY, mergeTextDecorationValues(current, UNDERLINE_TEXT_DECORATION));
      }
      else
      {
        attr.addAttribute(TEXT_DECORATION_KEY, NONE_TEXT_DECORATION);
      }
    }
    else if(characterConstant == StyleConstants.StrikeThrough)
    {
      final Boolean b = (Boolean)value;
      if(Boolean.TRUE.equals(b))
      {
        final Object current = cssAttr.getAttribute(TEXT_DECORATION_KEY);
        attr.addAttribute(TEXT_DECORATION_KEY, mergeTextDecorationValues(current, LINETHROUGH_TEXT_DECORATION));
      }
      else
      {
        attr.addAttribute(TEXT_DECORATION_KEY, NONE_TEXT_DECORATION);
      }
    }
    else if(characterConstant == StyleConstants.Superscript)
    {
      final Boolean b = (Boolean)value;
      if(Boolean.TRUE.equals(b))
      {
        attr.addAttribute(LineStyleKeys.VERTICAL_ALIGN.getName(), VerticalAlign.SUPER);
      }
    }
    else if(characterConstant == StyleConstants.Subscript)
    {
      final Boolean b = (Boolean)value;
      if(Boolean.TRUE.equals(b))
      {
        attr.addAttribute(LineStyleKeys.VERTICAL_ALIGN.getName(), VerticalAlign.SUB);
      }
    }
    else if(characterConstant == StyleConstants.BidiLevel)
    {
      final Boolean b = (Boolean)value;
      if(Boolean.TRUE.equals(b))
      {
        attr.addAttribute(TextStyleKeys.UNICODE_BIDI.getName(), UnicodeBidi.EMBED);
      }
      else
      {
        attr.addAttribute(TextStyleKeys.UNICODE_BIDI.getName(), UnicodeBidi.NORMAL);
      }
    }
    else
    {
      DebugLog.log("Unkown type of character attribute" + characterConstant);
View Full Code Here

   * @return The conversion result or null if no converstion has been done.
   */
  private ConverterAttributeSet handleParagraphConstants (
          final StyleConstants.ParagraphConstants paragraphConstant, final Object value)
  {
    final ConverterAttributeSet attr = new ConverterAttributeSet();

    if(paragraphConstant == StyleConstants.FirstLineIndent)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.PT, Double.parseDouble(value.toString()));
      attr.addAttribute(TextStyleKeys.TEXT_INDENT.getName(), cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.RightIndent)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.PT, Double.parseDouble(value.toString()));
      attr.addAttribute(BoxStyleKeys.MARGIN_RIGHT.getName(), cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.LeftIndent)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.PT, Double.parseDouble(value.toString()));
      attr.addAttribute(BoxStyleKeys.MARGIN_LEFT.getName(), cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.LineSpacing)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.EM, Double.parseDouble(value.toString()));
      attr.addAttribute(LineStyleKeys.LINE_HEIGHT, cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.SpaceAbove)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.PT, Double.parseDouble(value.toString()));
      attr.addAttribute(BoxStyleKeys.MARGIN_TOP.getName(), cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.SpaceBelow)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.PT, Double.parseDouble(value.toString()));
      attr.addAttribute(BoxStyleKeys.MARGIN_BOTTOM.getName(), cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.Alignment)
    {
      Object val = null;
      final int interger = Integer.parseInt(value.toString());
      if(interger == StyleConstants.ALIGN_CENTER)
      {
        val = TextAlign.CENTER;
      }
      else if(interger == StyleConstants.ALIGN_JUSTIFIED)
      {
        val = TextAlign.JUSTIFY;
      }
      else if(interger == StyleConstants.ALIGN_LEFT)
      {
        val = TextAlign.LEFT;
      }
      else if(interger == StyleConstants.ALIGN_RIGHT)
      {
        val = TextAlign.RIGHT;
      }

      attr.addAttribute(TextStyleKeys.TEXT_ALIGN.getName(), val);
    }
    else
    {
      // StyleConstants.TabSet @see TabSet class
      DebugLog.log("Unkown type of paragraphe attribute: " + paragraphConstant);
View Full Code Here

   * @param cssAttr The current converted CSS attributes.
   * @return The conversion result or null if no converstion has been done.
   */
  private ConverterAttributeSet handleStringAttributes(final Object key, final Object value, final ConverterAttributeSet cssAttr)
  {
    final ConverterAttributeSet attr = new ConverterAttributeSet();

    final String styleKey = (String) key;

    if (styleKey.equals(RTF_PAGEWIDTH) || styleKey.equals(RTF_PAGEHEIGHT))
    {
      final float floatValue = ((Float) value).floatValue();
      final Object size = cssAttr.getAttribute(PageStyleKeys.SIZE.getName());
      double width = 0;
      double height = 0;

      if(size instanceof PageSize)
      {
        final PageSize pageSize = (PageSize)size;
        width = pageSize.getWidth();
        height = pageSize.getHeight();
      }
      else if(RTF_LANDSCAPE.equals(size))
      {
        if (styleKey.equals(RTF_PAGEWIDTH))
        {
          height = twipToInt(floatValue);
        }
        else
        {
          width = twipToInt(floatValue);
        }
      }
      else
      {
        if (styleKey.equals(RTF_PAGEWIDTH))
        {
          width = twipToInt(floatValue);
        }
        else
        {
          height = twipToInt(floatValue);
        }
      }

      attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), new PageSize(width, height));
    }
    else if(styleKey.equals(RTF_MARGINLEFT))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_LEFT.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_MARGINRIGHT))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_RIGHT.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_MARGINTOP))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_TOP.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_MARGINBOTTOM))
    {
      final float floatValue = ((Float) value).floatValue();
      attr.addAttribute(PAGE_RULE_TYPE, BoxStyleKeys.MARGIN_BOTTOM.getName(), CSSNumericValue.createValue(CSSNumericType.PT, floatValue));
    }
    else if(styleKey.equals(RTF_LANDSCAPE))
    {
      final Object size = cssAttr.getAttribute(PageStyleKeys.SIZE.getName());
      if(size instanceof PageSize)
      {
        final PageSize pageSize = (PageSize)size;
        attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), new PageSize(pageSize.getHeight(), pageSize.getWidth()));
      }
      else
      {
        attr.addAttribute(PAGE_RULE_TYPE, PageStyleKeys.SIZE.getName(), RTF_LANDSCAPE);
      }
    }
    else
    {
      Log.debug(new Log.SimpleMessage("Unkown type of document attribute", styleKey));
View Full Code Here

   * @return The conversion result or null if no converstion has been done.
   */
  protected ConverterAttributeSet handleFontConstants (final StyleConstants.FontConstants fontConstant,
                                              final Object value)
  {
    final ConverterAttributeSet attr = new ConverterAttributeSet();

    if(fontConstant == StyleConstants.FontFamily)
    {
      // just attribute name conversion
      attr.addAttribute(FontStyleKeys.FONT_FAMILY.getName(), value);

    }
    else if(fontConstant == StyleConstants.FontSize)
    {
      // just attribute name conversion
      attr.addAttribute(FontStyleKeys.FONT_SIZE.getName(), value);
    }
    else if (fontConstant == StyleConstants.Bold)
    {
      final Boolean b = (Boolean)value;
      if(Boolean.TRUE.equals(b))
      {
        attr.addAttribute(FontStyleKeys.FONT_WEIGHT.getName(), FontWeight.BOLD);
      }
      else
      {
        attr.addAttribute(FontStyleKeys.FONT_WEIGHT.getName(), FontWeight.NORMAL);
      }
    }
    else if (fontConstant == StyleConstants.Italic)
    {
      final Boolean b = (Boolean)value;
      if(Boolean.TRUE.equals(b))
      {
        attr.addAttribute(FontStyleKeys.FONT_STYLE.getName(), FontStyle.ITALIC);
      }
      else
      {
        attr.addAttribute(FontStyleKeys.FONT_STYLE.getName(), FontStyle.NORMAL);
      }
    }
    else
    {
      Log.debug(new Log.SimpleMessage("Unkown type of font attribute", fontConstant));
View Full Code Here

   * @return The conversion result or null if no converstion has been done.
   */
  private ConverterAttributeSet handleColorConstants (final StyleConstants.ColorConstants colorConstant,
                                     final Object value)
  {
    final ConverterAttributeSet attr = new ConverterAttributeSet();

    if(colorConstant == StyleConstants.Foreground)
    {
      final CSSColorValue cssColorValue = new CSSColorValue((Color) value);
      attr.addAttribute(ColorStyleKeys.COLOR.getName(), cssColorValue);
    }
    else if(colorConstant == StyleConstants.Background)
    {
      final CSSColorValue cssColorValue = new CSSColorValue((Color) value);
      attr.addAttribute(BorderStyleKeys.BACKGROUND_COLOR.getName(), cssColorValue);
    }
    else
    {
      Log.debug(new Log.SimpleMessage("Unkown type of color attribute", colorConstant));
      return null;
View Full Code Here

      return handleCharacterConstants(characterConstant, value, cssAttr);
    }
    else if(key instanceof String)
    {
      final String constant = (String)key;
      final ConverterAttributeSet attr = new ConverterAttributeSet();
      if(constant.equals(RTF_SMALLCAPS))
      {
        final Boolean b = (Boolean)value;
        if(Boolean.TRUE.equals(b))
        {
          attr.addAttribute(FontStyleKeys.FONT_VARIANT.getName(), FontVariant.SMALL_CAPS);
        }
      }
      else if(constant.equals(RTF_CAPS))
      {
        final Boolean b = (Boolean)value;
        if(Boolean.TRUE.equals(b))
        {
          attr.addAttribute(TextStyleKeys.TEXT_TRANSFORM.getName(), TextTransform.CAPITALIZE);
        }
      }
      else if(constant.equals(RTF_OUTLINE))
      {
        final Boolean b = (Boolean)value;
        if(Boolean.TRUE.equals(b))
        {
          attr.addAttribute(FontStyleKeys.FONT_EFFECT, FontEffects.OUTLINE);
        }
      }
      else if(constant.equals(RTF_STRIKETRHOUGH))
      {
        final Object current = cssAttr.getAttribute(TEXT_DECORATION_KEY);
        attr.addAttribute(TEXT_DECORATION_KEY, mergeTextDecorationValues(current, LINETHROUGH_TEXT_DECORATION));
      }
      else
      {
        Log.debug(new Log.SimpleMessage("Unkown type of character attribute", constant));
        return null;
View Full Code Here

TOP

Related Classes of org.jfree.layouting.input.swing.ConverterAttributeSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.