-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/github/creme332/controller/canvas/transform/Rotator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.github.creme332.controller.canvas.transform; | ||
|
||
import java.awt.geom.Point2D; | ||
|
||
import com.github.creme332.model.AppState; | ||
import com.github.creme332.model.Mode; | ||
import com.github.creme332.model.ShapeWrapper; | ||
import com.github.creme332.view.Canvas; | ||
|
||
public class Rotator extends AbstractTransformer { | ||
|
||
public Rotator(AppState app, Canvas canvas) { | ||
super(app, canvas); | ||
} | ||
|
||
@Override | ||
public void handleShapeSelection(int shapeIndex) { | ||
// get copy of selected shape | ||
ShapeWrapper selectedWrapperCopy = canvasModel.getShapeManager().getShapes().get(shapeIndex); | ||
|
||
// TODO: Get rotation details | ||
|
||
// perform rotation | ||
selectedWrapperCopy.rotate(30, new Point2D.Double(0, 0)); | ||
|
||
// replace old shape with new one | ||
canvasModel.getShapeManager().editShape(shapeIndex, selectedWrapperCopy); | ||
|
||
// repaint canvas | ||
canvas.repaint(); | ||
} | ||
|
||
@Override | ||
public boolean shouldDraw() { | ||
return getCanvasMode() == Mode.ROTATE_ABOUT_POINT; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters