idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
6,500
@ Pure public static double distanceSquaredSegmentPoint ( double sx1 , double sy1 , double sz1 , double sx2 , double sy2 , double sz2 , double px , double py , double pz ) { double ratio = getPointProjectionFactorOnSegmentLine ( px , py , pz , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; if ( ratio <= 0. ) return FunctionalPoint3D . distanceSquaredPointPoint ( px , py , pz , sx1 , sy1 , sz1 ) ; if ( ratio >= 1. ) return FunctionalPoint3D . distanceSquaredPointPoint ( px , py , pz , sx2 , sy2 , sz2 ) ; return FunctionalPoint3D . distanceSquaredPointPoint ( px , py , pz , ( 1. - ratio ) * sx1 + ratio * sx2 , ( 1. - ratio ) * sy1 + ratio * sy2 , ( 1. - ratio ) * sz1 + ratio * sz2 ) ; }
Compute and replies the perpendicular squared distance from a point to a segment .
245
15
6,501
@ Pure public static double distanceSegmentPoint ( double sx1 , double sy1 , double sz1 , double sx2 , double sy2 , double sz2 , double px , double py , double pz ) { double ratio = getPointProjectionFactorOnSegmentLine ( px , py , pz , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; if ( ratio <= 0. ) return FunctionalPoint3D . distancePointPoint ( px , py , pz , sx1 , sy1 , sz1 ) ; if ( ratio >= 1. ) return FunctionalPoint3D . distancePointPoint ( px , py , pz , sx2 , sy2 , sz2 ) ; return FunctionalPoint3D . distancePointPoint ( px , py , pz , ( 1. - ratio ) * sx1 + ratio * sx2 , ( 1. - ratio ) * sy1 + ratio * sy2 , ( 1. - ratio ) * sz1 + ratio * sz2 ) ; }
Compute and replies the perpendicular distance from a point to a segment .
237
14
6,502
@ Pure public static double getPointProjectionFactorOnSegmentLine ( double px , double py , double pz , double s1x , double s1y , double s1z , double s2x , double s2y , double s2z ) { double dx = s2x - s1x ; double dy = s2y - s1y ; double dz = s2z - s1z ; if ( dx == 0. && dy == 0. && dz == 0. ) return 0. ; return ( ( px - s1x ) * dx + ( py - s1y ) * dy + ( pz - s1z ) * dz ) / ( dx * dx + dy * dy + dz * dz ) ; }
Replies the projection a point on a segment .
166
10
6,503
@ Pure public static double distanceSegmentSegment ( double ax1 , double ay1 , double az1 , double ax2 , double ay2 , double az2 , double bx1 , double by1 , double bz1 , double bx2 , double by2 , double bz2 ) { return Math . sqrt ( distanceSquaredSegmentSegment ( ax1 , ay1 , az1 , ax2 , ay2 , az2 , bx1 , by1 , bz1 , bx2 , by2 , bz2 ) ) ; }
Compute and replies the distance between two segments .
121
10
6,504
@ Pure public static double distanceSquaredSegmentSegment ( double ax1 , double ay1 , double az1 , double ax2 , double ay2 , double az2 , double bx1 , double by1 , double bz1 , double bx2 , double by2 , double bz2 ) { Vector3f u = new Vector3f ( ax2 - ax1 , ay2 - ay1 , az2 - az1 ) ; Vector3f v = new Vector3f ( bx2 - bx1 , by2 - by1 , bz2 - bz1 ) ; Vector3f w = new Vector3f ( ax1 - bx1 , ay1 - by1 , az1 - bz1 ) ; double a = u . dot ( u ) ; double b = u . dot ( v ) ; double c = v . dot ( v ) ; double d = u . dot ( w ) ; double e = v . dot ( w ) ; double D = a * c - b * b ; double sc , sN , tc , tN ; double sD = D ; double tD = D ; // compute the line parameters of the two closest points if ( MathUtil . isEpsilonZero ( D ) ) { // the lines are almost parallel // force using point P0 on segment S1 // to prevent possible division by 0.0 later sN = 0. ; sD = 1. ; tN = e ; tD = c ; } else { // get the closest points on the infinite lines sN = b * e - c * d ; tN = a * e - b * d ; if ( sN < 0. ) { // sc < 0 => the s=0 edge is visible sN = 0. ; tN = e ; tD = c ; } else if ( sN > sD ) { // sc > 1 => the s=1 edge is visible sN = sD ; tN = e + b ; tD = c ; } } if ( tN < 0. ) { // tc < 0 => the t=0 edge is visible tN = 0. ; // recompute sc for this edge if ( - d < 0. ) sN = 0. ; else if ( - d > a ) sN = sD ; else { sN = - d ; sD = a ; } } else if ( tN > tD ) { // tc > 1 => the t=1 edge is visible tN = tD ; // recompute sc for this edge if ( ( - d + b ) < 0. ) sN = 0 ; else if ( ( - d + b ) > a ) sN = sD ; else { sN = ( - d + b ) ; sD = a ; } } // finally do the division to get sc and tc sc = ( MathUtil . isEpsilonZero ( sN ) ? 0. : sN / sD ) ; tc = ( MathUtil . isEpsilonZero ( tN ) ? 0. : tN / tD ) ; // get the difference of the two closest points // = S1(sc) - S2(tc) // reuse u, v, w u . scale ( sc ) ; w . add ( u ) ; v . scale ( tc ) ; w . sub ( v ) ; return w . lengthSquared ( ) ; }
Compute and replies the squared distance between two segments .
728
11
6,505
@ Pure public double distanceSegment ( Point3D point ) { return distanceSegmentPoint ( getX1 ( ) , getY1 ( ) , getZ1 ( ) , getX2 ( ) , getY2 ( ) , getZ2 ( ) , point . getX ( ) , point . getY ( ) , point . getZ ( ) ) ; }
Replies the distance between this segment and the given point .
79
12
6,506
@ Pure public double distanceLine ( Point3D point ) { return distanceLinePoint ( getX1 ( ) , getY1 ( ) , getZ1 ( ) , getX2 ( ) , getY2 ( ) , getZ2 ( ) , point . getX ( ) , point . getY ( ) , point . getZ ( ) ) ; }
Replies the distance between the line of this segment and the given point .
77
15
6,507
@ Pure public double distanceSquaredSegment ( Point3D point ) { return distanceSquaredSegmentPoint ( getX1 ( ) , getY1 ( ) , getZ1 ( ) , getX2 ( ) , getY2 ( ) , getZ2 ( ) , point . getX ( ) , point . getY ( ) , point . getZ ( ) ) ; }
Replies the squared distance between this segment and the given point .
83
13
6,508
@ Pure public double distanceSquaredLine ( Point3D point ) { return distanceSquaredLinePoint ( getX1 ( ) , getY1 ( ) , getZ1 ( ) , getX2 ( ) , getY2 ( ) , getZ2 ( ) , point . getX ( ) , point . getY ( ) , point . getZ ( ) ) ; }
Replies the squared distance between the line of this segment and the given point .
81
16
6,509
protected boolean onBusLineAdded ( BusLine line , int index ) { if ( this . autoUpdate . get ( ) ) { try { addMapLayer ( index , new BusLineLayer ( line , isLayerAutoUpdated ( ) ) ) ; return true ; } catch ( Throwable exception ) { // } } return false ; }
Invoked when a bus line was added in the attached network .
69
13
6,510
protected boolean onBusLineRemoved ( BusLine line , int index ) { if ( this . autoUpdate . get ( ) ) { try { removeMapLayerAt ( index ) ; return true ; } catch ( Throwable exception ) { // } } return false ; }
Invoked when a bus line was removed from the attached network .
55
13
6,511
@ Nonnull public static ImmutableKeyValueSource < Symbol , ByteSource > fromFileMap ( final Map < Symbol , File > fileMap ) { return new FileMapKeyToByteSource ( fileMap ) ; }
Creates a new key - value source based on the contents of the specified symbol to file map .
45
20
6,512
@ Nonnull public static ImmutableKeyValueSource < Symbol , ByteSource > fromPalDB ( final File dbFile ) throws IOException { return PalDBKeyValueSource . fromFile ( dbFile ) ; }
Creates a new key - value source based on the contents of the specified embedded database .
44
18
6,513
protected JTree newTree ( ) { JTree tree = new JTree ( ) ; tree . setModel ( newTreeModel ( getModel ( ) ) ) ; tree . setEditable ( true ) ; tree . getSelectionModel ( ) . setSelectionMode ( TreeSelectionModel . SINGLE_TREE_SELECTION ) ; tree . addMouseListener ( new MouseAdapter ( ) { @ Override public void mousePressed ( MouseEvent e ) { int selRow = tree . getRowForLocation ( e . getX ( ) , e . getY ( ) ) ; if ( selRow != - 1 ) { if ( e . getClickCount ( ) == 1 ) { onSingleClick ( e ) ; } else if ( e . getClickCount ( ) == 2 ) { onDoubleClick ( e ) ; } } } } ) ; return tree ; }
New tree .
188
3
6,514
public void add ( Iterator < AbstractPathElement3F > iterator ) { AbstractPathElement3F element ; while ( iterator . hasNext ( ) ) { element = iterator . next ( ) ; switch ( element . type ) { case MOVE_TO : moveTo ( element . getToX ( ) , element . getToY ( ) , element . getToZ ( ) ) ; break ; case LINE_TO : lineTo ( element . getToX ( ) , element . getToY ( ) , element . getToZ ( ) ) ; break ; case QUAD_TO : quadTo ( element . getCtrlX1 ( ) , element . getCtrlY1 ( ) , element . getCtrlZ1 ( ) , element . getToX ( ) , element . getToY ( ) , element . getToZ ( ) ) ; break ; case CURVE_TO : curveTo ( element . getCtrlX1 ( ) , element . getCtrlY1 ( ) , element . getCtrlZ1 ( ) , element . getCtrlX2 ( ) , element . getCtrlY2 ( ) , element . getCtrlZ2 ( ) , element . getToX ( ) , element . getToY ( ) , element . getToZ ( ) ) ; break ; case CLOSE : closePath ( ) ; break ; default : } } }
Add the elements replied by the iterator into this path .
289
11
6,515
public double length ( ) { if ( this . isEmpty ( ) ) return 0 ; double length = 0 ; PathIterator3f pi = getPathIterator ( MathConstants . SPLINE_APPROXIMATION_RATIO ) ; AbstractPathElement3F pathElement = pi . next ( ) ; if ( pathElement . type != PathElementType . MOVE_TO ) { throw new IllegalArgumentException ( "missing initial moveto in path definition" ) ; } Path3f subPath ; double curx , cury , curz , movx , movy , movz , endx , endy , endz ; curx = movx = pathElement . getToX ( ) ; cury = movy = pathElement . getToY ( ) ; curz = movz = pathElement . getToZ ( ) ; while ( pi . hasNext ( ) ) { pathElement = pi . next ( ) ; switch ( pathElement . type ) { case MOVE_TO : movx = curx = pathElement . getToX ( ) ; movy = cury = pathElement . getToY ( ) ; movz = curz = pathElement . getToZ ( ) ; break ; case LINE_TO : endx = pathElement . getToX ( ) ; endy = pathElement . getToY ( ) ; endz = pathElement . getToZ ( ) ; length += FunctionalPoint3D . distancePointPoint ( curx , cury , curz , endx , endy , endz ) ; curx = endx ; cury = endy ; curz = endz ; break ; case QUAD_TO : endx = pathElement . getToX ( ) ; endy = pathElement . getToY ( ) ; endz = pathElement . getToZ ( ) ; subPath = new Path3f ( ) ; subPath . moveTo ( curx , cury , curz ) ; subPath . quadTo ( pathElement . getCtrlX1 ( ) , pathElement . getCtrlY1 ( ) , pathElement . getCtrlZ1 ( ) , endx , endy , endz ) ; length += subPath . length ( ) ; curx = endx ; cury = endy ; curz = endz ; break ; case CURVE_TO : endx = pathElement . getToX ( ) ; endy = pathElement . getToY ( ) ; endz = pathElement . getToZ ( ) ; subPath = new Path3f ( ) ; subPath . moveTo ( curx , cury , curz ) ; subPath . curveTo ( pathElement . getCtrlX1 ( ) , pathElement . getCtrlY1 ( ) , pathElement . getCtrlZ1 ( ) , pathElement . getCtrlX2 ( ) , pathElement . getCtrlY2 ( ) , pathElement . getCtrlZ2 ( ) , endx , endy , endz ) ; length += subPath . length ( ) ; curx = endx ; cury = endy ; curz = endz ; break ; case CLOSE : if ( curx != movx || cury != movy || curz != movz ) { length += FunctionalPoint3D . distancePointPoint ( curx , cury , curz , movx , movy , movz ) ; } curx = movx ; cury = movy ; cury = movz ; break ; default : } } return length ; }
FIXME TO BE IMPLEMENTED IN POLYLINE
752
12
6,516
private ImmutableMap < Integer , Integer > lightEREOffsetToEDTOffset ( String document ) { final ImmutableMap . Builder < Integer , Integer > offsetMap = ImmutableMap . builder ( ) ; int EDT = 0 ; // lightERE treats these as one, not two (as an XML parser would) document = document . replaceAll ( "\\r\\n" , "\n" ) ; for ( int i = 0 ; i < document . length ( ) ; i ++ ) { final String c = document . substring ( i , i + 1 ) ; // skip <tags> if ( c . equals ( "<" ) ) { i = document . indexOf ( ' ' , i ) ; continue ; } offsetMap . put ( i , EDT ) ; EDT ++ ; } return offsetMap . build ( ) ; }
lightERE offsets are indexed into the document including text inside tags EDT offsets are
176
15
6,517
protected boolean validate ( String text ) { try { String [ ] strings = text . split ( "," ) ; for ( int i = 0 ; i < strings . length ; i ++ ) { Integer . parseInt ( strings [ i ] . trim ( ) ) ; } return true ; } catch ( NumberFormatException e ) { return false ; } }
Validate the given string that it is a int array
73
11
6,518
private Collection < EqClassT > getAlignedTo ( final Object item ) { if ( rightEquivalenceClassesToProvenances . containsKey ( item ) && leftEquivalenceClassesToProvenances . containsKey ( item ) ) { return ImmutableList . of ( ( EqClassT ) item ) ; } else { return ImmutableList . of ( ) ; } }
Any equivalence class is by definition aligned to itself if it is present on both the left and the right . Otherwise it has no alignment .
85
28
6,519
public synchronized < T extends EventListener > void add ( Class < T > type , T listener ) { assert listener != null ; if ( this . listeners == NULL ) { // if this is the first listener added, // initialize the lists this . listeners = new Object [ ] { type , listener } ; } else { // Otherwise copy the array and add the new listener final int i = this . listeners . length ; final Object [ ] tmp = new Object [ i + 2 ] ; System . arraycopy ( this . listeners , 0 , tmp , 0 , i ) ; tmp [ i ] = type ; tmp [ i + 1 ] = listener ; this . listeners = tmp ; } }
Adds the listener as a listener of the specified type .
141
11
6,520
public synchronized < T extends EventListener > void remove ( Class < T > type , T listener ) { assert listener != null ; // Is l on the list? int index = - 1 ; for ( int i = this . listeners . length - 2 ; i >= 0 ; i -= 2 ) { if ( ( this . listeners [ i ] == type ) && ( this . listeners [ i + 1 ] . equals ( listener ) ) ) { index = i ; break ; } } // If so, remove it if ( index != - 1 ) { final Object [ ] tmp = new Object [ this . listeners . length - 2 ] ; // Copy the list up to index System . arraycopy ( this . listeners , 0 , tmp , 0 , index ) ; // Copy from two past the index, up to // the end of tmp (which is two elements // shorter than the old list) if ( index < tmp . length ) { System . arraycopy ( this . listeners , index + 2 , tmp , index , tmp . length - index ) ; } // set the listener array to the new array or null this . listeners = ( tmp . length == 0 ) ? NULL : tmp ; } }
Removes the listener as a listener of the specified type .
246
12
6,521
private void writeObject ( ObjectOutputStream stream ) throws IOException { final Object [ ] lList = this . listeners ; stream . defaultWriteObject ( ) ; // Save the non-null event listeners: for ( int i = 0 ; i < lList . length ; i += 2 ) { final Class < ? > t = ( Class < ? > ) lList [ i ] ; final EventListener l = ( EventListener ) lList [ i + 1 ] ; if ( ( l != null ) && ( l instanceof Serializable ) ) { stream . writeObject ( t . getName ( ) ) ; stream . writeObject ( l ) ; } } stream . writeObject ( null ) ; }
Serialization support .
146
4
6,522
@ Pure public static MathFunctionRange [ ] createDiscreteSet ( double ... values ) { final MathFunctionRange [ ] bounds = new MathFunctionRange [ values . length ] ; for ( int i = 0 ; i < values . length ; ++ i ) { bounds [ i ] = new MathFunctionRange ( values [ i ] ) ; } return bounds ; }
Create a set of bounds that correspond to the specified discrete values .
75
13
6,523
@ Pure public static MathFunctionRange [ ] createSet ( double ... values ) { final MathFunctionRange [ ] bounds = new MathFunctionRange [ values . length / 2 ] ; for ( int i = 0 , j = 0 ; i < values . length ; i += 2 , ++ j ) { bounds [ j ] = new MathFunctionRange ( values [ i ] , values [ i + 1 ] ) ; } return bounds ; }
Create a set of bounds that correspond to the specified values .
90
12
6,524
public Interceptor interceptToProgressResponse ( ) { return new Interceptor ( ) { @ Override public Response intercept ( Chain chain ) throws IOException { Response response = chain . proceed ( chain . request ( ) ) ; ResponseBody body = new ForwardResponseBody ( response . body ( ) ) ; return response . newBuilder ( ) . body ( body ) . build ( ) ; } } ; }
intercept the Response body stream progress
82
7
6,525
void setStartPoint ( StandardRoadConnection desiredConnection ) { final StandardRoadConnection oldPoint = getBeginPoint ( StandardRoadConnection . class ) ; if ( oldPoint != null ) { oldPoint . removeConnectedSegment ( this , true ) ; } this . firstConnection = desiredConnection ; if ( desiredConnection != null ) { final Point2d pts = desiredConnection . getPoint ( ) ; if ( pts != null ) { setPointAt ( 0 , pts , true ) ; } desiredConnection . addConnectedSegment ( this , true ) ; } }
Move the start point of a road segment .
118
9
6,526
void setEndPoint ( StandardRoadConnection desiredConnection ) { final StandardRoadConnection oldPoint = getEndPoint ( StandardRoadConnection . class ) ; if ( oldPoint != null ) { oldPoint . removeConnectedSegment ( this , false ) ; } this . lastConnection = desiredConnection ; if ( desiredConnection != null ) { final Point2d pts = desiredConnection . getPoint ( ) ; if ( pts != null ) { setPointAt ( - 1 , pts , true ) ; } desiredConnection . addConnectedSegment ( this , false ) ; } }
Move the end point of a road segment .
119
9
6,527
private static < K , V > ImmutableMap < K , V > filterMapToKeysPreservingOrder ( final ImmutableMap < ? extends K , ? extends V > map , Iterable < ? extends K > keys ) { final ImmutableMap . Builder < K , V > ret = ImmutableMap . builder ( ) ; for ( final K key : keys ) { final V value = map . get ( key ) ; checkArgument ( value != null , "Key " + key + " not in map" ) ; ret . put ( key , value ) ; } return ret . build ( ) ; }
Filters a map down to the specified keys such that the new map has the same iteration order as the specified keys .
128
24
6,528
public static Component getRootJDialog ( Component component ) { while ( null != component . getParent ( ) ) { component = component . getParent ( ) ; if ( component instanceof JDialog ) { break ; } } return component ; }
Gets the root JDialog from the given Component Object .
50
12
6,529
public static Component getRootJFrame ( Component component ) { while ( null != component . getParent ( ) ) { component = component . getParent ( ) ; if ( component instanceof JFrame ) { break ; } } return component ; }
Gets the root JFrame from the given Component Object .
50
12
6,530
public static Component getRootParent ( Component component ) { while ( null != component . getParent ( ) ) { component = component . getParent ( ) ; } return component ; }
Gets the root parent from the given Component Object .
37
11
6,531
public static void setIconImage ( final String resourceName , final Window window ) throws IOException { final InputStream isLogo = ClassExtensions . getResourceAsStream ( resourceName ) ; final BufferedImage biLogo = ImageIO . read ( isLogo ) ; window . setIconImage ( biLogo ) ; }
Sets the icon image from the given resource name and add it to the given window object .
70
19
6,532
@ Override @ Pure public double getDistance ( Point2D < ? , ? > point ) { double dist = super . getDistance ( point ) ; dist -= this . radius ; return dist ; }
Replies the distance between this MapCircle and point .
42
12
6,533
public static Point3dfx convert ( Tuple3D < ? > tuple ) { if ( tuple instanceof Point3dfx ) { return ( Point3dfx ) tuple ; } return new Point3dfx ( tuple . getX ( ) , tuple . getY ( ) , tuple . getZ ( ) ) ; }
Convert the given tuple to a real Point3dfx .
65
12
6,534
@ SuppressWarnings ( { "TypeParameterUnusedInFormals" , "unchecked" } ) private < T > T fetch ( final String id ) { checkNotNull ( id ) ; checkArgument ( ! id . isEmpty ( ) ) ; final T ret = ( T ) idMap . get ( id ) ; if ( ret == null ) { throw new EREException ( String . format ( "Lookup failed for id %s." , id ) ) ; } return ret ; }
no way around unchecked cast for heterogeneous container
107
9
6,535
public void setSpecialChars ( String [ ] [ ] chars ) { assert chars != null : AssertMessages . notNullParameter ( ) ; this . specialChars . clear ( ) ; for ( final String [ ] pair : chars ) { assert pair != null ; assert pair . length == 2 ; assert pair [ 0 ] . length ( ) > 0 ; assert pair [ 1 ] . length ( ) > 0 ; this . specialChars . put ( pair [ 0 ] , pair [ 1 ] ) ; } }
Change the special characters .
109
5
6,536
public void setValidCharRange ( int minValidChar , int maxValidChar ) { if ( minValidChar <= maxValidChar ) { this . minValidChar = minValidChar ; this . maxValidChar = maxValidChar ; } else { this . maxValidChar = minValidChar ; this . minValidChar = maxValidChar ; } }
Change the range of the valid characters that should not be escaped . Any character outside the given range is automatically escaped .
74
23
6,537
@ SuppressWarnings ( "checkstyle:magicnumber" ) public String escape ( CharSequence text ) { final StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < text . length ( ) ; ++ i ) { final char c = text . charAt ( i ) ; final String cs = Character . toString ( c ) ; if ( this . escapeCharacters . contains ( cs ) ) { // Escape protected elements result . append ( this . toEscapeCharacter ) ; result . append ( cs ) ; } else { // Escape special characters final String special = this . specialChars . get ( cs ) ; if ( special != null ) { result . append ( special ) ; } else if ( c < this . minValidChar || c > this . maxValidChar ) { if ( this . maxValidChar > 0 ) { // Escape invalid characters. result . append ( "\\u" ) ; //$NON-NLS-1$ result . append ( formatHex ( c , 4 ) ) ; } } else { result . append ( cs ) ; } } } return result . toString ( ) ; }
Escape the given text .
245
6
6,538
public static void shuffle ( final int [ ] arr , final Random rng ) { // Fisher-Yates shuffle for ( int i = arr . length ; i > 1 ; i -- ) { // swap i-1 and a random spot final int a = i - 1 ; final int b = rng . nextInt ( i ) ; final int tmp = arr [ b ] ; arr [ b ] = arr [ a ] ; arr [ a ] = tmp ; } }
Fisher - Yates suffer a primitive int array
98
9
6,539
protected void setupRoadBorders ( ZoomableGraphicsContext gc , RoadPolyline element ) { final Color color = gc . rgb ( getDrawingColor ( element ) ) ; gc . setStroke ( color ) ; final double width ; if ( element . isWidePolyline ( ) ) { width = 2 + gc . doc2fxSize ( element . getWidth ( ) ) ; } else { width = 3 ; } gc . setLineWidthInPixels ( width ) ; }
Setup for drawing the road borders .
107
7
6,540
protected void setupRoadInterior ( ZoomableGraphicsContext gc , RoadPolyline element ) { final Color color ; if ( isSelected ( element ) ) { color = gc . rgb ( SELECTED_ROAD_COLOR ) ; } else { color = gc . rgb ( ROAD_COLOR ) ; } gc . setStroke ( color ) ; if ( element . isWidePolyline ( ) ) { gc . setLineWidthInMeters ( element . getWidth ( ) ) ; } else { gc . setLineWidthInPixels ( 1 ) ; } }
Setup for drawing the road interior .
126
7
6,541
@ Pure public static String lowerEqualParameter ( int aindex , Object avalue , Object value ) { return msg ( "A11" , aindex , avalue , value ) ; //$NON-NLS-1$ }
Parameter A must be lower than or equal to the given value .
50
13
6,542
@ Pure public static String lowerEqualParameters ( int aindex , Object avalue , int bindex , Object bvalue ) { return msg ( "A3" , aindex , avalue , bindex , bvalue ) ; //$NON-NLS-1$ }
Parameter A must be lower than or equal to Parameter B .
59
13
6,543
@ Pure public static String outsideRangeInclusiveParameter ( int parameterIndex , Object currentValue , Object minValue , Object maxValue ) { return msg ( "A6" , parameterIndex , currentValue , minValue , maxValue ) ; //$NON-NLS-1$ }
Value is outside range .
60
5
6,544
@ Pure @ Inline ( value = "AssertMessages.outsideRangeInclusiveParameter(0, $1, $2, $3)" , imported = { AssertMessages . class } ) public static String outsideRangeInclusiveParameter ( Object currentValue , Object minValue , Object maxValue ) { return outsideRangeInclusiveParameter ( 0 , currentValue , minValue , maxValue ) ; }
First parameter value is outside range .
85
7
6,545
@ Pure @ Inline ( value = "AssertMessages.tooSmallArrayParameter(0, $1, $2)" , imported = { AssertMessages . class } ) public static String tooSmallArrayParameter ( int currentSize , int expectedSize ) { return tooSmallArrayParameter ( 0 , currentSize , expectedSize ) ; }
Size of the first array parameter is too small .
72
10
6,546
@ Pure public static String tooSmallArrayParameter ( int parameterIndex , int currentSize , int expectedSize ) { return msg ( "A5" , parameterIndex , currentSize , expectedSize ) ; //$NON-NLS-1$ }
Size of the array parameter is too small .
52
9
6,547
@ Pure public static ShapeElementType toESRI ( Class < ? extends MapElement > type ) { if ( MapPolyline . class . isAssignableFrom ( type ) ) { return ShapeElementType . POLYLINE ; } if ( MapPolygon . class . isAssignableFrom ( type ) ) { return ShapeElementType . POLYGON ; } if ( MapMultiPoint . class . isAssignableFrom ( type ) ) { return ShapeElementType . MULTIPOINT ; } if ( MapPoint . class . isAssignableFrom ( type ) ) { return ShapeElementType . POINT ; } throw new IllegalArgumentException ( ) ; }
Replies the type of map element which is corresponding to the given GIS class .
144
17
6,548
@ SuppressWarnings ( "unchecked" ) public static < T , V > ImmutableMap < V , Alignment < T , T > > splitAlignmentByKeyFunction ( Alignment < ? extends T , ? extends T > alignment , Function < ? super T , ? extends V > keyFunction ) { // we first determine all keys we could ever encounter to ensure we can construct our map // deterministically // Java will complain about this cast but it is safe because ImmutableSet if covariant in its // type parameter final ImmutableSet < ? extends V > allKeys = FluentIterable . from ( ( ImmutableSet < T > ) alignment . allLeftItems ( ) ) . append ( alignment . allRightItems ( ) ) . transform ( keyFunction ) . toSet ( ) ; final ImmutableMap . Builder < V , MultimapAlignment . Builder < T , T > > keysToAlignmentsB = ImmutableMap . builder ( ) ; for ( final V key : allKeys ) { keysToAlignmentsB . put ( key , MultimapAlignment . < T , T > builder ( ) ) ; } final ImmutableMap < V , MultimapAlignment . Builder < T , T > > keysToAlignments = keysToAlignmentsB . build ( ) ; for ( final T leftItem : alignment . allLeftItems ( ) ) { final V keyVal = keyFunction . apply ( leftItem ) ; final MultimapAlignment . Builder < T , T > alignmentForKey = keysToAlignments . get ( keyVal ) ; alignmentForKey . addLeftItem ( leftItem ) ; for ( T rightItem : alignment . alignedToLeftItem ( leftItem ) ) { if ( keyFunction . apply ( rightItem ) . equals ( keyVal ) ) { alignmentForKey . align ( leftItem , rightItem ) ; } } } for ( final T rightItem : alignment . allRightItems ( ) ) { final V keyVal = keyFunction . apply ( rightItem ) ; final MultimapAlignment . Builder < T , T > alignmentForKey = keysToAlignments . get ( keyVal ) ; alignmentForKey . addRightItem ( rightItem ) ; for ( final T leftItem : alignment . alignedToRightItem ( rightItem ) ) { if ( keyVal . equals ( keyFunction . apply ( leftItem ) ) ) { alignmentForKey . align ( leftItem , rightItem ) ; } } } final ImmutableMap . Builder < V , Alignment < T , T > > ret = ImmutableMap . builder ( ) ; for ( final Map . Entry < V , MultimapAlignment . Builder < T , T > > entry : keysToAlignments . entrySet ( ) ) { ret . put ( entry . getKey ( ) , entry . getValue ( ) . build ( ) ) ; } return ret . build ( ) ; }
Splits an alignment into many alignments based on a function mapping aligned items to some set of keys . Returns a map where the keys are all observed outputs of the key function on items in the alignment and the values are new alignments containing only elements which yield that output when the key function is applied . For example if you had an alignment of EventMentions you could use an event type key function to produce one alignment per event type .
623
89
6,549
protected void fireStateChange ( ) { if ( this . listeners != null ) { final ProgressionEvent event = new ProgressionEvent ( this , isRootModel ( ) ) ; for ( final ProgressionListener listener : this . listeners . getListeners ( ProgressionListener . class ) ) { listener . onProgressionStateChanged ( event ) ; } } }
Notify listeners about state change .
75
7
6,550
protected void fireValueChange ( ) { if ( this . listeners != null ) { final ProgressionEvent event = new ProgressionEvent ( this , isRootModel ( ) ) ; for ( final ProgressionListener listener : this . listeners . getListeners ( ProgressionListener . class ) ) { listener . onProgressionValueChanged ( event ) ; } } }
Notify listeners about value change .
75
7
6,551
void setValue ( SubProgressionModel subTask , double newValue , String comment ) { setProperties ( newValue , this . min , this . max , this . isAdjusting , comment == null ? this . comment : comment , true , true , false , subTask ) ; }
Set the value with a float - point precision . This method is invoked from a subtask .
61
19
6,552
void disconnectSubTask ( SubProgressionModel subTask , double value , boolean overwriteComment ) { if ( this . child == subTask ) { if ( overwriteComment ) { final String cmt = subTask . getComment ( ) ; if ( cmt != null ) { this . comment = cmt ; } } this . child = null ; setProperties ( value , this . min , this . max , this . isAdjusting , this . comment , overwriteComment , true , false , null ) ; } }
Set the parent value and disconnect this subtask from its parent . This method is invoked from a subtask .
108
22
6,553
protected boolean onBusItineraryAdded ( BusItinerary itinerary , int index ) { if ( this . autoUpdate . get ( ) ) { try { addMapLayer ( index , new BusItineraryLayer ( itinerary , isLayerAutoUpdated ( ) ) ) ; return true ; } catch ( Throwable exception ) { // } } return false ; }
Invoked when a bus itinerary was added in the attached line .
77
14
6,554
protected boolean onBusItineraryRemoved ( BusItinerary itinerary , int index ) { if ( this . autoUpdate . get ( ) ) { try { removeMapLayerAt ( index ) ; return true ; } catch ( Throwable exception ) { // } } return false ; }
Invoked when a bus itinerary was removed from the attached line .
60
14
6,555
@ Pure @ SuppressWarnings ( "checkstyle:cyclomaticcomplexity" ) public static Class < ? extends MapElement > fromESRI ( ShapeElementType type ) { switch ( type ) { case MULTIPOINT : case MULTIPOINT_M : case MULTIPOINT_Z : return MapMultiPoint . class ; case POINT : case POINT_M : case POINT_Z : return MapPoint . class ; case POLYGON : case POLYGON_M : case POLYGON_Z : return MapPolygon . class ; case POLYLINE : case POLYLINE_M : case POLYLINE_Z : return MapPolyline . class ; //$CASES-OMITTED$ default : } throw new IllegalArgumentException ( ) ; }
Replies the type of map element which is corresponding to the given ESRI type .
175
17
6,556
@ Pure public Class < ? extends MapElement > getMapElementType ( ) { if ( this . elementType != null ) { return this . elementType ; } try { return fromESRI ( getShapeElementType ( ) ) ; } catch ( IllegalArgumentException exception ) { // } return null ; }
Replies the type of map element replied by this reader .
65
12
6,557
protected static UUID extractUUID ( AttributeProvider provider ) { AttributeValue value ; value = provider . getAttribute ( UUID_ATTR ) ; if ( value != null ) { try { return value . getUUID ( ) ; } catch ( InvalidAttributeTypeException e ) { // } catch ( AttributeNotInitializedException e ) { // } } value = provider . getAttribute ( ID_ATTR ) ; if ( value != null ) { try { return value . getUUID ( ) ; } catch ( InvalidAttributeTypeException e ) { // } catch ( AttributeNotInitializedException e ) { // } } return null ; }
Extract the UUID from the attributes .
136
9
6,558
protected void onShowPopup ( final MouseEvent e ) { if ( e . isPopupTrigger ( ) ) { System . out . println ( e . getSource ( ) ) ; popupMenu . show ( e . getComponent ( ) , e . getX ( ) , e . getY ( ) ) ; } }
Callback method that is called on show popup .
68
9
6,559
private final Command takeExecutingCommand ( ) { try { return this . commandAlreadySent . take ( ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; } return null ; }
get current command from queue
48
5
6,560
public static void load ( URL filename ) throws IOException { // Silently ignore loading query if ( disable ) { return ; } if ( URISchemeType . FILE . isURL ( filename ) ) { try { load ( new File ( filename . toURI ( ) ) ) ; } catch ( URISyntaxException e ) { throw new FileNotFoundException ( filename . toExternalForm ( ) ) ; } } else { // Create a tmp file to receive the library code. final String libName = System . mapLibraryName ( "javaDynLib" ) ; //$NON-NLS-1$ String suffix = ".dll" ; //$NON-NLS-1$ String prefix = "javaDynLib" ; //$NON-NLS-1$ final int pos = libName . lastIndexOf ( ' ' ) ; if ( pos >= 0 ) { suffix = libName . substring ( pos ) ; prefix = libName . substring ( 0 , pos ) ; } final File file = File . createTempFile ( prefix , suffix ) ; // Copy the library code into the local file try ( FileOutputStream outs = new FileOutputStream ( file ) ) { try ( InputStream ins = filename . openStream ( ) ) { final byte [ ] buffer = new byte [ BUFFER_SIZE ] ; int lu ; while ( ( lu = ins . read ( buffer ) ) > 0 ) { outs . write ( buffer , 0 , lu ) ; } } } // Load the library from the local file load ( file ) ; // Delete local file file . deleteOnExit ( ) ; } }
Loads a code file with the specified filename from the local file system as a dynamic library . The filename argument must be a complete path name .
346
29
6,561
private E readPoint ( int elementIndex , ShapeElementType type ) throws IOException { final boolean hasZ = type . hasZ ( ) ; final boolean hasM = type . hasM ( ) ; // Read coordinates final double x = fromESRI_x ( readLEDouble ( ) ) ; final double y = fromESRI_y ( readLEDouble ( ) ) ; double z = 0 ; double measure = Double . NaN ; if ( hasZ ) { z = fromESRI_z ( readLEDouble ( ) ) ; } if ( hasM ) { measure = fromESRI_m ( readLEDouble ( ) ) ; } // Create the point if ( ! Double . isNaN ( x ) && ! Double . isNaN ( y ) ) { return createPoint ( createAttributeCollection ( elementIndex ) , elementIndex , new ESRIPoint ( x , y , z , measure ) ) ; } return null ; }
Read a point .
199
4
6,562
@ SuppressWarnings ( { "checkstyle:cyclomaticcomplexity" , "checkstyle:npathcomplexity" } ) private E readPolyElement ( int elementIndex , ShapeElementType type ) throws IOException { final boolean hasZ = type . hasZ ( ) ; final boolean hasM = type . hasM ( ) ; // Ignore the bounds stored inside the file skipBytes ( 8 * 4 ) ; // Count of parts final int numParts ; if ( type == ShapeElementType . MULTIPOINT || type == ShapeElementType . MULTIPOINT_Z || type == ShapeElementType . MULTIPOINT_M ) { numParts = 0 ; } else { numParts = readLEInt ( ) ; } // Count of points final int numPoints = readLEInt ( ) ; // Read the parts' indexes final int [ ] parts = new int [ numParts ] ; for ( int idxParts = 0 ; idxParts < numParts ; ++ idxParts ) { parts [ idxParts ] = readLEInt ( ) ; } // Read the points final ESRIPoint [ ] points = new ESRIPoint [ numPoints ] ; for ( int idxPoints = 0 ; idxPoints < numPoints ; ++ idxPoints ) { // Read coordinates final double x = fromESRI_x ( readLEDouble ( ) ) ; final double y = fromESRI_y ( readLEDouble ( ) ) ; // Create point if ( ! Double . isNaN ( x ) && ! Double . isNaN ( y ) ) { points [ idxPoints ] = new ESRIPoint ( x , y ) ; } else { throw new ShapeFileException ( "invalid (x,y) coordinates" ) ; //$NON-NLS-1$ } } // for i= 0 to numPoints if ( hasZ ) { // Zmin and Zmax: 2*Double - ignored skipBytes ( 2 * 8 ) ; // Z array: numpoints*Double double z ; for ( int i = 0 ; i < numPoints ; ++ i ) { z = fromESRI_z ( readLEDouble ( ) ) ; if ( ! Double . isNaN ( z ) ) { points [ i ] . setZ ( z ) ; } } } if ( hasM ) { // Mmin and Mmax: 2*Double - ignored skipBytes ( 2 * 8 ) ; // M array: numpoints*Double double measure ; for ( int i = 0 ; i < numPoints ; ++ i ) { measure = fromESRI_m ( readLEDouble ( ) ) ; if ( ! Double . isNaN ( measure ) ) { points [ i ] . setM ( measure ) ; } } } // Create the instance of the element E newElement = null ; switch ( type ) { case POLYGON_Z : case POLYGON_M : case POLYGON : newElement = createPolygon ( createAttributeCollection ( elementIndex ) , elementIndex , parts , points , hasZ ) ; break ; case POLYLINE_Z : case POLYLINE_M : case POLYLINE : newElement = createPolyline ( createAttributeCollection ( elementIndex ) , elementIndex , parts , points , hasZ ) ; break ; case MULTIPOINT : case MULTIPOINT_M : case MULTIPOINT_Z : newElement = createMultiPoint ( createAttributeCollection ( elementIndex ) , elementIndex , points , hasZ ) ; break ; //$CASES-OMITTED$ default : } return newElement ; }
Read a polyelement .
773
5
6,563
private E readMultiPatch ( int elementIndex , ShapeElementType type ) throws IOException { // Ignore the bounds stored inside the file skipBytes ( 8 * 4 ) ; // Read the part count final int partCount = readLEInt ( ) ; // Read the point count final int pointCount = readLEInt ( ) ; // Read the parts' indexes final int [ ] parts = new int [ partCount ] ; for ( int idxParts = 0 ; idxParts < partCount ; ++ idxParts ) { parts [ idxParts ] = readLEInt ( ) ; } // Read the parts' types final ShapeMultiPatchType [ ] partTypes = new ShapeMultiPatchType [ partCount ] ; for ( int idxParts = 0 ; idxParts < partCount ; ++ idxParts ) { partTypes [ idxParts ] = ShapeMultiPatchType . fromESRIInteger ( readLEInt ( ) ) ; } // Read the points final ESRIPoint [ ] points = new ESRIPoint [ pointCount ] ; for ( int idxPoints = 0 ; idxPoints < pointCount ; ++ idxPoints ) { // Read coordinates final double x = fromESRI_x ( readLEDouble ( ) ) ; final double y = fromESRI_y ( readLEDouble ( ) ) ; // Create point if ( ! Double . isNaN ( x ) && ! Double . isNaN ( y ) ) { points [ idxPoints ] = new ESRIPoint ( x , y ) ; } else { throw new InvalidNumericValueException ( Double . isNaN ( x ) ? x : y ) ; } } // for i= 0 to numPoints // Zmin and Zmax: 2*Double - ignored skipBytes ( 2 * 8 ) ; // Z array: numpoints*Double double z ; for ( int i = 0 ; i < pointCount ; ++ i ) { z = fromESRI_z ( readLEDouble ( ) ) ; if ( ! Double . isNaN ( z ) ) { points [ i ] . setZ ( z ) ; } } // Mmin and Mmax: 2*Double - ignored skipBytes ( 2 * 8 ) ; // M array: numpoints*Double double measure ; for ( int i = 0 ; i < pointCount ; ++ i ) { measure = fromESRI_m ( readLEDouble ( ) ) ; if ( ! Double . isNaN ( measure ) ) { points [ i ] . setM ( measure ) ; } } // Create the instance of the element return createMultiPatch ( createAttributeCollection ( elementIndex ) , elementIndex , parts , partTypes , points ) ; }
Read a multipatch .
571
5
6,564
private void readAttributesFromDBaseFile ( E created_element ) throws IOException { // Read the DBF entry if ( this . dbfReader != null ) { final List < DBaseFileField > dbfColumns = this . dbfReader . getDBFFields ( ) ; // Read the record even if the shape element was not inserted into // the database. It is necessary to not have inconsistancy between // the shape entries and the dbase entries. final DBaseFileRecord record = this . dbfReader . readNextDBFRecord ( ) ; if ( record != null ) { // Add the dBase values for ( final DBaseFileField dbfColumn : dbfColumns ) { // Test if the column was marked as selected. // A column was selected if the user want to import the column // values into the database. if ( this . dbfReader . isColumnSelectable ( dbfColumn ) ) { final Object fieldValue = record . getFieldValue ( dbfColumn . getColumnIndex ( ) ) ; final AttributeValueImpl attr = new AttributeValueImpl ( ) ; attr . castAndSet ( dbfColumn . getAttributeType ( ) , fieldValue ) ; putAttributeIn ( created_element , dbfColumn . getName ( ) , attr ) ; } } } } }
Create the attribute values that correspond to the dBase content .
282
12
6,565
@ Pure public static double noiseValue ( double value , MathFunction noiseLaw ) throws MathException { try { double noise = Math . abs ( noiseLaw . f ( value ) ) ; initRandomNumberList ( ) ; noise *= uniformRandomVariableList . nextFloat ( ) ; if ( uniformRandomVariableList . nextBoolean ( ) ) { noise = - noise ; } return value + noise ; } catch ( MathException e ) { return value ; } }
Add a noise to the specified value .
96
8
6,566
public void setRotation ( Quaternion rotation ) { this . m00 = 1.0f - 2.0f * rotation . getY ( ) * rotation . getY ( ) - 2.0f * rotation . getZ ( ) * rotation . getZ ( ) ; this . m10 = 2.0f * ( rotation . getX ( ) * rotation . getY ( ) + rotation . getW ( ) * rotation . getZ ( ) ) ; this . m20 = 2.0f * ( rotation . getX ( ) * rotation . getZ ( ) - rotation . getW ( ) * rotation . getY ( ) ) ; this . m01 = 2.0f * ( rotation . getX ( ) * rotation . getY ( ) - rotation . getW ( ) * rotation . getZ ( ) ) ; this . m11 = 1.0f - 2.0f * rotation . getX ( ) * rotation . getX ( ) - 2.0f * rotation . getZ ( ) * rotation . getZ ( ) ; this . m21 = 2.0f * ( rotation . getY ( ) * rotation . getZ ( ) + rotation . getW ( ) * rotation . getX ( ) ) ; this . m02 = 2.0f * ( rotation . getX ( ) * rotation . getZ ( ) + rotation . getW ( ) * rotation . getY ( ) ) ; this . m12 = 2.0f * ( rotation . getY ( ) * rotation . getZ ( ) - rotation . getW ( ) * rotation . getX ( ) ) ; this . m22 = 1.0f - 2.0f * rotation . getX ( ) * rotation . getX ( ) - 2.0f * rotation . getY ( ) * rotation . getY ( ) ; }
Set the rotation for the object but do not change the translation .
397
13
6,567
public final void makeRotationMatrix ( Quaternion rotation ) { this . m00 = 1.0f - 2.0f * rotation . getY ( ) * rotation . getY ( ) - 2.0f * rotation . getZ ( ) * rotation . getZ ( ) ; this . m10 = 2.0f * ( rotation . getX ( ) * rotation . getY ( ) + rotation . getW ( ) * rotation . getZ ( ) ) ; this . m20 = 2.0f * ( rotation . getX ( ) * rotation . getZ ( ) - rotation . getW ( ) * rotation . getY ( ) ) ; this . m01 = 2.0f * ( rotation . getX ( ) * rotation . getY ( ) - rotation . getW ( ) * rotation . getZ ( ) ) ; this . m11 = 1.0f - 2.0f * rotation . getX ( ) * rotation . getX ( ) - 2.0f * rotation . getZ ( ) * rotation . getZ ( ) ; this . m21 = 2.0f * ( rotation . getY ( ) * rotation . getZ ( ) + rotation . getW ( ) * rotation . getX ( ) ) ; this . m02 = 2.0f * ( rotation . getX ( ) * rotation . getZ ( ) + rotation . getW ( ) * rotation . getY ( ) ) ; this . m12 = 2.0f * ( rotation . getY ( ) * rotation . getZ ( ) - rotation . getW ( ) * rotation . getX ( ) ) ; this . m22 = 1.0f - 2.0f * rotation . getX ( ) * rotation . getX ( ) - 2.0f * rotation . getY ( ) * rotation . getY ( ) ; this . m03 = 0.0 ; this . m13 = 0.0 ; this . m23 = 0.0 ; this . m30 = 0.0 ; this . m31 = 0.0 ; this . m32 = 0.0 ; this . m33 = 1.0 ; }
Sets the value of this matrix to a rotation matrix and no translation .
462
15
6,568
void setPosition ( Point2D < ? , ? > position ) { this . location = position == null ? null : new SoftReference <> ( Point2d . convert ( position ) ) ; }
Set the temporary buffer of the position of the road connection .
42
12
6,569
void addConnectedSegment ( RoadPolyline segment , boolean attachToStartPoint ) { if ( segment == null ) { return ; } if ( this . connectedSegments . isEmpty ( ) ) { this . connectedSegments . add ( new Connection ( segment , attachToStartPoint ) ) ; } else { // Compute the angle to the unit vector for the new segment final double newSegmentAngle = computeAngle ( segment , attachToStartPoint ) ; // Search for the insertion index final int insertionIndex = searchInsertionIndex ( newSegmentAngle , 0 , this . connectedSegments . size ( ) - 1 ) ; // Insert this . connectedSegments . add ( insertionIndex , new Connection ( segment , attachToStartPoint ) ) ; } fireIteratorUpdate ( ) ; }
Add a segment to this connection point .
169
8
6,570
int removeConnectedSegment ( RoadSegment segment , boolean attachToStartPoint ) { if ( segment == null ) { return - 1 ; } final int idx = indexOf ( segment , attachToStartPoint ) ; if ( idx != - 1 ) { this . connectedSegments . remove ( idx ) ; fireIteratorUpdate ( ) ; } return idx ; }
Remove a connection with a segment .
80
7
6,571
protected void addListeningIterator ( IClockwiseIterator iterator ) { if ( this . listeningIterators == null ) { this . listeningIterators = new WeakArrayList <> ( ) ; } this . listeningIterators . add ( iterator ) ; }
Add a listening iterator .
53
5
6,572
protected void removeListeningIterator ( IClockwiseIterator iterator ) { if ( this . listeningIterators != null ) { this . listeningIterators . remove ( iterator ) ; if ( this . listeningIterators . isEmpty ( ) ) { this . listeningIterators = null ; } } }
Remove a listening iterator .
61
5
6,573
protected void fireIteratorUpdate ( ) { if ( this . listeningIterators != null ) { for ( final IClockwiseIterator iterator : this . listeningIterators ) { if ( iterator != null ) { iterator . dataStructureUpdated ( ) ; } } } }
Notify the iterators about changes .
55
8
6,574
@ Pure public static int getPreferredRoadColor ( RoadType roadType , boolean useSystemValue ) { final RoadType rt = roadType == null ? RoadType . OTHER : roadType ; final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkLayerConstants . class ) ; if ( prefs != null ) { final String str = prefs . get ( "ROAD_COLOR_" + rt . name ( ) . toUpperCase ( ) , null ) ; //$NON-NLS-1$ if ( str != null ) { try { return Integer . valueOf ( str ) ; } catch ( Throwable exception ) { // } } } if ( useSystemValue ) { return DEFAULT_ROAD_COLORS [ rt . ordinal ( ) * 2 ] ; } return 0 ; }
Replies the preferred color to draw the content of the roads of the given type .
177
17
6,575
public static void setPreferredRoadColor ( RoadType roadType , Integer color ) { final RoadType rt = roadType == null ? RoadType . OTHER : roadType ; final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkLayerConstants . class ) ; if ( prefs != null ) { if ( color == null || color . intValue ( ) == DEFAULT_ROAD_COLORS [ rt . ordinal ( ) * 2 ] ) { prefs . remove ( "ROAD_COLOR_" + rt . name ( ) . toUpperCase ( ) ) ; //$NON-NLS-1$ } else { prefs . put ( "ROAD_COLOR_" + rt . name ( ) . toUpperCase ( ) , Integer . toString ( color . intValue ( ) ) ) ; //$NON-NLS-1$ } try { prefs . flush ( ) ; } catch ( BackingStoreException exception ) { // } } }
Set the preferred color to draw the content of the roads of the given type .
216
16
6,576
@ Pure public static boolean getPreferredRoadInternDrawing ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkLayerConstants . class ) ; if ( prefs != null ) { return prefs . getBoolean ( "ROAD_INTERN_DRAWING" , DEFAULT_ROAD_INTERN_DRAWING ) ; //$NON-NLS-1$ } return DEFAULT_ROAD_INTERN_DRAWING ; }
Replies if the internal data structure used to store the road network may be drawn on the displayers .
104
21
6,577
public static void setPreferredRoadInternDrawing ( Boolean draw ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkLayerConstants . class ) ; if ( prefs != null ) { if ( draw == null ) { prefs . remove ( "ROAD_INTERN_DRAWING" ) ; //$NON-NLS-1$ } else { prefs . putBoolean ( "ROAD_INTERN_DRAWING" , draw ) ; //$NON-NLS-1$ } try { prefs . flush ( ) ; } catch ( BackingStoreException exception ) { // } } }
Set if the internal data structure used to store the road network may be drawn on the displayers .
138
20
6,578
@ Pure public static int getPreferredRoadInternColor ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkLayerConstants . class ) ; if ( prefs != null ) { final String color = prefs . get ( "ROAD_INTERN_COLOR" , null ) ; //$NON-NLS-1$ if ( color != null ) { try { return Integer . valueOf ( color ) ; } catch ( Throwable exception ) { // } } } return DEFAULT_ROAD_INTERN_COLOR ; }
Replies the color of the internal data structures used when they are drawn on the displayers .
118
19
6,579
public static void setPreferredRoadInternColor ( Integer color ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkLayerConstants . class ) ; if ( prefs != null ) { if ( color == null ) { prefs . remove ( "ROAD_INTERN_COLOR" ) ; //$NON-NLS-1$ } else { prefs . put ( "ROAD_INTERN_COLOR" , Integer . toString ( color . intValue ( ) ) ) ; //$NON-NLS-1$ } try { prefs . flush ( ) ; } catch ( BackingStoreException exception ) { // } } }
Set the color of the internal data structures used when they are drawn on the displayers .
142
18
6,580
@ Pure public static double clamp ( double v , double min , double max ) { assert min <= max : AssertMessages . lowerEqualParameters ( 1 , min , 2 , max ) ; if ( v < min ) { return min ; } if ( v > max ) { return max ; } return v ; }
Clamp the given value to the given range .
67
10
6,581
@ Pure public static double clampCyclic ( double value , double min , double max ) { assert min <= max : AssertMessages . lowerEqualParameters ( 1 , min , 2 , max ) ; if ( Double . isNaN ( max ) || Double . isNaN ( min ) || Double . isNaN ( max ) ) { return Double . NaN ; } if ( value < min ) { final double perimeter = max - min ; final double nvalue = min - value ; double rest = perimeter - ( nvalue % perimeter ) ; if ( rest >= perimeter ) { rest -= perimeter ; } return min + rest ; } else if ( value >= max ) { final double perimeter = max - min ; final double nvalue = value - max ; final double rest = nvalue % perimeter ; return min + rest ; } return value ; }
Clamp the given value to fit between the min and max values according to a cyclic heuristic . If the given value is not between the minimum and maximum values the replied value is modulo the min - max range .
179
45
6,582
public static DoubleRange getMinMax ( double value1 , double value2 , double value3 ) { // Efficient implementation of the min/max determination final double min ; final double max ; // --------------------------------- // Table of cases // --------------------------------- // a-b a-c b-c sequence min max case // < < < a b c a c 1 // < < > a c b a b 2 // < > < - - // < > > c a b c b 3 // > < < b a c b c 4 // > < > - - // > > < b c a b a 5 // > > > c b a c a 6 // --------------------------------- if ( value1 <= value2 ) { // A and B are not NaN // case candidates: 123 if ( value1 <= value3 ) { // case candidates: 12 min = value1 ; if ( value2 <= value3 ) { // case: 1 max = value3 ; } else { // case: 2 max = value2 ; } } else { // 3 max = value2 ; if ( Double . isNaN ( value3 ) ) { min = value1 ; } else { min = value3 ; } } } else { // case candidates: 456 if ( value1 <= value3 ) { max = value3 ; if ( Double . isNaN ( value2 ) ) { min = value1 ; } else { // case: 4 min = value2 ; } } else if ( Double . isNaN ( value1 ) ) { if ( value2 <= value3 ) { min = value2 ; max = value3 ; } else if ( Double . isNaN ( value2 ) ) { if ( Double . isNaN ( value3 ) ) { return null ; } min = value3 ; max = min ; } else if ( Double . isNaN ( value3 ) ) { min = value2 ; max = min ; } else { min = value3 ; max = value2 ; } } else if ( Double . isNaN ( value3 ) ) { if ( Double . isNaN ( value2 ) ) { min = value1 ; max = min ; } else { min = value2 ; max = value1 ; } } else { // B may NaN // case candidates: 56 max = value1 ; if ( value2 <= value3 ) { // case: 5 min = value2 ; } else { // case: 6 min = value3 ; } } } return new DoubleRange ( min , max ) ; }
Determine the min and max values from a set of three values .
528
15
6,583
@ Pure @ Inline ( value = "1./Math.sin($1)" , imported = { Math . class } ) public static double csc ( double angle ) { return 1. / Math . sin ( angle ) ; }
Replies the cosecant of the specified angle .
48
12
6,584
@ Pure @ Inline ( value = "1./Math.cos($1)" , imported = { Math . class } ) public static double sec ( double angle ) { return 1. / Math . cos ( angle ) ; }
Replies the secant of the specified angle .
47
10
6,585
@ Pure @ Inline ( value = "1./Math.tan($1)" , imported = { Math . class } ) public static double cot ( double angle ) { return 1. / Math . tan ( angle ) ; }
Replies the cotangent of the specified angle .
48
12
6,586
@ Pure @ Inline ( value = "1.-Math.cos($1)" , imported = { Math . class } ) public static double versin ( double angle ) { return 1. - Math . cos ( angle ) ; }
Replies the versine of the specified angle .
48
10
6,587
@ Pure @ Inline ( value = "2.*Math.sin(($1)/2.)" , imported = { Math . class } ) public static double crd ( double angle ) { return 2. * Math . sin ( angle / 2. ) ; }
Replies the chord of the specified angle .
55
9
6,588
public static Point2dfx convert ( Tuple2D < ? > tuple ) { if ( tuple instanceof Point2dfx ) { return ( Point2dfx ) tuple ; } return new Point2dfx ( tuple . getX ( ) , tuple . getY ( ) ) ; }
Convert the given tuple to a real Point2dfx .
58
12
6,589
@ Pure @ SuppressWarnings ( "checkstyle:cyclomaticcomplexity" ) public static AttributeValueImpl parse ( String text ) { final AttributeValueImpl value = new AttributeValueImpl ( text ) ; if ( text != null && ! text . isEmpty ( ) ) { Object binValue ; for ( final AttributeType type : AttributeType . values ( ) ) { try { binValue = null ; switch ( type ) { case BOOLEAN : binValue = value . getBoolean ( ) ; break ; case DATE : binValue = value . getDate ( ) ; break ; case ENUMERATION : binValue = value . getEnumeration ( ) ; break ; case INET_ADDRESS : binValue = value . getInetAddress ( ) ; break ; case INTEGER : binValue = value . getInteger ( ) ; break ; case OBJECT : binValue = value . getJavaObject ( ) ; break ; case POINT : binValue = parsePoint ( ( String ) value . value , true ) ; break ; case POINT3D : binValue = parsePoint3D ( ( String ) value . value , true ) ; break ; case POLYLINE : binValue = parsePolyline ( ( String ) value . value , true ) ; break ; case POLYLINE3D : binValue = parsePolyline3D ( ( String ) value . value , true ) ; break ; case REAL : binValue = value . getReal ( ) ; break ; case STRING : binValue = value . getString ( ) ; break ; case TIMESTAMP : binValue = value . getTimestamp ( ) ; break ; case TYPE : binValue = value . getJavaClass ( ) ; break ; case URI : binValue = parseURI ( ( String ) value . value ) ; break ; case URL : binValue = value . getURL ( ) ; break ; case UUID : binValue = parseUUID ( ( String ) value . value ) ; break ; default : // } if ( binValue != null ) { return new AttributeValueImpl ( type , binValue ) ; } } catch ( Throwable exception ) { // } } } return value ; }
Replies the best attribute value that is representing the given text .
468
13
6,590
@ Pure public static int compareValues ( AttributeValue arg0 , AttributeValue arg1 ) { if ( arg0 == arg1 ) { return 0 ; } if ( arg0 == null ) { return Integer . MAX_VALUE ; } if ( arg1 == null ) { return Integer . MIN_VALUE ; } Object v0 ; Object v1 ; try { v0 = arg0 . getValue ( ) ; } catch ( Exception exception ) { v0 = null ; } try { v1 = arg1 . getValue ( ) ; } catch ( Exception exception ) { v1 = null ; } return compareRawValues ( v0 , v1 ) ; }
Compare the two specified values .
139
6
6,591
@ Pure @ SuppressWarnings ( { "unchecked" , "rawtypes" , "checkstyle:returncount" , "checkstyle:npathcomplexity" } ) private static int compareRawValues ( Object arg0 , Object arg1 ) { if ( arg0 == arg1 ) { return 0 ; } if ( arg0 == null ) { return Integer . MAX_VALUE ; } if ( arg1 == null ) { return Integer . MIN_VALUE ; } if ( ( arg0 instanceof Number ) && ( arg1 instanceof Number ) ) { return Double . compare ( ( ( Number ) arg0 ) . doubleValue ( ) , ( ( Number ) arg1 ) . doubleValue ( ) ) ; } try { if ( arg0 instanceof Comparable < ? > ) { return ( ( Comparable ) arg0 ) . compareTo ( arg1 ) ; } } catch ( RuntimeException exception ) { // } try { if ( arg1 instanceof Comparable < ? > ) { return - ( ( Comparable ) arg1 ) . compareTo ( arg0 ) ; } } catch ( RuntimeException exception ) { // } if ( arg0 . equals ( arg1 ) ) { return 0 ; } final String sv0 = arg0 . toString ( ) ; final String sv1 = arg1 . toString ( ) ; if ( sv0 == sv1 ) { return 0 ; } if ( sv0 == null ) { return Integer . MAX_VALUE ; } if ( sv1 == null ) { return Integer . MIN_VALUE ; } return sv0 . compareTo ( sv1 ) ; }
Compare the internal objects of two specified values .
338
9
6,592
protected void setInternalValue ( Object value , AttributeType type ) { this . value = value ; this . assigned = this . value != null ; this . type = type ; }
Set this value with the content of the specified one .
38
11
6,593
private static Date extractDate ( String text , Locale locale ) { DateFormat fmt ; for ( int style = 0 ; style <= 3 ; ++ style ) { // Date and time parsing for ( int style2 = 0 ; style2 <= 3 ; ++ style2 ) { fmt = DateFormat . getDateTimeInstance ( style , style2 , locale ) ; try { return fmt . parse ( text ) ; } catch ( ParseException exception ) { // } } // Date only parsing fmt = DateFormat . getDateInstance ( style , locale ) ; try { return fmt . parse ( text ) ; } catch ( ParseException exception ) { // } // Time only parsing fmt = DateFormat . getTimeInstance ( style , locale ) ; try { return fmt . parse ( text ) ; } catch ( ParseException exception ) { // } } return null ; }
Parse a date according to the specified locale .
179
10
6,594
@ Pure public static boolean isDbaseFile ( File file ) { return FileType . isContentType ( file , MimeName . MIME_DBASE_FILE . getMimeConstant ( ) ) ; }
Replies if the specified file content is a dBase file .
46
13
6,595
protected void stroke ( ZoomableGraphicsContext gc , T element ) { final double radius = element . getRadius ( ) ; final double diameter = radius * radius ; final double minx = element . getX ( ) - radius ; final double miny = element . getY ( ) - radius ; gc . strokeOval ( minx , miny , diameter , diameter ) ; }
Stroke the circle .
82
6
6,596
protected void fill ( ZoomableGraphicsContext gc , T element ) { final double radius = element . getRadius ( ) ; final double diameter = radius * radius ; final double minx = element . getX ( ) - radius ; final double miny = element . getY ( ) - radius ; gc . fillOval ( minx , miny , diameter , diameter ) ; }
Fill the circle .
82
4
6,597
@ Pure public static String getFirstFreeBushaltName ( BusItinerary busItinerary ) { if ( busItinerary == null ) { return null ; } int nb = busItinerary . size ( ) ; String name ; do { ++ nb ; name = Locale . getString ( "NAME_TEMPLATE" , Integer . toString ( nb ) ) ; //$NON-NLS-1$ } while ( busItinerary . getBusHalt ( name ) != null ) ; return name ; }
Replies a bus halt name that was not exist in the specified bus itinerary .
118
17
6,598
public boolean setBusStop ( BusStop busStop ) { final BusStop old = getBusStop ( ) ; if ( ( busStop == null && old != null ) || ( busStop != null && ! busStop . equals ( old ) ) ) { if ( old != null ) { old . removeBusHalt ( this ) ; } this . busStop = busStop == null ? null : new WeakReference <> ( busStop ) ; if ( busStop != null ) { busStop . addBusHalt ( this ) ; } clearPositionBuffers ( ) ; fireShapeChanged ( ) ; checkPrimitiveValidity ( ) ; return true ; } return false ; }
Set the bus stop associated to this halt .
142
9
6,599
@ Pure public RoadSegment getRoadSegment ( ) { final BusItinerary itinerary = getContainer ( ) ; if ( itinerary != null && this . roadSegmentIndex >= 0 && this . roadSegmentIndex < itinerary . getRoadSegmentCount ( ) ) { return itinerary . getRoadSegmentAt ( this . roadSegmentIndex ) ; } return null ; }
Replies the road segment on which this bus halt was .
84
12