diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxView.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxView.java
index 0b709f1e71..fcae55615b 100644
--- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxView.java
+++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxView.java
@@ -3,30 +3,43 @@
*
* SyntaxView.java - The View object used by RSyntaxTextArea when word wrap is
* disabled.
- *
+ *
* This library is distributed under a modified BSD license. See the included
* RSyntaxTextArea.License.txt file for details.
*/
package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
-import java.awt.*;
-import javax.swing.event.*;
-import javax.swing.text.*;
-
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
+import javax.swing.event.DocumentEvent;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Element;
+import javax.swing.text.PlainDocument;
+import javax.swing.text.Position;
+import javax.swing.text.TabExpander;
+import javax.swing.text.View;
+import javax.swing.text.ViewFactory;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.Shape;
+
/**
* The javax.swing.text.View
object used by {@link RSyntaxTextArea}
* when word wrap is disabled. It implements syntax highlighting for
* programming languages using the colors and font styles specified by the
* RSyntaxTextArea
.
- * + *
* You don't really have to do anything to use this class, as * {@link RSyntaxTextAreaUI} automatically sets the text area's view to be * an instance of this class if word wrap is disabled.
- * + *
* The tokens that specify how to paint the syntax-highlighted text are gleaned
* from the text area's {@link RSyntaxDocument}.
*
@@ -34,7 +47,7 @@ import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
* @version 0.3
*/
public class SyntaxView extends View implements TabExpander,
- TokenOrientedView, RSTAView {
+ TokenOrientedView, RSTAView {
/**
* The default font used by the text area. If this changes we need to
@@ -70,7 +83,7 @@ public class SyntaxView extends View implements TabExpander,
private int ascent;
private int clipStart;
private int clipEnd;
-
+
/**
* Temporary token used when we need to "modify" tokens for rendering
* purposes. Since tokens returned from RSyntaxDocuments are treated as
@@ -95,7 +108,7 @@ public class SyntaxView extends View implements TabExpander,
* of the element this view represents, looking for the line
* that is the longest. The longLine variable is updated to
* represent the longest line contained. The font variable
- * is updated to indicate the font used to calculate the
+ * is updated to indicate the font used to calculate the
* longest line.
*/
void calculateLongestLine() {
@@ -105,7 +118,7 @@ public class SyntaxView extends View implements TabExpander,
tabSize = getTabSize() * metrics.charWidth(' ');
Element lines = getElement();
int n = lines.getElementCount();
- for (int i=0; i
- *
+ *
* This is implemented to subtract the width of the second character, as
* this view's
* Overridden to account for code folding.
- *
+ *
* @param index The index of the child, >= 0 && < getViewCount().
* @param a The allocation to this view
* @return The allocation to the child; or
* Overridden to account for lines hidden by collapsed folded regions.
- *
+ *
* @param line The index of the child, >= 0 && < getViewCount()
* @param a The allocation to this view
* @return The allocation to the child
@@ -515,7 +533,7 @@ return p + 1;
* @param axis may be either View.X_AXIS or View.Y_AXIS
* @return the span the view would like to be rendered into.
* Typically the view is told to render into the span
- * that is returned, although there is no guarantee.
+ * that is returned, although there is no guarantee.
* The parent may choose to resize or break the view.
* @see View#getMaximumSpan
*/
@@ -541,7 +559,7 @@ return p + 1;
* @param axis may be either View.X_AXIS or View.Y_AXIS
* @return the span the view would like to be rendered into.
* Typically the view is told to render into the span
- * that is returned, although there is no guarantee.
+ * that is returned, although there is no guarantee.
* The parent may choose to resize or break the view.
* @see View#getMinimumSpan
*/
@@ -567,7 +585,7 @@ return p + 1;
* @param axis may be either View.X_AXIS or View.Y_AXIS
* @return the span the view would like to be rendered into.
* Typically the view is told to render into the span
- * that is returned, although there is no guarantee.
+ * that is returned, although there is no guarantee.
* The parent may choose to resize or break the view.
* @see View#getPreferredSpan
*/
@@ -605,7 +623,7 @@ return p + 1;
*/
protected int getTabSize() {
Integer i = (Integer) getDocument().
- getProperty(PlainDocument.tabSizeAttribute);
+ getProperty(PlainDocument.tabSizeAttribute);
int size = (i != null) ? i.intValue() : 5;
return size;
}
@@ -643,7 +661,7 @@ return p + 1;
/**
- * Gives notification that something was inserted into the
+ * Gives notification that something was inserted into the
* document in a location that this view is responsible for.
* This is implemented to simply update the children.
*
@@ -655,8 +673,8 @@ return p + 1;
@Override
public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f) {
updateChildren(changes, a);
- Rectangle alloc = ((a != null) && isAllocationValid()) ?
- getInsideAllocation(a) : null;
+ Rectangle alloc = ((a != null) && isAllocationValid()) ?
+ getInsideAllocation(a) : null;
int pos = changes.getOffset();
View v = getViewAtPosition(pos, alloc);
if (v != null)
@@ -669,7 +687,7 @@ return p + 1;
* This is called by the >> >>> calculated number of lines for this view (line " + l
// Wants end.
if (pos > p0) {
alloc = RSyntaxUtilities.getLineWidthUpTo(
- textArea, s, p0, pos,
- WrappedSyntaxView.this,
- alloc, alloc.x);
+ textArea, s, p0, pos,
+ WrappedSyntaxView.this,
+ alloc, alloc.x);
}
//System.err.println("--- end modelToView ---");
return alloc;
@@ -1351,14 +1369,9 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
// Start at alloc.x since this chunk starts
// at the beginning of a physical line.
- if (tlist == null) {
- p0 = (p == p0) ? p1 : p;
- alloc.y += alloc.height;
- continue;
- }
int n = tlist.getListOffset(textArea,
- WrappedSyntaxView.this,
- alloc.x, x);
+ WrappedSyntaxView.this,
+ alloc.x, x);
// NOTE: We needed to add the max() with
// p0 as getTokenListForLine returns -1
@@ -1384,7 +1397,7 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
}
private void handleDocumentEvent(DocumentEvent e, Shape a,
- ViewFactory f) {
+ ViewFactory f) {
int n = calculateLineCount();
if (this.nlines != n) {
this.nlines = n;
offset
is in the first line in
- * the document, null
is returned.
+ * before this one. If offset
is in the first line in
+ * the document, null
is returned.
*/
public Token getTokenListForPhysicalLineAbove(int offset) {
- RSyntaxDocument document = (RSyntaxDocument)getDocument();
+ RSyntaxDocument document = (RSyntaxDocument) getDocument();
Element map = document.getDefaultRootElement();
-int line = map.getElementIndex(offset);
-FoldManager fm = host.getFoldManager();
-if (fm==null) {
- line--;
- if (line>=0) {
- return document.getTokenListForLine(line);
- }
-}
-else {
- line = fm.getVisibleLineAbove(line);
- if (line>=0) {
- return document.getTokenListForLine(line);
- }
-}
+ int line = map.getElementIndex(offset);
+ FoldManager fm = host.getFoldManager();
+ if (fm == null) {
+ line--;
+ if (line >= 0) {
+ return document.getTokenListForLine(line);
+ }
+ } else {
+ line = fm.getVisibleLineAbove(line);
+ if (line >= 0) {
+ return document.getTokenListForLine(line);
+ }
+ }
// int line = map.getElementIndex(offset) - 1;
// if (line>=0)
// return document.getTokenListForLine(line);
@@ -443,26 +453,25 @@ else {
*
* @param offset The offset in question.
* @return A token list for the physical (and in this view, logical) line
- * after this one. If offset
is in the last physical
- * line in the document, null
is returned.
+ * after this one. If offset
is in the last physical
+ * line in the document, null
is returned.
*/
public Token getTokenListForPhysicalLineBelow(int offset) {
- RSyntaxDocument document = (RSyntaxDocument)getDocument();
+ RSyntaxDocument document = (RSyntaxDocument) getDocument();
Element map = document.getDefaultRootElement();
int lineCount = map.getElementCount();
-int line = map.getElementIndex(offset);
-if (!host.isCodeFoldingEnabled()) {
- if (linemodelToView
actually returns the width of the
* character instead of "1" or "0" like the View implementations in
@@ -565,34 +574,34 @@ if (host.isCodeFoldingEnabled()) {
*
* @param p0 the position of the first character (>=0)
* @param b0 The bias of the first character position, toward the previous
- * character or the next character represented by the offset, in
- * case the position is a boundary of two views; b0
- * will have one of these values:
- *
- *
+ * character or the next character represented by the offset, in
+ * case the position is a boundary of two views; Position.Bias.Forward
- * Position.Bias.Backward
- * b0
+ * will have one of these values:
+ *
+ *
* @param p1 the position of the last character (>=0)
* @param b1 the bias for the second character position, defined
- * one of the legal values shown above
- * @param a the area of the view, which encompasses the requested region
+ * one of the legal values shown above
+ * @param a the area of the view, which encompasses the requested region
* @return the bounding box which is a union of the region specified
- * by the first and last character positions
- * @exception BadLocationException if the given position does
- * not represent a valid location in the associated document
- * @exception IllegalArgumentException if Position.Bias.Forward
+ * Position.Bias.Backward
+ * b0
or
- * b1
are not one of the
- * legal Position.Bias
values listed above
+ * by the first and last character positions
+ * @throws BadLocationException if the given position does
+ * not represent a valid location in the associated document
+ * @throws IllegalArgumentException if b0
or
+ * b1
are not one of the
+ * legal Position.Bias
values listed above
* @see View#viewToModel
*/
@Override
public Shape modelToView(int p0, Position.Bias b0,
- int p1, Position.Bias b1,
- Shape a) throws BadLocationException {
+ int p1, Position.Bias b1,
+ Shape a) throws BadLocationException {
Shape s0 = modelToView(p0, a, b0);
Shape s1;
- if (p1 ==getEndOffset()) {
+ if (p1 == getEndOffset()) {
try {
s1 = modelToView(p1, a, b1);
} catch (BadLocationException ble) {
@@ -600,21 +609,20 @@ if (host.isCodeFoldingEnabled()) {
}
if (s1 == null) {
// Assume extends left to right.
- Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a :
- a.getBounds();
+ Rectangle alloc = (a instanceof Rectangle) ? (Rectangle) a :
+ a.getBounds();
s1 = new Rectangle(alloc.x + alloc.width - 1, alloc.y,
- 1, alloc.height);
+ 1, alloc.height);
}
- }
- else {
+ } else {
s1 = modelToView(p1, a, b1);
}
- Rectangle r0 = s0 instanceof Rectangle ? (Rectangle)s0 : s0.getBounds();
- Rectangle r1 = s1 instanceof Rectangle ? (Rectangle)s1 : s1.getBounds();
+ Rectangle r0 = s0 instanceof Rectangle ? (Rectangle) s0 : s0.getBounds();
+ Rectangle r1 = s1 instanceof Rectangle ? (Rectangle) s1 : s1.getBounds();
if (r0.y != r1.y) {
// If it spans lines, force it to be the width of the view.
- Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a :
- a.getBounds();
+ Rectangle alloc = (a instanceof Rectangle) ? (Rectangle) a :
+ a.getBounds();
r0.x = alloc.x;
r0.width = alloc.width;
}
@@ -627,7 +635,7 @@ if (host.isCodeFoldingEnabled()) {
// this, one character too many is highlighted thanks to our
// modelToView() implementation returning the actual width of the
// character requested!
- if (p1>p0) r0.width -= r1.width;
+ if (p1 > p0) r0.width -= r1.width;
return r0;
@@ -639,15 +647,15 @@ if (host.isCodeFoldingEnabled()) {
* This implementation does not support things like centering so it
* ignores the tabOffset argument.
*
- * @param x the current position >= 0
+ * @param x the current position >= 0
* @param tabOffset the position within the text stream
- * that the tab occurred at >= 0.
+ * that the tab occurred at >= 0.
* @return the tab stop, measured in points >= 0
*/
public float nextTabStop(float x, int tabOffset) {
if (tabSize == 0)
return x;
- int ntabs = (((int)x) - tabBase) / tabSize;
+ int ntabs = (((int) x) - tabBase) / tabSize;
return tabBase + ((ntabs + 1) * tabSize);
}
@@ -662,12 +670,12 @@ if (host.isCodeFoldingEnabled()) {
@Override
public void paint(Graphics g, Shape a) {
- RSyntaxDocument document = (RSyntaxDocument)getDocument();
+ RSyntaxDocument document = (RSyntaxDocument) getDocument();
Rectangle alloc = a.getBounds();
tabBase = alloc.x;
- host = (RSyntaxTextArea)getContainer();
+ host = (RSyntaxTextArea) getContainer();
Rectangle clip = g.getClipBounds();
// An attempt to speed things up for files with long lines. Note that
@@ -695,52 +703,51 @@ if (host.isCodeFoldingEnabled()) {
boolean useSelectedTextColor = host.getUseSelectedTextColor();
RSyntaxTextAreaHighlighter h =
- (RSyntaxTextAreaHighlighter)host.getHighlighter();
+ (RSyntaxTextAreaHighlighter) host.getHighlighter();
- Graphics2D g2d = (Graphics2D)g;
+ Graphics2D g2d = (Graphics2D) g;
Token token;
//System.err.println("Painting lines: " + linesAbove + " to " + (endLine-1));
TokenPainter painter = host.getTokenPainter();
int line = linesAbove;
//int count = 0;
- while (ytrue
iff the current longest line was updated.
*/
@@ -787,8 +794,8 @@ if (host.isCodeFoldingEnabled()) {
* 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
+ * @param a the current allocation of the view
+ * @param f the factory to use to rebuild if the view has children
*/
@Override
public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f) {
@@ -806,9 +813,9 @@ if (host.isCodeFoldingEnabled()) {
/**
* Repaint the region of change covered by the given document
* event. Damages the line that begins the range to cover
- * the case when the insert/remove is only on one line.
- * If lines are added or removed, damages the whole
- * view. The longest line is checked to see if it has
+ * the case when the insert/remove is only on one line.
+ * If lines are added or removed, damages the whole
+ * view. The longest line is checked to see if it has
* changed.
*/
protected void updateDamage(DocumentEvent changes, Shape a, ViewFactory f) {
@@ -818,13 +825,13 @@ if (host.isCodeFoldingEnabled()) {
DocumentEvent.ElementChange ec = changes.getChange(elem);
Element[] added = (ec != null) ? ec.getChildrenAdded() : null;
Element[] removed = (ec != null) ? ec.getChildrenRemoved() : null;
- if (((added != null) && (added.length > 0)) ||
- ((removed != null) && (removed.length > 0))) {
+ if (((added != null) && (added.length > 0)) ||
+ ((removed != null) && (removed.length > 0))) {
// lines were added or removed...
if (added != null) {
int addedAt = ec.getIndex(); // FIXME: Is this correct?????
for (int i = 0; i < added.length; i++)
- possiblyUpdateLongLine(added[i], addedAt+i);
+ possiblyUpdateLongLine(added[i], addedAt + i);
}
if (removed != null) {
for (int i = 0; i < removed.length; i++) {
@@ -841,14 +848,12 @@ if (host.isCodeFoldingEnabled()) {
// This occurs when syntax highlighting only changes on lines
// (i.e. beginning a multiline comment).
- else if (changes.getType()==DocumentEvent.EventType.CHANGE) {
+ else if (changes.getType() == DocumentEvent.EventType.CHANGE) {
//System.err.println("Updating the damage due to a CHANGE event...");
int startLine = changes.getOffset();
int endLine = changes.getLength();
- damageLineRange(startLine,endLine, a, host);
- }
-
- else {
+ damageLineRange(startLine, endLine, a, host);
+ } else {
Element map = getElement();
int line = map.getElementIndex(changes.getOffset());
damageLineRange(line, line, a, host);
@@ -861,20 +866,18 @@ if (host.isCodeFoldingEnabled()) {
// because it has gotten longer.
longLineWidth = getLineWidth(line);
preferenceChanged(null, true, false);
- }
- else {
+ } else {
// If long line gets updated, update the status bars too.
if (possiblyUpdateLongLine(e, line))
preferenceChanged(null, true, false);
}
- }
- else if (changes.getType() == DocumentEvent.EventType.REMOVE) {
+ } else if (changes.getType() == DocumentEvent.EventType.REMOVE) {
if (map.getElement(line) == longLine) {
// removed from longest line... recalc
longLineWidth = -1; // Must do this!
calculateLongestLine();
preferenceChanged(null, true, false);
- }
+ }
}
}
}
@@ -884,7 +887,7 @@ if (host.isCodeFoldingEnabled()) {
* Checks to see if the font metrics and longest line are up-to-date.
*/
private void updateMetrics() {
- host = (RSyntaxTextArea)getContainer();
+ host = (RSyntaxTextArea) getContainer();
Font f = host.getFont();
if (font != f) {
// The font changed, we need to recalculate the longest line!
@@ -900,9 +903,9 @@ if (host.isCodeFoldingEnabled()) {
*
* @param fx the X coordinate >= 0
* @param fy the Y coordinate >= 0
- * @param a the allocated region to render into
+ * @param a the allocated region to render into
* @return the location within the model that best represents the
- * given point in the view >= 0
+ * given point in the view >= 0
*/
@Override
public int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias) {
@@ -910,7 +913,7 @@ if (host.isCodeFoldingEnabled()) {
bias[0] = Position.Bias.Forward;
Rectangle alloc = a.getBounds();
- RSyntaxDocument doc = (RSyntaxDocument)getDocument();
+ RSyntaxDocument doc = (RSyntaxDocument) getDocument();
int x = (int) fx;
int y = (int) fy;
@@ -936,9 +939,9 @@ if (host.isCodeFoldingEnabled()) {
Element map = doc.getDefaultRootElement();
int lineIndex = Math.abs((y - alloc.y) / lineHeight);//metrics.getHeight() );
-FoldManager fm = host.getFoldManager();
+ FoldManager fm = host.getFoldManager();
//System.out.print("--- " + lineIndex);
-lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
+ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
//System.out.println(" => " + lineIndex);
if (lineIndex >= map.getElementCount()) {
return host.getLastVisibleOffset();
@@ -950,7 +953,7 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
if (x < alloc.x)
return line.getStartOffset();
- // If the point is to the right of the line...
+ // If the point is to the right of the line...
else if (x > alloc.x + alloc.width)
return line.getEndOffset() - 1;
@@ -960,14 +963,14 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
Token tokenList = doc.getTokenListForLine(lineIndex);
tabBase = alloc.x;
int offs = tokenList.getListOffset(
- (RSyntaxTextArea)getContainer(),
- this, tabBase, x);
- return offs!=-1 ? offs : p0;
+ (RSyntaxTextArea) getContainer(),
+ this, tabBase, x);
+ return offs != -1 ? offs : p0;
}
} // End of else.
- }
+ }
/**
@@ -981,11 +984,13 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
// NOTE: lineHeight is not initially set here, leading to the
// current line not being highlighted when a document is first
// opened. So, we set it here just in case.
- lineHeight = host!=null ? host.getLineHeight() : lineHeight;
- FoldManager fm = host.getFoldManager();
- if (!fm.isLineHidden(line)) {
- line -= fm.getHiddenLineCountAbove(line);
- return alloc.y + line*lineHeight;
+ lineHeight = host != null ? host.getLineHeight() : lineHeight;
+ if (host != null) {
+ FoldManager fm = host.getFoldManager();
+ if (!fm.isLineHidden(line)) {
+ line -= fm.getHiddenLineCountAbove(line);
+ return alloc.y + line * lineHeight;
+ }
}
}
@@ -998,7 +1003,7 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
* {@inheritDoc}
*/
public int yForLineContaining(Rectangle alloc, int offs)
- throws BadLocationException {
+ throws BadLocationException {
Element map = getElement();
int line = map.getElementIndex(offs);
return yForLine(alloc, line);
diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java
index b08b0caf76..e99208afc0 100644
--- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java
+++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java
@@ -3,21 +3,39 @@
*
* WrappedSyntaxView.java - Test implementation of WrappedSyntaxView that
* is also aware of RSyntaxTextArea's different fonts per token type.
- *
+ *
* This library is distributed under a modified BSD license. See the included
* RSyntaxTextArea.License.txt file for details.
*/
package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
-import java.awt.*;
-import javax.swing.text.*;
-import javax.swing.text.Position.Bias;
-import javax.swing.event.*;
-
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenUtils.TokenSubList;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import com.fr.design.gui.syntax.ui.rtextarea.Gutter;
+import com.fr.stable.CommonUtils;
+
+import javax.swing.event.DocumentEvent;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.BoxView;
+import javax.swing.text.Document;
+import javax.swing.text.Element;
+import javax.swing.text.LayeredHighlighter;
+import javax.swing.text.PlainDocument;
+import javax.swing.text.Position;
+import javax.swing.text.Position.Bias;
+import javax.swing.text.Segment;
+import javax.swing.text.TabExpander;
+import javax.swing.text.View;
+import javax.swing.text.ViewFactory;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.Shape;
/**
@@ -27,17 +45,17 @@ import com.fr.design.gui.syntax.ui.rtextarea.Gutter;
* @version 0.2
*/
public class WrappedSyntaxView extends BoxView implements TabExpander,
- RSTAView {
+ RSTAView {
boolean widthChanging;
int tabBase;
int tabSize;
-
+
/**
* This is reused to keep from allocating/deallocating.
*/
private Segment s, drawSeg;
-
+
/**
* Another variable initialized once to keep from allocating/deallocating.
*/
@@ -93,7 +111,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander,
int p = p0;
RSyntaxTextArea textArea = (RSyntaxTextArea)getContainer();
float currentWidth = getWidth();
- if (currentWidth==Integer.MAX_VALUE)
+ if (CommonUtils.equals(currentWidth, Integer.MAX_VALUE))
currentWidth = getPreferredSpan(X_AXIS);
// Make sure width>0; this is a huge hack to fix a bug where
// loading text into an RTextArea before it is visible if word wrap
@@ -128,7 +146,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander,
//System.err.println("------ ending calculateBreakPosition() --------");
// return p;
-return p + 1;
+ return p + 1;
}
//private int getBreakLocation(Token t, FontMetrics fm, int x0, int x,
@@ -229,7 +247,7 @@ return p + 1;
x = painter.paint(token, g, x,y, host, this);
token = token.getNextToken();
}
-
+
if (token!=null && token.isPaintable() && token.getOffset()null
if
@@ -476,7 +494,7 @@ return p + 1;
/**
* Fetches the allocation for the given child view to render into.setParent
method.
* Subclasses can re-implement this to initialize their
* child views in a different manner. The default
- * implementation creates a child view for each
+ * implementation creates a child view for each
* child element.
*
* @param f the view factory
@@ -765,8 +783,8 @@ return p + 1;
*/
@Override
public Shape modelToView(int p0, Position.Bias b0,
- int p1, Position.Bias b1,
- Shape a) throws BadLocationException {
+ int p1, Position.Bias b1,
+ Shape a) throws BadLocationException {
Shape s0 = modelToView(p0, a, b0);
Shape s1;
@@ -779,9 +797,9 @@ return p + 1;
if (s1 == null) {
// Assume extends left to right.
Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a :
- a.getBounds();
+ a.getBounds();
s1 = new Rectangle(alloc.x + alloc.width - 1, alloc.y,
- 1, alloc.height);
+ 1, alloc.height);
}
}
else {
@@ -789,11 +807,11 @@ return p + 1;
}
Rectangle r0 = s0.getBounds();
Rectangle r1 = (s1 instanceof Rectangle) ? (Rectangle) s1 :
- s1.getBounds();
+ s1.getBounds();
if (r0.y != r1.y) {
// If it spans lines, force it to be the width of the view.
Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a :
- a.getBounds();
+ a.getBounds();
r0.x = alloc.x;
r0.width = alloc.width;
}
@@ -840,7 +858,7 @@ return p + 1;
public void paint(Graphics g, Shape a) {
Rectangle alloc = (a instanceof Rectangle) ?
- (Rectangle)a : a.getBounds();
+ (Rectangle)a : a.getBounds();
tabBase = alloc.x;
Graphics2D g2d = (Graphics2D)g;
@@ -904,7 +922,7 @@ return p + 1;
/**
- * Gives notification that something was removed from the
+ * Gives notification that something was removed from the
* document in a location that this view is responsible for.
* This is implemented to simply update the children.
*
@@ -918,12 +936,12 @@ return p + 1;
updateChildren(changes, a);
- Rectangle alloc = ((a != null) && isAllocationValid()) ?
- getInsideAllocation(a) : null;
+ Rectangle alloc = ((a != null) && isAllocationValid()) ?
+ getInsideAllocation(a) : null;
int pos = changes.getOffset();
View v = getViewAtPosition(pos, alloc);
if (v != null)
- v.removeUpdate(changes, alloc, f);
+ v.removeUpdate(changes, alloc, f);
}
@@ -972,7 +990,7 @@ return p + 1;
/**
- * Update the child views in response to a
+ * Update the child views in response to a
* document event.
*/
void updateChildren(DocumentEvent e, Shape a) {
@@ -1044,8 +1062,8 @@ return p + 1;
// Code folding may have hidden the last line. If so, return the last
// visible offset instead of the last offset.
- if (host.isCodeFoldingEnabled() && v==getView(getViewCount()-1) &&
- offs==v.getEndOffset()-1) {
+ if (v != null && host.isCodeFoldingEnabled() && v == getView(getViewCount() - 1) &&
+ offs == v.getEndOffset() - 1) {
offs = host.getLastVisibleOffset();
}
@@ -1068,7 +1086,7 @@ return p + 1;
* {@inheritDoc}
*/
public int yForLineContaining(Rectangle alloc, int offs)
- throws BadLocationException {
+ throws BadLocationException {
if (isAllocationValid()) {
// TODO: make cached Y_AXIS offsets valid even with folding enabled
// to speed this back up!
@@ -1091,8 +1109,8 @@ return p + 1;
/**
* Simple view of a line that wraps if it doesn't
* fit within the horizontal space allocated.
- * This class tries to be lightweight by carrying little
- * state of it's own and sharing the state of the outer class
+ * This class tries to be lightweight by carrying little
+ * state of it's own and sharing the state of the outer class
* with it's siblings.
*/
class WrappedLine extends View {
@@ -1136,10 +1154,10 @@ return p + 1;
//System.err.println("... ... ... break position p==" + p);
p0 = (p == p0) ? ++p : p; // this is the fix of #4410243
- // we check on situation when
- // width is too small and
- // break position is calculated
- // incorrectly.
+ // we check on situation when
+ // width is too small and
+ // break position is calculated
+ // incorrectly.
//System.err.println("... ... ... new p0==" + p0);
}
/*
@@ -1161,7 +1179,7 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
* @param axis may be either X_AXIS or Y_AXIS
* @return the span the view would like to be rendered into.
* Typically the view is told to render into the span
- * that is returned, although there is no guarantee.
+ * that is returned, although there is no guarantee.
* The parent may choose to resize or break the view.
* @see View#getPreferredSpan
*/
@@ -1170,7 +1188,7 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
switch (axis) {
case View.X_AXIS:
float width = getWidth();
- if (width == Integer.MAX_VALUE) {
+ if (CommonUtils.equals(width, Integer.MAX_VALUE)) {
// We have been initially set to MAX_VALUE, but we don't
// want this as our preferred.
return 100f;
@@ -1212,7 +1230,7 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
*/
@Override
public Shape modelToView(int pos, Shape a, Position.Bias b)
- throws BadLocationException {
+ throws BadLocationException {
//System.err.println("--- begin modelToView ---");
Rectangle alloc = a.getBounds();
@@ -1222,7 +1240,7 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
int p0 = getStartOffset();
int p1 = getEndOffset();
int testP = (b == Position.Bias.Forward) ? pos :
- Math.max(p0, pos - 1);
+ Math.max(p0, pos - 1);
// Get the token list for this line so we don't have to keep
// recomputing it if this logical line spans multiple physical
@@ -1242,9 +1260,9 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
if ((pos >= p0) && (testP