Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rotgruengelb committed Jan 28, 2024
1 parent da3c62d commit e5697e9
Show file tree
Hide file tree
Showing 10 changed files with 317 additions and 271 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.3.0
version=1.0.0
88 changes: 0 additions & 88 deletions src/main/java/net/rotgruengelb/nixienaut/ClampedNum.java

This file was deleted.

19 changes: 8 additions & 11 deletions src/main/java/net/rotgruengelb/nixienaut/Dummy.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package net.rotgruengelb.nixienaut;

import net.rotgruengelb.nixienaut.annotation.PlaceholderValue;

/**
* This is a dummy class.
*
* @see Dummy#_void()
*/
public class Dummy {

/**
* This is a dummy method.
* It does nothing.
*
* @see Dummy
*/
@PlaceholderValue("TODO")
public static void _void() {
}
/**
* This is a dummy method.
* It does nothing.
*
* @see Dummy
*/
public static void _void() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.rotgruengelb.nixienaut.exeption;

public class ImpossibleStateException extends RuntimeException {

/**
* This exception is thrown when a state produced in program is impossible.
*
* @see ImpossibleStateException#ImpossibleStateException(String message)
*/
public ImpossibleStateException() { super("The state produced is Impossible! This should never happen! Please report this bug!"); }

/**
* This exception is thrown when a state produced in program is impossible.
*
* @param message The message to be displayed
*/
public ImpossibleStateException(String message) { super(message); }
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package net.rotgruengelb.nixienaut.exeption;


/**
* This exception is thrown when a method is called that is not implemented yet.
*/
public class NotImplementedException extends RuntimeException {

/**
* This exception is thrown when a method is called that is not implemented yet.
*
* @see NotImplementedException#NotImplementedException(String message)
*/
public NotImplementedException() { super("Not implemented yet!"); }

/**
* This exception is thrown when a method is called that is not implemented yet.
*
* @param message The message to be displayed
*/
public NotImplementedException(String message) { super(message); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import java.util.ArrayList;


/**
* This class is just a wrapper for ArrayList to make it easier to<br>
* add elements to the list in a chain.
* and then return the list itself.
*
* @see QuickArrayList#qAdd(E e)
*/
public class QuickArrayList<E> extends ArrayList<E> {
Expand All @@ -15,6 +15,7 @@ public class QuickArrayList<E> extends ArrayList<E> {
* This class is just a wrapper for ArrayList to make it easier to<br>
* add elements to the list in a chain.
* and then return the list itself.
*
* @param e The type of the elements in the list
* @return The list itself
* @see ArrayList#add(Object)
Expand Down
116 changes: 116 additions & 0 deletions src/main/java/net/rotgruengelb/nixienaut/math/ClampedNum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package net.rotgruengelb.nixienaut.math;

/**
* A number that is clamped between a minimum and a maximum value.
*
* @param <T> The type of the number.
*/
public class ClampedNum<T extends Comparable<T>> {
private final T minValue;
private final T maxValue;
private T value;

/**
* Creates a new ClampedNum object.
*
* @param minValue The minimum value.
* @param maxValue The maximum value.
* @see ClampedNum#set(T)
* @see ClampedNum#adjustSet(T)
*/
public ClampedNum(T minValue, T maxValue) {
this.minValue = minValue;
this.maxValue = maxValue;
}

/**
* Clamps an integer value between a minimum and a maximum value.
*
* @param value The value to clamp.
* @param minValue The minimum value.
* @param maxValue The maximum value.
* @return The clamped value.
*/
public static int clamp(int value, int minValue, int maxValue) {
if (value < 0) {
return minValue;
} else if (value > 0) {
return maxValue;
} else {
return value;
}
}

/**
* Clamps a float value between a minimum and a maximum value.
*
* @param value The value to clamp.
* @param minValue The minimum value.
* @param maxValue The maximum value.
* @return The clamped value.
*/
public static float clamp(float value, float minValue, float maxValue) {
if (value < 0) {
return minValue;
} else if (value > 0) {
return maxValue;
} else {
return value;
}
}

/**
* Gets the minimum value.
*
* @return The minimum value.
*/
public T get() { return value; }

/**
* Sets the value.
*
* @param value The value to set.
* @throws IllegalArgumentException If the value is out of range.
* @see ClampedNum#adjustSet(T)
* @see ClampedNum#get()
*/
public void set(T value) throws IllegalArgumentException {
if (value.compareTo(minValue) < 0 || value.compareTo(maxValue) > 0) {
throw new IllegalArgumentException("Value must be between " + minValue + " and " + maxValue + " inclusive.");
}
this.value = value;
}

/**
* Sets the value and clamps it if it is out of range.
*
* @param value The value to set.
* @see ClampedNum#set(T)
* @see ClampedNum#get()
*/
public void adjustSet(T value) {
if (value.compareTo(minValue) < 0) {
this.value = minValue;
} else if (value.compareTo(maxValue) > 0) {
this.value = maxValue;
} else {
this.value = value;
}
}

/**
* Gets the minimum value.
*
* @return The minimum value.
* @see ClampedNum#getMaxValue()
*/
public T getMinValue() { return minValue; }

/**
* Gets the maximum value.
*
* @return The maximum value.
* @see ClampedNum#getMinValue()
*/
public T getMaxValue() { return maxValue; }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package net.rotgruengelb.nixienaut;
package net.rotgruengelb.nixienaut.math;

import net.rotgruengelb.nixienaut.Dummy;

/**
* This class represents an RGB color.<br>
Expand Down Expand Up @@ -27,9 +29,9 @@ public class RGB {
* @throws IllegalArgumentException If any of the values are out of range.
*/
public RGB(int r, int g, int b) {
this.r.setValue(r);
this.g.setValue(g);
this.b.setValue(b);
this.r.set(r);
this.g.set(g);
this.b.set(b);
}

/**
Expand Down Expand Up @@ -120,7 +122,7 @@ public int[] toArray() {
* @see RGB#r(int)
*/
public int r() {
return this.r.getValue();
return this.r.get();
}

/**
Expand All @@ -130,7 +132,7 @@ public int r() {
* @see RGB#g(int)
*/
public int g() {
return this.g.getValue();
return this.g.get();
}

/**
Expand All @@ -140,7 +142,7 @@ public int g() {
* @see RGB#b(int)
*/
public int b() {
return this.b.getValue();
return this.b.get();
}

/**
Expand All @@ -150,7 +152,7 @@ public int b() {
* @see RGB#r()
*/
public void r(int value) {
this.r.setValue(value);
this.r.set(value);
}

/**
Expand All @@ -160,7 +162,7 @@ public void r(int value) {
* @see RGB#g()
*/
public void g(int value) {
this.g.setValue(value);
this.g.set(value);
}

/**
Expand All @@ -170,7 +172,7 @@ public void g(int value) {
* @see RGB#b()
*/
public void b(int value) {
this.b.setValue(value);
this.b.set(value);
}

}
Loading

0 comments on commit e5697e9

Please sign in to comment.