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