import java.applet.*; import java.awt.*; import java.awt.event.*; import java.util.Vector; import java.lang.*; import java.text.Format; public class FinalNetworkApplet extends Applet implements ActionListener { // declaring variables etc int lastLoopSize=0; double currentpipeheadloss; double enteredFlowRate; int pipeflowstartX; int pipeflowstartY; int pipeflowendX; int pipeflowendY; int pipeloopstartX; int pipeloopstartY; int pipeloopendX; int pipeloopendY; int pipeNumber = 0; int drawSelectedpipe = 0; int redraw = 0; int nodeSelected = 0; float FFdata; float diameterdata; float lengthdata; int drawPipe = -1; int pipeNodeCounter = 0; int PressedCreatePipeButtonFirst = 0; int start; int end; int pipeStartX; int pipeStartY; int pipeEndX; int pipeEndY; private int pipeFirstLocX = -5; private int pipeSecondLocX = -5; private int pipeFirstLocY = -5; private int pipeSecondLocY = -5; private int nClicks = 0; private int x1, y1; private int mouseX ; private int mouseY ; private int vectorSize; private Label title = new Label("Network Node Input"); private Label title2 = new Label("Network Pipe Input"); private Label title3 = new Label("Network Pipe Loops Input"); private Label title5 = new Label("Pipe Network Flow Results"); private Label title4 = new Label("Network Pipe Flow Rate Input"); private NetworkDisplay canvas = new NetworkDisplay (); private NetworkDisplay2 canvas2 = new NetworkDisplay2 (); private NetworkDisplay3 canvas3 = new NetworkDisplay3 (); private NetworkDisplay4 canvas4 = new NetworkDisplay4 (); private NetworkDisplay5 canvas5 = new NetworkDisplay5 (); private Label clearData = new Label("CLEAR all node information"); private Label mouseLoc = new Label("Mouse Coordinates:"); private Label pipeLengthLabel = new Label("Length"); private Label pipeInformation = new Label("Pipe Dimensions and Data:"); private Label pipeDiameterLabel = new Label("Diameter"); private Label pipeFrictionFactorLabel = new Label("Roughness Coefficient"); private Label unitLabel = new Label("Metres"); private Label unitLabel2 = new Label("Metres"); private Label flowRateLabel = new Label("Assumed Volumetric Flow Rate"); private Label unitLabel3 = new Label ("m3/s"); private TextArea log = new TextArea ("Pipe network information will be displayed here. " + "\n" + "Please select node locations......\n",8, 40,TextArea.SCROLLBARS_VERTICAL_ONLY); private TextArea log2 = new TextArea ("Pipe network information will be displayed here. " ,8, 40,TextArea.SCROLLBARS_VERTICAL_ONLY); private TextArea log3 = new TextArea ("Pipe network information will be displayed here. " ,8, 40,TextArea.SCROLLBARS_VERTICAL_ONLY); private TextArea log4 = new TextArea ("Pipe network information will be displayed here. " ,8, 40,TextArea.SCROLLBARS_VERTICAL_ONLY); private TextArea resultsLog = new TextArea ("Network Flow Results..." ,25,40,TextArea.SCROLLBARS_VERTICAL_ONLY); private Label mouseLocation = new Label ("Mouse Co-ordinates"); private Label mouseLocation2 = new Label ("Mouse Co-ordinates"); private Label mouseLocation3 = new Label ("Mouse Co-ordinates"); private Label mouseLocation4 = new Label ("Mouse Co-ordinates"); private Label nodeInstructions = new Label ("Welcome. To create a node simply click at a location."); private Label pipeInstructions = new Label ("To create pipe, enter details and press button."); private Label loopInstructions = new Label ("Select and add pipes, then create loops from the list. "); private Label flowInstructions = new Label ("Select and set assumed flow rates to all pipes."); private Label resultsInstructions = new Label ("Hover over a pipe to recall its number."); private Vector nodeData = new Vector(); private Vector pipeStartLocationData = new Vector(); private Vector pipeEndLocationData = new Vector(); private Vector pipeLengthData = new Vector(); private Vector pipeDiameterData = new Vector(); private Vector pipeFFData = new Vector(); private Vector pipeStartData = new Vector(); private Vector pipeEndData = new Vector(); private Vector pipeMidpointData = new Vector(); private Vector loopData = new Vector(); private Vector flowData = new Vector(); private Vector flowDataNew = new Vector(); private Vector pipeHeadLossPerQ = new Vector(); private Vector pipeHeadLoss = new Vector(); private Vector summedPHL = new Vector(); private Vector summedPHLQ = new Vector(); private Vector initialDelta = new Vector(); private Vector correctionDelta = new Vector(); private Button gobackNodeCard = new Button("Back: Node Card"); private Button gobackPipeCard = new Button("Back: Pipe Card"); private Button gobackLoopCard = new Button("Back: Loop Card"); private Button gobackFlowCard = new Button("Back: Flow Card"); private Button gotoNodeCard = new Button("Back to Node Card"); private Button gotoPipeCard = new Button("Next Card: Pipe Input"); private Button gotoLoopCard = new Button("Next Card: Loop Input"); private Button gotoFlowCard = new Button("Next Card: Pipe Flow Input"); private Button gotoResultsCard = new Button("Next Card: Results"); private Button clearButton = new Button("Remove ALL nodes"); private Button createPipeButton = new Button("Click to Create Pipe"); private Button removePipeButton = new Button("Remove LAST Pipe"); private Button addPipeListButton = new Button("Add Pipe to List "); private Button resetLoopButton = new Button("Remove ALL Loops"); private Button createLoopButton = new Button("Create Loop from Listed Pipes"); private Button setFlowRateButton = new Button("Set Flow Rate for Pipe"); private Button calculateButton = new Button("CALCULATE"); private List pipeSelectedList = new List(8,false); private TextField pipeLengthTextField = new TextField(6); private TextField pipeDiameterTextField = new TextField(6); private TextField pipeFFTextField = new TextField(6); private TextField flowRateTextField = new TextField(6); Font titles = new Font ( "SansSerif", Font.BOLD,13); Font instructions = new Font ( "SansSerif", Font.BOLD,12); BorderLayout bl = new BorderLayout(); GridBagLayout gl = new GridBagLayout(); GridBagLayout gl2 = new GridBagLayout(); GridBagLayout gl3 = new GridBagLayout(); GridBagLayout gl4 = new GridBagLayout(); GridBagLayout gl5 = new GridBagLayout(); CardLayout cl = new CardLayout(); Panel p1 = new Panel(); Panel p2 = new Panel(); Panel p3 = new Panel(); Panel p4 = new Panel(); Panel p5 = new Panel(); Panel p6 = new Panel(); // Button listeners for whole Applet. public void actionPerformed(ActionEvent e) { Object source = e.getSource(); // CALCULATE BUTTON if (source == calculateButton) { try{ int itteration =0; double cD = 10; // iteration controller while ( Math.sqrt(Math.pow(cD,2)) > 0.000001 ) { double delta=0; double loopAdjustedFlow =0; double newFlow=0; double sum1=0; double sum2=0; int status = 0; int deltaCounter = 0; double correction=0; int currentpipe=0; int nextpipe=0; int loopSizeCount = 0; int loopDataSize = loopData.size(); for ( int b=0; b 1 ) { pipeSelectedList.removeAll(); loopInstructions.setText("Loop Created, create more or go to next card."); loopData.addElement( new Integer(999)); int loopData2 = loopData.size(); log3.append("\n" + "Loop Created from Pipes: "); for(int n=loopData2-lastLoopSize-1; npipeMidpointDataSize-1) { pipeNumber=0; } // resets resultsInstructions if no pipe is found else if (pipeNumber==999) { resultsInstructions.setText(""); } else; }; // loop close i=0; } //try closed catch (ArrayIndexOutOfBoundsException aioobe) { resultsInstructions.setText(""); } } } public void init () { // text area non-editable log.setEditable(false); log2.setEditable(false); log3.setEditable(false); log4.setEditable(false); resultsLog.setEditable(false); setLayout(bl); p1.setLayout(cl); p2.setLayout(gl); p3.setLayout(gl2); p4.setLayout(gl3); p5.setLayout(gl4); p6.setLayout(gl5); // defining gridbaglayout constraints GridBagConstraints gb = new GridBagConstraints(); gb.fill = GridBagConstraints.NONE; gb.weightx = 1; gb.weighty = 1; GridBagConstraints gb2 = new GridBagConstraints(); gb2.fill = GridBagConstraints.NONE; gb2.weightx = 1; gb2.weighty = 1; GridBagConstraints gb3 = new GridBagConstraints(); gb3.fill = GridBagConstraints.NONE; gb3.weightx = 1; gb3.weighty = 1; GridBagConstraints gb4 = new GridBagConstraints(); gb4.fill = GridBagConstraints.NONE; gb4.weightx = 1; gb4.weighty = 1; GridBagConstraints gb5 = new GridBagConstraints(); gb5.fill = GridBagConstraints.NONE; gb5.weightx = 1; gb5.weighty = 1; // Layout for Node Panel follows ************************************** NODE LAYOUT // Node Title GBL setup gb.gridx = 0; gb.gridy = 0; gb.gridwidth = 1; gb.gridheight = 1; gb.fill = GridBagConstraints.NONE; gb.anchor = GridBagConstraints.WEST; gl.setConstraints(title,gb); p2.add(title); // gotoPipeCard GBL setup gb.gridx = 2; gb.gridy = 0; gb.gridwidth = 2; gb.gridheight = 1; gb.fill = GridBagConstraints.NONE; gb.anchor = GridBagConstraints.EAST; gl.setConstraints(gotoPipeCard,gb); gotoPipeCard.addActionListener(this); p2.add(gotoPipeCard); // Canvas1 GBL Setup gb.gridx = 0; gb.gridy = 1; gb.gridwidth = 1; gb.gridheight = 3; gb.fill = GridBagConstraints.NONE; gb.anchor = GridBagConstraints.SOUTH; gl.setConstraints(canvas,gb); p2.add(canvas); // clearData Nodes Label GBl Setup gb.gridx = 1; gb.gridy = 1; gb.gridheight = 1; gb.gridwidth = 1; gb.fill = GridBagConstraints.NONE; gb.anchor = GridBagConstraints.WEST; gl.setConstraints(clearData,gb); p2.add(clearData); // clearButton Nodes GBl Setup gb.gridx = 2; gb.gridy = 1; gb.gridheight = 1; gb.gridwidth = 1; gb.fill = GridBagConstraints.HORIZONTAL; gb.anchor = GridBagConstraints.EAST; gl.setConstraints(clearButton,gb); clearButton.addActionListener(this); p2.add(clearButton); // Textarea log Node GBL Setup gb.gridx = 1; gb.gridy = 3; gb.gridheight = 1; gb.gridwidth = 2; gb.fill = GridBagConstraints.NONE; gb.anchor = GridBagConstraints.SOUTH; gl.setConstraints(log,gb); p2.add(log); // mouseLocation Label Node GBL Setup gb.gridx = 0; gb.gridy = 5; gb.gridheight = 1; gb.gridwidth = 1; gb.fill = GridBagConstraints.BOTH; gb.anchor = GridBagConstraints.NORTHWEST; gl.setConstraints(mouseLocation,gb); p2.add(mouseLocation); // nodeInstructions Label GBL Setup gb.gridx = 1; gb.gridy = 5; gb.gridheight = 1; gb.gridwidth = 2; gb.fill = GridBagConstraints.BOTH; gb.anchor = GridBagConstraints.WEST; gl.setConstraints(nodeInstructions,gb); p2.add(nodeInstructions); // Layout for Pipe Panel follows ********************************* PIPE LAYOUT // Title2 GBL setup gb2.gridx = 0; gb2.gridy = 0; gb2.gridwidth = 1; gb2.gridheight = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.WEST; gl2.setConstraints(title2,gb2); p3.add(title2); // gobackNodeCard Button GBL setup gb2.gridx = 1; gb2.gridy = 0; gb2.gridwidth = 1; gb2.gridheight = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.WEST; gl2.setConstraints(gobackNodeCard,gb2); gobackNodeCard.addActionListener(this); p3.add(gobackNodeCard); // gotoLoopCard Button GBL setup gb2.gridx = 2; gb2.gridy = 0; gb2.gridwidth = 2; gb2.gridheight = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.EAST; gl2.setConstraints(gotoLoopCard,gb2); gotoLoopCard.addActionListener(this); p3.add(gotoLoopCard); // Canvas2 GBL Setup gb2.gridx = 0; gb2.gridy = 1; gb2.gridwidth = 1; gb2.gridheight = 7; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.SOUTH; gl2.setConstraints(canvas2,gb2); p3.add(canvas2); // Label pipeLength GBL Setup gb2.gridx = 1; gb2.gridy = 1; gb2.gridheight = 1; gb2.gridwidth = 3; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.NORTHWEST; gl2.setConstraints(pipeInformation,gb2); p3.add(pipeInformation); // Label pipeLengthLabel GBL Setup gb2.gridx = 1; gb2.gridy = 2; gb2.gridheight = 1; gb2.gridwidth = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.WEST; gl2.setConstraints(pipeLengthLabel,gb2); p3.add(pipeLengthLabel); // TextField pipeLengthTextField GBL Setup gb2.gridx = 2; gb2.gridy = 2; gb2.gridheight = 1; gb2.gridwidth = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.EAST; gl2.setConstraints(pipeLengthTextField,gb2); p3.add(pipeLengthTextField); // Label unitLabel GBL Setup gb2.gridx = 3; gb2.gridy = 2; gb2.gridheight = 1; gb2.gridwidth = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.WEST; gl2.setConstraints(unitLabel,gb2); p3.add(unitLabel); // Label pipediameterlabel GBL Setup gb2.gridx = 1; gb2.gridy = 3; gb2.gridheight = 1; gb2.gridwidth = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.WEST; gl2.setConstraints(pipeDiameterLabel,gb2); p3.add(pipeDiameterLabel); // TextField pipeDiameterTextField GBL Setup gb2.gridx = 2; gb2.gridy = 3; gb2.gridheight = 1; gb2.gridwidth = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.EAST; gl2.setConstraints(pipeDiameterTextField,gb2); p3.add(pipeDiameterTextField); // Label unitLabel2 GBL Setup gb2.gridx = 3; gb2.gridy = 3; gb2.gridheight = 1; gb2.gridwidth = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.WEST; gl2.setConstraints(unitLabel2,gb2); p3.add(unitLabel2); // Label pipeFFLabel GBL Setup gb2.gridx = 1; gb2.gridy = 4; gb2.gridheight = 1; gb2.gridwidth = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.WEST; gl2.setConstraints(pipeFrictionFactorLabel,gb2); p3.add(pipeFrictionFactorLabel); // TextField pipeDiameterTextField GBL Setup gb2.gridx = 2; gb2.gridy = 4; gb2.gridheight = 1; gb2.gridwidth = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.EAST; gl2.setConstraints(pipeFFTextField,gb2); p3.add(pipeFFTextField); // Buttons createPipeButton GBL setup gb2.gridx = 1; gb2.gridy = 5; gb2.gridwidth = 3; gb2.gridheight = 1; gb2.fill = GridBagConstraints.HORIZONTAL; gb2.anchor = GridBagConstraints.SOUTH; gl2.setConstraints(createPipeButton,gb2); createPipeButton.addActionListener(this); p3.add(createPipeButton); // Buttons removepipebuttonGBL setup gb2.gridx = 2; gb2.gridy = 6; gb2.gridwidth = 2; gb2.gridheight = 1; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.EAST; gl2.setConstraints(removePipeButton,gb2); removePipeButton.addActionListener(this); p3.add(removePipeButton); // Textarea2 log2 GBL Setup gb2.gridx = 1; gb2.gridy = 7; gb2.gridheight = 1; gb2.gridwidth = 3; gb2.fill = GridBagConstraints.NONE; gb2.anchor = GridBagConstraints.SOUTH; gl2.setConstraints(log2,gb2); p3.add(log2); // Label mouseLocation2 GBL Setup gb2.gridx = 0; gb2.gridy = 8; gb2.gridheight = 1; gb2.gridwidth = 1; gb2.fill = GridBagConstraints.BOTH; gb2.anchor = GridBagConstraints.WEST; gl2.setConstraints(mouseLocation2,gb2); p3.add(mouseLocation2); // Label pipeInstructions GBL Setup gb2.gridx = 1; gb2.gridy = 8; gb2.gridheight = 1; gb2.gridwidth = 3; gb2.fill = GridBagConstraints.BOTH; gb2.anchor = GridBagConstraints.WEST; gl2.setConstraints(pipeInstructions,gb2); p3.add(pipeInstructions); // Loop Panel Layout follows *************************************** LOOP LAYOUT // Title3 GBL setup gb3.gridx = 0; gb3.gridy = 0; gb3.gridwidth = 1; gb3.gridheight = 1; gb3.fill = GridBagConstraints.NONE; gb3.anchor = GridBagConstraints.WEST; gl3.setConstraints(title3,gb3); p4.add(title3); // gobackPipeCard Button GBL setup gb3.gridx = 1; gb3.gridy = 0; gb3.gridwidth = 1; gb3.gridheight = 1; gb3.fill = GridBagConstraints.NONE; gb3.anchor = GridBagConstraints.WEST; gl3.setConstraints(gobackPipeCard,gb3); gobackPipeCard.addActionListener(this); p4.add(gobackPipeCard); // Buttons goto flow card GBL setup gb3.gridx = 2; gb3.gridy = 0; gb3.gridwidth = 1; gb3.gridheight = 1; gb3.fill = GridBagConstraints.NONE; gb3.anchor = GridBagConstraints.EAST; gl3.setConstraints(gotoFlowCard,gb3); gotoFlowCard.addActionListener(this); p4.add(gotoFlowCard); // Canvas3 GBL Setup gb3.gridx = 0; gb3.gridy = 1; gb3.gridwidth = 1; gb3.gridheight = 5; gb3.fill = GridBagConstraints.NONE; gb3.anchor = GridBagConstraints.SOUTH; gl3.setConstraints(canvas3,gb3); p4.add(canvas3); // List pipeSelectedList GBL setup gb3.gridx = 1; gb3.gridy = 2; gb3.gridwidth = 2; gb3.gridheight = 1; gb3.fill = GridBagConstraints.NONE; gb3.anchor = GridBagConstraints.CENTER; gl3.setConstraints(pipeSelectedList,gb3); p4.add(pipeSelectedList); // addpipelistbutton button GBL setup gb3.gridx = 1; gb3.gridy = 3; gb3.gridwidth = 1; gb3.gridheight = 1; gb3.fill = GridBagConstraints.NONE; gb3.anchor = GridBagConstraints.WEST; gl3.setConstraints(addPipeListButton,gb3); addPipeListButton.addActionListener(this); p4.add(addPipeListButton); // createLoopButton button GBL setup gb3.gridx = 2; gb3.gridy = 3; gb3.gridwidth = 1; gb3.gridheight = 1; gb3.fill = GridBagConstraints.NONE; gb3.anchor = GridBagConstraints.EAST; gl3.setConstraints(createLoopButton,gb3); createLoopButton.addActionListener(this); p4.add(createLoopButton); // resetloopbutton GBL setup gb3.gridx = 2; gb3.gridy = 4; gb3.gridwidth = 1; gb3.gridheight = 1; gb3.fill = GridBagConstraints.NONE; gb3.anchor = GridBagConstraints.EAST; gl3.setConstraints(resetLoopButton,gb3); resetLoopButton.addActionListener(this); p4.add(resetLoopButton); // Textarea3 log3 GBL Setup gb3.gridx = 1; gb3.gridy = 5; gb3.gridheight = 1; gb3.gridwidth = 2; gb3.fill = GridBagConstraints.NONE; gb3.anchor = GridBagConstraints.SOUTH; gl3.setConstraints(log3,gb3); p4.add(log3); // Label mouseLocation3 GBL Setup gb3.gridx = 0; gb3.gridy = 6; gb3.gridheight = 1; gb3.gridwidth = 1; gb3.fill = GridBagConstraints.BOTH; gb3.anchor = GridBagConstraints.NORTHWEST; gl3.setConstraints(mouseLocation3,gb3); p4.add(mouseLocation3); // loopInstructions label GBL Setup gb3.gridx = 1; gb3.gridy = 6; gb3.gridwidth = 2; gb3.gridheight = 1; gb3.fill = GridBagConstraints.NONE; gb3.anchor = GridBagConstraints.WEST; gl3.setConstraints(loopInstructions,gb3); p4.add(loopInstructions); // Flow rate Panel Layout follows *************************************** FLOW LAYOUT // Title4 GBL setup gb4.gridx = 0; gb4.gridy = 0; gb4.gridwidth = 1; gb4.gridheight = 1; gb4.fill = GridBagConstraints.NONE; gb4.anchor = GridBagConstraints.WEST; gl4.setConstraints(title4,gb4); p5.add(title4); // gobackLoopCard button GBL setup gb4.gridx = 1; gb4.gridy = 0; gb4.gridwidth = 1; gb4.gridheight = 1; gb4.fill = GridBagConstraints.NONE; gb4.anchor = GridBagConstraints.WEST; gl4.setConstraints(gobackLoopCard,gb4); gobackLoopCard.addActionListener(this); p5.add(gobackLoopCard); // Buttons gotoresultscard GBL setup gb4.gridx = 2; gb4.gridy = 0; gb4.gridwidth = 2; gb4.gridheight = 1; gb4.fill = GridBagConstraints.NONE; gb4.anchor = GridBagConstraints.EAST; gl4.setConstraints(gotoResultsCard,gb4); gotoResultsCard.addActionListener(this); p5.add(gotoResultsCard); // Canvas4 GBL Setup gb4.gridx = 0; gb4.gridy = 1; gb4.gridwidth = 1; gb4.gridheight = 3; gb4.fill = GridBagConstraints.NONE; gb4.anchor = GridBagConstraints.SOUTH; gl4.setConstraints(canvas4,gb4); p5.add(canvas4); // FlowRatelabel label GBL Setup gb4.gridx = 1; gb4.gridy = 1; gb4.gridwidth = 1; gb4.gridheight = 1; gb4.fill = GridBagConstraints.NONE; gb4.anchor = GridBagConstraints.WEST; gl4.setConstraints(flowRateLabel,gb4); p5.add(flowRateLabel); // flowRateTextField GBL Setup gb4.gridx = 2; gb4.gridy = 1; gb4.gridwidth = 1; gb4.gridheight = 1; gb4.fill = GridBagConstraints.NONE; gb4.anchor = GridBagConstraints.EAST; gl4.setConstraints(flowRateTextField,gb4); p5.add(flowRateTextField); // unitLabel3 GBL Setup gb4.gridx = 3; gb4.gridy = 1; gb4.gridwidth = 1; gb4.gridheight = 1; gb4.fill = GridBagConstraints.NONE; gb4.anchor = GridBagConstraints.WEST; gl4.setConstraints(unitLabel3,gb4); p5.add(unitLabel3); // setFlowRateButton button GBL Setup gb4.gridx = 1; gb4.gridy = 2; gb4.gridwidth = 2; gb4.gridheight = 1; gb4.fill = GridBagConstraints.NONE; gb4.anchor = GridBagConstraints.NORTHEAST; gl4.setConstraints(setFlowRateButton,gb4); setFlowRateButton.addActionListener(this); p5.add(setFlowRateButton); // textarea log4 GBL Setup gb4.gridx = 1; gb4.gridy = 3; gb4.gridwidth = 3; gb4.gridheight = 1; gb4.fill = GridBagConstraints.NONE; gb4.anchor = GridBagConstraints.SOUTH; gl4.setConstraints(log4,gb4); p5.add(log4); // Label mouseLocation4 GBL Setup gb4.gridx = 0; gb4.gridy = 4; gb4.gridheight = 1; gb4.gridwidth = 1; gb4.fill = GridBagConstraints.BOTH; gb4.anchor = GridBagConstraints.NORTHWEST; gl4.setConstraints(mouseLocation4,gb4); p5.add(mouseLocation4); // flowInstructions label GBL Setup gb4.gridx = 1; gb4.gridy = 4; gb4.gridwidth = 2; gb4.gridheight = 1; gb4.fill = GridBagConstraints.NONE; gb4.anchor = GridBagConstraints.WEST; gl4.setConstraints(flowInstructions,gb4); p5.add(flowInstructions); // Results Panel Layout follows ****************************************** RESULTS LAYOUT // Title5 GBL setup gb5.gridx = 0; gb5.gridy = 0; gb5.gridwidth = 1; gb5.gridheight = 1; gb5.fill = GridBagConstraints.NONE; gb5.anchor = GridBagConstraints.WEST; gl5.setConstraints(title5,gb5); p6.add(title5); // gobackFlowCard button GBL setup gb5.gridx = 1; gb5.gridy = 0; gb5.gridwidth = 1; gb5.gridheight = 1; gb5.fill = GridBagConstraints.NONE; gb5.anchor = GridBagConstraints.WEST; gl5.setConstraints(gobackFlowCard,gb5); gobackFlowCard.addActionListener(this); p6.add(gobackFlowCard); // Buttons gotonodecard GBL setup gb5.gridx = 2; gb5.gridy = 0; gb5.gridwidth = 1; gb5.gridheight = 1; gb5.fill = GridBagConstraints.NONE; gb5.anchor = GridBagConstraints.EAST; gl5.setConstraints(gotoNodeCard,gb5); gotoNodeCard.addActionListener(this); p6.add(gotoNodeCard); // Canvas5 GBL Setup gb5.gridx = 0; gb5.gridy = 1; gb5.gridwidth = 1; gb5.gridheight = 2; gb5.fill = GridBagConstraints.NONE; gb5.anchor = GridBagConstraints.CENTER; gl5.setConstraints(canvas5,gb5); p6.add(canvas5); // Textarea resultsLog GBL Setup gb5.gridx = 1; gb5.gridy = 1; gb5.gridheight = 1; gb5.gridwidth = 2; gb5.fill = GridBagConstraints.NONE; gb5.anchor = GridBagConstraints.CENTER; gl5.setConstraints(resultsLog,gb5); p6.add(resultsLog); // ResultsInstructions label GBL setup gb5.gridx = 1; gb5.gridy = 2; gb5.gridwidth = 2; gb5.gridheight = 1; gb5.fill = GridBagConstraints.BOTH; gb5.anchor = GridBagConstraints.EAST; gl5.setConstraints(resultsInstructions,gb5); p6.add(resultsInstructions); // Buttons calculate button GBL setup gb5.gridx = 0; gb5.gridy = 3; gb5.gridwidth = 3; gb5.gridheight = 1; gb5.fill = GridBagConstraints.BOTH; gb5.anchor = GridBagConstraints.CENTER; gl5.setConstraints(calculateButton,gb5); calculateButton.addActionListener(this); p6.add(calculateButton); //adding display panels to main card layout. p1.add("p2",p2); p1.add("p3",p3); p1.add("p4",p4); p1.add("p5",p5); p1.add("p6",p6); // adding card layout panel to main applet. add("Center", p1); // setting panel and canvas sizes p1.setSize(640,480); p2.setSize(640,480); p3.setSize(640,480); p4.setSize(640,480); p5.setSize(640,480); p6.setSize(640,480); canvas.setSize(330,420); canvas2.setSize(330,420); canvas3.setSize(330,420); canvas4.setSize(330,420); canvas5.setSize(330,420); //setting fonts title.setFont(titles); title2.setFont(titles); title3.setFont(titles); title4.setFont(titles); title5.setFont(titles); pipeInstructions.setFont(instructions); nodeInstructions.setFont(instructions); loopInstructions.setFont(instructions); flowInstructions.setFont(instructions); resultsInstructions.setFont(instructions); // setting background colours for all components // using different shades of orange for panels p2.setBackground(new Color(252,242,220)); p3.setBackground(new Color(250,231,192)); p4.setBackground(new Color(247,218,157)); p5.setBackground(new Color(244,209,136)); p6.setBackground(new Color(241,194,97)); log.setBackground(Color.white); log2.setBackground(Color.white); log3.setBackground(Color.white); log4.setBackground(Color.white); resultsLog.setBackground(Color.white); canvas.setBackground(new Color(236,236,236)); canvas2.setBackground(new Color(236,236,236)); canvas3.setBackground(new Color(236,236,236)); canvas4.setBackground(new Color(236,236,236)); canvas5.setBackground(new Color(241,194,97)); title.setBackground(new Color(252,242,220)); title2.setBackground(new Color(250,231,192)); title3.setBackground(new Color(247,218,157)); title4.setBackground(new Color(244,209,136)); title5.setBackground(new Color(241,194,97)); clearData.setBackground(new Color(252,242,220)); clearData.setForeground(Color.black); mouseLoc.setBackground(new Color(252,242,220)); mouseLoc.setForeground(Color.black); mouseLocation.setBackground(new Color(252,242,220)); mouseLocation.setForeground(Color.black); mouseLocation2.setBackground(new Color(250,231,192)); mouseLocation2.setForeground(Color.black); mouseLocation3.setBackground(new Color(247,218,157)); mouseLocation3.setForeground(Color.black); mouseLocation4.setBackground(new Color(244,209,136)); mouseLocation4.setForeground(Color.black); pipeLengthLabel.setBackground(new Color(250,231,192)); pipeLengthLabel.setForeground(Color.black); pipeDiameterLabel.setBackground(new Color(250,231,192)); pipeDiameterLabel.setForeground(Color.black); pipeInformation.setBackground(new Color(250,231,192)); pipeInformation.setForeground(Color.black); unitLabel.setBackground(new Color(250,231,192)); unitLabel.setForeground(Color.black); unitLabel2.setBackground(new Color(250,231,192)); unitLabel2.setForeground(Color.black); unitLabel3.setBackground(new Color(244,209,136)); unitLabel3.setForeground(Color.black); pipeLengthTextField.setBackground(Color.white); pipeLengthTextField.setForeground(Color.black); pipeDiameterTextField.setBackground(Color.white); pipeDiameterTextField.setForeground(Color.black); pipeFFTextField.setBackground(Color.white); pipeFFTextField.setForeground(Color.black); pipeFrictionFactorLabel.setBackground(new Color(250,231,192)); pipeFrictionFactorLabel.setForeground(Color.black); flowRateLabel.setBackground(new Color(244,209,136)); flowRateLabel.setForeground(Color.black); pipeInstructions.setBackground(new Color(250,231,192)); pipeInstructions.setForeground(Color.red); nodeInstructions.setBackground(new Color(252,242,220)); nodeInstructions.setForeground(Color.red); flowInstructions.setBackground(new Color(244,209,136)); flowInstructions.setForeground(Color.red); loopInstructions.setBackground(new Color(247,218,157)); loopInstructions.setForeground(Color.red); resultsInstructions.setBackground(new Color(241,194,97)); resultsInstructions.setForeground(Color.red); pipeSelectedList.setForeground(Color.black); pipeSelectedList.setBackground(Color.white); flowRateTextField.setBackground(Color.white); flowRateTextField.setForeground(Color.black); } // method init end } // MAIN CLASS END >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> // PROGRAM END...