Skip to content

Commit

Permalink
Removed jidesoft-oss as it was not working with NetBeans and FlatLaf. (
Browse files Browse the repository at this point in the history
  • Loading branch information
breiler committed Jan 15, 2024
1 parent 9fba1ae commit 15c7e72
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 53 deletions.
2 changes: 0 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@
<ugs.commons-cli.version>1.4</ugs.commons-cli.version>
<ugs.easymock.version>3.4</ugs.easymock.version>
<ugs.maven-assembly-plugin.version>2.5.3</ugs.maven-assembly-plugin.version>
<ugs.jide.version>3.7.12</ugs.jide.version>
<ugs.snakeyaml.version>1.30</ugs.snakeyaml.version>
<ugs.flatlaf.version>3.2.5</ugs.flatlaf.version>

<!-- Sets the timestamp format -->
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
Expand Down
19 changes: 0 additions & 19 deletions ugs-platform/ugs-platform-plugin-designer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,6 @@
<version>${batik.version}</version>
</dependency>

<!-- For special graphical components -->
<dependency>
<groupId>com.formdev</groupId>
<artifactId>jide-oss</artifactId>
<version>${ugs.jide.version}</version>
</dependency>
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf-jide-oss</artifactId>
<version>${ugs.flatlaf.version}</version>
</dependency>

<!-- Look and feel when running standalone-->
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf</artifactId>
<version>${ugs.flatlaf.version}</version>
</dependency>

<!-- UGS dependencies -->
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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);
}
}

Expand All @@ -78,6 +82,6 @@ private String getClipartText(Clipart clipart) {

@Override
public void mouseExited(MouseEvent e) {
popup.hidePopup();
popup.setVisible(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<ChangeListener> changeListeners = new ArrayList<>();

public TraceSettingsPanel() {
Expand All @@ -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);
Expand Down Expand Up @@ -94,28 +104,30 @@ 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));
}
}

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());
settings.setNumberOfColors(colors.getValue());
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;
}

Expand All @@ -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) {
Expand Down

0 comments on commit 15c7e72

Please sign in to comment.