mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 08:38:03 -06:00
Work on stuff
This commit is contained in:
@@ -61,7 +61,7 @@ public class ScoutingArray {
|
||||
|
||||
private dataType get_data_type_by_name(String name){
|
||||
for(dataType dt : array){
|
||||
if(dt.name.equals(name)){
|
||||
if(dt.getName().equals(name)){
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,27 @@ public abstract class dataType {
|
||||
NUM,
|
||||
STRING
|
||||
}
|
||||
public String name;
|
||||
public Object value;
|
||||
|
||||
|
||||
private Object value;
|
||||
private final String name;
|
||||
|
||||
public abstract valueTypes getValueType();
|
||||
|
||||
public Object forceGetValue(){return value;}
|
||||
public void forceSetValue(Object value){this.value = value;}
|
||||
|
||||
public abstract Object get();
|
||||
public abstract void set(Object value);
|
||||
|
||||
// public abstract Object getNullValue();
|
||||
// public abstract Object getUnselectedValue();
|
||||
|
||||
public abstract boolean isNull();
|
||||
public abstract Object getNullValue();
|
||||
public abstract valueTypes getValueType();
|
||||
public Object get(){
|
||||
return value;
|
||||
}
|
||||
public void set(Object value){
|
||||
this.value = value;
|
||||
}
|
||||
public abstract boolean isUnselected();
|
||||
|
||||
public String getName() {return name;}
|
||||
|
||||
public dataType(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -1,24 +1,56 @@
|
||||
package com.astatin3.scoutingapp2025.types.data;
|
||||
|
||||
public class intType extends dataType {
|
||||
public static final int nulval = 255;
|
||||
public static final int nullval = 0;
|
||||
public static final int unselectedval = 1;
|
||||
|
||||
public valueTypes getValueType() {
|
||||
return valueTypes.NUM;
|
||||
}
|
||||
|
||||
public intType(String name, int value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
// public Object getNullValue(){
|
||||
// return nullval;
|
||||
// }
|
||||
// public Object getUnselectedValue(){
|
||||
// return unselectedval;
|
||||
// }
|
||||
|
||||
public Object get(){
|
||||
return (int) forceGetValue()+2;
|
||||
}
|
||||
|
||||
public void set(Object value){
|
||||
forceSetValue((int) value - 2);
|
||||
}
|
||||
|
||||
public intType(String name, int value) {
|
||||
super(name);
|
||||
forceSetValue(value+2);
|
||||
}
|
||||
|
||||
public static intType newNull(String name){
|
||||
final intType a = new intType(name, 0);
|
||||
a.forceSetValue(nullval);
|
||||
return a;
|
||||
}
|
||||
|
||||
public static intType newUnselected(String name){
|
||||
final intType a = new intType(name, 0);
|
||||
a.forceSetValue(unselectedval);
|
||||
return a;
|
||||
}
|
||||
|
||||
public static boolean isNull(int obj){
|
||||
return obj == nullval;
|
||||
}
|
||||
public boolean isNull() {
|
||||
return ((int) value) == nulval;
|
||||
return isNull((int) forceGetValue());
|
||||
}
|
||||
public Object getNullValue(){
|
||||
return nulval;
|
||||
|
||||
public static boolean isUnselected(int obj){
|
||||
return obj == unselectedval;
|
||||
}
|
||||
public static intType nullify(String name){
|
||||
return new intType(name, nulval);
|
||||
public boolean isUnselected() {
|
||||
return isUnselected((int) forceGetValue());
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,57 @@
|
||||
package com.astatin3.scoutingapp2025.types.data;
|
||||
|
||||
public class stringType extends dataType{
|
||||
public static final String nulval = "Joe";
|
||||
public static final String nullval = "ƒ";
|
||||
public static final String unselectedval = "■";
|
||||
|
||||
public valueTypes getValueType() {return valueTypes.STRING;}
|
||||
public stringType(String name, String value){
|
||||
public valueTypes getValueType() {
|
||||
return valueTypes.STRING;
|
||||
}
|
||||
|
||||
// public Object getNullValue(){
|
||||
// return nullval;
|
||||
// }
|
||||
// public Object getUnselectedValue(){
|
||||
// return unselectedval;
|
||||
// }
|
||||
|
||||
public Object get(){
|
||||
return forceGetValue();
|
||||
}
|
||||
|
||||
public void set(Object value){
|
||||
forceSetValue(value);
|
||||
}
|
||||
|
||||
public stringType(String name, String value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
forceSetValue(value+2);
|
||||
}
|
||||
public boolean isNull(){
|
||||
return value.equals(nulval);
|
||||
|
||||
public static stringType newNull(String name){
|
||||
final stringType a = new stringType(name, "");
|
||||
a.forceSetValue(nullval);
|
||||
return a;
|
||||
}
|
||||
public Object getNullValue(){
|
||||
return nulval;
|
||||
|
||||
public static stringType newUnselected(String name){
|
||||
final stringType a = new stringType(name, "");
|
||||
a.forceSetValue(unselectedval);
|
||||
return a;
|
||||
}
|
||||
public static stringType nullify(String name){
|
||||
return new stringType(name, nulval);
|
||||
|
||||
public static boolean isNull(String obj){
|
||||
return obj.equals(nullval);
|
||||
}
|
||||
public boolean isNull() {
|
||||
return isNull((String) forceGetValue());
|
||||
}
|
||||
|
||||
|
||||
public static boolean isUnselected(String obj){
|
||||
return obj.equals(unselectedval);
|
||||
}
|
||||
public boolean isUnselected() {
|
||||
return isUnselected((String) forceGetValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class dropdownType extends inputType {
|
||||
};
|
||||
public void setViewValue(Object value) {
|
||||
if(dropdown == null) return;
|
||||
if(value.equals(intType.nulval)){
|
||||
if(intType.isNull((int) value)){
|
||||
nullify();
|
||||
return;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public class dropdownType extends inputType {
|
||||
}
|
||||
public dataType getViewValue(){
|
||||
if(dropdown == null) return null;
|
||||
if(dropdown.getVisibility() == View.GONE) return new intType(name, intType.nulval);
|
||||
if(dropdown.getVisibility() == View.GONE) return new intType(name, intType.nullval);
|
||||
return new intType(name, dropdown.getSelectedIndex());
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public class sliderType extends inputType {
|
||||
}
|
||||
public void setViewValue(Object value) {
|
||||
if(slider == null) return;
|
||||
if(value.equals(intType.nulval)){
|
||||
if(intType.isNull((int) value)){
|
||||
nullify();
|
||||
return;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class sliderType extends inputType {
|
||||
}
|
||||
public dataType getViewValue(){
|
||||
if(slider == null) return null;
|
||||
if(slider.getVisibility() == View.GONE) return new intType(name, intType.nulval);
|
||||
if(slider.getVisibility() == View.GONE) return intType.newNull(name);
|
||||
return new intType(name, min + (int) (slider.getValue() * (max-min)));
|
||||
}
|
||||
public void nullify(){
|
||||
@@ -170,7 +170,7 @@ public class sliderType extends inputType {
|
||||
int[] values = new int[max-min+1];
|
||||
|
||||
for (int i = 0; i < data.length; i++)
|
||||
if((int) data[i].get() != intType.nulval)
|
||||
if(intType.isNull((int) data[i].get()))
|
||||
values[(int) data[i].get()-min]++;
|
||||
|
||||
|
||||
|
||||
@@ -9,28 +9,16 @@ import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.astatin3.scoutingapp2025.types.data.dataType;
|
||||
import com.astatin3.scoutingapp2025.types.data.intType;
|
||||
import com.astatin3.scoutingapp2025.ui.scouting.TallyCounterView;
|
||||
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.charts.PieChart;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.data.PieDataSet;
|
||||
import com.github.mikephil.charting.data.PieEntry;
|
||||
import com.google.android.material.slider.Slider;
|
||||
import com.skydoves.powerspinner.IconSpinnerAdapter;
|
||||
import com.skydoves.powerspinner.IconSpinnerItem;
|
||||
import com.skydoves.powerspinner.OnSpinnerItemSelectedListener;
|
||||
import com.skydoves.powerspinner.PowerSpinnerView;
|
||||
import com.skydoves.powerspinner.SpinnerGravity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -41,11 +29,11 @@ public class tallyType extends inputType {
|
||||
public inputTypes getInputType(){return inputTypes.TALLY;}
|
||||
public dataType.valueTypes getValueType(){return dataType.valueTypes.NUM;}
|
||||
public Object get_fallback_value(){return 0;}
|
||||
public tallyType(){};
|
||||
public tallyType(){}
|
||||
public String get_type_name(){return "Dropdown";}
|
||||
public tallyType(String name, int default_value){
|
||||
super(name);
|
||||
this.default_value = default_value+1;
|
||||
this.default_value = default_value;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,15 +62,14 @@ public class tallyType extends inputType {
|
||||
|
||||
public View createView(Context context, Function<dataType, Integer> onUpdate){
|
||||
tally = new TallyCounterView(context);
|
||||
tally.setOnCountChangedListener(n -> {
|
||||
onUpdate.apply(getViewValue());
|
||||
});
|
||||
tally.setOnCountChangedListener(n -> onUpdate.apply(getViewValue()));
|
||||
|
||||
setViewValue(default_value);
|
||||
|
||||
return tally;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public void setViewValue(Object value) {
|
||||
if(tally == null) return;
|
||||
System.out.println(value);
|
||||
@@ -93,7 +80,7 @@ public class tallyType extends inputType {
|
||||
|
||||
isBlank = false;
|
||||
tally.setVisibility(View.VISIBLE);
|
||||
tally.setValue((int)value-1);
|
||||
tally.setValue((int)value);
|
||||
}
|
||||
public void nullify(){
|
||||
isBlank = true;
|
||||
@@ -102,7 +89,7 @@ public class tallyType extends inputType {
|
||||
public dataType getViewValue(){
|
||||
if(tally == null) return null;
|
||||
if(tally.getVisibility() == View.GONE) return new intType(name, 0);
|
||||
return new intType(name, tally.getValue()+1);
|
||||
return new intType(name, tally.getValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +106,7 @@ public class tallyType extends inputType {
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
tv.setText(String.valueOf((int) data.get()-1));
|
||||
tv.setText(String.valueOf((int) data.get()));
|
||||
tv.setTextSize(24);
|
||||
parent.addView(tv);
|
||||
}
|
||||
@@ -142,7 +129,7 @@ public class tallyType extends inputType {
|
||||
private static float calculateStandardDeviation(int[] data, float mean) {
|
||||
float sum = 0;
|
||||
for (int value : data) {
|
||||
sum += Math.pow((float) value - mean, 2);
|
||||
sum += (float) Math.pow((float) value - mean, 2);
|
||||
}
|
||||
return (float) Math.sqrt(sum / (data.length - 1));
|
||||
}
|
||||
@@ -150,27 +137,26 @@ public class tallyType extends inputType {
|
||||
private static List<Entry> generateNormalDistribution(float mean, float stdDev, int count, int scale) {
|
||||
List<Entry> entries = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
float x = i;
|
||||
float y = (float) ((1 / (stdDev * Math.sqrt(2 * Math.PI)))
|
||||
* Math.exp(-0.5 * Math.pow((x - mean) / stdDev, 2)));
|
||||
entries.add(new Entry(x, y*scale)); // Scale y for visibility
|
||||
* Math.exp(-0.5 * Math.pow(((float) i - mean) / stdDev, 2)));
|
||||
entries.add(new Entry((float) i, y*scale)); // Scale y for visibility
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
private static int findMin(dataType[] data){
|
||||
int min = (int)data[0].get()-1;
|
||||
int min = (int)data[0].get();
|
||||
for(int i = 1; i < data.length; i++)
|
||||
if((int)data[i].get()-1 < min)
|
||||
min = (int)data[i].get()-1;
|
||||
if((int)data[i].get() < min)
|
||||
min = (int)data[i].get();
|
||||
return min;
|
||||
}
|
||||
|
||||
private static int findMax(dataType[] data){
|
||||
int max = (int)data[0].get()-1;
|
||||
int max = (int)data[0].get();
|
||||
for(int i = 1; i < data.length; i++)
|
||||
if((int)data[i].get()-1 > max)
|
||||
max = (int)data[i].get()-1;
|
||||
if((int)data[i].get() > max)
|
||||
max = (int)data[i].get();
|
||||
return max;
|
||||
}
|
||||
|
||||
@@ -190,14 +176,14 @@ public class tallyType extends inputType {
|
||||
int[] values = new int[max-min+1];
|
||||
|
||||
for (int i = 0; i < data.length; i++)
|
||||
if((int) data[i].get() != intType.nulval)
|
||||
values[(int) data[i].get()-min-1]++;
|
||||
if(intType.isNull((int) data[i].get()))
|
||||
values[(int) data[i].get()-min]++;
|
||||
|
||||
|
||||
ArrayList<Integer> mean_temp = new ArrayList<>();
|
||||
for (int i = 0; i < data.length; i++)
|
||||
if((int)data[i].get() != 0)
|
||||
mean_temp.add((int) data[i].get()-1);
|
||||
mean_temp.add((int) data[i].get());
|
||||
|
||||
int[] mean_vals = mean_temp.stream().mapToInt(Integer::intValue).toArray();
|
||||
|
||||
@@ -270,7 +256,7 @@ public class tallyType extends inputType {
|
||||
for (int i = 0; i < data.length; i++){
|
||||
if(data[i] == null) continue;
|
||||
|
||||
entries.add(new Entry(i, (float)(int) data[i].get()-1));
|
||||
entries.add(new Entry(i, (float)(int) data[i].get()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public class textType extends inputType {
|
||||
};
|
||||
public void setViewValue(Object value) {
|
||||
if(text == null) return;
|
||||
if(value.equals(stringType.nulval)){
|
||||
if(stringType.isNull((String) value)){
|
||||
nullify();
|
||||
return;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class textType extends inputType {
|
||||
}
|
||||
public dataType getViewValue(){
|
||||
if(text == null) return null;
|
||||
if(text.getVisibility() == View.GONE) return new stringType(name, stringType.nulval);
|
||||
if(text.getVisibility() == View.GONE) return new stringType(name, stringType.nullval);
|
||||
return new stringType(name, text.getText().toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ public class TeamsFragment extends Fragment {
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
tv.setText(psda.data.array[a].name);
|
||||
tv.setText(psda.data.array[a].getName());
|
||||
tv.setTextSize(25);
|
||||
|
||||
if(psda.data.array[a].isNull()){
|
||||
@@ -305,7 +305,7 @@ public class TeamsFragment extends Fragment {
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
tv.setText(psda.data.array[a].name);
|
||||
tv.setText(psda.data.array[a].getName());
|
||||
tv.setTextSize(25);
|
||||
|
||||
if (psda.data.array[a].isNull()) {
|
||||
|
||||
Reference in New Issue
Block a user