How to Access and Display Attributes of Selected Features
Jump to navigation
Jump to search
//Prepare Output Frame context.getWorkbenchFrame().getOutputFrame().createNewDocument(); context.getWorkbenchFrame().getOutputFrame().addText("Hello, World!"); context.getWorkbenchFrame().getOutputFrame().surface(); //Select desired Layer::In this case the ith this.itemlayer=context.getCandidateLayer(i); //Get respective LayerViewPanel LayerViewPanel LVP=context.getLayerViewPanel(); //Get SelectionManager for the Layer SelectionManager SM=LVP.getSelectionManager(); //Get Features Collection data=SM.getFeaturesWithSelectedItems(); //Iterate features to access desired Attributes Feature firstF; Object firstO; for (Iterator iter = data.iterator(); iter.hasNext();){ firstF = (Feature)iter.next(); //Get required Attributes:: '0' represents the column index in my case it was 'length' firstO = firstF.getAttribute(0); //Finally display :) context.getWorkbenchFrame().getOutputFrame().addText("\n"+LayerName+"\n"+"\n"+firstO.toString()+"\n"); }