idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
10,200
private List < Coordinate [ ] > getCoordinateArrays ( List < Geometry > geometries ) { List < Coordinate [ ] > res = new ArrayList < Coordinate [ ] > ( ) ; for ( Geometry geometry : geometries ) { res . add ( geometry . getCoordinates ( ) ) ; } return res ; }
Transform the list of geometries into a list of coordinate arrays .
10,201
public void onUp ( HumanInputEvent < ? > event ) { if ( ! isRightMouseButton ( event ) ) { ToggleSelectionAction action = new ToggleSelectionAction ( mapWidget , pixelTolerance ) ; action . setPriorityToSelectedLayer ( priorityToSelectedLayer ) ; action . toggleSingle ( getLocation ( event , RenderSpace . SCREEN ) ) ; } }
Toggle selection at the event location .
10,202
@ Path ( "/{locale}" ) @ Produces ( MediaType . APPLICATION_JSON ) public Response getTranslations ( @ PathParam ( "locale" ) String locale ) { Map < String , String > messages = getMessages ( locale ) ; if ( ! messages . isEmpty ( ) ) { return Response . ok ( messages ) . build ( ) ; } return Response . ok ( "{}" ) . build ( ) ; }
Returns a map of key translation for the given locale .
10,203
public Translation getTranslation ( String locale ) { LocaleCodeSpecification . assertCode ( locale ) ; return this . getTranslations ( ) . get ( locale ) ; }
Returns the translation corresponding to the given locale code .
10,204
public void removeTranslation ( String locale ) { LocaleCodeSpecification . assertCode ( locale ) ; Translation translation = getTranslation ( locale ) ; if ( translation != null ) { this . translations . remove ( translation . getId ( ) ) ; } }
Removes the translation corresponding to the given locale code .
10,205
public void checkOutdatedStatus ( ) { boolean newStatus = false ; for ( Translation translation : translations . values ( ) ) { if ( translation . isOutdated ( ) ) { newStatus = true ; break ; } } outdated = newStatus ; }
Checks if the key has outdated translations and then update the outdated status of the key .
10,206
public Map < String , Translation > getTranslations ( ) { Map < String , Translation > map = new HashMap < > ( ) ; for ( Map . Entry < TranslationId , Translation > translationEntry : translations . entrySet ( ) ) { map . put ( translationEntry . getKey ( ) . getLocale ( ) , translationEntry . getValue ( ) ) ; } return map ; }
Returns the translation set .
10,207
public org . geomajas . geometry . Bbox toDtoBbox ( ) { return new org . geomajas . geometry . Bbox ( getX ( ) , getY ( ) , getWidth ( ) , getHeight ( ) ) ; }
Convert the GWT bounding box to a DTO bounding box .
10,208
public Coordinate [ ] getCoordinates ( ) { Coordinate [ ] result = new Coordinate [ 5 ] ; result [ 0 ] = new Coordinate ( x , y ) ; result [ 1 ] = new Coordinate ( x + width , y ) ; result [ 2 ] = new Coordinate ( x + width , y + height ) ; result [ 3 ] = new Coordinate ( x , y + height ) ; result [ 4 ] = new Coordinate ( x , y ) ; return result ; }
Get the coordinates of the bounding box as an array .
10,209
public boolean contains ( Bbox other ) { if ( other . getX ( ) < this . getX ( ) ) { return false ; } if ( other . getY ( ) < this . getY ( ) ) { return false ; } if ( other . getEndPoint ( ) . getX ( ) > this . getEndPoint ( ) . getX ( ) ) { return false ; } if ( other . getEndPoint ( ) . getY ( ) > this . getEndPoint ( ) . getY ( ) ) { return false ; } return true ; }
Does this bounding box contain the given bounding box?
10,210
public boolean intersects ( Bbox other ) { if ( other . getX ( ) > this . getEndPoint ( ) . getX ( ) ) { return false ; } if ( other . getY ( ) > this . getEndPoint ( ) . getY ( ) ) { return false ; } if ( other . getEndPoint ( ) . getX ( ) < this . getX ( ) ) { return false ; } if ( other . getEndPoint ( ) . getY ( ) < this . getY ( ) ) { return false ; } return true ; }
Does this bounding box intersect the given bounding box?
10,211
public Bbox intersection ( Bbox other ) { if ( ! this . intersects ( other ) ) { return null ; } else { double minx = other . getX ( ) > this . getX ( ) ? other . getX ( ) : this . getX ( ) ; double maxx = other . getEndPoint ( ) . getX ( ) < this . getEndPoint ( ) . getX ( ) ? other . getEndPoint ( ) . getX ( ) : this . getEndPoint ( ) . getX ( ) ; double miny = other . getY ( ) > this . getY ( ) ? other . getY ( ) : this . getY ( ) ; double maxy = other . getEndPoint ( ) . getY ( ) < this . getEndPoint ( ) . getY ( ) ? other . getEndPoint ( ) . getY ( ) : this . getEndPoint ( ) . getY ( ) ; return new Bbox ( minx , miny , ( maxx - minx ) , ( maxy - miny ) ) ; } }
Computes the intersection of this bounding box with the specified bounding box .
10,212
public Bbox buffer ( double range ) { if ( range > 0 ) { double r2 = range * 2 ; return new Bbox ( x - range , y - range , width + r2 , height + r2 ) ; } return null ; }
Return a new bounding box that has increased in size by adding a range to this bounding box .
10,213
public Bbox transform ( Matrix t ) { Coordinate c1 = transform ( t , new Coordinate ( x , y ) ) ; Coordinate c2 = transform ( t , new Coordinate ( x + width , y + height ) ) ; Coordinate origin = new Coordinate ( Math . min ( c1 . getX ( ) , c2 . getX ( ) ) , Math . min ( c1 . getY ( ) , c2 . getY ( ) ) ) ; Coordinate endPoint = new Coordinate ( Math . max ( c1 . getX ( ) , c2 . getX ( ) ) , Math . max ( c1 . getY ( ) , c2 . getY ( ) ) ) ; return new Bbox ( origin . getX ( ) , origin . getY ( ) , endPoint . getX ( ) - origin . getX ( ) , endPoint . getY ( ) - origin . getY ( ) ) ; }
Create a new bounds by transforming this bounds with the specified tranformation matrix .
10,214
public void setCenterPoint ( Coordinate coordinate ) { this . x = coordinate . getX ( ) - 0.5 * this . width ; this . y = coordinate . getY ( ) - 0.5 * this . height ; }
Moves center to the specified coordinate .
10,215
public MapController getMapController ( ) { final GraphicsController controller = mapWidget . getController ( ) ; MapController mapController = new MapController ( this , controller ) ; mapController . setActivationHandler ( new ExportableFunction ( ) { public void execute ( ) { controller . onActivate ( ) ; } } ) ; mapController . setDeactivationHandler ( new ExportableFunction ( ) { public void execute ( ) { controller . onDeactivate ( ) ; } } ) ; return mapController ; }
Return the currently active controller on the map .
10,216
public void registerPainter ( Painter painter ) { if ( painters . containsKey ( painter . getPaintableClassName ( ) ) ) { List < Painter > list = painters . remove ( painter . getPaintableClassName ( ) ) ; list . add ( painter ) ; this . painters . put ( painter . getPaintableClassName ( ) , list ) ; } else { List < Painter > list = new ArrayList < Painter > ( ) ; list . add ( painter ) ; this . painters . put ( painter . getPaintableClassName ( ) , list ) ; } }
Register a new painter to this visitor .
10,217
public void unregisterPainter ( Painter painter ) { String className = painter . getPaintableClassName ( ) ; if ( painters . containsKey ( className ) ) { List < Painter > list = painters . remove ( className ) ; if ( list . size ( ) > 1 ) { list . remove ( painter ) ; painters . put ( className , list ) ; } } }
Unregister an existing painter from this visitor .
10,218
public void visit ( Paintable paintable , Object group ) { if ( context . isReady ( ) ) { String className = paintable . getClass ( ) . getName ( ) ; if ( painters . containsKey ( className ) ) { List < Painter > list = painters . get ( className ) ; for ( Painter painter : list ) { painter . paint ( paintable , group , context ) ; } } } }
The visitors visit function .
10,219
public void remove ( Paintable paintable , Object group ) { String className = paintable . getClass ( ) . getName ( ) ; if ( painters . containsKey ( className ) ) { List < Painter > list = painters . get ( className ) ; for ( Painter painter : list ) { painter . deleteShape ( paintable , group , context ) ; } } }
Remove a paintable object from the graphics .
10,220
public List < Painter > getPaintersForObject ( Paintable paintable ) { String className = paintable . getClass ( ) . getName ( ) ; if ( painters . containsKey ( className ) ) { return painters . get ( className ) ; } return null ; }
Retrieve the full list of painter for a specific type of paintable object .
10,221
public static AssociationValue createEmptyAssociationValue ( AssociationAttributeInfo attributeInfo ) { AssociationValue value = new AssociationValue ( ) ; Map < String , Attribute < ? > > attributes = new HashMap < String , Attribute < ? > > ( ) ; for ( AbstractAttributeInfo attrInfo : attributeInfo . getFeature ( ) . getAttributes ( ) ) { attributes . put ( attrInfo . getName ( ) , createEmptyAttribute ( attrInfo ) ) ; } value . setAllAttributes ( attributes ) ; value . setId ( createEmptyPrimitiveAttribute ( attributeInfo . getFeature ( ) . getIdentifier ( ) ) ) ; return value ; }
Creates an empty association value . An empty association value is a value for which the attributes and identifier are empty .
10,222
public static Attribute < ? > createEmptyAttribute ( AbstractAttributeInfo attrInfo ) { if ( attrInfo instanceof PrimitiveAttributeInfo ) { return createEmptyPrimitiveAttribute ( ( PrimitiveAttributeInfo ) attrInfo ) ; } else if ( attrInfo instanceof AssociationAttributeInfo ) { return createEmptyAssociationAttribute ( ( AssociationAttributeInfo ) attrInfo ) ; } return null ; }
Creates an empty attribute . An empty attribute is an attribute which has null as its value .
10,223
public static PrimitiveAttribute < ? > createEmptyPrimitiveAttribute ( PrimitiveAttributeInfo info ) { PrimitiveAttribute < ? > attribute ; switch ( info . getType ( ) ) { case BOOLEAN : attribute = new BooleanAttribute ( ) ; break ; case SHORT : attribute = new ShortAttribute ( ) ; break ; case INTEGER : attribute = new IntegerAttribute ( ) ; break ; case LONG : attribute = new LongAttribute ( ) ; break ; case FLOAT : attribute = new FloatAttribute ( ) ; break ; case DOUBLE : attribute = new DoubleAttribute ( ) ; break ; case CURRENCY : attribute = new CurrencyAttribute ( ) ; break ; case STRING : attribute = new StringAttribute ( ) ; break ; case DATE : attribute = new DateAttribute ( ) ; break ; case URL : attribute = new UrlAttribute ( ) ; break ; case IMGURL : attribute = new ImageUrlAttribute ( ) ; break ; default : String msg = "Trying to build an unknown primitive attribute type " + info . getType ( ) ; Log . logError ( msg ) ; throw new IllegalStateException ( msg ) ; } attribute . setEditable ( info . isEditable ( ) ) ; return attribute ; }
Creates an empty primitive attribute . An empty attribute is an attribute which has null as its value .
10,224
public static AssociationAttribute < ? > createEmptyAssociationAttribute ( AssociationAttributeInfo info ) { AssociationAttribute < ? > association ; switch ( info . getType ( ) ) { case MANY_TO_ONE : association = new ManyToOneAttribute ( ) ; break ; case ONE_TO_MANY : association = new OneToManyAttribute ( ) ; break ; default : String msg = "Trying to build an unknown association attribute type " + info . getType ( ) ; Log . logError ( msg ) ; throw new IllegalStateException ( msg ) ; } association . setEditable ( info . isEditable ( ) ) ; return association ; }
Creates an empty association attribute . An empty attribute is an attribute which has null as its value .
10,225
public JsHandlerRegistration addLayersModelChangedHandler ( final LayersModelChangedHandler handler ) { HandlerRegistration registration = ( ( MapImpl ) map ) . getMapWidget ( ) . getMapModel ( ) . addMapModelChangedHandler ( new MapModelChangedHandler ( ) { public void onMapModelChanged ( MapModelChangedEvent event ) { handler . onLayersModelChanged ( new LayersModelChangedEvent ( map . getLayersModel ( ) ) ) ; } } ) ; return new JsHandlerRegistration ( new HandlerRegistration [ ] { registration } ) ; }
Add a handler to change events in the layer configuration from the map . This event is fired for example when the map gets it s configuration from the server . Only then can it know what layers it has available .
10,226
public JsHandlerRegistration addFeatureSelectionHandler ( final FeatureSelectedHandler selectedHandler , final FeatureDeselectedHandler deselectedHandler ) { if ( ( ( MapImpl ) map ) . getMapWidget ( ) . getMapModel ( ) . isInitialized ( ) ) { return addFeatureSelectionHandler2 ( selectedHandler , deselectedHandler ) ; } final CallbackHandlerRegistration callbackRegistration = new CallbackHandlerRegistration ( ) ; ( ( MapImpl ) map ) . getMapWidget ( ) . getMapModel ( ) . addMapModelChangedHandler ( new MapModelChangedHandler ( ) { public void onMapModelChanged ( MapModelChangedEvent event ) { JsHandlerRegistration temp = addFeatureSelectionHandler2 ( selectedHandler , deselectedHandler ) ; callbackRegistration . setRegistration ( temp ) ; } } ) ; return callbackRegistration ; }
Add a handler for feature selection .
10,227
public String hyphenate ( String text , Character shy , Character zwsp ) throws StandardHyphenationException { if ( shy == null && zwsp == null ) return text ; byte [ ] hyphens = hyphenate ( text ) ; StringBuffer hyphenatedText = new StringBuffer ( ) ; int i ; for ( i = 0 ; i < hyphens . length ; i ++ ) { hyphenatedText . append ( text . charAt ( i ) ) ; if ( shy != null && hyphens [ i ] == SHY ) hyphenatedText . append ( shy ) ; else if ( zwsp != null && hyphens [ i ] == ZWSP ) hyphenatedText . append ( zwsp ) ; } hyphenatedText . append ( text . charAt ( i ) ) ; return hyphenatedText . toString ( ) ; }
Returns the fully hyphenated string . The given hyphen characters are inserted at all possible hyphenation points .
10,228
public byte [ ] hyphenate ( String text ) throws StandardHyphenationException { Matcher matcher = Pattern . compile ( "['\\p{L}]+" ) . matcher ( text ) ; StringBuffer hyphenBuffer = new StringBuffer ( ) ; int pos = 0 ; while ( matcher . find ( ) ) { int start = matcher . start ( ) ; int end = matcher . end ( ) ; while ( pos ++ < start ) hyphenBuffer . append ( '0' ) ; String word = text . substring ( start , end ) ; word = word . toLowerCase ( ) ; byte [ ] wordBytes = encode ( word ) ; int wordSize = wordBytes . length ; if ( wordSize > wordHyphens . capacity ( ) ) wordHyphens = ByteBuffer . allocate ( wordSize * 2 ) ; PointerByReference repPointer = new PointerByReference ( Pointer . NULL ) ; PointerByReference posPointer = new PointerByReference ( Pointer . NULL ) ; PointerByReference cutPointer = new PointerByReference ( Pointer . NULL ) ; Hyphen . getLibrary ( ) . hnj_hyphen_hyphenate2 ( dictionary , wordBytes , wordSize , wordHyphens , null , repPointer , posPointer , cutPointer ) ; if ( repPointer . getValue ( ) != Pointer . NULL ) throw new StandardHyphenationException ( "Text contains non-standard hyphenation points." ) ; hyphenBuffer . append ( new String ( wordHyphens . array ( ) , 0 , word . length ( ) ) ) ; pos = end ; } while ( pos < text . length ( ) ) { hyphenBuffer . append ( '0' ) ; pos ++ ; } hyphenBuffer . deleteCharAt ( pos - 1 ) ; byte [ ] hyphens = new byte [ hyphenBuffer . length ( ) ] ; CharacterIterator iter = new StringCharacterIterator ( hyphenBuffer . toString ( ) ) ; int i = 0 ; for ( char c = iter . first ( ) ; c != CharacterIterator . DONE ; c = iter . next ( ) ) hyphens [ i ++ ] = ( c & 1 ) > 0 ? SHY : 0 ; matcher = Pattern . compile ( "[\\p{L}\\p{N}]-(?=[\\p{L}\\p{N}])" ) . matcher ( text ) ; while ( matcher . find ( ) ) hyphens [ matcher . start ( ) + 1 ] = ZWSP ; return hyphens ; }
Returns all possible hyphenation opportunities within a string
10,229
private static Charset getCharset ( File dictionaryFile ) throws UnsupportedCharsetException , FileNotFoundException { Charset cs = charsets . get ( dictionaryFile ) ; if ( cs == null ) { BufferedReader reader = null ; try { reader = new BufferedReader ( new FileReader ( dictionaryFile ) ) ; String charsetName = reader . readLine ( ) ; charsetName = charsetName . replaceAll ( "\\s+" , "" ) ; cs = Charset . forName ( charsetName ) ; charsets . put ( dictionaryFile , cs ) ; } catch ( IOException e ) { throw new RuntimeException ( "Could not read first line of file" ) ; } finally { if ( reader != null ) { try { reader . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } } return cs ; }
Reads the first line of the dictionary file which is the encoding
10,230
protected void resetIcons ( ) { for ( ViewConfigItem item : viewConfigItems ) { RangeConfig config = getRangeConfigForCurrentScale ( item . getViewConfig ( ) , mapWidget . getMapModel ( ) . getMapView ( ) . getCurrentScale ( ) ) ; if ( null != config && null != config . getIcon ( ) ) { ( ( MenuItem ) item . getButton ( ) ) . setIcon ( Geomajas . getDispatcherUrl ( ) + config . getIcon ( ) ) ; } } if ( activeViewConfig != null ) { setMasterItem ( ( MenuItem ) activeViewConfig . getButton ( ) ) ; } }
Reset all icons .
10,231
private void loginUser ( final String userId , final String password , final BooleanCallback callback ) { LoginRequest request = new LoginRequest ( ) ; request . setLogin ( userId ) ; request . setPassword ( password ) ; GwtCommand command = new GwtCommand ( loginCommandName ) ; command . setCommandRequest ( request ) ; GwtCommandDispatcher . getInstance ( ) . execute ( command , new AbstractCommandCallback < LoginResponse > ( ) { public void execute ( LoginResponse loginResponse ) { if ( loginResponse . getToken ( ) == null ) { if ( callback != null ) { callback . execute ( false ) ; } manager . fireEvent ( new LoginFailureEvent ( loginResponse . getErrorMessages ( ) ) ) ; } else { userToken = loginResponse . getToken ( ) ; Authentication . this . userId = userId ; UserDetail userDetail = GwtCommandDispatcher . getInstance ( ) . getUserDetail ( ) ; userDetail . setUserId ( loginResponse . getUserId ( ) ) ; userDetail . setUserName ( loginResponse . getUserName ( ) ) ; userDetail . setUserOrganization ( loginResponse . getUserOrganization ( ) ) ; userDetail . setUserDivision ( loginResponse . getUserDivision ( ) ) ; userDetail . setUserLocale ( loginResponse . getUserLocale ( ) ) ; if ( callback != null ) { callback . execute ( true ) ; } manager . fireEvent ( new LoginSuccessEvent ( userToken ) ) ; } } } ) ; }
Effectively log in a certain user .
10,232
public void accept ( PainterVisitor visitor , Object group , Bbox bounds , boolean recursive ) { applyPosition ( ) ; map . getVectorContext ( ) . drawGroup ( group , this ) ; map . getVectorContext ( ) . drawImage ( this , background . getId ( ) , background . getHref ( ) , background . getBounds ( ) , ( PictureStyle ) background . getStyle ( ) ) ; north . accept ( visitor , group , bounds , recursive ) ; east . accept ( visitor , group , bounds , recursive ) ; south . accept ( visitor , group , bounds , recursive ) ; west . accept ( visitor , group , bounds , recursive ) ; }
Apply the correct positions on all panning buttons and render them .
10,233
public void fetch ( final String filter , final TileFunction < VectorTile > callback ) { final GetVectorTileRequest request = createRequest ( filter ) ; GwtCommand command = new GwtCommand ( GetVectorTileRequest . COMMAND ) ; command . setCommandRequest ( request ) ; final VectorTile self = this ; lastRequest = request ; deferred = GwtCommandDispatcher . getInstance ( ) . execute ( command , new AbstractCommandCallback < GetVectorTileResponse > ( ) { public void execute ( GetVectorTileResponse tileResponse ) { if ( null == deferred || ! deferred . isCancelled ( ) ) { org . geomajas . layer . tile . VectorTile tile = tileResponse . getTile ( ) ; for ( TileCode relatedTile : tile . getCodes ( ) ) { codes . add ( relatedTile ) ; } code = tile . getCode ( ) ; contentType = tile . getContentType ( ) ; featureContent . setContent ( tile . getFeatureContent ( ) ) ; labelContent . setContent ( tile . getLabelContent ( ) ) ; try { callback . execute ( self ) ; } catch ( Throwable t ) { Log . logError ( "VectorTile: error calling the callback after a fetch." , t ) ; } } deferred = null ; } } ) ; }
Fetch all data related to this tile .
10,234
public void apply ( final String filter , final TileFunction < VectorTile > callback ) { switch ( getStatus ( ) ) { case EMPTY : fetch ( filter , callback ) ; break ; case LOADING : if ( needsReload ( filter ) ) { deferred . cancel ( ) ; fetch ( filter , callback ) ; } else { final VectorTile self = this ; deferred . addCallback ( new AbstractCommandCallback < GetVectorTileResponse > ( ) { public void execute ( GetVectorTileResponse response ) { callback . execute ( self ) ; } } ) ; } break ; case LOADED : if ( needsReload ( filter ) ) { fetch ( filter , callback ) ; } else { callback . execute ( this ) ; } break ; default : throw new IllegalStateException ( "Unknown status " + getStatus ( ) ) ; } }
Execute a TileFunction on this tile . If the tile is not yet loaded attach it to the isLoaded event .
10,235
public void moveToBack ( Object parent , String name ) { Element parentElement = getGroup ( parent ) ; if ( parentElement == null ) { throw new IllegalArgumentException ( "moveToBack failed: could not find parent group." ) ; } Element element = getElement ( parent , name ) ; if ( element == null ) { throw new IllegalArgumentException ( "moveToBack failed: could not find element within group." ) ; } if ( parentElement . getFirstChildElement ( ) != element ) { parentElement . insertFirst ( element ) ; } }
Within a certain group move an element to the back . All siblings will be rendered after this one .
10,236
private void applyAbsolutePosition ( Element element , Coordinate position ) { Dom . setStyleAttribute ( element , "position" , "absolute" ) ; Dom . setStyleAttribute ( element , "left" , ( int ) position . getX ( ) + "px" ) ; Dom . setStyleAttribute ( element , "top" , ( int ) position . getY ( ) + "px" ) ; }
Apply an absolute position on an element .
10,237
private void applyElementSize ( Element element , int width , int height , boolean addCoordSize ) { if ( width >= 0 && height >= 0 ) { if ( addCoordSize ) { Dom . setElementAttribute ( element , "coordsize" , width + " " + height ) ; } Dom . setStyleAttribute ( element , "width" , width + "px" ) ; Dom . setStyleAttribute ( element , "height" , height + "px" ) ; } }
Apply a size on an element .
10,238
private String parse ( Matrix matrix ) { String transform = "" ; if ( matrix != null ) { double dx = matrix . getDx ( ) ; double dy = matrix . getDy ( ) ; if ( matrix . getXx ( ) != 0 && matrix . getYy ( ) != 0 && matrix . getXx ( ) != 1 && matrix . getYy ( ) != 1 ) { transform += "scale(" + matrix . getXx ( ) + ", " + matrix . getYy ( ) + ")" ; dx /= matrix . getXx ( ) ; dy /= matrix . getYy ( ) ; } transform += " translate(" + ( float ) dx + ", " + ( float ) dy + ")" ; } return transform ; }
Parse a matrix object into a string suitable for the SVG transform attribute .
10,239
protected Element createGroup ( String namespace , Object parent , Object group , String type ) { Element parentElement ; if ( parent == null ) { parentElement = getRootElement ( ) ; } else { parentElement = getGroup ( parent ) ; } if ( parentElement == null ) { return null ; } else { Element element ; String id = Dom . createUniqueId ( ) ; if ( group instanceof PaintableGroup ) { id = Dom . assembleId ( id , ( ( PaintableGroup ) group ) . getGroupName ( ) ) ; } groupToId . put ( group , id ) ; idToGroup . put ( id , group ) ; if ( Dom . NS_HTML . equals ( namespace ) ) { element = Dom . createElement ( "div" , id ) ; } else { element = Dom . createElementNS ( namespace , type , id ) ; } parentElement . appendChild ( element ) ; return element ; } }
Generic creation method for group elements .
10,240
protected Element getElement ( Object parent , String name ) { if ( name == null ) { return null ; } String id ; if ( parent == null ) { id = getRootElement ( ) . getId ( ) ; } else { id = groupToId . get ( parent ) ; } return Dom . getElementById ( Dom . assembleId ( id , name ) ) ; }
Returns the element that is a child of the specified parent and has the specified local group name .
10,241
protected Element createElement ( Object parent , String name , String type , Style style , boolean generateId ) { if ( null == name ) { return null ; } Element parentElement ; if ( parent == null ) { parentElement = getRootElement ( ) ; } else { parentElement = getGroup ( parent ) ; } if ( parentElement == null ) { return null ; } else { Element element ; String id = generateId ? Dom . assembleId ( parentElement . getId ( ) , name ) : name ; elementToName . put ( id , name ) ; switch ( namespace ) { case SVG : element = Dom . createElementNS ( Dom . NS_SVG , type , id ) ; if ( style != null ) { applyStyle ( element , style ) ; } break ; case VML : element = Dom . createElementNS ( Dom . NS_VML , type , id ) ; Element stroke = Dom . createElementNS ( Dom . NS_VML , "stroke" ) ; element . appendChild ( stroke ) ; Element fill = Dom . createElementNS ( Dom . NS_VML , "fill" ) ; element . appendChild ( fill ) ; if ( "shape" . equals ( name ) ) { String coordsize = parentElement . getAttribute ( "coordsize" ) ; if ( coordsize != null && coordsize . length ( ) > 0 ) { element . setAttribute ( "coordsize" , coordsize ) ; } } Dom . setStyleAttribute ( element , "position" , "absolute" ) ; VmlStyleUtil . applyStyle ( element , style ) ; break ; case HTML : default : element = Dom . createElementNS ( Dom . NS_HTML , type , id ) ; if ( style != null ) { applyStyle ( element , style ) ; } } parentElement . appendChild ( element ) ; Dom . setElementAttribute ( element , "id" , id ) ; return element ; } }
Generic creation method for non - group elements .
10,242
public void deleteGroup ( Object object ) { Element element = getGroup ( object ) ; if ( element != null ) { Element parent = ( Element ) element . getParentElement ( ) ; if ( parent != null ) { deleteRecursively ( parent , element ) ; } } }
Delete this group from the graphics DOM structure .
10,243
public void applyStyle ( Element element , Style style ) { if ( element != null && style != null ) { switch ( namespace ) { case VML : VmlStyleUtil . applyStyle ( element , style ) ; break ; case SVG : if ( style instanceof ShapeStyle ) { applySvgStyle ( element , ( ShapeStyle ) style ) ; } else if ( style instanceof FontStyle ) { applySvgStyle ( element , ( FontStyle ) style ) ; } else if ( style instanceof PictureStyle ) { applySvgStyle ( element , ( PictureStyle ) style ) ; } break ; case HTML : if ( style instanceof ShapeStyle ) { applyHtmlStyle ( element , ( ShapeStyle ) style ) ; } else if ( style instanceof FontStyle ) { applyHtmlStyle ( element , ( FontStyle ) style ) ; } else if ( style instanceof PictureStyle ) { applyHtmlStyle ( element , ( PictureStyle ) style ) ; } break ; } } }
Apply the style .
10,244
public void onFailure ( ) throws InterruptedException { int val = currentFailureCount . incrementAndGet ( ) ; if ( val > 50 ) { currentFailureCount . compareAndSet ( val , MAX_FAILURE_COUNT ) ; val = MAX_FAILURE_COUNT ; } int delay = MIN_DELAY + ( ( MAX_DELAY - MIN_DELAY ) / MAX_FAILURE_COUNT ) * val ; synchronized ( this ) { Logger . d ( TAG , "onFailure: wait " + delay + " ms" ) ; wait ( delay ) ; } }
Called on failure wait required time before exiting method
10,245
public void onFailureNoWait ( ) { Logger . d ( TAG , "onFailureNoWait" ) ; int val = currentFailureCount . incrementAndGet ( ) ; if ( val > 50 ) { currentFailureCount . compareAndSet ( val , MAX_FAILURE_COUNT ) ; val = MAX_FAILURE_COUNT ; } }
onFailure without waiting
10,246
public void showGeometricInfo ( ) { FeatureTransaction ft = getFeatureTransaction ( ) ; if ( infoLabel == null && ft != null && ft . getNewFeatures ( ) != null && ft . getNewFeatures ( ) . length > 0 ) { infoLabel = new GeometricInfoLabel ( ) ; infoLabel . addClickHandler ( new DestroyLabelInfoOnClick ( ) ) ; infoLabel . setGeometry ( ft . getNewFeatures ( ) [ 0 ] . getGeometry ( ) ) ; infoLabel . animateMove ( mapWidget . getWidth ( ) - 155 , 10 ) ; } }
Show an overview of geometric attributes of the geometry that s being edited .
10,247
public void updateGeometricInfo ( ) { FeatureTransaction ft = getFeatureTransaction ( ) ; if ( infoLabel != null && ft != null && ft . getNewFeatures ( ) != null && ft . getNewFeatures ( ) . length > 0 ) { infoLabel . setGeometry ( ft . getNewFeatures ( ) [ 0 ] . getGeometry ( ) ) ; } }
Update the overview of geometric attributes of the geometry that s being edited .
10,248
public void onClick ( MenuItemClickEvent event ) { FeatureTransaction featureTransaction = mapWidget . getMapModel ( ) . getFeatureEditor ( ) . getFeatureTransaction ( ) ; if ( featureTransaction != null ) { controller . cleanup ( ) ; mapWidget . render ( featureTransaction , RenderGroup . VECTOR , RenderStatus . DELETE ) ; mapWidget . getMapModel ( ) . getFeatureEditor ( ) . stopEditing ( ) ; } }
Cancels editing and also removes the FeatureTransaction object from the map .
10,249
public void configure ( String key , String value ) { if ( "x" . equalsIgnoreCase ( key ) ) { xText = value ; } else if ( "y" . equalsIgnoreCase ( key ) ) { yText = value ; } }
Can accept X and Y text values to be printed out .
10,250
public void paint ( Paintable paintable , Object group , MapContext context ) { FeatureTransaction featureTransaction = ( FeatureTransaction ) paintable ; Feature [ ] features = featureTransaction . getNewFeatures ( ) ; if ( features == null ) { return ; } context . getVectorContext ( ) . drawGroup ( mapWidget . getGroup ( RenderGroup . VECTOR ) , featureTransaction ) ; for ( int i = 0 ; i < features . length ; i ++ ) { Geometry geometry = mapWidget . getMapModel ( ) . getMapView ( ) . getWorldViewTransformer ( ) . worldToPan ( features [ i ] . getGeometry ( ) ) ; context . getVectorContext ( ) . drawGroup ( featureTransaction , features [ i ] ) ; if ( geometry instanceof Point ) { paint ( features [ i ] , "featureTransaction.feature" + i , ( Point ) geometry , context . getVectorContext ( ) ) ; } else if ( geometry instanceof MultiPoint ) { paint ( features [ i ] , "featureTransaction.feature" + i , ( MultiPoint ) geometry , context . getVectorContext ( ) ) ; } else if ( geometry instanceof LineString ) { paint ( features [ i ] , "featureTransaction.feature" + i , ( LineString ) geometry , context . getVectorContext ( ) ) ; } else if ( geometry instanceof MultiLineString ) { paint ( features [ i ] , "featureTransaction.feature" + i , ( MultiLineString ) geometry , context . getVectorContext ( ) ) ; } else if ( geometry instanceof Polygon ) { paint ( features [ i ] , "featureTransaction.feature" + i , ( Polygon ) geometry , context . getVectorContext ( ) ) ; } else if ( geometry instanceof MultiPolygon ) { paint ( features [ i ] , "featureTransaction.feature" + i , ( MultiPolygon ) geometry , context . getVectorContext ( ) ) ; } } }
The actual painting function .
10,251
public void setScales ( Double ... scales ) { Arrays . sort ( scales , Collections . reverseOrder ( ) ) ; scaleList = Arrays . asList ( scales ) ; updateScaleList ( ) ; }
Set the specified relative scale values in the select item .
10,252
public void onKeyPress ( KeyPressEvent event ) { String name = event . getKeyName ( ) ; if ( KeyNames . ENTER . equals ( name ) ) { reorderValues ( ) ; } }
Make sure that the scale in the scale select is applied on the map when the user presses the Enter key .
10,253
public void onChanged ( ChangedEvent event ) { String value = ( String ) scaleItem . getValue ( ) ; Double scale = valueToScale . get ( value ) ; if ( scale != null && ! Double . isNaN ( pixelLength ) && 0.0 != pixelLength ) { mapView . setCurrentScale ( scale / pixelLength , MapView . ZoomOption . LEVEL_CLOSEST ) ; } }
When the user selects a different scale have the map zoom to it .
10,254
private void updateScaleList ( ) { refreshPixelLength ( ) ; valueToScale . clear ( ) ; if ( ! Double . isNaN ( pixelLength ) && ( 0.0 != pixelLength ) ) { for ( Double scale : scaleList ) { if ( scale != null ) { String value = ScaleConverter . scaleToString ( scale , precision , significantDigits ) ; valueToScale . put ( value , scale ) ; } } List < String > availableScales = new ArrayList < String > ( ) ; for ( Double scale : scaleList ) { if ( mapView . isResolutionAvailable ( pixelLength / scale ) ) { availableScales . add ( ScaleConverter . scaleToString ( scale , precision , significantDigits ) ) ; } } scaleItem . setValueMap ( availableScales . toArray ( new String [ availableScales . size ( ) ] ) ) ; isScaleItemInitialized = true ; } }
Given the full list of desirable resolutions which ones are actually available? Update the widget accordingly .
10,255
public void outdated_scenario ( ) throws JSONException { httpPost ( "keys" , jsonKey . toString ( ) , 201 ) ; try { sendTranslationUpdate ( "zztranslation" , EN , true ) ; sendTranslationUpdate ( "translation" , FR , true ) ; jsonKey . put ( "translation" , "updated translation" ) ; httpPut ( "keys/" + keyName , jsonKey . toString ( ) , 200 ) ; assertOutdatedStatus ( true ) ; sendTranslationUpdate ( "updated translation" , EN , false ) ; assertOutdatedStatus ( true ) ; sendTranslationUpdate ( "updated translation" , FR , false ) ; assertOutdatedStatus ( false ) ; } finally { httpDelete ( "keys/" + keyName , 204 ) ; } }
Checks the outdated scenario . 1 ) A key is added 2 ) Add fr translation 3 ) Update default translation = > key become outdated 4 ) Update en translation = > key is still outdated 5 ) Update fr translation = > key is no longer outdated
10,256
private Response assertOutdatedStatus ( boolean outdated ) throws JSONException { Response response = httpGet ( "keys/" + keyName ) ; JSONObject actual = new JSONObject ( response . asString ( ) ) ; Assertions . assertThat ( actual . getBoolean ( "outdated" ) ) . isEqualTo ( outdated ) ; return response ; }
Checks the outdated state of the key .
10,257
private void sendTranslationUpdate ( String translation , String locale , boolean outdated ) throws JSONException { JSONObject jsonTranslationValueObject = new JSONObject ( ) ; jsonTranslationValueObject . put ( "translation" , translation ) ; jsonTranslationValueObject . put ( "outdated" , outdated ) ; jsonTranslationValueObject . put ( "locale" , locale ) ; jsonTranslationValueObject . put ( "approx" , true ) ; jsonTranslation . put ( "target" , jsonTranslationValueObject ) ; httpPut ( "translations/" + locale + "/" + keyName , jsonTranslation . toString ( ) ) ; }
Sends an HTTP put request to update the translation for the given locale .
10,258
public void getSnappingSources ( final GeometryArrayFunction callback ) { GwtCommand commandRequest = new GwtCommand ( SearchByLocationRequest . COMMAND ) ; SearchByLocationRequest request = new SearchByLocationRequest ( ) ; request . addLayerWithFilter ( layer . getServerLayerId ( ) , layer . getServerLayerId ( ) , layer . getFilter ( ) ) ; request . setFeatureIncludes ( GeomajasConstant . FEATURE_INCLUDE_GEOMETRY ) ; request . setLocation ( boundsAsGeometry ( ) ) ; request . setCrs ( layer . getMapModel ( ) . getCrs ( ) ) ; request . setQueryType ( SearchByLocationRequest . QUERY_INTERSECTS ) ; request . setSearchType ( SearchByLocationRequest . SEARCH_ALL_LAYERS ) ; commandRequest . setCommandRequest ( request ) ; GwtCommandDispatcher . getInstance ( ) . execute ( commandRequest , new AbstractCommandCallback < SearchByLocationResponse > ( ) { public void execute ( SearchByLocationResponse response ) { if ( response . getFeatureMap ( ) . size ( ) > 0 ) { List < Feature > features = response . getFeatureMap ( ) . values ( ) . iterator ( ) . next ( ) ; Geometry [ ] geometries = new Geometry [ features . size ( ) ] ; for ( int i = 0 ; i < features . size ( ) ; i ++ ) { geometries [ i ] = features . get ( i ) . getGeometry ( ) ; } callback . execute ( geometries ) ; } } } ) ; }
Get the geometries of all features within the map view bounds .
10,259
public static void foreach ( String path , Consumer < ? super String > block ) { Ruby . Enumerator . of ( new EachLineIterable ( new File ( path ) ) ) . each ( block ) ; }
Iterates a file line by line .
10,260
public void close ( ) { try { raFile . close ( ) ; } catch ( IOException e ) { logger . log ( Level . SEVERE , null , e ) ; throw new RuntimeException ( e ) ; } }
Closes this IO .
10,261
public void puts ( String words ) { if ( mode . isWritable ( ) == false ) throw new IllegalStateException ( "IOError: not opened for writing" ) ; try { raFile . write ( words . getBytes ( ) ) ; raFile . writeBytes ( System . getProperty ( "line.separator" ) ) ; } catch ( IOException e ) { logger . log ( Level . SEVERE , null , e ) ; throw new RuntimeException ( e ) ; } }
Writes a line in the file .
10,262
public String read ( ) { if ( mode . isReadable ( ) == false ) throw new IllegalStateException ( "IOError: not opened for reading" ) ; StringBuilder sb = new StringBuilder ( ) ; try { BufferedReader reader = new BufferedReader ( new FileReader ( file ) ) ; char [ ] buf = new char [ 1024 ] ; int numOfChars = 0 ; while ( ( numOfChars = reader . read ( buf ) ) != - 1 ) { sb . append ( String . valueOf ( buf , 0 , numOfChars ) ) ; } reader . close ( ) ; } catch ( IOException e ) { logger . log ( Level . SEVERE , null , e ) ; throw new RuntimeException ( e ) ; } return sb . toString ( ) ; }
Reads the content of a file .
10,263
public void seek ( long pos ) { try { raFile . seek ( pos ) ; } catch ( IOException e ) { logger . log ( Level . SEVERE , null , e ) ; throw new RuntimeException ( e ) ; } }
Moves the cursor to certain position .
10,264
public int write ( String words ) { if ( mode . isWritable ( ) == false ) throw new IllegalStateException ( "IOError: not opened for writing" ) ; try { raFile . write ( words . getBytes ( ) ) ; } catch ( IOException e ) { logger . log ( Level . SEVERE , null , e ) ; throw new RuntimeException ( e ) ; } return words . getBytes ( ) . length ; }
Writes to the file .
10,265
public Layer getLayer ( String layerId ) { org . geomajas . gwt . client . map . layer . Layer < ? > layer = mapModel . getLayer ( layerId ) ; if ( layer instanceof org . geomajas . gwt . client . map . layer . VectorLayer ) { return new VectorLayer ( ( org . geomajas . gwt . client . map . layer . VectorLayer ) layer ) ; } return new LayerImpl ( layer ) ; }
Get a single layer by its identifier .
10,266
public Layer getLayerAt ( int index ) { org . geomajas . gwt . client . map . layer . Layer < ? > layer = mapModel . getLayers ( ) . get ( index ) ; if ( layer instanceof org . geomajas . gwt . client . map . layer . VectorLayer ) { return new VectorLayer ( ( org . geomajas . gwt . client . map . layer . VectorLayer ) layer ) ; } return new LayerImpl ( layer ) ; }
Return the layer at a certain index . If the index can t be found null is returned .
10,267
public Geometry execute ( Geometry geometry ) { if ( geometry instanceof Polygon ) { Polygon polygon = ( Polygon ) geometry ; if ( geometry . isEmpty ( ) ) { return null ; } else { LinearRing [ ] interiorRings = new LinearRing [ polygon . getNumInteriorRing ( ) + 1 ] ; int count = 0 ; for ( int n = 0 ; n < interiorRings . length ; n ++ ) { if ( n == index ) { interiorRings [ n ] = ring ; } else { interiorRings [ n ] = polygon . getInteriorRingN ( count ) ; } } return geometry . getGeometryFactory ( ) . createPolygon ( polygon . getExteriorRing ( ) , interiorRings ) ; } } return null ; }
Execute the operation! When the geometry is not a Polygon null is returned .
10,268
public FormItem createItem ( AbstractReadOnlyAttributeInfo info ) { return AttributeFormFieldRegistry . createFormItem ( info , attributeProvider . createProvider ( info . getName ( ) ) ) ; }
Creates a form item for a specific attribute .
10,269
public void setValue ( String name , BooleanAttribute attribute ) { FormItem item = formWidget . getField ( name ) ; if ( item != null ) { item . setValue ( attribute . getValue ( ) ) ; } }
Apply a boolean attribute value on the form with the given name .
10,270
public void setValue ( String name , ShortAttribute attribute ) { FormItem item = formWidget . getField ( name ) ; if ( item != null ) { item . setValue ( attribute . getValue ( ) ) ; } }
Apply a short attribute value on the form with the given name .
10,271
public void onClick ( MenuItemClickEvent event ) { final FeatureTransaction ft = mapWidget . getMapModel ( ) . getFeatureEditor ( ) . getFeatureTransaction ( ) ; if ( ft != null ) { SimpleFeatureAttributeWindow window = new SimpleFeatureAttributeWindow ( ft . getNewFeatures ( ) [ 0 ] ) { public void onOk ( Feature feature ) { ft . getNewFeatures ( ) [ 0 ] . setAttributes ( feature . getAttributes ( ) ) ; } public void onClose ( ) { } } ; window . show ( ) ; } }
Remove an existing ring from a Polygon or MultiPolygon at a given index .
10,272
public void savePage ( WizardView view , Runnable successCallback , Runnable failureCallback ) { if ( null != successCallback ) { successCallback . run ( ) ; } }
Save the page data . This can communicate with the server if needed . The return is handled by calling either the success or failure callback .
10,273
public boolean canShow ( ) { WizardPage < DATA > back = getPreviousPage ( ) ; while ( back != null && back . isValid ( ) ) { back = back . getPreviousPage ( ) ; } return back == null ; }
Returns whether this page can already be shown to the user . Default implementation checks whether all previous pages have been validated .
10,274
private void buildGui ( ) { setTitle ( I18nProvider . getGlobal ( ) . commandError ( ) ) ; setHeaderIcon ( WidgetLayout . iconError ) ; setIsModal ( true ) ; setShowModalMask ( true ) ; setModalMaskOpacity ( WidgetLayout . modalMaskOpacity ) ; setWidth ( WidgetLayout . exceptionWindowWidth ) ; setHeight ( WidgetLayout . exceptionWindowHeightNormal ) ; setKeepInParentRect ( WidgetLayout . exceptionWindowKeepInScreen ) ; setCanDragResize ( true ) ; centerInPage ( ) ; setAutoSize ( true ) ; addCloseClickHandler ( this ) ; addItem ( createErrorLayout ( error ) ) ; }
Build the entire GUI for this widget .
10,275
private VLayout createErrorLayout ( ExceptionDto error ) { VLayout layout = new VLayout ( ) ; layout . setWidth100 ( ) ; layout . setHeight100 ( ) ; layout . setPadding ( WidgetLayout . marginLarge ) ; HLayout topLayout = new HLayout ( WidgetLayout . marginLarge ) ; topLayout . setWidth100 ( ) ; Img icon = new Img ( WidgetLayout . iconError , WidgetLayout . exceptionWindowIconSize , WidgetLayout . exceptionWindowIconSize ) ; topLayout . addMember ( icon ) ; HTMLFlow message = new HTMLFlow ( ) ; message . setWidth100 ( ) ; message . setHeight100 ( ) ; message . setLayoutAlign ( VerticalAlignment . TOP ) ; message . setContents ( HtmlBuilder . divStyle ( WidgetLayout . exceptionWindowMessageStyle , error . getMessage ( ) ) ) ; topLayout . addMember ( message ) ; layout . addMember ( topLayout ) ; if ( error . getStackTrace ( ) != null && error . getStackTrace ( ) . length > 0 ) { expandButton = new Button ( MESSAGES . exceptionDetailsView ( ) ) ; expandButton . setWidth ( WidgetLayout . exceptionWindowButtonWidth ) ; expandButton . setLayoutAlign ( Alignment . RIGHT ) ; expandButton . addClickHandler ( new ClickHandler ( ) { public void onClick ( ClickEvent event ) { setDetailsVisible ( ! detailsLayout . isVisible ( ) ) ; } } ) ; layout . addMember ( expandButton ) ; String content = getDetails ( error ) ; HTMLPane detailPane = new HTMLPane ( ) ; detailPane . setContents ( content ) ; detailPane . setWidth100 ( ) ; detailPane . setHeight100 ( ) ; detailsLayout = new VLayout ( ) ; detailsLayout . setWidth100 ( ) ; detailsLayout . setHeight100 ( ) ; detailsLayout . addMember ( detailPane ) ; detailsLayout . setBorder ( WidgetLayout . exceptionWindowDetailBorderStyle ) ; layout . addMember ( detailsLayout ) ; } return layout ; }
Create the GUI for a single exception .
10,276
private void setDetailsVisible ( boolean detailsVisible ) { detailsLayout . setVisible ( detailsVisible ) ; if ( detailsVisible ) { setAutoSize ( false ) ; expandButton . setTitle ( MESSAGES . exceptionDetailsHide ( ) ) ; setHeight ( WidgetLayout . exceptionWindowHeightDetails ) ; } else { expandButton . setTitle ( MESSAGES . exceptionDetailsView ( ) ) ; setHeight ( WidgetLayout . exceptionWindowHeightNormal ) ; } }
Toggle the visibility of the exception details .
10,277
public static String tagClassHtmlContent ( String tag , String clazz , String ... content ) { return openTagClassHtmlContent ( tag , clazz , content ) + closeTag ( tag ) ; }
Build a String containing a HTML opening tag with given CSS class HTML content and closing tag .
10,278
public static String openTagClassHtmlContent ( String tag , String clazz , String ... content ) { return openTagHtmlContent ( tag , clazz , null , content ) ; }
Build a String containing a HTML opening tag with given CSS class and concatenates the given HTML content .
10,279
public void clearSelectedFeatures ( ) { List < Feature > clone = new LinkedList < Feature > ( selectedFeatures . values ( ) ) ; for ( Feature feature : clone ) { selectedFeatures . remove ( feature . getId ( ) ) ; handlerManager . fireEvent ( new FeatureDeselectedEvent ( feature ) ) ; } }
Clear the list of selected features .
10,280
public static String decode ( Style style ) { if ( style != null ) { if ( style instanceof ShapeStyle ) { return decode ( ( ShapeStyle ) style ) ; } else if ( style instanceof FontStyle ) { return decode ( ( FontStyle ) style ) ; } else if ( style instanceof PictureStyle ) { return decode ( ( PictureStyle ) style ) ; } } return "" ; }
Return the CSS equivalent of the Style object .
10,281
public static String getType ( GeometryIndex instance ) { switch ( instance . getType ( ) ) { case TYPE_GEOMETRY : return "geometry" ; case TYPE_VERTEX : return "vertex" ; case TYPE_EDGE : return "edge" ; default : return "unknown" ; } }
Get the type of sub - part this index points to . Can be a vertex edge or sub - geometry .
10,282
public void addCard ( KEY_TYPE key , Canvas card ) { if ( currentCard != null ) { currentCard . hide ( ) ; } addMember ( card ) ; currentCard = card ; cards . put ( key , card ) ; }
Add a card to the deck and associate it with the specified key .
10,283
public void showCard ( KEY_TYPE key ) { Canvas newCurrent = cards . get ( key ) ; if ( null != newCurrent ) { if ( newCurrent != currentCard && null != currentCard ) { currentCard . hide ( ) ; } currentCard = newCurrent ; currentCard . show ( ) ; } }
Show the card associated with the specified key .
10,284
public void addFeatures ( List < Feature > features ) { numFeatures += features . size ( ) ; for ( Feature feature : features ) { featureListGrid . addFeature ( feature ) ; } if ( sortFeatures ) { featureListGrid . sort ( sortFieldName , sortDirGWT ) ; } if ( exportCsvHandler instanceof ExportFeatureListToCsvHandler ) { ( ( ExportFeatureListToCsvHandler ) exportCsvHandler ) . setFeatures ( features ) ; } }
Add features to grid .
10,285
public void setCriterion ( Criterion criterion ) { this . criterion = criterion ; if ( exportCsvHandler == null || exportCsvHandler instanceof ExportFeatureListToCsvHandler ) { this . exportCsvHandler = new ExportSearchToCsvHandler ( mapWidget . getMapModel ( ) , layer , criterion ) ; } else if ( exportCsvHandler instanceof ExportSearchToCsvHandler ) { ( ( ExportSearchToCsvHandler ) exportCsvHandler ) . setCriterion ( criterion ) ; } }
Set the search criterion .
10,286
public boolean contains ( Paintable p ) { if ( children . contains ( p ) ) { return true ; } for ( Paintable t : children ) { if ( t instanceof Composite ) { if ( ( ( Composite ) t ) . contains ( p ) ) { return true ; } } } return false ; }
Recursively checks children to find p .
10,287
public void onLeafClick ( LeafClickEvent event ) { LayerTreeTreeNode layerTreeNode = ( LayerTreeTreeNode ) event . getLeaf ( ) ; if ( null != selectedLayerTreeNode && layerTreeNode . getLayer ( ) . getId ( ) . equals ( selectedLayerTreeNode . getLayer ( ) . getId ( ) ) ) { mapModel . selectLayer ( null ) ; } else { mapModel . selectLayer ( layerTreeNode . getLayer ( ) ) ; } }
When the user clicks on a leaf the header text of the tree table is changed to the selected leaf and the toolbar buttons are updated to represent the correct state of the buttons .
10,288
private ToolStrip buildToolstrip ( MapWidget mapWidget ) { toolStrip = new ToolStrip ( ) ; toolStrip . setWidth100 ( ) ; toolStrip . setPadding ( 3 ) ; ClientLayerTreeInfo layerTreeInfo = mapModel . getMapInfo ( ) . getLayerTree ( ) ; if ( layerTreeInfo != null ) { for ( ClientToolInfo tool : layerTreeInfo . getTools ( ) ) { String id = tool . getToolId ( ) ; Canvas button = null ; ToolbarBaseAction action = LayerTreeRegistry . getToolbarAction ( id , mapWidget ) ; if ( action instanceof ToolbarWidget ) { toolStrip . addMember ( ( ( ToolbarWidget ) action ) . getWidget ( ) ) ; } else if ( action instanceof ToolbarCanvas ) { button = ( ( ToolbarCanvas ) action ) . getCanvas ( ) ; } else if ( action instanceof LayerTreeAction ) { button = new LayerTreeButton ( this , ( LayerTreeAction ) action ) ; } else if ( action instanceof LayerTreeModalAction ) { button = new LayerTreeModalButton ( this , ( LayerTreeModalAction ) action ) ; } else { String msg = "LayerTree tool with id " + id + " unknown." ; Log . logError ( msg ) ; SC . warn ( msg ) ; } if ( button != null ) { toolStrip . addMember ( button ) ; LayoutSpacer spacer = new LayoutSpacer ( ) ; spacer . setWidth ( WidgetLayout . layerTreePadding ) ; toolStrip . addMember ( spacer ) ; } } } final Canvas [ ] toolStripMembers = toolStrip . getMembers ( ) ; Timer t = new Timer ( ) { public void run ( ) { updateButtonIconsAndStates ( toolStripMembers ) ; } } ; t . schedule ( 10 ) ; return toolStrip ; }
Builds the toolbar
10,289
private void buildTree ( MapModel mapModel ) { treeGrid . setWidth100 ( ) ; treeGrid . setHeight100 ( ) ; treeGrid . setShowHeader ( false ) ; tree = new RefreshableTree ( ) ; final TreeNode nodeRoot = new TreeNode ( "ROOT" ) ; tree . setRoot ( nodeRoot ) ; ClientLayerTreeInfo layerTreeInfo = mapModel . getMapInfo ( ) . getLayerTree ( ) ; if ( layerTreeInfo != null ) { ClientLayerTreeNodeInfo treeNode = layerTreeInfo . getTreeNode ( ) ; processNode ( treeNode , nodeRoot , tree , mapModel , false ) ; } treeGrid . setData ( tree ) ; treeGrid . addLeafClickHandler ( this ) ; treeGrid . addFolderClickHandler ( this ) ; for ( Layer < ? > layer : mapModel . getLayers ( ) ) { registrations . add ( layer . addLayerChangedHandler ( new LayerChangedHandler ( ) { public void onLabelChange ( LayerLabeledEvent event ) { } public void onVisibleChange ( LayerShownEvent event ) { for ( TreeNode node : tree . getAllNodes ( ) ) { if ( node . getName ( ) . equals ( event . getLayer ( ) . getLabel ( ) ) ) { if ( node instanceof LayerTreeTreeNode ) { ( ( LayerTreeTreeNode ) node ) . updateIcon ( ) ; } } } } } ) ) ; } }
Builds up the tree showing the layers
10,290
private void updateButtonIconsAndStates ( Canvas [ ] toolStripMembers ) { for ( Canvas toolStripMember : toolStripMembers ) { if ( toolStripMember instanceof LayerTreeModalButton ) { ( ( LayerTreeModalButton ) toolStripMember ) . update ( ) ; } else if ( toolStripMember instanceof LayerTreeButton ) { ( ( LayerTreeButton ) toolStripMember ) . update ( ) ; } } }
Updates the icons and the state of the buttons in the toolbar based upon the currently selected layer
10,291
public void unhide ( Object group , String name ) { if ( isAttached ( ) ) { Element element = helper . getElement ( group , name ) ; if ( element != null ) { Dom . setStyleAttribute ( element , "visibility" , "inherit" ) ; } } }
Show the specified element in the specified group . If the element does not exist nothing will happen .
10,292
public void onLeafClick ( LeafClickEvent event ) { LayerTreeTreeNode layerTreeNode ; if ( event . getLeaf ( ) instanceof LayerTreeLegendItemNode ) { layerTreeNode = ( ( LayerTreeLegendItemNode ) event . getLeaf ( ) ) . parent ; treeGrid . deselectRecord ( event . getLeaf ( ) ) ; treeGrid . selectRecord ( layerTreeNode ) ; } else { layerTreeNode = ( LayerTreeTreeNode ) event . getLeaf ( ) ; } mapModel . selectLayer ( layerTreeNode . getLayer ( ) ) ; }
When a legendItem is selected select the layer instead .
10,293
public void println ( String text , Color color ) { final Label label = new Label ( text , skin , "outputEntry" ) ; label . setColor ( color ) ; label . setWrap ( true ) ; addLabel ( label ) ; }
Add a single line to this buffer . The line may contain a \ n character and it will be honored but this is discouraged .
10,294
@ SuppressWarnings ( "unchecked" ) protected int hashFields ( int hash , Map < FieldDescriptor , Object > map ) { for ( Map . Entry < FieldDescriptor , Object > entry : map . entrySet ( ) ) { FieldDescriptor field = entry . getKey ( ) ; Object value = entry . getValue ( ) ; hash = ( 37 * hash ) + field . getNumber ( ) ; if ( field . getType ( ) != FieldDescriptor . Type . ENUM ) { hash = ( 53 * hash ) + value . hashCode ( ) ; } else if ( field . isRepeated ( ) ) { List < ? extends EnumLite > list = ( List < ? extends EnumLite > ) value ; hash = ( 53 * hash ) + hashEnumList ( list ) ; } else { hash = ( 53 * hash ) + hashEnum ( ( EnumLite ) value ) ; } } return hash ; }
Get a hash code for given fields and values using the given seed .
10,295
public static void initializeArg ( final RemoteProgram remoteProgram , final String [ ] arguments , final Launch < ? > launch ) throws OptionException , ParserException { int numberOfEquals = 0 ; for ( String argument : arguments ) { if ( argument . indexOf ( '=' ) > - 1 ) numberOfEquals ++ ; } if ( numberOfEquals != arguments . length ) throw new OptionException ( LaunchingMessageKind . WREMOTE001 . format ( remoteProgram . getClass ( ) . getCanonicalName ( ) ) ) ; for ( String argument : arguments ) { if ( argument . indexOf ( "=" ) > 0 ) { String [ ] arg = argument . split ( "=" ) ; String argName = arg [ 0 ] ; String argValue = null ; if ( arg . length > 1 ) argValue = arg [ 1 ] ; if ( argValue != null && argValue . trim ( ) . length ( ) == 0 ) argValue = null ; if ( argValue != null && argValue . charAt ( 0 ) == '"' && argValue . charAt ( argValue . length ( ) - 1 ) == '"' ) { argValue = argValue . substring ( 1 , argValue . length ( ) - 1 ) ; } if ( argValue != null && argValue . charAt ( 0 ) == '\'' && argValue . charAt ( argValue . length ( ) - 1 ) == '\'' ) { argValue = argValue . substring ( 1 , argValue . length ( ) - 1 ) ; } if ( argValue != null && argValue . equals ( "''" ) ) { argValue = "" ; } Iterator < Argument > argumentIterator = remoteProgram . getArguments ( ) . iterator ( ) ; boolean found = false ; while ( argumentIterator . hasNext ( ) && ! found ) { Argument a = argumentIterator . next ( ) ; try { if ( a . getName ( ) . equals ( argName ) ) { a . setValueUsingParser ( argValue ) ; found = true ; } } catch ( Exception e ) { throw new OptionException ( LaunchingMessageKind . EREMOTE0010 . format ( a . getName ( ) , remoteProgram . getClass ( ) . getCanonicalName ( ) ) , e ) ; } } if ( ! found ) { throw new OptionException ( LaunchingMessageKind . EREMOTE0012 . format ( argument , remoteProgram . getClass ( ) . getCanonicalName ( ) , argument ) ) ; } } else { throw new OptionException ( LaunchingMessageKind . EREMOTE0011 . format ( remoteProgram . getClass ( ) . getCanonicalName ( ) ) ) ; } } }
Check the validity of arguments values coming from remote launching with regard to types . If not done the Quartz Exception thrown doesn t stop the launch and Program may be launched with invalid arguments values .
10,296
public void invoke ( Node root , Action result ) throws IOException { doInvoke ( 0 , root , root . isLink ( ) , new ArrayList < > ( includes ) , new ArrayList < > ( excludes ) , result ) ; }
Main methods of this class .
10,297
public String serialize ( Node node , boolean format ) { Result result ; StringWriter dest ; if ( node == null ) { throw new IllegalArgumentException ( ) ; } dest = new StringWriter ( ) ; result = new StreamResult ( dest ) ; try { serialize ( node , result , format ) ; } catch ( IOException e ) { throw new IllegalStateException ( e ) ; } return dest . getBuffer ( ) . toString ( ) ; }
does not genereate encoding headers
10,298
public IContextMapping < INode > filter ( IContextMapping < INode > mapping ) throws MappingFilterException { if ( 0 < mapping . size ( ) ) { IContext sourceContext = mapping . getSourceContext ( ) ; IContext targetContext = mapping . getTargetContext ( ) ; sourceIndex = new ArrayList < Integer > ( ) ; targetIndex = new ArrayList < Integer > ( ) ; defautlMappings = mapping ; spsmMapping = mappingFactory . getContextMappingInstance ( sourceContext , targetContext ) ; spsmMapping . setSimilarity ( computeSimilarity ( mapping ) ) ; log . info ( "Similarity: " + spsmMapping . getSimilarity ( ) ) ; if ( isRelated ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . EQUIVALENCE ) || isRelated ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . LESS_GENERAL ) || isRelated ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . MORE_GENERAL ) ) { setStrongestMapping ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) ) ; filterMappingsOfChildren ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . EQUIVALENCE ) ; filterMappingsOfChildren ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . MORE_GENERAL ) ; filterMappingsOfChildren ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . LESS_GENERAL ) ; } return spsmMapping ; } return mapping ; }
Sorts the siblings in the source and target tree defined in the constructor using the given mapping .
10,299
private void filterMappingsOfChildren ( INode sourceParent , INode targetParent , char semanticRelation ) { List < INode > source = new ArrayList < INode > ( sourceParent . getChildrenList ( ) ) ; List < INode > target = new ArrayList < INode > ( targetParent . getChildrenList ( ) ) ; sourceIndex . add ( sourceParent . getLevel ( ) , 0 ) ; targetIndex . add ( targetParent . getLevel ( ) , 0 ) ; if ( source . size ( ) >= 1 && target . size ( ) >= 1 ) { filterMappingsOfSiblingsByRelation ( source , target , semanticRelation ) ; } sourceIndex . remove ( sourceParent . getLevel ( ) ) ; targetIndex . remove ( targetParent . getLevel ( ) ) ; }
Sorts the children of the given nodes .