1 /*
2 * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
393 Object val = e.getValue();
394 if (key.equals(DEFINED_KEY)) {
395 result.defineAll(((Integer)val).intValue());
396 } else {
397 try {
398 EAttribute ea =
399 EAttribute.forAttribute((Attribute)key);
400 if (ea != null) {
401 result.set(ea, val);
402 }
403 }
404 catch (ClassCastException ex) {
405 }
406 }
407 }
408 }
409 return result;
410 }
411
412 public Hashtable<Object, Object> toSerializableHashtable() {
413 Hashtable ht = new Hashtable();
414 int hashkey = defined;
415 for (int m = defined, i = 0; m != 0; ++i) {
416 EAttribute ea = EAttribute.atts[i];
417 if ((m & ea.mask) != 0) {
418 m &= ~ea.mask;
419 Object o = get(ea);
420 if (o == null) {
421 // hashkey will handle it
422 } else if (o instanceof Serializable) { // check all...
423 ht.put(ea.att, o);
424 } else {
425 hashkey &= ~ea.mask;
426 }
427 }
428 }
429 ht.put(DEFINED_KEY, Integer.valueOf(hashkey));
430
431 return ht;
432 }
433
781 if (obj != null && obj instanceof NumericShaper) {
782 return (NumericShaper)obj;
783 }
784 }
785 return DEFAULT.numericShaping;
786 }
787
788 /**
789 * If this has an imHighlight, create copy of this with those attributes
790 * applied to it. Otherwise return this unchanged.
791 */
792 public AttributeValues applyIMHighlight() {
793 if (imHighlight != null) {
794 InputMethodHighlight hl = null;
795 if (imHighlight instanceof InputMethodHighlight) {
796 hl = (InputMethodHighlight)imHighlight;
797 } else {
798 hl = (InputMethodHighlight)((Annotation)imHighlight).getValue();
799 }
800
801 Map imStyles = hl.getStyle();
802 if (imStyles == null) {
803 Toolkit tk = Toolkit.getDefaultToolkit();
804 imStyles = tk.mapInputMethodHighlight(hl);
805 }
806
807 if (imStyles != null) {
808 return clone().merge(imStyles);
809 }
810 }
811
812 return this;
813 }
814
815 public static AffineTransform getBaselineTransform(Map<?, ?> map) {
816 if (map != null) {
817 AttributeValues av = null;
818 if (map instanceof AttributeMap &&
819 ((AttributeMap) map).getValues() != null) {
820 av = ((AttributeMap)map).getValues();
821 } else if (map.get(TextAttribute.TRANSFORM) != null) {
822 av = AttributeValues.fromMap((Map<Attribute, ?>)map); // yuck
823 }
824 if (av != null) {
825 return av.baselineTransform;
826 }
827 }
828 return null;
829 }
830
831 public static AffineTransform getCharTransform(Map<?, ?> map) {
832 if (map != null) {
833 AttributeValues av = null;
834 if (map instanceof AttributeMap &&
835 ((AttributeMap) map).getValues() != null) {
836 av = ((AttributeMap)map).getValues();
837 } else if (map.get(TextAttribute.TRANSFORM) != null) {
838 av = AttributeValues.fromMap((Map<Attribute, ?>)map); // yuck
839 }
840 if (av != null) {
841 return av.charTransform;
842 }
843 }
844 return null;
845 }
846
847 public void updateDerivedTransforms() {
848 // this also updates the mask for the baseline transform
849 if (transform == null) {
850 baselineTransform = null;
|
1 /*
2 * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
393 Object val = e.getValue();
394 if (key.equals(DEFINED_KEY)) {
395 result.defineAll(((Integer)val).intValue());
396 } else {
397 try {
398 EAttribute ea =
399 EAttribute.forAttribute((Attribute)key);
400 if (ea != null) {
401 result.set(ea, val);
402 }
403 }
404 catch (ClassCastException ex) {
405 }
406 }
407 }
408 }
409 return result;
410 }
411
412 public Hashtable<Object, Object> toSerializableHashtable() {
413 Hashtable<Object, Object> ht = new Hashtable<>();
414 int hashkey = defined;
415 for (int m = defined, i = 0; m != 0; ++i) {
416 EAttribute ea = EAttribute.atts[i];
417 if ((m & ea.mask) != 0) {
418 m &= ~ea.mask;
419 Object o = get(ea);
420 if (o == null) {
421 // hashkey will handle it
422 } else if (o instanceof Serializable) { // check all...
423 ht.put(ea.att, o);
424 } else {
425 hashkey &= ~ea.mask;
426 }
427 }
428 }
429 ht.put(DEFINED_KEY, Integer.valueOf(hashkey));
430
431 return ht;
432 }
433
781 if (obj != null && obj instanceof NumericShaper) {
782 return (NumericShaper)obj;
783 }
784 }
785 return DEFAULT.numericShaping;
786 }
787
788 /**
789 * If this has an imHighlight, create copy of this with those attributes
790 * applied to it. Otherwise return this unchanged.
791 */
792 public AttributeValues applyIMHighlight() {
793 if (imHighlight != null) {
794 InputMethodHighlight hl = null;
795 if (imHighlight instanceof InputMethodHighlight) {
796 hl = (InputMethodHighlight)imHighlight;
797 } else {
798 hl = (InputMethodHighlight)((Annotation)imHighlight).getValue();
799 }
800
801 Map<TextAttribute, ?> imStyles = hl.getStyle();
802 if (imStyles == null) {
803 Toolkit tk = Toolkit.getDefaultToolkit();
804 imStyles = tk.mapInputMethodHighlight(hl);
805 }
806
807 if (imStyles != null) {
808 return clone().merge(imStyles);
809 }
810 }
811
812 return this;
813 }
814
815 @SuppressWarnings("unchecked")
816 public static AffineTransform getBaselineTransform(Map<?, ?> map) {
817 if (map != null) {
818 AttributeValues av = null;
819 if (map instanceof AttributeMap &&
820 ((AttributeMap) map).getValues() != null) {
821 av = ((AttributeMap)map).getValues();
822 } else if (map.get(TextAttribute.TRANSFORM) != null) {
823 av = AttributeValues.fromMap((Map<Attribute, ?>)map); // yuck
824 }
825 if (av != null) {
826 return av.baselineTransform;
827 }
828 }
829 return null;
830 }
831
832 @SuppressWarnings("unchecked")
833 public static AffineTransform getCharTransform(Map<?, ?> map) {
834 if (map != null) {
835 AttributeValues av = null;
836 if (map instanceof AttributeMap &&
837 ((AttributeMap) map).getValues() != null) {
838 av = ((AttributeMap)map).getValues();
839 } else if (map.get(TextAttribute.TRANSFORM) != null) {
840 av = AttributeValues.fromMap((Map<Attribute, ?>)map); // yuck
841 }
842 if (av != null) {
843 return av.charTransform;
844 }
845 }
846 return null;
847 }
848
849 public void updateDerivedTransforms() {
850 // this also updates the mask for the baseline transform
851 if (transform == null) {
852 baselineTransform = null;
|