src/share/classes/javax/swing/text/html/CSSBorder.java

Print this page


   1 /*
   2  * Copyright (c) 2007, 2011, 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


  33 import java.awt.Rectangle;
  34 import java.awt.Shape;
  35 import java.util.HashMap;
  36 import java.util.Map;
  37 import javax.swing.border.AbstractBorder;
  38 import javax.swing.text.AttributeSet;
  39 import javax.swing.text.View;
  40 import javax.swing.text.html.CSS.Attribute;
  41 import javax.swing.text.html.CSS.BorderStyle;
  42 import javax.swing.text.html.CSS.BorderWidthValue;
  43 import javax.swing.text.html.CSS.ColorValue;
  44 import javax.swing.text.html.CSS.CssValue;
  45 import javax.swing.text.html.CSS.LengthValue;
  46 import javax.swing.text.html.CSS.Value;
  47 
  48 /**
  49  * CSS-style borders for HTML elements.
  50  *
  51  * @author Sergey Groznyh
  52  */

  53 class CSSBorder extends AbstractBorder {
  54 
  55     /** Indices for the attribute groups.  */
  56     final static int COLOR = 0, STYLE = 1, WIDTH = 2;
  57 
  58     /** Indices for the box sides within the attribute group.  */
  59     final static int TOP = 0, RIGHT = 1, BOTTOM = 2, LEFT = 3;
  60 
  61     /** The attribute groups.  */
  62     final static Attribute[][] ATTRIBUTES = {
  63         { Attribute.BORDER_TOP_COLOR, Attribute.BORDER_RIGHT_COLOR,
  64           Attribute.BORDER_BOTTOM_COLOR, Attribute.BORDER_LEFT_COLOR, },
  65         { Attribute.BORDER_TOP_STYLE, Attribute.BORDER_RIGHT_STYLE,
  66           Attribute.BORDER_BOTTOM_STYLE, Attribute.BORDER_LEFT_STYLE, },
  67         { Attribute.BORDER_TOP_WIDTH, Attribute.BORDER_RIGHT_WIDTH,
  68           Attribute.BORDER_BOTTOM_WIDTH, Attribute.BORDER_LEFT_WIDTH, },
  69     };
  70 
  71     /** Parsers for the border properties.  */
  72     final static CssValue PARSERS[] = {


   1 /*
   2  * Copyright (c) 2007, 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


  33 import java.awt.Rectangle;
  34 import java.awt.Shape;
  35 import java.util.HashMap;
  36 import java.util.Map;
  37 import javax.swing.border.AbstractBorder;
  38 import javax.swing.text.AttributeSet;
  39 import javax.swing.text.View;
  40 import javax.swing.text.html.CSS.Attribute;
  41 import javax.swing.text.html.CSS.BorderStyle;
  42 import javax.swing.text.html.CSS.BorderWidthValue;
  43 import javax.swing.text.html.CSS.ColorValue;
  44 import javax.swing.text.html.CSS.CssValue;
  45 import javax.swing.text.html.CSS.LengthValue;
  46 import javax.swing.text.html.CSS.Value;
  47 
  48 /**
  49  * CSS-style borders for HTML elements.
  50  *
  51  * @author Sergey Groznyh
  52  */
  53 @SuppressWarnings("serial") // Superclass is not serializable across versions
  54 class CSSBorder extends AbstractBorder {
  55 
  56     /** Indices for the attribute groups.  */
  57     final static int COLOR = 0, STYLE = 1, WIDTH = 2;
  58 
  59     /** Indices for the box sides within the attribute group.  */
  60     final static int TOP = 0, RIGHT = 1, BOTTOM = 2, LEFT = 3;
  61 
  62     /** The attribute groups.  */
  63     final static Attribute[][] ATTRIBUTES = {
  64         { Attribute.BORDER_TOP_COLOR, Attribute.BORDER_RIGHT_COLOR,
  65           Attribute.BORDER_BOTTOM_COLOR, Attribute.BORDER_LEFT_COLOR, },
  66         { Attribute.BORDER_TOP_STYLE, Attribute.BORDER_RIGHT_STYLE,
  67           Attribute.BORDER_BOTTOM_STYLE, Attribute.BORDER_LEFT_STYLE, },
  68         { Attribute.BORDER_TOP_WIDTH, Attribute.BORDER_RIGHT_WIDTH,
  69           Attribute.BORDER_BOTTOM_WIDTH, Attribute.BORDER_LEFT_WIDTH, },
  70     };
  71 
  72     /** Parsers for the border properties.  */
  73     final static CssValue PARSERS[] = {