## modules/graphics/src/main/java/javafx/scene/CssStyleHelper.java

Print this page

    rev 4839 : RT-2529: Locale specific runtime errors (Turkish)

      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
      23  * questions.
      24  */
      25 package javafx.scene;
      26
      27 import java.util.ArrayList;
      28 import java.util.Collections;
      29 import java.util.HashMap;
      30 import java.util.HashSet;
      31 import java.util.List;

      32 import java.util.Map;
      33 import java.util.Map.Entry;
      34 import java.util.Set;
      35
      36 import com.sun.javafx.scene.CssFlags;
      37 import javafx.beans.property.ObjectProperty;
      38 import javafx.beans.property.SimpleObjectProperty;
      39 import javafx.collections.FXCollections;
      40 import javafx.collections.ObservableMap;
      41 import javafx.css.CssMetaData;
      42 import javafx.css.FontCssMetaData;
      43 import javafx.css.ParsedValue;
      44 import javafx.css.PseudoClass;
      45 import javafx.css.StyleConverter;
      46 import javafx.css.StyleOrigin;
      47 import javafx.css.Styleable;
      48 import javafx.css.StyleableProperty;
      49 import javafx.scene.text.Font;
      50 import javafx.scene.text.FontPosture;
      51 import javafx.scene.text.FontWeight;
    1490                     && parentCacheContainer.fontSizeCache.isEmpty() == false) {
    1491
    1492                 Set<PseudoClass>[] transitionStates = parentHelper.getTransitionStates(parent);
    1493                 StyleCacheEntry.Key parentCacheEntryKey = new StyleCacheEntry.Key(transitionStates, Font.getDefault());
    1494                 cachedFont = parentCacheContainer.fontSizeCache.get(parentCacheEntryKey);
    1495
    1496             } else {
    1497
    1498                 Set<PseudoClass> pseudoClassState = parent.getPseudoClassStates();
    1499                 StyleMap smap = parentHelper.getStyleMap(parent);
    1500                 cachedFont = parentHelper.lookup(parent, dummyFontProperty, smap, pseudoClassState, parent, null, null);
    1501             }
    1502         }
    1503
    1504         return cachedFont;
    1505     }
    1506
    1507     /*package access for testing*/ FontPosture getFontPosture(Font font) {
    1508         if (font == null) return FontPosture.REGULAR;
    1509
    1510         String fontName = font.getName().toLowerCase();
    1511
    1512         if (fontName.contains("italic")) {
    1513             return FontPosture.ITALIC;
    1514         }
    1515
    1516         return FontPosture.REGULAR;
    1517     }
    1518
    1519     /*package access for testing*/ FontWeight getFontWeight(Font font) {
    1520         if (font == null) return FontWeight.NORMAL;
    1521
    1522         String fontName = font.getName().toLowerCase();
    1523
    1524         if (fontName.contains("bold")) {
    1525             if (fontName.contains("extra")) return FontWeight.EXTRA_BOLD;
    1526             if (fontName.contains("ultra")) return FontWeight.EXTRA_BOLD;
    1527             else if (fontName.contains("semi")) return FontWeight.SEMI_BOLD;
    1528             else if (fontName.contains("demi")) return FontWeight.SEMI_BOLD;
    1529             else return FontWeight.BOLD;
    1530
    1531         } else if (fontName.contains("light")) {
    1532             if (fontName.contains("extra")) return FontWeight.EXTRA_LIGHT;
    1533             if (fontName.contains("ultra")) return FontWeight.EXTRA_LIGHT;
    1534             else return FontWeight.LIGHT;
    1535
    1536         } else if (fontName.contains("black")) {
    1537             return FontWeight.BLACK;
    1538
    1539         } else if (fontName.contains("heavy")) {
    1540             return FontWeight.BLACK;
    1541
    1542         } else if (fontName.contains("medium")) {
      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
      23  * questions.
      24  */
      25 package javafx.scene;
      26
      27 import java.util.ArrayList;
      28 import java.util.Collections;
      29 import java.util.HashMap;
      30 import java.util.HashSet;
      31 import java.util.List;
      32 import java.util.Locale;
      33 import java.util.Map;
      34 import java.util.Map.Entry;
      35 import java.util.Set;
      36
      37 import com.sun.javafx.scene.CssFlags;
      38 import javafx.beans.property.ObjectProperty;
      39 import javafx.beans.property.SimpleObjectProperty;
      40 import javafx.collections.FXCollections;
      41 import javafx.collections.ObservableMap;
      42 import javafx.css.CssMetaData;
      43 import javafx.css.FontCssMetaData;
      44 import javafx.css.ParsedValue;
      45 import javafx.css.PseudoClass;
      46 import javafx.css.StyleConverter;
      47 import javafx.css.StyleOrigin;
      48 import javafx.css.Styleable;
      49 import javafx.css.StyleableProperty;
      50 import javafx.scene.text.Font;
      51 import javafx.scene.text.FontPosture;
      52 import javafx.scene.text.FontWeight;
    1491                     && parentCacheContainer.fontSizeCache.isEmpty() == false) {
    1492
    1493                 Set<PseudoClass>[] transitionStates = parentHelper.getTransitionStates(parent);
    1494                 StyleCacheEntry.Key parentCacheEntryKey = new StyleCacheEntry.Key(transitionStates, Font.getDefault());
    1495                 cachedFont = parentCacheContainer.fontSizeCache.get(parentCacheEntryKey);
    1496
    1497             } else {
    1498
    1499                 Set<PseudoClass> pseudoClassState = parent.getPseudoClassStates();
    1500                 StyleMap smap = parentHelper.getStyleMap(parent);
    1501                 cachedFont = parentHelper.lookup(parent, dummyFontProperty, smap, pseudoClassState, parent, null, null);
    1502             }
    1503         }
    1504
    1505         return cachedFont;
    1506     }
    1507
    1508     /*package access for testing*/ FontPosture getFontPosture(Font font) {
    1509         if (font == null) return FontPosture.REGULAR;
    1510
    1511         String fontName = font.getName().toLowerCase(Locale.ROOT);
    1512
    1513         if (fontName.contains("italic")) {
    1514             return FontPosture.ITALIC;
    1515         }
    1516
    1517         return FontPosture.REGULAR;
    1518     }
    1519
    1520     /*package access for testing*/ FontWeight getFontWeight(Font font) {
    1521         if (font == null) return FontWeight.NORMAL;
    1522
    1523         String fontName = font.getName().toLowerCase(Locale.ROOT);
    1524
    1525         if (fontName.contains("bold")) {
    1526             if (fontName.contains("extra")) return FontWeight.EXTRA_BOLD;
    1527             if (fontName.contains("ultra")) return FontWeight.EXTRA_BOLD;
    1528             else if (fontName.contains("semi")) return FontWeight.SEMI_BOLD;
    1529             else if (fontName.contains("demi")) return FontWeight.SEMI_BOLD;
    1530             else return FontWeight.BOLD;
    1531
    1532         } else if (fontName.contains("light")) {
    1533             if (fontName.contains("extra")) return FontWeight.EXTRA_LIGHT;
    1534             if (fontName.contains("ultra")) return FontWeight.EXTRA_LIGHT;
    1535             else return FontWeight.LIGHT;
    1536
    1537         } else if (fontName.contains("black")) {
    1538             return FontWeight.BLACK;
    1539
    1540         } else if (fontName.contains("heavy")) {
    1541             return FontWeight.BLACK;
    1542
    1543         } else if (fontName.contains("medium")) {