예제 #1
0
 public void setAxesLength(int newVal) {
   int lengthIncrease = newVal - axesLength;
   Line xAxis = cartesianPlane.getXAxis();
   Line yAxis = cartesianPlane.getYAxis();
   xAxis.setX(xAxis.getX() - lengthIncrease / 2);
   yAxis.setY(yAxis.getY() - lengthIncrease / 2);
   updateXOfLabel(xLabel, xLabel.getLocation().getX() + lengthIncrease / 2);
   updateYOfLabel(yLabel, yLabel.getLocation().getY() - lengthIncrease / 2);
   axesLength = newVal;
   xAxis.setWidth(axesLength);
   yAxis.setHeight(axesLength);
 }
예제 #2
0
 public void draw(Graphics g, Line aLine) {
   // Hover over drawLine in case you do not understand what it does
   g.drawLine(
       aLine.getX(),
       aLine.getY(),
       aLine.getX() + aLine.getWidth(),
       aLine.getY() + aLine.getHeight());
 }
 public void setAxesLength(int anAxesLength) {
   axesLength = anAxesLength;
   xAxis.setWidth(axesLength);
   yAxis.setHeight(axesLength);
   xAxis.setX(toXAxisX());
   xAxis.setY(toXAxisY());
   yAxis.setX(toYAxisX());
   yAxis.setY(toYAxisY());
   xLabel.setX(toXLabelX());
   xLabel.setY(toXLabelY());
   yLabel.setX(toYLabelX());
   yLabel.setY(toYLabelY());
 }