Package java.awt.font

Examples of java.awt.font.TextAttribute


    }

    @Override
    public void render(ReportContext context, TextBuilder builder,
            List<Forward> fwds) {
        TextAttribute keys[] = getKeys();
        Object savedValues[] = new Object[keys.length];
        for (int i = 0; i < keys.length; ++i) {
            savedValues[i] = builder.getAttribute(keys[i]);
            builder.setAttribute(keys[i], attributes.get(keys[i]));
        }
View Full Code Here


        encoder.writeObject(TextAttribute.BACKGROUND);
        encoder.close();
        DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
                byteArrayOutputStream.toByteArray()));
        XMLDecoder decoder = new XMLDecoder(stream);
        TextAttribute attribute = (TextAttribute) decoder.readObject();
        assertEquals(TextAttribute.BACKGROUND, attribute);
    }
View Full Code Here

      final AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.Attribute) iterator.next();
      if (!(attribute instanceof TextAttribute))
      {
        continue;
      }
      final TextAttribute textattribute = (TextAttribute) attribute;
      if (textattribute.equals(TextAttribute.FONT))
      {
        final Font font = (Font) iter.getAttributes().get(textattribute);
        setFont(font);
      }
      else if (textattribute.equals(TextAttribute.UNDERLINE))
      {
        if (iter.getAttributes().get(textattribute) == TextAttribute.UNDERLINE_ON)
        {
          underline = true;
        }
      }
      else if (textattribute.equals(TextAttribute.SIZE))
      {
        final Object obj = iter.getAttributes().get(textattribute);
        if (obj instanceof Integer)
        {
          final int i = ((Integer) obj).intValue();
          setFont(getFont().deriveFont(getFont().getStyle(), i));
        }
        else if (obj instanceof Float)
        {
          final float f = ((Float) obj).floatValue();
          setFont(getFont().deriveFont(getFont().getStyle(), f));
        }
      }
      else if (textattribute.equals(TextAttribute.FOREGROUND))
      {
        setColor((Color) iter.getAttributes().get(textattribute));
      }
      else if (textattribute.equals(TextAttribute.FAMILY))
      {
        final Font font = getFont();
        final Map fontAttributes = font.getAttributes();
        fontAttributes.put(TextAttribute.FAMILY, iter.getAttributes().get(textattribute));
        setFont(font.deriveFont(fontAttributes));
      }
      else if (textattribute.equals(TextAttribute.POSTURE))
      {
        final Font font = getFont();
        final Map fontAttributes = font.getAttributes();
        fontAttributes.put(TextAttribute.POSTURE, iter.getAttributes().get(textattribute));
        setFont(font.deriveFont(fontAttributes));
      }
      else if (textattribute.equals(TextAttribute.WEIGHT))
      {
        final Font font = getFont();
        final Map fontAttributes = font.getAttributes();
        fontAttributes.put(TextAttribute.WEIGHT, iter.getAttributes().get(textattribute));
        setFont(font.deriveFont(fontAttributes));
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public void mapInputMethodHighlight(InputMethodHighlight highlight, Map<TextAttribute, ?> map) {
        Map<TextAttribute, Object> _map = (Map<TextAttribute, Object>)map;
        TextAttribute key = TextAttribute.INPUT_METHOD_UNDERLINE;
        boolean selected = highlight.isSelected();
        switch(highlight.getState()) {
        case InputMethodHighlight.RAW_TEXT:
            _map.put(key, selected ? TextAttribute.UNDERLINE_LOW_GRAY :
                TextAttribute.UNDERLINE_LOW_DOTTED);
View Full Code Here

                do {
                    if (!attributes.isEmpty()) {
                        reader.moveDown();
                    }
                    final Class<?> type = mapper.realClass(reader.getAttribute(classAlias));
                    final TextAttribute attribute = (TextAttribute)textAttributeConverter.fromString(reader.getNodeName());
                    final Object value = type == Mapper.Null.class ? null : context.convertAnother(null, type);
                    attributes.put(attribute, value);
                    reader.moveUp();
                } while (reader.hasMoreChildren());
            } else {
View Full Code Here

    checkSerial(TextAttribute.WIDTH, harness);
  }
 
  private void checkSerial(TextAttribute ta1, TestHarness harness)
  {
    TextAttribute ta2 = null;

    try {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      ObjectOutput out = new ObjectOutputStream(buffer);
      out.writeObject(ta1);
View Full Code Here

        underline = false;
        strikethrough = false;
        for (AttributedCharacterIterator.Attribute attribute: iter.getAttributes().keySet()) {
            if (!(attribute instanceof TextAttribute))
                continue;
            TextAttribute textattribute = (TextAttribute)attribute;
            if(textattribute.equals(TextAttribute.FONT)) {
                Font font = (Font)iter.getAttributes().get(textattribute);
                setFont(font);
            }
            else if(textattribute.equals(TextAttribute.UNDERLINE)) {
                if(iter.getAttributes().get(textattribute) == TextAttribute.UNDERLINE_ON)
                    underline = true;
            }
            else if(textattribute.equals(TextAttribute.STRIKETHROUGH)) {
              if(iter.getAttributes().get(textattribute) == TextAttribute.STRIKETHROUGH_ON)
                strikethrough = true;
            }
            else if(textattribute.equals(TextAttribute.SIZE)) {
                Object obj = iter.getAttributes().get(textattribute);
                if(obj instanceof Integer) {
                    int i = ((Integer)obj).intValue();
                    setFont(getFont().deriveFont(getFont().getStyle(), i));
                }
                else if(obj instanceof Float) {
                    float f = ((Float)obj).floatValue();
                    setFont(getFont().deriveFont(getFont().getStyle(), f));
                }
            }
            else if(textattribute.equals(TextAttribute.FOREGROUND)) {
                setColor((Color) iter.getAttributes().get(textattribute));
            }
            else if(textattribute.equals(TextAttribute.FAMILY)) {
              Font font = getFont();
              Map fontAttributes = font.getAttributes();
              fontAttributes.put(TextAttribute.FAMILY, iter.getAttributes().get(textattribute));
              setFont(font.deriveFont(fontAttributes));
            }
            else if(textattribute.equals(TextAttribute.POSTURE)) {
              Font font = getFont();
              Map fontAttributes = font.getAttributes();
              fontAttributes.put(TextAttribute.POSTURE, iter.getAttributes().get(textattribute));
              setFont(font.deriveFont(fontAttributes));
            }
            else if(textattribute.equals(TextAttribute.WEIGHT)) {
              Font font = getFont();
              Map fontAttributes = font.getAttributes();
              fontAttributes.put(TextAttribute.WEIGHT, iter.getAttributes().get(textattribute));
              setFont(font.deriveFont(fontAttributes));
            }
View Full Code Here

        underline = false;
        strikethrough = false;
        for (AttributedCharacterIterator.Attribute attribute: iter.getAttributes().keySet()) {
            if (!(attribute instanceof TextAttribute))
                continue;
            TextAttribute textattribute = (TextAttribute)attribute;
            if(textattribute.equals(TextAttribute.FONT)) {
                Font font = (Font)iter.getAttributes().get(textattribute);
                setFont(font);
            }
            else if(textattribute.equals(TextAttribute.UNDERLINE)) {
                if(iter.getAttributes().get(textattribute) == TextAttribute.UNDERLINE_ON)
                    underline = true;
            }
            else if(textattribute.equals(TextAttribute.STRIKETHROUGH)) {
              if(iter.getAttributes().get(textattribute) == TextAttribute.STRIKETHROUGH_ON)
                strikethrough = true;
            }
            else if(textattribute.equals(TextAttribute.SIZE)) {
                Object obj = iter.getAttributes().get(textattribute);
                if(obj instanceof Integer) {
                    int i = ((Integer)obj).intValue();
                    setFont(getFont().deriveFont(getFont().getStyle(), i));
                }
                else if(obj instanceof Float) {
                    float f = ((Float)obj).floatValue();
                    setFont(getFont().deriveFont(getFont().getStyle(), f));
                }
            }
            else if(textattribute.equals(TextAttribute.FOREGROUND)) {
                setColor((Color) iter.getAttributes().get(textattribute));
            }
            else if(textattribute.equals(TextAttribute.FAMILY)) {
              Font font = getFont();
              Map fontAttributes = font.getAttributes();
              fontAttributes.put(TextAttribute.FAMILY, iter.getAttributes().get(textattribute));
              setFont(font.deriveFont(fontAttributes));
            }
            else if(textattribute.equals(TextAttribute.POSTURE)) {
              Font font = getFont();
              Map fontAttributes = font.getAttributes();
              fontAttributes.put(TextAttribute.POSTURE, iter.getAttributes().get(textattribute));
              setFont(font.deriveFont(fontAttributes));
            }
            else if(textattribute.equals(TextAttribute.WEIGHT)) {
              Font font = getFont();
              Map fontAttributes = font.getAttributes();
              fontAttributes.put(TextAttribute.WEIGHT, iter.getAttributes().get(textattribute));
              setFont(font.deriveFont(fontAttributes));
            }
View Full Code Here

    public void init(Map desktopProperties) {
    }

    public void mapInputMethodHighlight(InputMethodHighlight highlight, Map map) {
        TextAttribute key = TextAttribute.SWAP_COLORS;
        if (highlight.isSelected()) {
            map.put(key, TextAttribute.SWAP_COLORS_ON);
            return;
        }
        switch(highlight.getState()) {
View Full Code Here

    public boolean canConvert(Class type) {
        return type == TextAttribute.class;
    }

    public String toString(Object source) {
        TextAttribute attribute = (TextAttribute)source;
        try {
            getName.setAccessible(true);
            return (String)getName.invoke(attribute, (Object[])null);
        } catch (IllegalAccessException e) {
            throw new ObjectAccessException("Cannot get name of TextAttribute", e);
View Full Code Here

TOP

Related Classes of java.awt.font.TextAttribute

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.