| 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.Color; |
| 18 | import java.awt.Font; |
| 19 | import java.awt.Graphics2D; |
| 20 | |
| 21 | public class TextDrawingAction |
| 22 | extends AbstractGraphicsDrawingAction |
| 23 | { |
| 24 | public TextDrawingAction( int x, int y, String[] text, |
| 25 | Font font, Color penColor, |
| 26 | int height) |
| 27 | { |
| 28 | _x = x; |
| 29 | _y = y; |
| 30 | _text = text; |
| 31 | _font = font; |
| 32 | _penColor = penColor; |
| 33 | _height = height; |
| 34 | } |
| 35 | |
| 36 | @Override protected void preDraw(Graphics2D graf) |
| 37 | { |
| 38 | graf.setColor(_penColor); |
| 39 | graf.setFont(_font); |
| 40 | } |
| 41 | |
| 42 | @Override protected void draw(Graphics2D graf) |
| 43 | { |
| 44 | int y = _y; |
| 45 | for (int i = 0; i < _text.length; i++) |
| 46 | { |
| 47 | graf.drawString(_text[i], _x, y); |
| 48 | y += _height; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | final private int _x; |
| 53 | final private int _y; |
| 54 | final private String[] _text; |
| 55 | final private Font _font; |
| 56 | final private Color _penColor; |
| 57 | final private int _height; |
| 58 | } |