From: <de...@us...> - 2016-04-26 22:05:47
|
Revision: 9389 http://sourceforge.net/p/fudaa/svn/9389 Author: deniger Date: 2016-04-26 22:05:44 +0000 (Tue, 26 Apr 2016) Log Message: ----------- version 1.9-SNAPSHOT Modified Paths: -------------- trunk/business/fudaa-sig/src/main/java/org/fudaa/fudaa/sig/layer/FSigLayerVariableDisplay.java Modified: trunk/business/fudaa-sig/src/main/java/org/fudaa/fudaa/sig/layer/FSigLayerVariableDisplay.java =================================================================== --- trunk/business/fudaa-sig/src/main/java/org/fudaa/fudaa/sig/layer/FSigLayerVariableDisplay.java 2016-04-26 22:05:21 UTC (rev 9388) +++ trunk/business/fudaa-sig/src/main/java/org/fudaa/fudaa/sig/layer/FSigLayerVariableDisplay.java 2016-04-26 22:05:44 UTC (rev 9389) @@ -25,104 +25,108 @@ import org.fudaa.ebli.trace.TraceBox; /** - * Decorator to FsigLayer that allow to display values of variable on FsigLayer for any variable declared on its parent - * group. + * Decorator to FsigLayer that allow to display values of variable on FsigLayer for any variable declared on its parent group. * * @author Adrien Hadoux */ public class FSigLayerVariableDisplay implements BSelecteurListTarget { - private boolean showValues = false; - private TraceBox paintBox = new TraceBox(); - ListSelectionModel selectionModel = new DefaultListSelectionModel(); - DefaultListModel listModel = new DefaultListModel(); + private boolean showValues = false; + private TraceBox paintBox = new TraceBox(); + ListSelectionModel selectionModel = new DefaultListSelectionModel(); + DefaultListModel listModel = new DefaultListModel(); - public TraceBox getTraceBox() { - return paintBox; - } - public void changeColor(Color color) { - paintBox.setColorText(color); - } - public void changeColorBackGround(Color color) { - paintBox.setColorFond(color); - } - public void changeBorderColor(Color color){ - paintBox.setColorBoite(color); - } - - public void changePosition() { - paintBox.setVertical(!paintBox.isVertical()); - } - - @Override - public ListModel getListModel() { - return listModel; - } + public TraceBox getTraceBox() { + return paintBox; + } - @Override - public ListSelectionModel getListSelectionModel() { - return selectionModel; - } + public void changeColor(Color color) { + paintBox.setColorText(color); + } - public void paintValueOfPoint(GISDataModel model, final Graphics2D _g, final GrPoint p, final int indicePoint, - final GrMorphisme _versEcran, final GrBoite _clipReel) { - if (showValues) { - String value = getValueForIdx(indicePoint, model); - if (StringUtils.isNotBlank(value)) { - paintBox.paintBox(_g, (int) p.x_, (int) p.y_, value); - } - } - } + public void changeColorBackGround(Color color) { + paintBox.setColorFond(color); + } - public boolean isShowValues() { - return this.showValues; + public void changeBorderColor(Color color) { + paintBox.setColorBoite(color); + } + + public void changePosition() { + paintBox.setVertical(!paintBox.isVertical()); + } + + @Override + public ListModel getListModel() { + return listModel; + } + + @Override + public ListSelectionModel getListSelectionModel() { + return selectionModel; + } + + public void paintValueOfPoint(GISDataModel model, final Graphics2D _g, final GrPoint p, final int indicePoint, + final GrMorphisme _versEcran, final GrBoite _clipReel) { + if (showValues) { + String value = getValueForIdx(indicePoint, model); + if (StringUtils.isNotBlank(value)) { + paintBox.paintBox(_g, (int) p.x_, (int) p.y_, value); + } } - - public void showValues(final boolean showValues, final BCalque contener) { - this.showValues = showValues; - contener.repaint(); - } + } - public void feedVariable(final FSigLayerGroup parent) { - if (listModel == null) { - listModel = new DefaultListModel(); - } else { - listModel.removeAllElements(); - } + public boolean isShowValues() { + return this.showValues; + } - for (GISAttributeInterface att : parent.getAttributes()) { - listModel.addElement(att); - } + public void showValues(final boolean showValues, final BCalque contener) { + this.showValues = showValues; + contener.repaint(); + } + public void feedVariable(final FSigLayerGroup parent) { + if (listModel == null) { + listModel = new DefaultListModel(); + } else { + listModel.removeAllElements(); } + if (parent != null && parent.getAttributes() != null) { + for (GISAttributeInterface att : parent.getAttributes()) { + listModel.addElement(att); + } + } - /** - * display variable value for Idx. - * - * @param idX - * @return - */ - public String getValueForIdx(final int idX, GISDataModel dataModel) { - int index = selectionModel.getMinSelectionIndex() == -1 ? 0 : selectionModel.getMinSelectionIndex(); + } - if (dataModel!= null) { - DecimalFormat decFormat = new DecimalFormat("##.####"); - if (dataModel.getNbAttributes() >index && idX< dataModel.getNumGeometries() && - dataModel.getValue(index, idX) != null && dataModel.getValue(index, idX) instanceof Double) { - - return decFormat.format(dataModel.getDoubleValue(0, idX)); - }else if (dataModel.getNbAttributes() >index && dataModel.getValue(index,0) instanceof GISAttributeModelDoubleArray) { - GISAttributeModelDoubleArray array =(GISAttributeModelDoubleArray)dataModel.getValue(index,0); - if(idX < array.getSize()) - return decFormat.format( array.getValue(idX)); - } else if(dataModel.getNbAttributes() ==0 && dataModel instanceof GISZoneCollection) { - GISZoneCollection collection = (GISZoneCollection)dataModel; - if(idX <collection.getCoordinates().length) { - return decFormat.format( collection.getCoordinates()[idX].z); - } - } + /** + * display variable value for Idx. + * + * @param idX + * @return + */ + public String getValueForIdx(final int idX, GISDataModel dataModel) { + int index = selectionModel.getMinSelectionIndex() == -1 ? 0 : selectionModel.getMinSelectionIndex(); + + if (dataModel != null) { + DecimalFormat decFormat = new DecimalFormat("##.####"); + if (dataModel.getNbAttributes() > index && idX < dataModel.getNumGeometries() + && dataModel.getValue(index, idX) != null && dataModel.getValue(index, idX) instanceof Double) { + + return decFormat.format(dataModel.getDoubleValue(0, idX)); + } else if (dataModel.getNbAttributes() > index && dataModel.getValue(index, 0) instanceof GISAttributeModelDoubleArray) { + GISAttributeModelDoubleArray array = (GISAttributeModelDoubleArray) dataModel.getValue(index, 0); + if (idX < array.getSize()) { + return decFormat.format(array.getValue(idX)); } - return ""; + } else if (dataModel.getNbAttributes() == 0 && dataModel instanceof GISZoneCollection) { + GISZoneCollection collection = (GISZoneCollection) dataModel; + if (idX < collection.getCoordinates().length) { + return decFormat.format(collection.getCoordinates()[idX].z); + } + } } + return ""; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |