CartesianPanel.java is a widget for Cartesian systems. This class extend JPanel.
Default constructorPostcondition: I have been initialized:
lower-left == (-4.0, -4.0);
upper-right == (4.0, 4.0).
Explicit Point constructorReceive: lowerLeft, upperRight, two Point values.
Postcondition: I have been initialized:
lower-left == lowerLeft;
upper-right == upperRight.
Explicit coordinate constructorReceive: minX, minY, maxX, maxY, four double values.
Postcondition: I have been initialized:
lower-left == (minX, minY);
upper-right == (maxX, maxY).
Utility to initialize size-dependent attributesPrecondition: I have a height accessible via getHeight(), and a width accessible via getWidth().
Postcondition: My size-dependent attributes: myRows, myLastRow, myColumns, myColumnsPerX, myRowsPerY, xInterval, and yInterval have been initialized.
Map x-value to a grid columnReceive: x, a double
Return: the grid column corresponding to x.
Map y-value to a grid rowReceive: y, a double
Return: the grid row corresponding to y.
Get x-value corresponding to 1 grid columnReturn: the change in x per column.
Get y-value corresponding to 1 grid rowReturn: the change in y per row.
Minimum x-value accessorReturn: my minimum x-value
Minimum y-value accessorReturn: my minimum y-value
Maximum x-value accessorReturn: my maximum x-value
Maximum y-value accessorReturn: my maximum y-value
Mutator for axis visibilityReceive: flag, a boolean value
Postcondition: myAxisVisible == flag && my axis is visible iff myAxisVisible.
Accessor for axis visibilityReturn: myAxisVisible
Mutator for axis values using coordinatesReceive: minX, minY, maxX, maxY, all double values.
Postcondition: my axes and size-dependent variables and display have been updated according to the parameter values.
Mutator for axis values using PointsReceive: lowerLeft, upperRight, two Point values.
Postcondition: my axes and size-dependent variables and display have been updated according to the parameter values.
Method to draw my axesReceive: pen, a Graphics object.
Postcondition: I have been drawn, showing axes iff myAxisVisible.
Method to "clear" the grid of anything that has been drawn on me (except for my axes).Postcondition: I have just a set of axes showing.
Method to mutate my pen/drawing colorReceive: newColor, a Color value
Postcondition: myPenColor = newColor
Accessor to retrieve my current pen/drawing colorReturn: myPenColor
public final static int AXIS_MARGIN = 32rows/columns at edge of axispublic final static int AXIS_GAP = 50
rows/columns btwn axis markings
Rounding methodReceive: number, a double
Return: the nearest int to number.
Back to the package documentation index