/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A flow strategy that uses java.awt.font.LineBreakMeasureer to
* produce java.awt.font.TextLayout for i18n capable rendering.
* If the child view being placed into the flow is of type
* GlyphView and can be rendered by TextLayout, a GlyphPainter
* that uses TextLayout is plugged into the GlyphView.
*
* @author Timothy Prinzing
*/
/**
* Constructs a layout strategy for paragraphs based
* upon java.awt.font.LineBreakMeasurer.
*/
public TextLayoutStrategy() {
text = new AttributedSegment();
}
// --- FlowStrategy methods --------------------------------------------
/**
* Gives notification that something was inserted into the document
* in a location that the given flow view is responsible for. The
* strategy should update the appropriate changed region (which
* depends upon the strategy used for repair).
*
* @param e the change information from the associated document
* @param alloc the current allocation of the view inside of the insets.
* This value will be null if the view has not yet been displayed.
* @see View#insertUpdate
*/
}
/**
* Gives notification that something was removed from the document
* in a location that the given flow view is responsible for.
*
* @param e the change information from the associated document
* @param alloc the current allocation of the view inside of the insets.
* @see View#removeUpdate
*/
}
/**
* Gives notification from the document that attributes were changed
* in a location that this view is responsible for.
*
* @param changes the change information from the associated document
* @param a the current allocation of the view
* @param f the factory to use to rebuild if the view has children
* @see View#changedUpdate
*/
}
/**
* Does a a full layout on the given View. This causes all of
* the rows (child views) to be rebuilt to match the given
* constraints for each row. This is called by a FlowView.layout
* to update the child views in the flow.
*
* @param fv the view to reflow
*/
}
/**
* Creates a row of views that will fit within the
* layout span of the row. This is implemented to execute the
* superclass functionality (which fills the row with child
* views or view fragments) and follow that with bidi reordering
* of the unidirectional view fragments.
*
* @param row the row to fill in with views. This is assumed
* to be empty on entry.
* @param pos The current position in the children of
* this views element from which to start.
* @return the position to start the next row
*/
int n = row.getViewCount();
if (n > 1) {
byte[] levels = new byte[n];
for( int i=0; i<n; i++ ) {
reorder[i] = v;
}
}
}
return p1;
}
/**
* Adjusts the given row if possible to fit within the
* layout span. Since all adjustments were already
* calculated by the LineBreakMeasurer, this is implemented
* to do nothing.
*
* @param r the row to adjust to the current layout
* span.
* @param desiredSpan the current layout span >= 0
* @param x the location r starts at.
*/
}
/**
* Creates a unidirectional view that can be used to represent the
* current chunk. This can be either an entire view from the
* logical view, or a fragment of the view.
*
* @param fv the view holding the flow
* @param startOffset the start location for the view being created
* @param spanLeft the about of span left to fill in the row
* @param rowIndex the row the view will be placed into
*/
// Get the child view that contains the given starting position
if (endOffset == startOffset) {
return null;
}
// return the entire view
frag = v;
} else {
// return a unidirectional fragment.
}
// install a TextLayout based renderer if the view is responsible
// for glyphs. If the view represents a tab, the default
// glyph painter is used (may want to handle tabs differently).
boolean isTab = false;
// check for tab
if (ch == '\t') {
isTab = true;
}
}
}
}
return frag;
}
/**
* Calculate the limiting offset for the next view fragment.
* At most this would be the entire view (i.e. the limiting
* offset would be the end offset in that case). If the range
* contains a tab or a direction change, that will limit the
* offset to something less. This value is then fed to the
* LineBreakMeasurer as a limit to consider in addition to the
* remaining span.
*
* @param v the logical view representing the starting offset.
* @param startOffset the model location to start at.
*/
int endOffset = v.getEndOffset();
// check for direction change
if (doc instanceof AbstractDocument) {
}
}
// check for tab
if (v instanceof GlyphView) {
if (ch == '\t') {
// if the first character is a tab, create a dedicated
// view for just the tab
} else {
if (ch == '\t') {
// found a tab, don't include it in the text
break;
}
}
}
}
// determine limit from LineBreakMeasurer
}
}
return pos;
}
/**
* Synchronize the strategy with its FlowView. Allows the strategy
* to update its state to account for changes in that portion of the
* model represented by the FlowView. Also allows the strategy
* to update the FlowView in response to these changes.
*/
if (c != null) {
} else {
}
if (c instanceof JComponent) {
}
// If the children of the FlowView's logical view are GlyphViews, they
// need to have their painters updated.
int n = lv.getViewCount();
for( int i=0; i<n; i++ ) {
}
}
// Reset measurer.
}
// --- variables -------------------------------------------------------
/**
* Implementation of AttributedCharacterIterator that supports
* the GlyphView attributes for rendering the glyphs through a
* TextLayout.
*/
}
return v;
}
this.v = v;
int p0 = v.getStartOffset();
int p1 = v.getEndOffset();
try {
} catch (BadLocationException bl) {
throw new IllegalArgumentException("Invalid view");
}
first();
}
/**
* Get a boundary position for the font.
* This is implemented to assume that two fonts are
* equal if their references are equal (i.e. that the
* font came from a cache).
*
* @return the location in model coordinates. This is
* not the same as the Segment coordinates.
*/
childIndex += dir) {
if (next != f) {
// this run is different
break;
}
}
}
/**
* Get the font at the given child index.
*/
}
return null;
}
}
}
}
// --- AttributedCharacterIterator methods -------------------------
/**
* Returns the index of the first character of the run
* with respect to all attributes containing the current character.
*/
public int getRunStart() {
}
/**
* Returns the index of the first character of the run
* with respect to the given attribute containing the current character.
*/
if (attribute instanceof TextAttribute) {
}
}
return getBeginIndex();
}
/**
* Returns the index of the first character of the run
* with respect to the given attributes containing the current character.
*/
int index = getBeginIndex();
for (int i = 0; i < a.length; i++) {
}
}
/**
* Returns the index of the first character following the run
* with respect to all attributes containing the current character.
*/
public int getRunLimit() {
}
/**
* Returns the index of the first character following the run
* with respect to the given attribute containing the current character.
*/
if (attribute instanceof TextAttribute) {
}
}
return getEndIndex();
}
/**
* Returns the index of the first character following the run
* with respect to the given attributes containing the current character.
*/
int index = getEndIndex();
for (int i = 0; i < a.length; i++) {
}
}
/**
* Returns a map with the attributes defined on the current
* character.
*/
}
}
return h;
}
/**
* Returns the value of the named attribute for the current character.
* Returns null if the attribute is not defined.
* @param attribute the key of the attribute whose value is requested.
*/
return getFont(childIndex);
return
return shaper;
}
return null;
}
/**
* Returns the keys of all attributes defined on the
* iterator's text range. The set is empty if no
* attributes are defined.
*/
return keys;
}
View v;
static {
}
}
}