Source for javax.swing.text.html.InlineView

   1: /* InlineView.java -- Renders HTML content
   2:    Copyright (C) 2006 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package javax.swing.text.html;
  40: 
  41: import java.awt.Shape;
  42: 
  43: import javax.swing.event.DocumentEvent;
  44: import javax.swing.text.AttributeSet;
  45: import javax.swing.text.Document;
  46: import javax.swing.text.Element;
  47: import javax.swing.text.LabelView;
  48: import javax.swing.text.View;
  49: import javax.swing.text.ViewFactory;
  50: 
  51: /**
  52:  * Renders HTML content (identified by {@link HTML.Tag#CONTENT}). This is
  53:  * basically a {@link LabelView} that is adjusted to understand styles defined
  54:  * by stylesheets.
  55:  *
  56:  * @author Roman Kennke (kennke@aicas.com)
  57:  */
  58: public class InlineView
  59:   extends LabelView
  60: {
  61: 
  62:   /**
  63:    * Creates a new <code>InlineView</code> that renders the specified element.
  64:    *
  65:    * @param element the element for this view
  66:    */
  67:   public InlineView(Element element)
  68:   {
  69:     super(element);
  70:   }
  71: 
  72:   /**
  73:    * Receives notification that something was inserted into the document in
  74:    * a location that this view is responsible for.
  75:    *
  76:    * @param e the document event
  77:    * @param a the current allocation of this view
  78:    * @param f the view factory for creating new views
  79:    *
  80:    * @since 1.5
  81:    */
  82:   public void insertUpdate(DocumentEvent e, Shape a, ViewFactory f)
  83:   {
  84:     // FIXME: What to do here?
  85:     super.insertUpdate(e, a, f);
  86:   }
  87: 
  88:   /**
  89:    * Receives notification that something was removed from the document in
  90:    * a location that this view is responsible for.
  91:    *
  92:    * @param e the document event
  93:    * @param a the current allocation of this view
  94:    * @param f the view factory for creating new views
  95:    *
  96:    * @since 1.5
  97:    */
  98:   public void removeUpdate(DocumentEvent e, Shape a, ViewFactory f)
  99:   {
 100:     // FIXME: What to do here?
 101:     super.removeUpdate(e, a, f);
 102:   }
 103: 
 104:   /**
 105:    * Receives notification that attributes have changed in the document in
 106:    * a location that this view is responsible for. This calls
 107:    * {@link #setPropertiesFromAttributes}.
 108:    *
 109:    * @param e the document event
 110:    * @param a the current allocation of this view
 111:    * @param f the view factory for creating new views
 112:    *
 113:    * @since 1.5
 114:    */
 115:   public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
 116:   {
 117:     super.changedUpdate(e, a, f);
 118:     setPropertiesFromAttributes();
 119:   }
 120: 
 121:   /**
 122:    * Returns the attributes that are used for rendering. This is implemented
 123:    * to multiplex the attributes specified in the model with a stylesheet.
 124:    *
 125:    * @return the attributes that are used for rendering
 126:    */
 127:   public AttributeSet getAttributes()
 128:   {
 129:     // FIXME: Implement this.
 130:     return super.getAttributes();
 131:   }
 132: 
 133:   
 134:   public int getBreakWeight(int axis, float pos, float len)
 135:   {
 136:     // FIXME: Implement this.
 137:     return super.getBreakWeight(axis, pos, len);
 138:   }
 139: 
 140:   public View breakView(int axis, int offset, float pos, float len)
 141:   {
 142:     // FIXME: Implement this.
 143:     return super.breakView(axis, offset, pos, len);
 144:   }
 145: 
 146:   protected void setPropertiesFromAttributes()
 147:   {
 148:     // FIXME: Implement this.
 149:     super.setPropertiesFromAttributes();
 150:   }
 151: 
 152:   /**
 153:    * Returns the stylesheet used by this view. This returns the stylesheet
 154:    * of the <code>HTMLDocument</code> that is rendered by this view.
 155:    *
 156:    * @return the stylesheet used by this view
 157:    */
 158:   protected StyleSheet getStyleSheet()
 159:   {
 160:     Document doc = getDocument();
 161:     StyleSheet styleSheet = null;
 162:     if (doc instanceof HTMLDocument)
 163:       styleSheet = ((HTMLDocument) doc).getStyleSheet();
 164:     return styleSheet;
 165:   }
 166: }