Reputation: 11
I'm writing a Java application that plots graphs for min/max/avg values of an accelerometer and gyroscope in their three fields xyz. I would like to be able to plot each factor independently, i.e. maximum acceleration in the X field with the average acceleration in the Z field etc.
I have used radio buttons for min/max/avg and for acceleration/y/z and gyroscopex/y/z.
I also thought about making radio buttons for min/max/avg for each variable but then I would have 18 separate variables.
Here is a snippet of my code:
if (selectionAccelX == 1 && selectionAccelY == 0 && selectionAccelZ == 0 &&
selectionGyroX == 0 && selectionGyroY == 0 && selectionGyroZ == 0 &&
selectionXAxis == 0) {
Graphing graphing = new Graphing("Average AccelerationX");
graphing.setAccelerationX(avgAccXSec);
graphing.displayGraphing();
graphing.pack();
RefineryUtilities.centerFrameOnScreen(graphing);
graphing.setVisible(true);
}
Is there an easier way to go about this?
Upvotes: 0
Views: 98
Reputation: 2824
Your code maps one variable (the radio button selector) to another variable (the value selector). One possible solution can be to
I assume that is not lesser code but can be more readable.
Upvotes: 1