Skip to content

Commit

Permalink
chore: remove controlsfx library and replace with MathUtils clamp met…
Browse files Browse the repository at this point in the history
…hod; fix exclusion for module added in NB RCP 21.0
  • Loading branch information
kunstmusik committed May 13, 2024
1 parent fdcf2b9 commit 51b0ff6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 44 deletions.
4 changes: 4 additions & 0 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,10 @@
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-libs-tomlj</artifactId>
</exclusion>
<exclusion>
<groupId>org.netbeans.modules</groupId>
<artifactId>org-netbeans-modules-project-dependency</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down
26 changes: 15 additions & 11 deletions blue-core/src/main/java/blue/utility/MathUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,26 @@
import java.math.MathContext;

/**
*
*
* @author steven
*/
public class MathUtils {

public static double remainder(double f1, double f2) {
MathContext mc = new MathContext(0);
public static double remainder(double f1, double f2) {
MathContext mc = new MathContext(0);

BigDecimal a = new BigDecimal(f1,mc);
BigDecimal b = new BigDecimal(f2, mc);
BigDecimal a = new BigDecimal(f1, mc);
BigDecimal b = new BigDecimal(f2, mc);

return a.remainder(b, mc).doubleValue();
}
return a.remainder(b, mc).doubleValue();
}

public static double clamp(double min, double value, double max) {
return Math.min(max, Math.max(min, value));
}

public static void main(String[] args) {
System.out.println(MathUtils.remainder(5.2, 5));
System.out.println(MathUtils.remainder(5.2, 1));
}
public static void main(String[] args) {
System.out.println(MathUtils.remainder(5.2, 5));
System.out.println(MathUtils.remainder(5.2, 1));
}
}
27 changes: 0 additions & 27 deletions blue-ui-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,33 +299,6 @@
<artifactId>blue-ext-openjfx</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>11.0.0</version>
<exclusions>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
</exclusion>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
</exclusion>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
</exclusion>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.java.timingframework</groupId>
<artifactId>timingframework-swing</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import blue.ui.utilities.UiUtilities;
import blue.undo.BlueUndoManager;
import blue.utilities.scales.ScaleLinear;
import blue.utility.MathUtils;
import blue.utility.NumberUtilities;
import blue.utility.ScoreUtilities;
import java.awt.BasicStroke;
Expand Down Expand Up @@ -67,7 +68,6 @@
import javax.swing.event.PopupMenuListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import org.controlsfx.tools.Utils;
import org.openide.windows.WindowManager;

/**
Expand Down Expand Up @@ -1174,7 +1174,7 @@ public void mouseDragged(MouseEvent e) {

ScaleLinear scale = selection.getScale();
if (selection.getScaleDirection() == ResizeMode.LEFT) {
newTime = Utils.clamp(0.0, newTime, scale.getRangeEnd() - edgeTime);
newTime = MathUtils.clamp(0.0, newTime, scale.getRangeEnd() - edgeTime);
} else {
newTime = Math.max(scale.getRangeStart() + edgeTime, newTime);
}
Expand Down Expand Up @@ -1274,7 +1274,7 @@ public void mouseDragged(MouseEvent e) {
timeState.getSnapValue());
}

dragTime = Utils.clamp(leftBoundaryTime, dragTime, rightBoundaryTime);
dragTime = MathUtils.clamp(leftBoundaryTime, dragTime, rightBoundaryTime);

selectedPoint.setLocation(dragTime,
screenToDoubleY(newY, min, max, currentParameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import blue.ui.core.score.ScoreMode;
import blue.ui.core.score.undo.ResizeScoreObjectsEdit;
import blue.undo.BlueUndoManager;
import blue.utility.MathUtils;
import blue.utility.ScoreUtilities;
import java.awt.Cursor;
import java.awt.Point;
Expand All @@ -35,7 +36,6 @@
import java.util.Collection;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.controlsfx.tools.Utils;

/**
*
Expand Down Expand Up @@ -213,7 +213,7 @@ private void resizeScoreObjectRight(MouseEvent e) {
newEnd = currentSObjTimes.end + maxDiffTime;
}

double diff = Utils.clamp(minDiffTime, newEnd - currentSObjTimes.end, maxDiffTime);
double diff = MathUtils.clamp(minDiffTime, newEnd - currentSObjTimes.end, maxDiffTime);

for (int i = 0; i < startEndTimes.length; i++) {
blue.ui.core.score.undo.StartEndTime t = startEndTimes[i];
Expand Down Expand Up @@ -268,7 +268,7 @@ private void resizeScoreObjectLeft(MouseEvent e) {
newStart = currentSObjTimes.start + minDiffTime;
}

double diff = Utils.clamp(minDiffTime, newStart - currentSObjTimes.start, maxDiffTime);
double diff = MathUtils.clamp(minDiffTime, newStart - currentSObjTimes.start, maxDiffTime);

for (int i = 0; i < startEndTimes.length; i++) {
blue.ui.core.score.undo.StartEndTime t = startEndTimes[i];
Expand Down

0 comments on commit 51b0ff6

Please sign in to comment.