_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15200 | RhythmicalTomcat.addWebapp | train | @Override
public Context addWebapp(Host host, String contextPath, String docBase) {
final ContextConfig contextConfig = createContextConfig(); // *extension point
return addWebapp(host, contextPath, docBase, contextConfig);
} | java | {
"resource": ""
} |
q15201 | MultiAttributeCollection.fireAttributeChange | train | protected void fireAttributeChange(AttributeChangeEvent event) {
if (this.listeners != null && isEventFirable()) {
final AttributeChangeListener[] list = new AttributeChangeListener[this.listeners.size()];
this.listeners.toArray(list);
for (final AttributeChangeListener listener : list) {
listener.onAttributeChangeEvent(event);
}
}
} | java | {
"resource": ""
} |
q15202 | WeakArrayList.maskNull | train | @SuppressWarnings("unchecked")
private static <T> T maskNull(T value) {
return (value == null) ? (T) NULL_VALUE : value;
} | java | {
"resource": ""
} |
q15203 | WeakArrayList.assertRange | train | protected void assertRange(int index, boolean allowLast) {
final int csize = expurge();
if (index < 0) {
throw new IndexOutOfBoundsException(Locale.getString("E1", index)); //$NON-NLS-1$
}
if (allowLast && (index > csize)) {
throw new IndexOutOfBoundsException(Locale.getString("E2", csize, index)); //$NON-NLS-1$
}
if (!allowLast && (index >= csize)) {
throw new IndexOutOfBoundsException(Locale.getString("E3", csize, index)); //$NON-NLS-1$
}
} | java | {
"resource": ""
} |
q15204 | WeakArrayList.addReferenceListener | train | public void addReferenceListener(ReferenceListener listener) {
if (this.listeners == null) {
this.listeners = new LinkedList<>();
}
final List<ReferenceListener> list = this.listeners;
synchronized (list) {
list.add(listener);
}
} | java | {
"resource": ""
} |
q15205 | WeakArrayList.removeReferenceListener | train | public void removeReferenceListener(ReferenceListener listener) {
final List<ReferenceListener> list = this.listeners;
if (list != null) {
synchronized (list) {
list.remove(listener);
if (list.isEmpty()) {
this.listeners = null;
}
}
}
} | java | {
"resource": ""
} |
q15206 | WeakArrayList.fireReferenceRelease | train | protected void fireReferenceRelease(int released) {
final List<ReferenceListener> list = this.listeners;
if (list != null && !list.isEmpty()) {
for (final ReferenceListener listener : list) {
listener.referenceReleased(released);
}
}
} | java | {
"resource": ""
} |
q15207 | GraphPath.getStartingPointFor | train | @Pure
@SuppressWarnings("checkstyle:cyclomaticcomplexity")
public PT getStartingPointFor(int index) {
if ((index < 1) || (this.segmentList.size() <= 1)) {
if (this.startingPoint != null) {
return this.startingPoint;
}
} else {
int idx = index;
ST currentSegment = this.segmentList.get(idx);
ST previousSegment = this.segmentList.get(--idx);
// Because the two segments are the same
// we must go deeper in the path elements
// to detect the right segment
int count = 0;
while ((previousSegment != null) && (previousSegment.equals(currentSegment))) {
currentSegment = previousSegment;
idx--;
previousSegment = (idx >= 0) ? this.segmentList.get(idx) : null;
count++;
}
if (count > 0) {
PT sp = null;
if (previousSegment != null) {
final PT p1 = currentSegment.getBeginPoint();
final PT p2 = currentSegment.getEndPoint();
final PT p3 = previousSegment.getBeginPoint();
final PT p4 = previousSegment.getEndPoint();
assert p1 != null && p2 != null && p3 != null && p4 != null;
if (p1.equals(p3) || p1.equals(p4)) {
sp = p1;
} else if (p2.equals(p3) || p2.equals(p4)) {
sp = p2;
}
} else {
sp = this.startingPoint;
}
if (sp != null) {
return ((count % 2) == 0) ? sp : currentSegment.getOtherSidePoint(sp);
}
} else if ((currentSegment != null) && (previousSegment != null)) {
// if the two segments are different
// it is simple to detect the
// common point
final PT p1 = currentSegment.getBeginPoint();
final PT p2 = currentSegment.getEndPoint();
final PT p3 = previousSegment.getBeginPoint();
final PT p4 = previousSegment.getEndPoint();
assert p1 != null && p2 != null && p3 != null && p4 != null;
if (p1.equals(p3) || p1.equals(p4)) {
return p1;
}
if (p2.equals(p3) || p2.equals(p4)) {
return p2;
}
}
}
return null;
} | java | {
"resource": ""
} |
q15208 | GraphPath.removeUntil | train | boolean removeUntil(int index, boolean inclusive) {
if (index >= 0) {
boolean changed = false;
PT startPoint = this.startingPoint;
ST segment;
int limit = index;
if (inclusive) {
++limit;
}
for (int i = 0; i < limit; ++i) {
segment = this.segmentList.remove(0);
this.length -= segment.getLength();
if (this.length < 0) {
this.length = 0;
}
startPoint = segment.getOtherSidePoint(startPoint);
changed = true;
}
if (changed) {
if (this.segmentList.isEmpty()) {
this.startingPoint = null;
this.endingPoint = null;
this.isReversable = true;
} else {
this.startingPoint = startPoint;
}
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q15209 | GraphPath.invert | train | public void invert() {
final PT p = this.startingPoint;
this.startingPoint = this.endingPoint;
this.endingPoint = p;
final int middle = this.segmentList.size() / 2;
ST segment;
for (int i = 0, j = this.segmentList.size() - 1; i < middle; ++i, --j) {
segment = this.segmentList.get(i);
this.segmentList.set(i, this.segmentList.get(j));
this.segmentList.set(j, segment);
}
} | java | {
"resource": ""
} |
q15210 | GraphPath.splitAt | train | public GP splitAt(ST obj, PT startPoint) {
return splitAt(indexOf(obj, startPoint), true);
} | java | {
"resource": ""
} |
q15211 | GraphPath.splitAfterLast | train | public GP splitAfterLast(ST obj, PT startPoint) {
return splitAt(lastIndexOf(obj, startPoint), false);
} | java | {
"resource": ""
} |
q15212 | GraphPath.splitAtLast | train | public GP splitAtLast(ST obj, PT startPoint) {
return splitAt(lastIndexOf(obj, startPoint), true);
} | java | {
"resource": ""
} |
q15213 | GraphPath.splitAfter | train | public GP splitAfter(ST obj, PT startPoint) {
return splitAt(indexOf(obj, startPoint), false);
} | java | {
"resource": ""
} |
q15214 | AbstractPlane4F.transform | train | public void transform(Transform3D transform, Point3D pivot) {
Point3D refPoint = (pivot == null) ? getPivot() : pivot;
Vector3f v = new Vector3f(this.getEquationComponentA(),this.getEquationComponentB(),this.getEquationComponentC());
transform.transform(v);
// Update the plane equation according
// to the desired normal (computed from
// the identity vector and the rotations).
// a.x + b.y + c.z + d = 0
// where (x,y,z) is the translation point
this.set(v.getX(),v.getY(),v.getZ(),- (this.getEquationComponentA()*(refPoint.getX()+transform.m03) +
this.getEquationComponentB()*(refPoint.getY()+transform.m13) +
this.getEquationComponentC()*(refPoint.getZ()+transform.m23)));
clearBufferedValues();
} | java | {
"resource": ""
} |
q15215 | AbstractPlane4F.translate | train | public void translate(double dx, double dy, double dz) {
// Compute the reference point for the plane
// (usefull for translation)
Point3f refPoint = (Point3f) getPivot();
// a.x + b.y + c.z + d = 0
// where (x,y,z) is the translation point
setPivot(refPoint.getX()+dx,refPoint.getY()+dy,refPoint.getZ()+dz);
} | java | {
"resource": ""
} |
q15216 | AbstractPlane4F.rotate | train | public void rotate(Quaternion rotation, Point3D pivot) {
Point3D currentPivot = getPivot();
// Update the plane equation according
// to the desired normal (computed from
// the identity vector and the rotations).
Transform3D m = new Transform3D();
m.setRotation(rotation);
Vector3f v = new Vector3f(this.getEquationComponentA(),this.getEquationComponentB(),this.getEquationComponentC());
m.transform(v);
this.setEquationComponentA(v.getX());
this.setEquationComponentB(v.getY());
this.setEquationComponentC(v.getZ());
if (pivot==null) {
// a.x + b.y + c.z + d = 0
// where (x,y,z) is the translation point
this.setEquationComponentD( - (this.getEquationComponentA()*currentPivot.getX() +
this.getEquationComponentB()*currentPivot.getY() +
this.getEquationComponentC()*currentPivot.getZ()));
}
else {
// Compute the new point
Point3f nP = new Point3f(
currentPivot.getX() - pivot.getX(),
currentPivot.getY() - pivot.getY(),
currentPivot.getZ() - pivot.getZ());
m.transform(nP);
nP.setX(nP.getX() + pivot.getX());
nP.setY(nP.getY() + pivot.getY());
nP.setZ(nP.getZ() + pivot.getZ());
// a.x + b.y + c.z + d = 0
// where (x,y,z) is the translation point
this.setEquationComponentD( - (this.getEquationComponentA()*nP.getX() +
this.getEquationComponentB()*nP.getY() +
this.getEquationComponentC()*nP.getZ()));
}
clearBufferedValues();
} | java | {
"resource": ""
} |
q15217 | ProbabilityUtils.cleanProbability | train | public static double cleanProbability(double prob, double epsilon, boolean allowOne) {
if (prob < -epsilon || prob > (1.0 + epsilon)) {
throw new InvalidProbabilityException(prob);
}
if (prob < epsilon) {
prob = epsilon;
} else {
final double limit = allowOne ? 1.0 : (1.0 - epsilon);
if (prob > limit) {
prob = limit;
}
}
return prob;
} | java | {
"resource": ""
} |
q15218 | Path3d.propertyArraysEquals | train | @Pure
public static boolean propertyArraysEquals (Property<?>[] array, Property<?> [] array2) {
if(array.length==array2.length) {
for(int i=0; i<array.length; i++) {
if(array[i]==null) {
if(array2[i]!=null)
return false;
} else if(array2[i]==null) {
return false;
} else if(!array[i].getValue().equals(array2[i].getValue())) {
return false;
}
}
return true;
}
return false;
} | java | {
"resource": ""
} |
q15219 | Path3d.moveTo | train | public void moveTo(Point3d point) {
if (this.numTypesProperty.get()>0 && this.types[this.numTypesProperty.get()-1]==PathElementType.MOVE_TO) {
this.coordsProperty[this.numCoordsProperty.get()-3] = point.xProperty;
this.coordsProperty[this.numCoordsProperty.get()-2] = point.yProperty;
this.coordsProperty[this.numCoordsProperty.get()-1] = point.zProperty;
}
else {
ensureSlots(false, 3);
this.types[this.numTypesProperty.get()] = PathElementType.MOVE_TO;
this.numTypesProperty.set(this.numTypesProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = point.xProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = point.yProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = point.zProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
}
this.graphicalBounds = null;
this.logicalBounds = null;
} | java | {
"resource": ""
} |
q15220 | Path3d.lineTo | train | public void lineTo(Point3d point) {
ensureSlots(true, 3);
this.types[this.numTypesProperty.get()] = PathElementType.LINE_TO;
this.numTypesProperty.set(this.numTypesProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = point.xProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = point.yProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = point.zProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.isEmptyProperty = null;
this.graphicalBounds = null;
this.logicalBounds = null;
} | java | {
"resource": ""
} |
q15221 | Path3d.quadTo | train | public void quadTo(Point3d controlPoint, Point3d endPoint) {
ensureSlots(true, 6);
this.types[this.numTypesProperty.get()] = PathElementType.QUAD_TO;
this.numTypesProperty.set(this.numTypesProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = controlPoint.xProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = controlPoint.yProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = controlPoint.zProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = endPoint.xProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = endPoint.yProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = endPoint.zProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.isEmptyProperty = null;
this.isPolylineProperty.set(false);
this.graphicalBounds = null;
this.logicalBounds = null;
} | java | {
"resource": ""
} |
q15222 | Path3d.curveTo | train | public void curveTo(Point3d controlPoint1,
Point3d controlPoint2,
Point3d endPoint) {
ensureSlots(true, 9);
this.types[this.numTypesProperty.get()] = PathElementType.CURVE_TO;
this.numTypesProperty.set(this.numTypesProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = controlPoint1.xProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = controlPoint1.yProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = controlPoint1.zProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = controlPoint2.xProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = controlPoint2.yProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = controlPoint2.zProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = endPoint.xProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = endPoint.yProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.coordsProperty[this.numCoordsProperty.get()] = endPoint.zProperty;
this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
this.isEmptyProperty = null;
this.isPolylineProperty.set(false);
this.graphicalBounds = null;
this.logicalBounds = null;
} | java | {
"resource": ""
} |
q15223 | AbstractCommonShapeFileWriter.flush | train | protected void flush() throws IOException {
if (this.tempStream != null && this.buffer.position() > 0) {
final int pos = this.buffer.position();
this.buffer.rewind();
this.buffer.limit(pos);
this.tempStream.write(this.buffer);
this.buffer.rewind();
this.buffer.limit(this.buffer.capacity());
this.bufferPosition += pos;
}
} | java | {
"resource": ""
} |
q15224 | AbstractCommonShapeFileWriter.writeBEInt | train | protected final void writeBEInt(int v) throws IOException {
ensureAvailableBytes(4);
this.buffer.order(ByteOrder.BIG_ENDIAN);
this.buffer.putInt(v);
} | java | {
"resource": ""
} |
q15225 | AbstractCommonShapeFileWriter.writeBEDouble | train | protected final void writeBEDouble(double v) throws IOException {
ensureAvailableBytes(8);
this.buffer.order(ByteOrder.BIG_ENDIAN);
this.buffer.putDouble(v);
} | java | {
"resource": ""
} |
q15226 | AbstractCommonShapeFileWriter.writeLEInt | train | protected final void writeLEInt(int v) throws IOException {
ensureAvailableBytes(4);
this.buffer.order(ByteOrder.LITTLE_ENDIAN);
this.buffer.putInt(v);
} | java | {
"resource": ""
} |
q15227 | AbstractCommonShapeFileWriter.writeLEDouble | train | protected final void writeLEDouble(double v) throws IOException {
ensureAvailableBytes(8);
this.buffer.order(ByteOrder.LITTLE_ENDIAN);
this.buffer.putDouble(v);
} | java | {
"resource": ""
} |
q15228 | AbstractCommonShapeFileWriter.writeHeader | train | private void writeHeader(ESRIBounds box, ShapeElementType type, Collection<? extends E> elements) throws IOException {
if (!this.headerWasWritten) {
initializeContentBuffer();
box.ensureMinMax();
//Byte 0 : File Code (9994)
writeBEInt(SHAPE_FILE_CODE);
//Byte 4 : Unused (0)
writeBEInt(0);
//Byte 8 : Unused (0)
writeBEInt(0);
//Byte 12 : Unused (0)
writeBEInt(0);
//Byte 16 : Unused (0)
writeBEInt(0);
//Byte 20 : Unused (0)
writeBEInt(0);
//Byte 24 : File Length, fill later
writeBEInt(0);
//Byte 28 : Version(1000)
writeLEInt(SHAPE_FILE_VERSION);
//Byte 32 : ShapeType
writeLEInt(type.shapeType);
//Byte 36 : Xmin
writeLEDouble(toESRI_x(box.getMinX()));
//Byte 44 : Ymin
writeLEDouble(toESRI_y(box.getMinY()));
//Byte 52 : Xmax
writeLEDouble(toESRI_x(box.getMaxX()));
//Byte 60 : Ymax
writeLEDouble(toESRI_y(box.getMaxY()));
//Byte 68 : Zmin
writeLEDouble(toESRI_z(box.getMinZ()));
//Byte 76 : Zmax
writeLEDouble(toESRI_z(box.getMaxZ()));
//Byte 84 : Mmin
writeLEDouble(toESRI_m(box.getMinM()));
//Byte 92 : Mmax
writeLEDouble(toESRI_m(box.getMaxM()));
this.headerWasWritten = true;
this.recordIndex = 0;
onHeaderWritten(box, type, elements);
}
} | java | {
"resource": ""
} |
q15229 | AbstractCommonShapeFileWriter.write | train | public void write(Collection<? extends E> elements) throws IOException {
final Progression progressBar = getTaskProgression();
Progression subTask = null;
if (progressBar != null) {
progressBar.setProperties(0, 0, (elements.size() + 1) * 100, false);
}
if (this.fileBounds == null) {
this.fileBounds = getFileBounds();
}
if (this.fileBounds != null) {
writeHeader(this.fileBounds, this.elementType, elements);
if (progressBar != null) {
progressBar.setValue(100);
subTask = progressBar.subTask(elements.size() * 100);
subTask.setProperties(0, 0, elements.size(), false);
}
for (final E element : elements) {
writeElement(this.recordIndex, element, this.elementType);
if (subTask != null) {
subTask.setValue(this.recordIndex + 1);
}
++this.recordIndex;
}
} else {
throw new BoundsNotFoundException();
}
if (progressBar != null) {
progressBar.end();
}
} | java | {
"resource": ""
} |
q15230 | MeasureUnitUtil.toSeconds | train | @Pure
public static double toSeconds(double value, TimeUnit inputUnit) {
switch (inputUnit) {
case DAYS:
return value * 86400.;
case HOURS:
return value * 3600.;
case MINUTES:
return value * 60.;
case SECONDS:
break;
case MILLISECONDS:
return milli2unit(value);
case MICROSECONDS:
return micro2unit(value);
case NANOSECONDS:
return nano2unit(value);
default:
throw new IllegalArgumentException();
}
return value;
} | java | {
"resource": ""
} |
q15231 | MeasureUnitUtil.toMeters | train | @Pure
@SuppressWarnings("checkstyle:returncount")
public static double toMeters(double value, SpaceUnit inputUnit) {
switch (inputUnit) {
case TERAMETER:
return value * 1e12;
case GIGAMETER:
return value * 1e9;
case MEGAMETER:
return value * 1e6;
case KILOMETER:
return value * 1e3;
case HECTOMETER:
return value * 1e2;
case DECAMETER:
return value * 1e1;
case METER:
break;
case DECIMETER:
return value * 1e-1;
case CENTIMETER:
return value * 1e-2;
case MILLIMETER:
return value * 1e-3;
case MICROMETER:
return value * 1e-6;
case NANOMETER:
return value * 1e-9;
case PICOMETER:
return value * 1e-12;
case FEMTOMETER:
return value * 1e-15;
default:
throw new IllegalArgumentException();
}
return value;
} | java | {
"resource": ""
} |
q15232 | MeasureUnitUtil.fromSeconds | train | @Pure
public static double fromSeconds(double value, TimeUnit outputUnit) {
switch (outputUnit) {
case DAYS:
return value / 86400.;
case HOURS:
return value / 3600.;
case MINUTES:
return value / 60.;
case SECONDS:
break;
case MILLISECONDS:
return unit2milli(value);
case MICROSECONDS:
return unit2micro(value);
case NANOSECONDS:
return unit2nano(value);
default:
throw new IllegalArgumentException();
}
return value;
} | java | {
"resource": ""
} |
q15233 | MeasureUnitUtil.toMetersPerSecond | train | @Pure
public static double toMetersPerSecond(double value, SpeedUnit inputUnit) {
switch (inputUnit) {
case KILOMETERS_PER_HOUR:
return 3.6 * value;
case MILLIMETERS_PER_SECOND:
return value / 1000.;
case METERS_PER_SECOND:
default:
}
return value;
} | java | {
"resource": ""
} |
q15234 | MeasureUnitUtil.toRadiansPerSecond | train | @Pure
public static double toRadiansPerSecond(double value, AngularUnit inputUnit) {
switch (inputUnit) {
case TURNS_PER_SECOND:
return value * (2. * MathConstants.PI);
case DEGREES_PER_SECOND:
return Math.toRadians(value);
case RADIANS_PER_SECOND:
default:
}
return value;
} | java | {
"resource": ""
} |
q15235 | MeasureUnitUtil.fromMetersPerSecond | train | @Pure
public static double fromMetersPerSecond(double value, SpeedUnit outputUnit) {
switch (outputUnit) {
case KILOMETERS_PER_HOUR:
return value / 3.6;
case MILLIMETERS_PER_SECOND:
return value * 1000.;
case METERS_PER_SECOND:
default:
}
return value;
} | java | {
"resource": ""
} |
q15236 | MeasureUnitUtil.fromRadiansPerSecond | train | @Pure
public static double fromRadiansPerSecond(double value, AngularUnit outputUnit) {
switch (outputUnit) {
case TURNS_PER_SECOND:
return value / (2. * MathConstants.PI);
case DEGREES_PER_SECOND:
return Math.toDegrees(value);
case RADIANS_PER_SECOND:
default:
}
return value;
} | java | {
"resource": ""
} |
q15237 | MeasureUnitUtil.getSmallestUnit | train | @Pure
public static SpaceUnit getSmallestUnit(double amount, SpaceUnit unit) {
final double meters = toMeters(amount, unit);
double v;
final SpaceUnit[] units = SpaceUnit.values();
SpaceUnit u;
for (int i = units.length - 1; i >= 0; --i) {
u = units[i];
v = Math.floor(fromMeters(meters, u));
if (v > 0.) {
return u;
}
}
return unit;
} | java | {
"resource": ""
} |
q15238 | Vector3d.convert | train | public static Vector3d convert(Tuple3D<?> tuple) {
if (tuple instanceof Vector3d) {
return (Vector3d) tuple;
}
return new Vector3d(tuple.getX(), tuple.getY(), tuple.getZ());
} | java | {
"resource": ""
} |
q15239 | NYTCorpusDocument.ljust | train | private String ljust(String s, Integer length) {
if (s.length() >= length) {
return s;
}
length -= s.length();
StringBuffer sb = new StringBuffer();
for (Integer i = 0; i < length; i++) {
sb.append(" ");
}
return s + sb.toString();
} | java | {
"resource": ""
} |
q15240 | NYTCorpusDocument.appendProperty | train | private void appendProperty(StringBuffer sb, String propertyName,
Object propertyValue) {
if (propertyValue != null) {
propertyValue = propertyValue.toString().replaceAll("\\s+", " ")
.trim();
}
sb.append(ljust(propertyName + ":", 45) + propertyValue + "\n");
} | java | {
"resource": ""
} |
q15241 | AbstractBoxedShape3F.inflate | train | public void inflate(double minx, double miny, double minz, double maxx, double maxy, double maxz) {
this.setFromCorners(this.getMinX()+ minx,this.getMinY()+ miny,this.getMinZ()+ minz,this.getMaxX()+ maxx,this.getMaxY()+ maxy,this.getMaxZ()+ maxz);
} | java | {
"resource": ""
} |
q15242 | AlignedBox3d.computeClosestPoint | train | @Pure
public static Point3d computeClosestPoint(
double minx, double miny, double minz,
double maxx, double maxy, double maxz,
double x, double y, double z) {
Point3d closest = new Point3d();
if (x < minx) {
closest.setX(minx);
}
else if (x > maxx) {
closest.setX(maxx);
}
else {
closest.setX(x);
}
if (y < miny) {
closest.setY(miny);
}
else if (y > maxy) {
closest.setY(maxy);
}
else {
closest.setY(y);
}
if (z < minz) {
closest.setZ(minz);
}
else if (z > maxz) {
closest.setZ(maxz);
}
else {
closest.setZ(z);
}
return closest;
} | java | {
"resource": ""
} |
q15243 | AlignedBox3d.setMinX | train | @Override
public void setMinX(double x) {
double o = this.maxxProperty.doubleValue();
if (o<x) {
this.minxProperty.set(o);
this.maxxProperty.set(x);
}
else {
this.minxProperty.set(x);
}
} | java | {
"resource": ""
} |
q15244 | AlignedBox3d.setMaxX | train | @Override
public void setMaxX(double x) {
double o = this.minxProperty.doubleValue();
if (o>x) {
this.maxxProperty.set(o);
this.minxProperty.set(x);
}
else {
this.maxxProperty.set(x);
}
} | java | {
"resource": ""
} |
q15245 | AlignedBox3d.setMaxY | train | @Override
public void setMaxY(double y) {
double o = this.minyProperty.doubleValue() ;
if (o>y) {
this.maxyProperty.set( o);
this.minyProperty.set(y);
}
else {
this.maxyProperty.set(y);
}
} | java | {
"resource": ""
} |
q15246 | MapElementGroup.classifiesElement | train | @Pure
public static ShapeElementType classifiesElement(MapElement element) {
final Class<? extends MapElement> type = element.getClass();
if (MapMultiPoint.class.isAssignableFrom(type)) {
return ShapeElementType.MULTIPOINT;
}
if (MapPolygon.class.isAssignableFrom(type)) {
return ShapeElementType.POLYGON;
}
if (MapPolyline.class.isAssignableFrom(type)) {
return ShapeElementType.POLYLINE;
}
if (MapPoint.class.isAssignableFrom(type)) {
return ShapeElementType.POINT;
}
return ShapeElementType.UNSUPPORTED;
} | java | {
"resource": ""
} |
q15247 | MapElementGroup.add | train | void add(MapElement element) {
final Rectangle2d r = element.getBoundingBox();
if (r != null) {
if (Double.isNaN(this.minx) || this.minx > r.getMinX()) {
this.minx = r.getMinX();
}
if (Double.isNaN(this.maxx) || this.maxx < r.getMaxX()) {
this.maxx = r.getMaxX();
}
if (Double.isNaN(this.miny) || this.miny > r.getMinY()) {
this.miny = r.getMinY();
}
if (Double.isNaN(this.maxy) || this.maxy < r.getMaxY()) {
this.maxy = r.getMaxY();
}
}
this.elements.add(element);
} | java | {
"resource": ""
} |
q15248 | MultiCollection.addCollection | train | public void addCollection(Collection<? extends E> collection) {
if (collection != null && !collection.isEmpty()) {
this.collections.add(collection);
}
} | java | {
"resource": ""
} |
q15249 | Point2ifx.convert | train | public static Point2ifx convert(Tuple2D<?> tuple) {
if (tuple instanceof Point2ifx) {
return (Point2ifx) tuple;
}
return new Point2ifx(tuple.getX(), tuple.getY());
} | java | {
"resource": ""
} |
q15250 | GenericTableModel.remove | train | public T remove(final T row)
{
final int index = data.indexOf(row);
if (index != -1)
{
try
{
return data.remove(index);
}
finally
{
fireTableDataChanged();
}
}
return null;
} | java | {
"resource": ""
} |
q15251 | GenericTableModel.removeAll | train | public List<T> removeAll(final List<T> toRemove)
{
final List<T> removedList = new ArrayList<>();
for (final T t : toRemove)
{
final int index = data.indexOf(t);
if (index != -1)
{
removedList.add(data.remove(index));
}
}
fireTableDataChanged();
return removedList;
} | java | {
"resource": ""
} |
q15252 | GenericTableModel.update | train | public void update(final T row)
{
final int index = data.indexOf(row);
if (index != -1)
{
data.set(index, row);
fireTableDataChanged();
}
} | java | {
"resource": ""
} |
q15253 | Point3ifx.convert | train | public static Point3ifx convert(Tuple3D<?> tuple) {
if (tuple instanceof Point3ifx) {
return (Point3ifx) tuple;
}
return new Point3ifx(tuple.getX(), tuple.getY(), tuple.getZ());
} | java | {
"resource": ""
} |
q15254 | Triangle2dfx.ccwProperty | train | @Pure
public ReadOnlyBooleanProperty ccwProperty() {
if (this.ccw == null) {
this.ccw = new ReadOnlyBooleanWrapper(this, MathFXAttributeNames.CCW);
this.ccw.bind(Bindings.createBooleanBinding(() ->
Triangle2afp.isCCW(
getX1(), getY1(), getX2(), getY2(),
getX3(), getY3()),
x1Property(), y1Property(),
x2Property(), y2Property(),
x3Property(), y3Property()));
}
return this.ccw.getReadOnlyProperty();
} | java | {
"resource": ""
} |
q15255 | SummaryConfusionMatrices.chooseMostCommonRightHandClassAccuracy | train | public static final double chooseMostCommonRightHandClassAccuracy(SummaryConfusionMatrix m) {
final double total = m.sumOfallCells();
double max = 0.0;
for (final Symbol right : m.rightLabels()) {
max = Math.max(max, m.columnSum(right));
}
return DoubleUtils.XOverYOrZero(max, total);
} | java | {
"resource": ""
} |
q15256 | GridCellElement.consumeCells | train | public List<GridCell<P>> consumeCells() {
final List<GridCell<P>> list = new ArrayList<>(this.cells);
this.cells.clear();
return list;
} | java | {
"resource": ""
} |
q15257 | GridCellElement.isReferenceCell | train | @Pure
public boolean isReferenceCell(GridCell<P> cell) {
return !this.cells.isEmpty() && this.cells.get(0) == cell;
} | java | {
"resource": ""
} |
q15258 | ListUtils.shuffledCopy | train | public static <E> ImmutableList<E> shuffledCopy(List<? extends E> list, Random rng) {
final ArrayList<E> shuffled = Lists.newArrayList(list);
Collections.shuffle(shuffled, rng);
return ImmutableList.copyOf(shuffled);
} | java | {
"resource": ""
} |
q15259 | AbstractReplaceMojo.replaceInFileBuffered | train | protected synchronized void replaceInFileBuffered(File sourceFile, File targetFile, ReplacementType replacementType,
File[] classpath, boolean detectEncoding) throws MojoExecutionException {
if (this.replacementTreatedFiles.contains(targetFile)
&& targetFile.exists()) {
getLog().debug("Skiping " + targetFile //$NON-NLS-1$
+ " because is was already treated for replacements"); //$NON-NLS-1$
return;
}
replaceInFile(sourceFile, targetFile, replacementType, classpath, detectEncoding);
} | java | {
"resource": ""
} |
q15260 | AbstractReplaceMojo.replaceAuthor | train | @SuppressWarnings("checkstyle:nestedifdepth")
protected synchronized String replaceAuthor(File sourceFile, int sourceLine, String text,
ExtendedArtifact artifact, ReplacementType replacementType) throws MojoExecutionException {
String result = text;
final Pattern p = buildMacroPatternWithGroup(Macros.MACRO_AUTHOR);
final Matcher m = p.matcher(text);
boolean hasResult = m.find();
if (hasResult) {
final StringBuffer sb = new StringBuffer();
final StringBuilder replacement = new StringBuilder();
String login;
URL url;
Contributor contributor;
do {
login = m.group(1);
if (login != null) {
login = login.trim();
if (login.length() > 0) {
replacement.setLength(0);
if (artifact != null) {
contributor = artifact.getPeople(login, getLog());
if (contributor != null) {
url = getContributorURL(contributor, getLog());
if (url == null) {
replacement.append(contributor.getName());
} else if (replacementType == ReplacementType.HTML) {
replacement.append("<a target=\"_blank\" href=\""); //$NON-NLS-1$
replacement.append(url.toExternalForm());
replacement.append("\">"); //$NON-NLS-1$
replacement.append(contributor.getName());
replacement.append("</a>"); //$NON-NLS-1$
} else {
replacement.append(contributor.getName());
replacement.append(" ["); //$NON-NLS-1$
replacement.append(url.toExternalForm());
replacement.append("]"); //$NON-NLS-1$
}
} else {
getBuildContext().addMessage(
sourceFile,
sourceLine, 1,
"unable to find a developer or a contributor " //$NON-NLS-1$
+ "with an id, a name or an email equal to: " //$NON-NLS-1$
+ login,
BuildContext.SEVERITY_WARNING, null);
}
}
if (replacement.length() != 0) {
m.appendReplacement(sb, Matcher.quoteReplacement(replacement.toString()));
}
} else {
getBuildContext().addMessage(
sourceFile,
sourceLine, 1,
"no login for Author tag: " + m.group(0), //$NON-NLS-1$
BuildContext.SEVERITY_WARNING, null);
}
} else {
getBuildContext().addMessage(
sourceFile,
sourceLine, 1,
"no login for Author tag: " + m.group(0), //$NON-NLS-1$
BuildContext.SEVERITY_WARNING, null);
}
hasResult = m.find();
} while (hasResult);
m.appendTail(sb);
result = sb.toString();
}
return result;
} | java | {
"resource": ""
} |
q15261 | AbstractReplaceMojo.replaceProp | train | @SuppressWarnings("checkstyle:nestedifdepth")
protected synchronized String replaceProp(File sourceFile, int sourceLine, String text,
MavenProject project, ReplacementType replacementType) throws MojoExecutionException {
String result = text;
final Pattern p = buildMacroPatternWithGroup(Macros.MACRO_PROP);
final Matcher m = p.matcher(text);
boolean hasResult = m.find();
Properties props = null;
if (project != null) {
props = project.getProperties();
}
if (hasResult) {
final StringBuffer sb = new StringBuffer();
final StringBuilder replacement = new StringBuilder();
String propName;
do {
propName = m.group(1);
if (propName != null) {
propName = propName.trim();
if (propName.length() > 0) {
replacement.setLength(0);
if (props != null) {
final String value = props.getProperty(propName);
if (value != null && !value.isEmpty()) {
replacement.append(value);
}
}
if (replacement.length() != 0) {
m.appendReplacement(sb, Matcher.quoteReplacement(replacement.toString()));
}
} else {
getBuildContext().addMessage(
sourceFile,
sourceLine, 1,
"no property name for Prop tag: " + m.group(0), //$NON-NLS-1$
BuildContext.SEVERITY_WARNING, null);
}
} else {
getBuildContext().addMessage(
sourceFile,
sourceLine, 1,
"no property name for Prop tag: " + m.group(0), //$NON-NLS-1$
BuildContext.SEVERITY_WARNING, null);
}
hasResult = m.find();
}
while (hasResult);
m.appendTail(sb);
result = sb.toString();
}
return result;
} | java | {
"resource": ""
} |
q15262 | AbstractReplaceMojo.setSourceDirectoryForAllMojo | train | protected void setSourceDirectoryForAllMojo(File newSourceDirectory) {
final List<String> sourceRoots = this.mavenProject.getCompileSourceRoots();
getLog().debug("Old source roots: " + sourceRoots.toString()); //$NON-NLS-1$
final Iterator<String> iterator = sourceRoots.iterator();
final String removableSourcePath = this.javaSourceRoot.getAbsolutePath();
getLog().debug("Removable source root: " + removableSourcePath); //$NON-NLS-1$
String path;
while (iterator.hasNext()) {
path = iterator.next();
if (path != null && path.equals(removableSourcePath)) {
getLog().debug("Removing source root: " + path); //$NON-NLS-1$
iterator.remove();
}
}
getLog().debug("Adding source root: " + newSourceDirectory.getAbsolutePath()); //$NON-NLS-1$
this.mavenProject.addCompileSourceRoot(newSourceDirectory.toString());
this.sourceDirectory = newSourceDirectory;
} | java | {
"resource": ""
} |
q15263 | OffsetRange.charOffsetsOfWholeString | train | public static Optional<OffsetRange<CharOffset>> charOffsetsOfWholeString(String s) {
if (s.isEmpty()) {
return Optional.absent();
}
return Optional.of(charOffsetRange(0, s.length() - 1));
} | java | {
"resource": ""
} |
q15264 | OffsetRange.contains | train | public boolean contains(final OffsetType x) {
return x.asInt() >= startInclusive().asInt() && x.asInt() <= endInclusive().asInt();
} | java | {
"resource": ""
} |
q15265 | ColorNames.getColorFromName | train | @Pure
public static int getColorFromName(String colorName, int defaultValue) {
final Integer value = COLOR_MATCHES.get(Strings.nullToEmpty(colorName).toLowerCase());
if (value != null) {
return value.intValue();
}
return defaultValue;
} | java | {
"resource": ""
} |
q15266 | ColorNames.getColorNameFromValue | train | @Pure
public static String getColorNameFromValue(int colorValue) {
for (final Entry<String, Integer> entry : COLOR_MATCHES.entrySet()) {
final int knownValue = entry.getValue().intValue();
if (colorValue == knownValue) {
return entry.getKey();
}
}
return null;
} | java | {
"resource": ""
} |
q15267 | ClusteredRoadPath.getLength | train | @Pure
public double getLength() {
double length = 0;
for (final RoadPath p : this.paths) {
length += p.getLength();
}
return length;
} | java | {
"resource": ""
} |
q15268 | ClusteredRoadPath.indexOf | train | @Pure
public int indexOf(RoadSegment segment) {
int count = 0;
int index;
for (final RoadPath p : this.paths) {
index = p.indexOf(segment);
if (index >= 0) {
return count + index;
}
count += p.size();
}
return -1;
} | java | {
"resource": ""
} |
q15269 | ClusteredRoadPath.lastIndexOf | train | @Pure
public int lastIndexOf(RoadSegment segment) {
int count = 0;
int index;
int lastIndex = -1;
for (final RoadPath p : this.paths) {
index = p.lastIndexOf(segment);
if (index >= 0) {
lastIndex = count + index;
}
count += p.size();
}
return lastIndex;
} | java | {
"resource": ""
} |
q15270 | ClusteredRoadPath.getRoadSegmentAt | train | @Pure
public RoadSegment getRoadSegmentAt(int index) {
if (index >= 0) {
int b = 0;
for (final RoadPath p : this.paths) {
final int e = b + p.size();
if (index < e) {
return p.get(index - b);
}
b = e;
}
}
throw new IndexOutOfBoundsException();
} | java | {
"resource": ""
} |
q15271 | ClusteredRoadPath.getPathForRoadSegmentAt | train | @Pure
public RoadPath getPathForRoadSegmentAt(int index) {
if (index >= 0) {
int b = 0;
for (final RoadPath p : this.paths) {
final int e = b + p.size();
if (index < e) {
return p;
}
b = e;
}
}
throw new IndexOutOfBoundsException();
} | java | {
"resource": ""
} |
q15272 | ClusteredRoadPath.removeRoadSegmentAt | train | public RoadSegment removeRoadSegmentAt(int index) {
if (index >= 0) {
int b = 0;
for (final RoadPath p : this.paths) {
int end = b + p.size();
if (index < end) {
end = index - b;
return removeRoadSegmentAt(p, end, null);
}
b = end;
}
}
throw new IndexOutOfBoundsException();
} | java | {
"resource": ""
} |
q15273 | ClusteredRoadPath.removeRoadSegmentAt | train | private RoadSegment removeRoadSegmentAt(RoadPath path, int index, PathIterator iterator) {
final int pathIndex = this.paths.indexOf(path);
assert pathIndex >= 0 && pathIndex < this.paths.size();
assert index >= 0 && index < path.size();
final RoadPath syncPath;
final RoadSegment sgmt;
if (index == 0 || index == path.size() - 1) {
// Remove one of the bounds of the path. if cause
// minimal insertion changes in the clustered road-path
sgmt = path.remove(index);
} else {
// Split the path somewhere between the first and last positions
sgmt = path.get(index);
assert sgmt != null;
final RoadPath rest = path.splitAfter(sgmt);
path.remove(sgmt);
if (rest != null && !rest.isEmpty()) {
// put back the rest of the segments
this.paths.add(pathIndex + 1, rest);
}
}
--this.segmentCount;
if (path.isEmpty()) {
this.paths.remove(path);
if (pathIndex > 0) {
syncPath = this.paths.get(pathIndex - 1);
} else {
syncPath = null;
}
} else {
syncPath = path;
}
if (iterator != null) {
iterator.reset(syncPath);
}
return sgmt;
} | java | {
"resource": ""
} |
q15274 | ClusteredRoadPath.addAndGetPath | train | @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity",
"checkstyle:nestedifdepth"})
public RoadPath addAndGetPath(RoadPath end) {
RoadPath selectedPath = null;
if (end != null && !end.isEmpty()) {
RoadConnection first = end.getFirstPoint();
RoadConnection last = end.getLastPoint();
assert first != null;
assert last != null;
first = first.getWrappedRoadConnection();
last = last.getWrappedRoadConnection();
assert first != null;
assert last != null;
if (this.paths.isEmpty()) {
this.paths.add(end);
selectedPath = end;
} else {
RoadPath connectToFirst = null;
RoadPath connectToLast = null;
final Iterator<RoadPath> pathIterator = this.paths.iterator();
RoadPath path;
while ((connectToFirst == null || connectToLast == null) && pathIterator.hasNext()) {
path = pathIterator.next();
if (connectToFirst == null) {
if (first.equals(path.getFirstPoint())) {
connectToFirst = path;
} else if (first.equals(path.getLastPoint())) {
connectToFirst = path;
}
}
if (connectToLast == null) {
if (last.equals(path.getFirstPoint())) {
connectToLast = path;
} else if (last.equals(path.getLastPoint())) {
connectToLast = path;
}
}
}
if (connectToFirst != null && connectToLast != null && !connectToLast.equals(connectToFirst)) {
// a) Select the biggest path as reference
// b) Remove the nonreference path that is connected to the new path
// c) Add the components of the new path into the reference path
// d) Reinject the components of the nonreference path.
// --
// a)
final RoadPath reference;
final RoadPath nonreference;
if (connectToFirst.size() > connectToLast.size()) {
reference = connectToFirst;
nonreference = connectToLast;
} else {
reference = connectToLast;
nonreference = connectToFirst;
}
// b)
if (this.paths.remove(nonreference)) {
// c)
if (!RoadPath.addPathToPath(reference, end)) {
// Reinject the remove elements.
this.paths.add(nonreference);
} else {
// d)
if (!RoadPath.addPathToPath(reference, nonreference)) {
// Reinject the remove elements.
this.paths.add(nonreference);
} else {
selectedPath = reference;
}
}
}
} else if (connectToFirst != null) {
if (RoadPath.addPathToPath(connectToFirst, end)) {
selectedPath = connectToFirst;
}
} else if (connectToLast != null) {
if (RoadPath.addPathToPath(connectToLast, end)) {
selectedPath = connectToLast;
}
} else if (this.paths.add(end)) {
selectedPath = end;
}
}
if (selectedPath != null) {
this.segmentCount += end.size();
}
}
return selectedPath;
} | java | {
"resource": ""
} |
q15275 | AbstractTreeNode.setParentNodeReference | train | boolean setParentNodeReference(N newParent, boolean fireEvent) {
final N oldParent = getParentNode();
if (newParent == oldParent) {
return false;
}
this.parent = (newParent == null) ? null : new WeakReference<>(newParent);
if (!fireEvent) {
return true;
}
firePropertyParentChanged(oldParent, newParent);
if (oldParent != null) {
oldParent.firePropertyParentChanged(toN(), oldParent, newParent);
}
return false;
} | java | {
"resource": ""
} |
q15276 | AbstractTreeNode.firePropertyChildAdded | train | void firePropertyChildAdded(TreeNodeAddedEvent event) {
if (this.nodeListeners != null) {
for (final TreeNodeListener listener : this.nodeListeners) {
if (listener != null) {
listener.treeNodeChildAdded(event);
}
}
}
final N parentNode = getParentNode();
assert parentNode != this;
if (parentNode != null) {
parentNode.firePropertyChildAdded(event);
}
} | java | {
"resource": ""
} |
q15277 | AbstractTreeNode.firePropertyChildRemoved | train | void firePropertyChildRemoved(TreeNodeRemovedEvent event) {
if (this.nodeListeners != null) {
for (final TreeNodeListener listener : this.nodeListeners) {
if (listener != null) {
listener.treeNodeChildRemoved(event);
}
}
}
final N parentNode = getParentNode();
if (parentNode != null) {
parentNode.firePropertyChildRemoved(event);
}
} | java | {
"resource": ""
} |
q15278 | StringUtils.joinFunction | train | public static Function<Iterable<?>, String> joinFunction(final Joiner joiner) {
return new Function<Iterable<?>, String>() {
@Override
public String apply(final Iterable<?> list) {
return joiner.join(list);
}
};
} | java | {
"resource": ""
} |
q15279 | StringUtils.toLowerCaseFunction | train | public static Function<String, String> toLowerCaseFunction(final Locale locale) {
return new Function<String, String>() {
@Override
public String apply(final String s) {
return s.toLowerCase(locale);
}
@Override
public String toString() {
return "toLowercase(" + locale + ")";
}
};
} | java | {
"resource": ""
} |
q15280 | StringUtils.stripAccents | train | public static UnicodeFriendlyString stripAccents(final UnicodeFriendlyString input) {
// this nifty normalization courtesy of http://stackoverflow.com/questions/3322152/is-there-a-way-to-get-rid-of-accents-and-convert-a-whole-string-to-regular-lette
return StringUtils.unicodeFriendly(ACCENT_STRIPPER.matcher(
Normalizer.normalize(input.utf16CodeUnits(), Normalizer.Form.NFD))
// note this replaceAll is really deleteAll
.replaceAll(""));
} | java | {
"resource": ""
} |
q15281 | RobotExtensions.getKeyCode | train | public static int getKeyCode(final char character)
throws IllegalAccessException, NoSuchFieldException
{
final String c = String.valueOf(character).toUpperCase();
final String variableName = "VK_" + c;
final Class<KeyEvent> clazz = KeyEvent.class;
final Field field = clazz.getField(variableName);
final int keyCode = field.getInt(null);
return keyCode;
} | java | {
"resource": ""
} |
q15282 | RobotExtensions.typeCharacter | train | public static void typeCharacter(final Robot robot, final char character)
throws IllegalAccessException, NoSuchFieldException
{
final boolean upperCase = Character.isUpperCase(character);
final int keyCode = getKeyCode(character);
if (upperCase)
{
robot.keyPress(KeyEvent.VK_SHIFT);
}
robot.keyPress(keyCode);
robot.keyRelease(keyCode);
if (upperCase)
{
robot.keyRelease(KeyEvent.VK_SHIFT);
}
} | java | {
"resource": ""
} |
q15283 | RobotExtensions.typeString | train | public static void typeString(final Robot robot, final String input)
throws NoSuchFieldException, IllegalAccessException
{
if (input != null && !input.isEmpty())
{
for (final char character : input.toCharArray())
{
typeCharacter(robot, character);
}
}
} | java | {
"resource": ""
} |
q15284 | GISLayerReader.iterator | train | public <T extends MapLayer> Iterator<T> iterator(Class<T> type) {
return new LayerReaderIterator<>(type);
} | java | {
"resource": ""
} |
q15285 | GISLayerReader.read | train | public final <T extends MapLayer> T read(Class<T> type) throws IOException {
// Read the header
if (!this.isHeaderRead) {
this.isHeaderRead = true;
readHeader();
if (this.progression != null) {
this.progression.setProperties(0, 0, this.restToRead, false);
}
}
T selectedObject = null;
if (this.restToRead > 0) {
final ObjectInputStream oos = new ObjectInputStream(this.input);
do {
try {
final Object readObject = oos.readObject();
--this.restToRead;
if (type.isInstance(readObject)) {
selectedObject = type.cast(readObject);
}
} catch (ClassNotFoundException e) {
//
}
}
while (this.restToRead > 0 && selectedObject == null);
}
if (this.progression != null) {
if (this.restToRead <= 0) {
this.progression.end();
} else {
this.progression.increment();
}
}
return selectedObject;
} | java | {
"resource": ""
} |
q15286 | GISLayerReader.readHeader | train | @SuppressWarnings({"resource", "checkstyle:magicnumber"})
protected void readHeader() throws IOException {
final ReadableByteChannel in = Channels.newChannel(this.input);
final int limit = HEADER_KEY.getBytes().length + 2;
final ByteBuffer hBuffer = ByteBuffer.allocate(limit);
hBuffer.limit(limit);
// Check the header
final byte[] key = GISLayerIOConstants.HEADER_KEY.getBytes();
final int n = in.read(hBuffer);
if (n != limit) {
throw new IOException("Invalid file header"); //$NON-NLS-1$
}
for (int i = 0; i < key.length; ++i) {
if (hBuffer.get(i) != key[i]) {
throw new IOException("Invalid file header"); //$NON-NLS-1$
}
}
// Check the format version
final byte major = hBuffer.get(key.length);
final byte minor = hBuffer.get(key.length + 1);
if (major != GISLayerIOConstants.MAJOR_SPEC_NUMBER || minor != GISLayerIOConstants.MINOR_SPEC_NUMBER) {
throw new IOException("Invalid file format version."); //$NON-NLS-1$
}
// Read the number of objects inside the input stream
final ByteBuffer sBuffer = ByteBuffer.allocate(4);
sBuffer.limit(4);
in.read(sBuffer);
sBuffer.rewind();
this.restToRead = sBuffer.getInt();
} | java | {
"resource": ""
} |
q15287 | ZoomableGraphicsContext.getLevelOfDetails | train | public LevelOfDetails getLevelOfDetails() {
if (this.lod == null) {
final double meterSize = doc2fxSize(1);
if (meterSize <= LOW_DETAILLED_METER_SIZE) {
this.lod = LevelOfDetails.LOW;
} else if (meterSize >= HIGH_DETAILLED_METER_SIZE) {
this.lod = LevelOfDetails.HIGH;
} else {
this.lod = LevelOfDetails.NORMAL;
}
}
return this.lod;
} | java | {
"resource": ""
} |
q15288 | ZoomableGraphicsContext.rgb | train | @SuppressWarnings({ "checkstyle:magicnumber", "static-method" })
@Pure
public Color rgb(int color) {
final int red = (color & 0x00FF0000) >> 16;
final int green = (color & 0x0000FF00) >> 8;
final int blue = color & 0x000000FF;
return Color.rgb(red, green, blue);
} | java | {
"resource": ""
} |
q15289 | ZoomableGraphicsContext.doc2fxX | train | @Pure
public double doc2fxX(double x) {
return this.centeringTransform.toCenterX(x) * this.scale.get() + this.canvasWidth.get() / 2.;
} | java | {
"resource": ""
} |
q15290 | ZoomableGraphicsContext.fx2docX | train | @Pure
public double fx2docX(double x) {
return this.centeringTransform.toGlobalX((x - this.canvasWidth.get() / 2.) / this.scale.get());
} | java | {
"resource": ""
} |
q15291 | ZoomableGraphicsContext.doc2fxY | train | @Pure
public double doc2fxY(double y) {
return this.centeringTransform.toCenterY(y) * this.scale.get() + this.canvasHeight.get() / 2.;
} | java | {
"resource": ""
} |
q15292 | ZoomableGraphicsContext.fx2docY | train | @Pure
public double fx2docY(double y) {
return this.centeringTransform.toGlobalY((y - this.canvasHeight.get() / 2.) / this.scale.get());
} | java | {
"resource": ""
} |
q15293 | ZoomableGraphicsContext.doc2fxAngle | train | @Pure
public double doc2fxAngle(double angle) {
final ZoomableCanvas<?> canvas = getCanvas();
if (canvas.isInvertedAxisX() != canvas.isInvertedAxisY()) {
return -angle;
}
return angle;
} | java | {
"resource": ""
} |
q15294 | ZoomableGraphicsContext.fx2docAngle | train | @Pure
public double fx2docAngle(double angle) {
final ZoomableCanvas<?> canvas = getCanvas();
if (canvas.isInvertedAxisX() != canvas.isInvertedAxisY()) {
return -angle;
}
return angle;
} | java | {
"resource": ""
} |
q15295 | ZoomableGraphicsContext.restore | train | public void restore() {
this.gc.restore();
if (this.stateStack != null) {
if (!this.stateStack.isEmpty()) {
final int[] data = this.stateStack.pop();
if (this.stateStack.isEmpty()) {
this.stateStack = null;
}
this.bugdet = data[0];
this.state = data[1];
} else {
this.stateStack = null;
}
}
} | java | {
"resource": ""
} |
q15296 | ZoomableGraphicsContext.fillRoundRect | train | public void fillRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight) {
this.gc.fillRoundRect(
doc2fxX(x), doc2fxY(y),
doc2fxSize(width), doc2fxSize(height),
doc2fxSize(arcWidth), doc2fxSize(arcHeight));
} | java | {
"resource": ""
} |
q15297 | ZoomableGraphicsContext.strokeLine | train | public void strokeLine(double x1, double y1, double x2, double y2) {
this.gc.strokeLine(
doc2fxX(x1), doc2fxY(y1),
doc2fxX(x2), doc2fxY(y2));
} | java | {
"resource": ""
} |
q15298 | StandardRoadNetwork.createInternalDataStructure | train | @SuppressWarnings({"static-method", "checkstyle:magicnumber"})
protected GISPolylineSet<RoadPolyline> createInternalDataStructure(Rectangle2afp<?, ?, ?, ?, ?, ?> originalBounds) {
/*return new MapPolylineGridSet<>(100, 100,
originalBounds.getMinX(),
originalBounds.getMinY(),
originalBounds.getWidth(),
originalBounds.getHeight());*/
return new MapPolylineTreeSet<>(
originalBounds.getMinX(),
originalBounds.getMinY(),
originalBounds.getWidth(),
originalBounds.getHeight());
} | java | {
"resource": ""
} |
q15299 | StandardRoadNetwork.getInternalTree | train | @SuppressWarnings("unchecked")
@Pure
public Tree<RoadPolyline, ?> getInternalTree() {
if (this.roadSegments instanceof GISTreeSet<?, ?>) {
return ((GISTreeSet<RoadPolyline, ?>) this.roadSegments).getTree();
}
return null;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.