Revision: 6056
http://sourceforge.net/p/jump-pilot/code/6056
Author: edso
Date: 2018-12-29 19:09:24 +0000 (Sat, 29 Dec 2018)
Log Message:
-----------
speedup init by delaying gui init
took 1.40s now 0.01s
Modified Paths:
--------------
plug-ins/Color_chooser/trunk/src/org/openjump/core/ui/plugin/colorchooser/FeatureColorChooserPlugIn.java
plug-ins/Color_chooser/trunk/src/readme.txt
Modified:
plug-ins/Color_chooser/trunk/src/org/openjump/core/ui/plugin/colorchooser/FeatureColorChooserPlugIn.java
===================================================================
---
plug-ins/Color_chooser/trunk/src/org/openjump/core/ui/plugin/colorchooser/FeatureColorChooserPlugIn.java
2018-12-29 17:35:03 UTC (rev 6055)
+++
plug-ins/Color_chooser/trunk/src/org/openjump/core/ui/plugin/colorchooser/FeatureColorChooserPlugIn.java
2018-12-29 19:09:24 UTC (rev 6056)
@@ -1,7 +1,5 @@
package org.openjump.core.ui.plugin.colorchooser;
-import images.ColorChooserIconLoader;
-
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
@@ -20,6 +18,7 @@
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
import language.I18NPlug;
@@ -47,6 +46,8 @@
import com.vividsolutions.jump.workbench.ui.renderer.style.BasicStyle;
import com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager;
+import images.ColorChooserIconLoader;
+
public class FeatureColorChooserPlugIn extends AbstractPlugIn {
private static int buttonWidth = 25;
@@ -53,7 +54,7 @@
private PlugInContext context;
public ComboButton colorChooserButton;
public static ComboButton colorSetbutton;
- private JPopupMenu colorPickerPopup = new JPopupMenu();
+ private JPopupMenu colorPickerPopup = null;
public static JMenuItem mi;
public static final String COLOR = "COLOR";
@@ -63,216 +64,173 @@
@Override
public void initialize(final PlugInContext context) throws Exception {
- this.context = context;
- colorSetbutton = new ComboButton(1) {
- private static final long serialVersionUID = 1L;
+ this.context = context;
+ colorSetbutton = new ComboButton(1) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void setBounds(int x, int y, int width, int height) {
+ super.setBounds(x, y, buttonWidth, height);
+ }
+ };
+ colorChooserButton = new ComboButton(0) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void setBounds(int x, int y, int width, int height) {
+ super.setBounds(colorSetbutton.getX() + buttonWidth, y, buttonWidth,
height);
+ }
+ };
+
+ colorSetbutton.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ setFeatureColor(colorSetbutton.getColor());
+ }
+ });
+
+ // init popup takes a long time, defer it after workbench is shown
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ colorPickerPopup = initPopupLazily();
+ }
+ });
- @Override
- public void setBounds(int x, int y, int width, int height) {
- super.setBounds(x, y, buttonWidth, height);
- }
- };
- colorChooserButton = new ComboButton(0) {
- private static final long serialVersionUID = 1L;
+ colorChooserButton.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ final int x = colorSetbutton.getLocation().x;
+ final int y = colorSetbutton.getLocation().y +
colorSetbutton.getHeight();
+ if (colorPickerPopup == null) {
+ colorPickerPopup = initPopupLazily();
+ }
+ colorPickerPopup.show(colorSetbutton.getParent(), x, y);
+ }
+ });
+
+ colorSetbutton.setToolTipText(I18NPlug.getI18N("set-color-Tool"));
+ colorChooserButton.setToolTipText(I18NPlug.getI18N("pick-color-tools"));
+
+
context.getWorkbenchContext().getWorkbench().getFrame().getToolBar().addSeparator();
+
context.getWorkbenchContext().getWorkbench().getFrame().getToolBar().add(colorSetbutton);
+
context.getWorkbenchContext().getWorkbench().getFrame().getToolBar().add(colorChooserButton);
+
context.getWorkbenchContext().getWorkbench().getFrame().getToolBar().addSeparator();
+ }
- @Override
- public void setBounds(int x, int y, int width, int height) {
- super.setBounds(colorSetbutton.getX() + buttonWidth, y,
- buttonWidth, height);
- }
- };
+ private JPopupMenu initPopupLazily() {
+ final JPopupMenu popup = new JPopupMenu();
+ popup.setLayout(new GridLayout(0, 1));
+ mi = new JMenuItem(I18NPlug.getI18N("use-layer-style-color"),
+ new ColorIcon(null));
- colorSetbutton.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- setFeatureColor(colorSetbutton.getColor());
- }
- });
+ final JMenu recent = new JMenu(I18NPlug.getI18N("recent-color") + "...");
- /* colorSetbutton.addMouseListener(new MouseListener() {
- @Override
- public void mouseClicked(MouseEvent e) {
- setFeatureColor(colorSetbutton.getColor());
- }
+ mi.addActionListener(new ColorPickerActionListener(null));
+ popup.add(mi);
+ final ColorMenu cm = new ColorMenu(I18NPlug.getI18N("choose-color"));
+ cm.setIcon(getColorIcon());
- @Override
- public void mousePressed(MouseEvent e) {
- }
+ cm.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ final Color color = cm.getColor();
+ if (color != null) {
+ colorSetbutton.setColor(color);
+ setFeatureColor(color);
+ cm.addActionListener(new ColorPickerActionListener(color));
- @Override
- public void mouseReleased(MouseEvent e) {
- }
+ colorSetbutton.setColor(color);
+ setFeatureColor(color);
+ final String hex = ColorUtils.colorRGBToHex(color);
+ final String acad = ColorUtils.getColorIndexRegistry(hex);
+ final String msg = "Index color: " + acad;
- @Override
- public void mouseExited(MouseEvent e) {
- }
+ final String text = "Hex: " + hex + " RGB: "
+ + color.getRed() + "," + color.getGreen() + ","
+ + color.getBlue();
+ final JMenuItem mis = new JMenuItem(text,
+ new FeatureColorChooserPlugIn.ColorIcon(color));
+ mis.setToolTipText(msg);
+ mis.addActionListener(new
FeatureColorChooserPlugIn.ColorPickerActionListener(
+ color));
+ recent.add(mis);
+ colorPickerPopup.insert(recent, customIndex++);
+ popup.revalidate();
+ popup.repaint();
+ }
+ }
+ });
- @Override
- public void mouseEntered(MouseEvent e) {
- }
- });
+ popup.add(cm);
- colorChooserButton.addMouseListener(new MouseListener() {
- @Override
- public void mousePressed(MouseEvent e) {
- final int x = colorSetbutton.getLocation().x;
- final int y = colorSetbutton.getLocation().y
- + colorSetbutton.getHeight();
- colorPickerPopup.show(colorSetbutton.getParent(), x, y);
- }
+ mi = new JMenuItem(I18NPlug.getI18N("other-color"), getColorIcon_2());
+ mi.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent paramAnonymousActionEvent) {
+ new JColorChooser();
+ final Color color = JColorChooser.showDialog(context
+ .getWorkbenchContext().getWorkbench().getFrame(),
+ I18NPlug.getI18N("choose-color"), new Color(0, 0, 0));
+ if (color != null) {
+ colorSetbutton.setColor(color);
+ setFeatureColor(color);
+ colorSetbutton.setColor(color);
+ setFeatureColor(color);
+ final String hex = ColorUtils.colorRGBToHex(color);
+ final String acad = ColorUtils.getColorIndexRegistry(hex);
- @Override
- public void mouseClicked(MouseEvent e) {
- }
+ final String msg = "Index color: " + acad;
- @Override
- public void mouseReleased(MouseEvent e) {
- }
+ final String text = "Hex: " + hex + " RGB: "
+ + color.getRed() + "," + color.getGreen() + ","
+ + color.getBlue();
+ final JMenuItem mis = new JMenuItem(text,
+ new FeatureColorChooserPlugIn.ColorIcon(color));
+ mis.setToolTipText(msg);
+ mis.addActionListener(new
FeatureColorChooserPlugIn.ColorPickerActionListener(
+ color));
+ recent.add(mis);
+ colorPickerPopup.insert(recent, customIndex++);
+ popup.revalidate();
+ popup.repaint();
+ }
+ }
+ });
+ popup.add(mi);
- @Override
- public void mouseExited(MouseEvent e) {
- }
+ // popup.addSeparator();
+ mi = new JMenuItem(I18NPlug.getI18N("picker-color"), getPickColorIcon());
+ final PickPlugIn pick = new PickPlugIn();
+ mi.setToolTipText(I18NPlug.getI18N("msg2"));
+ final ActionListener listener = AbstractPlugIn.toActionListener(pick,
+ context.getWorkbenchContext(), taskMonitorManager);
+ mi.addActionListener(new ActionListener() {
- @Override
- public void mouseEntered(MouseEvent e) {
- }
- });*/
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ listener.actionPerformed(e);
+ }
+ });
+ popup.add(mi);
- colorChooserButton.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- final int x = colorSetbutton.getLocation().x;
- final int y = colorSetbutton.getLocation().y
- + colorSetbutton.getHeight();
- colorPickerPopup.show(colorSetbutton.getParent(), x, y);
- }
- });
-
- final JPopupMenu popup = new JPopupMenu();
- popup.setLayout(new GridLayout(0, 1));
- mi = new JMenuItem(I18NPlug.getI18N("use-layer-style-color"),
- new ColorIcon(null));
-
- final JMenu recent = new JMenu(I18NPlug.getI18N("recent-color") +
"...");
-
- mi.addActionListener(new ColorPickerActionListener(null));
- popup.add(mi);
- final ColorMenu cm = new ColorMenu(I18NPlug.getI18N("choose-color"));
- cm.setIcon(getColorIcon());
-
- cm.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- final Color color = cm.getColor();
- if (color != null) {
- colorSetbutton.setColor(color);
- setFeatureColor(color);
- cm.addActionListener(new ColorPickerActionListener(color));
-
- colorSetbutton.setColor(color);
- setFeatureColor(color);
- final String hex = ColorUtils.colorRGBToHex(color);
- final String acad = ColorUtils.getColorIndexRegistry(hex);
- final String msg = "Index color: " + acad;
-
- final String text = "Hex: " + hex + " RGB: "
- + color.getRed() + "," + color.getGreen() + ","
- + color.getBlue();
- final JMenuItem mis = new JMenuItem(text,
- new FeatureColorChooserPlugIn.ColorIcon(color));
- mis.setToolTipText(msg);
- mis.addActionListener(new
FeatureColorChooserPlugIn.ColorPickerActionListener(
- color));
- recent.add(mis);
- colorPickerPopup.insert(recent, customIndex++);
- popup.revalidate();
- popup.repaint();
- }
- }
- });
-
- popup.add(cm);
-
- mi = new JMenuItem(I18NPlug.getI18N("other-color"), getColorIcon_2());
- mi.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent paramAnonymousActionEvent)
{
- new JColorChooser();
- final Color color = JColorChooser.showDialog(context
- .getWorkbenchContext().getWorkbench().getFrame(),
- I18NPlug.getI18N("choose-color"), new Color(0, 0, 0));
- if (color != null) {
- colorSetbutton.setColor(color);
- setFeatureColor(color);
- colorSetbutton.setColor(color);
- setFeatureColor(color);
- final String hex = ColorUtils.colorRGBToHex(color);
- final String acad = ColorUtils.getColorIndexRegistry(hex);
-
- final String msg = "Index color: " + acad;
-
- final String text = "Hex: " + hex + " RGB: "
- + color.getRed() + "," + color.getGreen() + ","
- + color.getBlue();
- final JMenuItem mis = new JMenuItem(text,
- new FeatureColorChooserPlugIn.ColorIcon(color));
- mis.setToolTipText(msg);
- mis.addActionListener(new
FeatureColorChooserPlugIn.ColorPickerActionListener(
- color));
- recent.add(mis);
- colorPickerPopup.insert(recent, customIndex++);
- popup.revalidate();
- popup.repaint();
- }
- }
- });
- popup.add(mi);
-
- // popup.addSeparator();
- mi = new JMenuItem(I18NPlug.getI18N("picker-color"),
getPickColorIcon());
- final PickPlugIn pick = new PickPlugIn();
- mi.setToolTipText(I18NPlug.getI18N("msg2"));
- final ActionListener listener = AbstractPlugIn.toActionListener(pick,
- context.getWorkbenchContext(), taskMonitorManager);
- mi.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- listener.actionPerformed(e);
- }
- });
- popup.add(mi);
-
- //
- popup.add(recent);
-
- colorPickerPopup = popup;
- colorSetbutton.setToolTipText(I18NPlug.getI18N("set-color-Tool"));
-
colorChooserButton.setToolTipText(I18NPlug.getI18N("pick-color-tools"));
- context.getWorkbenchContext().getWorkbench().getFrame().getToolBar()
- .addSeparator();
- context.getWorkbenchContext().getWorkbench().getFrame().getToolBar()
- .add(colorSetbutton);
- context.getWorkbenchContext().getWorkbench().getFrame().getToolBar()
- .add(colorChooserButton);
- context.getWorkbenchContext().getWorkbench().getFrame().getToolBar()
- .addSeparator();
-
+ popup.add(recent);
+
+ return popup;
}
public Icon getColorIcon() {
- final ImageIcon icon = ColorChooserIconLoader.icon("color-swatch.png");
- return GUIUtil.toSmallIcon(icon);
+ final ImageIcon icon = ColorChooserIconLoader.icon("color-swatch.png");
+ return GUIUtil.toSmallIcon(icon);
}
-
+
public Icon getColorIcon_2() {
- final ImageIcon icon = IconLoader.icon("color_wheel.png");
- return GUIUtil.toSmallIcon(icon);
+ final ImageIcon icon = IconLoader.icon("color_wheel.png");
+ return GUIUtil.toSmallIcon(icon);
}
-
+
public Icon getPickColorIcon() {
- final ImageIcon icon2 = ColorChooserIconLoader.icon("pipette.png");
- return GUIUtil.toSmallIcon(icon2);
+ final ImageIcon icon2 = ColorChooserIconLoader.icon("pipette.png");
+ return GUIUtil.toSmallIcon(icon2);
}
private void setFeatureColor(Color color) {
Modified: plug-ins/Color_chooser/trunk/src/readme.txt
===================================================================
--- plug-ins/Color_chooser/trunk/src/readme.txt 2018-12-29 17:35:03 UTC (rev
6055)
+++ plug-ins/Color_chooser/trunk/src/readme.txt 2018-12-29 19:09:24 UTC (rev
6056)
@@ -1,3 +1,8 @@
+Color Chooser Plugin 1.3 (29.12.2018)
+--------------------------------------
+speedup init by delaying popup creation
+from 1.40s to 0.01s
+
Color Chooser Plugin 1.2 (Dicember 2017)
--------------------------------------
correct bug on repository
@@ -33,21 +38,23 @@
Color Chooser Plugin 0.4 (June 2012)
-------------------------------------
Complete Translation of Color Chooser in German, English, Spanish, French and
Italian.
-Thanks to OpenJUMP Developers and Users Comunity members
+Thanks to OpenJUMP Developers and Users Community members
Color Chooser Plugin 0.3 (June 2011)
--------------------------------------
-Color Chooser plugin for OpenJUMp allows to change color of features in a CAD
style way.
+Color Chooser plugin for OpenJUMP allows to change color of features in a CAD
style way.
This means that users have not to set attributes for features and define a
style according to them.
This version of Color Chooser Plugin derives from SkyJUMP
(https://sourceforge.net/projects/skyjump/) and was internationalized
-Currenty only Italian and English are full internationalized. German, Frenche
and Spanish are only partially translated.
+Currently only Italian and English are full internationalized. German, French
and Spanish are only partially translated.
NOTES & COPYRIGHT
--------------------------------------
Note that this plugin is developed only to test new features for OpenJUMP.
-It is NOT recomanded to use it for work or other productive activities as it
is still at the first developing stage.
-All copyright are reserved to (https://sourceforge.net/projects/skyjump/)
under the terms of GNU General Public License
-Sourcecode of ColorChooser PlugIn is embedded into the JAR file
+It is NOT recommended to use it for work or other productive activities as it
is still at the first developing stage.
+All copyright are reserved to (https://sourceforge.net/projects/skyjump/)
under the terms of GNU General Public License 2.
+Source Code of ColorChooser PlugIn is embedded into the JAR file or available
on
+https://sourceforge.net/p/jump-pilot/code/HEAD/tree/plug-ins/Color_chooser/
+.
OpenJUMP User Mailing List: http://groups.google.com/group/openjump-users
OpenJUMP Development Mailing List:
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel