diff --git a/pom.xml b/pom.xml index e2b637b485..0acabcab61 100644 --- a/pom.xml +++ b/pom.xml @@ -80,9 +80,7 @@ 1.4 3.4 2.5.3 - 3.7.12 1.30 - 3.2.5 yyyy-MM-dd diff --git a/ugs-platform/ugs-platform-plugin-designer/pom.xml b/ugs-platform/ugs-platform-plugin-designer/pom.xml index 31b9e27a60..a59807cc9f 100644 --- a/ugs-platform/ugs-platform-plugin-designer/pom.xml +++ b/ugs-platform/ugs-platform-plugin-designer/pom.xml @@ -65,25 +65,6 @@ ${batik.version} - - - com.formdev - jide-oss - ${ugs.jide.version} - - - com.formdev - flatlaf-jide-oss - ${ugs.flatlaf.version} - - - - - com.formdev - flatlaf - ${ugs.flatlaf.version} - - ${project.groupId} diff --git a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/Drawing.java b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/Drawing.java index 5568b70bcc..c3e774a359 100644 --- a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/Drawing.java +++ b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/Drawing.java @@ -107,6 +107,7 @@ public Drawing(Controller controller) { controlsRoot.addChild(new EditTextControl(controller)); controlsRoot.addChild(new ZoomControl(controller)); + setFocusable(true); setBackground(Colors.BACKGROUND); setScale(2); } diff --git a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/MainMenu.java b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/MainMenu.java index 162246fb59..c5815b799f 100644 --- a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/MainMenu.java +++ b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/MainMenu.java @@ -89,7 +89,7 @@ public MainMenu(Controller controller) { previous.setAccelerator(Utilities.stringToKey("SD-P")); all.setAccelerator(Utilities.stringToKey("D-A")); next.setAccelerator(Utilities.stringToKey("SD-N")); - delete.setAccelerator(Utilities.stringToKey("BACK_SPACE")); + delete.setAccelerator(Utilities.stringToKey("DELETE")); copy.setAccelerator(Utilities.stringToKey("D-C")); paste.setAccelerator(Utilities.stringToKey("D-V")); diff --git a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/MouseListener.java b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/MouseListener.java index efc14c00bd..5c3b74f708 100644 --- a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/MouseListener.java +++ b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/MouseListener.java @@ -59,6 +59,7 @@ public MouseListener(Controller controller) { @Override public void mouseDragged(MouseEvent m) { + controller.getDrawing().requestFocus(); lastPos = toRelativePoint(m); boolean shiftPressed = (m.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0; boolean ctrlPressed = (m.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0; @@ -118,6 +119,7 @@ private Point2D toRelativePoint(MouseEvent m) { @Override public void mousePressed(MouseEvent m) { + controller.getDrawing().requestFocus(); startPos = toRelativePoint(m); boolean shiftPressed = (m.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0; boolean ctrlPressed = (m.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0; @@ -135,6 +137,7 @@ public void mousePressed(MouseEvent m) { @Override public void mouseReleased(MouseEvent m) { + controller.getDrawing().requestFocus(); lastPos = toRelativePoint(m); boolean shiftPressed = (m.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0; boolean ctrlPressed = (m.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0; diff --git a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/clipart/ClipartTooltip.java b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/clipart/ClipartTooltip.java index 01aabc8c1d..ad3bd97ac4 100644 --- a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/clipart/ClipartTooltip.java +++ b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/clipart/ClipartTooltip.java @@ -18,10 +18,11 @@ This file is part of Universal Gcode Sender (UGS). */ package com.willwinder.ugs.nbp.designer.gui.clipart; -import com.jidesoft.popup.JidePopup; - import javax.swing.JLabel; +import javax.swing.JWindow; +import javax.swing.SwingUtilities; import java.awt.Component; +import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -33,11 +34,11 @@ This file is part of Universal Gcode Sender (UGS). */ public class ClipartTooltip implements MouseListener { - private final JidePopup popup; + private final JWindow popup; - public ClipartTooltip() { - popup = new JidePopup(); - popup.setKeepPreviousSize(false); + public ClipartTooltip(Component component) { + popup = new JWindow(SwingUtilities.getWindowAncestor(component)); + popup.setSize(400, 120); } @Override @@ -57,12 +58,15 @@ public void mouseReleased(MouseEvent e) { @Override public void mouseEntered(MouseEvent e) { - if (e.getSource() instanceof ClipartButton) { - ClipartButton clipartButton = (ClipartButton) e.getSource(); + if (e.getSource() instanceof ClipartButton clipartButton) { Clipart clipart = clipartButton.getClipart(); + + Point componentLocation = clipartButton.getLocationOnScreen(); + Point point = new Point(componentLocation.x + clipartButton.getWidth() - 20, componentLocation.y + clipartButton.getHeight() - 20); + popup.setLocation(point); popup.getContentPane().removeAll(); popup.getContentPane().add(new JLabel(getClipartText(clipart))); - popup.showPopup((Component) e.getSource()); + popup.setVisible(true); } } @@ -78,6 +82,6 @@ private String getClipartText(Clipart clipart) { @Override public void mouseExited(MouseEvent e) { - popup.hidePopup(); + popup.setVisible(false); } } diff --git a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/clipart/PreviewListPanel.java b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/clipart/PreviewListPanel.java index 9f01df7880..3c1cf20f76 100644 --- a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/clipart/PreviewListPanel.java +++ b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/clipart/PreviewListPanel.java @@ -114,7 +114,7 @@ public PreviewListPanel(ActionListener selectAction) { public void setCategory(Category category) { buttonsPanel.removeAll(); - ClipartTooltip tooltip = new ClipartTooltip(); + ClipartTooltip tooltip = new ClipartTooltip(this); sources.stream() .flatMap(source -> source.getCliparts(category).stream()) .sorted(Comparator.comparing(clipart -> clipart.getName().toLowerCase())) diff --git a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/imagetracer/ImageTracerDialog.java b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/imagetracer/ImageTracerDialog.java index 66993c9f22..a60cc345aa 100644 --- a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/imagetracer/ImageTracerDialog.java +++ b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/imagetracer/ImageTracerDialog.java @@ -27,14 +27,26 @@ This file is part of Universal Gcode Sender (UGS). import net.miginfocom.swing.MigLayout; import org.apache.commons.lang3.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.WindowConstants; import javax.swing.filechooser.FileNameExtensionFilter; -import java.awt.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; import java.io.ByteArrayInputStream; import java.io.File; import java.nio.charset.Charset; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Optional; /** * @author Joacim Breiler diff --git a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/imagetracer/TraceSettingsPanel.java b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/imagetracer/TraceSettingsPanel.java index b2a6bc92c6..8d284009b5 100644 --- a/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/imagetracer/TraceSettingsPanel.java +++ b/ugs-platform/ugs-platform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/imagetracer/TraceSettingsPanel.java @@ -18,10 +18,13 @@ This file is part of Universal Gcode Sender (UGS). */ package com.willwinder.ugs.nbp.designer.gui.imagetracer; -import com.jidesoft.swing.RangeSlider; import net.miginfocom.swing.MigLayout; -import javax.swing.*; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.JSlider; +import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.util.ArrayList; @@ -38,7 +41,8 @@ public class TraceSettingsPanel extends JPanel { private final JSlider pathOmit = new JSlider(0, 100, 0); private final JSlider blurRadius = new JSlider(0, 5, 0); private final JSlider blurDelta = new JSlider(0, 1014, 0); - private final RangeSlider colorRange = new RangeSlider(0, 255, 0, 255); + private final JSlider startColor = new JSlider(0, 255); + private final JSlider endColor = new JSlider(0, 255); private final List changeListeners = new ArrayList<>(); public TraceSettingsPanel() { @@ -49,11 +53,17 @@ public TraceSettingsPanel() { add(new JLabel("Number of layers")); add(colors); - colorRange.addChangeListener(this::updateValues); - colorRange.setMinorTickSpacing(10); - colorRange.setSnapToTicks(true); - add(new JLabel("Color range")); - add(colorRange); + startColor.addChangeListener(this::updateValues); + startColor.setMinorTickSpacing(10); + startColor.setSnapToTicks(true); + add(new JLabel("Color range start")); + add(startColor); + + endColor.addChangeListener(this::updateValues); + endColor.setMinorTickSpacing(10); + endColor.setSnapToTicks(true); + add(new JLabel("Color range end")); + add(endColor); colorsQuantization.addChangeListener(this::updateValues); colorsQuantization.setSnapToTicks(true); @@ -94,11 +104,13 @@ public TraceSettingsPanel() { } private void updateValues(ChangeEvent e) { - if(colorRange.getHighValue() == colorRange.getMinimum()) { - colorRange.setHighValue(colorRange.getMinimum() + 20); - } else if(colorRange.getLowValue() == colorRange.getMaximum()) { - colorRange.setLowValue(colorRange.getMaximum() - 20); - } + if (e.getSource() == endColor && endColor.getValue() <= startColor.getValue()) { + startColor.setValue(endColor.getValue() - 10); + } + + if (e.getSource() == startColor && startColor.getValue() >= endColor.getValue()) { + endColor.setValue(startColor.getValue() + 10); + } if (!((JSlider) e.getSource()).getValueIsAdjusting()) { changeListeners.forEach(l -> l.stateChanged(e)); @@ -106,7 +118,7 @@ private void updateValues(ChangeEvent e) { } public TraceSettings getSettings() { - TraceSettings settings = new TraceSettings(); + TraceSettings settings = new TraceSettings(); settings.setLineThreshold(Integer.valueOf(lineThreshold.getValue()).floatValue() / 10f); settings.setQuadThreshold(Integer.valueOf(curveThreshold.getValue()).floatValue() / 10f); settings.setPathOmit(pathOmit.getValue()); @@ -114,8 +126,8 @@ public TraceSettings getSettings() { settings.setColorQuantize(colorsQuantization.getValue()); settings.setBlurRadius(blurRadius.getValue()); settings.setBlurDelta(blurDelta.getValue()); - settings.setStartColor(colorRange.getLowValue()); - settings.setEndColor(colorRange.getHighValue()); + settings.setStartColor(startColor.getValue()); + settings.setEndColor(endColor.getValue()); return settings; } @@ -130,7 +142,8 @@ public void setEnabled(boolean enabled) { colorsQuantization.setEnabled(enabled); blurRadius.setEnabled(enabled); blurDelta.setEnabled(enabled); - colorRange.setEnabled(enabled); + startColor.setEnabled(enabled); + endColor.setEnabled(enabled); } public void addListener(ChangeListener listener) {