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

Print this page


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


2062             paintRect = new Rectangle();
2063         }
2064 
2065         /**
2066          * Returns a string that represents the value
2067          * of the HTML.Attribute.TYPE attribute.
2068          * If this attributes is not defined, then
2069          * then the type defaults to "disc" unless
2070          * the tag is on Ordered list.  In the case
2071          * of the latter, the default type is "decimal".
2072          */
2073         private CSS.Value getChildType(View childView) {
2074             CSS.Value childtype = (CSS.Value)childView.getAttributes().
2075                                   getAttribute(CSS.Attribute.LIST_STYLE_TYPE);
2076 
2077             if (childtype == null) {
2078                 if (type == null) {
2079                     // Parent view.
2080                     View v = childView.getParent();
2081                     HTMLDocument doc = (HTMLDocument)v.getDocument();
2082                     if (doc.matchNameAttribute(v.getElement().getAttributes(),
2083                                                HTML.Tag.OL)) {
2084                         childtype = CSS.Value.DECIMAL;
2085                     } else {
2086                         childtype = CSS.Value.DISC;
2087                     }
2088                 } else {
2089                     childtype = type;
2090                 }
2091             }
2092             return childtype;
2093         }
2094 
2095         /**
2096          * Obtains the starting index from <code>parent</code>.
2097          */
2098         private void getStart(View parent) {
2099             checkedForStart = true;
2100             Element element = parent.getElement();
2101             if (element != null) {
2102                 AttributeSet attr = element.getAttributes();


2456         // 3 for vert relative
2457         short       flags;
2458         // These are used when painting, updatePaintCoordinates updates them.
2459         private int paintX;
2460         private int paintY;
2461         private int paintMaxX;
2462         private int paintMaxY;
2463 
2464         BackgroundImagePainter(AttributeSet a, CSS css, StyleSheet ss) {
2465             backgroundImage = ss.getBackgroundImage(a);
2466             // Determine the position.
2467             CSS.BackgroundPosition pos = (CSS.BackgroundPosition)a.getAttribute
2468                                            (CSS.Attribute.BACKGROUND_POSITION);
2469             if (pos != null) {
2470                 hPosition = pos.getHorizontalPosition();
2471                 vPosition = pos.getVerticalPosition();
2472                 if (pos.isHorizontalPositionRelativeToSize()) {
2473                     flags |= 4;
2474                 }
2475                 else if (pos.isHorizontalPositionRelativeToSize()) {
2476                     hPosition *= css.getFontSize(a, 12, ss);
2477                 }
2478                 if (pos.isVerticalPositionRelativeToSize()) {
2479                     flags |= 8;
2480                 }
2481                 else if (pos.isVerticalPositionRelativeToFontSize()) {
2482                     vPosition *= css.getFontSize(a, 12, ss);
2483                 }
2484             }
2485             // Determine any repeating values.
2486             CSS.Value repeats = (CSS.Value)a.getAttribute(CSS.Attribute.
2487                                                           BACKGROUND_REPEAT);
2488             if (repeats == null || repeats == CSS.Value.BACKGROUND_REPEAT) {
2489                 flags |= 3;
2490             }
2491             else if (repeats == CSS.Value.BACKGROUND_REPEAT_X) {
2492                 flags |= 1;
2493             }
2494             else if (repeats == CSS.Value.BACKGROUND_REPEAT_Y) {
2495                 flags |= 2;
2496             }
2497         }
2498 
2499         void paint(Graphics g, float x, float y, float w, float h, View v) {
2500             Rectangle clip = g.getClipRect();
2501             if (clip != null) {
2502                 // Constrain the clip so that images don't draw outside the


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


2062             paintRect = new Rectangle();
2063         }
2064 
2065         /**
2066          * Returns a string that represents the value
2067          * of the HTML.Attribute.TYPE attribute.
2068          * If this attributes is not defined, then
2069          * then the type defaults to "disc" unless
2070          * the tag is on Ordered list.  In the case
2071          * of the latter, the default type is "decimal".
2072          */
2073         private CSS.Value getChildType(View childView) {
2074             CSS.Value childtype = (CSS.Value)childView.getAttributes().
2075                                   getAttribute(CSS.Attribute.LIST_STYLE_TYPE);
2076 
2077             if (childtype == null) {
2078                 if (type == null) {
2079                     // Parent view.
2080                     View v = childView.getParent();
2081                     HTMLDocument doc = (HTMLDocument)v.getDocument();
2082                     if (HTMLDocument.matchNameAttribute(v.getElement().getAttributes(),
2083                                                         HTML.Tag.OL)) {
2084                         childtype = CSS.Value.DECIMAL;
2085                     } else {
2086                         childtype = CSS.Value.DISC;
2087                     }
2088                 } else {
2089                     childtype = type;
2090                 }
2091             }
2092             return childtype;
2093         }
2094 
2095         /**
2096          * Obtains the starting index from <code>parent</code>.
2097          */
2098         private void getStart(View parent) {
2099             checkedForStart = true;
2100             Element element = parent.getElement();
2101             if (element != null) {
2102                 AttributeSet attr = element.getAttributes();


2456         // 3 for vert relative
2457         short       flags;
2458         // These are used when painting, updatePaintCoordinates updates them.
2459         private int paintX;
2460         private int paintY;
2461         private int paintMaxX;
2462         private int paintMaxY;
2463 
2464         BackgroundImagePainter(AttributeSet a, CSS css, StyleSheet ss) {
2465             backgroundImage = ss.getBackgroundImage(a);
2466             // Determine the position.
2467             CSS.BackgroundPosition pos = (CSS.BackgroundPosition)a.getAttribute
2468                                            (CSS.Attribute.BACKGROUND_POSITION);
2469             if (pos != null) {
2470                 hPosition = pos.getHorizontalPosition();
2471                 vPosition = pos.getVerticalPosition();
2472                 if (pos.isHorizontalPositionRelativeToSize()) {
2473                     flags |= 4;
2474                 }
2475                 else if (pos.isHorizontalPositionRelativeToSize()) {
2476                     hPosition *= CSS.getFontSize(a, 12, ss);
2477                 }
2478                 if (pos.isVerticalPositionRelativeToSize()) {
2479                     flags |= 8;
2480                 }
2481                 else if (pos.isVerticalPositionRelativeToFontSize()) {
2482                     vPosition *= CSS.getFontSize(a, 12, ss);
2483                 }
2484             }
2485             // Determine any repeating values.
2486             CSS.Value repeats = (CSS.Value)a.getAttribute(CSS.Attribute.
2487                                                           BACKGROUND_REPEAT);
2488             if (repeats == null || repeats == CSS.Value.BACKGROUND_REPEAT) {
2489                 flags |= 3;
2490             }
2491             else if (repeats == CSS.Value.BACKGROUND_REPEAT_X) {
2492                 flags |= 1;
2493             }
2494             else if (repeats == CSS.Value.BACKGROUND_REPEAT_Y) {
2495                 flags |= 2;
2496             }
2497         }
2498 
2499         void paint(Graphics g, float x, float y, float w, float h, View v) {
2500             Rectangle clip = g.getClipRect();
2501             if (clip != null) {
2502                 // Constrain the clip so that images don't draw outside the