refSMO.moveShape(diff, pos);
//refSMO.setPosition();
}
}
if(mo instanceof SelectMapObject){
SelectMapObject refSMO = (SelectMapObject)mo;
if(refSMO.getAnchorPos() != null){
refSMO.getAnchorPos().setX(refSMO.getAnchorPos().getX()-diff.getX()+pos.getX());
refSMO.getAnchorPos().setY(refSMO.getAnchorPos().getY()-diff.getY()+pos.getY());
}
}
}
}
dragButton = MouseEvent.NOBUTTON;
// Reset state
if(oldMode != MODE_DRAW_NO && oldMode != currentMode && e != null){
currentMode = oldMode;
}
break;
case MODE_SEL_AREA:
case MODE_SEL_SINGLE:
//List<IMapObject> mapobjs;
WorldPos anchorPos = null;
mapobjs = refEditor.getIMapObjects();
// RIGHT CLICK => REMOVE ALL SELECTION!
if(e.getButton() == MouseEvent.BUTTON3){
for (IMapObject mo : Collections.unmodifiableCollection(mapobjs)){
if(mo instanceof ShapeMapObject){
ShapeMapObject refSMO = (ShapeMapObject)mo;
refSMO.setSelected(false);
}
}
if(selMO != null){
refEditor.delMapObject(selMO);
selMO = null;
}
}
if(currentMode == MODE_SEL_SINGLE){
mapobjs = refEditor.getIMapObjects();
for (IMapObject mo : Collections.unmodifiableCollection(mapobjs)){
if(mo instanceof ShapeMapObject){
ShapeMapObject refSMO = (ShapeMapObject)mo;
if(refSMO.isPointInShape(pos)){
refSMO.setSelected(!refSMO.isSelected());
}
if(refSMO.isSelected()){
if(anchorPos == null){
anchorPos = new WorldPos(10000,10000);
}
if(anchorPos.getX()>refSMO.getUpperLeft().getX()){
anchorPos.setX(refSMO.getUpperLeft().getX());
}
if(anchorPos.getY()>refSMO.getUpperLeft().getY()){
anchorPos.setY(refSMO.getUpperLeft().getY());
}
}
}
}
if(anchorPos == null){
if(selMO != null){
refEditor.delMapObject(selMO);
selMO = null;
}
} else {
if(selMO == null){
selMO = new SelectMapObject();
refEditor.addMapObject(selMO);
}
selMO.setStartPos(pos);
selMO.setEndPos(pos);
selMO.setAnchorPos(anchorPos);
}
} else {
if(dragButton == MouseEvent.BUTTON1){
mapobjs = refEditor.getIMapObjects();
for (IMapObject mo : Collections.unmodifiableCollection(mapobjs)){
if(mo instanceof ShapeMapObject){
ShapeMapObject refSMO = (ShapeMapObject)mo;
if( (refSMO.getUpperLeft().getX()>=selMO.getUpperLeft().getX() &&
refSMO.getUpperLeft().getX()<=pos.getX() &&
refSMO.getUpperLeft().getY()>=selMO.getUpperLeft().getY() &&
refSMO.getUpperLeft().getY()<=pos.getY() )
||
(refSMO.getLowerRight().getX()>=selMO.getUpperLeft().getX() &&
refSMO.getLowerRight().getX()<=pos.getX() &&
refSMO.getLowerRight().getY()>=selMO.getUpperLeft().getY() &&
refSMO.getLowerRight().getY()<=pos.getY() ) )
{
refSMO.setSelected(!refSMO.isSelected());
}
if(refSMO.isSelected()){
if(anchorPos == null){
anchorPos = new WorldPos(10000,10000);
}
if(anchorPos.getX()>refSMO.getUpperLeft().getX()){
anchorPos.setX(refSMO.getUpperLeft().getX());
}
if(anchorPos.getY()>refSMO.getUpperLeft().getY()){
anchorPos.setY(refSMO.getUpperLeft().getY());
}
}
}
}
if(anchorPos == null){