gvsig-vectorediting / org.gvsig.vectorediting / trunk / org.gvsig.vectorediting / org.gvsig.vectorediting.lib / org.gvsig.vectorediting.lib.impl / src / main / java / org / gvsig / vectorediting / lib / impl / DefaultEditingBehavior.java @ 17
History | View | Annotate | Download (3.11 KB)
1 |
/*
|
---|---|
2 |
* Copyright 2014 DiSiD Technologies S.L.L. All rights reserved.
|
3 |
*
|
4 |
* Project : DiSiD org.gvsig.vectorediting.lib.impl
|
5 |
* SVN Id : $Id$
|
6 |
*/
|
7 |
package org.gvsig.vectorediting.lib.impl; |
8 |
|
9 |
import java.awt.Color; |
10 |
import java.awt.Graphics; |
11 |
import java.awt.Image; |
12 |
import java.awt.event.MouseEvent; |
13 |
import java.awt.image.BufferedImage; |
14 |
|
15 |
import org.gvsig.fmap.mapcontrol.MapControl; |
16 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
17 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
18 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener; |
19 |
import org.gvsig.tools.dynobject.DynObject; |
20 |
import org.gvsig.tools.service.ServiceException; |
21 |
import org.gvsig.vectorediting.lib.api.EditingBehavior; |
22 |
import org.gvsig.vectorediting.lib.api.EditingLocator; |
23 |
import org.gvsig.vectorediting.lib.api.EditingManager; |
24 |
import org.gvsig.vectorediting.lib.api.EditingService; |
25 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameter; |
26 |
|
27 |
public class DefaultEditingBehavior extends Behavior implements EditingBehavior { |
28 |
|
29 |
private MapControl mapControl;
|
30 |
private EditingService activatedTool;
|
31 |
|
32 |
private static final Image imageCursor = new BufferedImage(32, 32, |
33 |
BufferedImage.TYPE_INT_ARGB);
|
34 |
static {
|
35 |
Graphics g = imageCursor.getGraphics();
|
36 |
int size1 = 15; |
37 |
int x = 16; |
38 |
int y = 16; |
39 |
g.setColor(Color.MAGENTA);
|
40 |
g.drawLine((x - size1), (y), (x + size1), (y)); |
41 |
g.drawLine((x), (y - size1), (x), (y + size1)); |
42 |
// g.setColor(Color.MAGENTA);
|
43 |
g.drawRect((x - 6), (y - 6), 12, 12); |
44 |
g.drawRect((x - 3), (y - 3), 6, 6); |
45 |
} |
46 |
|
47 |
public DefaultEditingBehavior(MapControl mapControl) {
|
48 |
// TODO Auto-generated constructor stub
|
49 |
if (mapControl != null) { |
50 |
this.mapControl = mapControl;
|
51 |
} |
52 |
} |
53 |
|
54 |
public void activateTool(String name) { |
55 |
// TODO Auto-generated method stub
|
56 |
|
57 |
EditingManager manager = EditingLocator.getManager(); |
58 |
|
59 |
DynObject params; |
60 |
try {
|
61 |
params = manager.createServiceParameters(name); |
62 |
EditingService tool = (EditingService) manager.getService(params); |
63 |
if(tool != null){ |
64 |
this.activatedTool = tool;
|
65 |
EditingServiceParameter param = activatedTool.getNextParameter(); |
66 |
|
67 |
} |
68 |
} |
69 |
catch (ServiceException e) {
|
70 |
// TODO Auto-generated catch block
|
71 |
e.printStackTrace(); |
72 |
} |
73 |
|
74 |
} |
75 |
|
76 |
@Override
|
77 |
public ToolListener getListener() {
|
78 |
return new ToolListener() { |
79 |
|
80 |
/**
|
81 |
*
|
82 |
*/
|
83 |
public Image getImageCursor() { |
84 |
return imageCursor;
|
85 |
} |
86 |
|
87 |
/**
|
88 |
*
|
89 |
*/
|
90 |
public boolean cancelDrawing() { |
91 |
return false; |
92 |
} |
93 |
}; |
94 |
} |
95 |
|
96 |
public void mouseClicked(MouseEvent e) throws BehaviorException { |
97 |
// TODO Auto-generated method stub
|
98 |
} |
99 |
|
100 |
public void mouseEntered(MouseEvent e) throws BehaviorException { |
101 |
// TODO Auto-generated method stub
|
102 |
} |
103 |
|
104 |
public void mouseMoved(MouseEvent e) throws BehaviorException { |
105 |
// TODO Auto-generated method stub
|
106 |
} |
107 |
|
108 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
109 |
// TODO Auto-generated method stub
|
110 |
} |
111 |
|
112 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
113 |
// TODO Auto-generated method stub
|
114 |
} |
115 |
|
116 |
} |