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

Print this page


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


 278         return false;
 279     }
 280 
 281     /** Alignment along the y axis, based on the font of the textfield. */
 282     float yAlign;
 283     /** Set to true when setting attributes. */
 284     boolean isSettingAttributes;
 285 
 286 
 287     // Following are for Borders that used for Unknown tags and comments.
 288     //
 289     // Border defines
 290     static final int circleR = 3;
 291     static final int circleD = circleR * 2;
 292     static final int tagSize = 6;
 293     static final int padding = 3;
 294     static final Color UnknownTagBorderColor = Color.black;
 295     static final Border StartBorder = new StartTagBorder();
 296     static final Border EndBorder = new EndTagBorder();
 297 
 298 
 299     static class StartTagBorder implements Border, Serializable {
 300         public void paintBorder(Component c, Graphics g, int x, int y,
 301                                 int width, int height) {
 302             g.setColor(UnknownTagBorderColor);
 303             x += padding;
 304             width -= (padding * 2);
 305             g.drawLine(x, y + circleR,
 306                        x, y + height - circleR);
 307             g.drawArc(x, y + height - circleD - 1,
 308                       circleD, circleD, 180, 90);
 309             g.drawArc(x, y, circleD, circleD, 90, 90);
 310             g.drawLine(x + circleR, y, x + width - tagSize, y);
 311             g.drawLine(x + circleR, y + height - 1,
 312                        x + width - tagSize, y + height - 1);
 313 
 314             g.drawLine(x + width - tagSize, y,
 315                        x + width - 1, y + height / 2);
 316             g.drawLine(x + width - tagSize, y + height,
 317                        x + width - 1, y + height / 2);
 318         }
 319 
 320         public Insets getBorderInsets(Component c) {
 321             return new Insets(2, 2 + padding, 2, tagSize + 2 + padding);
 322         }
 323 
 324         public boolean isBorderOpaque() {
 325             return false;
 326         }
 327     } // End of class HiddenTagView.StartTagBorder
 328 
 329 
 330     static class EndTagBorder implements Border, Serializable {
 331         public void paintBorder(Component c, Graphics g, int x, int y,
 332                                 int width, int height) {
 333             g.setColor(UnknownTagBorderColor);
 334             x += padding;
 335             width -= (padding * 2);
 336             g.drawLine(x + width - 1, y + circleR,
 337                        x + width - 1, y + height - circleR);
 338             g.drawArc(x + width - circleD - 1, y + height - circleD - 1,
 339                       circleD, circleD, 270, 90);
 340             g.drawArc(x + width - circleD - 1, y, circleD, circleD, 0, 90);
 341             g.drawLine(x + tagSize, y, x + width - circleR, y);
 342             g.drawLine(x + tagSize, y + height - 1,
 343                        x + width - circleR, y + height - 1);
 344 
 345             g.drawLine(x + tagSize, y,
 346                        x, y + height / 2);
 347             g.drawLine(x + tagSize, y + height,
 348                        x, y + height / 2);
 349         }
   1 /*
   2  * Copyright (c) 1998, 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


 278         return false;
 279     }
 280 
 281     /** Alignment along the y axis, based on the font of the textfield. */
 282     float yAlign;
 283     /** Set to true when setting attributes. */
 284     boolean isSettingAttributes;
 285 
 286 
 287     // Following are for Borders that used for Unknown tags and comments.
 288     //
 289     // Border defines
 290     static final int circleR = 3;
 291     static final int circleD = circleR * 2;
 292     static final int tagSize = 6;
 293     static final int padding = 3;
 294     static final Color UnknownTagBorderColor = Color.black;
 295     static final Border StartBorder = new StartTagBorder();
 296     static final Border EndBorder = new EndTagBorder();
 297 
 298     @SuppressWarnings("serial") // Same-version serialization only
 299     static class StartTagBorder implements Border, Serializable {
 300         public void paintBorder(Component c, Graphics g, int x, int y,
 301                                 int width, int height) {
 302             g.setColor(UnknownTagBorderColor);
 303             x += padding;
 304             width -= (padding * 2);
 305             g.drawLine(x, y + circleR,
 306                        x, y + height - circleR);
 307             g.drawArc(x, y + height - circleD - 1,
 308                       circleD, circleD, 180, 90);
 309             g.drawArc(x, y, circleD, circleD, 90, 90);
 310             g.drawLine(x + circleR, y, x + width - tagSize, y);
 311             g.drawLine(x + circleR, y + height - 1,
 312                        x + width - tagSize, y + height - 1);
 313 
 314             g.drawLine(x + width - tagSize, y,
 315                        x + width - 1, y + height / 2);
 316             g.drawLine(x + width - tagSize, y + height,
 317                        x + width - 1, y + height / 2);
 318         }
 319 
 320         public Insets getBorderInsets(Component c) {
 321             return new Insets(2, 2 + padding, 2, tagSize + 2 + padding);
 322         }
 323 
 324         public boolean isBorderOpaque() {
 325             return false;
 326         }
 327     } // End of class HiddenTagView.StartTagBorder
 328 
 329     @SuppressWarnings("serial") // Same-version serialization only
 330     static class EndTagBorder implements Border, Serializable {
 331         public void paintBorder(Component c, Graphics g, int x, int y,
 332                                 int width, int height) {
 333             g.setColor(UnknownTagBorderColor);
 334             x += padding;
 335             width -= (padding * 2);
 336             g.drawLine(x + width - 1, y + circleR,
 337                        x + width - 1, y + height - circleR);
 338             g.drawArc(x + width - circleD - 1, y + height - circleD - 1,
 339                       circleD, circleD, 270, 90);
 340             g.drawArc(x + width - circleD - 1, y, circleD, circleD, 0, 90);
 341             g.drawLine(x + tagSize, y, x + width - circleR, y);
 342             g.drawLine(x + tagSize, y + height - 1,
 343                        x + width - circleR, y + height - 1);
 344 
 345             g.drawLine(x + tagSize, y,
 346                        x, y + height / 2);
 347             g.drawLine(x + tagSize, y + height,
 348                        x, y + height / 2);
 349         }