modules/graphics/src/main/java/com/sun/javafx/scene/layout/region/CornerRadiiConverter.java

Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization


   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.scene.layout.region;
  27 
  28 import com.sun.javafx.css.Size;
  29 import com.sun.javafx.css.SizeUnits;
  30 import com.sun.javafx.css.StyleConverterImpl;
  31 import javafx.css.ParsedValue;

  32 import javafx.scene.layout.CornerRadii;
  33 import javafx.scene.text.Font;
  34 
  35 /**
  36  * Convert parsed value of <size>{1,4} [ '/' <size>{1,4}]? [',' <size>{1,4} [ '/' <size>{1,4}]?]? to CornerRadii
  37  */
  38 public final class CornerRadiiConverter extends StyleConverterImpl<ParsedValue<ParsedValue<?,Size>[][],CornerRadii>[], CornerRadii[]> {
  39 
  40     private static final CornerRadiiConverter INSTANCE =
  41             new CornerRadiiConverter();
  42 
  43     public static CornerRadiiConverter getInstance() {
  44         return INSTANCE;
  45     }
  46 
  47     // Disallow instantiation
  48     private CornerRadiiConverter() { }
  49 
  50 
  51     @Override
  52     public CornerRadii[] convert(ParsedValue<ParsedValue<ParsedValue<?,Size>[][], CornerRadii>[], CornerRadii[]> value, Font font) {
  53 
  54         ParsedValue<ParsedValue<?,Size>[][], CornerRadii>[] values = value.getValue();
  55         CornerRadii[] cornerRadiiValues = new CornerRadii[values.length];
  56 
  57         // parser gives us 2x4 array normalized to the rules in http://www.w3.org/TR/css3-background/#the-border-radius
  58         for(int n=0; n<values.length; n++) {




   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.scene.layout.region;
  27 
  28 import javafx.css.Size;
  29 import javafx.css.SizeUnits;

  30 import javafx.css.ParsedValue;
  31 import javafx.css.StyleConverter;
  32 import javafx.scene.layout.CornerRadii;
  33 import javafx.scene.text.Font;
  34 
  35 /**
  36  * Convert parsed value of &lt;size&gt;{1,4} [ '/' &lt;size&gt;{1,4}]? [',' &lt;size&gt;{1,4} [ '/' &lt;size&gt;{1,4}]?]? to CornerRadii
  37  */
  38 public final class CornerRadiiConverter extends StyleConverter<ParsedValue<ParsedValue<?,Size>[][],CornerRadii>[], CornerRadii[]> {
  39 
  40     private static final CornerRadiiConverter INSTANCE =
  41             new CornerRadiiConverter();
  42 
  43     public static CornerRadiiConverter getInstance() {
  44         return INSTANCE;
  45     }
  46 
  47     // Disallow instantiation
  48     private CornerRadiiConverter() { }
  49 
  50 
  51     @Override
  52     public CornerRadii[] convert(ParsedValue<ParsedValue<ParsedValue<?,Size>[][], CornerRadii>[], CornerRadii[]> value, Font font) {
  53 
  54         ParsedValue<ParsedValue<?,Size>[][], CornerRadii>[] values = value.getValue();
  55         CornerRadii[] cornerRadiiValues = new CornerRadii[values.length];
  56 
  57         // parser gives us 2x4 array normalized to the rules in http://www.w3.org/TR/css3-background/#the-border-radius
  58         for(int n=0; n<values.length; n++) {