MTH 115-01 Stats Name__________________
85 Possible Points Fall 2015
Part A: For problems 1 - 4, draw the necessary pictures so that I may follow your work. Label all z-scores and areas. Assume that we have a normal distribution with a. (5 pts each)
1. P(x < 75) = __________ 2. P(73 < x < 93) = __________
3. P(x <73 or x > 75) = __________ 4. P(x = 73) = ___________
Part B: Determine whether each statement is true or false.
If the statement is false, explain why. (15 points = 3pts each)
1. The total area under the normal distribution bell-shaped curve is infinite.
2. The standard normal distribution is a discrete distribution.
3. The z value corresponding to a number below the mean is always negative.
4. The area under the standard normal distribution to the left of z = 0 is negative.
5. For a standard normal probability distribution, the mean is always 1.
Part C: Work the following problems. Please show your work to receive full credit.
1. (15pts) 30 High school students were randomly selected and surveyed about the amounts of time they spend at after-school jobs. The mean and standard deviation were found to be 26 hours and 6 hours, respectively. Assume that the given statistics come from a normally distributed population.
a. Find the best point estimate of the population standard deviation.
b. Find a 95% confidence interval for the population standard deviation.
2. (10pts) You have just been hired by General Motors to tour the United States giving randomly selected drivers test rides in a new Corvette (yeah, right!). After giving the test drive, you must ask the rider whether he or she would consider buying a Corvette. How many riders must you survey (take for test rides) to be 90% confident that the sample proportion is off by no more than five percentage points?
3. (10pts) Of 2590 students randomly selected, 98% of them own computers. Construct a 99% confidence interval for the true proportion of all students who own computers.
4. (15pts) A food packing company fills sacks of cereal using automated machinery. The fill amounts are normally distributed with a mean weight of 2 pounds and a standard deviation of 0.20 pounds.
a) One sack is randomly selected. What is the probability that the weight of the sack exceeds 2.05 pounds?
b) Sixteen sacks are randomly selected. What is the probability that the mean weight of the sample of 16 sacks exceeds 2.05 pounds?
Page 1 of 3
75 and 10
ms
==
PainterStartup/.classpath
PainterStartup/.project
Painter
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
PainterStartup/.settings/org.eclipse.jdt.core.prefs
#Fri Apr 27 08:03:31 EDT 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.comp.
MTH 115-01 StatsName__________________85 Possible Points.docx
1. MTH 115-01 Stats Name__________________
85 Possible Points Fall 2015
Part A: For problems 1 - 4, draw the necessary pictures so that
I may follow your work. Label all z-scores and areas.
Assume that we have a normal distribution with a. (5 pts
each)
1. P(x < 75) = __________ 2. P(73 < x < 93) =
__________
3. P(x <73 or x > 75) = __________ 4. P(x = 73) =
___________
2. Part B: Determine whether each statement is true or false.
If the statement is false, explain why. (15 points = 3pts each)
1. The total area under the normal distribution bell-shaped
curve is infinite.
2. The standard normal distribution is a discrete
distribution.
3. The z value corresponding to a number below the mean
is always negative.
4. The area under the standard normal distribution to the
left of z = 0 is negative.
5. For a standard normal probability distribution, the
mean is always 1.
Part C: Work the following problems. Please show your work
to receive full credit.
1. (15pts) 30 High school students were randomly selected and
surveyed about the amounts of time they spend at after-school
jobs. The mean and standard deviation were found to be 26
hours and 6 hours, respectively. Assume that the given
statistics come from a normally distributed population.
a. Find the best point estimate of the population standard
deviation.
3. b. Find a 95% confidence interval for the population standard
deviation.
2. (10pts) You have just been hired by General Motors to tour
the United States giving randomly selected drivers test rides in
a new Corvette (yeah, right!). After giving the test drive, you
must ask the rider whether he or she would consider buying a
Corvette. How many riders must you survey (take for test
rides) to be 90% confident that the sample proportion is off by
no more than five percentage points?
3. (10pts) Of 2590 students randomly selected, 98% of them
own computers. Construct a 99% confidence interval for the
true proportion of all students who own computers.
4. 4. (15pts) A food packing company fills sacks of cereal using
automated machinery. The fill amounts are normally distributed
with a mean weight of 2 pounds and a standard deviation of
0.20 pounds.
a) One sack is randomly selected. What is the probability that
the weight of the sack exceeds 2.05 pounds?
b) Sixteen sacks are randomly selected. What is the probability
that the mean weight of the sample of 16 sacks exceeds 2.05
pounds?
Page 1 of 3
75 and 10
ms
==
PainterStartup/.classpath
12. import java.awt.event.ActionEvent;
import java.util.EventObject;
/**
* This interface should be implemented by UI classes that want
to allow some data they handle to be saved.
* @author David T. Smith
*/
publicinterfaceCloseable{
publicvoid close(ActionEvent evt);
publicboolean isCloseable(EventObject evt);
}
PainterStartup/com/javera/ui/actions/CloseAction.classpackage
com.javera.ui.actions;
publicsynchronizedclass CloseAction extends
ManagedStateAction {
privatestatic CloseAction saveAction;
static void <clinit>();
private void CloseAction();
publicstatic CloseAction getAction();
public void actionPerformed(java.awt.event.ActionEvent);
public boolean isTargetEnabled(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/CloseAction.javaPainterSt
artup/com/javera/ui/actions/CloseAction.java//Copyright 2004, (
c) Javera Software, LLC. as an unpublished work. All rights res
erved world-wide.
//This is a proprietary trade secret of Javera Software LLC. Use
restricted to licensing terms.
package com.javera.ui.actions;
14. }
}
PainterStartup/com/javera/ui/actions/CloseAllable.classpackage
com.javera.ui.actions;
publicabstractinterface CloseAllable {
publicabstract boolean closeAll(java.awt.event.ActionEvent);
publicabstract boolean isCloseAllable(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/CloseAllable.javaPainterSt
artup/com/javera/ui/actions/CloseAllable.javapackage com.javer
a.ui.actions;
import java.awt.event.ActionEvent;
import java.util.EventObject;
/**
* This interface should be implemented by UI classes that want
to allow some data they handle to be saved.
* @author David T. Smith
*/
publicinterfaceCloseAllable{
publicboolean closeAll(ActionEvent evt);
publicboolean isCloseAllable(EventObject evt);
}
PainterStartup/com/javera/ui/actions/CloseAllAction.classpacka
ge com.javera.ui.actions;
publicsynchronizedclass CloseAllAction extends
javax.swing.AbstractAction {
privatestatic CloseAllAction saveAllAction;
27. }
publicboolean isTargetEnabled(EventObject evt ){
Exitable exitable =(Exitable)
ActionUtilities.getCommandTarget( evt,Exitable.class);
if( exitable !=null){
return exitable.isExitable( evt );
}else{
returnfalse;
}
}
}
PainterStartup/com/javera/ui/actions/Exportable.classpackage
com.javera.ui.actions;
publicabstractinterface Exportable {
publicabstract void export(java.awt.event.ActionEvent);
publicabstract boolean isExportable(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/Exportable.javaPainterStar
tup/com/javera/ui/actions/Exportable.java/* Generated by Toget
her */
package com.javera.ui.actions;
import java.awt.event.ActionEvent;
import java.util.EventObject;
/**
* This interface should be implemented by components that wis
28. h to work
* with Export actions.
*/
publicinterfaceExportable{
/**
* Performs the Export action.
*/
publicvoid export(ActionEvent evt );
/**
* Implementing object should use this method to specify wh
ether an Export
* is currently performable.
*/
publicboolean isExportable(EventObject evt );
}
PainterStartup/com/javera/ui/actions/ExportAction.classpackage
com.javera.ui.actions;
publicsynchronizedclass ExportAction extends
ManagedStateAction {
privatestatic ExportAction exportAction;
static void <clinit>();
private void ExportAction();
publicstatic ExportAction getAction();
public void actionPerformed(java.awt.event.ActionEvent);
public boolean isTargetEnabled(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/ExportAction.javaPainterS
tartup/com/javera/ui/actions/ExportAction.java/* Generated by
Together */
package com.javera.ui.actions;
46. publicabstract void pageSetup(java.awt.event.ActionEvent);
publicabstract boolean
isPageSetupable(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/PageSetupable.javaPainter
Startup/com/javera/ui/actions/PageSetupable.javapackage com.j
avera.ui.actions;
import java.awt.event.ActionEvent;
import java.util.EventObject;
/**
* This interface should be implemented by components that wis
h to work
* with Print actions.
*/
publicinterfacePageSetupable{
/** Performs the Print action. */
publicvoid pageSetup(ActionEvent evt );
/**
* Implementing object should use this method to specify wh
ether a Print
* is currently performable.
*/
publicboolean isPageSetupable(EventObject evt );
}
PainterStartup/com/javera/ui/actions/PageSetupAction.classpack
age com.javera.ui.actions;
publicsynchronizedclass PageSetupAction extends
javax.swing.AbstractAction {
privatestatic PageSetupAction pageSetupAction;
51. returnfalse;
}
}
}
PainterStartup/com/javera/ui/actions/Printable.classpackage
com.javera.ui.actions;
publicabstractinterface Printable {
publicabstract void print(java.awt.event.ActionEvent);
publicabstract boolean isPrintable(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/Printable.javaPainterStartu
p/com/javera/ui/actions/Printable.javapackage com.javera.ui.act
ions;
import java.awt.event.ActionEvent;
import java.util.EventObject;
/**
* This interface should be implemented by components that wis
h to work
* with Print actions.
*/
publicinterfacePrintable{
/** Performs the Print action. */
publicvoid print(ActionEvent evt );
/**
* Implementing object should use this method to specify wh
ether a Print
56. returnfalse;
}
}
}
PainterStartup/com/javera/ui/actions/Refreshable.classpackage
com.javera.ui.actions;
publicabstractinterface Refreshable {
publicabstract void refresh(java.awt.event.ActionEvent);
publicabstract boolean isRefreshable(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/Refreshable.javaPainterSta
rtup/com/javera/ui/actions/Refreshable.javapackage com.javera.
ui.actions;
import java.awt.event.ActionEvent;
import java.util.EventObject;
/**
* This interface should be implemented by components that wis
h to work
* with Refresh actions.
*/
publicinterfaceRefreshable{
/** Performs the Find action. */
publicvoid refresh(ActionEvent evt );
/**
* Implementing object should use this method to specify wh
ether a Refresh
* is currently performable.
*/
publicboolean isRefreshable(EventObject evt );
57. }
PainterStartup/com/javera/ui/actions/RefreshAction.classpackag
e com.javera.ui.actions;
publicsynchronizedclass RefreshAction extends
ManagedStateAction {
privatestatic RefreshAction refreshAction;
static void <clinit>();
private void RefreshAction();
publicstatic RefreshAction getAction();
public void actionPerformed(java.awt.event.ActionEvent);
public boolean isTargetEnabled(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/RefreshAction.javaPainter
Startup/com/javera/ui/actions/RefreshAction.javapackage com.j
avera.ui.actions;
import com.javera.ui.IconManager;
import java.awt.event.ActionEvent;
import java.util.EventObject;
import javax.swing.Action;
/** A managed state action for Refresh operations. */
publicclassRefreshActionextendsManagedStateAction{
privatestaticRefreshAction refreshAction =newRefreshAction();
privateRefreshAction(){
super("Refresh...",IconManager.getIcon("Refresh.gif"));
putValue(Action.MNEMONIC_KEY,newInteger('F'));
putValue(Action.SHORT_DESCRIPTION,"Refresh");
putValue(Action.LONG_DESCRIPTION,"Refresh");
}
59. ons;
import java.awt.event.ActionEvent;
import java.util.EventObject;
/**
* This interface should be implemented by UI classes that want
to allow some data they handle to be saved.
* @author David T. Smith
*/
publicinterfaceSaveable{
publicvoid save(ActionEvent evt);
publicboolean isSaveable(EventObject evt);
}
PainterStartup/com/javera/ui/actions/SaveAction.classpackage
com.javera.ui.actions;
publicsynchronizedclass SaveAction extends
ManagedStateAction {
privatestatic SaveAction saveAction;
static void <clinit>();
private void SaveAction();
publicstatic SaveAction getAction();
public void actionPerformed(java.awt.event.ActionEvent);
public boolean isTargetEnabled(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/SaveAction.javaPainterSta
rtup/com/javera/ui/actions/SaveAction.javapackage com.javera.
ui.actions;
import java.awt.event.ActionEvent;
import java.util.EventObject;
61. PainterStartup/com/javera/ui/actions/SaveAllable.classpackage
com.javera.ui.actions;
publicabstractinterface SaveAllable {
publicabstract void saveAll(java.awt.event.ActionEvent);
publicabstract boolean isSaveAllable(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/SaveAllable.javaPainterSta
rtup/com/javera/ui/actions/SaveAllable.javapackage com.javera.
ui.actions;
import java.awt.event.ActionEvent;
import java.util.EventObject;
/**
* This interface should be implemented by UI classes that want
to allow some data they handle to be saved.
* @author David T. Smith
*/
publicinterfaceSaveAllable{
publicvoid saveAll(ActionEvent evt);
publicboolean isSaveAllable(EventObject evt);
}
PainterStartup/com/javera/ui/actions/SaveAllAction.classpackag
e com.javera.ui.actions;
publicsynchronizedclass SaveAllAction extends
javax.swing.AbstractAction {
privatestatic SaveAllAction saveAllAction;
static void <clinit>();
private void SaveAllAction();
63. }
publicboolean isTargetEnabled(EventObject evt){
SaveAllable target =
(SaveAllable)ActionUtilities.getCommandTarget(evt,SaveAllabl
e.class);
if(target !=null){
return target.isSaveAllable(evt);
}else{
returnfalse;
}
}
}
PainterStartup/com/javera/ui/actions/SaveAsable.classpackage
com.javera.ui.actions;
publicabstractinterface SaveAsable {
publicabstract void saveAs(java.awt.event.ActionEvent);
publicabstract boolean isSaveAsable(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/SaveAsable.javaPainterSta
rtup/com/javera/ui/actions/SaveAsable.java//Copyright 2004, (c)
Javera Software, LLC. as an unpublished work. All rights reser
ved world-wide.
//This is a proprietary trade secret of Javera Software LLC. Use
restricted to licensing terms.
package com.javera.ui.actions;
import java.awt.event.ActionEvent;
import java.util.EventObject;
64. /**
* This interface should be implemented by UI classes that want
to allow some data they handle to be saved
* as another entity.
* @author David T. Smith
*/
publicinterfaceSaveAsable{
publicvoid saveAs(ActionEvent evt);
publicboolean isSaveAsable(EventObject evt);
}
PainterStartup/com/javera/ui/actions/SaveAsAction.classpackag
e com.javera.ui.actions;
publicsynchronizedclass SaveAsAction extends
javax.swing.AbstractAction {
privatestatic SaveAsAction saveAsAction;
static void <clinit>();
private void SaveAsAction();
publicstatic SaveAsAction getAction();
public void actionPerformed(java.awt.event.ActionEvent);
public boolean isTargetEnabled(java.util.EventObject);
}
PainterStartup/com/javera/ui/actions/SaveAsAction.javaPainter
Startup/com/javera/ui/actions/SaveAsAction.java//Copyright 20
04, (c) Javera Software, LLC. as an unpublished work. All right
s reserved world-wide.
//This is a proprietary trade secret of Javera Software LLC. Use
restricted to licensing terms.
package com.javera.ui.actions;
import java.awt.event.ActionEvent;
74. */
publicinterfaceCompleteEntry{
publicvoid completeEntry();
}
PainterStartup/com/javera/ui/GetIcon.classpackage
com.javera.ui;
publicabstractinterface GetIcon {
publicabstract javax.swing.Icon getIcon();
}
PainterStartup/com/javera/ui/GetIcon.javaPainterStartup/com/ja
vera/ui/GetIcon.java//Copyright 2004, (c) Javera Software, LLC
. as an unpublished work. All rights reserved world-wide.
//This is a proprietary trade secret of Javera Software LLC. Use
restricted to licensing terms.
package com.javera.ui;
import javax.swing.Icon;
/**
* GetIcon interface provides access to the getIcon() method use
d by
* the various renderers to obtain an Icon for a given object
*
* @author David T. Smith
*/
publicinterfaceGetIcon{
/**
* Get the icon to be displayed by the renderer
* @ return the icon to be displayed
*/
publicIcon getIcon();
75. }
PainterStartup/com/javera/ui/GetObject.classpackage
com.javera.ui;
publicabstractinterface GetObject {
publicabstract Object getObject();
}
PainterStartup/com/javera/ui/GetObject.javaPainterStartup/com/
javera/ui/GetObject.java//Copyright 2004, (c) Javera Software,
LLC. as an unpublished work. All rights reserved world-wide.
//This is a proprietary trade secret of Javera Software LLC. Use
restricted to licensing terms.
package com.javera.ui;
/**
* GetObject interface provides access to the getObject() metho
d used by
* the various renderers to obtain a contained object
*
* @author David T. Smith
*/
publicinterfaceGetObject{
/**
* Get the contained object
* @return the contained object
*/
publicObject getObject();
}
PainterStartup/com/javera/ui/GetPopupMenu.classpackage
com.javera.ui;
76. publicabstractinterface GetPopupMenu {
publicabstract javax.swing.JPopupMenu
getPopupMenu(java.awt.event.MouseEvent);
}
PainterStartup/com/javera/ui/GetPopupMenu.javaPainterStartup
/com/javera/ui/GetPopupMenu.java//Copyright 2004, (c) Javera
Software, LLC. as an unpublished work. All rights reserved wo
rld-wide.
//This is a proprietary trade secret of Javera Software LLC. Use
restricted to licensing terms.
package com.javera.ui;
import java.awt.event.MouseEvent;
import javax.swing.JPopupMenu;
publicinterfaceGetPopupMenu{
publicJPopupMenu getPopupMenu(MouseEvent e);
}
PainterStartup/com/javera/ui/GetText.classpackage
com.javera.ui;
publicabstractinterface GetText {
publicabstract String getText();
}
PainterStartup/com/javera/ui/GetText.javaPainterStartup/com/ja
vera/ui/GetText.java//Copyright 2004, (c) Javera Software, LLC
. as an unpublished work. All rights reserved world-wide.
//This is a proprietary trade secret of Javera Software LLC. Use
restricted to licensing terms.
77. package com.javera.ui;
/**
* GetText interface provides access to the getText() method us
ed by
* the default renderers for JvList and JvComboBox to get the te
xt to be
* displayed as an entry
*
* @author David T. Smith
*/
publicinterfaceGetText{
/**
* Get the text to be displayed by the renderer
* @ return the text to be displayed
*/
publicString getText();
}
PainterStartup/com/javera/ui/GetTransferable.classpackage
com.javera.ui;
publicabstractinterface GetTransferable {
publicabstract java.awt.datatransfer.Transferable
getTransferable();
}
PainterStartup/com/javera/ui/GetTransferable.javaPainterStartu
p/com/javera/ui/GetTransferable.java// Copyright 2004, (c) Jave
ra Software, LLC. as an unpublished work. All rights reserved
world-wide.
// This is a proprietary trade secret of Javera Software LLC. Us
e restricted to licensing terms.
package com.javera.ui;
78. import java.awt.datatransfer.Transferable;
/**
* @author dtsmith
*/
publicinterfaceGetTransferable{
/**
* @return
*/
Transferable getTransferable();
}
PainterStartup/com/javera/ui/GetValue.classpackage
com.javera.ui;
publicabstractinterface GetValue {
publicabstract Object getValue();
}
PainterStartup/com/javera/ui/GetValue.javaPainterStartup/com/j
avera/ui/GetValue.java//Copyright 2004, (c) Javera Software, L
LC. as an unpublished work. All rights reserved world-wide.
//This is a proprietary trade secret of Javera Software LLC. Use
restricted to licensing terms.
package com.javera.ui;
/**
* GetValue interface provides access to the getValue() method
used
* to obtain a value associated with an object
*
79. * @author David T. Smith
*/
publicinterfaceGetValue{
/**
* Get the contained object
* @return the contained object
*/
publicObject getValue();
}
PainterStartup/com/javera/ui/GuiListDataListener.classpackage
com.javera.ui;
publicabstractinterface GuiListDataListener extends
javax.swing.event.ListDataListener {
}
PainterStartup/com/javera/ui/GuiListDataListener.javaPainterSt
artup/com/javera/ui/GuiListDataListener.java// Copyright 2004,
(c) Javera Software, LLC. as an unpublished work. All rights re
served world-wide.
// This is a proprietary trade secret of Javera Software LLC. Us
e restricted to licensing terms.
package com.javera.ui;
import javax.swing.event.ListDataListener;
/**
* @author dtsmith
*/
publicinterfaceGuiListDataListenerextendsListDataListener{
}
80. PainterStartup/com/javera/ui/IconManager.classpackage
com.javera.ui;
publicsynchronizedclass IconManager {
static ClassLoader classLoader;
static java.util.Hashtable iconTable;
static void <clinit>();
public void IconManager();
publicstatic javax.swing.ImageIcon getIcon(String);
publicstatic javax.swing.ImageIcon getImageIcon(String);
}
PainterStartup/com/javera/ui/IconManager.javaPainterStartup/c
om/javera/ui/IconManager.java//Copyright 2004, (c) Javera Soft
ware, LLC. as an unpublished work. All rights reserved world-
wide.
//This is a proprietary trade secret of Javera Software LLC. Use
restricted to licensing terms.
package com.javera.ui;
import java.net.*;
import java.util.Hashtable;
import javax.swing.ImageIcon;
/**
* IconManager provides a convenience class to load icons.
*
* @author David T. Smith
*/
publicclassIconManager{
staticClassLoader classLoader =IconManager.class.getClassLoa
der();
staticHashtable iconTable =newHashtable();
84. }
PainterStartup/com/javera/ui/layout/JvBoxLayout.classpackage
com.javera.ui.layout;
publicsynchronizedclass JvBoxLayout implements
java.awt.LayoutManager2, com.javera.ui.LayoutPrintLayout,
java.io.Serializable {
publicstaticfinal int X_AXIS = 0;
publicstaticfinal int Y_AXIS = 1;
private int axis;
private int gap;
private int topMargin;
private int bottomMargin;
private int leftMargin;
private int rightMargin;
private java.util.Map weightMap;
public void JvBoxLayout(int);
public void JvBoxLayout(int, int, int, int, int, int);
public int getGap();
public void setGap(int);
public int getTopMargin();
public void setTopMargin(int);
public int getLeftMargin();
public void setLeftMargin(int);
public int getBottomMargin();
public void setBottomMargin(int);
public int getRightMargin();
public void setRightMargin(int);
public void addLayoutComponent(java.awt.Component,
Object);
public java.awt.Dimension
maximumLayoutSize(java.awt.Container);
public float getLayoutAlignmentX(java.awt.Container);
public float getLayoutAlignmentY(java.awt.Container);
public void invalidateLayout(java.awt.Container);
85. public void addLayoutComponent(String,
java.awt.Component);
public void removeLayoutComponent(java.awt.Component);
public java.awt.Dimension
minimumLayoutSize(java.awt.Container);
public java.awt.Dimension
preferredLayoutSize(java.awt.Container);
public void layoutContainer(java.awt.Container);
publicstatic java.awt.Component createFiller(int, int);
public int layoutPrint(java.awt.Container, int);
}
PainterStartup/com/javera/ui/layout/JvBoxLayout.javaPainterSt
artup/com/javera/ui/layout/JvBoxLayout.java//Copyright 2004, (
c) Javera Software, LLC. as an unpublished work. All rights res
erved world-wide.
//This is a proprietary trade secret of Javera Software LLC. Use
restricted to licensing terms.
package com.javera.ui.layout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager2;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.accessibility.Accessible;
import com.javera.ui.LayoutPrintLayout;
import com.javera.ui.LayoutPrint;
86. //import com.javera.ui.panel.JvPanel;
/**
* A Javera box layout arranges components in a vertical or hori
zontal format.
* For vertical format all components are resized to have the sa
me width of
* the container, but have a height that is in proportion to their a
ssigned
* weights and such that the total height of all compoenents fills
the height
* of the container. Likewise a horizontal format will resize co
mponents to
* have the same width as the container and a height that is in pr
oportion to
* the assigned weights. If a component has an assigned weight
of 0 then that
* components is sized according to its preferred size.
*
* Weights are assigned using a Double as the second argument
to the
* containers add method. A null second argument will be inter
preted as a
* zero weight assignement.
*
* A Javera box layout is similar in function to a Box layout exc
ept that the
* assigned weights, not glue or preferred sizes are used to distr
ibute space
* over the row or column. Javera box layout also provides gap
* separation and margins.
*
* @author David T. Smith
*/
publicclassJvBoxLayoutimplementsLayoutManager2,LayoutPrin
tLayout,Serializable{
87. /**
* Horizontal axis orientation
*/
publicfinalstaticint X_AXIS =0;
/**
* Vertical axis orientation
*/
publicfinalstaticint Y_AXIS =1;
/**
* The axis orientation of the weighted layout.
*/
privateint axis;
/**
* The weighted layout manager allows a seperation of compo
nents with
* gaps. The gap will specify the space between components.
*
* @serial
* @see getGap
* @see setGap
*/
privateint gap;
/**
* The weighted layout manager allows specification of a top
margin to be
* reserved above laidout components.
*
* @serial
* @see getTopMargin
* @see setTopMargin
*/
88. privateint topMargin;
/**
* The command button layout manager allows specification
of a bottom
* margin to be reserved below laidout components.
*
* @serial
* @see getBottomMargin
* @see setBottomMargin
*/
privateint bottomMargin;
/**
* The weighted layout manager allows specification of a left
margin to be
* reserved to the left of the leftmost component.
*
* @serial
* @see getLeftMargin
* @see setLeftMargin
*/
privateint leftMargin;
/**
* The weighted layout manager allows specification of a rig
ht margin to
* be reserved to the right of the rightmost component.
*
* @serial
* @see getRightMargin
* @see setRightMargin
*/
privateint rightMargin;
/**
89. * A Map of each component's weight, keyed on the compone
nt
* objects themselves.
*/
privateMap weightMap =newHashMap();
/**
* Constructs a new Weighted Layout with specified axis, a d
efault 5 pixel
* gap, and a 5 pixel margins.
*
* @param axis X_AXIS or Y_AXIS
*/
publicJvBoxLayout(int axis){
this(axis,5,5,5,5,5);
}
/**
* Constructs a new Weighted Layout with specified axis, gap
, and margins.
*
* @param axis X_AXIS or Y_AXIS
* @param gap the gap between components.
* @param topMargin the top margin.
* @param leftMargin the left margin.
* @param bottomMargin the bottom margin.
* @param rightMargin the right margin.
*/
publicJvBoxLayout(
int axis,
int gap,
int topMargin,
int leftMargin,
int bottomMargin,
int rightMargin){
this.axis = axis;
90. this.gap = gap;
this.topMargin = topMargin;
this.leftMargin = leftMargin;
this.bottomMargin = bottomMargin;
this.rightMargin = rightMargin;
}
/**
* Gets the gap between components.
*
* @return the gap between components.
*/
publicint getGap(){
return gap;
}
/**
* Sets the gap between components.
*
* @param gap the gap between components
*/
publicvoid setGap(int gap){
this.gap = gap;
}
/**
* Gets the top margin to be reserved above all components.
*
* @return the top margin.
*/
publicint getTopMargin(){
return topMargin;
}
/**
* Sets the top margin to be reserve above components.
91. *
* @param topMargin the top margin.
*/
publicvoid setTopMargin(int topMargin){
this.topMargin = topMargin;
}
/**
* Gets the left margin to be reserved to the left of the
* leftmost component.
*
* @return the left margin.
*/
publicint getLeftMargin(){
return leftMargin;
}
/**
* Sets the left margin to be reserved to the left of the
* leftmost component.
*
* @param leftMargin the left margin.
*/
publicvoid setLeftMargin(int leftMargin){
this.leftMargin = leftMargin;
}
/**
* Gets the bottom margin to be reserved below all componen
ts.
*
* @return the bottom margin.
*/
publicint getBottomMargin(){
return bottomMargin;
}
92. /**
* Sets the bottom margin to be reserve below components.
*
* @param bottomMargin the bottom margin.
*/
publicvoid setBottomMargin(int bottomMargin){
this.bottomMargin = bottomMargin;
}
/**
* Gets the right margin to be reserved to the right of the
* rightmost component.
*
* @return the right margin.
*/
COSC 210 - Object Oriented Programming
Assignment 7
Due: Nov 18th
The objectives of this assignment are to:
1) Gain further understanding and experience with inheritance.
2) Gain understanding and experience with polymorphism.
3) Gain further understanding and experience with interfaces.
4) Gain understanding and experience with low level graphics.
5) Modify an existing program to meet new requirements
applying concepts of objectives 1 through 4.
6) Gain experience with medium-size Java program.
7) Continue to practice good programming techniques.
93. AFTER YOU HAVE COMPLETED, create a zip file named
[your name]Assignment7.zip containing your entire project.
Upload the .zip file to Moodle. Printout all source files you
created or modified. Include a screen shot of the editor with
boxes, ellipses, lines and images shown in the editor. Turn-in
all printouts.
COSC 210 – Fundamentals of Computer Science
Assignment 7 Problem Statement
Updated
On the tomcat drive in folder cosc210 you will find file named
PainterStartup.zip. This file contains the source code for the
start of a Painter program. In its current state, Painter can
create boxes and text objects at given locations. Both boxes
and text objects can be repositioned and resized using a mouse.
The task is to add to the program the implementation for an
ellipse, line, image, and group objects.
Instructions:
1) Add an ellipse object. An ellipse is very similar in
implementation as the box, except it renders an oval instead of a
rectangle. The ellipse can be repositioned by dragging the
object to a new location. The ellipse can be resized by first
clicking over the ellipse to display grab handles and then
dragging a grab handle to a new position. The grab handles are
to be rendered at the same positions as the box. Likewise,
clicking anywhere in the smallest rectangle that encloses the
ellipse performs selection.
2) Add a Line object. A Line is to be created by selecting a
Line tool and then click and drag over the canvas. The line is
rendered from the point of the initial click to the mouse pointer.
On releasing the mouse the construction of the line object is
completed. Have the Line object inherit from
94. PtrDrawAbstractAreaObject. Thus it will have only two grab
handles.
A Line is selected by clicking anywhere over the line. Right
now if you click anywhere in the rectangular region hold the
line, then the line is selected. To accomplish this task,
override the isOver method in PtrDrawAbstractAreaObject.
Given below is a partial solution to determine if a mouse click
position (the x and y parameters to the isOver method) is over a
line:
double ratio = (double) getWidth() / (double) getHeight();
if (Math.abs((x - getX()) * ratio) - (y - getY()) <= 1) {
return true;
}
You need to modify this code when the y to x ratio is less than -
1 or greater than 1. (Hint: Inverse the roles of width and
height, and the roles of x and y)
3) Add an Image object. An Image object is created by
selecting an Image tool and then clicking anywhere on the
canvas. On clicking the canvas, a File Selection Dialog should
be displayed. The dialog prompts for selection of .gif and .jpg
files. On selecting a .gif or .jpg file and clicking “Open”, an
Image object that renders the image of the selected file is
created at the click position. Image selection and drag
behaviors are the same as a Box object. The image object
additionally renders lines at the edges of the image (as done in
Box).
95. The code for displaying a File Selection Dialog is:
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileFilter(new FileFilter() {
public boolean accept(File f) {
return f.isDirectory() ||
f.getName().toLowerCase().endsWith(".jpg")
|| f.getName().toLowerCase().endsWith(".gif");
}
public String getDescription() {
return "JPG & GIF Images";
}
});
if (fileChooser.showOpenDialog(editor) ==
JFileChooser.APPROVE_OPTION) {
ImageIcon image = new
ImageIcon(fileChooser.getSelectedFile().getAbsolutePath());
/* you will need to do stuff with your image here
*/
/* note the Graphics object has a method drawImage() */
96. }
Make sure to import FileFilter from the javax.swing.filechooser.
The above code is added to the PtrDrawImageTool
4) Add a group object. A group object represents a set of
objects that have been grouped together. A partial
implementation is provided. Your task is to fix the rendering.
The group object should draw each of the objects in the
groupedObjects list.
Before drawing any object your will need to create a new
graphics object that is transposed to the dimensions if the group
object itself. To do this use:
Graphics2D g2 = (Graphics2D) g.create(getX(), getY(),
getWidth(),
getHeight());
After drawing each of the objects in groupedObjects list, release
the resources used by the created graphics object by calling
dispose:
g2.dispose();
One more item, after creating the new graphics context and
before drawing each of the objects in the group, use scale as
follows:
g2.scale(getXScale(), getYScale());
This will insure that all objects get rendered as at the right scale
when the group object itself is resized.
5) Have the box, ellipse, line, and image implement the
Lineable and Colorable interface. Create instance variables as
97. needed to hold the values of the parameters. Before doing any
rendering of lines (e.g., any g.drawXXXX method) create a new
graphics context as follows:
Graphics2D g2 = (Graphics2D) g.create();
Then set the line width by:
g2.setStroke(new BasicStroke(lineWidth));
Also set the color to the lineColor:
g2.setColor(lineColor);
Use g2 to do the rendering of the lines. After all line rendering,
release the resources of the graphics context by calling
dispose();
In the corresponding tool object (e.g., PtrDrawBoxTool for
PtrDrawBox), after creating the draw object add the following
calls in the object:
box.setLineColor(editor.getLineColor());
box.setLineWidth(editor.getLineWidth());
6) Have the box and ellipse, line implement the Colorable
interface. Create instance variables as need to hold the value of
the parameter (color). Before doing any rendering of filled
areas (e.g., any g.fillXXXX method) set the graphics color to
the color instance variable:
g.setColor(color); // or use g2 if you have created a new
graphics context
In the corresponding tool object (e.g., PtrDrawBoxTool for
PtrDrawBox), after creating the draw object add the following
calls in the object:
98. box.setColor(editor.getColor());
Warning:
Your objects may not render correctly whenever they are
resized such that either the height or width is negative.
Bonus:
1) Bonus 5 points -The isInside method provides the
implementation for determining if the line is inside a
rectangular area as specified by the parameters. This code may
not work right if the ending point of the line is to the left or
above the starting point. Fix this to work in all cases for 3
bonus points.
2) Currently, if you click in the area where two objects overlap,
the object on the bottom is selected. Change this so that the top
object is selected. 3 bonus points.
3) On the Group object, clicking in anywhere in the bounding
rectangle will select the object. Change this so that a group is
only selected with clicking over an object in the group. 3 bonus
points
4) The south east grab handle processing is broken. Fix this to
behave as the other grab handles for 3 bonus points
5) Currently, if you drag the right hand side smaller than the
left (likewise the bottom smaller that the top) the objects may
not be displayed correctly (or even at all). Once in the bad
display state, clicking over the object no longer works. Second,
if you click in the region of overlapping object, the object on
the bottom gets selected. It should be the top object. Fix these
bugs. One possible solution is to add a normalizeRect method to
PtrDrawRect. This will adjust the x, y, width, and height
99. variables so that width and height are never negative. For
example if width is negative then change x to be the value of x
plus width and then change width to be the absolute value.
Place a call to this method in the corresponding setter methods
after updating the instance variables. (Note there may be
problems with the grab handles). 3 points bonus.