Package de.tum.cit.ase.editor.tools
Class Square
java.lang.Object
de.tum.cit.ase.editor.input.ToolInputAdapter
de.tum.cit.ase.editor.tools.EditorTool
de.tum.cit.ase.editor.tools.Square
- All Implemented Interfaces:
com.badlogic.gdx.InputProcessor
,com.badlogic.gdx.utils.Pool.Poolable
,ShortcutAdapter
,Tool
Represents a square tool for drawing squares on a canvas.
-
Field Summary
Fields inherited from class de.tum.cit.ase.editor.tools.EditorTool
bresenham2, canvas, lastGridPosition, lastPosition
Fields inherited from interface de.tum.cit.ase.editor.input.ShortcutAdapter
pressedKeys
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer) Draws using the provided ShapeRenderer.protected void
markTile
(com.badlogic.gdx.math.GridPoint2 gridPoint) Marks a tile on the grid based on the given grid point.void
reset()
Resets the state of the tool.boolean
touchDown
(int screenX, int screenY, int pointer, int button) Handles the touch down event in the editor.boolean
touchDragged
(int screenX, int screenY, int pointer) Handles the touch dragged event in the editor.boolean
touchUp
(int screenX, int screenY, int pointer, int button) void
validate()
Validates the current state of the tool.Methods inherited from class de.tum.cit.ase.editor.tools.EditorTool
getGrid, getInstance, getLine, getStraightLineCoordinates, isStraightLine, projectGridPointToWorld, projectGridPointToWorld
Methods inherited from class de.tum.cit.ase.editor.input.ToolInputAdapter
keyDown, keyTyped, keyUp, mouseMoved, scrolled, touchCancelled
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.tum.cit.ase.editor.input.ShortcutAdapter
addKey, isShortcut, isShortcut, isShortcut, removeKey
-
Constructor Details
-
Square
public Square()
-
-
Method Details
-
draw
public void draw(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer) Description copied from interface:Tool
Draws using the provided ShapeRenderer.- Specified by:
draw
in interfaceTool
- Overrides:
draw
in classEditorTool
- Parameters:
shapeRenderer
- the ShapeRenderer object to use for drawing
-
validate
public void validate()Description copied from interface:Tool
Validates the current state of the tool. This method is called internally to ensure the tool is in a valid state. It performs necessary validations and updates to the tool's internal state.- Specified by:
validate
in interfaceTool
- Overrides:
validate
in classEditorTool
-
touchDown
public boolean touchDown(int screenX, int screenY, int pointer, int button) Description copied from class:EditorTool
Handles the touch down event in the editor.- Specified by:
touchDown
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
touchDown
in classEditorTool
- Parameters:
screenX
- The x coordinate of the touch positionscreenY
- The y coordinate of the touch positionpointer
- The pointer for the eventbutton
- The button that was pressed- Returns:
true
if the touch event is handled,false
otherwise
-
markTile
Description copied from class:EditorTool
Marks a tile on the grid based on the given grid point.- Specified by:
markTile
in classEditorTool
- Parameters:
gridPoint
- the grid point representing the tile to be marked- Throws:
InvalidGridCellException
- if the grid point is invalid
-
touchUp
public boolean touchUp(int screenX, int screenY, int pointer, int button) - Specified by:
touchUp
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
touchUp
in classEditorTool
-
touchDragged
public boolean touchDragged(int screenX, int screenY, int pointer) Description copied from class:EditorTool
Handles the touch dragged event in the editor.- Specified by:
touchDragged
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
touchDragged
in classEditorTool
- Parameters:
screenX
- The x coordinate of the touch positionscreenY
- The y coordinate of the touch positionpointer
- The pointer for the event- Returns:
true
if the touch event is handled,false
otherwise
-
reset
public void reset()Description copied from class:EditorTool
Resets the state of the tool.This method is responsible for resetting the tool to its initial state by setting the
canvas
field tonull
, and clearing thelastPosition
andlastGridPosition
fields.- Specified by:
reset
in interfacecom.badlogic.gdx.utils.Pool.Poolable
- Overrides:
reset
in classEditorTool
-