Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / toolListeners / snapping / snappers / InsertPointSnapper.java @ 40558

History | View | Annotate | Download (3.1 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.project.documents.view.toolListeners.snapping.snappers;
25

    
26
import java.awt.geom.Point2D;
27

    
28
import org.gvsig.fmap.geom.Geometry;
29
import org.gvsig.fmap.mapcontrol.PrimitivesDrawer;
30
import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapperVectorial;
31
import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.impl.AbstractSnapper;
32
import org.gvsig.i18n.Messages;
33

    
34

    
35

    
36
/**
37
 * Insert point snapper.
38
 *
39
 * @author Vicente Caballero Navarro
40
 */
41
public class InsertPointSnapper extends AbstractSnapper
42
    implements ISnapperVectorial {
43
        /* (non-Javadoc)
44
     * @see com.iver.cit.gvsig.gui.cad.snapping.ISnapper#getSnapPoint(Point2D point,
45
     * IGeometry geom,double tolerance, Point2D lastPointEntered)
46
     */
47
    public Point2D getSnapPoint(Point2D point, Geometry geom,
48
        double tolerance, Point2D lastPointEntered) {
49
        Point2D resul = null;
50

    
51
        return resul;
52
    }
53

    
54
    /* (non-Javadoc)
55
     * @see com.iver.cit.gvsig.gui.cad.snapping.ISnapper#getToolTipText()
56
     */
57
    public String getToolTipText() {
58
        return Messages.getText("Insert_point");
59
    }
60

    
61
    /*
62
     * (non-Javadoc)
63
     * @see org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapper#draw(org.gvsig.fmap.mapcontrol.PrimitivesDrawer, java.awt.geom.Point2D)
64
     */
65
    public void draw(PrimitivesDrawer primitivesDrawer, Point2D pPixels) {
66
            primitivesDrawer.setColor(getColor());
67

    
68
        int half = getSizePixels() / 2;
69
        int x1 = (int) (pPixels.getX() - half);
70
        int x2 = (int) (pPixels.getX() + half);
71
        int x3 = (int) pPixels.getX();
72
        int y1 = (int) (pPixels.getY() - half);
73
        int y2 = (int) (pPixels.getY() + half);
74
        int y3 = (int) pPixels.getY();
75

    
76
        primitivesDrawer.drawLine(x1, y1, x3, y1);
77
        primitivesDrawer.drawLine(x1, y1, x1, y3);
78
        primitivesDrawer.drawLine(x1, y3, x3, y3);
79
        primitivesDrawer.drawLine(x3, y1, x3, y3);
80

    
81
        primitivesDrawer.drawLine(x3, y3, x2, y3);
82
        primitivesDrawer.drawLine(x3, y3, x3, y2);
83
        primitivesDrawer.drawLine(x3, y2, x2, y2);
84
        primitivesDrawer.drawLine(x2, y3, x2, y2);
85
    }
86
}