GUI2 - SYSC-2004 SYSC-2004 Object-Oriented Software...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
YSC 004* Object riented Software SYSC-2004 Object-Oriented Software Development Part 20-b Building Graphic User Interfaces with Java LayoutManagers andling Mouse Inputs Handling Mouse Inputs More JComponents Direct Drawing of Circles, Lines, etc Files discussed in these slides: l tt VC j • PlotterVC.java • Plotter.java • LinearLine.java Copyright © 2002, Systems and Computer Engineering, Carleton University. 94.204-18b-Gui2.ppt 1 revised October 2004
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
roblem: Curve Fitting Problem: Curve Fitting • Consider the problem of plotting a straight line through a set of points using linear regression (method of least squares) • Given a set of n points ( x 0 , y 0 ), ( x 1 , y 1 ), …( x n-1 , y n-1 ) the uation of the “best- t” straight line through the points is: equation of the best fit straight line through the points is: y = mx + b where: m= ( Σ ( x i y i ) - Σ x i * Σ y i / n ) / ( Σ ( x i 2 ) - ( Σ x i ) 2 / n ) b =( Σ y i - m * Σ x i ) / n • Deriving the equations is not difficult, but students metimes have difficulty relating the equations to the line sometimes have difficulty relating the equations to the line that they plot on a piece of paper. • Why not build an interactive GUI-based Java application at demonstrates the method of least squares? Copyright © 2002, Systems and Computer Engineering, Carleton University. 94.204-18b-Gui2.ppt 2 that demonstrates the method of least squares?
Background image of page 2
No points clicked One point clicked Each time you click the mouse in the frame, a circle is drawn at that point Copyright © 2002, Systems and Computer Engineering, Carleton University. 94.204-18b-Gui2.ppt 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Three points clicked Two points clicked y = 2.11x + 5.38 y = 1.86x + 3.46 As each point is clicked, the "best-fit" straight line through the set of points is calculated and drawn he equation is displayed below Copyright © 2002, Systems and Computer Engineering, Carleton University. 94.204-18b-Gui2.ppt 4 The equation is displayed below
Background image of page 4
Clear Plot button clicked Ten points clicked Copyright © 2002, Systems and Computer Engineering, Carleton University. 94.204-18b-Gui2.ppt 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
hat’sisthe odel or our application ? What s is the model for our application ? • The underlying data involved is a collection of points. LinearLine -points:ArrayList If insufficient points available, oth set to -slope:double -intercept:double; LinearLine() both set to Double.POSITIVE_INFINITY +LinearLine() +add(p:Point) +getPoints():Point[] t S l ( ) db l +getSlope():double +getIntercept():double -linearRegression() Uses least-squares to compute slope and intercept. Copyright © 2002, Systems and Computer Engineering, Carleton University. 94.204-18b-Gui2.ppt 6
Background image of page 6
hat’sthe ew f our application ? What s the view of our application ? JFrame JPanel JLabel JTextField JButton Copyright © 2002, Systems and Computer Engineering, Carleton University. 94.204-18b-Gui2.ppt 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
irst Cut at the Curve Fitting Application First Cut at the Curve Fitting Application Frame Panel inearLine JFrame JPanel LinearLine PlotterVC Plot paintComponent() Draws points and JButton JLabel JTextField p the straight line in the panel Copyright © 2002, Systems and Computer Engineering, Carleton University. 94.204-18b-Gui2.ppt 12
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/16/2009 for the course SYSC 3303 taught by Professor Shramp during the Spring '09 term at Carleton CA.

Page1 / 29

GUI2 - SYSC-2004 SYSC-2004 Object-Oriented Software...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online