// -*- tab-width: 4; -*- %{ // // Vicente Caballero Navarro %} %start Selection::FirstPoint %class SelectionCADTool %package com.iver.cit.gvsig.gui.cad.tools.smc %import com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool %import com.iver.cit.gvsig.fmap.layers.FBitSet %import java.awt.event.InputEvent %import com.iver.andami.PluginServices %map Selection %% // A task begins life in suspended animation. FirstPoint Entry { setQuestion( PluginServices.getText(this,"insert_point_selection")); setDescription(new String[]{"cancel"}); } Exit{ } { addPoint( pointX:double,pointY:double,event:InputEvent) [ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.SecondPoint")] SecondPoint{ setQuestion(PluginServices.getText(this,"insert_second_point")); setDescription(new String[]{"cancel"}); addPoint( pointX,pointY,event); } addPoint( pointX:double,pointY:double,event:InputEvent) [ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")] WithSelectedFeatures { setQuestion(PluginServices.getText(this,"select_handlers")); setDescription(new String[]{"cancel"}); addPoint( pointX,pointY,event); end(); } } SecondPoint{ // Si hemos conseguido seleccionar algo addPoint( pointX:double,pointY:double,event:InputEvent) [ctxt.selectWithSecondPoint(pointX,pointY, event) > 0] WithSelectedFeatures { setQuestion(PluginServices.getText(this,"select_handlers")); setDescription(new String[]{"cancel"}); addPoint( pointX,pointY,event); end(); } // Si no lo hemos conseguido addPoint( pointX:double,pointY:double,event:InputEvent) FirstPoint { setQuestion(PluginServices.getText(this,"insert_point_selection")); setDescription(new String[]{"cancel"}); addPoint(pointX,pointY,event); } addOption(s:String) FirstPoint{ setQuestion(PluginServices.getText(this,"insert_point_selection")); setDescription(new String[]{"cancel"}); setType(s); } } WithSelectedFeatures{ // Si hemos pinchado encima de un handler addPoint( pointX:double,pointY:double,event:InputEvent) [ctxt.selectHandlers(pointX, pointY, event)>0] WithHandlers { setQuestion(PluginServices.getText(this,"insert_destination_point")); setDescription(new String[]{"cancel"}); addPoint( pointX,pointY,event); // refresh(); } // Si no hemos cogido un handler, probamos a seleccionar // otra entidad addPoint( pointX:double,pointY:double,event:InputEvent) [ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")] WithSelectedFeatures { setQuestion(PluginServices.getText(this,"select_handlers")); setDescription(new String[]{"cancel"}); addPoint( pointX,pointY,event); } // Cualquier otro caso (hemos pinchado en algo vacio), volvemos al estado inicial addPoint( pointX:double,pointY:double,event:InputEvent) FirstPoint { setQuestion(PluginServices.getText(this,"insert_point_selection")); setDescription(new String[]{"cancel"}); addPoint( pointX,pointY,event); // refresh(); } addOption(s:String) FirstPoint{ setQuestion(PluginServices.getText(this,"insert_point_selection")); setDescription(new String[]{"cancel"}); setType(s); } } WithHandlers{ addPoint( pointX:double,pointY:double,event:InputEvent) WithSelectedFeatures { setQuestion(PluginServices.getText(this,"select_handlers")); setDescription(new String[]{"cancel"}); addPoint( pointX,pointY,event); refresh(); } } Default { addOption(s:String) [s.equals("")] FirstPoint{ restorePreviousTool(); setQuestion(PluginServices.getText(this,"insert_point_selection")); setDescription(new String[]{"cancel"}); end(); } addOption(s:String) [s.equals(PluginServices.getText(this,"cancel"))] FirstPoint{ end(); } addOption(s:String) FirstPoint{ throwOptionException(PluginServices.getText(this,"incorrect_option"),s); } addValue(d:double) FirstPoint{ throwValueException(PluginServices.getText(this,"incorrect_value"),d); } addPoint(pointX:double,pointY:double,event:InputEvent) FirstPoint{ throwPointException(PluginServices.getText(this,"incorrect_point"),pointX,pointY); } } %%