// manages change of attributes for highlighting, annotation bubble toggle, event firing private void internalHighlight(SurfaceShape shape, boolean noDeselect) { if (!highlightingEnabled) { return; } String shpId = (String) shape.getValue(AVKey.HOVER_TEXT); // if annotation visible and same shape if (shape.equals(prevPopupShape) && shape.isHighlighted()) { if (!noDeselect) { // hide annotation and de-highlight popupAnnotation.getAttributes().setVisible(false); shape.setHighlighted(false); // forget previous highlighted shape and fire deselection event prevPopupShape = null; firePropertyChange(new PropertyChangeEvent(this, PROPERTY_SELECTION, shpId, null)); } } else { if (showAnnotation) { // find shape centroid final Sector boundingSector = Sector.boundingSector(shape.getLocations(wwd.getModel().getGlobe())); Position centroid = new Position(boundingSector.getCentroid(), 0d); // prepare and show annotation popupAnnotation.setText(shpId); popupAnnotation.setPosition(centroid); popupAnnotation.getAttributes().setVisible(true); } // highlight shape shape.setHighlighted(true); if (prevPopupShape != null) { // de-highlight previous shape and fire deselection event prevPopupShape.setHighlighted(false); firePropertyChange( new PropertyChangeEvent( this, PROPERTY_SELECTION, prevPopupShape.getValue(AVKey.HOVER_TEXT), shpId)); } else { // fire event only firePropertyChange(new PropertyChangeEvent(this, PROPERTY_SELECTION, null, shpId)); } // remember shape prevPopupShape = shape; } }
@Override public void setHighlightingEnabled(boolean highlightingEnabled) { this.highlightingEnabled = highlightingEnabled; // hide popup and clear highlighed object when disabling if (!highlightingEnabled) { popupAnnotation.getAttributes().setVisible(false); if (prevPopupShape != null) { prevPopupShape.setHighlighted(false); } wwd.redraw(); } }