Package net.sf.fysix.leveleditor.tool.level.subtool.select

Examples of net.sf.fysix.leveleditor.tool.level.subtool.select.SelectMapObject


      break;
    case MODE_SEL_AREA:
    case MODE_SEL_SINGLE:
      if(currentMode == MODE_SEL_AREA && dragButton == MouseEvent.NOBUTTON && e.getButton() == MouseEvent.BUTTON1){
            if(selMO == null){
              selMO = new SelectMapObject();
              refEditor.addMapObject(selMO);
            }
              selMO.setStartPos(pos);
              selMO.setEndPos(pos);
            dragButton = MouseEvent.BUTTON1;
View Full Code Here


              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){
View Full Code Here

    } else if (source.equals(btnShapeRotate)) {
      List<IMapObject> mapobjs = refEditor.getIMapObjects();
      WorldPos anchorPos = new WorldPos(0,0);
      for (IMapObject mo : Collections.unmodifiableCollection(mapobjs)){
        if(mo instanceof SelectMapObject){
          SelectMapObject refSMO = (SelectMapObject)mo;
          if(refSMO.getAnchorPos() != null){
            anchorPos.setPosition(refSMO.getAnchorPos().getX(), refSMO.getAnchorPos().getY());
            break; // Abort for-loop...
          }
        }
      }
      for (IMapObject mo : Collections.unmodifiableCollection(mapobjs)){
View Full Code Here

              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());
            }
          }
        }
            break;
        }
View Full Code Here

        } else if (source.equals(btnRotate)) {
          List<IMapObject> mapobjs = refEditor.getIMapObjects();
          WorldPos anchorPos = new WorldPos(0,0);
          for (IMapObject mo : Collections.unmodifiableCollection(mapobjs)){
            if(mo instanceof SelectMapObject){
              SelectMapObject refSMO = (SelectMapObject)mo;
              if(refSMO.getAnchorPos() != null){
                anchorPos.setPosition(refSMO.getAnchorPos().getX(), refSMO.getAnchorPos().getY());
                break; // Abort for-loop...
              }
            }
          }
          for (IMapObject mo : Collections.unmodifiableCollection(mapobjs)){
View Full Code Here

TOP

Related Classes of net.sf.fysix.leveleditor.tool.level.subtool.select.SelectMapObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.