< prev index next >

src/java.desktop/share/classes/javax/swing/text/ParagraphView.java

Print this page




  54      *
  55      * @param elem the element that this view is responsible for
  56      */
  57     public ParagraphView(Element elem) {
  58         super(elem, View.Y_AXIS);
  59         setPropertiesFromAttributes();
  60         Document doc = elem.getDocument();
  61         Object i18nFlag = doc.getProperty(AbstractDocument.I18NProperty);
  62         if ((i18nFlag != null) && i18nFlag.equals(Boolean.TRUE)) {
  63             try {
  64                 if (i18nStrategy == null) {
  65                     // the classname should probably come from a property file.
  66                     String classname = "javax.swing.text.TextLayoutStrategy";
  67                     ClassLoader loader = getClass().getClassLoader();
  68                     if (loader != null) {
  69                         i18nStrategy = loader.loadClass(classname);
  70                     } else {
  71                         i18nStrategy = Class.forName(classname);
  72                     }
  73                 }

  74                 Object o = i18nStrategy.newInstance();
  75                 if (o instanceof FlowStrategy) {
  76                     strategy = (FlowStrategy) o;
  77                 }
  78             } catch (Throwable e) {
  79                 throw new StateInvariantError("ParagraphView: Can't create i18n strategy: "
  80                                               + e.getMessage());
  81             }
  82         }
  83     }
  84 
  85     /**
  86      * Sets the type of justification.
  87      *
  88      * @param j one of the following values:
  89      * <ul>
  90      * <li><code>StyleConstants.ALIGN_LEFT</code>
  91      * <li><code>StyleConstants.ALIGN_CENTER</code>
  92      * <li><code>StyleConstants.ALIGN_RIGHT</code>
  93      * </ul>




  54      *
  55      * @param elem the element that this view is responsible for
  56      */
  57     public ParagraphView(Element elem) {
  58         super(elem, View.Y_AXIS);
  59         setPropertiesFromAttributes();
  60         Document doc = elem.getDocument();
  61         Object i18nFlag = doc.getProperty(AbstractDocument.I18NProperty);
  62         if ((i18nFlag != null) && i18nFlag.equals(Boolean.TRUE)) {
  63             try {
  64                 if (i18nStrategy == null) {
  65                     // the classname should probably come from a property file.
  66                     String classname = "javax.swing.text.TextLayoutStrategy";
  67                     ClassLoader loader = getClass().getClassLoader();
  68                     if (loader != null) {
  69                         i18nStrategy = loader.loadClass(classname);
  70                     } else {
  71                         i18nStrategy = Class.forName(classname);
  72                     }
  73                 }
  74                 @SuppressWarnings("deprecation")
  75                 Object o = i18nStrategy.newInstance();
  76                 if (o instanceof FlowStrategy) {
  77                     strategy = (FlowStrategy) o;
  78                 }
  79             } catch (Throwable e) {
  80                 throw new StateInvariantError("ParagraphView: Can't create i18n strategy: "
  81                                               + e.getMessage());
  82             }
  83         }
  84     }
  85 
  86     /**
  87      * Sets the type of justification.
  88      *
  89      * @param j one of the following values:
  90      * <ul>
  91      * <li><code>StyleConstants.ALIGN_LEFT</code>
  92      * <li><code>StyleConstants.ALIGN_CENTER</code>
  93      * <li><code>StyleConstants.ALIGN_RIGHT</code>
  94      * </ul>


< prev index next >