org.thdl.tib.text
Class TibetanLabelView

java.lang.Object
  |
  +--javax.swing.text.View
        |
        +--javax.swing.text.GlyphView
              |
              +--javax.swing.text.LabelView
                    |
                    +--org.thdl.tib.text.TibetanLabelView
All Implemented Interfaces:
Cloneable, SwingConstants, TabableView

class TibetanLabelView
extends LabelView

A TibetanLabelView is a LabelView that has its own idea, informed by its knowledge of Tibetan, about where a good place to break text is.

If Character.isWhiteSpace() could be overridden, and if that only affected breaking (which is doubtful), we wouldn't need this--we'd just treat Tibetan punctuation there. We might also like to override java.awt.font.GlyphMetrics idea of whitespace (though I'm not sure what consequences besides breaking that might have). But we can't override either since they're final. So we roll our own.

Author:
David Chandler

Field Summary
private  boolean logging
           
 
Fields inherited from class javax.swing.text.LabelView
 
Fields inherited from class javax.swing.text.GlyphView
 
Fields inherited from class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
TibetanLabelView(Element e, boolean debugLog)
          Creates a new TibetanLabelView.
 
Method Summary
 View breakView(int axis, int p0, float pos, float len)
           
 int getBreakWeight(int axis, float pos, float len)
           
private  int getGoodBreakingLocation(int startOffset, int endOffset)
          Returns a nonnegative offset if we find a character after which breaking would be good.
private  int getPosNearTheEnd(int startPos, float pos, float len)
          Returns a position just before or at the position specified by the three arguments.
 
Methods inherited from class javax.swing.text.LabelView
changedUpdate, getBackground, getFont, getFontMetrics, getForeground, isStrikeThrough, isSubscript, isSuperscript, isUnderline, setPropertiesFromAttributes, setStrikeThrough, setSubscript, setSuperscript, setUnderline
 
Methods inherited from class javax.swing.text.GlyphView
checkPainter, clone, createFragment, getAlignment, getEndOffset, getGlyphPainter, getNextVisualPositionFrom, getPartialSpan, getPreferredSpan, getStartOffset, getTabbedSpan, getTabExpander, getText, insertUpdate, modelToView, paint, removeUpdate, setGlyphPainter, viewToModel
 
Methods inherited from class javax.swing.text.View
append, forwardUpdate, forwardUpdateToView, getAttributes, getChildAllocation, getContainer, getDocument, getElement, getGraphics, getMaximumSpan, getMinimumSpan, getParent, getResizeWeight, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, replace, setParent, setSize, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.text.TabableView
getPartialSpan, getTabbedSpan
 

Field Detail

logging

private boolean logging
Constructor Detail

TibetanLabelView

public TibetanLabelView(Element e,
                        boolean debugLog)
Creates a new TibetanLabelView.

Method Detail

getBreakWeight

public int getBreakWeight(int axis,
                          float pos,
                          float len)
Overrides:
getBreakWeight in class GlyphView

breakView

public View breakView(int axis,
                      int p0,
                      float pos,
                      float len)
Overrides:
breakView in class GlyphView

getGoodBreakingLocation

private int getGoodBreakingLocation(int startOffset,
                                    int endOffset)
Returns a nonnegative offset if we find a character after which breaking would be good. Returns negative otherwise.


getPosNearTheEnd

private int getPosNearTheEnd(int startPos,
                             float pos,
                             float len)
Returns a position just before or at the position specified by the three arguments. viewToModel seems like the thing to use, but we don't have the parameters to pass to it. We can call GlyphView.GlyphPainter.getBoundedPosition(..) instead, and its comment mentions viewToModel, so maybe this is actually better.



These API docs were created 02/02/2003 08:20 PM.
Copyright © 2001-2002 Tibetan and Himalayan Digital Library. All Rights Reserved.
Hosted by SourceForge_Logo