/
SelectField.java
58 lines (45 loc) · 1.39 KB
/
SelectField.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package jcan2;
import java.awt.Color;
import java.awt.Point;
import org.openstreetmap.gui.jmapviewer.Coordinate;
import org.openstreetmap.gui.jmapviewer.MapRectangleImpl;
/**
*
* @author Micha
*/
public class SelectField {
private Coordinate upperLeft;
private Coordinate lowerRight;
private boolean active = false;
private MapRectangleImpl rectangle;
public SelectField(){
//constructor
}
boolean isActive(){return active;}
Coordinate upperLeft(){return upperLeft;}
Coordinate lowerRight(){return lowerRight;}
void setFirstCorner(Coordinate corner){
upperLeft = corner;
}
void setSecondCorner(Coordinate corner){
lowerRight = corner;
enable();
}
void enable(){
BeMapEditor.mainWindow.getMap().removeMapRectangle(rectangle); //remove any existing
rectangle = new MapRectangleImpl(upperLeft,lowerRight);
rectangle.setBackColor(Color.blue);
BeMapEditor.mainWindow.getMap().addMapRectangle(rectangle);
rectangle.setVisible(true);
active = true;
}
void disable(){
BeMapEditor.mainWindow.getMap().removeMapRectangle(rectangle);
active = false;
}
}