| 1 | // Copyright 2004-2007 Jean-Francois Poilpret |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package net.sourceforge.hiveboard.drawing; |
| 16 | |
| 17 | import java.awt.BasicStroke; |
| 18 | import java.awt.Color; |
| 19 | import java.awt.Graphics2D; |
| 20 | |
| 21 | import org.jdesktop.application.ResourceMap; |
| 22 | |
| 23 | public class EraserTool extends AbstractPenFreeTool |
| 24 | { |
| 25 | @Override protected void initResources(ResourceMap map) |
| 26 | { |
| 27 | super.initResources(map); |
| 28 | //#### Later should define a custom Stroke according to the cursor shape |
| 29 | _stroke = new BasicStroke(DEFAULT_SIZE, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); |
| 30 | } |
| 31 | |
| 32 | @Override protected void preDraw(Graphics2D graf) |
| 33 | { |
| 34 | graf.setColor(BOARD_COLOR); |
| 35 | graf.setStroke(_stroke); |
| 36 | } |
| 37 | |
| 38 | @Override protected DrawingAction createAction(int[] x, int[] y) |
| 39 | { |
| 40 | return new PenFreeDrawingAction(x, y, BOARD_COLOR, _stroke); |
| 41 | } |
| 42 | |
| 43 | static final private Color BOARD_COLOR = Color.WHITE; |
| 44 | static final private float DEFAULT_SIZE = 25.0f; |
| 45 | private BasicStroke _stroke; |
| 46 | } |