_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15000 | MapCircle.getDistance | train | @Override
@Pure
public double getDistance(Point2D<?, ?> point) {
double dist = super.getDistance(point);
dist -= this.radius;
return dist;
} | java | {
"resource": ""
} |
q15001 | Point3dfx.convert | train | public static Point3dfx convert(Tuple3D<?> tuple) {
if (tuple instanceof Point3dfx) {
return (Point3dfx) tuple;
}
return new Point3dfx(tuple.getX(), tuple.getY(), tuple.getZ());
} | java | {
"resource": ""
} |
q15002 | ERELoading.fetch | train | @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;
} | java | {
"resource": ""
} |
q15003 | StringEscaper.setSpecialChars | train | 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]);
}
} | java | {
"resource": ""
} |
q15004 | StringEscaper.setValidCharRange | train | public void setValidCharRange(int minValidChar, int maxValidChar) {
if (minValidChar <= maxValidChar) {
this.minValidChar = minValidChar;
this.maxValidChar = maxValidChar;
} else {
this.maxValidChar = minValidChar;
this.minValidChar = maxValidChar;
}
} | java | {
"resource": ""
} |
q15005 | StringEscaper.escape | train | @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();
} | java | {
"resource": ""
} |
q15006 | IntUtils.shuffle | train | 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;
}
} | java | {
"resource": ""
} |
q15007 | RoadPolylineDrawer.setupRoadBorders | train | 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);
} | java | {
"resource": ""
} |
q15008 | RoadPolylineDrawer.setupRoadInterior | train | 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);
}
} | java | {
"resource": ""
} |
q15009 | AssertMessages.lowerEqualParameter | train | @Pure
public static String lowerEqualParameter(int aindex, Object avalue, Object value) {
return msg("A11", aindex, avalue, value); //$NON-NLS-1$
} | java | {
"resource": ""
} |
q15010 | AssertMessages.lowerEqualParameters | train | @Pure
public static String lowerEqualParameters(int aindex, Object avalue, int bindex, Object bvalue) {
return msg("A3", aindex, avalue, bindex, bvalue); //$NON-NLS-1$
} | java | {
"resource": ""
} |
q15011 | AssertMessages.outsideRangeInclusiveParameter | train | @Pure
public static String outsideRangeInclusiveParameter(int parameterIndex, Object currentValue,
Object minValue, Object maxValue) {
return msg("A6", parameterIndex, currentValue, minValue, maxValue); //$NON-NLS-1$
} | java | {
"resource": ""
} |
q15012 | AssertMessages.outsideRangeInclusiveParameter | train | @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);
} | java | {
"resource": ""
} |
q15013 | AssertMessages.tooSmallArrayParameter | train | @Pure
@Inline(value = "AssertMessages.tooSmallArrayParameter(0, $1, $2)", imported = {AssertMessages.class})
public static String tooSmallArrayParameter(int currentSize, int expectedSize) {
return tooSmallArrayParameter(0, currentSize, expectedSize);
} | java | {
"resource": ""
} |
q15014 | AssertMessages.tooSmallArrayParameter | train | @Pure
public static String tooSmallArrayParameter(int parameterIndex, int currentSize, int expectedSize) {
return msg("A5", parameterIndex, currentSize, expectedSize); //$NON-NLS-1$
} | java | {
"resource": ""
} |
q15015 | GISShapeFileWriter.toESRI | train | @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();
} | java | {
"resource": ""
} |
q15016 | Alignments.splitAlignmentByKeyFunction | train | @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();
} | java | {
"resource": ""
} |
q15017 | DefaultProgression.fireStateChange | train | 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);
}
}
} | java | {
"resource": ""
} |
q15018 | DefaultProgression.fireValueChange | train | 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);
}
}
} | java | {
"resource": ""
} |
q15019 | DefaultProgression.setValue | train | 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);
} | java | {
"resource": ""
} |
q15020 | DefaultProgression.disconnectSubTask | train | 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);
}
} | java | {
"resource": ""
} |
q15021 | BusLineLayer.onBusItineraryAdded | train | 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;
} | java | {
"resource": ""
} |
q15022 | BusLineLayer.onBusItineraryRemoved | train | protected boolean onBusItineraryRemoved(BusItinerary itinerary, int index) {
if (this.autoUpdate.get()) {
try {
removeMapLayerAt(index);
return true;
} catch (Throwable exception) {
//
}
}
return false;
} | java | {
"resource": ""
} |
q15023 | GISShapeFileReader.fromESRI | train | @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();
} | java | {
"resource": ""
} |
q15024 | GISShapeFileReader.getMapElementType | train | @Pure
public Class<? extends MapElement> getMapElementType() {
if (this.elementType != null) {
return this.elementType;
}
try {
return fromESRI(getShapeElementType());
} catch (IllegalArgumentException exception) {
//
}
return null;
} | java | {
"resource": ""
} |
q15025 | GISShapeFileReader.extractUUID | train | 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;
} | java | {
"resource": ""
} |
q15026 | PopupListener.onShowPopup | train | protected void onShowPopup(final MouseEvent e)
{
if (e.isPopupTrigger())
{
System.out.println(e.getSource());
popupMenu.show(e.getComponent(), e.getX(), e.getY());
}
} | java | {
"resource": ""
} |
q15027 | HandlerSocketSessionImpl.takeExecutingCommand | train | private final Command takeExecutingCommand() {
try {
return this.commandAlreadySent.take();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return null;
} | java | {
"resource": ""
} |
q15028 | LibraryLoader.load | train | 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();
}
} | java | {
"resource": ""
} |
q15029 | AbstractShapeFileReader.readPoint | train | 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;
} | java | {
"resource": ""
} |
q15030 | AbstractShapeFileReader.readPolyElement | train | @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;
} | java | {
"resource": ""
} |
q15031 | AbstractShapeFileReader.readMultiPatch | train | 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);
} | java | {
"resource": ""
} |
q15032 | AbstractShapeFileReader.readAttributesFromDBaseFile | train | 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);
}
}
}
}
} | java | {
"resource": ""
} |
q15033 | StochasticGenerator.noiseValue | train | @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;
}
} | java | {
"resource": ""
} |
q15034 | Transform3D.setRotation | train | 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();
} | java | {
"resource": ""
} |
q15035 | Transform3D.makeRotationMatrix | train | 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;
} | java | {
"resource": ""
} |
q15036 | StandardRoadConnection.setPosition | train | void setPosition(Point2D<?, ?> position) {
this.location = position == null ? null : new SoftReference<>(Point2d.convert(position));
} | java | {
"resource": ""
} |
q15037 | StandardRoadConnection.addConnectedSegment | train | 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();
} | java | {
"resource": ""
} |
q15038 | StandardRoadConnection.removeConnectedSegment | train | 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;
} | java | {
"resource": ""
} |
q15039 | StandardRoadConnection.addListeningIterator | train | protected void addListeningIterator(IClockwiseIterator iterator) {
if (this.listeningIterators == null) {
this.listeningIterators = new WeakArrayList<>();
}
this.listeningIterators.add(iterator);
} | java | {
"resource": ""
} |
q15040 | StandardRoadConnection.removeListeningIterator | train | protected void removeListeningIterator(IClockwiseIterator iterator) {
if (this.listeningIterators != null) {
this.listeningIterators.remove(iterator);
if (this.listeningIterators.isEmpty()) {
this.listeningIterators = null;
}
}
} | java | {
"resource": ""
} |
q15041 | StandardRoadConnection.fireIteratorUpdate | train | protected void fireIteratorUpdate() {
if (this.listeningIterators != null) {
for (final IClockwiseIterator iterator : this.listeningIterators) {
if (iterator != null) {
iterator.dataStructureUpdated();
}
}
}
} | java | {
"resource": ""
} |
q15042 | RoadNetworkLayerConstants.getPreferredRoadColor | train | @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;
} | java | {
"resource": ""
} |
q15043 | RoadNetworkLayerConstants.setPreferredRoadColor | train | 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) {
//
}
}
} | java | {
"resource": ""
} |
q15044 | RoadNetworkLayerConstants.getPreferredRoadInternDrawing | train | @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;
} | java | {
"resource": ""
} |
q15045 | RoadNetworkLayerConstants.setPreferredRoadInternDrawing | train | 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) {
//
}
}
} | java | {
"resource": ""
} |
q15046 | RoadNetworkLayerConstants.getPreferredRoadInternColor | train | @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;
} | java | {
"resource": ""
} |
q15047 | RoadNetworkLayerConstants.setPreferredRoadInternColor | train | 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) {
//
}
}
} | java | {
"resource": ""
} |
q15048 | MathUtil.clamp | train | @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;
} | java | {
"resource": ""
} |
q15049 | MathUtil.clampCyclic | train | @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;
} | java | {
"resource": ""
} |
q15050 | MathUtil.getMinMax | train | 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);
} | java | {
"resource": ""
} |
q15051 | MathUtil.csc | train | @Pure
@Inline(value = "1./Math.sin($1)", imported = {Math.class})
public static double csc(double angle) {
return 1. / Math.sin(angle);
} | java | {
"resource": ""
} |
q15052 | MathUtil.sec | train | @Pure
@Inline(value = "1./Math.cos($1)", imported = {Math.class})
public static double sec(double angle) {
return 1. / Math.cos(angle);
} | java | {
"resource": ""
} |
q15053 | MathUtil.cot | train | @Pure
@Inline(value = "1./Math.tan($1)", imported = {Math.class})
public static double cot(double angle) {
return 1. / Math.tan(angle);
} | java | {
"resource": ""
} |
q15054 | MathUtil.versin | train | @Pure
@Inline(value = "1.-Math.cos($1)", imported = {Math.class})
public static double versin(double angle) {
return 1. - Math.cos(angle);
} | java | {
"resource": ""
} |
q15055 | MathUtil.crd | train | @Pure
@Inline(value = "2.*Math.sin(($1)/2.)", imported = {Math.class})
public static double crd(double angle) {
return 2. * Math.sin(angle / 2.);
} | java | {
"resource": ""
} |
q15056 | Point2dfx.convert | train | public static Point2dfx convert(Tuple2D<?> tuple) {
if (tuple instanceof Point2dfx) {
return (Point2dfx) tuple;
}
return new Point2dfx(tuple.getX(), tuple.getY());
} | java | {
"resource": ""
} |
q15057 | AttributeValueImpl.parse | train | @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;
} | java | {
"resource": ""
} |
q15058 | AttributeValueImpl.compareValues | train | @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);
} | java | {
"resource": ""
} |
q15059 | AttributeValueImpl.compareRawValues | train | @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);
} | java | {
"resource": ""
} |
q15060 | AttributeValueImpl.setInternalValue | train | protected void setInternalValue(Object value, AttributeType type) {
this.value = value;
this.assigned = this.value != null;
this.type = type;
} | java | {
"resource": ""
} |
q15061 | AttributeValueImpl.extractDate | train | 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;
} | java | {
"resource": ""
} |
q15062 | DBaseFileFilter.isDbaseFile | train | @Pure
public static boolean isDbaseFile(File file) {
return FileType.isContentType(
file,
MimeName.MIME_DBASE_FILE.getMimeConstant());
} | java | {
"resource": ""
} |
q15063 | AbstractMapCircleDrawer.stroke | train | 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);
} | java | {
"resource": ""
} |
q15064 | AbstractMapCircleDrawer.fill | train | 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);
} | java | {
"resource": ""
} |
q15065 | BusItineraryHalt.getFirstFreeBushaltName | train | @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;
} | java | {
"resource": ""
} |
q15066 | BusItineraryHalt.setBusStop | train | 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;
} | java | {
"resource": ""
} |
q15067 | BusItineraryHalt.getRoadSegment | train | @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;
} | java | {
"resource": ""
} |
q15068 | BusItineraryHalt.getRoadSegmentDirection | train | @Pure
public Direction1D getRoadSegmentDirection() {
final BusItinerary itinerary = getContainer();
if (itinerary != null && this.roadSegmentIndex >= 0 && this.roadSegmentIndex < itinerary.getRoadSegmentCount()) {
return itinerary.getRoadSegmentDirection(this.roadSegmentIndex);
}
return null;
} | java | {
"resource": ""
} |
q15069 | BusItineraryHalt.setType | train | public void setType(BusItineraryHaltType type) {
if (type != null && type != this.type) {
this.type = type;
firePrimitiveChanged();
}
} | java | {
"resource": ""
} |
q15070 | BusItineraryHalt.insideBusHub | train | @Pure
public boolean insideBusHub() {
final BusStop busStop = getBusStop();
if (busStop != null) {
return busStop.insideBusHub();
}
return false;
} | java | {
"resource": ""
} |
q15071 | BusItineraryHalt.busHubs | train | @Pure
public Iterable<BusHub> busHubs() {
final BusStop busStop = getBusStop();
if (busStop != null) {
return busStop.busHubs();
}
return Collections.emptyList();
} | java | {
"resource": ""
} |
q15072 | BusItineraryHalt.busHubIterator | train | @Pure
public Iterator<BusHub> busHubIterator() {
final BusStop busStop = getBusStop();
if (busStop != null) {
return busStop.busHubIterator();
}
return Collections.emptyIterator();
} | java | {
"resource": ""
} |
q15073 | BusItineraryHalt.getGeoPosition | train | @Pure
public GeoLocationPoint getGeoPosition() {
final Point2d p = getPosition2D();
if (p != null) {
return new GeoLocationPoint(p.getX(), p.getY());
}
return null;
} | java | {
"resource": ""
} |
q15074 | BusItineraryHalt.distanceToBusStop | train | @Pure
public double distanceToBusStop() {
final Point2d p1 = getPosition2D();
if (p1 != null) {
final BusStop stop = getBusStop();
if (stop != null) {
final Point2d p2 = stop.getPosition2D();
if (p2 != null) {
return p1.getDistance(p2);
}
}
}
return Double.NaN;
} | java | {
"resource": ""
} |
q15075 | BusItineraryHalt.distance | train | @Pure
public double distance(Point2D<?, ?> point) {
assert point != null;
final GeoLocationPoint p = getGeoPosition();
if (p != null) {
return Point2D.getDistancePointPoint(p.getX(), p.getY(), point.getX(), point.getY());
}
return Double.NaN;
} | java | {
"resource": ""
} |
q15076 | BusItineraryHalt.distance | train | @Pure
public double distance(BusItineraryHalt halt) {
assert halt != null;
final GeoLocationPoint p = getGeoPosition();
final GeoLocationPoint p2 = halt.getGeoPosition();
if (p != null && p2 != null) {
return Point2D.getDistancePointPoint(p.getX(), p.getY(), p2.getX(), p2.getY());
}
return Double.NaN;
} | java | {
"resource": ""
} |
q15077 | BusItineraryHalt.distance | train | @Pure
public double distance(BusStop busStop) {
assert busStop != null;
final GeoLocationPoint p = getGeoPosition();
final GeoLocationPoint p2 = busStop.getGeoPosition();
if (p != null && p2 != null) {
return Point2D.getDistancePointPoint(p.getX(), p.getY(), p2.getX(), p2.getY());
}
return Double.NaN;
} | java | {
"resource": ""
} |
q15078 | EnglishAndChineseHeadRules.createChinesePTBFromResources | train | public static <NodeT extends ConstituentNode<NodeT, ?>> HeadFinder<NodeT> createChinesePTBFromResources()
throws IOException {
final boolean headInitial = true;
final CharSource resource = Resources
.asCharSource(EnglishAndChineseHeadRules.class.getResource("ch_heads.sun.txt"),
Charsets.UTF_8);
final ImmutableMap<Symbol, HeadRule<NodeT>> headRules =
headRulesFromResources(headInitial, resource);
return MapHeadFinder.create(headRules);
} | java | {
"resource": ""
} |
q15079 | DotDotWriter.write | train | public void write(Tree<?, ?> tree) throws IOException {
this.writer.append("digraph G"); //$NON-NLS-1$
this.writer.append(Integer.toString(this.graphIndex++));
this.writer.append(" {\n"); //$NON-NLS-1$
if (tree != null) {
// Write the node attributes
Iterator<? extends TreeNode<?, ?>> iterator = tree.broadFirstIterator();
TreeNode<?, ?> node;
int dataCount;
while (iterator.hasNext()) {
node = iterator.next();
dataCount = node.getUserDataCount();
final String name = "NODE" + Integer.toHexString(System.identityHashCode(node)); //$NON-NLS-1$
final String label = Integer.toString(dataCount);
this.writer.append("\t"); //$NON-NLS-1$
this.writer.append(name);
this.writer.append(" [label=\""); //$NON-NLS-1$
this.writer.append(label);
this.writer.append("\"]\n"); //$NON-NLS-1$
}
this.writer.append("\n"); //$NON-NLS-1$
// Write the node links
iterator = tree.broadFirstIterator();
Class<? extends Enum<?>> partitionType;
TreeNode<?, ?> child;
String childName;
while (iterator.hasNext()) {
node = iterator.next();
final String name = "NODE" + Integer.toHexString(System.identityHashCode(node)); //$NON-NLS-1$
if (!node.isLeaf()) {
partitionType = node.getPartitionEnumeration();
final int childCount = node.getChildCount();
for (int i = 0; i < childCount; ++i) {
child = node.getChildAt(i);
if (child != null) {
childName = "NODE" + Integer.toHexString(System.identityHashCode(child)); //$NON-NLS-1$
final String label;
if (partitionType != null) {
label = partitionType.getEnumConstants()[i].name();
} else {
label = Integer.toString(i);
}
this.writer.append("\t"); //$NON-NLS-1$
this.writer.append(name);
this.writer.append("->"); //$NON-NLS-1$
this.writer.append(childName);
this.writer.append(" [label=\""); //$NON-NLS-1$
this.writer.append(label);
this.writer.append("\"]\n"); //$NON-NLS-1$
}
}
}
}
}
this.writer.append("}\n\n"); //$NON-NLS-1$
} | java | {
"resource": ""
} |
q15080 | AbstractCapsule3F.containsCapsulePoint | train | @Pure
public static boolean containsCapsulePoint(
double capsule1Ax, double capsule1Ay, double capsule1Az, double capsule1Bx, double capsule1By, double capsule1Bz, double capsule1Radius,
double px, double py, double pz) {
double distPointToCapsuleSegment = AbstractSegment3F.distanceSquaredSegmentPoint(
capsule1Ax, capsule1Ay, capsule1Az, capsule1Bx, capsule1By, capsule1Bz,
px,py,pz);
return (distPointToCapsuleSegment <= (capsule1Radius * capsule1Radius));
} | java | {
"resource": ""
} |
q15081 | AbstractCapsule3F.intersectsCapsuleAlignedBox | train | @Pure
public static boolean intersectsCapsuleAlignedBox(
double mx1, double my1, double mz1,
double mx2, double my2, double mz2,
double radius,
double minx, double miny, double minz,
double maxx, double maxy, double maxz) {
Point3f closest1 = AlignedBox3f.computeClosestPoint(
minx, miny, minz, maxx, maxy, maxz,
mx1, my1, mz1);
Point3f closest2 = AlignedBox3f.computeClosestPoint(
minx, miny, minz, maxx, maxy, maxz,
mx2, my2, mz2);
double sq = AbstractSegment3F.distanceSquaredSegmentSegment(
mx1, my1, mz1,
mx2, my2, mz2,
closest1.getX(), closest1.getY(), closest1.getZ(),
closest2.getX(), closest2.getY(), closest2.getZ());
return (sq <= (radius * radius));
} | java | {
"resource": ""
} |
q15082 | AbstractCapsule3F.intersectsCapsuleCapsule | train | @Pure
public static boolean intersectsCapsuleCapsule(
double capsule1Ax, double capsule1Ay, double capsule1Az, double capsule1Bx, double capsule1By, double capsule1Bz, double capsule1Radius,
double capsule2Ax, double capsule2Ay, double capsule2Az, double capsule2Bx, double capsule2By, double capsule2Bz, double capsule2Radius) {
double dist2 = AbstractSegment3F.distanceSquaredSegmentSegment(
capsule1Ax, capsule1Ay, capsule1Az, capsule1Bx, capsule1By, capsule1Bz,
capsule2Ax, capsule2Ay, capsule2Az, capsule2Bx, capsule2By, capsule2Bz);
// If (squared) distance smaller than (squared) sum of radii, they collide
double radius = capsule1Radius + capsule2Radius;
return dist2 <= (radius * radius);
} | java | {
"resource": ""
} |
q15083 | AbstractCapsule3F.ensureAIsLowerPoint | train | protected void ensureAIsLowerPoint() {
CoordinateSystem3D cs = CoordinateSystem3D.getDefaultCoordinateSystem();
boolean swap = false;
if (cs.isZOnUp()) {
swap = (this.getMedial1().getZ() > this.getMedial2().getZ());
} else if (cs.isYOnUp()){
swap = (this.getMedial1().getY() > this.getMedial2().getY());
}
if (swap) {
double x = this.getMedial1().getX();
double y = this.getMedial1().getY();
double z = this.getMedial1().getZ();
this.getMedial1().set(this.getMedial2());
this.getMedial2().set(x, y, z);
}
} | java | {
"resource": ""
} |
q15084 | Vector3ifx.convert | train | public static Vector3ifx convert(Tuple3D<?> tuple) {
if (tuple instanceof Vector3ifx) {
return (Vector3ifx) tuple;
}
return new Vector3ifx(tuple.getX(), tuple.getY(), tuple.getZ());
} | java | {
"resource": ""
} |
q15085 | DssatSoilInput.readFile | train | @Override
protected HashMap readFile(HashMap brMap) throws IOException {
HashMap ret = new HashMap();
ArrayList<HashMap> sites = readSoilSites(brMap, new HashMap());
// compressData(sites);
ret.put("soils", sites);
return ret;
} | java | {
"resource": ""
} |
q15086 | Point3d.convert | train | public static Point3d convert(Tuple3D<?> tuple) {
if (tuple instanceof Point3d) {
return (Point3d) tuple;
}
return new Point3d(tuple.getX(), tuple.getY(), tuple.getZ());
} | java | {
"resource": ""
} |
q15087 | OctTreeNode.getChildAt | train | @Pure
public final N getChildAt(OctTreeZone zone) {
if (zone != null) {
return getChildAt(zone.ordinal());
}
return null;
} | java | {
"resource": ""
} |
q15088 | OctTreeNode.setChild6 | train | @SuppressWarnings("checkstyle:magicnumber")
private boolean setChild6(N newChild) {
if (this.child6 == newChild) {
return false;
}
if (this.child6 != null) {
this.child6.setParentNodeReference(null, true);
--this.notNullChildCount;
firePropertyChildRemoved(5, this.child5);
}
if (newChild != null) {
final N oldParent = newChild.getParentNode();
if (oldParent != this) {
newChild.removeFromParent();
}
}
this.child6 = newChild;
if (newChild != null) {
newChild.setParentNodeReference(toN(), true);
++this.notNullChildCount;
firePropertyChildAdded(5, newChild);
}
return true;
} | java | {
"resource": ""
} |
q15089 | OctTreeNode.setChild7 | train | @SuppressWarnings("checkstyle:magicnumber")
private boolean setChild7(N newChild) {
if (this.child7 == newChild) {
return false;
}
if (this.child7 != null) {
this.child7.setParentNodeReference(null, true);
--this.notNullChildCount;
firePropertyChildRemoved(6, this.child7);
}
if (newChild != null) {
final N oldParent = newChild.getParentNode();
if (oldParent != this) {
newChild.removeFromParent();
}
}
this.child7 = newChild;
if (newChild != null) {
newChild.setParentNodeReference(toN(), true);
++this.notNullChildCount;
firePropertyChildAdded(6, newChild);
}
return true;
} | java | {
"resource": ""
} |
q15090 | OctTreeNode.setChild8 | train | @SuppressWarnings("checkstyle:magicnumber")
private boolean setChild8(N newChild) {
if (this.child8 == newChild) {
return false;
}
if (this.child8 != null) {
this.child8.setParentNodeReference(null, true);
--this.notNullChildCount;
firePropertyChildRemoved(7, this.child8);
}
if (newChild != null) {
final N oldParent = newChild.getParentNode();
if (oldParent != this) {
newChild.removeFromParent();
}
}
this.child8 = newChild;
if (newChild != null) {
newChild.setParentNodeReference(toN(), true);
++this.notNullChildCount;
firePropertyChildAdded(7, newChild);
}
return true;
} | java | {
"resource": ""
} |
q15091 | GenerateSourceMojo.executeMojo | train | protected synchronized void executeMojo(File targetDir) throws MojoExecutionException {
if (this.generateTargets.contains(targetDir)
&& targetDir.isDirectory()) {
getLog().debug("Skiping " + targetDir + " because is was already generated"); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
this.generateTargets.add(targetDir);
final File[] sourceDirs;
final File mainDirectory = new File(getSourceDirectory(), "main"); //$NON-NLS-1$
if (this.sources == null || this.sources.length == 0) {
sourceDirs = new File[] {
new File(mainDirectory, "java"), //$NON-NLS-1$
};
} else {
sourceDirs = this.sources;
}
clearInternalBuffers();
for (final File sourceDir : sourceDirs) {
Map<File, File> htmlBasedFiles = this.bufferedFiles.get(sourceDir);
if (htmlBasedFiles == null) {
htmlBasedFiles = new TreeMap<>();
if (sourceDir.isDirectory()) {
// Search for .java files
findFiles(sourceDir, new JavaSourceFileFilter(), htmlBasedFiles);
}
this.bufferedFiles.put(sourceDir, htmlBasedFiles);
}
for (final Entry<File, File> entry : htmlBasedFiles.entrySet()) {
final String baseFile = removePathPrefix(entry.getValue(), entry.getKey());
replaceInFileBuffered(
entry.getKey(),
new File(targetDir, baseFile),
ReplacementType.HTML,
sourceDirs,
false);
}
}
} | java | {
"resource": ""
} |
q15092 | Caller.getCaller | train | @Pure
public static org.arakhne.afc.vmutil.caller.Caller getCaller() {
synchronized (Caller.class) {
if (caller == null) {
caller = new StackTraceCaller();
}
return caller;
}
} | java | {
"resource": ""
} |
q15093 | GridCell.getElementAt | train | @Pure
public P getElementAt(int index) {
if (index >= 0 && index < this.referenceElementCount) {
int idx = 0;
for (final GridCellElement<P> element : this.elements) {
if (element.isReferenceCell(this)) {
if (idx == index) {
return element.get();
}
++idx;
}
}
}
throw new IndexOutOfBoundsException();
} | java | {
"resource": ""
} |
q15094 | GridCell.iterator | train | @Pure
public Iterator<P> iterator(Rectangle2afp<?, ?, ?, ?, ?, ?> bounds) {
return new BoundsIterator<>(this.elements.iterator(), bounds);
} | java | {
"resource": ""
} |
q15095 | GridCell.addElement | train | public boolean addElement(GridCellElement<P> element) {
if (element != null && this.elements.add(element)) {
if (element.addCellLink(this)) {
++this.referenceElementCount;
}
return true;
}
return false;
} | java | {
"resource": ""
} |
q15096 | GridCell.removeElement | train | public GridCellElement<P> removeElement(P element) {
final GridCellElement<P> elt = remove(element);
if (elt != null) {
if (elt.removeCellLink(this)) {
--this.referenceElementCount;
}
}
return elt;
} | java | {
"resource": ""
} |
q15097 | SimpleViewer.getElementUnderMouse | train | @SuppressWarnings({ "rawtypes" })
public MapElement getElementUnderMouse(GisPane<?> pane, double x, double y) {
final GISContainer model = pane.getDocumentModel();
final Point2d mousePosition = pane.toDocumentPosition(x, y);
final Rectangle2d selectionArea = pane.toDocumentRect(x - 2, y - 2, 5, 5);
return getElementUnderMouse(model, mousePosition, selectionArea);
} | java | {
"resource": ""
} |
q15098 | EnumRadioButtonGroupBean.getSelectedEnumFromRadioButtons | train | protected E getSelectedEnumFromRadioButtons()
{
for (final E enumValue : this.radioButtonMap.keySet())
{
final JRadioButton btn = this.radioButtonMap.get(enumValue);
if (btn.isSelected())
{
return enumValue;
}
}
return null;
} | java | {
"resource": ""
} |
q15099 | EnumRadioButtonGroupBean.setSelectedRadioButton | train | private void setSelectedRadioButton(final E enumValue)
{
if (enumValue != null)
{
final JRadioButton radioButton = this.radioButtonMap.get(enumValue);
radioButton.setSelected(true);
}
else
{
for (final JRadioButton radioButton : this.radioButtonMap.values())
{
radioButton.setSelected(false);
}
}
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.