Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have created 3 classes separately.....student class, GrahicUsInterface class &

ID: 3660153 • Letter: I

Question

I have created 3 classes separately.....student class, GrahicUsInterface class & studentGrade class. Data are created as a file in the project folder. But I dont know how to do input processing & display bar graphs on clicking buttons.... I need help on Input processing from data file to studentGrade class & add action events to each buttons to display bar graphs.

Explanation / Answer

BarGraph.java import javax.swing.*; import java.io.IOException; import java.util.Vector; import java.awt.*; import fr.esrf.tangoatk.widget.util.jdraw.JDrawEditor; import fr.esrf.tangoatk.widget.util.jdraw.JDObject; import fr.esrf.tangoatk.widget.util.jdraw.JDAxis; import fr.esrf.tangoatk.widget.util.ATKGraphicsUtils; public class BarGraph extends JFrame { JDrawEditor theGraph; JDObject graphArea; JDAxis graphAxis; JDObject[] allBars = new JDObject[8]; String[] barList = {"Cell1","Cell3","Cell4","Cell8","Cell9","Cell10","Cell15","Cell19"}; public BarGraph() { // Creates a JDrawEditor in MODE_PLAY theGraph = new JDrawEditor(JDrawEditor.MODE_PLAY); // Loads the JDraw file try { theGraph.loadFile("bargraph.jdw"); } catch (IOException e) { JOptionPane.showMessageDialog(this,e.getMessage(),"Error loading file",JOptionPane.ERROR_MESSAGE); System.exit(1); } // Retreives a handle to the graph area. // We will use this to repaint the appropriate area on update // and to calculate bar position. graphArea = getObject("masterView"); // Gets the axis handle in order // to retreive the min and max value. graphAxis = (JDAxis)getObject("Axis"); // Retreives bars handles. for(int i=0;i gRect.y // Min => gRect.y + gRect.heigth Rectangle gRect = graphArea.getBoundRect(); double y = (double)gRect.y; double h = (double)gRect.height; double max = graphAxis.getMax(); double min = graphAxis.getMin(); double nPos = (min-x)*h / (max-min) + (y+h); // Moves the summit (control point) of the shape. // Hint: To know which summit to move, you // can right click on a summit within the // editor and you will see the summit Id. allBars[idx].moveSummitV(5,nPos); // We do not call refresh() here because repaint // will be done by a refresh on the graphArea. } /** * Main function. */ public static void main(String[] args) { final BarGraph bg = new BarGraph(); ATKGraphicsUtils.centerFrameOnScreen(bg); bg.setVisible(true); } }