|
001 packagepackage is used to name the directory or folder a class is in scg.ch02;
002
003 importimport means to make the classes and/or packages available in this program fang2.attributes.Location2D;
004 importimport means to make the classes and/or packages available in this program fang2.attributes.Vector2D;
005 importimport means to make the classes and/or packages available in this program fang2.sprites.LineSprite;
006 importimport means to make the classes and/or packages available in this program fang2.transformers.MouseClickTransformer;
007 importimport means to make the classes and/or packages available in this program fang2.transformers.MouseClickTransformerListener;
008 importimport means to make the classes and/or packages available in this program fang2.transformers.MouseMovementTransformer;
009 importimport means to make the classes and/or packages available in this program fang2.transformers.MouseMovementTransformerListener;
010
011 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects MouseTrackingLine
012 extendsextends means to customize or extend the functionality of a class LineSprite
013 implementsimplements means providing method bodies for the methods declared in the corresponding interface MouseMovementTransformerListener,
014 MouseClickTransformerListener {open braces start code blocks and must be matched with a close brace
015 /** truetrue is the boolean value that is the opposite of false during the frame after moving goes to falsefalse is a value for the boolean type and means not true */
016 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false justClicked;
017
018 /** is thisthis means the current object (the implicit parameter) line currently tracking? True ifif executes the next statement only if the condition in parenthesis evaluates to true yes, falsefalse is a value for the boolean type and means not true otherwise */
019 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false moving;
020
021 /** which player's input is being tracked by thisthis means the current object (the implicit parameter) line? */
022 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer playerId;
023
024 /**
025 * Create a newnew is used to create objects by calling the constructor {open braces start code blocks and must be matched with a close brace@link MouseTrackingLine}close braces end code blocks and must match an earlier open brace with its anchor at the given
026 * point. The newnew is used to create objects by calling the constructor line is created in the moving state. The line will
027 * track the defaultdefault is what is executed when no cases are matched player's mouse.
028 *
029 * @paramthis is the Javadoc tag for documenting the purpose of parameters x x-coordinate of the anchor point
030 * @paramthis is the Javadoc tag for documenting the purpose of parameters y y-coordinate of the anchor point
031 */
032 publicpublic is used to indicate unrestricted access (any other class can have access) MouseTrackingLine(doubledouble is the type for numbers that can contain decimal fractions x, doubledouble is the type for numbers that can contain decimal fractions y) {open braces start code blocks and must be matched with a close brace
033 thisthis means the current object (the implicit parameter)(newnew is used to create objects by calling the constructor Location2D(x, y));
034 }close braces end code blocks and must match an earlier open brace
035
036 /**
037 * Create a newnew is used to create objects by calling the constructor {open braces start code blocks and must be matched with a close brace@link MouseTrackingLine}close braces end code blocks and must match an earlier open brace with the given anchor and
038 * moving state. Line will track the defaultdefault is what is executed when no cases are matched player's mouse.
039 *
040 * @paramthis is the Javadoc tag for documenting the purpose of parameters x x-coordinate of the anchor point
041 * @paramthis is the Javadoc tag for documenting the purpose of parameters y y-coordinate of the anchor point
042 * @paramthis is the Javadoc tag for documenting the purpose of parameters moving truetrue is the boolean value that is the opposite of false ifif executes the next statement only if the condition in parenthesis evaluates to true line should track mouse now, falsefalse is a value for the boolean type and means not true
043 * otherwise.
044 */
045 publicpublic is used to indicate unrestricted access (any other class can have access) MouseTrackingLine(doubledouble is the type for numbers that can contain decimal fractions x, doubledouble is the type for numbers that can contain decimal fractions y, booleanboolean is a type that is either true or false moving) {open braces start code blocks and must be matched with a close brace
046 thisthis means the current object (the implicit parameter)(newnew is used to create objects by calling the constructor Location2D(x, y), moving);
047 }close braces end code blocks and must match an earlier open brace
048 /**
049 * Create a newnew is used to create objects by calling the constructor {open braces start code blocks and must be matched with a close brace@link MouseTrackingLine}close braces end code blocks and must match an earlier open brace with its beginning anchor at
050 * the given point and in the given moving state.
051 *
052 * @paramthis is the Javadoc tag for documenting the purpose of parameters x x-coordinate of the anchor point
053 * @paramthis is the Javadoc tag for documenting the purpose of parameters y y-coordinate of the anchor point
054 * @paramthis is the Javadoc tag for documenting the purpose of parameters moving truetrue is the boolean value that is the opposite of false ifif executes the next statement only if the condition in parenthesis evaluates to true line should track mouse now, falsefalse is a value for the boolean type and means not true
055 * otherwise.
056 * @paramthis is the Javadoc tag for documenting the purpose of parameters playerId identifier of player whose mouse should be
057 * tracked
058 */
059 publicpublic is used to indicate unrestricted access (any other class can have access) MouseTrackingLine(doubledouble is the type for numbers that can contain decimal fractions x, doubledouble is the type for numbers that can contain decimal fractions y, booleanboolean is a type that is either true or false moving,
060 intint is the type for whole numbers and it is short for integer playerId) {open braces start code blocks and must be matched with a close brace
061 thisthis means the current object (the implicit parameter)(newnew is used to create objects by calling the constructor Location2D(x, y), moving, playerId);
062 }close braces end code blocks and must match an earlier open brace
063
064 /**
065 * Create a newnew is used to create objects by calling the constructor {open braces start code blocks and must be matched with a close brace@link MouseTrackingLine}close braces end code blocks and must match an earlier open brace with its anchor at the given
066 * point. The newnew is used to create objects by calling the constructor line is created in the moving state. The line will
067 * track the defaultdefault is what is executed when no cases are matched player's mouse.
068 *
069 * @paramthis is the Javadoc tag for documenting the purpose of parameters anchor the location (screen coordinates) where the
070 * beginning of the line should be anchored
071 */
072 publicpublic is used to indicate unrestricted access (any other class can have access) MouseTrackingLine(Location2D anchor) {open braces start code blocks and must be matched with a close brace
073 thisthis means the current object (the implicit parameter)(anchor, truetrue is the boolean value that is the opposite of false);
074 }close braces end code blocks and must match an earlier open brace
075
076 /**
077 * Create a newnew is used to create objects by calling the constructor {open braces start code blocks and must be matched with a close brace@link MouseTrackingLine}close braces end code blocks and must match an earlier open brace with the given anchor and
078 * moving state. Line will track the defaultdefault is what is executed when no cases are matched player's mouse.
079 *
080 * @paramthis is the Javadoc tag for documenting the purpose of parameters anchor screen location to anchor beginning of line.
081 * @paramthis is the Javadoc tag for documenting the purpose of parameters moving truetrue is the boolean value that is the opposite of false ifif executes the next statement only if the condition in parenthesis evaluates to true line should track mouse now, falsefalse is a value for the boolean type and means not true
082 * otherwise.
083 */
084 publicpublic is used to indicate unrestricted access (any other class can have access) MouseTrackingLine(Location2D anchor, booleanboolean is a type that is either true or false moving) {open braces start code blocks and must be matched with a close brace
085 thisthis means the current object (the implicit parameter)(anchor, moving, 0);
086 }close braces end code blocks and must match an earlier open brace
087
088 /**
089 * Create a newnew is used to create objects by calling the constructor {open braces start code blocks and must be matched with a close brace@link MouseTrackingLine}close braces end code blocks and must match an earlier open brace with its beginning anchor at
090 * the given point and in the given moving state.
091 *
092 * @paramthis is the Javadoc tag for documenting the purpose of parameters anchor screen location to anchor beginning of line.
093 * @paramthis is the Javadoc tag for documenting the purpose of parameters moving truetrue is the boolean value that is the opposite of false ifif executes the next statement only if the condition in parenthesis evaluates to true line should track mouse now, falsefalse is a value for the boolean type and means not true
094 * otherwise
095 * @paramthis is the Javadoc tag for documenting the purpose of parameters playerId identifier of player whose mouse should be
096 * tracked
097 */
098 publicpublic is used to indicate unrestricted access (any other class can have access) MouseTrackingLine(Location2D anchor, booleanboolean is a type that is either true or false moving,
099 intint is the type for whole numbers and it is short for integer playerId) {open braces start code blocks and must be matched with a close brace
100 super(anchor, anchor);
101 thisthis means the current object (the implicit parameter).moving =this assignment operator makes the left side equal to the right side moving;
102 thisthis means the current object (the implicit parameter).playerId =this assignment operator makes the left side equal to the right side playerId;
103 MouseMovementTransformer mmt =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor MouseMovementTransformer(
104 playerId);
105 mmt.add(thisthis means the current object (the implicit parameter));
106 MouseClickTransformer mct =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor MouseClickTransformer(playerId);
107 mct.add(thisthis means the current object (the implicit parameter));
108 }close braces end code blocks and must match an earlier open brace
109
110 /**
111 * Get the point which is anchored (the start of the line).
112 * @returnnull the anchored point of the line segment
113 */
114 publicpublic is used to indicate unrestricted access (any other class can have access) Location2D getAnchor() {open braces start code blocks and must be matched with a close brace
115 returnreturn means to provide the result of the method and/or cease execution of the method immediately getStart();
116 }close braces end code blocks and must match an earlier open brace
117
118 /**
119 * @returnnull the playerId
120 */
121 publicpublic is used to indicate unrestricted access (any other class can have access) intint is the type for whole numbers and it is short for integer getPlayerId() {open braces start code blocks and must be matched with a close brace
122 returnreturn means to provide the result of the method and/or cease execution of the method immediately playerId;
123 }close braces end code blocks and must match an earlier open brace
124
125 /**
126 * Get the vector represented by thisthis means the current object (the implicit parameter) line.
127 *
128 * @returnnull a vector going from start to end in screen coordinates.
129 */
130 publicpublic is used to indicate unrestricted access (any other class can have access) Vector2D getVector() {open braces start code blocks and must be matched with a close brace
131 returnreturn means to provide the result of the method and/or cease execution of the method immediately newnew is used to create objects by calling the constructor Vector2D(getStart(), getEnd());
132 }close braces end code blocks and must match an earlier open brace
133
134 /**
135 * Get and clear the justClicked flag.
136 * @returnnull truetrue is the boolean value that is the opposite of false ifif executes the next statement only if the condition in parenthesis evaluates to true the line was just clicked, falsefalse is a value for the boolean type and means not true otherwise.
137 */
138 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false isJustClicked() {open braces start code blocks and must be matched with a close brace
139 booleanboolean is a type that is either true or false is =this assignment operator makes the left side equal to the right side justClicked;
140 justClicked =this assignment operator makes the left side equal to the right side falsefalse is a value for the boolean type and means not true;
141 returnreturn means to provide the result of the method and/or cease execution of the method immediately is;
142 }close braces end code blocks and must match an earlier open brace
143 /**
144 * @returnnull the moving
145 */
146 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false isMoving() {open braces start code blocks and must be matched with a close brace
147 returnreturn means to provide the result of the method and/or cease execution of the method immediately moving;
148 }close braces end code blocks and must match an earlier open brace
149
150 /**
151 * Respond to any mouse button being clicked. Just change the moving state to not moving.
152 */
153 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value mouseClickedAt(Location2D location, intint is the type for whole numbers and it is short for integer mouseButton) {open braces start code blocks and must be matched with a close brace
154 justClicked =this assignment operator makes the left side equal to the right side moving;
155 moving =this assignment operator makes the left side equal to the right side falsefalse is a value for the boolean type and means not true;
156 }close braces end code blocks and must match an earlier open brace
157
158 /**
159 * Listener method called by the mouse movement transformer.
160 */
161 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value mouseMovedTo(Location2D location) {open braces start code blocks and must be matched with a close brace
162 ifif executes the next statement only if the condition in parenthesis evaluates to true (moving) {open braces start code blocks and must be matched with a close brace
163 thisthis means the current object (the implicit parameter).setEnd(location);
164 }close braces end code blocks and must match an earlier open brace
165 }close braces end code blocks and must match an earlier open brace
166
167 /**
168 * @paramthis is the Javadoc tag for documenting the purpose of parameters moving the moving to set
169 */
170 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setMoving(booleanboolean is a type that is either true or false moving) {open braces start code blocks and must be matched with a close brace
171 thisthis means the current object (the implicit parameter).moving =this assignment operator makes the left side equal to the right side moving;
172 }close braces end code blocks and must match an earlier open brace
173
174 /**
175 * @paramthis is the Javadoc tag for documenting the purpose of parameters playerId the playerId to set
176 */
177 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setPlayerId(intint is the type for whole numbers and it is short for integer playerId) {open braces start code blocks and must be matched with a close brace
178 thisthis means the current object (the implicit parameter).playerId =this assignment operator makes the left side equal to the right side playerId;
179 }close braces end code blocks and must match an earlier open brace
180 }close braces end code blocks and must match an earlier open brace
181
182 //Uploaded on Mon Mar 29 21:38:32 EDT 2010
|