idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
10,000
public Matrix getWorldToPanTransformation ( ) { if ( viewState . getScale ( ) > 0 ) { double dX = - ( viewState . getPanX ( ) * viewState . getScale ( ) ) ; double dY = viewState . getPanY ( ) * viewState . getScale ( ) ; return new Matrix ( viewState . getScale ( ) , 0 , 0 , - viewState . getScale ( ) , dX , dY ) ; } return new Matrix ( 1 , 0 , 0 , 1 , 0 , 0 ) ; }
Return the world - to - pan space translation matrix .
10,001
public Matrix getPanToViewTranslation ( ) { if ( viewState . getScale ( ) > 0 ) { double dX = - ( ( viewState . getX ( ) - viewState . getPanX ( ) ) * viewState . getScale ( ) ) + width / 2 ; double dY = ( viewState . getY ( ) - viewState . getPanY ( ) ) * viewState . getScale ( ) + height / 2 ; return new Matrix ( 1 , 0 , 0 , 1 , dX , dY ) ; } return new Matrix ( 1 , 0 , 0 , 1 , 0 , 0 ) ; }
Return the translation of coordinates relative to the pan origin to view coordinates .
10,002
public Matrix getWorldToPanTranslation ( ) { if ( viewState . getScale ( ) > 0 ) { double dX = - ( viewState . getPanX ( ) * viewState . getScale ( ) ) ; double dY = viewState . getPanY ( ) * viewState . getScale ( ) ; return new Matrix ( 1 , 0 , 0 , 1 , dX , dY ) ; } return new Matrix ( 1 , 0 , 0 , 1 , 0 , 0 ) ; }
Return the translation of scaled world coordinates to coordinates relative to the pan origin .
10,003
public Matrix getWorldToViewScaling ( ) { if ( viewState . getScale ( ) > 0 ) { return new Matrix ( viewState . getScale ( ) , 0 , 0 , - viewState . getScale ( ) , 0 , 0 ) ; } return new Matrix ( 1 , 0 , 0 , 1 , 0 , 0 ) ; }
Return the world - to - view space translation matrix .
10,004
public void setSize ( int newWidth , int newHeight ) { saveState ( ) ; Bbox bbox = getBounds ( ) ; if ( width != newWidth || height != newHeight ) { this . width = newWidth ; this . height = newHeight ; if ( viewState . getScale ( ) < getMinimumScale ( ) ) { double scale = getBestScale ( bbox ) ; doSetScale ( snapToResolution ( scale , ZoomOption . LEVEL_FIT ) ) ; } doSetOrigin ( bbox . getCenterPoint ( ) ) ; fireEvent ( true , null ) ; } }
Set the size of the map in pixels .
10,005
public void translate ( double x , double y ) { saveState ( ) ; doSetOrigin ( new Coordinate ( viewState . getX ( ) + x , viewState . getY ( ) + y ) ) ; fireEvent ( false , null ) ; }
Move the view on the map . This happens by translating the camera in turn .
10,006
public void scale ( double delta , ZoomOption option , Coordinate center ) { setCurrentScale ( viewState . getScale ( ) * delta , option , center ) ; }
Adjust the current scale on the map by a new factor keeping a coordinate in place .
10,007
public Bbox getBounds ( ) { double w = getViewSpaceWidth ( ) ; double h = getViewSpaceHeight ( ) ; double x = viewState . getX ( ) - w / 2 ; double y = viewState . getY ( ) - h / 2 ; return new Bbox ( x , y , w , h ) ; }
Given the information in this MapView object what is the currently visible area?
10,008
private void fireEvent ( boolean resized , ZoomOption option ) { if ( width > 0 ) { boolean sameScale = lastViewState != null && viewState . isPannableFrom ( lastViewState ) ; handlerManager . fireEvent ( new MapViewChangedEvent ( getBounds ( ) , getCurrentScale ( ) , sameScale , viewState . isPanDragging ( ) , resized , option ) ) ; } }
Fire an event .
10,009
private double snapToResolution ( double scale , ZoomOption option ) { double allowedScale = limitScale ( scale ) ; if ( resolutions != null ) { IndexRange indices = getResolutionRange ( ) ; if ( option == ZoomOption . EXACT || ! indices . isValid ( ) ) { return allowedScale ; } else { int newResolutionIndex = 0 ; double screenResolution = 1.0 / allowedScale ; if ( screenResolution >= resolutions . get ( indices . getMin ( ) ) ) { newResolutionIndex = indices . getMin ( ) ; } else if ( screenResolution <= resolutions . get ( indices . getMax ( ) ) ) { newResolutionIndex = indices . getMax ( ) ; } else { for ( int i = indices . getMin ( ) ; i < indices . getMax ( ) ; i ++ ) { double upper = resolutions . get ( i ) ; double lower = resolutions . get ( i + 1 ) ; if ( screenResolution <= upper && screenResolution > lower ) { if ( option == ZoomOption . LEVEL_FIT ) { newResolutionIndex = i ; break ; } else { if ( ( upper / screenResolution ) > ( screenResolution / lower ) ) { newResolutionIndex = i + 1 ; break ; } else { newResolutionIndex = i ; break ; } } } } } if ( newResolutionIndex == resolutionIndex && option == ZoomOption . LEVEL_CHANGE ) { if ( scale > viewState . getScale ( ) && newResolutionIndex < indices . getMax ( ) ) { newResolutionIndex ++ ; } else if ( scale < viewState . getScale ( ) && newResolutionIndex > indices . getMin ( ) ) { newResolutionIndex -- ; } } resolutionIndex = newResolutionIndex ; return 1.0 / resolutions . get ( resolutionIndex ) ; } } else { return scale ; } }
Finds an optimal scale by snapping to resolutions .
10,010
private Coordinate calcCenterFromPoint ( final Coordinate worldCenter ) { double xCenter = worldCenter . getX ( ) ; double yCenter = worldCenter . getY ( ) ; if ( maxBounds != null ) { Coordinate minCoordinate = maxBounds . getOrigin ( ) ; Coordinate maxCoordinate = maxBounds . getEndPoint ( ) ; if ( BoundsLimitOption . COMPLETELY_WITHIN_MAX_BOUNDS . equals ( viewBoundsLimitOption ) ) { double w = getViewSpaceWidth ( ) / 2 ; double h = getViewSpaceHeight ( ) / 2 ; if ( ( w * 2 ) > maxBounds . getWidth ( ) ) { xCenter = maxBounds . getCenterPoint ( ) . getX ( ) ; } else { if ( ( xCenter - w ) < minCoordinate . getX ( ) ) { xCenter = minCoordinate . getX ( ) + w ; } if ( ( xCenter + w ) > maxCoordinate . getX ( ) ) { xCenter = maxCoordinate . getX ( ) - w ; } } if ( ( h * 2 ) > maxBounds . getHeight ( ) ) { yCenter = maxBounds . getCenterPoint ( ) . getY ( ) ; } else { if ( ( yCenter - h ) < minCoordinate . getY ( ) ) { yCenter = minCoordinate . getY ( ) + h ; } if ( ( yCenter + h ) > maxCoordinate . getY ( ) ) { yCenter = maxCoordinate . getY ( ) - h ; } } } else if ( BoundsLimitOption . CENTER_WITHIN_MAX_BOUNDS . equals ( viewBoundsLimitOption ) ) { Coordinate center = new Coordinate ( xCenter , yCenter ) ; if ( ! maxBounds . contains ( center ) ) { if ( xCenter < minCoordinate . getX ( ) ) { xCenter = minCoordinate . getX ( ) ; } else if ( xCenter > maxCoordinate . getX ( ) ) { xCenter = maxCoordinate . getX ( ) ; } if ( yCenter < minCoordinate . getY ( ) ) { yCenter = minCoordinate . getY ( ) ; } else if ( yCenter > maxCoordinate . getY ( ) ) { yCenter = maxCoordinate . getY ( ) ; } } } } return new Coordinate ( xCenter , yCenter ) ; }
Adjusts the center point of the map to an allowed center point . This method tries to make sure the whole map extent is inside the maximum allowed bounds .
10,011
private void initializeList ( ) { FavouritesCommService . getSearchFavourites ( new DataCallback < List < SearchFavourite > > ( ) { public void execute ( List < SearchFavourite > result ) { favouriteItems . getDataAsRecordList ( ) . removeList ( favouriteItems . getRecords ( ) ) ; for ( SearchFavourite sf : result ) { favouriteItems . addData ( new FavouriteListRecord ( sf ) ) ; } } } ) ; }
get favourites from store
10,012
public Geometry getGeometryN ( int n ) { if ( isEmpty ( ) ) { return null ; } if ( n >= 0 && n < points . length ) { return points [ n ] ; } throw new ArrayIndexOutOfBoundsException ( n ) ; }
Return null if the MultiPoint is empty returns one of the points if the requested index exists throws an exception otherwise .
10,013
public Bbox getBounds ( ) { if ( isEmpty ( ) ) { return null ; } double minX = Double . MAX_VALUE ; double minY = Double . MAX_VALUE ; double maxX = - Double . MAX_VALUE ; double maxY = - Double . MAX_VALUE ; for ( Point point : points ) { if ( point . getX ( ) < minX ) { minX = point . getX ( ) ; } if ( point . getY ( ) < minY ) { minY = point . getY ( ) ; } if ( point . getX ( ) > maxX ) { maxX = point . getX ( ) ; } if ( point . getY ( ) > maxY ) { maxY = point . getY ( ) ; } } return new Bbox ( minX , minY , maxX - minX , maxY - minY ) ; }
Return the bounding box spanning the full list of points .
10,014
public Coordinate [ ] getCoordinates ( ) { if ( isEmpty ( ) ) { return null ; } Coordinate [ ] coordinates = new Coordinate [ points . length ] ; for ( int i = 0 ; i < points . length ; i ++ ) { coordinates [ i ] = points [ i ] . getCoordinate ( ) ; } return coordinates ; }
Get the full list of coordinates from all the points in this MultiPoint geometry . If this geometry is empty null will be returned .
10,015
public boolean intersects ( Geometry geometry ) { if ( isEmpty ( ) ) { return false ; } for ( Point point : points ) { if ( point . intersects ( geometry ) ) { return true ; } } return false ; }
Return true if any of the points intersect the given geometry .
10,016
public void addFeatures ( Map < VectorLayer , List < Feature > > featureMap , Criterion criterion ) { if ( showDetailsOnSingleResult && featureMap . size ( ) == 1 ) { List < Feature > features = featureMap . values ( ) . iterator ( ) . next ( ) ; if ( features . size ( ) == 1 ) { showFeatureDetailWindow ( map , features . get ( 0 ) ) ; } } for ( VectorLayer layer : map . getMapModel ( ) . getVectorLayers ( ) ) { if ( featureMap . containsKey ( layer ) ) { addFeatures ( layer , featureMap . get ( layer ) , criterion ) ; } } tabset . selectTab ( 0 ) ; }
Add features in the widget for several layers .
10,017
public ListGridRecord [ ] getSelection ( String layerId ) { String id = tabset . getID ( ) + "_" + constructIdSaveLayerId ( layerId ) ; FeatureListGridTab tab = ( FeatureListGridTab ) tabset . getTab ( id ) ; if ( tab != null ) { return tab . getSelection ( ) ; } return null ; }
Get the selected records for the tab .
10,018
public static boolean isBlank ( Object o ) { if ( o instanceof CharSequence ) { CharSequence cs = ( CharSequence ) o ; return cs == null || new StringBuilder ( cs . length ( ) ) . append ( cs ) . toString ( ) . trim ( ) . isEmpty ( ) ; } if ( o instanceof Iterable ) { Iterable < ? > iter = ( Iterable < ? > ) o ; return iter == null || ! iter . iterator ( ) . hasNext ( ) ; } if ( o instanceof Iterator ) { Iterator < ? > iter = ( Iterator < ? > ) o ; return iter == null || ! iter . hasNext ( ) ; } if ( o instanceof Map ) { Map < ? , ? > map = ( Map < ? , ? > ) o ; return map == null || map . isEmpty ( ) ; } if ( o instanceof Boolean ) { Boolean bool = ( Boolean ) o ; return bool == null || bool . equals ( Boolean . FALSE ) ; } return o == null ; }
Checks if an Object is null blank Iterable blank Iterator blank Map blank CharSequence or Boolean . FALSE .
10,019
public void setFeature ( Feature feature ) { if ( feature != null ) { this . feature = feature ; copyToForm ( this . feature ) ; } else { this . feature = null ; featureForm . clear ( ) ; } }
Apply a new feature onto this widget . The feature will be immediately shown on the attribute form .
10,020
public void onClick ( MenuItemClickEvent event ) { FeatureTransaction ft = mapWidget . getMapModel ( ) . getFeatureEditor ( ) . getFeatureTransaction ( ) ; if ( ft != null && index != null ) { mapWidget . render ( ft , RenderGroup . VECTOR , RenderStatus . DELETE ) ; RemoveCoordinateOp op = new RemoveCoordinateOp ( index ) ; ft . execute ( op ) ; mapWidget . render ( ft , RenderGroup . VECTOR , RenderStatus . ALL ) ; } }
Remove an existing point from the geometry at a given index .
10,021
public void onDoubleClick ( DoubleClickEvent event ) { if ( null != lastClickPosition ) { Bbox bounds = mapWidget . getMapModel ( ) . getMapView ( ) . getBounds ( ) ; double x = lastClickPosition . getX ( ) - ( bounds . getWidth ( ) / 4 ) ; double y = lastClickPosition . getY ( ) - ( bounds . getHeight ( ) / 4 ) ; Bbox newBounds = new Bbox ( x , y , bounds . getWidth ( ) / 2 , bounds . getHeight ( ) / 2 ) ; mapWidget . getMapModel ( ) . getMapView ( ) . applyBounds ( newBounds , ZoomOption . LEVEL_CHANGE ) ; } }
Zoom in to the double - clicked position .
10,022
public void onCommunicationException ( Throwable error ) { String msg = I18nProvider . getGlobal ( ) . commandCommunicationError ( ) + ":\n" + error . getMessage ( ) ; Log . logWarn ( msg , error ) ; SC . warn ( msg ) ; }
Default behaviour for handling a communication exception . Shows a warning window to the user .
10,023
public void onCommandException ( CommandResponse response ) { String message = I18nProvider . getGlobal ( ) . commandError ( ) + ":" ; for ( String error : response . getErrorMessages ( ) ) { message += "\n" + error ; } Log . logWarn ( message ) ; if ( response . getExceptions ( ) == null || response . getExceptions ( ) . size ( ) == 0 ) { SC . warn ( message ) ; } else { ExceptionWindow window = new ExceptionWindow ( response . getExceptions ( ) . get ( 0 ) ) ; window . show ( ) ; } }
Default behaviour for handling a command execution exception . Shows an exception report to the user .
10,024
public void setFeature ( Feature feature ) { List < Feature > features = new ArrayList < Feature > ( ) ; features . add ( feature ) ; LazyLoader . lazyLoad ( features , GeomajasConstant . FEATURE_INCLUDE_ATTRIBUTES , new LazyLoadCallback ( ) { public void execute ( List < Feature > response ) { Feature feature = response . get ( 0 ) ; if ( attributeTable == null ) { buildWidget ( feature . getLayer ( ) ) ; } if ( feature != null ) { setTitle ( I18nProvider . getAttribute ( ) . getAttributeWindowTitle ( feature . getLabel ( ) ) ) ; } else { setTitle ( I18nProvider . getAttribute ( ) . getAttributeWindowTitle ( "" ) ) ; } attributeTable . setFeature ( feature ) ; } } ) ; }
Apply a new feature onto this widget assuring the attributes are loaded .
10,025
public void setEditingEnabled ( boolean editingEnabled ) { if ( isEditingAllowed ( ) ) { this . editingEnabled = editingEnabled ; if ( editingEnabled ) { savePanel . setVisible ( true ) ; if ( attributeTable != null && attributeTable . isDisabled ( ) ) { attributeTable . setDisabled ( false ) ; } } else { savePanel . setVisible ( false ) ; if ( attributeTable != null && ! attributeTable . isDisabled ( ) ) { attributeTable . setDisabled ( true ) ; } } } }
Is editing currently enabled or not? This widget can toggle this value on the fly . When editing is enabled it will display an editable attribute form with save cancel and reset buttons . When editing is not enabled these buttons will disappear and a simple attribute form is shown that displays the attribute values but does not allow for editing .
10,026
public static Geometry toDto ( org . geomajas . gwt . client . spatial . geometry . Geometry geometry ) { if ( geometry == null ) { return null ; } int srid = geometry . getSrid ( ) ; int precision = geometry . getPrecision ( ) ; Geometry dto ; if ( geometry instanceof Point ) { dto = new Geometry ( Geometry . POINT , srid , precision ) ; dto . setCoordinates ( geometry . getCoordinates ( ) ) ; } else if ( geometry instanceof LinearRing ) { dto = new Geometry ( Geometry . LINEAR_RING , srid , precision ) ; dto . setCoordinates ( geometry . getCoordinates ( ) ) ; } else if ( geometry instanceof LineString ) { dto = new Geometry ( Geometry . LINE_STRING , srid , precision ) ; dto . setCoordinates ( geometry . getCoordinates ( ) ) ; } else if ( geometry instanceof Polygon ) { dto = new Geometry ( Geometry . POLYGON , srid , precision ) ; Polygon polygon = ( Polygon ) geometry ; if ( ! polygon . isEmpty ( ) ) { Geometry [ ] geometries = new Geometry [ polygon . getNumInteriorRing ( ) + 1 ] ; for ( int i = 0 ; i < geometries . length ; i ++ ) { if ( i == 0 ) { geometries [ i ] = toDto ( polygon . getExteriorRing ( ) ) ; } else { geometries [ i ] = toDto ( polygon . getInteriorRingN ( i - 1 ) ) ; } } dto . setGeometries ( geometries ) ; } } else if ( geometry instanceof MultiPoint ) { dto = new Geometry ( Geometry . MULTI_POINT , srid , precision ) ; dto . setGeometries ( convertGeometries ( geometry ) ) ; } else if ( geometry instanceof MultiLineString ) { dto = new Geometry ( Geometry . MULTI_LINE_STRING , srid , precision ) ; dto . setGeometries ( convertGeometries ( geometry ) ) ; } else if ( geometry instanceof MultiPolygon ) { dto = new Geometry ( Geometry . MULTI_POLYGON , srid , precision ) ; dto . setGeometries ( convertGeometries ( geometry ) ) ; } else { String msg = "GeometryConverter.toDto() unrecognized geometry type" ; Log . logServer ( Log . LEVEL_ERROR , msg ) ; throw new IllegalStateException ( msg ) ; } return dto ; }
Takes in a GWT geometry and creates a new DTO geometry from it .
10,027
public static Bbox toDto ( org . geomajas . gwt . client . spatial . Bbox bbox ) { return new Bbox ( bbox . getX ( ) , bbox . getY ( ) , bbox . getWidth ( ) , bbox . getHeight ( ) ) ; }
Takes in a GWT bbox and creates a new DTO bbox from it .
10,028
public static org . geomajas . gwt . client . spatial . Bbox toGwt ( Bbox bbox ) { return new org . geomajas . gwt . client . spatial . Bbox ( bbox ) ; }
Takes in a DTO bbox and creates a new GWT bbox from it .
10,029
public int sendRpcMessage ( TLMethod request , long timeout , boolean highPriority ) { int id = scheduller . postMessage ( request , true , timeout , highPriority ) ; Logger . d ( TAG , "sendMessage #" + id + " " + request . toString ( ) + " with timeout " + timeout + " ms" ) ; return id ; }
Sending rpc request
10,030
public void switchMode ( int mode ) { if ( this . mode != mode ) { this . mode = mode ; switch ( mode ) { case MODE_GENERAL : case MODE_PUSH : transportPool . switchMode ( TransportPool . MODE_DEFAULT ) ; break ; case MODE_GENERAL_LOW_MODE : case MODE_FILE : transportPool . switchMode ( TransportPool . MODE_LOWMODE ) ; break ; } this . actionsActor . sendOnce ( new RequestPingDelay ( ) ) ; } }
Switch mode of mtproto
10,031
private void onMTMessage ( MTMessage mtMessage ) { if ( mtMessage . getSeqNo ( ) % 2 == 1 ) { scheduller . confirmMessage ( mtMessage . getMessageId ( ) ) ; } if ( ! needProcessing ( mtMessage . getMessageId ( ) ) ) { if ( Logger . LOG_IGNORED ) { Logger . d ( TAG , "Ignoring messages #" + mtMessage . getMessageId ( ) ) ; } return ; } try { TLObject intMessage = protoContext . deserializeMessage ( new ByteArrayInputStream ( mtMessage . getContent ( ) ) ) ; onMTProtoMessage ( mtMessage . getMessageId ( ) , intMessage ) ; } catch ( DeserializeException e ) { callback . onApiMessage ( mtMessage . getContent ( ) , this ) ; } catch ( IOException e ) { Logger . e ( TAG , e ) ; } }
Finding message type
10,032
private List < org . geomajas . layer . tile . RasterTile > calculateTilesForBounds ( Bbox bounds ) { List < org . geomajas . layer . tile . RasterTile > tiles = new ArrayList < org . geomajas . layer . tile . RasterTile > ( ) ; if ( bounds . getHeight ( ) == 0 || bounds . getWidth ( ) == 0 ) { return tiles ; } return tiles ; }
Method based on WmsTileServiceImpl in GWT2 client .
10,033
public void initialize ( ClientMapInfo mapInfo ) { super . removeMembers ( getMembers ( ) ) ; ClientToolbarInfo toolbarInfo = mapInfo . getToolbar ( ) ; if ( toolbarInfo != null ) { for ( ClientToolInfo tool : toolbarInfo . getTools ( ) ) { String id = tool . getToolId ( ) ; if ( ToolId . TOOL_SEPARATOR . equals ( id ) ) { addToolbarSeparator ( ) ; } else { ToolbarBaseAction action = ToolbarRegistry . getToolbarAction ( id , mapWidget ) ; if ( action instanceof ConfigurableAction ) { for ( Parameter parameter : tool . getParameters ( ) ) { ( ( ConfigurableAction ) action ) . configure ( parameter . getName ( ) , parameter . getValue ( ) ) ; } } String description = tool . getDescription ( ) ; if ( null != description && ! "" . equals ( description ) ) { action . setTooltip ( description ) ; } if ( action instanceof ToolbarWidget ) { super . addMember ( ( ( ToolbarWidget ) action ) . getWidget ( ) ) ; } else if ( action instanceof ToolbarCanvas ) { super . addMember ( ( ( ToolbarCanvas ) action ) . getCanvas ( ) ) ; } else if ( action instanceof ToolbarModalAction ) { addModalButton ( ( ToolbarModalAction ) action ) ; } else if ( action instanceof ToolbarAction ) { addActionButton ( ( ToolbarAction ) action ) ; } else { String msg = "Tool with id " + id + " unknown." ; Log . logError ( msg ) ; SC . warn ( msg ) ; } } } } for ( Canvas extra : extraCanvasMembers ) { super . addMember ( extra ) ; } }
Initialize this widget .
10,034
public void addActionButton ( final ToolbarAction action ) { final IButton button = new IButton ( ) ; button . setWidth ( buttonSize ) ; button . setHeight ( buttonSize ) ; button . setIconSize ( buttonSize - WidgetLayout . toolbarStripHeight ) ; button . setIcon ( action . getIcon ( ) ) ; button . setActionType ( SelectionType . BUTTON ) ; button . addClickHandler ( action ) ; button . setShowRollOver ( false ) ; button . setShowFocused ( false ) ; button . setTooltip ( action . getTooltip ( ) ) ; button . setDisabled ( action . isDisabled ( ) ) ; if ( getMembers ( ) != null && getMembers ( ) . length > 0 ) { LayoutSpacer spacer = new LayoutSpacer ( ) ; spacer . setWidth ( 2 ) ; super . addMember ( spacer ) ; } action . addToolbarActionHandler ( new ToolbarActionHandler ( ) { public void onToolbarActionDisabled ( ToolbarActionDisabledEvent event ) { button . setDisabled ( true ) ; } public void onToolbarActionEnabled ( ToolbarActionEnabledEvent event ) { button . setDisabled ( false ) ; } } ) ; super . addMember ( button ) ; }
Add a new action button to the toolbar . An action button is the kind of button that executes immediately when clicked upon . It can not be selected or deselected it just executes every click .
10,035
public void addToolbarSeparator ( ) { ToolStripSeparator stripSeparator = new ToolStripSeparator ( ) ; stripSeparator . setHeight ( WidgetLayout . toolbarStripHeight ) ; super . addMember ( stripSeparator ) ; }
Add a vertical line to the toolbar .
10,036
public void setCoordinate ( Coordinate coordinate ) { if ( coordinate == null ) { throw new IllegalArgumentException ( "Can't snap to a null coordinate." ) ; } this . coordinate = coordinate ; bounds = new Bbox ( coordinate . getX ( ) - rule . getDistance ( ) , coordinate . getY ( ) - rule . getDistance ( ) , rule . getDistance ( ) * 2 , rule . getDistance ( ) * 2 ) ; distance = Double . MAX_VALUE ; snappedCoordinate = coordinate ; }
Set a new coordinate ready to be snapped .
10,037
public static String convertGlobToRegex ( String pattern ) { pattern = pattern . replaceAll ( "[\\\\\\.\\(\\)\\+\\|\\^\\$]" , "\\\\$0" ) ; pattern = pattern . replaceAll ( "\\[\\\\\\^" , "[^" ) ; pattern = Ruby . String . of ( pattern ) . gsub ( "\\{[^\\}]+\\}" , m -> { m = m . replaceAll ( "," , "|" ) ; m = "(" + m . substring ( 1 , m . lastIndexOf ( '}' ) ) + ")" ; return m ; } ) . toS ( ) ; pattern = pattern . replaceAll ( "\\?" , ".{1}" ) ; pattern = pattern . replaceAll ( "\\*\\*/" , "(.+/)?" ) ; pattern = pattern . replaceAll ( "\\*" , "[^/]*" ) ; return pattern ; }
Converts a glob pattern to Regex string .
10,038
public boolean addAdministrator ( String projectId , String name , String email ) { ResponseWrapper wrapper = service . addProjectMember ( Action . ADD_CONTRIBUTOR , apiKey , projectId , name , email , null , 1 ) ; return "200" . equals ( wrapper . response . code ) ; }
Create a new admin for a project
10,039
public TermsDetails addTerms ( String projectId , List < Term > terms ) { String jsonTerms = new Gson ( ) . toJson ( terms ) ; EditTermsResponse atr = service . editTerms ( Action . ADD_TERMS , apiKey , projectId , jsonTerms ) ; ApiUtils . checkResponse ( atr . response ) ; return atr . details ; }
Add new terms to a project
10,040
public File export ( String projectId , String language , FileTypeEnum fte , FilterByEnum [ ] filters ) { return export ( projectId , language , fte , filters , null , null ) ; }
Export a translation for a language of a project .
10,041
public UploadDetails uploadTerms ( String projectId , File translationFile , String [ ] allTags , String [ ] newTags , String [ ] obsoleteTags ) { Map < String , String [ ] > tags = new HashMap < String , String [ ] > ( ) ; if ( allTags != null ) { tags . put ( "all" , allTags ) ; } if ( newTags != null ) { tags . put ( "new" , newTags ) ; } if ( obsoleteTags != null ) { tags . put ( "obsolete" , obsoleteTags ) ; } String tagsStr = new Gson ( ) . toJson ( tags ) ; TypedFile typedFile = new TypedFile ( "application/xml" , translationFile ) ; UploadResponse ur = service . upload ( "upload" , apiKey , projectId , "terms" , typedFile , null , "0" , tagsStr ) ; ApiUtils . checkResponse ( ur . response ) ; return ur . details ; }
Uploads a translation file . For the moment it only takes terms into account .
10,042
private static String decodeLineString ( LineString lineString ) { if ( lineString == null || lineString . isEmpty ( ) ) { return "" ; } StringBuilder buffer = new StringBuilder ( ) ; Coordinate [ ] coordinates = lineString . getCoordinates ( ) ; for ( int i = 0 ; i < coordinates . length ; i ++ ) { buffer . append ( getX ( coordinates [ i ] ) ) ; buffer . append ( " " ) ; buffer . append ( getY ( coordinates [ i ] ) ) ; if ( i < ( coordinates . length - 1 ) ) { buffer . append ( ", " ) ; } } return "M" + buffer . toString ( ) ; }
Decode LineString .
10,043
GeometryIndex [ ] getSelection ( ) { List < GeometryIndex > indices = delegate . getSelection ( ) ; return indices . toArray ( new GeometryIndex [ indices . size ( ) ] ) ; }
Get the current selection . Do not make changes on this list!
10,044
@ SuppressFBWarnings ( value = "NP_BOOLEAN_RETURN_NULL" , justification = "That's the point (but dubious)" ) public static Boolean falseToNull ( Boolean bool ) { if ( bool != null && bool ) { return true ; } return null ; }
If bool is false change it to null otherwise do nothing .
10,045
public static void mixin ( Window window ) { final Docker docker = new Docker ( window ) ; window . addMinimizeClickHandler ( docker ) ; window . addRestoreClickHandler ( docker ) ; }
Add the functionality to an existing window .
10,046
public static HLayout createDefaultDock ( ) { HLayout windowDock = new HLayout ( 5 ) ; windowDock . setHeight ( 22 ) ; windowDock . setAutoWidth ( ) ; windowDock . setSnapTo ( "BL" ) ; windowDock . setSnapOffsetTop ( - 0 ) ; windowDock . setSnapOffsetLeft ( 0 ) ; windowDock . setBorder ( "thin dashed red" ) ; return windowDock ; }
This will create a windowDock based on a HLayout and placed in the dockParent if provided .
10,047
@ Consumes ( "multipart/form-data" ) @ RequiresPermissions ( I18nPermissions . KEY_WRITE ) public Response importTranslations ( FormDataMultiPart multiPart ) { WebAssertions . assertNotNull ( multiPart , "Missing input file" ) ; int importedKeys = 0 ; for ( BodyPart bodyPart : multiPart . getBodyParts ( ) ) { importedKeys += importFile ( bodyPart ) ; } String importedKeysMessage = String . format ( LOADED_KEYS_MESSAGE , importedKeys ) ; LOGGER . debug ( importedKeysMessage ) ; return Response . ok ( importedKeysMessage , MediaType . TEXT_PLAIN_TYPE ) . build ( ) ; }
Imports one or more CSV files containing i18n keys with their translations .
10,048
@ Produces ( MediaType . TEXT_PLAIN ) @ RequiresPermissions ( I18nPermissions . KEY_READ ) public Response exportTranslations ( ) { final List < Key > keys = keyRepository . loadAll ( ) ; return Response . ok ( new StreamingOutput ( ) { private boolean isFirstLine = true ; public void write ( OutputStream os ) throws IOException { Writer writer = new BufferedWriter ( new OutputStreamWriter ( os , "UTF-8" ) ) ; for ( Key key : keys ) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream ( ) ; renderer . render ( byteArrayOutputStream , key , APPLICATION_CSV , printHeader ( isFirstLine ) ) ; writer . write ( byteArrayOutputStream . toString ( "UTF-8" ) ) ; isFirstLine = false ; } writer . flush ( ) ; } } ) . header ( CONTENT_DISPOSITION , ATTACHMENT_FILENAME_I18N_CSV ) . build ( ) ; }
Streams a CSV file with all keys with their translations .
10,049
public static void main ( String [ ] args ) throws IOException { if ( args . length == 0 ) { System . out . println ( "No command given, choose: \n\tinit\n\tpull\n\tpush\n\tpushTerms" ) ; return ; } Map < String , String > parameters = new HashMap < String , String > ( ) ; if ( args . length > 1 ) { for ( String s : args ) { String [ ] splitted = s . split ( "=" ) ; if ( splitted . length == 2 ) { parameters . put ( splitted [ 0 ] , splitted [ 1 ] ) ; } } } Path current = Paths . get ( "" ) ; File configFile = new File ( current . toAbsolutePath ( ) . toString ( ) , "poeditor.properties" ) ; Config config = Config . load ( configFile ) ; BaseTask task = null ; if ( "init" . equals ( args [ 0 ] ) ) { System . out . println ( "Initialize project" ) ; task = new InitTask ( ) ; } else if ( "pull" . equals ( args [ 0 ] ) ) { System . out . println ( "Pull languages" ) ; task = new PullTask ( ) ; } else if ( "push" . equals ( args [ 0 ] ) ) { System . out . println ( "Push languages" ) ; task = new PushTask ( ) ; } else if ( "pushTerms" . equals ( args [ 0 ] ) ) { System . out . println ( "Push terms" ) ; task = new PushTermsTask ( ) ; } else if ( "generate" . equals ( args [ 0 ] ) ) { System . out . println ( "Generate config" ) ; task = new GenerateTask ( ) ; } else if ( "status" . equals ( args [ 0 ] ) ) { System . out . println ( "Status" ) ; task = new StatusTask ( ) ; } if ( task != null ) { task . configure ( config , parameters ) ; task . handle ( ) ; } }
By default read config from current dir
10,050
public void doActivities ( Object seedData ) { List < Activity > activities = getActivities ( ) ; if ( seedData != null ) { context . setSeedData ( seedData ) ; } for ( Activity activity : activities ) { try { context = activity . execute ( context ) ; } catch ( Throwable th ) { WorkflowErrorHandler errorHandler = activity . getErrorHandler ( ) ; if ( errorHandler == null ) { getDefaultErrorHandler ( ) . handleError ( context , th ) ; break ; } else { errorHandler . handleError ( context , th ) ; } } if ( processShouldStop ( context , activity ) ) { break ; } } }
This method kicks off the processing of workflow activities . It goes over them one by one and executes them .
10,051
private boolean processShouldStop ( WorkflowContext workflowContext , Activity activity ) { if ( workflowContext != null && workflowContext . stopProcess ( ) ) { return true ; } return false ; }
Determine if the process should stop
10,052
public static String join ( List < String > parts , String separator ) { Iterator < String > it = parts . iterator ( ) ; StringBuilder builder = new StringBuilder ( ) ; while ( it . hasNext ( ) ) { String part = it . next ( ) ; builder . append ( part ) ; if ( it . hasNext ( ) ) { builder . append ( separator ) ; } } return builder . toString ( ) ; }
Joins a list of strings using the specified separator .
10,053
public static org . geomajas . geometry . Bbox constructor ( double x , double y , double width , double height ) { return new org . geomajas . geometry . Bbox ( x , y , width , height ) ; }
Bbox constructor .
10,054
public static LinkedHashMap < String , String > getSearchWidgetMapping ( ) { LinkedHashMap < String , String > map = new LinkedHashMap < String , String > ( ) ; for ( SearchWidgetCreator swc : REGISTRY . values ( ) ) { map . put ( swc . getSearchWidgetId ( ) , swc . getSearchWidgetName ( ) ) ; } return map ; }
Get a list with all the ids + names of the search widgets in the registry .
10,055
public List < SearchCriterion > getSearchCriteria ( ) { List < SearchCriterion > criteria = new ArrayList < SearchCriterion > ( ) ; for ( AttributeCriterionPane criterionPane : criterionPanes ) { if ( criterionPane . hasErrors ( ) ) { SC . warn ( I18nProvider . getSearch ( ) . warningInvalidCriteria ( ) ) ; return null ; } SearchCriterion criterion = criterionPane . getSearchCriterion ( ) ; if ( criterion != null ) { criteria . add ( criterion ) ; } } if ( criteria . size ( ) == 0 ) { SC . warn ( I18nProvider . getSearch ( ) . warningNoCriteria ( ) ) ; } return criteria ; }
Get the full list of search criteria from the criterion grid .
10,056
public void empty ( ) { searchButton . setDisabled ( true ) ; resetButton . setDisabled ( true ) ; for ( AttributeCriterionPane criterionPane : criterionPanes ) { criterionStack . removeMember ( criterionPane ) ; } criterionPanes . clear ( ) ; for ( HLayout criterionPane : buttonPanes ) { buttonStack . removeMember ( criterionPane ) ; } buttonPanes . clear ( ) ; for ( HandlerRegistration handlerRegistration : addHandlers ) { handlerRegistration . removeHandler ( ) ; } addHandlers . clear ( ) ; for ( HandlerRegistration handlerRegistration : removeHandlers ) { handlerRegistration . removeHandler ( ) ; } removeHandlers . clear ( ) ; addEmptyRow ( 0 ) ; }
Empty the grid thereby removing all rows . When that is done a new empty row will be displayed .
10,057
public void setLogicalOperator ( LogicalOperator operator ) { switch ( operator ) { case AND : logicalOperatorRadio . setValue ( I18nProvider . getSearch ( ) . radioOperatorAnd ( ) ) ; break ; case OR : logicalOperatorRadio . setValue ( I18nProvider . getSearch ( ) . radioOperatorOr ( ) ) ; break ; default : throw new IllegalStateException ( "Unknown operator " + operator ) ; } }
Set a new value for the logical operator . This operator determines whether all the criteria have to be met in the search or just one of them .
10,058
public LogicalOperator getLogicalOperator ( ) { String value = ( String ) logicalOperatorRadio . getValue ( ) ; if ( value . equals ( I18nProvider . getSearch ( ) . radioOperatorAnd ( ) ) ) { return LogicalOperator . AND ; } return LogicalOperator . OR ; }
Return the current value for the logical operator . This operator determines whether all the criteria have to be met in the search or just one of them .
10,059
public void setLayer ( VectorLayer layer ) { this . layer = layer ; Object value = layerSelect . getValue ( ) ; if ( value == null || ! value . equals ( layer . getLabel ( ) ) ) { layerSelect . setValue ( layer . getLabel ( ) ) ; } empty ( ) ; }
Set a new layer onto which searching should happen .
10,060
public void addTranslationDTO ( String locale , String value , boolean outdated , boolean approximate ) { translations . add ( new TranslationDTO ( locale , value , outdated , approximate ) ) ; }
Adds a translation to the keyDTO
10,061
public static String scaleToString ( double scale , int precision , int significantDigits ) { NumberFormat numberFormat = NumberFormat . getFormat ( "###,###" ) ; if ( scale > 0 && scale < 1.0 ) { int denominator = round ( ( int ) Math . round ( 1.0 / scale ) , precision , significantDigits ) ; return "1 : " + numberFormat . format ( denominator ) ; } else if ( scale >= 1.0 ) { int nominator = round ( ( int ) Math . round ( scale ) , precision , significantDigits ) ; return numberFormat . format ( nominator ) + " : 1" ; } else { return ERROR_SCALE ; } }
Convert a scale to a string representation .
10,062
public static Double stringToScale ( String value ) { NumberFormat numberFormat = NumberFormat . getFormat ( "###,###" ) ; String [ ] scale2 = value . split ( ":" ) ; if ( scale2 . length == 1 ) { return 1.0 / numberFormat . parse ( scale2 [ 0 ] . trim ( ) ) ; } else { return numberFormat . parse ( scale2 [ 0 ] . trim ( ) ) / numberFormat . parse ( scale2 [ 1 ] . trim ( ) ) ; } }
Parse scale from string representation .
10,063
static int round ( int value , int precision , int significantDigits ) { if ( precision > 0 ) { value = ( value + precision / 2 ) / precision * precision ; } if ( significantDigits > 0 ) { int forRounding = value ; int precisionMax = ( int ) Math . pow ( 10 , significantDigits ) ; int multiplier = 1 ; while ( value > precisionMax ) { forRounding = value ; multiplier *= 10 ; value /= 10 ; } if ( forRounding % 10 >= 5 ) { value ++ ; } value *= multiplier ; } return value ; }
Round integer number by applying precision and maximum significant digits .
10,064
public synchronized void put ( byte [ ] data ) { references . remove ( data ) ; if ( mainFilter . add ( data ) ) { for ( Integer i : SIZES ) { if ( data . length == i ) { fastBuffers . get ( i ) . add ( data ) ; return ; } } if ( data . length <= MAX_SIZE ) { return ; } byteBuffer . add ( data ) ; } }
Put bytes to cache
10,065
public synchronized byte [ ] allocate ( int minSize ) { if ( minSize <= MAX_SIZE ) { for ( int i = 0 ; i < SIZES . length ; i ++ ) { if ( minSize < SIZES [ i ] ) { if ( ! fastBuffers . get ( SIZES [ i ] ) . isEmpty ( ) ) { Iterator < byte [ ] > interator = fastBuffers . get ( SIZES [ i ] ) . iterator ( ) ; byte [ ] res = interator . next ( ) ; interator . remove ( ) ; mainFilter . remove ( res ) ; if ( TRACK_ALLOCATIONS ) { references . put ( res , Thread . currentThread ( ) . getStackTrace ( ) ) ; } return res ; } return new byte [ SIZES [ i ] ] ; } } } else { byte [ ] res = null ; for ( byte [ ] cached : byteBuffer ) { if ( cached . length < minSize ) { continue ; } if ( res == null ) { res = cached ; } else if ( res . length > cached . length ) { res = cached ; } } if ( res != null ) { byteBuffer . remove ( res ) ; mainFilter . remove ( res ) ; if ( TRACK_ALLOCATIONS ) { references . put ( res , Thread . currentThread ( ) . getStackTrace ( ) ) ; } return res ; } } return new byte [ minSize ] ; }
Allocating new byte array with minimal size
10,066
public static OwncloudFileResource toOwncloudFileResource ( OwncloudResource owncloudResource ) throws OwncloudNoFileResourceException { if ( owncloudResource == null ) { return null ; } if ( isDirectory ( owncloudResource ) || ! ClassUtils . isAssignable ( owncloudResource . getClass ( ) , OwncloudFileResource . class ) ) { throw new OwncloudNoFileResourceException ( owncloudResource . getHref ( ) ) ; } return ( OwncloudFileResource ) owncloudResource ; }
Convert a OwncloudResource to a OwncloudFileResource .
10,067
public static boolean isDirectory ( OwncloudResource owncloudResource ) { return UNIX_DIRECTORY . equals ( Optional . ofNullable ( owncloudResource ) . map ( resource -> resource . getMediaType ( ) . toString ( ) ) . orElse ( null ) ) ; }
Checks if the OwncloudResource is a Directory
10,068
public void refresh ( ) { if ( layer instanceof RasterLayer ) { RasterLayer rLayer = ( RasterLayer ) layer ; rLayer . setVisible ( false ) ; rLayer . getStore ( ) . clear ( ) ; rLayer . setVisible ( true ) ; } else if ( layer instanceof org . geomajas . gwt . client . map . layer . VectorLayer ) { org . geomajas . gwt . client . map . layer . VectorLayer vl = ( org . geomajas . gwt . client . map . layer . VectorLayer ) layer ; vl . setVisible ( false ) ; vl . clearSelectedFeatures ( ) ; vl . getFeatureStore ( ) . clear ( ) ; vl . setVisible ( true ) ; } }
Completely clear all rendering of this layer and redraw .
10,069
public static boolean hasConstructorInTheCorrectForm ( Class < ? > clazz ) { if ( clazz . getConstructors ( ) . length != 1 ) { return false ; } Constructor < ? > con = clazz . getConstructors ( ) [ 0 ] ; if ( con . getParameterTypes ( ) . length == 0 ) { return false ; } Annotation [ ] [ ] parameterAnnotations = con . getParameterAnnotations ( ) ; for ( Annotation [ ] as : parameterAnnotations ) { if ( ! hasColumnAnnotation ( as ) ) { return false ; } } return true ; }
Check if the given class has the correct form .
10,070
private Composite getOrCreateGroup ( Object parent , String name ) { if ( groups . containsKey ( name ) ) { return groups . get ( name ) ; } Composite group = new Composite ( name ) ; mapWidget . getVectorContext ( ) . drawGroup ( parent , group ) ; groups . put ( name , group ) ; return group ; }
Used in creating the edges selection and vertices groups for LineStrings and LinearRings .
10,071
public void onDraw ( ) { map . getVectorContext ( ) . setController ( parent , getId ( ) , controller , Event . MOUSEEVENTS ) ; map . getVectorContext ( ) . setCursor ( parent , getId ( ) , Cursor . POINTER . getValue ( ) ) ; }
When this pan button is drawn for the first time add a pan controller to it that reacts on the click event .
10,072
public static void assertNotBlank ( String actual , String message ) { if ( StringUtils . isBlank ( actual ) ) { throw new BadRequestException ( message ) ; } }
Throws a BadRequestException if actual is null .
10,073
public void onModuleLoad ( ) { ToolbarRegistry . put ( RasterizingToolId . GET_LEGEND_IMAGE , new ToolCreator ( ) { public ToolbarBaseAction createTool ( MapWidget mapWidget ) { return new GetLegendImageAction ( mapWidget ) ; } } ) ; ToolbarRegistry . put ( RasterizingToolId . GET_MAP_IMAGE , new ToolCreator ( ) { public ToolbarBaseAction createTool ( MapWidget mapWidget ) { return new GetMapImageAction ( mapWidget ) ; } } ) ; }
Registers toolbar actions .
10,074
public static byte [ ] toArray ( Collection < ? extends Number > bytes ) { byte [ ] array = new byte [ bytes . size ( ) ] ; Iterator < ? extends Number > iter = bytes . iterator ( ) ; for ( int i = 0 ; i < bytes . size ( ) ; i ++ ) { array [ i ] = iter . next ( ) . byteValue ( ) ; } return array ; }
Converts a Collection of Number to a byte array .
10,075
public static byte [ ] ljust ( byte [ ] bytes , int width ) { if ( bytes . length >= width ) { return Arrays . copyOf ( bytes , width ) ; } else { byte [ ] ljustied = new byte [ width ] ; System . arraycopy ( bytes , 0 , ljustied , 0 , bytes . length ) ; return ljustied ; } }
Modifies the length of a byte array by padding zero bytes to the right .
10,076
public static byte [ ] rjust ( byte [ ] bytes , int width ) { if ( bytes . length >= width ) { return Arrays . copyOfRange ( bytes , bytes . length - width , bytes . length ) ; } else { byte [ ] rjustied = new byte [ width ] ; System . arraycopy ( bytes , 0 , rjustied , width - bytes . length , bytes . length ) ; return rjustied ; } }
Modifies the length of a byte array by padding zero bytes to the left .
10,077
public static void reverse ( byte [ ] bytes ) { for ( int i = 0 ; i < bytes . length / 2 ; i ++ ) { byte temp = bytes [ i ] ; bytes [ i ] = bytes [ bytes . length - 1 - i ] ; bytes [ bytes . length - 1 - i ] = temp ; } }
Reverses a byte array in place .
10,078
public static byte [ ] toByteArray ( short s , ByteOrder bo ) { return ByteBuffer . allocate ( 2 ) . order ( bo ) . putShort ( s ) . array ( ) ; }
Converts a short into a byte array .
10,079
public static byte [ ] toByteArray ( int i , ByteOrder bo ) { return ByteBuffer . allocate ( 4 ) . order ( bo ) . putInt ( i ) . array ( ) ; }
Converts an int into a byte array .
10,080
public static byte [ ] toByteArray ( long l , ByteOrder bo ) { return ByteBuffer . allocate ( 8 ) . order ( bo ) . putLong ( l ) . array ( ) ; }
Converts a long into a byte array .
10,081
public static byte [ ] toByteArray ( float f , ByteOrder bo ) { return ByteBuffer . allocate ( 4 ) . order ( bo ) . putFloat ( f ) . array ( ) ; }
Converts a float into a byte array .
10,082
public static byte [ ] toByteArray ( double d , ByteOrder bo ) { return ByteBuffer . allocate ( 8 ) . order ( bo ) . putDouble ( d ) . array ( ) ; }
Converts a double into a byte array .
10,083
public static byte [ ] toByteArray ( char c , ByteOrder bo ) { return ByteBuffer . allocate ( 2 ) . order ( bo ) . putChar ( c ) . array ( ) ; }
Converts a char into a byte array .
10,084
public static String toExtendedASCIIs ( byte [ ] bytes , int n , ByteOrder bo ) { RubyArray < String > ra = Ruby . Array . create ( ) ; if ( bo == LITTLE_ENDIAN ) { for ( int i = 0 ; i < n ; i ++ ) { if ( i >= bytes . length ) { ra . push ( "\0" ) ; continue ; } byte b = bytes [ i ] ; ra . push ( toASCII8Bit ( b ) ) ; } return ra . join ( ) ; } else { for ( int i = bytes . length - 1 ; n > 0 ; i -- ) { if ( i < 0 ) { ra . unshift ( "\0" ) ; n -- ; continue ; } byte b = bytes [ i ] ; ra . unshift ( toASCII8Bit ( b ) ) ; n -- ; } return ra . join ( ) ; } }
Converts a byte array into an ASCII String .
10,085
public static String toUTF ( byte [ ] bytes ) { int codePoint = ByteBuffer . wrap ( bytes ) . getInt ( ) ; if ( codePoint < 0 || codePoint > 0X10FFFF ) throw new IllegalArgumentException ( "RangeError: pack(U): value out of range" ) ; return String . valueOf ( ( char ) codePoint ) ; }
Converts a byte array into an UTF String .
10,086
public static String toBinaryString ( byte [ ] bytes , boolean isMSB ) { StringBuilder sb = new StringBuilder ( ) ; for ( byte b : bytes ) { String binary = String . format ( "%8s" , Integer . toBinaryString ( b & 0xFF ) ) . replace ( ' ' , '0' ) ; if ( isMSB ) sb . append ( binary ) ; else sb . append ( new StringBuilder ( binary ) . reverse ( ) ) ; } return sb . toString ( ) ; }
Converts a byte array to a binary String .
10,087
public static String toHexString ( byte [ ] bytes , boolean isHNF ) { StringBuilder sb = new StringBuilder ( ) ; for ( byte b : bytes ) { String hex = String . format ( "%2s" , Integer . toHexString ( b & 0xFF ) ) . replace ( ' ' , '0' ) ; if ( isHNF ) sb . append ( hex ) ; else sb . append ( new StringBuilder ( hex ) . reverse ( ) ) ; } return sb . toString ( ) ; }
Converts a byte array to a hex String .
10,088
public static byte [ ] fromBinaryString ( String binaryStr ) { if ( ! binaryStr . matches ( "^[01]*$" ) ) throw new IllegalArgumentException ( "Invalid binary string" ) ; if ( binaryStr . isEmpty ( ) ) return new byte [ 0 ] ; int complementary = binaryStr . length ( ) % 8 ; if ( complementary != 0 ) binaryStr += Ruby . Array . of ( "0" ) . multiply ( 8 - complementary ) . join ( ) ; return rjust ( new BigInteger ( binaryStr , 2 ) . toByteArray ( ) , binaryStr . length ( ) / 8 ) ; }
Converts a binary string into byte array .
10,089
public static byte [ ] fromHexString ( String hexStr ) { if ( ! hexStr . matches ( "^[0-9A-Fa-f]*$" ) ) throw new IllegalArgumentException ( "Invalid hexadecimal string" ) ; if ( hexStr . isEmpty ( ) ) return new byte [ 0 ] ; int complementary = hexStr . length ( ) % 2 ; if ( complementary != 0 ) hexStr += "0" ; return rjust ( new BigInteger ( hexStr , 16 ) . toByteArray ( ) , hexStr . length ( ) / 2 ) ; }
Converts a hexadecimal string into byte array .
10,090
public org . geomajas . layer . feature . Feature toDto ( ) { org . geomajas . layer . feature . Feature dto = new org . geomajas . layer . feature . Feature ( ) ; dto . setAttributes ( attributes ) ; dto . setClipped ( clipped ) ; dto . setId ( id ) ; dto . setGeometry ( GeometryConverter . toDto ( geometry ) ) ; dto . setCrs ( crs ) ; dto . setLabel ( getLabel ( ) ) ; return dto ; }
Transform this object into a DTO feature .
10,091
public void setAttributes ( Map < String , Attribute > attributes ) { if ( null == attributes ) { throw new IllegalArgumentException ( "Attributes should be not-null." ) ; } this . attributes = attributes ; this . attributesLoaded = true ; }
Set the attributes map .
10,092
public void setRectangleStyle ( ShapeStyle rectangleStyle ) { this . rectangleStyle = rectangleStyle ; if ( targetRectangle != null ) { targetRectangle . setStyle ( rectangleStyle ) ; render ( targetRectangle , RenderGroup . SCREEN , RenderStatus . ALL ) ; } }
Set a new style for the rectangle that shows the current position on the target map .
10,093
public void setDrawTargetMaxExtent ( boolean drawTargetMaxExtent ) { this . drawTargetMaxExtent = drawTargetMaxExtent ; if ( drawTargetMaxExtent ) { targetMaxExtentRectangle = new GfxGeometry ( "targetMaxExtentRectangle" ) ; targetMaxExtentRectangle . setStyle ( targetMaxExtentRectangleStyle ) ; Bbox targetMaxExtent = getOverviewMaxBounds ( ) ; Bbox box = getMapModel ( ) . getMapView ( ) . getWorldViewTransformer ( ) . worldToView ( targetMaxExtent ) ; LinearRing shell = getMapModel ( ) . getGeometryFactory ( ) . createLinearRing ( new Coordinate [ ] { new Coordinate ( - 2 , - 2 ) , new Coordinate ( getWidth ( ) + 2 , - 2 ) , new Coordinate ( getWidth ( ) + 2 , getHeight ( ) + 2 ) , new Coordinate ( - 2 , getHeight ( ) + 2 ) } ) ; LinearRing hole = getMapModel ( ) . getGeometryFactory ( ) . createLinearRing ( new Coordinate [ ] { new Coordinate ( box . getX ( ) , box . getY ( ) ) , new Coordinate ( box . getMaxX ( ) , box . getY ( ) ) , new Coordinate ( box . getMaxX ( ) , box . getMaxY ( ) ) , new Coordinate ( box . getX ( ) , box . getMaxY ( ) ) } ) ; Polygon polygon = getMapModel ( ) . getGeometryFactory ( ) . createPolygon ( shell , new LinearRing [ ] { hole } ) ; targetMaxExtentRectangle . setGeometry ( polygon ) ; render ( targetMaxExtentRectangle , RenderGroup . SCREEN , RenderStatus . ALL ) ; } else { render ( targetMaxExtentRectangle , RenderGroup . SCREEN , RenderStatus . DELETE ) ; targetMaxExtentRectangle = null ; } }
Determine whether or not a rectangle that shows the target map s maximum extent should be shown .
10,094
public void setTargetMaxExtentRectangleStyle ( ShapeStyle targetMaxExtentRectangleStyle ) { this . targetMaxExtentRectangleStyle = targetMaxExtentRectangleStyle ; if ( targetMaxExtentRectangle != null ) { targetMaxExtentRectangle . setStyle ( targetMaxExtentRectangleStyle ) ; if ( drawTargetMaxExtent ) { render ( targetMaxExtentRectangle , RenderGroup . SCREEN , RenderStatus . UPDATE ) ; } } }
Set a new style for the rectangle that show the target map s maximum extent . This style will be applied immediately .
10,095
private void updateMaxExtent ( ) { if ( targetMap . getMapModel ( ) . isInitialized ( ) && getGraphics ( ) . isReady ( ) ) { getMapModel ( ) . getMapView ( ) . setSize ( getWidth ( ) , getHeight ( ) ) ; Bbox targetMaxBounds = getOverviewMaxBounds ( ) ; MapView mapView = getMapModel ( ) . getMapView ( ) ; mapView . setMaxBounds ( targetMaxBounds . buffer ( targetMaxBounds . getWidth ( ) ) ) ; if ( maxExtentIncreasePercentage > 0 ) { targetMaxBounds = targetMaxBounds . buffer ( targetMaxBounds . getWidth ( ) * maxExtentIncreasePercentage / 100 ) ; } mapView . applyBounds ( targetMaxBounds , MapView . ZoomOption . LEVEL_FIT ) ; setDrawTargetMaxExtent ( drawTargetMaxExtent ) ; } }
Apply a maximum extent . This will extend the map extend to be used by the percentage to increase .
10,096
private void updatePov ( ) { MapView mapView = getMapModel ( ) . getMapView ( ) ; WorldViewTransformer transformer = new WorldViewTransformer ( mapView ) ; Bbox targetBox = targetMap . getMapModel ( ) . getMapView ( ) . getBounds ( ) ; Bbox overviewBox = mapView . getBounds ( ) ; if ( Double . isNaN ( overviewBox . getX ( ) ) ) { return ; } if ( dynamicOverview && ! overviewBox . contains ( targetBox ) ) { } Coordinate viewBegin = transformer . worldToView ( targetBox . getOrigin ( ) ) ; Coordinate viewEnd = transformer . worldToView ( targetBox . getEndPoint ( ) ) ; double width = Math . abs ( viewEnd . getX ( ) - viewBegin . getX ( ) ) ; double height = Math . abs ( viewEnd . getY ( ) - viewBegin . getY ( ) ) ; viewBegin . setY ( viewBegin . getY ( ) - height ) ; if ( width < 20 ) { if ( null != targetRectangle ) { render ( targetRectangle , RenderGroup . SCREEN , RenderStatus . DELETE ) ; targetRectangle = null ; } if ( null == targetReticle ) { targetReticle = new Image ( "targetReticle" ) ; targetReticle . setHref ( Geomajas . getIsomorphicDir ( ) + TARGET_RETICLE_IMAGE ) ; targetReticle . setBounds ( new Bbox ( 0 , 0 , 21 , 21 ) ) ; } double x = viewBegin . getX ( ) + ( width / 2 ) - 10 ; double y = viewBegin . getY ( ) + ( width / 2 ) - 10 ; targetReticle . getBounds ( ) . setX ( x ) ; targetReticle . getBounds ( ) . setY ( y ) ; render ( targetReticle , RenderGroup . SCREEN , RenderStatus . UPDATE ) ; } else { if ( null != targetReticle ) { render ( targetReticle , RenderGroup . SCREEN , RenderStatus . DELETE ) ; targetReticle = null ; } if ( null == targetRectangle ) { targetRectangle = new Rectangle ( "targetRect" ) ; targetRectangle . setStyle ( rectangleStyle ) ; } targetRectangle . setBounds ( new Bbox ( viewBegin . getX ( ) , viewBegin . getY ( ) , width , height ) ) ; render ( targetRectangle , RenderGroup . SCREEN , RenderStatus . UPDATE ) ; } }
Update the rectangle and perhaps the entire map if needed .
10,097
private Bbox getOverviewMaxBounds ( ) { Bbox targetMaxBounds ; if ( ! useTargetMaxExtent ) { targetMaxBounds = new Bbox ( getMapModel ( ) . getMapInfo ( ) . getInitialBounds ( ) ) ; } else { if ( targetMap . getMapModel ( ) . isInitialized ( ) ) { targetMaxBounds = targetMap . getMapModel ( ) . getMapView ( ) . getMaxBounds ( ) ; } else { targetMaxBounds = new Bbox ( targetMap . getMapModel ( ) . getMapInfo ( ) . getMaxBounds ( ) ) ; } } return targetMaxBounds ; }
The maximum bounds depend on whether useTargetMaxExtent was set . If not set the initialBounds from the overviewMap are used . It it was set the maximum bounds of the target view is used .
10,098
@ Produces ( MediaType . APPLICATION_JSON ) public Response getStatistics ( @ QueryParam ( "selectLang" ) String locale ) { List < StatisticRepresentation > listResult = new ArrayList < > ( ) ; if ( StringUtils . isBlank ( locale ) ) { List < LocaleRepresentation > availableLocales = localeFinder . findAvailableLocales ( ) ; for ( LocaleRepresentation localeRepresentation : availableLocales ) { statisticFinder . findStatisticRepresentation ( localeRepresentation , listResult ) ; } } else { LocaleRepresentation localeRepresentation = localeFinder . findAvailableLocale ( locale ) ; statisticFinder . findStatisticRepresentation ( localeRepresentation , listResult ) ; } if ( ! listResult . isEmpty ( ) ) { return Response . ok ( listResult ) . build ( ) ; } return Response . noContent ( ) . build ( ) ; }
Returns a list contains the result statistic for the selected language
10,099
@ SuppressWarnings ( "unchecked" ) public < T > T getProperty ( String key , T defaultValue ) { T value = ( T ) serviceReference . getProperty ( key ) ; return value == null ? defaultValue : value ; }
Returns the service property value or the default value if the property is not present .