_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q14900 | PhysicsUtil.acceleration | train | @Pure
@Inline(value = "PhysicsUtil.getPhysicsEngine().acceleration(($1), ($2), ($3))",
imported = {PhysicsUtil.class})
public static double acceleration(
double previousSpeed,
double currentSpeed,
double dt) {
return engine.acceleration(previousSpeed, currentSpeed, dt);
} | java | {
"resource": ""
} |
q14901 | ScreenSizeExtensions.computeDialogPositions | train | public static List<Point> computeDialogPositions(final int dialogWidth, final int dialogHeight)
{
List<Point> dialogPosition = null;
final int windowBesides = ScreenSizeExtensions.getScreenWidth() / dialogWidth;
final int windowBelow = ScreenSizeExtensions.getScreenHeight() / dialogHeight;
final int listSize = windowBesides * windowBelow;
dialogPosition = new ArrayList<>(listSize);
int dotWidth = 0;
int dotHeight = 0;
for (int y = 0; y < windowBelow; y++)
{
dotWidth = 0;
for (int x = 0; x < windowBesides; x++)
{
final Point p = new Point(dotWidth, dotHeight);
dialogPosition.add(p);
dotWidth = dotWidth + dialogWidth;
}
dotHeight = dotHeight + dialogHeight;
}
return dialogPosition;
} | java | {
"resource": ""
} |
q14902 | ScreenSizeExtensions.getScreenDevices | train | public static GraphicsDevice[] getScreenDevices()
{
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsDevice[] gs = ge.getScreenDevices();
return gs;
} | java | {
"resource": ""
} |
q14903 | ScreenSizeExtensions.getScreenDimension | train | public static Dimension getScreenDimension(Component component)
{
int screenID = getScreenID(component);
Dimension dimension = new Dimension(0, 0);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration defaultConfiguration = ge.getScreenDevices()[screenID]
.getDefaultConfiguration();
Rectangle rectangle = defaultConfiguration.getBounds();
dimension.setSize(rectangle.getWidth(), rectangle.getHeight());
return dimension;
} | java | {
"resource": ""
} |
q14904 | ScreenSizeExtensions.getScreenID | train | public static int getScreenID(Component component)
{
int screenID;
final AtomicInteger counter = new AtomicInteger(-1);
Stream.of(getScreenDevices()).forEach(graphicsDevice -> {
GraphicsConfiguration gc = graphicsDevice.getDefaultConfiguration();
Rectangle rectangle = gc.getBounds();
if (rectangle.contains(component.getLocation()))
{
try
{
Object object = ReflectionExtensions.getFieldValue(graphicsDevice, "screen");
Integer sid = (Integer)object;
counter.set(sid);
}
catch (NoSuchFieldException | SecurityException | IllegalArgumentException
| IllegalAccessException e)
{
e.printStackTrace();
}
}
});
screenID = counter.get();
return screenID;
} | java | {
"resource": ""
} |
q14905 | Grid.getCellBounds | train | @Pure
public Rectangle2d getCellBounds(int row, int column) {
final double cellWidth = getCellWidth();
final double cellHeight = getCellHeight();
final double x = this.bounds.getMinX() + cellWidth * column;
final double y = this.bounds.getMinY() + cellHeight * row;
return new Rectangle2d(x, y, cellWidth, cellHeight);
} | java | {
"resource": ""
} |
q14906 | Grid.createCellAt | train | public GridCell<P> createCellAt(int row, int column) {
GridCell<P> cell = this.cells[row][column];
if (cell == null) {
cell = new GridCell<>(row, column, getCellBounds(row, column));
this.cells[row][column] = cell;
++this.cellCount;
}
return cell;
} | java | {
"resource": ""
} |
q14907 | Grid.removeCellAt | train | public GridCell<P> removeCellAt(int row, int column) {
final GridCell<P> cell = this.cells[row][column];
if (cell != null) {
this.cells[row][column] = null;
--this.cellCount;
for (final P element : cell) {
removeElement(element);
}
}
return cell;
} | java | {
"resource": ""
} |
q14908 | Grid.addElement | train | public boolean addElement(P element) {
boolean changed = false;
if (element != null) {
final GridCellElement<P> gridElement = new GridCellElement<>(element);
for (final GridCell<P> cell : getGridCellsOn(element.getGeoLocation().toBounds2D(), true)) {
if (cell.addElement(gridElement)) {
changed = true;
}
}
}
if (changed) {
++this.elementCount;
}
return changed;
} | java | {
"resource": ""
} |
q14909 | Grid.removeElement | train | public boolean removeElement(P element) {
boolean changed = false;
if (element != null) {
GridCellElement<P> gridElement;
for (final GridCell<P> cell : getGridCellsOn(element.getGeoLocation().toBounds2D())) {
gridElement = cell.removeElement(element);
if (gridElement != null) {
if (cell.isEmpty()) {
this.cells[cell.row()][cell.column()] = null;
--this.cellCount;
}
for (final GridCell<P> otherCell : gridElement.consumeCells()) {
assert otherCell != cell;
otherCell.removeElement(element);
if (otherCell.isEmpty()) {
this.cells[otherCell.row()][otherCell.column()] = null;
--this.cellCount;
}
}
changed = true;
}
}
}
if (changed) {
--this.elementCount;
}
return changed;
} | java | {
"resource": ""
} |
q14910 | Grid.getColumnFor | train | @Pure
public int getColumnFor(double x) {
final double xx = x - this.bounds.getMinX();
if (xx >= 0.) {
final int idx = (int) (xx / getCellWidth());
assert idx >= 0;
if (idx < getColumnCount()) {
return idx;
}
return getColumnCount() - 1;
}
return 0;
} | java | {
"resource": ""
} |
q14911 | Grid.getRowFor | train | @Pure
public int getRowFor(double y) {
final double yy = y - this.bounds.getMinY();
if (yy >= 0.) {
final int idx = (int) (yy / getCellHeight());
assert idx >= 0;
if (idx < getRowCount()) {
return idx;
}
return getRowCount() - 1;
}
return 0;
} | java | {
"resource": ""
} |
q14912 | Grid.getGridCellsAround | train | @Pure
public AroundCellIterable<P> getGridCellsAround(Point2D<?, ?> position, double maximalDistance) {
final int column = getColumnFor(position.getX());
final int row = getRowFor(position.getY());
return new AroundIterable(row, column, position, maximalDistance);
} | java | {
"resource": ""
} |
q14913 | Grid.iterator | train | @Pure
public Iterator<P> iterator(Rectangle2afp<?, ?, ?, ?, ?, ?> bounds) {
if (this.bounds.intersects(bounds)) {
final int c1 = getColumnFor(bounds.getMinX());
final int r1 = getRowFor(bounds.getMinY());
final int c2 = getColumnFor(bounds.getMaxX());
final int r2 = getRowFor(bounds.getMaxY());
return new BoundedElementIterator(new CellIterator(r1, c1, r2, c2, false), -1, bounds);
}
return Collections.<P>emptyList().iterator();
} | java | {
"resource": ""
} |
q14914 | Grid.getElementAt | train | @Pure
public P getElementAt(int index) {
if (index >= 0) {
int idx = 0;
int eIdx;
for (final GridCell<P> cell : getGridCells()) {
eIdx = idx + cell.getReferenceElementCount();
if (index < eIdx) {
try {
return cell.getElementAt(index - idx);
} catch (IndexOutOfBoundsException exception) {
throw new IndexOutOfBoundsException(Integer.toString(index));
}
}
idx = eIdx;
}
}
throw new IndexOutOfBoundsException(Integer.toString(index));
} | java | {
"resource": ""
} |
q14915 | NioTCPSession.blockingWrite | train | protected final Object blockingWrite(SelectableChannel channel,
WriteMessage message, IoBuffer writeBuffer) throws IOException,
ClosedChannelException {
SelectionKey tmpKey = null;
Selector writeSelector = null;
int attempts = 0;
int bytesProduced = 0;
try {
while (writeBuffer.hasRemaining()) {
long len = doRealWrite(channel, writeBuffer);
if (len > 0) {
attempts = 0;
bytesProduced += len;
statistics.statisticsWrite(len);
} else {
attempts++;
if (writeSelector == null) {
writeSelector = SelectorFactory.getSelector();
if (writeSelector == null) {
// Continue using the main one.
continue;
}
tmpKey = channel.register(writeSelector,
SelectionKey.OP_WRITE);
}
if (writeSelector.select(1000) == 0) {
if (attempts > 2) {
throw new IOException("Client disconnected");
}
}
}
}
if (!writeBuffer.hasRemaining() && message.getWriteFuture() != null) {
message.getWriteFuture().setResult(Boolean.TRUE);
}
} finally {
if (tmpKey != null) {
tmpKey.cancel();
tmpKey = null;
}
if (writeSelector != null) {
// Cancel the key.
writeSelector.selectNow();
SelectorFactory.returnSelector(writeSelector);
}
}
scheduleWritenBytes.addAndGet(0 - bytesProduced);
return message.getMessage();
} | java | {
"resource": ""
} |
q14916 | DssatXFileOutput.setSecDataArr | train | private int setSecDataArr(HashMap m, ArrayList arr, boolean isEvent) {
int idx = setSecDataArr(m, arr);
if (idx != 0 && isEvent && getValueOr(m, "date", "").equals("")) {
return -1;
} else {
return idx;
}
} | java | {
"resource": ""
} |
q14917 | DssatXFileOutput.isPlotInfoExist | train | private boolean isPlotInfoExist(Map expData) {
String[] plotIds = {"plta", "pltr#", "pltln", "pldr", "pltsp", "pllay", "pltha", "plth#", "plthl", "plthm"};
for (String plotId : plotIds) {
if (!getValueOr(expData, plotId, "").equals("")) {
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q14918 | DssatXFileOutput.isSoilAnalysisExist | train | private boolean isSoilAnalysisExist(ArrayList<HashMap> icSubArr) {
for (HashMap icSubData : icSubArr) {
if (!getValueOr(icSubData, "slsc", "").equals("")) {
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q14919 | DssatXFileOutput.getDataList | train | private ArrayList<HashMap> getDataList(Map expData, String blockName, String dataListName) {
HashMap dataBlock = getObjectOr(expData, blockName, new HashMap());
return getObjectOr(dataBlock, dataListName, new ArrayList<HashMap>());
} | java | {
"resource": ""
} |
q14920 | ProvenancedConfusionMatrix.entries | train | public Set<CellFiller> entries() {
return FluentIterable.from(table.cellSet())
.transformAndConcat(CollectionUtils.<List<CellFiller>>TableCellValue())
.toSet();
} | java | {
"resource": ""
} |
q14921 | ProvenancedConfusionMatrix.breakdown | train | public <SignatureType> BrokenDownProvenancedConfusionMatrix<SignatureType, CellFiller>
breakdown(Function<? super CellFiller, SignatureType> signatureFunction,
Ordering<SignatureType> keyOrdering) {
final Map<SignatureType, Builder<CellFiller>> ret = Maps.newHashMap();
// a more efficient implementation should be used if the confusion matrix is
// large and sparse, but this is unlikely. ~ rgabbard
for (final Symbol leftLabel : leftLabels()) {
for (final Symbol rightLabel : rightLabels()) {
for (final CellFiller provenance : cell(leftLabel, rightLabel)) {
final SignatureType signature = signatureFunction.apply(provenance);
checkNotNull(signature, "Provenance function may never return null");
if (!ret.containsKey(signature)) {
ret.put(signature, ProvenancedConfusionMatrix.<CellFiller>builder());
}
ret.get(signature).record(leftLabel, rightLabel, provenance);
}
}
}
final ImmutableMap.Builder<SignatureType, ProvenancedConfusionMatrix<CellFiller>> trueRet =
ImmutableMap.builder();
// to get consistent output, we make sure to sort by the keys
for (final Map.Entry<SignatureType, Builder<CellFiller>> entry :
MapUtils.<SignatureType, Builder<CellFiller>>byKeyOrdering(keyOrdering).sortedCopy(
ret.entrySet())) {
trueRet.put(entry.getKey(), entry.getValue().build());
}
return BrokenDownProvenancedConfusionMatrix.fromMap(trueRet.build());
} | java | {
"resource": ""
} |
q14922 | FileType.getContentType | train | public static String getContentType(String filename) {
final ContentFileTypeMap map = ensureContentTypeManager();
return map.getContentType(filename);
} | java | {
"resource": ""
} |
q14923 | FileType.getFormatVersion | train | public static String getFormatVersion(File filename) {
final ContentFileTypeMap map = ensureContentTypeManager();
return map.getFormatVersion(filename);
} | java | {
"resource": ""
} |
q14924 | FileType.isImage | train | public static boolean isImage(String mime) {
try {
final MimeType type = new MimeType(mime);
return IMAGE.equalsIgnoreCase(type.getPrimaryType());
} catch (MimeTypeParseException e) {
//
}
return false;
} | java | {
"resource": ""
} |
q14925 | FileType.isContentType | train | public static boolean isContentType(URL filename, String desiredMimeType) {
final ContentFileTypeMap map = ensureContentTypeManager();
return map.isContentType(filename, desiredMimeType);
} | java | {
"resource": ""
} |
q14926 | BotmReflectionUtil.getPublicMethod | train | public static Method getPublicMethod(Class<?> clazz, String methodName, Class<?>[] argTypes) {
assertObjectNotNull("clazz", clazz);
assertStringNotNullAndNotTrimmedEmpty("methodName", methodName);
return findMethod(clazz, methodName, argTypes, VisibilityType.PUBLIC, false);
} | java | {
"resource": ""
} |
q14927 | BotmReflectionUtil.invoke | train | public static Object invoke(Method method, Object target, Object[] args) {
assertObjectNotNull("method", method);
try {
return method.invoke(target, args);
} catch (InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}
if (t instanceof Error) {
throw (Error) t;
}
String msg = "The InvocationTargetException occurred: ";
msg = msg + " method=" + method + " target=" + target;
msg = msg + " args=" + (args != null ? Arrays.asList(args) : "");
throw new ReflectionFailureException(msg, t);
} catch (IllegalArgumentException e) {
String msg = "Illegal argument for the method:";
msg = msg + " method=" + method + " target=" + target;
msg = msg + " args=" + (args != null ? Arrays.asList(args) : "");
throw new ReflectionFailureException(msg, e);
} catch (IllegalAccessException e) {
String msg = "Illegal access to the method:";
msg = msg + " method=" + method + " target=" + target;
msg = msg + " args=" + (args != null ? Arrays.asList(args) : "");
throw new ReflectionFailureException(msg, e);
}
} | java | {
"resource": ""
} |
q14928 | BotmReflectionUtil.assertStringNotNullAndNotTrimmedEmpty | train | public static void assertStringNotNullAndNotTrimmedEmpty(String variableName, String value) {
assertObjectNotNull("variableName", variableName);
assertObjectNotNull("value", value);
if (value.trim().length() == 0) {
String msg = "The value should not be empty: variableName=" + variableName + " value=" + value;
throw new IllegalArgumentException(msg);
}
} | java | {
"resource": ""
} |
q14929 | XMLUtils.nextSibling | train | public static Optional<Element> nextSibling(final Element element, final String name) {
for (Node childNode = element.getNextSibling(); childNode != null;
childNode = childNode.getNextSibling()) {
if (childNode instanceof Element && ((Element) childNode).getTagName()
.equalsIgnoreCase(name)) {
return Optional.of((Element) childNode);
}
}
return Optional.absent();
} | java | {
"resource": ""
} |
q14930 | XMLUtils.prettyPrintElementLocally | train | public static String prettyPrintElementLocally(Element e) {
final ImmutableMap.Builder<String, String> ret = ImmutableMap.builder();
final NamedNodeMap attributes = e.getAttributes();
for (int i = 0; i < attributes.getLength(); ++i) {
final Node attr = attributes.item(i);
ret.put(attr.getNodeName(), "\"" + attr.getNodeValue() + "\"");
}
return "<" + e.getNodeName() + " " + Joiner.on(" ").withKeyValueSeparator("=").join(ret.build())
+ "/>";
} | java | {
"resource": ""
} |
q14931 | Point1d.convert | train | public static Point1d convert(Tuple1d<?> tuple) {
if (tuple instanceof Point1d) {
return (Point1d) tuple;
}
return new Point1d(tuple.getSegment(), tuple.getX(), tuple.getY());
} | java | {
"resource": ""
} |
q14932 | GISCoordinates.EL2_WSG84 | train | @Pure
public static GeodesicPosition EL2_WSG84(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_2E_N,
LAMBERT_2E_C,
LAMBERT_2E_XS,
LAMBERT_2E_YS);
return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
} | java | {
"resource": ""
} |
q14933 | GISCoordinates.EL2_L2 | train | @Pure
public static Point2d EL2_L2(double x, double y) {
return new Point2d(x, y + (LAMBERT_2E_YS - LAMBERT_2_YS));
} | java | {
"resource": ""
} |
q14934 | GISCoordinates.EL2_L3 | train | @Pure
public static Point2d EL2_L3(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_2E_N,
LAMBERT_2E_C,
LAMBERT_2E_XS,
LAMBERT_2E_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_3_N,
LAMBERT_3_C,
LAMBERT_3_XS,
LAMBERT_3_YS);
} | java | {
"resource": ""
} |
q14935 | GISCoordinates.L1_WSG84 | train | @Pure
public static GeodesicPosition L1_WSG84(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_1_N,
LAMBERT_1_C,
LAMBERT_1_XS,
LAMBERT_1_YS);
return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
} | java | {
"resource": ""
} |
q14936 | GISCoordinates.L1_EL2 | train | @Pure
public static Point2d L1_EL2(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_1_N,
LAMBERT_1_C,
LAMBERT_1_XS,
LAMBERT_1_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_2E_N,
LAMBERT_2E_C,
LAMBERT_2E_XS,
LAMBERT_2E_YS);
} | java | {
"resource": ""
} |
q14937 | GISCoordinates.L1_L3 | train | @Pure
public static Point2d L1_L3(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_1_N,
LAMBERT_1_C,
LAMBERT_1_XS,
LAMBERT_1_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_3_N,
LAMBERT_3_C,
LAMBERT_3_XS,
LAMBERT_3_YS);
} | java | {
"resource": ""
} |
q14938 | GISCoordinates.L1_L4 | train | @Pure
public static Point2d L1_L4(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_1_N,
LAMBERT_1_C,
LAMBERT_1_XS,
LAMBERT_1_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_4_N,
LAMBERT_4_C,
LAMBERT_4_XS,
LAMBERT_4_YS);
} | java | {
"resource": ""
} |
q14939 | GISCoordinates.L2_WSG84 | train | @Pure
public static GeodesicPosition L2_WSG84(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_2_N,
LAMBERT_2_C,
LAMBERT_2_XS,
LAMBERT_2_YS);
return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
} | java | {
"resource": ""
} |
q14940 | GISCoordinates.L2_EL2 | train | @Pure
public static Point2d L2_EL2(double x, double y) {
return new Point2d(x, y - (LAMBERT_2E_YS - LAMBERT_2_YS));
} | java | {
"resource": ""
} |
q14941 | GISCoordinates.L2_L1 | train | @Pure
public static Point2d L2_L1(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_2_N,
LAMBERT_2_C,
LAMBERT_2_XS,
LAMBERT_2_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_1_N,
LAMBERT_1_C,
LAMBERT_1_XS,
LAMBERT_1_YS);
} | java | {
"resource": ""
} |
q14942 | GISCoordinates.L2_L3 | train | @Pure
public static Point2d L2_L3(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_2_N,
LAMBERT_2_C,
LAMBERT_2_XS,
LAMBERT_2_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_3_N,
LAMBERT_3_C,
LAMBERT_3_XS,
LAMBERT_3_YS);
} | java | {
"resource": ""
} |
q14943 | GISCoordinates.L2_L4 | train | @Pure
public static Point2d L2_L4(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_2_N,
LAMBERT_2_C,
LAMBERT_2_XS,
LAMBERT_2_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_4_N,
LAMBERT_4_C,
LAMBERT_4_XS,
LAMBERT_4_YS);
} | java | {
"resource": ""
} |
q14944 | GISCoordinates.L2_L93 | train | @Pure
public static Point2d L2_L93(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_2_N,
LAMBERT_2_C,
LAMBERT_2_XS,
LAMBERT_2_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_93_N,
LAMBERT_93_C,
LAMBERT_93_XS,
LAMBERT_93_YS);
} | java | {
"resource": ""
} |
q14945 | GISCoordinates.L3_WSG84 | train | @Pure
public static GeodesicPosition L3_WSG84(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_3_N,
LAMBERT_3_C,
LAMBERT_3_XS,
LAMBERT_3_YS);
return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
} | java | {
"resource": ""
} |
q14946 | GISCoordinates.L3_L4 | train | @Pure
public static Point2d L3_L4(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_3_N,
LAMBERT_3_C,
LAMBERT_3_XS,
LAMBERT_3_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_4_N,
LAMBERT_4_C,
LAMBERT_4_XS,
LAMBERT_4_YS);
} | java | {
"resource": ""
} |
q14947 | GISCoordinates.L3_L93 | train | @Pure
public static Point2d L3_L93(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_3_N,
LAMBERT_3_C,
LAMBERT_3_XS,
LAMBERT_3_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_93_N,
LAMBERT_93_C,
LAMBERT_93_XS,
LAMBERT_93_YS);
} | java | {
"resource": ""
} |
q14948 | GISCoordinates.L4_WSG84 | train | @Pure
public static GeodesicPosition L4_WSG84(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_4_N,
LAMBERT_4_C,
LAMBERT_4_XS,
LAMBERT_4_YS);
return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
} | java | {
"resource": ""
} |
q14949 | GISCoordinates.L4_EL2 | train | @Pure
public static Point2d L4_EL2(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_4_N,
LAMBERT_4_C,
LAMBERT_4_XS,
LAMBERT_4_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_2E_N,
LAMBERT_2E_C,
LAMBERT_2E_XS,
LAMBERT_2E_YS);
} | java | {
"resource": ""
} |
q14950 | GISCoordinates.L93_WSG84 | train | @Pure
public static GeodesicPosition L93_WSG84(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_93_N,
LAMBERT_93_C,
LAMBERT_93_XS,
LAMBERT_93_YS);
return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
} | java | {
"resource": ""
} |
q14951 | GISCoordinates.L93_EL2 | train | @Pure
public static Point2d L93_EL2(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_93_N,
LAMBERT_93_C,
LAMBERT_93_XS,
LAMBERT_93_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_2E_N,
LAMBERT_2E_C,
LAMBERT_2E_XS,
LAMBERT_2E_YS);
} | java | {
"resource": ""
} |
q14952 | GISCoordinates.L93_L1 | train | @Pure
public static Point2d L93_L1(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_93_N,
LAMBERT_93_C,
LAMBERT_93_XS,
LAMBERT_93_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_1_N,
LAMBERT_1_C,
LAMBERT_1_XS,
LAMBERT_1_YS);
} | java | {
"resource": ""
} |
q14953 | GISCoordinates.L93_L4 | train | @Pure
public static Point2d L93_L4(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_93_N,
LAMBERT_93_C,
LAMBERT_93_XS,
LAMBERT_93_YS);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_4_N,
LAMBERT_4_C,
LAMBERT_4_XS,
LAMBERT_4_YS);
} | java | {
"resource": ""
} |
q14954 | GISCoordinates.NTFLambert_NTFLambdaPhi | train | @SuppressWarnings({"checkstyle:parametername", "checkstyle:localfinalvariablename"})
private static Point2d NTFLambert_NTFLambdaPhi(double x, double y, double n, double c, double Xs, double Ys) {
// Several constants from the IGN specifications
//Longitude in radians of Paris (2°20'14.025" E) from Greenwich
final double lambda_0 = 0.;
// Extended Lambert II (x,y) -> graphical coordinate NTF (lambda_ntf,phi_ntf)
// ALG0004
final double R = Math.hypot(x - Xs, y - Ys);
final double g = Math.atan((x - Xs) / (Ys - y));
final double lamdda_ntf = lambda_0 + (g / n);
final double L = -(1 / n) * Math.log(Math.abs(R / c));
final double phi0 = 2 * Math.atan(Math.exp(L)) - (Math.PI / 2.0);
double phiprec = phi0;
double phii = compute1(phiprec, L);
while (Math.abs(phii - phiprec) >= EPSILON) {
phiprec = phii;
phii = compute1(phiprec, L);
}
final double phi_ntf = phii;
return new Point2d(lamdda_ntf, phi_ntf);
} | java | {
"resource": ""
} |
q14955 | GISCoordinates.NTFLambdaPhi_WSG84 | train | @SuppressWarnings({"checkstyle:magicnumber", "checkstyle:localfinalvariablename", "checkstyle:localvariablename"})
private static GeodesicPosition NTFLambdaPhi_WSG84(double lambda_ntf, double phi_ntf) {
// Geographical coordinate NTF (lamda_ntf,phi_ntf)
// -> Cartesian coordinate NTF (x_ntf,y_ntf,z_ntf)
// ALG0009
double a = 6378249.2;
// 100 meters
final double h = 100;
final double N = a / Math.pow(1. - (NTF_E * NTF_E) * (Math.sin(phi_ntf) * Math.sin(phi_ntf)), .5);
final double x_ntf = (N + h) * Math.cos(phi_ntf) * Math.cos(lambda_ntf);
final double y_ntf = (N + h) * Math.cos(phi_ntf) * Math.sin(lambda_ntf);
final double z_ntf = ((N * (1. - (NTF_E * NTF_E))) + h) * Math.sin(phi_ntf);
// Cartesian coordinate NTF (x_ntf,y_ntf,z_ntf)
// -> Cartesian coordinate WGS84 (x_w,y_w,z_w)
// ALG0013
// This is a simple translation.
final double x_w = x_ntf - 168.;
final double y_w = y_ntf - 60.;
final double z_w = z_ntf + 320;
// Cartesian coordinate WGS84 (x_w,y_w,z_w)
// -> Geographic coordinate WGS84 (lamda_w,phi_w)
// ALG0012
// 0.04079234433 to use the Greenwich meridian, 0 else
final double l840 = 0.04079234433;
a = 6378137.0;
final double P = Math.hypot(x_w, y_w);
double lambda_w = l840 + Math.atan(y_w / x_w);
double phi0_w = Math.atan(z_w / (P * (1 - ((a * WSG84_E * WSG84_E))
/ Math.sqrt((x_w * x_w) + (y_w * y_w) + (z_w * z_w)))));
double phi_w = Math.atan((z_w / P) / (1 - ((a * WSG84_E * WSG84_E * Math.cos(phi0_w))
/ (P * Math.sqrt(1 - NTF_E * NTF_E * (Math.sin(phi0_w) * Math.sin(phi0_w)))))));
while (Math.abs(phi_w - phi0_w) >= EPSILON) {
phi0_w = phi_w;
phi_w = Math.atan((z_w / P) / (1 - ((a * WSG84_E * WSG84_E * Math.cos(phi0_w))
/ (P * Math.sqrt(1 - ((WSG84_E * WSG84_E) * (Math.sin(phi0_w) * Math.sin(phi0_w))))))));
}
// Convert radians to degrees.
lambda_w = Math.toDegrees(lambda_w);
phi_w = Math.toDegrees(phi_w);
return new GeodesicPosition(lambda_w, phi_w);
} | java | {
"resource": ""
} |
q14956 | GISCoordinates.WSG84_EL2 | train | @Pure
public static Point2d WSG84_EL2(double lambda, double phi) {
final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi(lambda, phi);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_2E_N,
LAMBERT_2E_C,
LAMBERT_2E_XS,
LAMBERT_2E_YS);
} | java | {
"resource": ""
} |
q14957 | GISCoordinates.WSG84_L1 | train | @Pure
public static Point2d WSG84_L1(double lambda, double phi) {
final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi(lambda, phi);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_1_N,
LAMBERT_1_C,
LAMBERT_1_XS,
LAMBERT_1_YS);
} | java | {
"resource": ""
} |
q14958 | GISCoordinates.WSG84_L2 | train | @Pure
public static Point2d WSG84_L2(double lambda, double phi) {
final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi(lambda, phi);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_2_N,
LAMBERT_2_C,
LAMBERT_2_XS,
LAMBERT_2_YS);
} | java | {
"resource": ""
} |
q14959 | GISCoordinates.WSG84_L3 | train | @Pure
public static Point2d WSG84_L3(double lambda, double phi) {
final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi(lambda, phi);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_3_N,
LAMBERT_3_C,
LAMBERT_3_XS,
LAMBERT_3_YS);
} | java | {
"resource": ""
} |
q14960 | GISCoordinates.WSG84_L4 | train | public static Point2d WSG84_L4(double lambda, double phi) {
final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi(lambda, phi);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_4_N,
LAMBERT_4_C,
LAMBERT_4_XS,
LAMBERT_4_YS);
} | java | {
"resource": ""
} |
q14961 | GISCoordinates.WSG84_L93 | train | @Pure
public static Point2d WSG84_L93(double lambda, double phi) {
final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi(lambda, phi);
return NTFLambdaPhi_NTFLambert(
ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
LAMBERT_93_N,
LAMBERT_93_C,
LAMBERT_93_XS,
LAMBERT_93_YS);
} | java | {
"resource": ""
} |
q14962 | GISCoordinates.NTFLambdaPhi_NTFLambert | train | @SuppressWarnings({"checkstyle:parametername", "checkstyle:magicnumber",
"checkstyle:localfinalvariablename", "checkstyle:localvariablename"})
private static Point2d NTFLambdaPhi_NTFLambert(double lambda, double phi, double n, double c, double Xs, double Ys) {
//---------------------------------------------------------
// 3) cartesian coordinate NTF (X_n,Y_n,Z_n)
// -> geographical coordinate NTF (phi_n,lambda_n)
// One formula is given by the IGN, and two constants about
// the ellipsoide are from the NTF system specification of Clarke 1880.
// Ref:
// http://www.ign.fr/telechargement/MPro/geodesie/CIRCE/NTG_80.pdf
// http://support.esrifrance.fr/Documents/Generalites/Projections/Generalites/Generalites.htm#2
final double a_n = 6378249.2;
final double b_n = 6356515.0;
// then
final double e2_n = (a_n * a_n - b_n * b_n) / (a_n * a_n);
//---------------------------------------------------------
// 4) Geographical coordinate NTF (phi_n,lambda_n)
// -> Extended Lambert II coordinate (X_l2e, Y_l2e)
// Formula are given by the IGN from another specification
// Ref:
// http://www.ign.fr/telechargement/MPro/geodesie/CIRCE/NTG_71.pdf
final double e_n = Math.sqrt(e2_n);
// Let the longitude in radians of Paris (2°20'14.025" E) from the Greenwich meridian
final double lambda0 = 0.04079234433198;
// Compute the isometric latitude
final double L = Math.log(Math.tan(Math.PI / 4. + phi / 2.)
* Math.pow((1. - e_n * Math.sin(phi)) / (1. + e_n * Math.sin(phi)),
e_n / 2.));
// Then do the projection according to extended Lambert II
final double X_l2e = Xs + c * Math.exp(-n * L) * Math.sin(n * (lambda - lambda0));
final double Y_l2e = Ys - c * Math.exp(-n * L) * Math.cos(n * (lambda - lambda0));
return new Point2d(X_l2e, Y_l2e);
} | java | {
"resource": ""
} |
q14963 | GISCoordinates.WSG84_NTFLamdaPhi | train | @SuppressWarnings({"checkstyle:parametername", "checkstyle:magicnumber",
"checkstyle:localfinalvariablename", "checkstyle:localvariablename"})
private static Point2d WSG84_NTFLamdaPhi(double lambda, double phi) {
//---------------------------------------------------------
// 0) degree -> radian
final double lambda_w = Math.toRadians(lambda);
final double phi_w = Math.toRadians(phi);
//---------------------------------------------------------
// 1) geographical coordinates WGS84 (phi_w,lambda_w)
// -> cartesian coordinate WGS84 (x_w,y_w,z_w)
// Formula from IGN are used from the official downloadable document, and
// the two constants, one for each demi-axis, are given by the WGS84 specification
// of the ellipsoide.
// Ref:
// http://www.ign.fr/telechargement/MPro/geodesie/CIRCE/NTG_80.pdf
// http://de.wikipedia.org/wiki/WGS84
final double a_w = 6378137.0;
final double b_w = 6356752.314;
// then
final double e2_w = (a_w * a_w - b_w * b_w) / (a_w * a_w);
// then let the big normal of the WGS84 ellipsoide
final double N = a_w / Math.sqrt(1. - e2_w * Math.pow(Math.sin(phi_w), 2.));
// let the WGS84 cartesian coordinates:
final double X_w = N * Math.cos(phi_w) * Math.cos(lambda_w);
final double Y_w = N * Math.cos(phi_w) * Math.sin(lambda_w);
final double Z_w = N * (1 - e2_w) * Math.sin(phi_w);
//---------------------------------------------------------
// 2) cartesian coordinate WGS84 (X_w,Y_w,Z_w)
// -> cartesian coordinate NTF (X_n,Y_n,Z_n)
// Ref: http://support.esrifrance.fr/Documents/Generalites/Projections/Generalites/Generalites.htm#2
// No convertion to be done.
final double dX = 168.0;
final double dY = 60.0;
final double dZ = -320.0;
final double X_n = X_w + dX;
final double Y_n = Y_w + dY;
final double Z_n = Z_w + dZ;
//---------------------------------------------------------
// 3) cartesian coordinate NTF (X_n,Y_n,Z_n)
// -> geographical coordinate NTF (phi_n,lambda_n)
// One formula is given by the IGN, and two constants about
// the ellipsoide are from the NTF system specification of Clarke 1880.
// Ref:
// http://www.ign.fr/telechargement/MPro/geodesie/CIRCE/NTG_80.pdf
// http://support.esrifrance.fr/Documents/Generalites/Projections/Generalites/Generalites.htm#2
final double a_n = 6378249.2;
final double b_n = 6356515.0;
// then
final double e2_n = (a_n * a_n - b_n * b_n) / (a_n * a_n);
// let the convergence epsilon
final double epsilon = 1e-10;
// Then try to converge
double p0 = Math.atan(Z_n / Math.sqrt(X_n * X_n + Y_n * Y_n) * (1 - (a_n * e2_n) / (Math.sqrt(X_n * X_n + Y_n
* Y_n + Z_n * Z_n))));
double p1 = Math.atan((Z_n / Math.sqrt(X_n * X_n + Y_n * Y_n)) / (1 - (a_n * e2_n
* Math.cos(p0)) / (Math.sqrt((X_n * X_n + Y_n * Y_n) * (1 - e2_n * Math.pow(Math.sin(p0), 2))))));
while (Math.abs(p1 - p0) >= epsilon) {
p0 = p1;
p1 = Math.atan((Z_n / Math.sqrt(X_n * X_n + Y_n * Y_n)) / (1 - (a_n * e2_n * Math.cos(p0))
/ (Math.sqrt((X_n * X_n + Y_n * Y_n) * (1 - e2_n * Math.pow(Math.sin(p0), 2))))));
}
final double phi_n = p1;
final double lambda_n = Math.atan(Y_n / X_n);
return new Point2d(lambda_n, phi_n);
} | java | {
"resource": ""
} |
q14964 | Tuple1dfx.segmentProperty | train | @Pure
public ObjectProperty<WeakReference<Segment1D<?, ?>>> segmentProperty() {
if (this.segment == null) {
this.segment = new SimpleObjectProperty<>(this, MathFXAttributeNames.SEGMENT);
}
return this.segment;
} | java | {
"resource": ""
} |
q14965 | Tuple1dfx.set | train | void set(ObjectProperty<WeakReference<Segment1D<?, ?>>> segment, DoubleProperty x, DoubleProperty y) {
this.segment = segment;
this.x = x;
this.y = y;
} | java | {
"resource": ""
} |
q14966 | AbstractSegment3F.intersectsSegmentCapsule | train | @Pure
public static boolean intersectsSegmentCapsule(
double sx1, double sy1, double sz1, double sx2, double sy2, double sz2,
double mx1, double my1, double mz1, double mx2, double my2, double mz2, double radius) {
double d = distanceSquaredSegmentSegment(
sx1, sy1, sz1, sx2, sy2, sz2,
mx1, my1, mz1, mx2, my2, mz2);
return d < (radius * radius);
} | java | {
"resource": ""
} |
q14967 | AbstractSegment3F.intersectsLineLine | train | @Pure
public static boolean intersectsLineLine(
double x1, double y1, double z1,
double x2, double y2, double z2,
double x3, double y3, double z3,
double x4, double y4, double z4) {
double s = computeLineLineIntersectionFactor(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
return !Double.isNaN(s);
} | java | {
"resource": ""
} |
q14968 | AbstractSegment3F.distanceSquaredSegmentPoint | train | @Pure
public static double distanceSquaredSegmentPoint(
double sx1, double sy1, double sz1, double sx2, double sy2, double sz2,
double px, double py, double pz) {
double ratio = getPointProjectionFactorOnSegmentLine(px, py, pz, sx1, sy1, sz1, sx2, sy2, sz2);
if (ratio <= 0.)
return FunctionalPoint3D.distanceSquaredPointPoint(px, py, pz, sx1, sy1, sz1);
if (ratio >= 1.)
return FunctionalPoint3D.distanceSquaredPointPoint(px, py, pz, sx2, sy2, sz2);
return FunctionalPoint3D.distanceSquaredPointPoint(
px, py, pz,
(1. - ratio) * sx1 + ratio * sx2,
(1. - ratio) * sy1 + ratio * sy2,
(1. - ratio) * sz1 + ratio * sz2);
} | java | {
"resource": ""
} |
q14969 | AbstractSegment3F.distanceSegmentPoint | train | @Pure
public static double distanceSegmentPoint(
double sx1, double sy1, double sz1, double sx2, double sy2, double sz2,
double px, double py, double pz) {
double ratio = getPointProjectionFactorOnSegmentLine(px, py, pz, sx1, sy1, sz1, sx2, sy2, sz2);
if (ratio <= 0.)
return FunctionalPoint3D.distancePointPoint(px, py, pz, sx1, sy1, sz1);
if (ratio >= 1.)
return FunctionalPoint3D.distancePointPoint(px, py, pz, sx2, sy2, sz2);
return FunctionalPoint3D.distancePointPoint(
px, py, pz,
(1. - ratio) * sx1 + ratio * sx2,
(1. - ratio) * sy1 + ratio * sy2,
(1. - ratio) * sz1 + ratio * sz2);
} | java | {
"resource": ""
} |
q14970 | AbstractSegment3F.getPointProjectionFactorOnSegmentLine | train | @Pure
public static double getPointProjectionFactorOnSegmentLine(
double px, double py, double pz,
double s1x, double s1y, double s1z,
double s2x, double s2y, double s2z) {
double dx = s2x - s1x;
double dy = s2y - s1y;
double dz = s2z - s1z;
if (dx == 0. && dy == 0. && dz == 0.)
return 0.;
return ((px - s1x) * dx + (py - s1y) * dy + (pz - s1z) * dz) / (dx * dx + dy * dy + dz * dz);
} | java | {
"resource": ""
} |
q14971 | AbstractSegment3F.distanceSegmentSegment | train | @Pure
public static double distanceSegmentSegment(
double ax1, double ay1, double az1, double ax2, double ay2, double az2,
double bx1, double by1, double bz1, double bx2, double by2, double bz2) {
return Math.sqrt(distanceSquaredSegmentSegment(
ax1, ay1, az1, ax2, ay2, az2,
bx1, by1, bz1, bx2, by2, bz2));
} | java | {
"resource": ""
} |
q14972 | AbstractSegment3F.distanceSquaredSegmentSegment | train | @Pure
public static double distanceSquaredSegmentSegment(
double ax1, double ay1, double az1, double ax2, double ay2, double az2,
double bx1, double by1, double bz1, double bx2, double by2, double bz2) {
Vector3f u = new Vector3f(ax2 - ax1, ay2 - ay1, az2 - az1);
Vector3f v = new Vector3f(bx2 - bx1, by2 - by1, bz2 - bz1);
Vector3f w = new Vector3f(ax1 - bx1, ay1 - by1, az1 - bz1);
double a = u.dot(u);
double b = u.dot(v);
double c = v.dot(v);
double d = u.dot(w);
double e = v.dot(w);
double D = a * c - b * b;
double sc, sN, tc, tN;
double sD = D;
double tD = D;
// compute the line parameters of the two closest points
if (MathUtil.isEpsilonZero(D)) {
// the lines are almost parallel
// force using point P0 on segment S1
// to prevent possible division by 0.0 later
sN = 0.;
sD = 1.;
tN = e;
tD = c;
}
else {
// get the closest points on the infinite lines
sN = b*e - c*d;
tN = a*e - b*d;
if (sN < 0.) {
// sc < 0 => the s=0 edge is visible
sN = 0.;
tN = e;
tD = c;
} else if (sN > sD) {
// sc > 1 => the s=1 edge is visible
sN = sD;
tN = e + b;
tD = c;
}
}
if (tN < 0.) {
// tc < 0 => the t=0 edge is visible
tN = 0.;
// recompute sc for this edge
if (-d < 0.)
sN = 0.;
else if (-d > a)
sN = sD;
else {
sN = -d;
sD = a;
}
}
else if (tN > tD) {
// tc > 1 => the t=1 edge is visible
tN = tD;
// recompute sc for this edge
if ((-d + b) < 0.)
sN = 0;
else if ((-d + b) > a)
sN = sD;
else {
sN = (-d + b);
sD = a;
}
}
// finally do the division to get sc and tc
sc = (MathUtil.isEpsilonZero(sN) ? 0. : sN / sD);
tc = (MathUtil.isEpsilonZero(tN) ? 0. : tN / tD);
// get the difference of the two closest points
// = S1(sc) - S2(tc)
// reuse u, v, w
u.scale(sc);
w.add(u);
v.scale(tc);
w.sub(v);
return w.lengthSquared();
} | java | {
"resource": ""
} |
q14973 | AbstractSegment3F.distanceSegment | train | @Pure
public double distanceSegment(Point3D point) {
return distanceSegmentPoint(
getX1(), getY1(), getZ1(),
getX2(), getY2(), getZ2(),
point.getX(), point.getY(), point.getZ());
} | java | {
"resource": ""
} |
q14974 | AbstractSegment3F.distanceLine | train | @Pure
public double distanceLine(Point3D point) {
return distanceLinePoint(
getX1(), getY1(), getZ1(),
getX2(), getY2(), getZ2(),
point.getX(), point.getY(), point.getZ());
} | java | {
"resource": ""
} |
q14975 | AbstractSegment3F.distanceSquaredSegment | train | @Pure
public double distanceSquaredSegment(Point3D point) {
return distanceSquaredSegmentPoint(
getX1(), getY1(), getZ1(),
getX2(), getY2(), getZ2(),
point.getX(), point.getY(), point.getZ());
} | java | {
"resource": ""
} |
q14976 | AbstractSegment3F.distanceSquaredLine | train | @Pure
public double distanceSquaredLine(Point3D point) {
return distanceSquaredLinePoint(
getX1(), getY1(), getZ1(),
getX2(), getY2(), getZ2(),
point.getX(), point.getY(), point.getZ());
} | java | {
"resource": ""
} |
q14977 | BusNetworkLayer.onBusLineAdded | train | protected boolean onBusLineAdded(BusLine line, int index) {
if (this.autoUpdate.get()) {
try {
addMapLayer(index, new BusLineLayer(line, isLayerAutoUpdated()));
return true;
} catch (Throwable exception) {
//
}
}
return false;
} | java | {
"resource": ""
} |
q14978 | BusNetworkLayer.onBusLineRemoved | train | protected boolean onBusLineRemoved(BusLine line, int index) {
if (this.autoUpdate.get()) {
try {
removeMapLayerAt(index);
return true;
} catch (Throwable exception) {
//
}
}
return false;
} | java | {
"resource": ""
} |
q14979 | KeyValueSources.fromFileMap | train | @Nonnull
public static ImmutableKeyValueSource<Symbol, ByteSource> fromFileMap(
final Map<Symbol, File> fileMap) {
return new FileMapKeyToByteSource(fileMap);
} | java | {
"resource": ""
} |
q14980 | KeyValueSources.fromPalDB | train | @Nonnull
public static ImmutableKeyValueSource<Symbol, ByteSource> fromPalDB(final File dbFile)
throws IOException {
return PalDBKeyValueSource.fromFile(dbFile);
} | java | {
"resource": ""
} |
q14981 | JTreePanel.newTree | train | protected JTree newTree()
{
JTree tree = new JTree();
tree.setModel(newTreeModel(getModel()));
tree.setEditable(true);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addMouseListener(new MouseAdapter()
{
@Override
public void mousePressed(MouseEvent e)
{
int selRow = tree.getRowForLocation(e.getX(), e.getY());
if (selRow != -1)
{
if (e.getClickCount() == 1)
{
onSingleClick(e);
}
else if (e.getClickCount() == 2)
{
onDoubleClick(e);
}
}
}
});
return tree;
} | java | {
"resource": ""
} |
q14982 | Path3f.add | train | public void add(Iterator<AbstractPathElement3F> iterator) {
AbstractPathElement3F element;
while (iterator.hasNext()) {
element = iterator.next();
switch(element.type) {
case MOVE_TO:
moveTo(element.getToX(), element.getToY(), element.getToZ());
break;
case LINE_TO:
lineTo(element.getToX(), element.getToY(), element.getToZ());
break;
case QUAD_TO:
quadTo(element.getCtrlX1(), element.getCtrlY1(), element.getCtrlZ1(), element.getToX(), element.getToY(), element.getToZ());
break;
case CURVE_TO:
curveTo(element.getCtrlX1(), element.getCtrlY1(), element.getCtrlZ1(), element.getCtrlX2(), element.getCtrlY2(), element.getCtrlZ2(), element.getToX(), element.getToY(), element.getToZ());
break;
case CLOSE:
closePath();
break;
default:
}
}
} | java | {
"resource": ""
} |
q14983 | Path3f.length | train | public double length() {
if (this.isEmpty()) return 0;
double length = 0;
PathIterator3f pi = getPathIterator(MathConstants.SPLINE_APPROXIMATION_RATIO);
AbstractPathElement3F pathElement = pi.next();
if (pathElement.type != PathElementType.MOVE_TO) {
throw new IllegalArgumentException("missing initial moveto in path definition");
}
Path3f subPath;
double curx, cury, curz, movx, movy, movz, endx, endy, endz;
curx = movx = pathElement.getToX();
cury = movy = pathElement.getToY();
curz = movz = pathElement.getToZ();
while (pi.hasNext()) {
pathElement = pi.next();
switch (pathElement.type) {
case MOVE_TO:
movx = curx = pathElement.getToX();
movy = cury = pathElement.getToY();
movz = curz = pathElement.getToZ();
break;
case LINE_TO:
endx = pathElement.getToX();
endy = pathElement.getToY();
endz = pathElement.getToZ();
length += FunctionalPoint3D.distancePointPoint(
curx, cury, curz,
endx, endy, endz);
curx = endx;
cury = endy;
curz = endz;
break;
case QUAD_TO:
endx = pathElement.getToX();
endy = pathElement.getToY();
endz = pathElement.getToZ();
subPath = new Path3f();
subPath.moveTo(curx, cury, curz);
subPath.quadTo(
pathElement.getCtrlX1(), pathElement.getCtrlY1(), pathElement.getCtrlZ1(),
endx, endy, endz);
length += subPath.length();
curx = endx;
cury = endy;
curz = endz;
break;
case CURVE_TO:
endx = pathElement.getToX();
endy = pathElement.getToY();
endz = pathElement.getToZ();
subPath = new Path3f();
subPath.moveTo(curx, cury, curz);
subPath.curveTo(
pathElement.getCtrlX1(), pathElement.getCtrlY1(), pathElement.getCtrlZ1(),
pathElement.getCtrlX2(), pathElement.getCtrlY2(), pathElement.getCtrlZ2(),
endx, endy, endz);
length += subPath.length();
curx = endx;
cury = endy;
curz = endz;
break;
case CLOSE:
if (curx != movx || cury != movy || curz != movz) {
length += FunctionalPoint3D.distancePointPoint(
curx, cury, curz,
movx, movy, movz);
}
curx = movx;
cury = movy;
cury = movz;
break;
default:
}
}
return length;
} | java | {
"resource": ""
} |
q14984 | EREtoEDT.lightEREOffsetToEDTOffset | train | private ImmutableMap<Integer, Integer> lightEREOffsetToEDTOffset(String document) {
final ImmutableMap.Builder<Integer, Integer> offsetMap = ImmutableMap.builder();
int EDT = 0;
// lightERE treats these as one, not two (as an XML parser would)
document = document.replaceAll("\\r\\n", "\n");
for (int i = 0; i < document.length(); i++) {
final String c = document.substring(i, i + 1);
// skip <tags>
if (c.equals("<")) {
i = document.indexOf('>', i);
continue;
}
offsetMap.put(i, EDT);
EDT++;
}
return offsetMap.build();
} | java | {
"resource": ""
} |
q14985 | IntegerArrayFilter.validate | train | protected boolean validate(String text)
{
try
{
String[] strings = text.split(",");
for (int i = 0; i < strings.length; i++)
{
Integer.parseInt(strings[i].trim());
}
return true;
}
catch (NumberFormatException e)
{
return false;
}
} | java | {
"resource": ""
} |
q14986 | EquivalenceBasedProvenancedAlignment.getAlignedTo | train | private Collection<EqClassT> getAlignedTo(final Object item) {
if (rightEquivalenceClassesToProvenances.containsKey(item)
&& leftEquivalenceClassesToProvenances.containsKey(item)) {
return ImmutableList.of((EqClassT) item);
} else {
return ImmutableList.of();
}
} | java | {
"resource": ""
} |
q14987 | ListenerCollection.add | train | public synchronized <T extends EventListener> void add(Class<T> type, T listener) {
assert listener != null;
if (this.listeners == NULL) {
// if this is the first listener added,
// initialize the lists
this.listeners = new Object[] {type, listener};
} else {
// Otherwise copy the array and add the new listener
final int i = this.listeners.length;
final Object[] tmp = new Object[i + 2];
System.arraycopy(this.listeners, 0, tmp, 0, i);
tmp[i] = type;
tmp[i + 1] = listener;
this.listeners = tmp;
}
} | java | {
"resource": ""
} |
q14988 | ListenerCollection.remove | train | public synchronized <T extends EventListener> void remove(Class<T> type, T listener) {
assert listener != null;
// Is l on the list?
int index = -1;
for (int i = this.listeners.length - 2; i >= 0; i -= 2) {
if ((this.listeners[i] == type) && (this.listeners[i + 1].equals(listener))) {
index = i;
break;
}
}
// If so, remove it
if (index != -1) {
final Object[] tmp = new Object[this.listeners.length - 2];
// Copy the list up to index
System.arraycopy(this.listeners, 0, tmp, 0, index);
// Copy from two past the index, up to
// the end of tmp (which is two elements
// shorter than the old list)
if (index < tmp.length) {
System.arraycopy(this.listeners, index + 2, tmp, index,
tmp.length - index);
}
// set the listener array to the new array or null
this.listeners = (tmp.length == 0) ? NULL : tmp;
}
} | java | {
"resource": ""
} |
q14989 | ListenerCollection.writeObject | train | private void writeObject(ObjectOutputStream stream) throws IOException {
final Object[] lList = this.listeners;
stream.defaultWriteObject();
// Save the non-null event listeners:
for (int i = 0; i < lList.length; i += 2) {
final Class<?> t = (Class<?>) lList[i];
final EventListener l = (EventListener) lList[i + 1];
if ((l != null) && (l instanceof Serializable)) {
stream.writeObject(t.getName());
stream.writeObject(l);
}
}
stream.writeObject(null);
} | java | {
"resource": ""
} |
q14990 | MathFunctionRange.createDiscreteSet | train | @Pure
public static MathFunctionRange[] createDiscreteSet(double... values) {
final MathFunctionRange[] bounds = new MathFunctionRange[values.length];
for (int i = 0; i < values.length; ++i) {
bounds[i] = new MathFunctionRange(values[i]);
}
return bounds;
} | java | {
"resource": ""
} |
q14991 | MathFunctionRange.createSet | train | @Pure
public static MathFunctionRange[] createSet(double... values) {
final MathFunctionRange[] bounds = new MathFunctionRange[values.length / 2];
for (int i = 0, j = 0; i < values.length; i += 2, ++j) {
bounds[j] = new MathFunctionRange(values[i], values[i + 1]);
}
return bounds;
} | java | {
"resource": ""
} |
q14992 | HttpCore.interceptToProgressResponse | train | public Interceptor interceptToProgressResponse() {
return new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Response response = chain.proceed(chain.request());
ResponseBody body = new ForwardResponseBody(response.body());
return response.newBuilder()
.body(body)
.build();
}
};
} | java | {
"resource": ""
} |
q14993 | RoadPolyline.setStartPoint | train | void setStartPoint(StandardRoadConnection desiredConnection) {
final StandardRoadConnection oldPoint = getBeginPoint(StandardRoadConnection.class);
if (oldPoint != null) {
oldPoint.removeConnectedSegment(this, true);
}
this.firstConnection = desiredConnection;
if (desiredConnection != null) {
final Point2d pts = desiredConnection.getPoint();
if (pts != null) {
setPointAt(0, pts, true);
}
desiredConnection.addConnectedSegment(this, true);
}
} | java | {
"resource": ""
} |
q14994 | RoadPolyline.setEndPoint | train | void setEndPoint(StandardRoadConnection desiredConnection) {
final StandardRoadConnection oldPoint = getEndPoint(StandardRoadConnection.class);
if (oldPoint != null) {
oldPoint.removeConnectedSegment(this, false);
}
this.lastConnection = desiredConnection;
if (desiredConnection != null) {
final Point2d pts = desiredConnection.getPoint();
if (pts != null) {
setPointAt(-1, pts, true);
}
desiredConnection.addConnectedSegment(this, false);
}
} | java | {
"resource": ""
} |
q14995 | PartitionData.filterMapToKeysPreservingOrder | train | private static <K, V> ImmutableMap<K, V> filterMapToKeysPreservingOrder(
final ImmutableMap<? extends K, ? extends V> map, Iterable<? extends K> keys) {
final ImmutableMap.Builder<K, V> ret = ImmutableMap.builder();
for (final K key : keys) {
final V value = map.get(key);
checkArgument(value != null, "Key " + key + " not in map");
ret.put(key, value);
}
return ret.build();
} | java | {
"resource": ""
} |
q14996 | AwtExtensions.getRootJDialog | train | public static Component getRootJDialog(Component component)
{
while (null != component.getParent())
{
component = component.getParent();
if (component instanceof JDialog)
{
break;
}
}
return component;
} | java | {
"resource": ""
} |
q14997 | AwtExtensions.getRootJFrame | train | public static Component getRootJFrame(Component component)
{
while (null != component.getParent())
{
component = component.getParent();
if (component instanceof JFrame)
{
break;
}
}
return component;
} | java | {
"resource": ""
} |
q14998 | AwtExtensions.getRootParent | train | public static Component getRootParent(Component component)
{
while (null != component.getParent())
{
component = component.getParent();
}
return component;
} | java | {
"resource": ""
} |
q14999 | AwtExtensions.setIconImage | train | public static void setIconImage(final String resourceName, final Window window)
throws IOException
{
final InputStream isLogo = ClassExtensions.getResourceAsStream(resourceName);
final BufferedImage biLogo = ImageIO.read(isLogo);
window.setIconImage(biLogo);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.