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

       1 /*
       2  * Copyright (c) 2010, 2013, 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
      23  * questions.
      24  */
      25
      26 package com.sun.javafx.fxml.builder;
      27
      28 import java.util.Locale;
      29 import java.util.Map.Entry;
      30 import java.util.Set;
      31 import java.util.StringTokenizer;
      32 import java.util.TreeMap;
      33 import javafx.scene.shape.TriangleMesh;
      34 import javafx.util.Builder;
      35
      36 public class TriangleMeshBuilder extends TreeMap<String, Object> implements Builder<TriangleMesh> {
      37
      38     private static final String VALUE_SEPARATOR = ",";
      39
      40     private float[] points;
      41     private float[] texCoords;
      42     private int[] faces;
      43     private int[] faceSmoothingGroups;
      44
      45     @Override
      46     public TriangleMesh build() {
      47         TriangleMesh mesh = new TriangleMesh();
      48         if (points != null) {
      49             mesh.getPoints().setAll(points);
      50         }
      51         if (texCoords != null) {
      52             mesh.getTexCoords().setAll(texCoords);
      53         }
      54         if (faces != null) {
      55             mesh.getFaces().setAll(faces);
      56         }
      57         if (faceSmoothingGroups != null) {
      58             mesh.getFaceSmoothingGroups().setAll(faceSmoothingGroups);
      59         }
      60         return mesh;
      61     }
      62
      63     @Override
      64     public Object put(String key, Object value) {
      65
      66         if ("points".equalsIgnoreCase(key)) {
      67             StringTokenizer tokenizer = new StringTokenizer((String) value, VALUE_SEPARATOR);
      68             points = new float[tokenizer.countTokens()];
      69             int counter = 0;
      70             while (tokenizer.hasMoreTokens()) {
      71                 points[counter++] = Float.parseFloat(tokenizer.nextToken().trim());
      72             }
      73         } else if ("texcoords".equalsIgnoreCase(key)) {
      74             StringTokenizer tokenizer = new StringTokenizer((String) value, VALUE_SEPARATOR);
      75             texCoords = new float[tokenizer.countTokens()];
      76             int counter = 0;
      77             while (tokenizer.hasMoreTokens()) {
      78                 texCoords[counter++] = Float.parseFloat(tokenizer.nextToken().trim());
      79             }
      80         } else if ("faces".equalsIgnoreCase(key)) {
      81             StringTokenizer tokenizer = new StringTokenizer((String) value, VALUE_SEPARATOR);
      82             faces = new int[tokenizer.countTokens()];
      83             int counter = 0;
      84             while (tokenizer.hasMoreTokens()) {
      85                 faces[counter++] = Integer.parseInt(tokenizer.nextToken().trim());
      86             }
      87         } else if ("facesmoothinggroups".equalsIgnoreCase(key)) {
      88             StringTokenizer tokenizer = new StringTokenizer((String) value, VALUE_SEPARATOR);
      89             faceSmoothingGroups = new int[tokenizer.countTokens()];
      90             int counter = 0;
      91             while (tokenizer.hasMoreTokens()) {
      92                 faceSmoothingGroups[counter++] = Integer.parseInt(tokenizer.nextToken().trim());
      93             }
      94         }
      95
      96         return super.put(key.toLowerCase(Locale.ROOT), value);
      97     }
      98
      99     @Override
     100     public Set<Entry<String, Object>> entrySet() {
     101         return super.entrySet();
     102     }
     103
     104 }
    --- EOF ---