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 224586 Details for
Bug 308964
NullPointerException in org.eclipse.draw2d.FigureUtilities.setFont
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]
Proposed patch for the problem
fix-308946.patch (text/plain), 7.38 KB, created by
Willem Duminy
on 2012-12-11 12:45:12 EST
(
hide
)
Description:
Proposed patch for the problem
Filename:
MIME Type:
Creator:
Willem Duminy
Created:
2012-12-11 12:45:12 EST
Size:
7.38 KB
patch
obsolete
>ÿþFrom a1271aeb266c90e33b71749d6ca2c7a3eaf0763b Mon Sep 17 00:00:00 2001 >From: Willem Duminy <willem.duminy@gmail.com> >Date: Tue, 11 Dec 2012 19:28:30 +0200 >Subject: [PATCH] NEW - bug 308964: NullPointerException in > org.eclipse.draw2d.FigureUtilities.setFont > https://bugs.eclipse.org/bugs/show_bug.cgi?id=308964 > >--- > .../src/org/eclipse/draw2d/test/LabelTest.java | 21 +++++++++++++++++ > .../src/org/eclipse/draw2d/Label.java | 26 ++++++++++++++-------- > 2 files changed, 38 insertions(+), 9 deletions(-) > create mode 100644 org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/LabelTest.java > >diff --git a/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/LabelTest.java b/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/LabelTest.java >new file mode 100644 >index 0000000..1f33d34 >--- /dev/null >+++ b/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/LabelTest.java >@@ -0,0 +1,21 @@ >+package org.eclipse.draw2d.test; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.draw2d.Label; >+import org.eclipse.draw2d.geometry.Dimension; >+ >+public class LabelTest extends TestCase { >+ public void testPrefSize() { >+ Label label = new Label("hello case 308964"); >+ assertEquals(new Dimension(), label.getPreferredSize(10, 10)); >+ } >+ >+ public void testPrefSizeAfterInvalidate() { >+ Label label = new Label("hello case 308964"); >+ assertEquals(new Dimension(), label.getPreferredSize(10, 10)); >+ label.invalidate(); >+ assertEquals(new Dimension(), label.getPreferredSize(10, 10)); >+ } >+ >+} >diff --git a/org.eclipse.draw2d/src/org/eclipse/draw2d/Label.java b/org.eclipse.draw2d/src/org/eclipse/draw2d/Label.java >index c327e2e..d51f74f 100644 >--- a/org.eclipse.draw2d/src/org/eclipse/draw2d/Label.java >+++ b/org.eclipse.draw2d/src/org/eclipse/draw2d/Label.java >@@ -240,12 +240,16 @@ public class Label extends Figure implements PositionConstants { > * Dimension is calculated using the Label's full text, regardless of > * whether or not its text is currently truncated. If text size considering > * current truncation is desired, use {@link #calculateSubStringTextSize()}. >+ * If {@link #getFont()} is null returns a zero dimension. > * > * @return the size of the label's text, ignoring truncation > * @since 2.0 > */ > protected Dimension calculateTextSize() { >- return getTextUtilities().getTextExtents(getText(), getFont()); >+ if (getFont() == null) >+ return new Dimension(); >+ else >+ return getTextUtilities().getTextExtents(getText(), getFont()); > } > > private void clearLocations() { >@@ -316,18 +320,22 @@ public class Label extends Figure implements PositionConstants { > minSize = new Dimension(); > if (getLayoutManager() != null) > minSize.setSize(getLayoutManager().getMinimumSize(this, w, h)); >- >- Dimension labelSize = calculateLabelSize(getTextUtilities() >- .getTextExtents(getTruncationString(), getFont()) >- .intersect( >- getTextUtilities().getTextExtents(getText(), getFont()))); >- Insets insets = getInsets(); >- labelSize.expand(insets.getWidth(), insets.getHeight()); >- minSize.union(labelSize); >+ if (getFont() != null) { >+ Dimension labelSize = calculateLabelSize(getTextUtilities() >+ .getTextExtents(getTruncationString(), getFont()) >+ .intersect( >+ getTextUtilities().getTextExtents(getText(), >+ getFont()))); >+ Insets insets = getInsets(); >+ labelSize.expand(insets.getWidth(), insets.getHeight()); >+ minSize.union(labelSize); >+ } > return minSize; > } > > /** >+ * If {@link #getFont()} == null returns zero dimension. >+ * > * @see IFigure#getPreferredSize(int, int) > */ > public Dimension getPreferredSize(int wHint, int hHint) { >-- >1.8.0.msysgit.0 > >
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
Flags:
willem.duminy
:
review?
Actions:
View
|
Diff
Attachments on
bug 308964
: 224586