lkishalmi closed pull request #878: [NETBEANS-1252] Fix shifted cursor in 
output window with GDK_SCALE=2
URL: https://github.com/apache/incubator-netbeans/pull/878
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/platform/core.output2/src/org/netbeans/core/output2/ExtPlainView.java 
b/platform/core.output2/src/org/netbeans/core/output2/ExtPlainView.java
index f2913e075e..97591fa156 100644
--- a/platform/core.output2/src/org/netbeans/core/output2/ExtPlainView.java
+++ b/platform/core.output2/src/org/netbeans/core/output2/ExtPlainView.java
@@ -28,7 +28,6 @@
 import java.awt.*;
 import javax.swing.text.Position.Bias;
 import org.netbeans.core.output2.options.OutputOptions;
-import org.openide.windows.IOColors;
 
 /**
  * Extension to PlainView which can paint hyperlinked lines in different
@@ -39,7 +38,7 @@
  * @author  Tim Boudreau
  */
 class ExtPlainView extends PlainView {
-    private final Segment SEGMENT = new Segment(); 
+    private final Segment SEGMENT = new Segment();
     private static final int MAX_LINE_LENGTH = 4096;
     private static final String LINE_TOO_LONG_MSG = 
org.openide.util.NbBundle.getMessage(ExtPlainView.class, "MSG_LINE_TOO_LONG");
 
@@ -48,7 +47,7 @@
                                              "Aqua".equals 
(UIManager.getLookAndFeel().getID()); // NOI18N
 
     private static Map<RenderingHints.Key, Object> hintsMap = null;
-    
+
     @SuppressWarnings("unchecked")
     static Map<RenderingHints.Key, Object> getHints() {
         if (hintsMap == null) {
@@ -63,7 +62,7 @@
         }
         return hintsMap;
     }
-    
+
     /** Creates a new instance of ExtPlainView */
     ExtPlainView(Element elem) {
         super (elem);
@@ -74,9 +73,9 @@ public void paint(Graphics g, Shape allocation) {
         ((Graphics2D)g).addRenderingHints(getHints());
         super.paint(g, allocation);
     }
-    
+
     Segment getSegment() {
-        return SwingUtilities.isEventDispatchThread() ? SEGMENT : new 
Segment(); 
+        return SwingUtilities.isEventDispatchThread() ? SEGMENT : new 
Segment();
     }
 
     private int drawText(Graphics g, int x, int y, int p0, int p1,
@@ -181,81 +180,6 @@ private void underline(Graphics g, Segment s, int x, int 
p0, int y) {
         g.drawLine(x, y + underlineShift, x + textLen, y + underlineShift);
     }
 
-    @Override
-    public Shape modelToView(int pos, Shape a, Bias b) throws 
BadLocationException {
-        // line coordinates
-        Element map = getElement();
-        int lineIndex = map.getElementIndex(pos);
-        Rectangle lineArea = lineToRect(a, lineIndex);
-        
-        // determine span from the start of the line
-        tabBase = lineArea.x;
-        Element line = map.getElement(lineIndex);
-        int lineStart = line.getStartOffset();
-        Segment s = getSegment();
-        getText(lineStart, pos - lineStart, s);
-        int xOffs = Utilities.getTabbedTextWidth(s, metrics, tabBase, this, 
lineStart);
-
-        // fill in the results and return
-        lineArea.x += xOffs;
-        lineArea.width = 1;
-        lineArea.height = metrics.getHeight();
-        return lineArea;        
-    }
-
-    @Override
-    public int viewToModel(float fx, float fy, Shape a, Bias[] bias) {
-        Document doc = getDocument();
-        if (!(doc instanceof Document)) {
-            return super.viewToModel(fx, fy, a, bias);
-        }
-        Rectangle alloc = a.getBounds();
-        int x = (int) fx;
-        int y = (int) fy;
-        if (y < alloc.y) {
-            // above the area covered by this icon, so the the position
-            // is assumed to be the start of the coverage for this view.
-            return getStartOffset();
-        } else if (y > alloc.y + alloc.height) {
-            // below the area covered by this icon, so the the position
-            // is assumed to be the end of the coverage for this view.
-            return getEndOffset() - 1;
-        } else {
-            // positioned within the coverage of this view vertically,
-            // so we figure out which line the point corresponds to.
-            // if the line is greater than the number of lines contained, then
-            // simply use the last line as it represents the last possible 
place
-            // we can position to.
-            Element map = doc.getDefaultRootElement();
-            int lineIndex = Math.abs((y - alloc.y) / metrics.getHeight() );
-            if (lineIndex >= map.getElementCount()) {
-                return getEndOffset() - 1;
-            }
-            Element line = map.getElement(lineIndex);
-            if (x < alloc.x) {
-                // point is to the left of the line
-                return line.getStartOffset();
-            } else if (x > alloc.x + alloc.width) {
-                // point is to the right of the line
-                return line.getEndOffset() - 1;
-            } else {
-                // Determine the offset into the text
-                try {
-                    int p0 = line.getStartOffset();
-                    int p1 = line.getEndOffset() - 1;
-                    Segment s = getSegment();
-                    getText(p0, p1 - p0, s);
-                    tabBase = alloc.x;
-                    int offs = p0 + Utilities.getTabbedTextOffset(s, metrics, 
tabBase, x, this, p0);
-                    return offs;
-                } catch (BadLocationException e) {
-                    // should not happen
-                    return -1;
-                }
-            }
-        }
-    }
-
     @Override
     public float getPreferredSpan(int axis) {
         if (axis == Y_AXIS) {
@@ -267,7 +191,7 @@ public float getPreferredSpan(int axis) {
             return longestLineLength + 1;
         }
     }
-    
+
     Font font;
     int tabBase;
     int longestLineLength = -1;
@@ -288,7 +212,7 @@ private void calcLongestLineLength() {
                longestLine = line;
            }
        }
-    }    
+    }
 
     /**
      * Calculate the width of the line represented by the given element.
@@ -306,8 +230,8 @@ protected int getLineWidth(Element line) {
            w = 0;
        }
        return w;
-    }    
-    
+    }
+
     @Override
     protected void updateDamage(DocumentEvent changes, Shape a, ViewFactory f) 
{
         Document doc = getDocument();
@@ -319,12 +243,12 @@ protected void updateDamage(DocumentEvent changes, Shape 
a, ViewFactory f) {
             calcLongestLineLength();
         }
        Component host = getContainer();
-       updateMetrics();        
+       updateMetrics();
        Element elem = getElement();
        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)) || 
+       if (((added != null) && (added.length > 0)) ||
            ((removed != null) && (removed.length > 0))) {
            // lines were added or removed...
            if (added != null) {
@@ -366,7 +290,7 @@ protected void updateDamage(DocumentEvent changes, Shape a, 
ViewFactory f) {
                    // removed from longest line... recalc
                    calcLongestLineLength();
                    preferenceChanged(null, true, false);
-               }                       
+               }
            }
        }
     }
@@ -391,7 +315,7 @@ public int getNextVisualPositionFrom(int pos, Bias b, Shape 
a, int direction, Bi
         if (pos == -1) {
             pos = (direction == SOUTH || direction == EAST) ? getStartOffset() 
: (getEndOffset() - 1);
         }
-        
+
         int lineIndex;
         int lineStart;
         switch (direction) {
@@ -429,7 +353,7 @@ public int getNextVisualPositionFrom(int pos, Bias b, Shape 
a, int direction, Bi
                 lineStart = elem.getElement(lineIndex).getStartOffset();
                 if (pos - lineStart > MAX_LINE_LENGTH) {
                     pos = (elem.getElementCount() > lineIndex + 1) ? 
elem.getElement(lineIndex + 1).getStartOffset() : lineStart + MAX_LINE_LENGTH;
-                }                
+                }
                 break;
             default:
                 throw new IllegalArgumentException("Bad direction: " + 
direction);
diff --git 
a/platform/core.output2/src/org/netbeans/core/output2/options/OutputOptions.java
 
b/platform/core.output2/src/org/netbeans/core/output2/options/OutputOptions.java
index 79bf3f87ac..5af72a073a 100644
--- 
a/platform/core.output2/src/org/netbeans/core/output2/options/OutputOptions.java
+++ 
b/platform/core.output2/src/org/netbeans/core/output2/options/OutputOptions.java
@@ -330,7 +330,7 @@ public static Font getDefaultFont() {
             if (size < MIN_FONT_SIZE) {
                 size = 11;
             }
-            defaultFont = new Font("Monospaced", Font.PLAIN, size);     
//NOI18N
+            defaultFont = new Font(Font.MONOSPACED, Font.PLAIN, size);     
//NOI18N
         }
         return defaultFont;
     }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to