Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 86872 Details for
Bug 210337
TextFlow doesn't take border fragments into account
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for TextFlow
patch.txt (text/plain), 5.03 KB, created by
Pratik Shah
on 2008-01-14 16:20:48 EST
(
hide
)
Description:
Patch for TextFlow
Filename:
MIME Type:
Creator:
Pratik Shah
Created:
2008-01-14 16:20:48 EST
Size:
5.03 KB
patch
obsolete
>Index: src/org/eclipse/draw2d/text/TextFlow.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/text/TextFlow.java,v >retrieving revision 1.58 >diff -u -r1.58 TextFlow.java >--- src/org/eclipse/draw2d/text/TextFlow.java 24 Sep 2007 14:04:57 -0000 1.58 >+++ src/org/eclipse/draw2d/text/TextFlow.java 14 Jan 2008 21:19:08 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,6 +10,8 @@ > *******************************************************************************/ > package org.eclipse.draw2d.text; > >+import java.util.List; >+ > import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.TextLayout; >@@ -23,7 +25,7 @@ > > /** > * An inline flow figure that renders a string of text across one or more lines. A >- * TextFlow can not contain children. All <code>InlineFlow</code> figure's must be >+ * TextFlow cannot contain children. All <code>InlineFlow</code> figure's must be > * parented by a <code>FlowFigure</code>. > * <p> > * WARNING: This class is not intended to be subclassed by clients. >@@ -126,6 +128,7 @@ > > TextFragmentBox closestBox = null; > int index = 0; >+ List fragments = getFragmentsWithoutBorder(); > for (int i = fragments.size() - 1; i >= 0; i--) { > TextFragmentBox box = (TextFragmentBox)fragments.get(i); > if (box.getBaseline() - box.getLineRoot().getAscent() > p.y >@@ -159,6 +162,7 @@ > > TextFragmentBox closestBox = null; > int index = 0; >+ List fragments = getFragmentsWithoutBorder(); > for (int i = fragments.size() - 1; i >= 0; i--) { > TextFragmentBox box = (TextFragmentBox)fragments.get(i); > if (box.getBaseline() + box.getLineRoot().getDescent() < p.y >@@ -209,7 +213,7 @@ > if (index == 0 && bidiInfo.leadingJoiner) > buffer.append(BidiChars.ZWJ); > buffer.append(getText().substring(box.offset, box.offset + box.length)); >- if (index == fragments.size() - 1 && bidiInfo.trailingJoiner) >+ if (index == getFragmentsWithoutBorder().size() - 1 && bidiInfo.trailingJoiner) > buffer.append(BidiChars.ZWJ); > return buffer.toString(); > } >@@ -232,16 +236,12 @@ > if (offset == getText().length()) > trailing = false; > >+ List fragments = getFragmentsWithoutBorder(); > int i = fragments.size(); >- int stop = 0; >- if (getBorder() instanceof FlowBorder) { >- i--; >- stop++; >- } > TextFragmentBox box; > do > box = (TextFragmentBox)fragments.get(--i); >- while (offset < box.offset && i > stop); >+ while (offset < box.offset && i > 0); > > // Cannot be trailing and after the last char, so go to first char in next box > if (trailing && box.offset + box.length <= offset) { >@@ -294,6 +294,7 @@ > */ > public int getFirstOffsetForLine(int baseline) { > TextFragmentBox box; >+ List fragments = getFragmentsWithoutBorder(); > for (int i = 0; i < fragments.size(); i++) { > box = (TextFragmentBox)fragments.get(i); > if (baseline == box.getBaseline()) >@@ -303,6 +304,19 @@ > } > > /** >+ * Returns the <code>TextFragmentBox</code> fragments contained in this TextFlow, not >+ * including the border fragments. The returned list should not be modified. >+ * @return list of fragments without the border fragments >+ * @since 3.4 >+ */ >+protected List getFragmentsWithoutBorder() { >+ List fragments = getFragments(); >+ if (getBorder() != null) >+ fragments = fragments.subList(1, fragments.size() - 1); >+ return fragments; >+} >+ >+/** > * Returns the maximum offset for a character which is on the given baseline y-coordinate. > * The y location should be relative to this figure. The return value will be between > * 0 and N-1. If no fragment is located on the baseline, <code>-1</code> is returned. >@@ -312,6 +326,7 @@ > */ > public int getLastOffsetForLine(int baseline) { > TextFragmentBox box; >+ List fragments = getFragmentsWithoutBorder(); > for (int i = fragments.size() - 1; i >= 0; i--) { > box = (TextFragmentBox)fragments.get(i); > if (baseline == box.getBaseline()) >@@ -346,6 +361,7 @@ > */ > public int getNextVisibleOffset(int offset) { > TextFragmentBox box; >+ List fragments = getFragmentsWithoutBorder(); > for (int i = 0; i < fragments.size(); i++) { > box = (TextFragmentBox)fragments.get(i); > if (box.offset + box.length <= offset) >@@ -425,6 +441,7 @@ > TextFragmentBox box; > if (offset == -1) > offset = Integer.MAX_VALUE; >+ List fragments = getFragmentsWithoutBorder(); > for (int i = fragments.size() - 1; i >= 0; i--) { > box = (TextFragmentBox)fragments.get(i); > if (box.offset >= offset) >@@ -648,4 +665,5 @@ > protected TextUtilities getTextUtilities() { > return TextUtilities.INSTANCE; > } >+ > } >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 210337
: 86872