Revision: 5739
http://sourceforge.net/p/jump-pilot/code/5739
Author: edso
Date: 2018-04-06 14:08:09 +0000 (Fri, 06 Apr 2018)
Log Message:
-----------
add a icon to image method
probably fix
Advertising
java.lang.NullPointerException
at
java.desktop/javax.swing.SwingUtilities.convertPointFromScreen(SwingUtilities.java:480)
at com.vividsolutions.jump.workbench.ui.GUIUtil.setBounds(GUIUtil.java:1352)
at
com.vividsolutions.jump.workbench.ui.WorkbenchFrame.position(WorkbenchFrame.java:1695)
at
com.vividsolutions.jump.workbench.ui.WorkbenchFrame.addInternalFrame(WorkbenchFrame.java:975)
at
org.openjump.core.ui.plugin.layer.NewLayerPropertiesPlugIn.execute(NewLayerPropertiesPlugIn.java:267)
with java9 when opening layer properties plugin
Modified Paths:
--------------
core/trunk/src/com/vividsolutions/jump/workbench/ui/GUIUtil.java
Modified: core/trunk/src/com/vividsolutions/jump/workbench/ui/GUIUtil.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/ui/GUIUtil.java
2018-04-05 17:24:10 UTC (rev 5738)
+++ core/trunk/src/com/vividsolutions/jump/workbench/ui/GUIUtil.java
2018-04-06 14:08:09 UTC (rev 5739)
@@ -58,6 +58,7 @@
import javax.swing.BorderFactory;
import javax.swing.GrayFilter;
+import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
@@ -797,6 +798,29 @@
}
/**
+ * convert Icon to Image
+ *
+ * @param icon
+ * @return
+ */
+ public static Image toImage(Icon icon) {
+ if (icon instanceof ImageIcon) {
+ return ((ImageIcon) icon).getImage();
+ } else {
+ int w = icon.getIconWidth();
+ int h = icon.getIconHeight();
+ GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
+ GraphicsDevice gd = ge.getDefaultScreenDevice();
+ GraphicsConfiguration gc = gd.getDefaultConfiguration();
+ BufferedImage image = gc.createCompatibleImage(w, h);
+ Graphics2D g = image.createGraphics();
+ icon.paintIcon(null, g, 0, 0);
+ g.dispose();
+ return image;
+ }
+ }
+
+ /**
* resize to a square, even non square images
*
* @param icon imageIcon to resize
@@ -1348,9 +1372,9 @@
(int) other.getLocationOnScreen().getY()
+ (location.fromBottom ? (other.getHeight()
- componentToMove.getHeight() - location.y) : location.y));
- if (!(componentToMove instanceof Window) /*&& !(componentToMove instanceof
JInternalFrame) */) {
- SwingUtilities.convertPointFromScreen(p, componentToMove.getParent());
- }
+ // recalc to others coord system, if not a freefloating window
+ if (!(componentToMove instanceof Window))
+ SwingUtilities.convertPointFromScreen(p, other);
componentToMove.setBounds(p.x, p.y, width, height);
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel