idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
9,900 | public < TCoder extends BinaryEncoder & BinaryDecoder > CodecCipher setCoder ( TCoder coder ) { this . encoder = coder ; this . decoder = coder ; return this ; } | Set a coder . |
9,901 | public void start ( DATA wizardData ) { if ( ! started ) { initHandlers ( ) ; } for ( WizardPage < DATA > page : pages ) { page . clear ( ) ; page . setWizardData ( wizardData ) ; } ListIterator < WizardPage < DATA > > iterator = pages . listIterator ( ) ; if ( iterator . hasNext ( ) ) { setCurrentPage ( iterator . next ( ) ) ; } } | Starts or restarts this wizard by clearing all pages and presenting the first page to the user . This method should only be called after all pages have been added . After this method has been called no more pages can be added . |
9,902 | protected void setCurrentPage ( WizardPage < DATA > newPage ) { currentPage = newPage ; updateState ( ) ; wizardView . setCurrentPage ( currentPage ) ; currentPage . show ( ) ; } | Sets the current page of this wizard . As this method forces the current page it should only be used after checking validity of the previous pages . |
9,903 | public void addPage ( WizardPage < DATA > page ) { if ( ! started ) { WizardPage < DATA > lastPage = pages . size ( ) > 0 ? pages . get ( pages . size ( ) - 1 ) : null ; if ( lastPage != null ) { lastPage . setNextPage ( page ) ; page . setPreviousPage ( lastPage ) ; } pages . add ( page ) ; wizardView . addPageToView ( page ) ; } } | Adds a page to this wizard . The page order is determined by the order in which pages are added . |
9,904 | public boolean execute ( Canvas target , Menu menu , MenuItem item ) { FeatureTransaction featureTransaction = mapWidget . getMapModel ( ) . getFeatureEditor ( ) . getFeatureTransaction ( ) ; if ( featureTransaction != null ) { boolean operationCount = featureTransaction . getOperationQueue ( ) . size ( ) > 0 ; if ( operationCount ) { FeatureOperation firstOperation = featureTransaction . getOperationQueue ( ) . get ( 0 ) ; if ( firstOperation instanceof AddCoordinateOp ) { if ( featureTransaction . getNewFeatures ( ) [ 0 ] . getGeometry ( ) . getNumPoints ( ) == 1 ) { return false ; } } return true ; } } return false ; } | This function tries to find out whether or not this menu item should be enabled . Only if there are more then 1 operations in the feature transaction operation queue will this menu item be enabled . |
9,905 | @ Produces ( MediaType . APPLICATION_JSON ) @ RequiresPermissions ( I18nPermissions . KEY_READ ) public KeyRepresentation getKey ( ) { KeyRepresentation keyRepresentation = keyFinder . findKeyWithName ( keyName ) ; if ( keyRepresentation == null ) { throw new NotFoundException ( String . format ( KEY_NOT_FOUND , keyName ) ) ; } return keyRepresentation ; } | Returns a key with the default translation . |
9,906 | @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) @ RequiresPermissions ( I18nPermissions . KEY_WRITE ) public Response updateKey ( KeyRepresentation representation ) throws URISyntaxException { WebAssertions . assertNotNull ( representation , THE_KEY_SHOULD_NOT_BE_NULL ) ; WebAssertions . assertNotBlank ( representation . getDefaultLocale ( ) , THE_KEY_SHOULD_CONTAINS_A_LOCALE ) ; Key key = loadKeyIfExistsOrFail ( ) ; key . setComment ( representation . getComment ( ) ) ; key . setOutdated ( ) ; key . addTranslation ( representation . getDefaultLocale ( ) , representation . getTranslation ( ) , representation . isApprox ( ) ) ; keyRepository . update ( key ) ; return Response . ok ( new URI ( uriInfo . getRequestUri ( ) + "/" + keyName ) ) . entity ( keyFinder . findKeyWithName ( keyName ) ) . build ( ) ; } | Updates a key with the translation in the default language . |
9,907 | public PaintableGroup getGroup ( RenderGroup group ) { switch ( group ) { case RASTER : return rasterGroup ; case VECTOR : return vectorGroup ; case WORLD : return worldGroup ; case SCREEN : default : return screenGroup ; } } | Return the Object that represents one the default RenderGroups in the DOM tree when drawing . |
9,908 | public void renderAll ( boolean force ) { Scheduler . get ( ) . scheduleDeferred ( new ScheduledCommand ( ) { public void execute ( ) { if ( graphics . isReady ( ) ) { render ( mapModel , null , RenderStatus . ALL ) ; } } } ) ; } | Render the map completely . |
9,909 | public void render ( Paintable paintable , RenderGroup renderGroup , RenderStatus status ) { if ( ! graphics . isReady ( ) || ! mapViewRenderer . isViewPortKnown ( ) || ! mapModelRenderer . isReadyToDraw ( ) ) { return ; } PaintableGroup group = null ; if ( renderGroup != null ) { group = getGroup ( renderGroup ) ; } if ( paintable == null ) { paintable = this . mapModel ; } if ( RenderStatus . DELETE . equals ( status ) ) { List < Painter > painters = painterVisitor . getPaintersForObject ( paintable ) ; if ( painters != null ) { for ( Painter painter : painters ) { painter . deleteShape ( paintable , group , graphics ) ; } } } else { if ( RenderStatus . ALL . equals ( status ) ) { paintable . accept ( painterVisitor , group , mapModel . getMapView ( ) . getBounds ( ) , true ) ; if ( paintable == this . mapModel ) { for ( WorldPaintable worldPaintable : worldPaintables . values ( ) ) { worldPaintable . transform ( mapModel . getMapView ( ) . getWorldViewTransformer ( ) ) ; worldPaintable . accept ( painterVisitor , getGroup ( RenderGroup . WORLD ) , mapModel . getMapView ( ) . getBounds ( ) , true ) ; } } } else if ( RenderStatus . UPDATE . equals ( status ) ) { if ( paintable == this . mapModel ) { for ( WorldPaintable worldPaintable : worldPaintables . values ( ) ) { worldPaintable . transform ( mapModel . getMapView ( ) . getWorldViewTransformer ( ) ) ; worldPaintable . accept ( painterVisitor , getGroup ( RenderGroup . WORLD ) , mapModel . getMapView ( ) . getBounds ( ) , false ) ; } } paintable . accept ( painterVisitor , group , mapModel . getMapView ( ) . getBounds ( ) , false ) ; } } } | The main rendering method . Renders some paintable object in the given group using the given status . |
9,910 | public void setDefaultCursorString ( String cursor ) { try { defaultCursor = cursor . toUpperCase ( ) ; Cursor . valueOf ( cursor . toUpperCase ( ) ) ; } catch ( Exception e ) { defaultCursor = cursor ; if ( ! cursor . contains ( "url" ) ) { defaultCursor = "url('" + cursor + "'),auto" ; } } setCursorString ( defaultCursor ) ; } | Apply a new default cursor on the map . This cursor will be set on deactivation of a controller . |
9,911 | public void unregisterMapAddon ( MapAddon addon ) { if ( addon != null && addons . containsKey ( addon . getId ( ) ) ) { addons . remove ( addon . getId ( ) ) ; graphics . getVectorContext ( ) . deleteGroup ( addon ) ; addon . onRemove ( ) ; } } | Remove a registered map add - on from the map . Map add - ons are fixed position entities on a map with possibly additional functionality . Examples are the scale bar and navigation buttons . |
9,912 | public void setZoomOnScrollEnabled ( boolean zoomOnScrollEnabled ) { if ( mouseWheelRegistration != null ) { mouseWheelRegistration . removeHandler ( ) ; mouseWheelRegistration = null ; } this . zoomOnScrollEnabled = zoomOnScrollEnabled ; if ( zoomOnScrollEnabled ) { mouseWheelRegistration = graphics . addMouseWheelHandler ( new ZoomOnScrollController ( ) ) ; } } | Determines whether or not the zooming using the mouse wheel should be enabled or not . |
9,913 | public void setScalebarEnabled ( boolean enabled ) { scaleBarEnabled = enabled ; final String scaleBarId = "scalebar" ; if ( scaleBarEnabled ) { if ( ! getMapAddons ( ) . containsKey ( scaleBarId ) ) { ScaleBar scalebar = new ScaleBar ( scaleBarId , this ) ; scalebar . setVerticalAlignment ( VerticalAlignment . BOTTOM ) ; scalebar . setHorizontalMargin ( 2 ) ; scalebar . setVerticalMargin ( 2 ) ; scalebar . initialize ( getMapModel ( ) . getMapInfo ( ) . getDisplayUnitType ( ) , unitLength , new Coordinate ( 20 , graphics . getHeight ( ) - 25 ) ) ; registerMapAddon ( scalebar ) ; } } else { unregisterMapAddon ( addons . get ( scaleBarId ) ) ; } } | Enables or disables the scale bar . This setting has immediate effect on the map . |
9,914 | public void setNavigationAddonEnabled ( boolean enabled ) { navigationAddonEnabled = enabled ; final String panId = "panBTNCollection" ; final String zoomId = "zoomAddon" ; final String zoomRectId = "zoomRectAddon" ; if ( enabled ) { if ( ! getMapAddons ( ) . containsKey ( panId ) ) { PanButtonCollection panButtons = new PanButtonCollection ( panId , this ) ; panButtons . setHorizontalMargin ( 5 ) ; panButtons . setVerticalMargin ( 5 ) ; registerMapAddon ( panButtons ) ; } if ( ! getMapAddons ( ) . containsKey ( zoomId ) ) { ZoomAddon zoomAddon = new ZoomAddon ( zoomId , this ) ; zoomAddon . setHorizontalMargin ( 20 ) ; zoomAddon . setVerticalMargin ( 65 ) ; registerMapAddon ( zoomAddon ) ; } if ( ! getMapAddons ( ) . containsKey ( zoomRectId ) ) { ZoomToRectangleAddon zoomToRectangleAddon = new ZoomToRectangleAddon ( zoomRectId , this ) ; zoomToRectangleAddon . setHorizontalMargin ( 20 ) ; zoomToRectangleAddon . setVerticalMargin ( 135 ) ; registerMapAddon ( zoomToRectangleAddon ) ; } } else { unregisterMapAddon ( addons . get ( panId ) ) ; unregisterMapAddon ( addons . get ( zoomId ) ) ; unregisterMapAddon ( addons . get ( zoomRectId ) ) ; } } | Enables or disables the panning buttons . This setting has immediate effect on the map . |
9,915 | public void setMouseWheelController ( MouseWheelHandler controller ) { setZoomOnScrollEnabled ( false ) ; mouseWheelRegistration = graphics . addMouseWheelHandler ( controller ) ; } | Set a new mouse wheel controller on the map . If the zoom on scroll is currently enabled it will be disabled first . |
9,916 | private void setForceContextMenu ( ) { suppressContextMenu ( getElement ( ) ) ; addShowContextMenuHandler ( new ShowContextMenuHandler ( ) { public void onShowContextMenu ( ShowContextMenuEvent event ) { getContextMenu ( ) . showContextMenu ( ) ; } } ) ; addListener ( new Listener ( ) { public void onMouseDown ( ListenerEvent event ) { if ( event . getNativeButton ( ) == NativeEvent . BUTTON_RIGHT ) { Scheduler . get ( ) . scheduleDeferred ( new ScheduledCommand ( ) { public void execute ( ) { fireEvent ( new ShowContextMenuEvent ( getOrCreateJsObj ( ) ) ) ; } } ) ; } } public void onMouseUp ( ListenerEvent event ) { } public void onMouseMove ( ListenerEvent event ) { } public void onMouseOut ( ListenerEvent event ) { } public void onMouseOver ( ListenerEvent event ) { } public void onMouseWheel ( ListenerEvent event ) { } } ) ; } | IE11 fix to force context !!! |
9,917 | public void refreshLayer ( Layer < ? > layer ) { if ( layer instanceof VectorLayer ) { VectorLayer vLayer = ( VectorLayer ) layer ; vLayer . getFeatureStore ( ) . clear ( ) ; } else if ( layer instanceof RasterLayer ) { RasterLayer rLayer = ( RasterLayer ) layer ; rLayer . getStore ( ) . clear ( ) ; } render ( layer , null , RenderStatus . ALL ) ; } | Refresh a layer . This will re - render the layer with freshly fetched data . |
9,918 | private double validateY ( double y ) { SliderArea sliderArea = zoomSlider . getSliderArea ( ) ; y -= zoomSlider . getVerticalMargin ( ) + sliderArea . getVerticalMargin ( ) + 5 ; double startY = 0 ; double endY = sliderArea . getHeight ( ) - zoomSlider . getSliderUnit ( ) . getBounds ( ) . getHeight ( ) ; if ( y > endY ) { y = endY ; } else if ( y < startY ) { y = startY ; } return y ; } | Checks if the given y is within the slider area s range . If not the initial y is corrected to either the top y or bottom y . |
9,919 | public static Window createDefaultFeatureDetailWindow ( Feature feature , Layer < ? > layer , boolean editingAllowed ) { if ( layer instanceof VectorLayer ) { FeatureAttributeWindow w = new FeatureAttributeWindow ( feature , editingAllowed ) ; customize ( w , feature ) ; return w ; } else { return new RasterLayerAttributeWindow ( feature ) ; } } | Overrule configuration and create Geomajas default FeatureAttributeWindow . |
9,920 | public void zoomNext ( ) { if ( hasNext ( ) ) { MapViewChangedEvent data = next . remove ( ) ; previous . addFirst ( data ) ; active = false ; mapView . applyBounds ( data . getBounds ( ) , MapView . ZoomOption . LEVEL_CLOSEST ) ; updateActionsAbility ( ) ; } } | Zoom to the next level . |
9,921 | public void zoomPrevious ( ) { if ( hasPrevious ( ) ) { next . addFirst ( previous . remove ( ) ) ; MapViewChangedEvent data = previous . peek ( ) ; active = false ; mapView . applyBounds ( data . getBounds ( ) , MapView . ZoomOption . LEVEL_CLOSEST ) ; updateActionsAbility ( ) ; } } | Zoom to the previous level . |
9,922 | @ Produces ( MediaType . APPLICATION_JSON ) @ RequiresPermissions ( I18nPermissions . KEY_READ ) public Response getKeys ( @ QueryParam ( PAGE_INDEX ) @ DefaultValue ( "0" ) long pageIndex , @ QueryParam ( PAGE_SIZE ) @ DefaultValue ( "10" ) int pageSize , @ QueryParam ( IS_MISSING ) Boolean isMissing , @ QueryParam ( IS_APPROX ) Boolean isApprox , @ QueryParam ( IS_OUTDATED ) Boolean isOutdated , @ QueryParam ( SEARCH_NAME ) String searchName ) { WebAssertions . assertIf ( pageSize > 0 , "Page size should be greater than zero." ) ; KeySearchCriteria keySearchCriteria = new KeySearchCriteria ( isMissing , isApprox , isOutdated , searchName ) ; Page page = new Page ( pageIndex , pageSize ) ; return Response . ok ( keyFinder . findKeysWithTheirDefaultTranslation ( page , keySearchCriteria ) ) . build ( ) ; } | Returns a list of filtered keys without their translations . |
9,923 | @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) @ RequiresPermissions ( I18nPermissions . KEY_WRITE ) public Response createKey ( KeyRepresentation keyRepresentation ) throws URISyntaxException { WebAssertions . assertNotNull ( keyRepresentation , THE_KEY_SHOULD_NOT_BE_NULL ) ; WebAssertions . assertNotBlank ( keyRepresentation . getName ( ) , THE_KEY_SHOULD_CONTAINS_A_NAME ) ; WebAssertions . assertNotBlank ( keyRepresentation . getDefaultLocale ( ) , THE_KEY_SHOULD_CONTAINS_A_LOCALE ) ; assertKeyDoNotAlreadyExists ( keyRepresentation ) ; Key key = factory . createKey ( keyRepresentation . getName ( ) ) ; key . setComment ( keyRepresentation . getComment ( ) ) ; addDefaultTranslation ( keyRepresentation , key ) ; keyRepository . add ( key ) ; return Response . created ( new URI ( uriInfo . getRequestUri ( ) + "/" + key . getId ( ) ) ) . entity ( keyFinder . findKeyWithName ( key . getId ( ) ) ) . build ( ) ; } | Inserts a key with the translation in the default language . |
9,924 | @ Produces ( "text/plain" ) @ RequiresPermissions ( I18nPermissions . KEY_DELETE ) public Response deleteKeys ( @ QueryParam ( IS_MISSING ) Boolean isMissing , @ QueryParam ( IS_APPROX ) Boolean isApprox , @ QueryParam ( IS_OUTDATED ) Boolean isOutdated , @ QueryParam ( SEARCH_NAME ) String searchName ) { KeySearchCriteria keySearchCriteria = new KeySearchCriteria ( isMissing , isApprox , isOutdated , searchName ) ; long numberOfDeletedKeys ; if ( shouldDeleteWithoutFilter ( keySearchCriteria ) ) { numberOfDeletedKeys = keyRepository . size ( ) ; keyRepository . clear ( ) ; } else { numberOfDeletedKeys = deleteFilteredKeys ( keySearchCriteria ) ; } return Response . ok ( String . format ( "%d deleted keys" , numberOfDeletedKeys ) ) . build ( ) ; } | Deletes all the filtered keys . |
9,925 | public void onChanged ( ChangedEvent event ) { String selectedLocale = ( String ) event . getValue ( ) ; for ( Entry < String , String > entry : locales . entrySet ( ) ) { if ( entry . getValue ( ) . equals ( selectedLocale ) ) { SC . showPrompt ( I18nProvider . getGlobal ( ) . localeReload ( ) + ": " + selectedLocale ) ; Window . Location . assign ( buildLocaleUrl ( entry . getKey ( ) ) ) ; } } } | When a new locale has been selected in the select item this method will be called . It will automatically reload the entire page using the newly selected locale . |
9,926 | private String buildLocaleUrl ( String selectedLocale ) { UrlBuilder builder = Window . Location . createUrlBuilder ( ) ; builder . removeParameter ( "locale" ) ; if ( ! "default" . equals ( selectedLocale ) ) { builder . setParameter ( "locale" , selectedLocale ) ; } return builder . buildString ( ) ; } | Build the correct URL for the new locale . |
9,927 | public void setVisible ( boolean visible ) { this . visible = visible ; if ( googleMap != null ) { String mapsId = map . getRasterContext ( ) . getId ( this ) ; Element gmap = DOM . getElementById ( mapsId ) ; UIObject . setVisible ( gmap , visible ) ; if ( tosGroup != null ) { UIObject . setVisible ( tosGroup , visible ) ; } if ( visible ) { triggerResize ( googleMap ) ; } } } | Set the visibility of the Google map . |
9,928 | public void setMapType ( MapType type ) { this . type = type ; if ( googleMap != null ) { setMapType ( googleMap , type . toString ( ) ) ; } } | Set the type of the Google map . |
9,929 | public void onMouseDown ( MouseDownEvent event ) { if ( event . getNativeButton ( ) != NativeEvent . BUTTON_RIGHT ) { dragging = true ; center = getScreenPosition ( event ) ; LineString radiusLine = mapWidget . getMapModel ( ) . getGeometryFactory ( ) . createLineString ( new Coordinate [ ] { center , center } ) ; mapWidget . getVectorContext ( ) . drawGroup ( mapWidget . getGroup ( RenderGroup . SCREEN ) , circleGroup ) ; mapWidget . getVectorContext ( ) . drawCircle ( circleGroup , "outer" , center , 1.0f , circleStyle ) ; mapWidget . getVectorContext ( ) . drawCircle ( circleGroup , "center" , center , 2.0f , circleStyle ) ; mapWidget . getVectorContext ( ) . drawLine ( circleGroup , "radius" , radiusLine , circleStyle ) ; } } | Register center point for the circle and start dragging and rendering . |
9,930 | protected Coordinate getWorldCenter ( ) { if ( center != null ) { return mapWidget . getMapModel ( ) . getMapView ( ) . getWorldViewTransformer ( ) . viewToWorld ( center ) ; } return null ; } | Return the center position of the circle in world coordinates . |
9,931 | protected double getWorldRadius ( ) { if ( center != null ) { Coordinate screenEndPoint = new Coordinate ( center . getX ( ) + radius , center . getY ( ) ) ; Coordinate worldEndPoint = mapWidget . getMapModel ( ) . getMapView ( ) . getWorldViewTransformer ( ) . viewToWorld ( screenEndPoint ) ; double deltaX = worldEndPoint . getX ( ) - getWorldCenter ( ) . getX ( ) ; double deltaY = worldEndPoint . getY ( ) - getWorldCenter ( ) . getY ( ) ; return ( float ) Math . sqrt ( ( deltaX * deltaX ) + ( deltaY * deltaY ) ) ; } return 0 ; } | Return the circle s radius in world length units . |
9,932 | public void move ( GeometryIndex [ ] indices , JsArray < JsArrayObject > coordinates ) { List < List < Coordinate > > coords = new ArrayList < List < Coordinate > > ( coordinates . length ( ) ) ; for ( int i = 0 ; i < coordinates . length ( ) ; i ++ ) { JsArrayObject jsObj = coordinates . get ( i ) ; coords . add ( Arrays . asList ( ExporterUtil . toArrObject ( jsObj , new Coordinate [ jsObj . length ( ) ] ) ) ) ; } try { delegate . move ( Arrays . asList ( indices ) , coords ) ; } catch ( GeometryOperationFailedException e ) { throw new RuntimeException ( e . getMessage ( ) ) ; } } | Move a set of indices to new locations . These indices can point to vertices edges or sub - geometries . For each index a list of new coordinates is provided . |
9,933 | public void remove ( GeometryIndex [ ] indices ) { try { delegate . remove ( Arrays . asList ( indices ) ) ; } catch ( GeometryOperationFailedException e ) { throw new RuntimeException ( e . getMessage ( ) ) ; } } | Delete vertices edges or sub - geometries at the given indices . |
9,934 | public static < T > RubyArray < T > p ( T first , T ... others ) { RubyArray < T > ra = new RubyArray < > ( ) ; out . print ( "[" ) ; ra . add ( p ( first , false ) ) ; Arrays . asList ( others ) . forEach ( item -> { out . print ( ", " ) ; ra . add ( p ( item , false ) ) ; } ) ; out . print ( "]" ) ; out . println ( ) ; return ra ; } | Prints a human - readable representation of given Objects . |
9,935 | public Coordinate getCoordinateN ( int n ) { if ( isEmpty ( ) ) { return null ; } if ( n >= 0 && n < coordinates . length ) { return coordinates [ n ] ; } return null ; } | Return a coordinate or null . |
9,936 | public double getLength ( ) { double len = 0 ; if ( ! isEmpty ( ) ) { for ( int i = 0 ; i < coordinates . length - 1 ; i ++ ) { double deltaX = coordinates [ i + 1 ] . getX ( ) - coordinates [ i ] . getX ( ) ; double deltaY = coordinates [ i + 1 ] . getY ( ) - coordinates [ i ] . getY ( ) ; len += Math . sqrt ( deltaX * deltaX + deltaY * deltaY ) ; } } return len ; } | Return the length of the LineString . |
9,937 | public double getDistance ( Coordinate coordinate ) { double minDistance = Double . MAX_VALUE ; if ( ! isEmpty ( ) ) { for ( int i = 0 ; i < this . coordinates . length - 1 ; i ++ ) { double dist = Mathlib . distance ( this . coordinates [ i ] , this . coordinates [ i + 1 ] , coordinate ) ; if ( dist < minDistance ) { minDistance = dist ; } } } return minDistance ; } | Return the minimal distance between this coordinate and any line segment of the geometry . |
9,938 | public LineString getLineString ( Geometry geometry ) { if ( geometry instanceof MultiLineString ) { if ( geometryIndex >= 0 && geometryIndex < geometry . getNumGeometries ( ) ) { return getLinearRing ( geometry . getGeometryN ( geometryIndex ) ) ; } } else if ( geometry instanceof LineString ) { return ( LineString ) geometry ; } return getLinearRing ( geometry ) ; } | Returns a LineString or LinearRing that is described by this index . |
9,939 | public boolean isNeighbor ( String identifier , Geometry geometry ) { LineString lineString = getLineString ( geometry ) ; if ( lineString != null ) { int index = TransactionGeomIndexUtil . getIndex ( identifier ) . getCoordinateIndex ( ) ; if ( index >= 0 && coordinateIndex >= 0 ) { if ( coordinateIndex == 0 ) { if ( index == 1 ) { return true ; } if ( lineString . isClosed ( ) && index == lineString . getNumPoints ( ) - 2 ) { return true ; } } else if ( coordinateIndex == lineString . getNumPoints ( ) - 2 ) { if ( index == coordinateIndex - 1 ) { return true ; } else if ( lineString . isClosed ( ) && index == 0 ) { return true ; } } else { if ( index == coordinateIndex - 1 || index == coordinateIndex + 1 ) { return true ; } } } else { SC . warn ( "TransactionGeomIndex.isNeighbor: Implement me" ) ; } } return false ; } | Return true or false indicating of the given identifier for an edge or vertex is a neighbor for this index . |
9,940 | public void paint ( Paintable paintable , Object group , MapContext context ) { context . getRasterContext ( ) . drawGroup ( null , mapWidget . getGroup ( RenderGroup . RASTER ) , mapWidget . getMapModel ( ) . getMapView ( ) . getPanToViewTranslation ( ) ) ; context . getVectorContext ( ) . drawGroup ( null , mapWidget . getGroup ( RenderGroup . VECTOR ) , mapWidget . getMapModel ( ) . getMapView ( ) . getPanToViewTranslation ( ) ) ; context . getVectorContext ( ) . drawGroup ( null , mapWidget . getGroup ( RenderGroup . WORLD ) , mapWidget . getMapModel ( ) . getMapView ( ) . getPanToViewTranslation ( ) ) ; context . getVectorContext ( ) . drawGroup ( null , mapWidget . getGroup ( RenderGroup . SCREEN ) ) ; } | The actual painting function . Draws the basic groups . |
9,941 | public void onDown ( HumanInputEvent < ? > event ) { if ( dragging && leftWidget ) { doSelect ( event ) ; } else if ( ! isRightMouseButton ( event ) ) { dragging = true ; leftWidget = false ; timestamp = new Date ( ) . getTime ( ) ; begin = getLocation ( event , RenderSpace . SCREEN ) ; bounds = new Bbox ( begin . getX ( ) , begin . getY ( ) , 0.0 , 0.0 ) ; shift = event . isShiftKeyDown ( ) ; rectangle = new Rectangle ( "selectionRectangle" ) ; rectangle . setStyle ( rectangleStyle ) ; rectangle . setBounds ( bounds ) ; mapWidget . render ( rectangle , RenderGroup . SCREEN , RenderStatus . UPDATE ) ; } } | Start dragging register base for selection rectangle . |
9,942 | public int indexOf ( String name ) { int i = 0 ; for ( FormItem formItem : this ) { if ( name . equals ( formItem . getName ( ) ) ) { return i ; } i ++ ; } return - 1 ; } | Get the index of the field with given name . |
9,943 | public void insertBefore ( String name , FormItem ... newItem ) { int index = indexOf ( name ) ; if ( index >= 0 ) { addAll ( index , Arrays . asList ( newItem ) ) ; } } | Insert a form item before the item with the specified name . |
9,944 | public JsHandlerRegistration addDispatchStartedHandler ( final DispatchStartedHandler handler ) { HandlerRegistration registration = GwtCommandDispatcher . getInstance ( ) . addDispatchStartedHandler ( new org . geomajas . gwt . client . command . event . DispatchStartedHandler ( ) { public void onDispatchStarted ( DispatchStartedEvent event ) { handler . onDispatchStarted ( new org . geomajas . plugin . jsapi . client . event . DispatchStartedEvent ( ) ) ; } } ) ; return new JsHandlerRegistration ( new HandlerRegistration [ ] { registration } ) ; } | Add a handler that is called whenever the client starts communicating with the back - end . |
9,945 | public JsHandlerRegistration addDispatchStoppedHandler ( final DispatchStoppedHandler handler ) { HandlerRegistration registration = GwtCommandDispatcher . getInstance ( ) . addDispatchStoppedHandler ( new org . geomajas . gwt . client . command . event . DispatchStoppedHandler ( ) { public void onDispatchStopped ( DispatchStoppedEvent event ) { handler . onDispatchStopped ( new org . geomajas . plugin . jsapi . client . event . DispatchStoppedEvent ( ) ) ; } } ) ; return new JsHandlerRegistration ( new HandlerRegistration [ ] { registration } ) ; } | Add a handler that is called whenever the client stops communicating with the back - end . |
9,946 | public MapController createMapController ( Map map , String id ) { MapWidget mapWidget = ( ( MapImpl ) map ) . getMapWidget ( ) ; if ( "PanMode" . equalsIgnoreCase ( id ) ) { return createMapController ( map , new PanController ( mapWidget ) , id ) ; } else if ( ToolId . TOOL_MEASURE_DISTANCE_MODE . equalsIgnoreCase ( id ) ) { return createMapController ( map , new MeasureDistanceController ( mapWidget ) , id ) ; } else if ( ToolId . TOOL_FEATURE_INFO . equalsIgnoreCase ( id ) ) { return createMapController ( map , new FeatureInfoController ( mapWidget , 3 ) , id ) ; } else if ( ToolId . TOOL_SELECTION_MODE . equalsIgnoreCase ( id ) ) { return createMapController ( map , new SelectionController ( mapWidget , 500 , 0.5f , false , 3 ) , id ) ; } else if ( "SingleSelectionMode" . equalsIgnoreCase ( id ) ) { return createMapController ( map , new SingleSelectionController ( mapWidget , false , 3 ) , id ) ; } else if ( ToolId . TOOL_EDIT . equalsIgnoreCase ( id ) ) { return createMapController ( map , new ParentEditController ( mapWidget ) , id ) ; } return null ; } | Create a known controller for the map . Different implementations may know different controllers so it s best to check with the implementing class . |
9,947 | public double getLength ( ) { double deltaX = this . c2 . getX ( ) - this . c1 . getX ( ) ; double deltaY = this . c2 . getY ( ) - this . c1 . getY ( ) ; return Math . sqrt ( deltaX * deltaX + deltaY * deltaY ) ; } | Return the length of the linesegment . |
9,948 | public Coordinate getMiddlePoint ( ) { double x = this . x1 ( ) + 0.5 * ( this . x2 ( ) - this . x1 ( ) ) ; double y = this . y1 ( ) + 0.5 * ( this . y2 ( ) - this . y1 ( ) ) ; return new Coordinate ( x , y ) ; } | Return the middle point of this linesegment . |
9,949 | public double distance ( Coordinate c ) { Coordinate nearest = this . nearest ( c ) ; LineSegment ls = new LineSegment ( c , nearest ) ; return ls . getLength ( ) ; } | Return the distance from a point to this linesegment . If the point is not perpendicular to the linesegment the closest endpoint will be returned . |
9,950 | public boolean intersects ( LineSegment lineSegment ) { double x1 = this . x1 ( ) ; double y1 = this . y1 ( ) ; double x2 = this . x2 ( ) ; double y2 = this . y2 ( ) ; double x3 = lineSegment . x1 ( ) ; double y3 = lineSegment . y1 ( ) ; double x4 = lineSegment . x2 ( ) ; double y4 = lineSegment . y2 ( ) ; double denom = ( y4 - y3 ) * ( x2 - x1 ) - ( x4 - x3 ) * ( y2 - y1 ) ; if ( denom == 0 ) { return false ; } double u1 = ( ( x4 - x3 ) * ( y1 - y3 ) - ( y4 - y3 ) * ( x1 - x3 ) ) / denom ; double u2 = ( ( x2 - x1 ) * ( y1 - y3 ) - ( y2 - y1 ) * ( x1 - x3 ) ) / denom ; return ( u1 > 0 && u1 < 1 && u2 > 0 && u2 < 1 ) ; } | Does this linesegment intersect with another or not? |
9,951 | public Coordinate getIntersectionSegments ( LineSegment lineSegment ) { double x1 = this . x1 ( ) ; double y1 = this . y1 ( ) ; double x2 = this . x2 ( ) ; double y2 = this . y2 ( ) ; double x3 = lineSegment . x1 ( ) ; double y3 = lineSegment . y1 ( ) ; double x4 = lineSegment . x2 ( ) ; double y4 = lineSegment . y2 ( ) ; double denom = ( y4 - y3 ) * ( x2 - x1 ) - ( x4 - x3 ) * ( y2 - y1 ) ; if ( denom == 0 ) { return null ; } double u1 = ( ( x4 - x3 ) * ( y1 - y3 ) - ( y4 - y3 ) * ( x1 - x3 ) ) / denom ; if ( u1 <= 0 || u1 >= 1 ) { return null ; } double u2 = ( ( x2 - x1 ) * ( y1 - y3 ) - ( y2 - y1 ) * ( x1 - x3 ) ) / denom ; if ( u2 <= 0 || u2 >= 1 ) { return null ; } double x = x1 + u1 * ( x2 - x1 ) ; double y = y1 + u1 * ( y2 - y1 ) ; return new Coordinate ( x , y ) ; } | Return the intersection point of 2 line segments if they intersect in 1 point . |
9,952 | public Coordinate nearest ( Coordinate c ) { double len = this . getLength ( ) ; double u = ( c . getX ( ) - this . c1 . getX ( ) ) * ( this . c2 . getX ( ) - this . c1 . getX ( ) ) + ( c . getY ( ) - this . c1 . getY ( ) ) * ( this . c2 . getY ( ) - this . c1 . getY ( ) ) ; u = u / ( len * len ) ; if ( u < 0.00001 || u > 1 ) { LineSegment ls1 = new LineSegment ( c , this . c1 ) ; LineSegment ls2 = new LineSegment ( c , this . c2 ) ; double len1 = ls1 . getLength ( ) ; double len2 = ls2 . getLength ( ) ; if ( len1 < len2 ) { return this . c1 ; } return this . c2 ; } else { double x1 = this . c1 . getX ( ) + u * ( this . c2 . getX ( ) - this . c1 . getX ( ) ) ; double y1 = this . c1 . getY ( ) + u * ( this . c2 . getY ( ) - this . c1 . getY ( ) ) ; return new Coordinate ( x1 , y1 ) ; } } | Calculate which point on the LineSegment is nearest to the given coordinate . Will be perpendicular or one of the end - points . |
9,953 | public void unhide ( Object group ) { if ( isAttached ( ) ) { Element element = helper . getGroup ( group ) ; if ( element != null ) { Dom . setElementAttribute ( element , "display" , "inline" ) ; } } } | Show the specified group . If the group does not exist nothing will happen . |
9,954 | public boolean isSingleResult ( ) { if ( result == null ) { return false ; } else { if ( singleResult == null ) { if ( result . size ( ) == 1 && result . values ( ) . iterator ( ) . next ( ) . size ( ) == 1 ) { singleResult = true ; } else { singleResult = false ; } } return singleResult ; } } | Returns true if the search resulted in a single result in a single layer . false in all other cases . Also returns false when search has not yet been run . |
9,955 | @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) @ RequiresPermissions ( I18nPermissions . LOCALE_WRITE ) public Response changeDefaultLocale ( LocaleRepresentation representation ) throws URISyntaxException { WebAssertions . assertNotNull ( representation , "The locale should not be null" ) ; WebAssertions . assertNotBlank ( representation . getCode ( ) , "The locale code should not be blank" ) ; try { localeService . changeDefaultLocaleTo ( representation . getCode ( ) ) ; } catch ( Exception e ) { logger . error ( e . getMessage ( ) , e ) ; return Response . status ( Response . Status . NOT_FOUND ) . build ( ) ; } return Response . ok ( new URI ( uriInfo . getRequestUri ( ) . toString ( ) ) ) . entity ( localeFinder . findDefaultLocale ( ) ) . build ( ) ; } | Changes the default locale |
9,956 | public void register ( ) { registrations . add ( editService . addGeometryEditMoveHandler ( this ) ) ; registrations . add ( editService . addGeometryEditShapeChangedHandler ( this ) ) ; registrations . add ( editService . addGeometryEditTentativeMoveHandler ( this ) ) ; registrations . add ( editService . addGeometryEditChangeStateHandler ( this ) ) ; } | Register handlers . Activates this handler . |
9,957 | private org . geomajas . geometry . Bbox toBbox ( Bbox bounds ) { return new org . geomajas . geometry . Bbox ( bounds . getX ( ) , bounds . getY ( ) , bounds . getWidth ( ) , bounds . getHeight ( ) ) ; } | Convert to Bbox DTO . |
9,958 | private static boolean addCallback ( String applicationId , DelayedCallback callback ) { boolean isFirst = false ; List < DelayedCallback > list = BACKLOG . get ( applicationId ) ; if ( null == list ) { list = new ArrayList < DelayedCallback > ( ) ; BACKLOG . put ( applicationId , list ) ; isFirst = true ; } list . add ( callback ) ; return isFirst ; } | Add a delayed callback for the given application id . Returns whether this is the first request for the application id . |
9,959 | public static void getMapWidgetInfo ( final String applicationId , final String mapId , final String name , final WidgetConfigurationCallback callback ) { if ( ! CONFIG . containsKey ( applicationId ) ) { if ( addCallback ( applicationId , new DelayedCallback ( mapId , name , callback ) ) ) { configurationLoader . loadClientApplicationInfo ( applicationId , SETTER ) ; } } else { execute ( applicationId , mapId , name , callback ) ; } } | Get the configuration for a specific widget . This method will search within the context of a specific map . This means that it will find maps tool - bars and layer trees as well as the widget configurations within a map . |
9,960 | public void execute ( FeatureOperation op ) { if ( newFeatures != null && newFeatures . length > 0 ) { operationQueue . add ( op ) ; for ( Feature newFeature : newFeatures ) { op . execute ( newFeature ) ; } } } | Execute an operation on each of the features from the newFeature array . Also store the operation on a queue so it is possible to undo all the changes afterwards . |
9,961 | public org . geomajas . layer . feature . FeatureTransaction toDto ( ) { org . geomajas . layer . feature . FeatureTransaction dto = new org . geomajas . layer . feature . FeatureTransaction ( ) ; dto . setLayerId ( layer . getServerLayerId ( ) ) ; if ( oldFeatures != null ) { org . geomajas . layer . feature . Feature [ ] oldDto = new org . geomajas . layer . feature . Feature [ oldFeatures . length ] ; for ( int i = 0 ; i < oldFeatures . length ; i ++ ) { oldDto [ i ] = oldFeatures [ i ] . toDto ( ) ; } dto . setOldFeatures ( oldDto ) ; } if ( newFeatures != null ) { org . geomajas . layer . feature . Feature [ ] newDto = new org . geomajas . layer . feature . Feature [ newFeatures . length ] ; for ( int i = 0 ; i < newFeatures . length ; i ++ ) { newDto [ i ] = newFeatures [ i ] . toDto ( ) ; } dto . setNewFeatures ( newDto ) ; } return dto ; } | Transform this object into a DTO feature transaction . |
9,962 | public void setPosition ( Coordinate position ) { if ( getOriginalLocation ( ) != null ) { Bbox oldBounds = ( Bbox ) getOriginalLocation ( ) ; Bbox newBounds = ( Bbox ) oldBounds . clone ( ) ; newBounds . setCenterPoint ( position ) ; setOriginalLocation ( newBounds ) ; } else { setOriginalLocation ( new Bbox ( position . getX ( ) , position . getY ( ) , 0 , 0 ) ) ; } } | Set circle position in world space . |
9,963 | public void setRadius ( float radius ) { if ( getOriginalLocation ( ) != null ) { Bbox oldBounds = ( Bbox ) getOriginalLocation ( ) ; Bbox newBounds = ( Bbox ) oldBounds . clone ( ) ; newBounds . setWidth ( 2 * radius ) ; newBounds . setHeight ( 2 * radius ) ; newBounds . setCenterPoint ( oldBounds . getCenterPoint ( ) ) ; setOriginalLocation ( newBounds ) ; } else { setOriginalLocation ( new Bbox ( 0 , 0 , 2 * radius , 2 * radius ) ) ; } } | Set circle radius in world coordinates . |
9,964 | public void addVertexAction ( final JsGeometryContextMenuAction action , String title ) { delegate . addVertexAction ( new GeometryContextMenuAction ( title , null ) { public void onClick ( MenuItemClickEvent event ) { action . execute ( JsGeometryContextMenuRegistry . this ) ; } } ) ; } | Adds a vertex context menu action . |
9,965 | public void onClick ( MenuItemClickEvent event ) { final FeatureTransaction ft = mapWidget . getMapModel ( ) . getFeatureEditor ( ) . getFeatureTransaction ( ) ; if ( ft != null && index != null ) { List < Feature > features = new ArrayList < Feature > ( ) ; features . add ( ft . getNewFeatures ( ) [ index . getFeatureIndex ( ) ] ) ; LazyLoader . lazyLoad ( features , GeomajasConstant . FEATURE_INCLUDE_GEOMETRY , new LazyLoadCallback ( ) { public void execute ( List < Feature > response ) { controller . setEditMode ( EditMode . INSERT_MODE ) ; Geometry geometry = response . get ( 0 ) . getGeometry ( ) ; if ( geometry instanceof Polygon ) { geometry = addRing ( ( Polygon ) geometry ) ; } else if ( geometry instanceof MultiPolygon ) { geometry = addRing ( ( MultiPolygon ) geometry ) ; } ft . getNewFeatures ( ) [ index . getFeatureIndex ( ) ] . setGeometry ( geometry ) ; controller . setGeometryIndex ( index ) ; controller . hideGeometricInfo ( ) ; } } ) ; } } | Insert a new point in the geometry at a given index . The index is taken from the context menu event . This function will add a new empty interior ring in the polygon in question . |
9,966 | public void setLayer ( VectorLayer layer ) { this . layer = layer ; if ( layer == null ) { clear ( ) ; } else { empty ( ) ; updateFields ( ) ; } } | Apply a new layer onto the grid . This means that the table header will immediately take on the attributes of this new layer . |
9,967 | public void setSelectionEnabled ( boolean selectionEnabled ) { if ( selectionRegistration != null ) { selectionRegistration . removeHandler ( ) ; selectionRegistration = null ; } if ( gridSelectionRegistration != null ) { gridSelectionRegistration . removeHandler ( ) ; gridSelectionRegistration = null ; } this . selectionEnabled = selectionEnabled ; if ( selectionEnabled ) { setAttribute ( "selectionType" , SelectionStyle . MULTIPLE . getValue ( ) , true ) ; selectionRegistration = mapModel . addFeatureSelectionHandler ( this ) ; gridSelectionRegistration = addSelectionChangedHandler ( this ) ; } else { setAttribute ( "selectionType" , SelectionStyle . NONE . getValue ( ) , true ) ; } } | Adds or removes this widget as a handler for selection onto the MapModel . What this means is that when selection is enabled selected rows in the grid will result in selected features in the MapModel and vice versa . |
9,968 | private ListGridField createAttributeGridField ( final AttributeInfo attributeInfo ) { ListGridField gridField = new ListGridField ( attributeInfo . getName ( ) , attributeInfo . getLabel ( ) ) ; gridField . setAlign ( Alignment . LEFT ) ; gridField . setCanEdit ( false ) ; gridField . setShowIfCondition ( new IdentifyingListGridFieldIfFunction ( attributeInfo . isIdentifying ( ) ) ) ; if ( attributeInfo instanceof PrimitiveAttributeInfo ) { PrimitiveAttributeInfo info = ( PrimitiveAttributeInfo ) attributeInfo ; if ( info . getType ( ) . equals ( PrimitiveType . BOOLEAN ) ) { gridField . setType ( ListGridFieldType . BOOLEAN ) ; } else if ( info . getType ( ) . equals ( PrimitiveType . STRING ) ) { gridField . setType ( ListGridFieldType . TEXT ) ; } else if ( info . getType ( ) . equals ( PrimitiveType . DATE ) ) { gridField . setType ( ListGridFieldType . DATE ) ; } else if ( info . getType ( ) . equals ( PrimitiveType . SHORT ) ) { gridField . setType ( ListGridFieldType . INTEGER ) ; } else if ( info . getType ( ) . equals ( PrimitiveType . INTEGER ) ) { gridField . setType ( ListGridFieldType . INTEGER ) ; } else if ( info . getType ( ) . equals ( PrimitiveType . LONG ) ) { gridField . setType ( ListGridFieldType . INTEGER ) ; } else if ( info . getType ( ) . equals ( PrimitiveType . FLOAT ) ) { gridField . setType ( ListGridFieldType . FLOAT ) ; } else if ( info . getType ( ) . equals ( PrimitiveType . DOUBLE ) ) { gridField . setType ( ListGridFieldType . FLOAT ) ; } else if ( info . getType ( ) . equals ( PrimitiveType . IMGURL ) ) { gridField . setType ( ListGridFieldType . IMAGE ) ; if ( showImageAttributeOnHover ) { addCellOverHandler ( new ImageCellHandler ( attributeInfo ) ) ; } } else if ( info . getType ( ) . equals ( PrimitiveType . CURRENCY ) ) { gridField . setType ( ListGridFieldType . TEXT ) ; } else if ( info . getType ( ) . equals ( PrimitiveType . URL ) ) { gridField . setType ( ListGridFieldType . LINK ) ; } } else if ( attributeInfo instanceof AssociationAttributeInfo ) { gridField . setType ( ListGridFieldType . TEXT ) ; } return gridField ; } | Create a single field definition from a attribute definition . |
9,969 | public LinearRing getInteriorRingN ( int n ) { if ( ! isEmpty ( ) ) { if ( interiorRings != null && interiorRings . length > n ) { return interiorRings [ n ] ; } } return null ; } | Get one of the interior LinearRing geometries . i . e . one of the holes . |
9,970 | public int getNumPoints ( ) { if ( isEmpty ( ) ) { return 0 ; } int total = exteriorRing . getNumPoints ( ) ; if ( interiorRings != null ) { for ( LinearRing interiorRing : interiorRings ) { total += interiorRing . getNumPoints ( ) ; } } return total ; } | Return the sum of all points in the exterior ring + the total number of points in all the interior rings . |
9,971 | public double getArea ( ) { double area = 0 ; if ( ! isEmpty ( ) ) { area = exteriorRing . getArea ( ) ; if ( interiorRings != null ) { for ( LinearRing interiorRing : interiorRings ) { area -= interiorRing . getArea ( ) ; } } } return area ; } | Return the shell area minus holes areas . |
9,972 | public double getLength ( ) { double length = 0 ; if ( ! isEmpty ( ) ) { length = exteriorRing . getLength ( ) ; if ( interiorRings != null ) { for ( LinearRing interiorRing : interiorRings ) { length += interiorRing . getLength ( ) ; } } } return length ; } | Return the total length of all rings . |
9,973 | public Coordinate [ ] getCoordinates ( ) { if ( isEmpty ( ) ) { return null ; } int len = getNumPoints ( ) ; Coordinate [ ] coordinates = new Coordinate [ len ] ; int count ; for ( count = 0 ; count < exteriorRing . getNumPoints ( ) ; count ++ ) { coordinates [ count ] = exteriorRing . getCoordinateN ( count ) ; } if ( interiorRings != null ) { for ( LinearRing interiorRing : interiorRings ) { for ( int n = 0 ; n < interiorRing . getNumPoints ( ) ; n ++ ) { coordinates [ count ++ ] = interiorRing . getCoordinateN ( n ) ; } } } return coordinates ; } | Return the concatenated coordinates of both the exterior ring and all the interior rings . If the polygon is empty null will be returned . |
9,974 | public boolean intersects ( Geometry geometry ) { if ( isEmpty ( ) ) { return false ; } if ( exteriorRing . intersects ( geometry ) ) { return true ; } if ( interiorRings != null ) { for ( LinearRing interiorRing : interiorRings ) { if ( interiorRing . intersects ( geometry ) ) { return true ; } } } return false ; } | Does this polygon intersects with the given geometry? |
9,975 | public Coordinate snap ( Coordinate coordinate ) { if ( rules == null || mapModel == null ) { return coordinate ; } Coordinate snappedCoordinate = coordinate ; double snappedDistance = Double . MAX_VALUE ; for ( SnappingRuleInfo rule : rules ) { if ( rule . getType ( ) != SnappingType . CLOSEST_ENDPOINT && rule . getType ( ) != SnappingType . NEAREST_POINT ) { throw new IllegalArgumentException ( "Unknown snapping rule type was found: " + rule . getType ( ) ) ; } VectorLayer snapLayer ; try { snapLayer = mapModel . getVectorLayer ( rule . getLayerId ( ) ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Target snapping layer (" + rule . getLayerId ( ) + ") was not a vector layer." ) ; } SnapMode tempMode = this . mode ; if ( snapLayer . getLayerInfo ( ) . getLayerType ( ) != LayerType . POLYGON && snapLayer . getLayerInfo ( ) . getLayerType ( ) != LayerType . MULTIPOLYGON ) { tempMode = SnapMode . ALL_GEOMETRIES_EQUAL ; } SnappingMode handler ; if ( tempMode == SnapMode . ALL_GEOMETRIES_EQUAL ) { handler = new EqualSnappingMode ( rule ) ; } else { handler = new IntersectPriorityMode ( rule ) ; } handler . setCoordinate ( coordinate ) ; iterateFeatures ( snapLayer , handler ) ; if ( handler . getDistance ( ) < snappedDistance ) { snappedCoordinate = handler . getSnappedCoordinate ( ) ; snappedDistance = handler . getDistance ( ) ; } } return snappedCoordinate ; } | Execute the actual snapping! |
9,976 | public static ToolbarBaseAction getToolbarAction ( String key , MapWidget mapWidget ) { ToolCreator toolCreator = REGISTRY . get ( key ) ; if ( null == toolCreator ) { return null ; } return toolCreator . createTool ( mapWidget ) ; } | Get the toolbar action which matches the given key . |
9,977 | public Geometry createGeometry ( Geometry geometry ) { if ( geometry instanceof Point ) { return createPoint ( geometry . getCoordinate ( ) ) ; } else if ( geometry instanceof LinearRing ) { return createLinearRing ( geometry . getCoordinates ( ) ) ; } else if ( geometry instanceof LineString ) { return createLineString ( geometry . getCoordinates ( ) ) ; } else if ( geometry instanceof Polygon ) { Polygon polygon = ( Polygon ) geometry ; LinearRing exteriorRing = createLinearRing ( polygon . getExteriorRing ( ) . getCoordinates ( ) ) ; LinearRing [ ] interiorRings = new LinearRing [ polygon . getNumInteriorRing ( ) ] ; for ( int n = 0 ; n < polygon . getNumInteriorRing ( ) ; n ++ ) { interiorRings [ n ] = createLinearRing ( polygon . getInteriorRingN ( n ) . getCoordinates ( ) ) ; } return new Polygon ( srid , precision , exteriorRing , interiorRings ) ; } else if ( geometry instanceof MultiPoint ) { Point [ ] clones = new Point [ geometry . getNumGeometries ( ) ] ; for ( int n = 0 ; n < geometry . getNumGeometries ( ) ; n ++ ) { clones [ n ] = createPoint ( geometry . getGeometryN ( n ) . getCoordinate ( ) ) ; } return new MultiPoint ( srid , precision , clones ) ; } else if ( geometry instanceof MultiLineString ) { LineString [ ] clones = new LineString [ geometry . getNumGeometries ( ) ] ; for ( int n = 0 ; n < geometry . getNumGeometries ( ) ; n ++ ) { clones [ n ] = createLineString ( geometry . getGeometryN ( n ) . getCoordinates ( ) ) ; } return new MultiLineString ( srid , precision , clones ) ; } else if ( geometry instanceof MultiPolygon ) { Polygon [ ] clones = new Polygon [ geometry . getNumGeometries ( ) ] ; for ( int n = 0 ; n < geometry . getNumGeometries ( ) ; n ++ ) { clones [ n ] = ( Polygon ) createGeometry ( geometry . getGeometryN ( n ) ) ; } return new MultiPolygon ( srid , precision , clones ) ; } return null ; } | Create a new geometry from an existing geometry . This will basically create a clone . |
9,978 | protected void updateGui ( ) { ButtonLayoutStyle buttonButtonLayoutStyle = buttonAction . getButtonLayoutStyle ( ) ; if ( ButtonLayoutStyle . ICON_TITLE_AND_DESCRIPTION . equals ( buttonButtonLayoutStyle ) ) { buildGuiWithDescription ( ) ; } else { setWidth ( 50 ) ; if ( titleAlignment . equals ( TitleAlignment . BOTTOM ) ) { setHeight100 ( ) ; outer = new VStack ( ) ; outer . setOverflow ( Overflow . VISIBLE ) ; outer . setWidth ( GuwLayout . ribbonButtonWidth ) ; outer . setAutoHeight ( ) ; outer . addMember ( icon ) ; if ( showTitles && ! GuwLayout . hideRibbonTitles ) { titleLabel . setBaseStyle ( getBaseStyle ( ) + "LargeTitle" ) ; titleLabel . setAutoHeight ( ) ; titleLabel . setWidth ( GuwLayout . ribbonButtonWidth ) ; outer . addMember ( titleLabel ) ; } outer . setAlign ( Alignment . CENTER ) ; } else { setAutoHeight ( ) ; outer = new HStack ( GuwLayout . ribbonButtonInnerMargin ) ; outer . setOverflow ( Overflow . VISIBLE ) ; outer . setWidth100 ( ) ; outer . setAutoHeight ( ) ; outer . addMember ( icon ) ; if ( showTitles ) { titleLabel . setBaseStyle ( getBaseStyle ( ) + "SmallTitle" ) ; titleLabel . setAutoHeight ( ) ; titleLabel . setAutoWidth ( ) ; outer . addMember ( titleLabel ) ; } } } } | Update the GUI to reflect the settings . |
9,979 | public void setUp ( ) { defineApplicationLocales ( ) ; clearKeys ( ) ; List < Key > keys = new ArrayList < > ( ) ; keys . add ( createKey ( KEY_DEFAULT , false , false , false ) ) ; Key outdatedKey = createKey ( KEY_OUTDATED , false , false , false ) ; outdatedKey . setOutdated ( ) ; keys . add ( outdatedKey ) ; keys . add ( createKey ( KEY_TLN_APPROX , true , false , false ) ) ; keys . add ( createKey ( KEY_TLN_OUTDATED , false , true , false ) ) ; keys . add ( createKey ( KEY_TLN_MISSING , false , false , true ) ) ; Key key = keyFactory . createKey ( KEY_WITH_MISSING_TRANSLATION ) ; key . addTranslation ( FR , TRANSLATION_FR ) ; keys . add ( key ) ; for ( Key keyToPersist : keys ) { keyRepository . add ( keyToPersist ) ; } } | Initializes the test . |
9,980 | public void get_missing_default_translation ( ) { KeySearchCriteria criteria = new KeySearchCriteria ( true , null , null , null ) ; PaginatedView < KeyRepresentation > keyRepresentations = keyFinder . findKeysWithTheirDefaultTranslation ( FIRST_RANGE , criteria ) ; assertThat ( keyRepresentations . getPageSize ( ) ) . isEqualTo ( 2 ) ; KeyRepresentation representation = keyRepresentations . getView ( ) . get ( 0 ) ; assertThat ( StringUtils . isBlank ( representation . getTranslation ( ) ) ) . isTrue ( ) ; } | Request all the keys marked as missing . |
9,981 | public void get_approx_default_translation ( ) { KeySearchCriteria criteria = new KeySearchCriteria ( null , true , null , null ) ; PaginatedView < KeyRepresentation > keyRepresentations = keyFinder . findKeysWithTheirDefaultTranslation ( FIRST_RANGE , criteria ) ; assertThat ( keyRepresentations . getPageSize ( ) ) . isEqualTo ( 1 ) ; KeyRepresentation representation = keyRepresentations . getView ( ) . get ( 0 ) ; assertThat ( representation . getDefaultLocale ( ) ) . isEqualTo ( EN ) ; assertThat ( representation . getTranslation ( ) ) . isEqualTo ( TRANSLATION_EN ) ; } | Request all the keys marked as approximate . |
9,982 | protected void updateShowing ( boolean fireEvents ) { double scale = mapModel . getMapView ( ) . getCurrentScale ( ) ; if ( visible ) { boolean oldShowing = showing ; showing = scale >= layerInfo . getMinimumScale ( ) . getPixelPerUnit ( ) && scale <= layerInfo . getMaximumScale ( ) . getPixelPerUnit ( ) ; if ( oldShowing != showing && fireEvents ) { handlerManager . fireEvent ( new LayerShownEvent ( this , true ) ) ; } } else { showing = false ; } } | Update showing state . |
9,983 | public void setVisible ( boolean visible ) { if ( visible != this . visible ) { this . visible = visible ; updateShowing ( false ) ; handlerManager . fireEvent ( new LayerShownEvent ( this ) ) ; } } | Make the layer visible or invisible . |
9,984 | public static void mergeAndBufferGeometries ( List < Geometry > geometries , double buffer , final DataCallback < Geometry [ ] > onFinished ) { GeometryUtilsRequest request = new GeometryUtilsRequest ( ) ; request . setActionFlags ( GeometryUtilsRequest . ACTION_BUFFER | GeometryUtilsRequest . ACTION_MERGE ) ; request . setIntermediateResults ( true ) ; request . setBuffer ( buffer ) ; request . setGeometries ( toDtoGeometries ( geometries ) ) ; GwtCommand command = new GwtCommand ( GeometryUtilsRequest . COMMAND ) ; command . setCommandRequest ( request ) ; GwtCommandDispatcher . getInstance ( ) . execute ( command , new AbstractCommandCallback < GeometryUtilsResponse > ( ) { public void execute ( GeometryUtilsResponse response ) { if ( onFinished != null ) { Geometry [ ] geoms = new Geometry [ 2 ] ; geoms [ 0 ] = GeometryConverter . toGwt ( response . getGeometries ( ) [ 0 ] ) ; geoms [ 1 ] = GeometryConverter . toGwt ( response . getGeometries ( ) [ 1 ] ) ; onFinished . execute ( geoms ) ; } } } ) ; } | The returned result will contain a merged - only and a merged and buffered result . |
9,985 | public static void searchByCriterion ( final Criterion criterion , final MapWidget mapWidget , final DataCallback < Map < VectorLayer , List < Feature > > > onFinished , final Runnable onError ) { FeatureSearchRequest request = new FeatureSearchRequest ( ) ; request . setMapCrs ( mapWidget . getMapModel ( ) . getCrs ( ) ) ; request . setCriterion ( criterion ) ; request . setLayerFilters ( getLayerFiltersForCriterion ( criterion , mapWidget . getMapModel ( ) ) ) ; request . setFeatureIncludes ( featureIncludes ) ; request . setMax ( searchResultSize ) ; GwtCommand commandRequest = new GwtCommand ( FeatureSearchRequest . COMMAND ) ; commandRequest . setCommandRequest ( request ) ; GwtCommandDispatcher . getInstance ( ) . execute ( commandRequest , new AbstractCommandCallback < FeatureSearchResponse > ( ) { public void execute ( FeatureSearchResponse response ) { onFinished . execute ( convertFromDto ( response . getFeatureMap ( ) , mapWidget . getMapModel ( ) ) ) ; } public void onCommunicationException ( Throwable error ) { if ( null != onError ) { onError . run ( ) ; } else { super . onCommunicationException ( error ) ; } } } ) ; } | Execute a search by criterion command . |
9,986 | public static Map < String , String > getLayerFiltersForCriterion ( Criterion critter , MapModel mapModel ) { Map < String , String > filters = new HashMap < String , String > ( ) ; Set < String > serverLayerIds = new HashSet < String > ( ) ; critter . serverLayerIdVisitor ( serverLayerIds ) ; for ( VectorLayer vectorLayer : mapModel . getVectorLayers ( ) ) { if ( serverLayerIds . contains ( vectorLayer . getServerLayerId ( ) ) ) { if ( vectorLayer . getFilter ( ) != null && ! "" . equals ( vectorLayer . getFilter ( ) ) ) { filters . put ( vectorLayer . getServerLayerId ( ) , vectorLayer . getFilter ( ) ) ; } } } return filters ; } | Builds a map with the filters for all layers that are used in the given criterion . |
9,987 | private static Map < VectorLayer , List < Feature > > convertFromDto ( Map < String , List < org . geomajas . layer . feature . Feature > > dtoFeatures , MapModel model ) { Map < VectorLayer , List < Feature > > result = new LinkedHashMap < VectorLayer , List < Feature > > ( ) ; for ( Entry < String , List < org . geomajas . layer . feature . Feature > > entry : dtoFeatures . entrySet ( ) ) { if ( ! entry . getValue ( ) . isEmpty ( ) ) { List < Feature > convertedFeatures = new ArrayList < Feature > ( ) ; VectorLayer layer = convertFromDto ( entry . getKey ( ) , entry . getValue ( ) , convertedFeatures , model ) ; if ( layer != null ) { result . put ( layer , convertedFeatures ) ; } else { GWT . log ( "Couldn't find layer client-side ?? " + entry . getKey ( ) ) ; } } } return result ; } | This also adds the features to their respective layers so no need to do that anymore . |
9,988 | public UrlBuilder addPath ( String path ) { if ( path . charAt ( 0 ) == '/' && baseUrl . endsWith ( "/" ) ) { baseUrl = baseUrl + path . substring ( 1 ) ; } else { baseUrl = baseUrl + path ; } return this ; } | Add a path extension . |
9,989 | @ Produces ( MediaType . APPLICATION_JSON ) @ RequiresPermissions ( I18nPermissions . LOCALE_READ ) public Response getAvailableLocales ( ) { List < LocaleRepresentation > availableLocales = localeFinder . findAvailableLocales ( ) ; if ( ! availableLocales . isEmpty ( ) ) { return Response . ok ( availableLocales ) . build ( ) ; } return Response . noContent ( ) . build ( ) ; } | Gets all the locales available in the application . |
9,990 | @ Path ( "/{localeId}" ) @ Produces ( MediaType . APPLICATION_JSON ) @ RequiresPermissions ( I18nPermissions . LOCALE_READ ) public Response getAvailableLocale ( @ PathParam ( "localeId" ) String localeId ) { WebAssertions . assertNotBlank ( localeId , LOCALE_SHOULD_NOT_BE_BLANK ) ; LocaleRepresentation availableLocale = localeFinder . findAvailableLocale ( localeId ) ; if ( availableLocale != null ) { return Response . ok ( availableLocale ) . build ( ) ; } return Response . status ( Response . Status . NOT_FOUND ) . build ( ) ; } | Gets the requested locale if it is available in the application . |
9,991 | public boolean isPannableFrom ( MapViewState other ) { return Math . abs ( scale - other . getScale ( ) ) < EQUAL_CHECK_DELTA && Math . abs ( getPanX ( ) - other . getPanX ( ) ) < EQUAL_CHECK_DELTA && Math . abs ( getPanY ( ) - other . getPanY ( ) ) < EQUAL_CHECK_DELTA ; } | Can this view state be reached by panning from another view state ? |
9,992 | public void setOpacity ( double opacity ) { getLayerInfo ( ) . setStyle ( Double . toString ( opacity ) ) ; handlerManager . fireEvent ( new LayerStyleChangeEvent ( this ) ) ; } | Apply a new opacity on the entire raster layer . |
9,993 | public Coordinate viewToPan ( Coordinate coordinate ) { if ( coordinate != null ) { Vector2D position = new Vector2D ( coordinate ) ; double scale = mapView . getCurrentScale ( ) ; Coordinate panOrigin = mapView . getPanOrigin ( ) ; double translateX = ( mapView . getViewState ( ) . getX ( ) - panOrigin . getX ( ) ) * scale - ( mapView . getWidth ( ) / 2 ) ; double translateY = - ( mapView . getViewState ( ) . getY ( ) - panOrigin . getY ( ) ) * scale - ( mapView . getHeight ( ) / 2 ) ; position . translate ( translateX , translateY ) ; return new Coordinate ( position . getX ( ) , position . getY ( ) ) ; } return null ; } | Transform a coordinate from view space to pan space . |
9,994 | public Coordinate viewToWorld ( Coordinate coordinate ) { if ( coordinate != null ) { Vector2D position = new Vector2D ( coordinate ) ; double inverseScale = 1 / mapView . getCurrentScale ( ) ; position . scale ( inverseScale , - inverseScale ) ; Bbox bounds = mapView . getBounds ( ) ; double translateX = - mapView . getViewState ( ) . getX ( ) + ( bounds . getWidth ( ) / 2 ) ; double translateY = - mapView . getViewState ( ) . getY ( ) - ( bounds . getHeight ( ) / 2 ) ; position . translate ( - translateX , - translateY ) ; return new Coordinate ( position . getX ( ) , position . getY ( ) ) ; } return null ; } | Transform a coordinate from view space to world space . |
9,995 | public void setMapSize ( int mapWidth , int mapHeight ) { double x = horizontalMargin ; double y = verticalMargin ; switch ( alignment ) { case LEFT : break ; case CENTER : x = Math . round ( ( mapWidth - width ) / 2 ) ; break ; case RIGHT : x = mapWidth - width - horizontalMargin ; } switch ( verticalAlignment ) { case TOP : break ; case CENTER : y = Math . round ( ( mapHeight - height ) / 2 ) ; break ; case BOTTOM : y = mapHeight - height - verticalMargin ; } upperLeftCorner = new Coordinate ( x , y ) ; } | Apply a new width and height for the map onto whom this add - on is drawn . This method is triggered automatically when the map resizes . |
9,996 | public static boolean lineIntersects ( Coordinate c1 , Coordinate c2 , Coordinate c3 , Coordinate c4 ) { LineSegment ls1 = new LineSegment ( c1 , c2 ) ; LineSegment ls2 = new LineSegment ( c3 , c4 ) ; return ls1 . intersects ( ls2 ) ; } | Calculates whether or not 2 line - segments intersect . |
9,997 | public Coordinate lineSegmentIntersection ( Coordinate c1 , Coordinate c2 , Coordinate c3 , Coordinate c4 ) { LineSegment ls1 = new LineSegment ( c1 , c2 ) ; LineSegment ls2 = new LineSegment ( c3 , c4 ) ; return ls1 . getIntersectionSegments ( ls2 ) ; } | Calculates the intersection point of 2 line segments . |
9,998 | public static double distance ( Coordinate c1 , Coordinate c2 , Coordinate c3 ) { LineSegment ls = new LineSegment ( c1 , c2 ) ; return ls . distance ( c3 ) ; } | Distance between a point and a line . |
9,999 | public Matrix getWorldToViewTransformation ( ) { if ( viewState . getScale ( ) > 0 ) { double dX = - ( viewState . getX ( ) * viewState . getScale ( ) ) + width / 2 ; double dY = viewState . getY ( ) * viewState . getScale ( ) + height / 2 ; return new Matrix ( viewState . getScale ( ) , 0 , 0 , - viewState . getScale ( ) , dX , dY ) ; } return new Matrix ( 1 , 0 , 0 , 1 , 0 , 0 ) ; } | Return the world - to - view space transformation matrix . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.