repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.createDummyPolygon
public static Polygon createDummyPolygon() { Coordinate[] c = new Coordinate[]{new Coordinate(0.0, 0.0), new Coordinate(1.0, 1.0), new Coordinate(1.0, 0.0), new Coordinate(0.0, 0.0)}; LinearRing linearRing = gf().createLinearRing(c); return gf().createPolygon(linearRing, null); }
java
public static Polygon createDummyPolygon() { Coordinate[] c = new Coordinate[]{new Coordinate(0.0, 0.0), new Coordinate(1.0, 1.0), new Coordinate(1.0, 0.0), new Coordinate(0.0, 0.0)}; LinearRing linearRing = gf().createLinearRing(c); return gf().createPolygon(linearRing, null); }
[ "public", "static", "Polygon", "createDummyPolygon", "(", ")", "{", "Coordinate", "[", "]", "c", "=", "new", "Coordinate", "[", "]", "{", "new", "Coordinate", "(", "0.0", ",", "0.0", ")", ",", "new", "Coordinate", "(", "1.0", ",", "1.0", ")", ",", "n...
Creates a polygon that may help out as placeholder. @return a dummy {@link Polygon}.
[ "Creates", "a", "polygon", "that", "may", "help", "out", "as", "placeholder", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L124-L129
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.createDummyLine
public static LineString createDummyLine() { Coordinate[] c = new Coordinate[]{new Coordinate(0.0, 0.0), new Coordinate(1.0, 1.0), new Coordinate(1.0, 0.0)}; LineString lineString = gf().createLineString(c); return lineString; }
java
public static LineString createDummyLine() { Coordinate[] c = new Coordinate[]{new Coordinate(0.0, 0.0), new Coordinate(1.0, 1.0), new Coordinate(1.0, 0.0)}; LineString lineString = gf().createLineString(c); return lineString; }
[ "public", "static", "LineString", "createDummyLine", "(", ")", "{", "Coordinate", "[", "]", "c", "=", "new", "Coordinate", "[", "]", "{", "new", "Coordinate", "(", "0.0", ",", "0.0", ")", ",", "new", "Coordinate", "(", "1.0", ",", "1.0", ")", ",", "n...
Creates a line that may help out as placeholder. @return a dummy {@link LineString}.
[ "Creates", "a", "line", "that", "may", "help", "out", "as", "placeholder", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L136-L140
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.getPolygonArea
public static double getPolygonArea( int[] x, int[] y, int N ) { int i, j; double area = 0; for( i = 0; i < N; i++ ) { j = (i + 1) % N; area += x[i] * y[j]; area -= y[i] * x[j]; } area /= 2; return (area < 0 ? -area : area); }
java
public static double getPolygonArea( int[] x, int[] y, int N ) { int i, j; double area = 0; for( i = 0; i < N; i++ ) { j = (i + 1) % N; area += x[i] * y[j]; area -= y[i] * x[j]; } area /= 2; return (area < 0 ? -area : area); }
[ "public", "static", "double", "getPolygonArea", "(", "int", "[", "]", "x", ",", "int", "[", "]", "y", ",", "int", "N", ")", "{", "int", "i", ",", "j", ";", "double", "area", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "N", ";",...
Calculates the area of a polygon from its vertices. @param x the array of x coordinates. @param y the array of y coordinates. @param N the number of sides of the polygon. @return the area of the polygon.
[ "Calculates", "the", "area", "of", "a", "polygon", "from", "its", "vertices", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L284-L296
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.distance3d
public static double distance3d( Coordinate c1, Coordinate c2, GeodeticCalculator geodeticCalculator ) { if (Double.isNaN(c1.z) || Double.isNaN(c2.z)) { throw new IllegalArgumentException("Missing elevation information in the supplied coordinates."); } double deltaElev = Math.abs(c1.z - c2.z); double projectedDistance; if (geodeticCalculator != null) { geodeticCalculator.setStartingGeographicPoint(c1.x, c1.y); geodeticCalculator.setDestinationGeographicPoint(c2.x, c2.y); projectedDistance = geodeticCalculator.getOrthodromicDistance(); } else { projectedDistance = c1.distance(c2); } double distance = NumericsUtilities.pythagoras(projectedDistance, deltaElev); return distance; }
java
public static double distance3d( Coordinate c1, Coordinate c2, GeodeticCalculator geodeticCalculator ) { if (Double.isNaN(c1.z) || Double.isNaN(c2.z)) { throw new IllegalArgumentException("Missing elevation information in the supplied coordinates."); } double deltaElev = Math.abs(c1.z - c2.z); double projectedDistance; if (geodeticCalculator != null) { geodeticCalculator.setStartingGeographicPoint(c1.x, c1.y); geodeticCalculator.setDestinationGeographicPoint(c2.x, c2.y); projectedDistance = geodeticCalculator.getOrthodromicDistance(); } else { projectedDistance = c1.distance(c2); } double distance = NumericsUtilities.pythagoras(projectedDistance, deltaElev); return distance; }
[ "public", "static", "double", "distance3d", "(", "Coordinate", "c1", ",", "Coordinate", "c2", ",", "GeodeticCalculator", "geodeticCalculator", ")", "{", "if", "(", "Double", ".", "isNaN", "(", "c1", ".", "z", ")", "||", "Double", ".", "isNaN", "(", "c2", ...
Calculates the 3d distance between two coordinates that have an elevation information. <p>Note that the {@link Coordinate#distance(Coordinate)} method does only 2d. @param c1 coordinate 1. @param c2 coordinate 2. @param geodeticCalculator If supplied it will be used for planar distance calculation. @return the distance considering also elevation.
[ "Calculates", "the", "3d", "distance", "between", "two", "coordinates", "that", "have", "an", "elevation", "information", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L308-L324
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.lines2Polygon
public static Polygon lines2Polygon( boolean checkValid, LineString... lines ) { List<Coordinate> coordinatesList = new ArrayList<Coordinate>(); List<LineString> linesList = new ArrayList<LineString>(); for( LineString tmpLine : lines ) { linesList.add(tmpLine); } LineString currentLine = linesList.get(0); linesList.remove(0); while( linesList.size() > 0 ) { Coordinate[] coordinates = currentLine.getCoordinates(); List<Coordinate> tmpList = Arrays.asList(coordinates); coordinatesList.addAll(tmpList); Point thePoint = currentLine.getEndPoint(); double minDistance = Double.MAX_VALUE; LineString minDistanceLine = null; boolean needFlip = false; for( LineString tmpLine : linesList ) { Point tmpStartPoint = tmpLine.getStartPoint(); double distance = thePoint.distance(tmpStartPoint); if (distance < minDistance) { minDistance = distance; minDistanceLine = tmpLine; needFlip = false; } Point tmpEndPoint = tmpLine.getEndPoint(); distance = thePoint.distance(tmpEndPoint); if (distance < minDistance) { minDistance = distance; minDistanceLine = tmpLine; needFlip = true; } } linesList.remove(minDistanceLine); if (needFlip) { minDistanceLine = (LineString) minDistanceLine.reverse(); } currentLine = minDistanceLine; } // add last Coordinate[] coordinates = currentLine.getCoordinates(); List<Coordinate> tmpList = Arrays.asList(coordinates); coordinatesList.addAll(tmpList); coordinatesList.add(coordinatesList.get(0)); LinearRing linearRing = gf().createLinearRing(coordinatesList.toArray(new Coordinate[0])); Polygon polygon = gf().createPolygon(linearRing, null); if (checkValid) { if (!polygon.isValid()) { return null; } } return polygon; }
java
public static Polygon lines2Polygon( boolean checkValid, LineString... lines ) { List<Coordinate> coordinatesList = new ArrayList<Coordinate>(); List<LineString> linesList = new ArrayList<LineString>(); for( LineString tmpLine : lines ) { linesList.add(tmpLine); } LineString currentLine = linesList.get(0); linesList.remove(0); while( linesList.size() > 0 ) { Coordinate[] coordinates = currentLine.getCoordinates(); List<Coordinate> tmpList = Arrays.asList(coordinates); coordinatesList.addAll(tmpList); Point thePoint = currentLine.getEndPoint(); double minDistance = Double.MAX_VALUE; LineString minDistanceLine = null; boolean needFlip = false; for( LineString tmpLine : linesList ) { Point tmpStartPoint = tmpLine.getStartPoint(); double distance = thePoint.distance(tmpStartPoint); if (distance < minDistance) { minDistance = distance; minDistanceLine = tmpLine; needFlip = false; } Point tmpEndPoint = tmpLine.getEndPoint(); distance = thePoint.distance(tmpEndPoint); if (distance < minDistance) { minDistance = distance; minDistanceLine = tmpLine; needFlip = true; } } linesList.remove(minDistanceLine); if (needFlip) { minDistanceLine = (LineString) minDistanceLine.reverse(); } currentLine = minDistanceLine; } // add last Coordinate[] coordinates = currentLine.getCoordinates(); List<Coordinate> tmpList = Arrays.asList(coordinates); coordinatesList.addAll(tmpList); coordinatesList.add(coordinatesList.get(0)); LinearRing linearRing = gf().createLinearRing(coordinatesList.toArray(new Coordinate[0])); Polygon polygon = gf().createPolygon(linearRing, null); if (checkValid) { if (!polygon.isValid()) { return null; } } return polygon; }
[ "public", "static", "Polygon", "lines2Polygon", "(", "boolean", "checkValid", ",", "LineString", "...", "lines", ")", "{", "List", "<", "Coordinate", ">", "coordinatesList", "=", "new", "ArrayList", "<", "Coordinate", ">", "(", ")", ";", "List", "<", "LineSt...
Joins two lines to a polygon. @param checkValid checks if the resulting polygon is valid. @param lines the lines to use. @return the joined polygon or <code>null</code> if something ugly happened.
[ "Joins", "two", "lines", "to", "a", "polygon", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L351-L413
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.getCoordinatesAtInterval
public static List<Coordinate> getCoordinatesAtInterval( LineString line, double interval, boolean keepExisting, double startFrom, double endAt ) { if (interval <= 0) { throw new IllegalArgumentException("Interval needs to be > 0."); } double length = line.getLength(); if (startFrom < 0) { startFrom = 0.0; } if (endAt < 0) { endAt = length; } List<Coordinate> coordinatesList = new ArrayList<Coordinate>(); LengthIndexedLine indexedLine = new LengthIndexedLine(line); Coordinate[] existingCoordinates = null; double[] indexOfExisting = null; if (keepExisting) { existingCoordinates = line.getCoordinates(); indexOfExisting = new double[existingCoordinates.length]; int i = 0; for( Coordinate coordinate : existingCoordinates ) { double indexOf = indexedLine.indexOf(coordinate); indexOfExisting[i] = indexOf; i++; } } double runningLength = startFrom; int currentIndexOfexisting = 1; // jump first while( runningLength < endAt ) { if (keepExisting && currentIndexOfexisting < indexOfExisting.length - 1 && runningLength > indexOfExisting[currentIndexOfexisting]) { // add the existing coordinatesList.add(existingCoordinates[currentIndexOfexisting]); currentIndexOfexisting++; continue; } Coordinate extractedPoint = indexedLine.extractPoint(runningLength); coordinatesList.add(extractedPoint); runningLength = runningLength + interval; } Coordinate extractedPoint = indexedLine.extractPoint(endAt); coordinatesList.add(extractedPoint); return coordinatesList; }
java
public static List<Coordinate> getCoordinatesAtInterval( LineString line, double interval, boolean keepExisting, double startFrom, double endAt ) { if (interval <= 0) { throw new IllegalArgumentException("Interval needs to be > 0."); } double length = line.getLength(); if (startFrom < 0) { startFrom = 0.0; } if (endAt < 0) { endAt = length; } List<Coordinate> coordinatesList = new ArrayList<Coordinate>(); LengthIndexedLine indexedLine = new LengthIndexedLine(line); Coordinate[] existingCoordinates = null; double[] indexOfExisting = null; if (keepExisting) { existingCoordinates = line.getCoordinates(); indexOfExisting = new double[existingCoordinates.length]; int i = 0; for( Coordinate coordinate : existingCoordinates ) { double indexOf = indexedLine.indexOf(coordinate); indexOfExisting[i] = indexOf; i++; } } double runningLength = startFrom; int currentIndexOfexisting = 1; // jump first while( runningLength < endAt ) { if (keepExisting && currentIndexOfexisting < indexOfExisting.length - 1 && runningLength > indexOfExisting[currentIndexOfexisting]) { // add the existing coordinatesList.add(existingCoordinates[currentIndexOfexisting]); currentIndexOfexisting++; continue; } Coordinate extractedPoint = indexedLine.extractPoint(runningLength); coordinatesList.add(extractedPoint); runningLength = runningLength + interval; } Coordinate extractedPoint = indexedLine.extractPoint(endAt); coordinatesList.add(extractedPoint); return coordinatesList; }
[ "public", "static", "List", "<", "Coordinate", ">", "getCoordinatesAtInterval", "(", "LineString", "line", ",", "double", "interval", ",", "boolean", "keepExisting", ",", "double", "startFrom", ",", "double", "endAt", ")", "{", "if", "(", "interval", "<=", "0"...
Returns the coordinates at a given interval along the line. <p> Note that first and last coordinate are also added, making it likely that the interval between the last two coordinates is less than the supplied interval. </p> @param line the line to use. @param interval the interval to use as distance between coordinates. Has to be > 0. @param keepExisting if <code>true</code>, keeps the existing coordinates in the generated list. Aslo in this case the interval around the existing points will not reflect the asked interval. @param startFrom if > 0, it defines the initial distance to jump. @param endAt if > 0, it defines where to end, even if the line is longer. @return the list of extracted coordinates.
[ "Returns", "the", "coordinates", "at", "a", "given", "interval", "along", "the", "line", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L433-L481
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.getSectionsAtInterval
public static List<LineString> getSectionsAtInterval( LineString line, double interval, double width, double startFrom, double endAt ) { if (interval <= 0) { throw new IllegalArgumentException("Interval needs to be > 0."); } double length = line.getLength(); if (startFrom < 0) { startFrom = 0.0; } if (endAt < 0) { endAt = length; } double halfWidth = width / 2.0; List<LineString> linesList = new ArrayList<LineString>(); LengthIndexedLine indexedLine = new LengthIndexedLine(line); double runningLength = startFrom; while( runningLength < endAt ) { Coordinate centerCoordinate = indexedLine.extractPoint(runningLength); Coordinate leftCoordinate = indexedLine.extractPoint(runningLength, -halfWidth); Coordinate rightCoordinate = indexedLine.extractPoint(runningLength, halfWidth); LineString lineString = geomFactory .createLineString(new Coordinate[]{leftCoordinate, centerCoordinate, rightCoordinate}); linesList.add(lineString); runningLength = runningLength + interval; } Coordinate centerCoordinate = indexedLine.extractPoint(endAt); Coordinate leftCoordinate = indexedLine.extractPoint(endAt, -halfWidth); Coordinate rightCoordinate = indexedLine.extractPoint(endAt, halfWidth); LineString lineString = geomFactory.createLineString(new Coordinate[]{leftCoordinate, centerCoordinate, rightCoordinate}); linesList.add(lineString); return linesList; }
java
public static List<LineString> getSectionsAtInterval( LineString line, double interval, double width, double startFrom, double endAt ) { if (interval <= 0) { throw new IllegalArgumentException("Interval needs to be > 0."); } double length = line.getLength(); if (startFrom < 0) { startFrom = 0.0; } if (endAt < 0) { endAt = length; } double halfWidth = width / 2.0; List<LineString> linesList = new ArrayList<LineString>(); LengthIndexedLine indexedLine = new LengthIndexedLine(line); double runningLength = startFrom; while( runningLength < endAt ) { Coordinate centerCoordinate = indexedLine.extractPoint(runningLength); Coordinate leftCoordinate = indexedLine.extractPoint(runningLength, -halfWidth); Coordinate rightCoordinate = indexedLine.extractPoint(runningLength, halfWidth); LineString lineString = geomFactory .createLineString(new Coordinate[]{leftCoordinate, centerCoordinate, rightCoordinate}); linesList.add(lineString); runningLength = runningLength + interval; } Coordinate centerCoordinate = indexedLine.extractPoint(endAt); Coordinate leftCoordinate = indexedLine.extractPoint(endAt, -halfWidth); Coordinate rightCoordinate = indexedLine.extractPoint(endAt, halfWidth); LineString lineString = geomFactory.createLineString(new Coordinate[]{leftCoordinate, centerCoordinate, rightCoordinate}); linesList.add(lineString); return linesList; }
[ "public", "static", "List", "<", "LineString", ">", "getSectionsAtInterval", "(", "LineString", "line", ",", "double", "interval", ",", "double", "width", ",", "double", "startFrom", ",", "double", "endAt", ")", "{", "if", "(", "interval", "<=", "0", ")", ...
Returns the section line at a given interval along the line. <p> The returned lines are digitized from left to right and contain also the center point. </p> <p> Note that first and last coordinate's section are also added, making it likely that the interval between the last two coordinates is less than the supplied interval. </p> @param line the line to use. @param interval the interval to use as distance between coordinates. Has to be > 0. @param width the total width of the section. @return the list of coordinates. @param startFrom if > 0, it defines the initial distance to jump. @param endAt if > 0, it defines where to end, even if the line is longer. @return the list of sections lines at a given interval.
[ "Returns", "the", "section", "line", "at", "a", "given", "interval", "along", "the", "line", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L560-L594
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.scaleToRatio
public static void scaleToRatio( Rectangle2D fixed, Rectangle2D toScale, boolean doShrink ) { double origWidth = fixed.getWidth(); double origHeight = fixed.getHeight(); double toAdaptWidth = toScale.getWidth(); double toAdaptHeight = toScale.getHeight(); double scaleWidth = 0; double scaleHeight = 0; scaleWidth = toAdaptWidth / origWidth; scaleHeight = toAdaptHeight / origHeight; double scaleFactor; if (doShrink) { scaleFactor = Math.min(scaleWidth, scaleHeight); } else { scaleFactor = Math.max(scaleWidth, scaleHeight); } double newWidth = origWidth * scaleFactor; double newHeight = origHeight * scaleFactor; double dw = (toAdaptWidth - newWidth) / 2.0; double dh = (toAdaptHeight - newHeight) / 2.0; double newX = toScale.getX() + dw; double newY = toScale.getY() + dh; double newW = toAdaptWidth - 2 * dw; double newH = toAdaptHeight - 2 * dh; toScale.setRect(newX, newY, newW, newH); }
java
public static void scaleToRatio( Rectangle2D fixed, Rectangle2D toScale, boolean doShrink ) { double origWidth = fixed.getWidth(); double origHeight = fixed.getHeight(); double toAdaptWidth = toScale.getWidth(); double toAdaptHeight = toScale.getHeight(); double scaleWidth = 0; double scaleHeight = 0; scaleWidth = toAdaptWidth / origWidth; scaleHeight = toAdaptHeight / origHeight; double scaleFactor; if (doShrink) { scaleFactor = Math.min(scaleWidth, scaleHeight); } else { scaleFactor = Math.max(scaleWidth, scaleHeight); } double newWidth = origWidth * scaleFactor; double newHeight = origHeight * scaleFactor; double dw = (toAdaptWidth - newWidth) / 2.0; double dh = (toAdaptHeight - newHeight) / 2.0; double newX = toScale.getX() + dw; double newY = toScale.getY() + dh; double newW = toAdaptWidth - 2 * dw; double newH = toAdaptHeight - 2 * dh; toScale.setRect(newX, newY, newW, newH); }
[ "public", "static", "void", "scaleToRatio", "(", "Rectangle2D", "fixed", ",", "Rectangle2D", "toScale", ",", "boolean", "doShrink", ")", "{", "double", "origWidth", "=", "fixed", ".", "getWidth", "(", ")", ";", "double", "origHeight", "=", "fixed", ".", "get...
Extends or shrinks a rectangle following the ration of a fixed one. <p>This keeps the center point of the rectangle fixed.</p> @param fixed the fixed {@link Rectangle2D} to use for the ratio. @param toScale the {@link Rectangle2D} to adapt to the ratio of the fixed one. @param doShrink if <code>true</code>, the adapted rectangle is shrinked as opposed to extended.
[ "Extends", "or", "shrinks", "a", "rectangle", "following", "the", "ration", "of", "a", "fixed", "one", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L679-L708
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.scaleDownToFit
public static void scaleDownToFit( Rectangle2D rectToFitIn, Rectangle2D toScale ) { double fitWidth = rectToFitIn.getWidth(); double fitHeight = rectToFitIn.getHeight(); double toScaleWidth = toScale.getWidth(); double toScaleHeight = toScale.getHeight(); if (toScaleWidth > fitWidth) { double factor = toScaleWidth / fitWidth; toScaleWidth = fitWidth; toScaleHeight = toScaleHeight / factor; } if (toScaleHeight > fitHeight) { double factor = toScaleHeight / fitHeight; toScaleHeight = fitHeight; toScaleWidth = toScaleWidth / factor; } toScale.setRect(0, 0, toScaleWidth, toScaleHeight); }
java
public static void scaleDownToFit( Rectangle2D rectToFitIn, Rectangle2D toScale ) { double fitWidth = rectToFitIn.getWidth(); double fitHeight = rectToFitIn.getHeight(); double toScaleWidth = toScale.getWidth(); double toScaleHeight = toScale.getHeight(); if (toScaleWidth > fitWidth) { double factor = toScaleWidth / fitWidth; toScaleWidth = fitWidth; toScaleHeight = toScaleHeight / factor; } if (toScaleHeight > fitHeight) { double factor = toScaleHeight / fitHeight; toScaleHeight = fitHeight; toScaleWidth = toScaleWidth / factor; } toScale.setRect(0, 0, toScaleWidth, toScaleHeight); }
[ "public", "static", "void", "scaleDownToFit", "(", "Rectangle2D", "rectToFitIn", ",", "Rectangle2D", "toScale", ")", "{", "double", "fitWidth", "=", "rectToFitIn", ".", "getWidth", "(", ")", ";", "double", "fitHeight", "=", "rectToFitIn", ".", "getHeight", "(", ...
Scales a rectangle down to fit inside the given one, keeping the ratio. @param rectToFitIn the fixed rectangle to fit in. @param toScale the rectangle to scale.
[ "Scales", "a", "rectangle", "down", "to", "fit", "inside", "the", "given", "one", "keeping", "the", "ratio", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L716-L734
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.getLineWithPlaneIntersection
public static Coordinate getLineWithPlaneIntersection( Coordinate lC1, Coordinate lC2, Coordinate pC1, Coordinate pC2, Coordinate pC3 ) { double[] p = getPlaneCoefficientsFrom3Points(pC1, pC2, pC3); double denominator = p[0] * (lC1.x - lC2.x) + p[1] * (lC1.y - lC2.y) + p[2] * (lC1.z - lC2.z); if (denominator == 0.0) { return null; } double u = (p[0] * lC1.x + p[1] * lC1.y + p[2] * lC1.z + p[3]) / // denominator; double x = lC1.x + (lC2.x - lC1.x) * u; double y = lC1.y + (lC2.y - lC1.y) * u; double z = lC1.z + (lC2.z - lC1.z) * u; return new Coordinate(x, y, z); }
java
public static Coordinate getLineWithPlaneIntersection( Coordinate lC1, Coordinate lC2, Coordinate pC1, Coordinate pC2, Coordinate pC3 ) { double[] p = getPlaneCoefficientsFrom3Points(pC1, pC2, pC3); double denominator = p[0] * (lC1.x - lC2.x) + p[1] * (lC1.y - lC2.y) + p[2] * (lC1.z - lC2.z); if (denominator == 0.0) { return null; } double u = (p[0] * lC1.x + p[1] * lC1.y + p[2] * lC1.z + p[3]) / // denominator; double x = lC1.x + (lC2.x - lC1.x) * u; double y = lC1.y + (lC2.y - lC1.y) * u; double z = lC1.z + (lC2.z - lC1.z) * u; return new Coordinate(x, y, z); }
[ "public", "static", "Coordinate", "getLineWithPlaneIntersection", "(", "Coordinate", "lC1", ",", "Coordinate", "lC2", ",", "Coordinate", "pC1", ",", "Coordinate", "pC2", ",", "Coordinate", "pC3", ")", "{", "double", "[", "]", "p", "=", "getPlaneCoefficientsFrom3Po...
Get the intersection coordinate between a line and plane. <p>The line is defined by 2 3d coordinates and the plane by 3 3d coordinates.</p> <p>from http://paulbourke.net/geometry/pointlineplane/</p> @param lC1 line coordinate 1. @param lC2 line coordinate 2. @param pC1 plane coordinate 1. @param pC2 plane coordinate 2. @param pC3 plane coordinate 3. @return the intersection coordinate or <code>null</code> if the line is parallel to the plane.
[ "Get", "the", "intersection", "coordinate", "between", "a", "line", "and", "plane", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L766-L780
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.getAngleBetweenLinePlane
public static double getAngleBetweenLinePlane( Coordinate a, Coordinate d, Coordinate b, Coordinate c ) { double[] rAD = {d.x - a.x, d.y - a.y, d.z - a.z}; double[] rDB = {b.x - d.x, b.y - d.y, b.z - d.z}; double[] rDC = {c.x - d.x, c.y - d.y, c.z - d.z}; double[] n = {// /* */rDB[1] * rDC[2] - rDC[1] * rDB[2], // -1 * (rDB[0] * rDC[2] - rDC[0] * rDB[2]), // rDB[0] * rDC[1] - rDC[0] * rDB[1]// }; double cosNum = n[0] * rAD[0] + n[1] * rAD[1] + n[2] * rAD[2]; double cosDen = sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]) * sqrt(rAD[0] * rAD[0] + rAD[1] * rAD[1] + rAD[2] * rAD[2]); double cos90MinAlpha = abs(cosNum / cosDen); double alpha = 90.0 - toDegrees(acos(cos90MinAlpha)); return alpha; }
java
public static double getAngleBetweenLinePlane( Coordinate a, Coordinate d, Coordinate b, Coordinate c ) { double[] rAD = {d.x - a.x, d.y - a.y, d.z - a.z}; double[] rDB = {b.x - d.x, b.y - d.y, b.z - d.z}; double[] rDC = {c.x - d.x, c.y - d.y, c.z - d.z}; double[] n = {// /* */rDB[1] * rDC[2] - rDC[1] * rDB[2], // -1 * (rDB[0] * rDC[2] - rDC[0] * rDB[2]), // rDB[0] * rDC[1] - rDC[0] * rDB[1]// }; double cosNum = n[0] * rAD[0] + n[1] * rAD[1] + n[2] * rAD[2]; double cosDen = sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]) * sqrt(rAD[0] * rAD[0] + rAD[1] * rAD[1] + rAD[2] * rAD[2]); double cos90MinAlpha = abs(cosNum / cosDen); double alpha = 90.0 - toDegrees(acos(cos90MinAlpha)); return alpha; }
[ "public", "static", "double", "getAngleBetweenLinePlane", "(", "Coordinate", "a", ",", "Coordinate", "d", ",", "Coordinate", "b", ",", "Coordinate", "c", ")", "{", "double", "[", "]", "rAD", "=", "{", "d", ".", "x", "-", "a", ".", "x", ",", "d", ".",...
Calculates the angle between line and plane. http://geogebrawiki.wikispaces.com/3D+Geometry @param a the 3d point. @param d the point of intersection between line and plane. @param b the second plane coordinate. @param c the third plane coordinate. @return the angle in degrees between line and plane.
[ "Calculates", "the", "angle", "between", "line", "and", "plane", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L793-L810
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.getAngleInTriangle
public static double getAngleInTriangle( double a, double b, double c ) { double angle = Math.acos((a * a + b * b - c * c) / (2.0 * a * b)); return angle; }
java
public static double getAngleInTriangle( double a, double b, double c ) { double angle = Math.acos((a * a + b * b - c * c) / (2.0 * a * b)); return angle; }
[ "public", "static", "double", "getAngleInTriangle", "(", "double", "a", ",", "double", "b", ",", "double", "c", ")", "{", "double", "angle", "=", "Math", ".", "acos", "(", "(", "a", "*", "a", "+", "b", "*", "b", "-", "c", "*", "c", ")", "/", "(...
Uses the cosine rule to find an angle in radiants of a triangle defined by the length of its sides. <p>The calculated angle is the one between the two adjacent sides a and b.</p> @param a adjacent side 1 length. @param b adjacent side 2 length. @param c opposite side length. @return the angle in radiants.
[ "Uses", "the", "cosine", "rule", "to", "find", "an", "angle", "in", "radiants", "of", "a", "triangle", "defined", "by", "the", "length", "of", "its", "sides", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L837-L840
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.angleBetween3D
public static double angleBetween3D( Coordinate c1, Coordinate c2, Coordinate c3 ) { double a = distance3d(c2, c1, null); double b = distance3d(c2, c3, null); double c = distance3d(c1, c3, null); double angleInTriangle = getAngleInTriangle(a, b, c); double degrees = toDegrees(angleInTriangle); return degrees; }
java
public static double angleBetween3D( Coordinate c1, Coordinate c2, Coordinate c3 ) { double a = distance3d(c2, c1, null); double b = distance3d(c2, c3, null); double c = distance3d(c1, c3, null); double angleInTriangle = getAngleInTriangle(a, b, c); double degrees = toDegrees(angleInTriangle); return degrees; }
[ "public", "static", "double", "angleBetween3D", "(", "Coordinate", "c1", ",", "Coordinate", "c2", ",", "Coordinate", "c3", ")", "{", "double", "a", "=", "distance3d", "(", "c2", ",", "c1", ",", "null", ")", ";", "double", "b", "=", "distance3d", "(", "...
Calculates the angle in degrees between 3 3D coordinates. <p>The calculated angle is the one placed in vertex c2.</p> @param c1 first 3D point. @param c2 central 3D point. @param c3 last 3D point. @return the angle between the coordinates in degrees.
[ "Calculates", "the", "angle", "in", "degrees", "between", "3", "3D", "coordinates", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L852-L860
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.mergeLinestrings
@SuppressWarnings("unchecked") public static List<LineString> mergeLinestrings( List<LineString> multiLines ) { LineMerger lineMerger = new LineMerger(); for( int i = 0; i < multiLines.size(); i++ ) { Geometry line = multiLines.get(i); lineMerger.add(line); } Collection<Geometry> merged = lineMerger.getMergedLineStrings(); List<LineString> mergedList = new ArrayList<>(); for( Geometry geom : merged ) { mergedList.add((LineString) geom); } return mergedList; }
java
@SuppressWarnings("unchecked") public static List<LineString> mergeLinestrings( List<LineString> multiLines ) { LineMerger lineMerger = new LineMerger(); for( int i = 0; i < multiLines.size(); i++ ) { Geometry line = multiLines.get(i); lineMerger.add(line); } Collection<Geometry> merged = lineMerger.getMergedLineStrings(); List<LineString> mergedList = new ArrayList<>(); for( Geometry geom : merged ) { mergedList.add((LineString) geom); } return mergedList; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "List", "<", "LineString", ">", "mergeLinestrings", "(", "List", "<", "LineString", ">", "multiLines", ")", "{", "LineMerger", "lineMerger", "=", "new", "LineMerger", "(", ")", ";", "for",...
Tries to merge multilines when they are snapped properly. @param multiLines the lines to merge. @return the list of lines, ideally containing a single line,merged.
[ "Tries", "to", "merge", "multilines", "when", "they", "are", "snapped", "properly", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L921-L934
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java
GeometryUtilities.createSimpleDirectionArrow
public static List<Polygon> createSimpleDirectionArrow( Geometry... geometries ) { List<Polygon> polygons = new ArrayList<>(); for( Geometry geometry : geometries ) { for( int i = 0; i < geometry.getNumGeometries(); i++ ) { Geometry geometryN = geometry.getGeometryN(i); if (geometryN instanceof LineString) { LineString line = (LineString) geometryN; polygons.addAll(makeArrows(line)); } else if (geometryN instanceof Polygon) { Polygon polygonGeom = (Polygon) geometryN; LineString exteriorRing = polygonGeom.getExteriorRing(); polygons.addAll(makeArrows(exteriorRing)); int numInteriorRing = polygonGeom.getNumInteriorRing(); for( int j = 0; j < numInteriorRing; j++ ) { LineString interiorRingN = polygonGeom.getInteriorRingN(j); polygons.addAll(makeArrows(interiorRingN)); } } } } return polygons; }
java
public static List<Polygon> createSimpleDirectionArrow( Geometry... geometries ) { List<Polygon> polygons = new ArrayList<>(); for( Geometry geometry : geometries ) { for( int i = 0; i < geometry.getNumGeometries(); i++ ) { Geometry geometryN = geometry.getGeometryN(i); if (geometryN instanceof LineString) { LineString line = (LineString) geometryN; polygons.addAll(makeArrows(line)); } else if (geometryN instanceof Polygon) { Polygon polygonGeom = (Polygon) geometryN; LineString exteriorRing = polygonGeom.getExteriorRing(); polygons.addAll(makeArrows(exteriorRing)); int numInteriorRing = polygonGeom.getNumInteriorRing(); for( int j = 0; j < numInteriorRing; j++ ) { LineString interiorRingN = polygonGeom.getInteriorRingN(j); polygons.addAll(makeArrows(interiorRingN)); } } } } return polygons; }
[ "public", "static", "List", "<", "Polygon", ">", "createSimpleDirectionArrow", "(", "Geometry", "...", "geometries", ")", "{", "List", "<", "Polygon", ">", "polygons", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "Geometry", "geometry", ":", "...
Creates simple arrow polygons in the direction of the coordinates. @param geometries the geometries (lines and polygons) for which to create the arrows. @return the list of polygon arrows.
[ "Creates", "simple", "arrow", "polygons", "in", "the", "direction", "of", "the", "coordinates", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/geometry/GeometryUtilities.java#L961-L982
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/api/entry/location/Location.java
Location.overlaps
public boolean overlaps(Location location) { if (location.getBeginPosition()>=getBeginPosition() && location.getBeginPosition() <= getEndPosition()) return true; if(location.getBeginPosition() <= getBeginPosition() && location.getEndPosition()>=getBeginPosition()) return true; else { return false; } }
java
public boolean overlaps(Location location) { if (location.getBeginPosition()>=getBeginPosition() && location.getBeginPosition() <= getEndPosition()) return true; if(location.getBeginPosition() <= getBeginPosition() && location.getEndPosition()>=getBeginPosition()) return true; else { return false; } }
[ "public", "boolean", "overlaps", "(", "Location", "location", ")", "{", "if", "(", "location", ".", "getBeginPosition", "(", ")", ">=", "getBeginPosition", "(", ")", "&&", "location", ".", "getBeginPosition", "(", ")", "<=", "getEndPosition", "(", ")", ")", ...
6361..6539,6363..6649
[ "6361", "..", "6539", "6363", "..", "6649" ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/entry/location/Location.java#L95-L103
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/libs/modules/JGTProcessingRegion.java
JGTProcessingRegion.fixRowsAndCols
private void fixRowsAndCols() { rows = (int) Math.round((north - south) / ns_res); if (rows < 1) rows = 1; cols = (int) Math.round((east - west) / we_res); if (cols < 1) cols = 1; }
java
private void fixRowsAndCols() { rows = (int) Math.round((north - south) / ns_res); if (rows < 1) rows = 1; cols = (int) Math.round((east - west) / we_res); if (cols < 1) cols = 1; }
[ "private", "void", "fixRowsAndCols", "(", ")", "{", "rows", "=", "(", "int", ")", "Math", ".", "round", "(", "(", "north", "-", "south", ")", "/", "ns_res", ")", ";", "if", "(", "rows", "<", "1", ")", "rows", "=", "1", ";", "cols", "=", "(", ...
calculates rows and cols from the region and its resolution. <p> Rows and cols have to be integers, rounding is applied if required. </p>
[ "calculates", "rows", "and", "cols", "from", "the", "region", "and", "its", "resolution", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/libs/modules/JGTProcessingRegion.java#L361-L368
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/libs/modules/JGTProcessingRegion.java
JGTProcessingRegion.degreeToNumber
private double degreeToNumber( String value ) { double number = -1; String[] valueSplit = value.trim().split(":"); //$NON-NLS-1$ if (valueSplit.length == 3) { // deg:min:sec.ss double deg = Double.parseDouble(valueSplit[0]); double min = Double.parseDouble(valueSplit[1]); double sec = Double.parseDouble(valueSplit[2]); number = deg + min / 60.0 + sec / 60.0 / 60.0; } else if (valueSplit.length == 2) { // deg:min double deg = Double.parseDouble(valueSplit[0]); double min = Double.parseDouble(valueSplit[1]); number = deg + min / 60.0; } else if (valueSplit.length == 1) { // deg number = Double.parseDouble(valueSplit[0]); } return number; }
java
private double degreeToNumber( String value ) { double number = -1; String[] valueSplit = value.trim().split(":"); //$NON-NLS-1$ if (valueSplit.length == 3) { // deg:min:sec.ss double deg = Double.parseDouble(valueSplit[0]); double min = Double.parseDouble(valueSplit[1]); double sec = Double.parseDouble(valueSplit[2]); number = deg + min / 60.0 + sec / 60.0 / 60.0; } else if (valueSplit.length == 2) { // deg:min double deg = Double.parseDouble(valueSplit[0]); double min = Double.parseDouble(valueSplit[1]); number = deg + min / 60.0; } else if (valueSplit.length == 1) { // deg number = Double.parseDouble(valueSplit[0]); } return number; }
[ "private", "double", "degreeToNumber", "(", "String", "value", ")", "{", "double", "number", "=", "-", "1", ";", "String", "[", "]", "valueSplit", "=", "value", ".", "trim", "(", ")", ".", "split", "(", "\":\"", ")", ";", "//$NON-NLS-1$", "if", "(", ...
Transforms degree string into the decimal value. @param value the string in degrees. @return the translated value.
[ "Transforms", "degree", "string", "into", "the", "decimal", "value", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/libs/modules/JGTProcessingRegion.java#L459-L479
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/libs/modules/JGTProcessingRegion.java
JGTProcessingRegion.xyResStringToNumbers
private double[] xyResStringToNumbers( String ewres, String nsres ) { double xres = -1.0; double yres = -1.0; if (ewres.indexOf(':') != -1) { xres = degreeToNumber(ewres); } else { xres = Double.parseDouble(ewres); } if (nsres.indexOf(':') != -1) { yres = degreeToNumber(nsres); } else { yres = Double.parseDouble(nsres); } return new double[]{xres, yres}; }
java
private double[] xyResStringToNumbers( String ewres, String nsres ) { double xres = -1.0; double yres = -1.0; if (ewres.indexOf(':') != -1) { xres = degreeToNumber(ewres); } else { xres = Double.parseDouble(ewres); } if (nsres.indexOf(':') != -1) { yres = degreeToNumber(nsres); } else { yres = Double.parseDouble(nsres); } return new double[]{xres, yres}; }
[ "private", "double", "[", "]", "xyResStringToNumbers", "(", "String", "ewres", ",", "String", "nsres", ")", "{", "double", "xres", "=", "-", "1.0", ";", "double", "yres", "=", "-", "1.0", ";", "if", "(", "ewres", ".", "indexOf", "(", "'", "'", ")", ...
Transforms a GRASS resolution string in metric or degree to decimal. @param ewres the x resolution string. @param nsres the y resolution string. @return the array of x and y resolution doubles.
[ "Transforms", "a", "GRASS", "resolution", "string", "in", "metric", "or", "degree", "to", "decimal", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/libs/modules/JGTProcessingRegion.java#L488-L503
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/libs/modules/JGTProcessingRegion.java
JGTProcessingRegion.nsewStringsToNumbers
@SuppressWarnings("nls") private double[] nsewStringsToNumbers( String north, String south, String east, String west ) { double no = -1.0; double so = -1.0; double ea = -1.0; double we = -1.0; if (north.indexOf("N") != -1 || north.indexOf("n") != -1) { north = north.substring(0, north.length() - 1); no = degreeToNumber(north); } else if (north.indexOf("S") != -1 || north.indexOf("s") != -1) { north = north.substring(0, north.length() - 1); no = -degreeToNumber(north); } else { no = Double.parseDouble(north); } if (south.indexOf("N") != -1 || south.indexOf("n") != -1) { south = south.substring(0, south.length() - 1); so = degreeToNumber(south); } else if (south.indexOf("S") != -1 || south.indexOf("s") != -1) { south = south.substring(0, south.length() - 1); so = -degreeToNumber(south); } else { so = Double.parseDouble(south); } if (west.indexOf("E") != -1 || west.indexOf("e") != -1) { west = west.substring(0, west.length() - 1); we = degreeToNumber(west); } else if (west.indexOf("W") != -1 || west.indexOf("w") != -1) { west = west.substring(0, west.length() - 1); we = -degreeToNumber(west); } else { we = Double.parseDouble(west); } if (east.indexOf("E") != -1 || east.indexOf("e") != -1) { east = east.substring(0, east.length() - 1); ea = degreeToNumber(east); } else if (east.indexOf("W") != -1 || east.indexOf("w") != -1) { east = east.substring(0, east.length() - 1); ea = -degreeToNumber(east); } else { ea = Double.parseDouble(east); } return new double[]{no, so, ea, we}; }
java
@SuppressWarnings("nls") private double[] nsewStringsToNumbers( String north, String south, String east, String west ) { double no = -1.0; double so = -1.0; double ea = -1.0; double we = -1.0; if (north.indexOf("N") != -1 || north.indexOf("n") != -1) { north = north.substring(0, north.length() - 1); no = degreeToNumber(north); } else if (north.indexOf("S") != -1 || north.indexOf("s") != -1) { north = north.substring(0, north.length() - 1); no = -degreeToNumber(north); } else { no = Double.parseDouble(north); } if (south.indexOf("N") != -1 || south.indexOf("n") != -1) { south = south.substring(0, south.length() - 1); so = degreeToNumber(south); } else if (south.indexOf("S") != -1 || south.indexOf("s") != -1) { south = south.substring(0, south.length() - 1); so = -degreeToNumber(south); } else { so = Double.parseDouble(south); } if (west.indexOf("E") != -1 || west.indexOf("e") != -1) { west = west.substring(0, west.length() - 1); we = degreeToNumber(west); } else if (west.indexOf("W") != -1 || west.indexOf("w") != -1) { west = west.substring(0, west.length() - 1); we = -degreeToNumber(west); } else { we = Double.parseDouble(west); } if (east.indexOf("E") != -1 || east.indexOf("e") != -1) { east = east.substring(0, east.length() - 1); ea = degreeToNumber(east); } else if (east.indexOf("W") != -1 || east.indexOf("w") != -1) { east = east.substring(0, east.length() - 1); ea = -degreeToNumber(east); } else { ea = Double.parseDouble(east); } return new double[]{no, so, ea, we}; }
[ "@", "SuppressWarnings", "(", "\"nls\"", ")", "private", "double", "[", "]", "nsewStringsToNumbers", "(", "String", "north", ",", "String", "south", ",", "String", "east", ",", "String", "west", ")", "{", "double", "no", "=", "-", "1.0", ";", "double", "...
Transforms the GRASS bounds strings in metric or degree to decimal. @param north the north string. @param south the south string. @param east the east string. @param west the west string. @return the array of the bounds in doubles.
[ "Transforms", "the", "GRASS", "bounds", "strings", "in", "metric", "or", "degree", "to", "decimal", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/libs/modules/JGTProcessingRegion.java#L514-L560
train
TheHortonMachine/hortonmachine
gears/src/main/java/oms3/io/ExtendedBufferedReader.java
ExtendedBufferedReader.read
@Override public int read() throws IOException { // initalize the lookahead if (lookaheadChar == UNDEFINED) { lookaheadChar = super.read(); } lastChar = lookaheadChar; if (super.ready()) { lookaheadChar = super.read(); } else { lookaheadChar = UNDEFINED; } if (lastChar == '\n') { lineCounter++; } return lastChar; }
java
@Override public int read() throws IOException { // initalize the lookahead if (lookaheadChar == UNDEFINED) { lookaheadChar = super.read(); } lastChar = lookaheadChar; if (super.ready()) { lookaheadChar = super.read(); } else { lookaheadChar = UNDEFINED; } if (lastChar == '\n') { lineCounter++; } return lastChar; }
[ "@", "Override", "public", "int", "read", "(", ")", "throws", "IOException", "{", "// initalize the lookahead", "if", "(", "lookaheadChar", "==", "UNDEFINED", ")", "{", "lookaheadChar", "=", "super", ".", "read", "(", ")", ";", "}", "lastChar", "=", "lookahe...
Reads the next char from the input stream. @return the next char or END_OF_STREAM if end of stream has been reached.
[ "Reads", "the", "next", "char", "from", "the", "input", "stream", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/io/ExtendedBufferedReader.java#L82-L98
train
TheHortonMachine/hortonmachine
gears/src/main/java/oms3/io/ExtendedBufferedReader.java
ExtendedBufferedReader.read
public int read(char[] buf, int off, int len) throws IOException { // do not claim if len == 0 if (len == 0) { return 0; } // init lookahead, but do not block !! if (lookaheadChar == UNDEFINED) { if (ready()) { lookaheadChar = super.read(); } else { return -1; } } // 'first read of underlying stream' if (lookaheadChar == -1) { return -1; } // continue until the lookaheadChar would block int cOff = off; while (len > 0 && ready()) { if (lookaheadChar == -1) { // eof stream reached, do not continue return cOff - off; } else { buf[cOff++] = (char) lookaheadChar; if (lookaheadChar == '\n') { lineCounter++; } lastChar = lookaheadChar; lookaheadChar = super.read(); len--; } } return cOff - off; }
java
public int read(char[] buf, int off, int len) throws IOException { // do not claim if len == 0 if (len == 0) { return 0; } // init lookahead, but do not block !! if (lookaheadChar == UNDEFINED) { if (ready()) { lookaheadChar = super.read(); } else { return -1; } } // 'first read of underlying stream' if (lookaheadChar == -1) { return -1; } // continue until the lookaheadChar would block int cOff = off; while (len > 0 && ready()) { if (lookaheadChar == -1) { // eof stream reached, do not continue return cOff - off; } else { buf[cOff++] = (char) lookaheadChar; if (lookaheadChar == '\n') { lineCounter++; } lastChar = lookaheadChar; lookaheadChar = super.read(); len--; } } return cOff - off; }
[ "public", "int", "read", "(", "char", "[", "]", "buf", ",", "int", "off", ",", "int", "len", ")", "throws", "IOException", "{", "// do not claim if len == 0", "if", "(", "len", "==", "0", ")", "{", "return", "0", ";", "}", "// init lookahead, but do not bl...
Non-blocking reading of len chars into buffer buf starting at bufferposition off. performs an iteratative read on the underlying stream as long as the following conditions hold: - less than len chars have been read - end of stream has not been reached - next read is not blocking @return nof chars actually read or END_OF_STREAM
[ "Non", "-", "blocking", "reading", "of", "len", "chars", "into", "buffer", "buf", "starting", "at", "bufferposition", "off", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/io/ExtendedBufferedReader.java#L121-L156
train
TheHortonMachine/hortonmachine
gears/src/main/java/oms3/io/ExtendedBufferedReader.java
ExtendedBufferedReader.skip
public long skip(long n) throws IllegalArgumentException, IOException { if (lookaheadChar == UNDEFINED) { lookaheadChar = super.read(); } // illegal argument if (n < 0) { throw new IllegalArgumentException("negative argument not supported"); } // no skipping if (n == 0 || lookaheadChar == END_OF_STREAM) { return 0; } // skip and reread the lookahead-char long skiped = 0; if (n > 1) { skiped = super.skip(n - 1); } lookaheadChar = super.read(); // fixme uh: we should check the skiped sequence for line-terminations... lineCounter = Integer.MIN_VALUE; return skiped + 1; }
java
public long skip(long n) throws IllegalArgumentException, IOException { if (lookaheadChar == UNDEFINED) { lookaheadChar = super.read(); } // illegal argument if (n < 0) { throw new IllegalArgumentException("negative argument not supported"); } // no skipping if (n == 0 || lookaheadChar == END_OF_STREAM) { return 0; } // skip and reread the lookahead-char long skiped = 0; if (n > 1) { skiped = super.skip(n - 1); } lookaheadChar = super.read(); // fixme uh: we should check the skiped sequence for line-terminations... lineCounter = Integer.MIN_VALUE; return skiped + 1; }
[ "public", "long", "skip", "(", "long", "n", ")", "throws", "IllegalArgumentException", ",", "IOException", "{", "if", "(", "lookaheadChar", "==", "UNDEFINED", ")", "{", "lookaheadChar", "=", "super", ".", "read", "(", ")", ";", "}", "// illegal argument", "i...
Skips char in the stream ATTENTION: invalidates the line-counter !!!!! @return nof skiped chars
[ "Skips", "char", "in", "the", "stream" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/io/ExtendedBufferedReader.java#L231-L256
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/sorting/QuickSortAlgorithmObjects.java
QuickSortAlgorithmObjects.sort
public void sort( double[] values, Object[] valuesToFollow ) { this.valuesToSort = values; this.valuesToFollow = valuesToFollow; number = values.length; monitor.beginTask("Sorting...", -1); monitor.worked(1); quicksort(0, number - 1); monitor.done(); }
java
public void sort( double[] values, Object[] valuesToFollow ) { this.valuesToSort = values; this.valuesToFollow = valuesToFollow; number = values.length; monitor.beginTask("Sorting...", -1); monitor.worked(1); quicksort(0, number - 1); monitor.done(); }
[ "public", "void", "sort", "(", "double", "[", "]", "values", ",", "Object", "[", "]", "valuesToFollow", ")", "{", "this", ".", "valuesToSort", "=", "values", ";", "this", ".", "valuesToFollow", "=", "valuesToFollow", ";", "number", "=", "values", ".", "l...
Sorts an array of values and moves with the sort a second array. @param values the array to sort. @param valuesToFollow the array that should be sorted following the indexes of the first array. Can be null.
[ "Sorts", "an", "array", "of", "values", "and", "moves", "with", "the", "sort", "a", "second", "array", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/sorting/QuickSortAlgorithmObjects.java#L49-L61
train
TheHortonMachine/hortonmachine
hmachine/src/main/java/org/hortonmachine/hmachine/modules/statistics/jami/OmsJami.java
OmsJami.createStationBasinsMatrix
private int[][] createStationBasinsMatrix( double[] statValues, int[] activeStationsPerBasin ) { int[][] stationsBasins = new int[stationCoordinates.size()][basinBaricenterCoordinates.size()]; Set<Integer> bandsIdSet = bin2StationsListMap.keySet(); Integer[] bandsIdArray = (Integer[]) bandsIdSet.toArray(new Integer[bandsIdSet.size()]); // for every basin for( int i = 0; i < basinBaricenterCoordinates.size(); i++ ) { Coordinate basinBaricenterCoordinate = basinBaricenterCoordinates.get(i); // for every stations band int activeStationsForThisBasin = 0; for( int j = 0; j < bandsIdArray.length; j++ ) { int bandId = bandsIdArray[j]; List<Integer> stationIdsForBand = bin2StationsListMap.get(bandId); /* * search for the nearest stations that have values. */ List<Integer> stationsToUse = extractStationsToUse(basinBaricenterCoordinate, stationIdsForBand, stationId2CoordinateMap, statValues, stationid2StationindexMap); if (stationsToUse.size() < pNum) { pm.message("Found only " + stationsToUse.size() + " for basin " + basinindex2basinidMap.get(i) + " and bandid " + bandId + "."); } /* * now we have the list of stations to use. With this list we * need to enable (1) the proper matrix positions inside the * stations-basins matrix. */ // i is the column (basin) index // the station id index can be taken from the idStationIndexMap // System.out.print("STATIONS for basin " + basinindex2basinidMap.get(i) + ": "); for( Integer stationIdToEnable : stationsToUse ) { int stIndex = stationid2StationindexMap.get(stationIdToEnable); stationsBasins[stIndex][i] = 1; // System.out.print(stationIdToEnable + ", "); } // System.out.println(); activeStationsForThisBasin = activeStationsForThisBasin + stationsToUse.size(); } activeStationsPerBasin[i] = activeStationsForThisBasin; } return stationsBasins; }
java
private int[][] createStationBasinsMatrix( double[] statValues, int[] activeStationsPerBasin ) { int[][] stationsBasins = new int[stationCoordinates.size()][basinBaricenterCoordinates.size()]; Set<Integer> bandsIdSet = bin2StationsListMap.keySet(); Integer[] bandsIdArray = (Integer[]) bandsIdSet.toArray(new Integer[bandsIdSet.size()]); // for every basin for( int i = 0; i < basinBaricenterCoordinates.size(); i++ ) { Coordinate basinBaricenterCoordinate = basinBaricenterCoordinates.get(i); // for every stations band int activeStationsForThisBasin = 0; for( int j = 0; j < bandsIdArray.length; j++ ) { int bandId = bandsIdArray[j]; List<Integer> stationIdsForBand = bin2StationsListMap.get(bandId); /* * search for the nearest stations that have values. */ List<Integer> stationsToUse = extractStationsToUse(basinBaricenterCoordinate, stationIdsForBand, stationId2CoordinateMap, statValues, stationid2StationindexMap); if (stationsToUse.size() < pNum) { pm.message("Found only " + stationsToUse.size() + " for basin " + basinindex2basinidMap.get(i) + " and bandid " + bandId + "."); } /* * now we have the list of stations to use. With this list we * need to enable (1) the proper matrix positions inside the * stations-basins matrix. */ // i is the column (basin) index // the station id index can be taken from the idStationIndexMap // System.out.print("STATIONS for basin " + basinindex2basinidMap.get(i) + ": "); for( Integer stationIdToEnable : stationsToUse ) { int stIndex = stationid2StationindexMap.get(stationIdToEnable); stationsBasins[stIndex][i] = 1; // System.out.print(stationIdToEnable + ", "); } // System.out.println(); activeStationsForThisBasin = activeStationsForThisBasin + stationsToUse.size(); } activeStationsPerBasin[i] = activeStationsForThisBasin; } return stationsBasins; }
[ "private", "int", "[", "]", "[", "]", "createStationBasinsMatrix", "(", "double", "[", "]", "statValues", ",", "int", "[", "]", "activeStationsPerBasin", ")", "{", "int", "[", "]", "[", "]", "stationsBasins", "=", "new", "int", "[", "stationCoordinates", "...
Creates the stations per basins matrix. <p> The matrix is a bitmap of the stations that will be used for every basin, following the schema: </p> <table> <tr> <td></td> <td>basin1</td> <td>basin2</td> <td>basin3</td> <td>basin...</td> <tr> <td>station1</td> <td>1</td> <td>0</td> <td>1</td> <td>0...</td> <tr> <td>station2</td> <td>1</td> <td>0</td> <td>1</td> <td>0...</td> <tr> <td>station3</td> <td>0</td> <td>1</td> <td>1</td> <td>0...</td> <tr> <td>station...</td> <td>0</td> <td>0</td> <td>0</td> <td>0...</td> </tr> </table> <p> In the above case basin1 will use station1 and station2, while basin2 will use only station3, and so on. </p> @param statValues the station data values, properly ordered, containing {@link JGrassConstants#defaultNovalue novalues}. @param activeStationsPerBasin an array to be filled with the number of active stations per basin. @return the matrix of active stations for every basin.
[ "Creates", "the", "stations", "per", "basins", "matrix", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/statistics/jami/OmsJami.java#L931-L976
train
TheHortonMachine/hortonmachine
hmachine/src/main/java/org/hortonmachine/hmachine/modules/statistics/jami/OmsJami.java
OmsJami.extractFromStationFeatures
private void extractFromStationFeatures() throws Exception { int stationIdIndex = -1; int stationElevIndex = -1; pm.beginTask("Filling the elevation and id arrays for the stations, ordering them in ascending elevation order.", stationCoordinates.size()); for( int i = 0; i < stationCoordinates.size(); i++ ) { pm.worked(1); SimpleFeature stationF = stationFeatures.get(i); Coordinate stationCoord = stationCoordinates.get(i); if (stationIdIndex == -1) { SimpleFeatureType featureType = stationF.getFeatureType(); stationIdIndex = featureType.indexOf(fStationid); stationElevIndex = featureType.indexOf(fStationelev); if (stationIdIndex == -1) { throw new IllegalArgumentException("Could not find the field: " + fStationid); } if (stationElevIndex == -1) { throw new IllegalArgumentException("Could not find the field: " + fStationelev); } } int id = ((Number) stationF.getAttribute(stationIdIndex)).intValue(); double elev = ((Number) stationF.getAttribute(stationElevIndex)).doubleValue(); statElev[i] = elev; statId[i] = id; stationId2CoordinateMap.put(id, stationCoord); } pm.done(); // sort QuickSortAlgorithm qsA = new QuickSortAlgorithm(pm); qsA.sort(statElev, statId); }
java
private void extractFromStationFeatures() throws Exception { int stationIdIndex = -1; int stationElevIndex = -1; pm.beginTask("Filling the elevation and id arrays for the stations, ordering them in ascending elevation order.", stationCoordinates.size()); for( int i = 0; i < stationCoordinates.size(); i++ ) { pm.worked(1); SimpleFeature stationF = stationFeatures.get(i); Coordinate stationCoord = stationCoordinates.get(i); if (stationIdIndex == -1) { SimpleFeatureType featureType = stationF.getFeatureType(); stationIdIndex = featureType.indexOf(fStationid); stationElevIndex = featureType.indexOf(fStationelev); if (stationIdIndex == -1) { throw new IllegalArgumentException("Could not find the field: " + fStationid); } if (stationElevIndex == -1) { throw new IllegalArgumentException("Could not find the field: " + fStationelev); } } int id = ((Number) stationF.getAttribute(stationIdIndex)).intValue(); double elev = ((Number) stationF.getAttribute(stationElevIndex)).doubleValue(); statElev[i] = elev; statId[i] = id; stationId2CoordinateMap.put(id, stationCoord); } pm.done(); // sort QuickSortAlgorithm qsA = new QuickSortAlgorithm(pm); qsA.sort(statElev, statId); }
[ "private", "void", "extractFromStationFeatures", "(", ")", "throws", "Exception", "{", "int", "stationIdIndex", "=", "-", "1", ";", "int", "stationElevIndex", "=", "-", "1", ";", "pm", ".", "beginTask", "(", "\"Filling the elevation and id arrays for the stations, ord...
Fills the elevation and id arrays for the stations, ordering in ascending elevation order. @throws Exception in the case the sorting gives problems.
[ "Fills", "the", "elevation", "and", "id", "arrays", "for", "the", "stations", "ordering", "in", "ascending", "elevation", "order", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/statistics/jami/OmsJami.java#L1050-L1080
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/modules/r/tmsgenerator/GlobalMercator.java
GlobalMercator.PixelsToTile
public int[] PixelsToTile( int px, int py ) { int tx = (int) Math.ceil(px / ((double) tileSize) - 1); int ty = (int) Math.ceil(py / ((double) tileSize) - 1); return new int[]{tx, ty}; }
java
public int[] PixelsToTile( int px, int py ) { int tx = (int) Math.ceil(px / ((double) tileSize) - 1); int ty = (int) Math.ceil(py / ((double) tileSize) - 1); return new int[]{tx, ty}; }
[ "public", "int", "[", "]", "PixelsToTile", "(", "int", "px", ",", "int", "py", ")", "{", "int", "tx", "=", "(", "int", ")", "Math", ".", "ceil", "(", "px", "/", "(", "(", "double", ")", "tileSize", ")", "-", "1", ")", ";", "int", "ty", "=", ...
Returns a tile covering region in given pixel coordinates @param px @param py @return
[ "Returns", "a", "tile", "covering", "region", "in", "given", "pixel", "coordinates" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/modules/r/tmsgenerator/GlobalMercator.java#L191-L195
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/modules/r/tmsgenerator/GlobalMercator.java
GlobalMercator.PixelsToRaster
public int[] PixelsToRaster( int px, int py, int zoom ) { int mapSize = tileSize << zoom; return new int[]{px, mapSize - py}; }
java
public int[] PixelsToRaster( int px, int py, int zoom ) { int mapSize = tileSize << zoom; return new int[]{px, mapSize - py}; }
[ "public", "int", "[", "]", "PixelsToRaster", "(", "int", "px", ",", "int", "py", ",", "int", "zoom", ")", "{", "int", "mapSize", "=", "tileSize", "<<", "zoom", ";", "return", "new", "int", "[", "]", "{", "px", ",", "mapSize", "-", "py", "}", ";",...
Move the origin of pixel coordinates to top-left corner @param px @param py @param zoom @return
[ "Move", "the", "origin", "of", "pixel", "coordinates", "to", "top", "-", "left", "corner" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/modules/r/tmsgenerator/GlobalMercator.java#L205-L208
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/modules/r/tmsgenerator/GlobalMercator.java
GlobalMercator.ZoomForPixelSize
public int ZoomForPixelSize( int pixelSize ) { for( int i = 0; i < 30; i++ ) { if (pixelSize > Resolution(i)) { if (i != 0) { return i - 1; } else { return 0; // We don't want to scale up } } } return 0; }
java
public int ZoomForPixelSize( int pixelSize ) { for( int i = 0; i < 30; i++ ) { if (pixelSize > Resolution(i)) { if (i != 0) { return i - 1; } else { return 0; // We don't want to scale up } } } return 0; }
[ "public", "int", "ZoomForPixelSize", "(", "int", "pixelSize", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "30", ";", "i", "++", ")", "{", "if", "(", "pixelSize", ">", "Resolution", "(", "i", ")", ")", "{", "if", "(", "i", "!=", ...
Maximal scaledown zoom of the pyramid closest to the pixelSize @param pixelSize @return
[ "Maximal", "scaledown", "zoom", "of", "the", "pyramid", "closest", "to", "the", "pixelSize" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/modules/r/tmsgenerator/GlobalMercator.java#L300-L311
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/modules/r/tmsgenerator/GlobalMercator.java
GlobalMercator.GoogleTile
public int[] GoogleTile( double lat, double lon, int zoom ) { double[] meters = LatLonToMeters(lat, lon); int[] tile = MetersToTile(meters[0], meters[1], zoom); return this.GoogleTile(tile[0], tile[1], zoom); }
java
public int[] GoogleTile( double lat, double lon, int zoom ) { double[] meters = LatLonToMeters(lat, lon); int[] tile = MetersToTile(meters[0], meters[1], zoom); return this.GoogleTile(tile[0], tile[1], zoom); }
[ "public", "int", "[", "]", "GoogleTile", "(", "double", "lat", ",", "double", "lon", ",", "int", "zoom", ")", "{", "double", "[", "]", "meters", "=", "LatLonToMeters", "(", "lat", ",", "lon", ")", ";", "int", "[", "]", "tile", "=", "MetersToTile", ...
Converts a lat long coordinates to Google Tile Coordinates @param lat @param lon @param zoom @return
[ "Converts", "a", "lat", "long", "coordinates", "to", "Google", "Tile", "Coordinates" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/modules/r/tmsgenerator/GlobalMercator.java#L341-L345
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/modules/r/tmsgenerator/GlobalMercator.java
GlobalMercator.QuadTree
public String QuadTree( int tx, int ty, int zoom ) { String quadKey = ""; ty = (int) ((Math.pow(2, zoom) - 1) - ty); for( int i = zoom; i < 0; i-- ) { int digit = 0; int mask = 1 << (i - 1); if ((tx & mask) != 0) { digit += 1; } if ((ty & mask) != 0) { digit += 2; } quadKey += (digit + ""); } return quadKey; }
java
public String QuadTree( int tx, int ty, int zoom ) { String quadKey = ""; ty = (int) ((Math.pow(2, zoom) - 1) - ty); for( int i = zoom; i < 0; i-- ) { int digit = 0; int mask = 1 << (i - 1); if ((tx & mask) != 0) { digit += 1; } if ((ty & mask) != 0) { digit += 2; } quadKey += (digit + ""); } return quadKey; }
[ "public", "String", "QuadTree", "(", "int", "tx", ",", "int", "ty", ",", "int", "zoom", ")", "{", "String", "quadKey", "=", "\"\"", ";", "ty", "=", "(", "int", ")", "(", "(", "Math", ".", "pow", "(", "2", ",", "zoom", ")", "-", "1", ")", "-",...
Converts TMS tile coordinates to Microsoft QuadTree @return
[ "Converts", "TMS", "tile", "coordinates", "to", "Microsoft", "QuadTree" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/modules/r/tmsgenerator/GlobalMercator.java#L352-L367
train
TheHortonMachine/hortonmachine
hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/splitsubbasin/OmsSplitSubbasins.java
OmsSplitSubbasins.net
private void net( WritableRandomIter hacksIter, WritableRandomIter netIter ) { // calculates the max order of basin (max hackstream value) pm.beginTask("Extraction of rivers of chosen order...", nRows); for( int r = 0; r < nRows; r++ ) { for( int c = 0; c < nCols; c++ ) { double value = hacksIter.getSampleDouble(c, r, 0); if (!isNovalue(value)) { /* * if the hack value is in the asked range * => keep it as net */ if (value <= hackOrder) { netIter.setSample(c, r, 0, 2); } else { hacksIter.setSample(c, r, 0, HMConstants.doubleNovalue); } } } pm.worked(1); } pm.done(); }
java
private void net( WritableRandomIter hacksIter, WritableRandomIter netIter ) { // calculates the max order of basin (max hackstream value) pm.beginTask("Extraction of rivers of chosen order...", nRows); for( int r = 0; r < nRows; r++ ) { for( int c = 0; c < nCols; c++ ) { double value = hacksIter.getSampleDouble(c, r, 0); if (!isNovalue(value)) { /* * if the hack value is in the asked range * => keep it as net */ if (value <= hackOrder) { netIter.setSample(c, r, 0, 2); } else { hacksIter.setSample(c, r, 0, HMConstants.doubleNovalue); } } } pm.worked(1); } pm.done(); }
[ "private", "void", "net", "(", "WritableRandomIter", "hacksIter", ",", "WritableRandomIter", "netIter", ")", "{", "// calculates the max order of basin (max hackstream value)", "pm", ".", "beginTask", "(", "\"Extraction of rivers of chosen order...\"", ",", "nRows", ")", ";",...
Return the map of the network with only the river of the choosen order. @param hacksIter the hack stream map. @param netIter the network map to build on the required hack orders. @return the map of the network with the choosen order.
[ "Return", "the", "map", "of", "the", "network", "with", "only", "the", "river", "of", "the", "choosen", "order", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/splitsubbasin/OmsSplitSubbasins.java#L138-L159
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/api/validation/helper/ByteBufferUtils.java
ByteBufferUtils.bytes
public static ByteBuffer bytes(String s, Charset charset) { return ByteBuffer.wrap(s.getBytes(charset)); }
java
public static ByteBuffer bytes(String s, Charset charset) { return ByteBuffer.wrap(s.getBytes(charset)); }
[ "public", "static", "ByteBuffer", "bytes", "(", "String", "s", ",", "Charset", "charset", ")", "{", "return", "ByteBuffer", ".", "wrap", "(", "s", ".", "getBytes", "(", "charset", ")", ")", ";", "}" ]
Encode a String in a ByteBuffer using the provided charset. @param s the string to encode @param charset the String encoding charset to use @return the encoded string
[ "Encode", "a", "String", "in", "a", "ByteBuffer", "using", "the", "provided", "charset", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/helper/ByteBufferUtils.java#L145-L148
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/gff3/writer/GFF3EntryWriter.java
GFF3EntryWriter.write
public void write(Writer writer) throws IOException { GFF3Writer.writeVersionPragma(writer); GFF3Writer.writeRegionPragma(writer, entry.getPrimaryAccession(), windowBeginPosition, windowEndPosition); int ID = 0; if (show.contains(SHOW_GENE)) { locusTagGeneMap = new HashMap<String, GFF3Gene>(); geneNameGeneMap = new HashMap<String, GFF3Gene>(); } for (Feature feature : entry.getFeatures()) { Long minPosition = feature.getLocations().getMinPosition(); Long maxPosition = feature.getLocations().getMaxPosition(); // Remove global complement. feature.getLocations().removeGlobalComplement(); String geneName = feature.getSingleQualifierValue(Qualifier.GENE_QUALIFIER_NAME); String locusTag = feature.getSingleQualifierValue(Qualifier.LOCUS_TAG_QUALIFIER_NAME); if (show.contains(SHOW_GENE)) { addGeneSegment(geneName, locusTag, minPosition, maxPosition); } if (show.contains(SHOW_FEATURE)) { ++ID; writeFeature(writer, feature, geneName, locusTag, ID, minPosition, maxPosition); for (Location location : feature.getLocations().getLocations()) { int parentID = ID; ++ID; writeFeatureSegment(writer, feature, geneName, locusTag, location, parentID, ID); } } } if (show.contains(SHOW_GENE)) { for (GFF3Gene gene : locusTagGeneMap.values()) { ++ID; writeGene(writer, gene, ID); } for (GFF3Gene gene : geneNameGeneMap.values()) { ++ID; writeGene(writer, gene, ID); } } if (show.contains(SHOW_CONTIG)) { Long contigPosition = 1L; for (Location location : entry.getSequence().getContigs()) { ++ID; contigPosition = writeContig(writer, location, ID, contigPosition); } } if (show.contains(SHOW_ASSEMBLY)) { for (Assembly assembly : entry.getAssemblies()) { ++ID; writeAssembly(writer, assembly, ID); } } }
java
public void write(Writer writer) throws IOException { GFF3Writer.writeVersionPragma(writer); GFF3Writer.writeRegionPragma(writer, entry.getPrimaryAccession(), windowBeginPosition, windowEndPosition); int ID = 0; if (show.contains(SHOW_GENE)) { locusTagGeneMap = new HashMap<String, GFF3Gene>(); geneNameGeneMap = new HashMap<String, GFF3Gene>(); } for (Feature feature : entry.getFeatures()) { Long minPosition = feature.getLocations().getMinPosition(); Long maxPosition = feature.getLocations().getMaxPosition(); // Remove global complement. feature.getLocations().removeGlobalComplement(); String geneName = feature.getSingleQualifierValue(Qualifier.GENE_QUALIFIER_NAME); String locusTag = feature.getSingleQualifierValue(Qualifier.LOCUS_TAG_QUALIFIER_NAME); if (show.contains(SHOW_GENE)) { addGeneSegment(geneName, locusTag, minPosition, maxPosition); } if (show.contains(SHOW_FEATURE)) { ++ID; writeFeature(writer, feature, geneName, locusTag, ID, minPosition, maxPosition); for (Location location : feature.getLocations().getLocations()) { int parentID = ID; ++ID; writeFeatureSegment(writer, feature, geneName, locusTag, location, parentID, ID); } } } if (show.contains(SHOW_GENE)) { for (GFF3Gene gene : locusTagGeneMap.values()) { ++ID; writeGene(writer, gene, ID); } for (GFF3Gene gene : geneNameGeneMap.values()) { ++ID; writeGene(writer, gene, ID); } } if (show.contains(SHOW_CONTIG)) { Long contigPosition = 1L; for (Location location : entry.getSequence().getContigs()) { ++ID; contigPosition = writeContig(writer, location, ID, contigPosition); } } if (show.contains(SHOW_ASSEMBLY)) { for (Assembly assembly : entry.getAssemblies()) { ++ID; writeAssembly(writer, assembly, ID); } } }
[ "public", "void", "write", "(", "Writer", "writer", ")", "throws", "IOException", "{", "GFF3Writer", ".", "writeVersionPragma", "(", "writer", ")", ";", "GFF3Writer", ".", "writeRegionPragma", "(", "writer", ",", "entry", ".", "getPrimaryAccession", "(", ")", ...
Writes the GFF3 file. @param writer the output stream. @throws IOException is there was an error in writing to the output stream.
[ "Writes", "the", "GFF3", "file", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/gff3/writer/GFF3EntryWriter.java#L71-L123
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java
FlatFileUtils.trim
public static String trim( String string, int pos ) { int len = string.length(); int leftPos = pos; int rightPos = len; for( ; rightPos > 0; --rightPos ) { char ch = string.charAt( rightPos - 1 ); if( ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r' ) { break; } } for( ; leftPos < rightPos; ++leftPos ) { char ch = string.charAt( leftPos ); if( ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r' ) { break; } } if( rightPos <= leftPos ) { return ""; } return ( leftPos == 0 && rightPos == string.length() )? string : string.substring( leftPos, rightPos ); }
java
public static String trim( String string, int pos ) { int len = string.length(); int leftPos = pos; int rightPos = len; for( ; rightPos > 0; --rightPos ) { char ch = string.charAt( rightPos - 1 ); if( ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r' ) { break; } } for( ; leftPos < rightPos; ++leftPos ) { char ch = string.charAt( leftPos ); if( ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r' ) { break; } } if( rightPos <= leftPos ) { return ""; } return ( leftPos == 0 && rightPos == string.length() )? string : string.substring( leftPos, rightPos ); }
[ "public", "static", "String", "trim", "(", "String", "string", ",", "int", "pos", ")", "{", "int", "len", "=", "string", ".", "length", "(", ")", ";", "int", "leftPos", "=", "pos", ";", "int", "rightPos", "=", "len", ";", "for", "(", ";", "rightPos...
Removes all whitespace characters from the beginning and end of the string starting from the given position.
[ "Removes", "all", "whitespace", "characters", "from", "the", "beginning", "and", "end", "of", "the", "string", "starting", "from", "the", "given", "position", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java#L32-L71
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java
FlatFileUtils.trimRight
public static String trimRight( String string ) { for( int i = string.length(); i > 0; --i ) { if( string.charAt(i-1) != ' ' && string.charAt(i-1) != '\t' && string.charAt(i-1) != '\n' && string.charAt(i-1) != '\r' ) { return i == string.length() ? string : string.substring( 0, i ); } } return ""; }
java
public static String trimRight( String string ) { for( int i = string.length(); i > 0; --i ) { if( string.charAt(i-1) != ' ' && string.charAt(i-1) != '\t' && string.charAt(i-1) != '\n' && string.charAt(i-1) != '\r' ) { return i == string.length() ? string : string.substring( 0, i ); } } return ""; }
[ "public", "static", "String", "trimRight", "(", "String", "string", ")", "{", "for", "(", "int", "i", "=", "string", ".", "length", "(", ")", ";", "i", ">", "0", ";", "--", "i", ")", "{", "if", "(", "string", ".", "charAt", "(", "i", "-", "1", ...
Removes all whitespace characters from the end of the string.
[ "Removes", "all", "whitespace", "characters", "from", "the", "end", "of", "the", "string", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java#L75-L90
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java
FlatFileUtils.trimRight
public static String trimRight( String string, int pos ) { int i = string.length(); for( ; i > pos; --i ) { char charAt = string.charAt( i - 1 ); if( charAt != ' ' && charAt != '\t' && charAt != '\n' && charAt != '\r' ) { break; } } if( i <= pos ) { return ""; } return ( 0 == pos && i == string.length() ) ? string : string.substring( pos, i ); }
java
public static String trimRight( String string, int pos ) { int i = string.length(); for( ; i > pos; --i ) { char charAt = string.charAt( i - 1 ); if( charAt != ' ' && charAt != '\t' && charAt != '\n' && charAt != '\r' ) { break; } } if( i <= pos ) { return ""; } return ( 0 == pos && i == string.length() ) ? string : string.substring( pos, i ); }
[ "public", "static", "String", "trimRight", "(", "String", "string", ",", "int", "pos", ")", "{", "int", "i", "=", "string", ".", "length", "(", ")", ";", "for", "(", ";", "i", ">", "pos", ";", "--", "i", ")", "{", "char", "charAt", "=", "string",...
Removes all whitespace characters from the end of the string starting from the given position.
[ "Removes", "all", "whitespace", "characters", "from", "the", "end", "of", "the", "string", "starting", "from", "the", "given", "position", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java#L95-L118
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java
FlatFileUtils.trimRight
public static String trimRight( String string, char c ) { for( int i = string.length(); i > 0; --i ) { char charAt = string.charAt( i - 1 ); if( charAt != c && charAt != ' ' && charAt != '\t' && charAt != '\n' && charAt != '\r' ) { return i == string.length() ? string : string.substring( 0, i ); } } return ""; }
java
public static String trimRight( String string, char c ) { for( int i = string.length(); i > 0; --i ) { char charAt = string.charAt( i - 1 ); if( charAt != c && charAt != ' ' && charAt != '\t' && charAt != '\n' && charAt != '\r' ) { return i == string.length() ? string : string.substring( 0, i ); } } return ""; }
[ "public", "static", "String", "trimRight", "(", "String", "string", ",", "char", "c", ")", "{", "for", "(", "int", "i", "=", "string", ".", "length", "(", ")", ";", "i", ">", "0", ";", "--", "i", ")", "{", "char", "charAt", "=", "string", ".", ...
Removes all whitespace characters and instances of the given character from the end of the string.
[ "Removes", "all", "whitespace", "characters", "and", "instances", "of", "the", "given", "character", "from", "the", "end", "of", "the", "string", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java#L123-L140
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java
FlatFileUtils.trimLeft
public static String trimLeft( String string ) { for( int i = 0; i < string.length(); ++i ) { char charAt = string.charAt( i ); if( charAt != ' ' && charAt != '\t' && charAt != '\n' && charAt != '\r' ) { return i == 0 ? string : string.substring( i ); } } return string; }
java
public static String trimLeft( String string ) { for( int i = 0; i < string.length(); ++i ) { char charAt = string.charAt( i ); if( charAt != ' ' && charAt != '\t' && charAt != '\n' && charAt != '\r' ) { return i == 0 ? string : string.substring( i ); } } return string; }
[ "public", "static", "String", "trimLeft", "(", "String", "string", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "string", ".", "length", "(", ")", ";", "++", "i", ")", "{", "char", "charAt", "=", "string", ".", "charAt", "(", "i", ...
Removes all whitespace characters from the beginning of the string.
[ "Removes", "all", "whitespace", "characters", "from", "the", "beginning", "of", "the", "string", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java#L145-L161
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java
FlatFileUtils.split
public static Vector<String> split(String string, String regex) { Vector<String> strings = new Vector<String>(); for (String value : string.split(new String(regex))) { value = value.trim(); if (!value.equals("")) { strings.add(shrink(value)); } } return strings; }
java
public static Vector<String> split(String string, String regex) { Vector<String> strings = new Vector<String>(); for (String value : string.split(new String(regex))) { value = value.trim(); if (!value.equals("")) { strings.add(shrink(value)); } } return strings; }
[ "public", "static", "Vector", "<", "String", ">", "split", "(", "String", "string", ",", "String", "regex", ")", "{", "Vector", "<", "String", ">", "strings", "=", "new", "Vector", "<", "String", ">", "(", ")", ";", "for", "(", "String", "value", ":"...
Split the string into values using the regular expression, removes whitespace from the beginning and end of the resultant strings and replaces runs of whitespace with a single space.
[ "Split", "the", "string", "into", "values", "using", "the", "regular", "expression", "removes", "whitespace", "from", "the", "beginning", "and", "end", "of", "the", "resultant", "strings", "and", "replaces", "runs", "of", "whitespace", "with", "a", "single", "...
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java#L190-L199
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java
FlatFileUtils.shrink
public static String shrink(String string) { if (string == null) { return null; } string = string.trim(); return SHRINK.matcher(string).replaceAll(" "); }
java
public static String shrink(String string) { if (string == null) { return null; } string = string.trim(); return SHRINK.matcher(string).replaceAll(" "); }
[ "public", "static", "String", "shrink", "(", "String", "string", ")", "{", "if", "(", "string", "==", "null", ")", "{", "return", "null", ";", "}", "string", "=", "string", ".", "trim", "(", ")", ";", "return", "SHRINK", ".", "matcher", "(", "string"...
Trims the string and replaces runs of whitespace with a single space.
[ "Trims", "the", "string", "and", "replaces", "runs", "of", "whitespace", "with", "a", "single", "space", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java#L205-L211
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java
FlatFileUtils.shrink
public static String shrink(String string, char c) { if (string == null) { return null; } string = string.trim(); Pattern pattern = Pattern.compile("\\" + String.valueOf(c) + "{2,}"); return pattern.matcher(string).replaceAll(String.valueOf(c)); }
java
public static String shrink(String string, char c) { if (string == null) { return null; } string = string.trim(); Pattern pattern = Pattern.compile("\\" + String.valueOf(c) + "{2,}"); return pattern.matcher(string).replaceAll(String.valueOf(c)); }
[ "public", "static", "String", "shrink", "(", "String", "string", ",", "char", "c", ")", "{", "if", "(", "string", "==", "null", ")", "{", "return", "null", ";", "}", "string", "=", "string", ".", "trim", "(", ")", ";", "Pattern", "pattern", "=", "P...
Trims the string and replaces runs of whitespace with a single character.
[ "Trims", "the", "string", "and", "replaces", "runs", "of", "whitespace", "with", "a", "single", "character", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java#L215-L222
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java
FlatFileUtils.remove
public static String remove(String string, char c) { return string.replaceAll(String.valueOf(c), ""); }
java
public static String remove(String string, char c) { return string.replaceAll(String.valueOf(c), ""); }
[ "public", "static", "String", "remove", "(", "String", "string", ",", "char", "c", ")", "{", "return", "string", ".", "replaceAll", "(", "String", ".", "valueOf", "(", "c", ")", ",", "\"\"", ")", ";", "}" ]
Removes the characters from the string.
[ "Removes", "the", "characters", "from", "the", "string", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java#L226-L228
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java
FlatFileUtils.getYear
public static Date getYear(String string) { if (string == null) { return null; } Date date = null; try { date = ((SimpleDateFormat)year.clone()) .parse(string); } catch (ParseException ex) { return null; } return date; }
java
public static Date getYear(String string) { if (string == null) { return null; } Date date = null; try { date = ((SimpleDateFormat)year.clone()) .parse(string); } catch (ParseException ex) { return null; } return date; }
[ "public", "static", "Date", "getYear", "(", "String", "string", ")", "{", "if", "(", "string", "==", "null", ")", "{", "return", "null", ";", "}", "Date", "date", "=", "null", ";", "try", "{", "date", "=", "(", "(", "SimpleDateFormat", ")", "year", ...
Returns the year given a string in format yyyy.
[ "Returns", "the", "year", "given", "a", "string", "in", "format", "yyyy", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/FlatFileUtils.java#L249-L261
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/modules/r/labeler/OmsLabeler.java
OmsLabeler.getNeighbours
private int getNeighbours( int[] src1d, int i, int ox, int oy, int d_w, int d_h ) { int x, y, result; x = (i % d_w) + ox; // d_w and d_h are assumed to be set to the y = (i / d_w) + oy; // width and height of scr1d if ((x < 0) || (x >= d_w) || (y < 0) || (y >= d_h)) { result = 0; } else { result = src1d[y * d_w + x] & 0x000000ff; } return result; }
java
private int getNeighbours( int[] src1d, int i, int ox, int oy, int d_w, int d_h ) { int x, y, result; x = (i % d_w) + ox; // d_w and d_h are assumed to be set to the y = (i / d_w) + oy; // width and height of scr1d if ((x < 0) || (x >= d_w) || (y < 0) || (y >= d_h)) { result = 0; } else { result = src1d[y * d_w + x] & 0x000000ff; } return result; }
[ "private", "int", "getNeighbours", "(", "int", "[", "]", "src1d", ",", "int", "i", ",", "int", "ox", ",", "int", "oy", ",", "int", "d_w", ",", "int", "d_h", ")", "{", "int", "x", ",", "y", ",", "result", ";", "x", "=", "(", "i", "%", "d_w", ...
getNeighbours will get the pixel value of i's neighbour that's ox and oy away from i, if the point is outside the image, then 0 is returned. This version gets from source image. @param d_w @param d_h
[ "getNeighbours", "will", "get", "the", "pixel", "value", "of", "i", "s", "neighbour", "that", "s", "ox", "and", "oy", "away", "from", "i", "if", "the", "point", "is", "outside", "the", "image", "then", "0", "is", "returned", ".", "This", "version", "ge...
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/modules/r/labeler/OmsLabeler.java#L248-L260
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/modules/r/labeler/OmsLabeler.java
OmsLabeler.reduce
private int reduce( int a, int[] labels ) { if (labels[a] == a) { return a; } else { return reduce(labels[a], labels); } }
java
private int reduce( int a, int[] labels ) { if (labels[a] == a) { return a; } else { return reduce(labels[a], labels); } }
[ "private", "int", "reduce", "(", "int", "a", ",", "int", "[", "]", "labels", ")", "{", "if", "(", "labels", "[", "a", "]", "==", "a", ")", "{", "return", "a", ";", "}", "else", "{", "return", "reduce", "(", "labels", "[", "a", "]", ",", "labe...
Reduces the number of labels. @param labels
[ "Reduces", "the", "number", "of", "labels", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/modules/r/labeler/OmsLabeler.java#L312-L318
train
TheHortonMachine/hortonmachine
gears/src/main/java/oms3/util/Annotations.java
Annotations.playsAll
public static boolean playsAll(Role role, String... r) { if (role == null) { return false; } for (String s : r) { if (!role.value().contains(s)) { return false; } } return true; }
java
public static boolean playsAll(Role role, String... r) { if (role == null) { return false; } for (String s : r) { if (!role.value().contains(s)) { return false; } } return true; }
[ "public", "static", "boolean", "playsAll", "(", "Role", "role", ",", "String", "...", "r", ")", "{", "if", "(", "role", "==", "null", ")", "{", "return", "false", ";", "}", "for", "(", "String", "s", ":", "r", ")", "{", "if", "(", "!", "role", ...
Checks if all roles are played. @param role the role to check. @param r the roles that all have to be played @return true or false.
[ "Checks", "if", "all", "roles", "are", "played", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/util/Annotations.java#L25-L35
train
TheHortonMachine/hortonmachine
gears/src/main/java/oms3/util/Annotations.java
Annotations.plays
public static boolean plays(Role role, String r) { if (r == null) { throw new IllegalArgumentException("null role"); } if (role == null) { return false; } return role.value().contains(r); }
java
public static boolean plays(Role role, String r) { if (r == null) { throw new IllegalArgumentException("null role"); } if (role == null) { return false; } return role.value().contains(r); }
[ "public", "static", "boolean", "plays", "(", "Role", "role", ",", "String", "r", ")", "{", "if", "(", "r", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"null role\"", ")", ";", "}", "if", "(", "role", "==", "null", ")", ...
Checks if one role is played. @param role the role to check @param r the expected role @return true or false.
[ "Checks", "if", "one", "role", "is", "played", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/util/Annotations.java#L43-L51
train
TheHortonMachine/hortonmachine
gears/src/main/java/oms3/util/Annotations.java
Annotations.inRange
public static boolean inRange(Range range, double val) { return val >= range.min() && val <= range.max(); }
java
public static boolean inRange(Range range, double val) { return val >= range.min() && val <= range.max(); }
[ "public", "static", "boolean", "inRange", "(", "Range", "range", ",", "double", "val", ")", "{", "return", "val", ">=", "range", ".", "min", "(", ")", "&&", "val", "<=", "range", ".", "max", "(", ")", ";", "}" ]
Check if a certain value is in range @param range range info @param val the value to check; @return true if it is in range, false otherwise.
[ "Check", "if", "a", "certain", "value", "is", "in", "range" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/util/Annotations.java#L87-L89
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/reader/EntryReader.java
EntryReader.close
public void close() { entry.close(); getBlockCounter().clear(); getSkipTagCounter().clear(); getCache().resetOrganismCache(); getCache().resetReferenceCache(); }
java
public void close() { entry.close(); getBlockCounter().clear(); getSkipTagCounter().clear(); getCache().resetOrganismCache(); getCache().resetReferenceCache(); }
[ "public", "void", "close", "(", ")", "{", "entry", ".", "close", "(", ")", ";", "getBlockCounter", "(", ")", ".", "clear", "(", ")", ";", "getSkipTagCounter", "(", ")", ".", "clear", "(", ")", ";", "getCache", "(", ")", ".", "resetOrganismCache", "("...
Release resources used by the reader. Help the GC to cleanup the heap
[ "Release", "resources", "used", "by", "the", "reader", ".", "Help", "the", "GC", "to", "cleanup", "the", "heap" ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/reader/EntryReader.java#L302-L308
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/GrassLegacyUtilities.java
GrassLegacyUtilities.ByteBufferImage
public static BufferedImage ByteBufferImage( byte[] data, int width, int height ) { int[] bandoffsets = {0, 1, 2, 3}; DataBufferByte dbb = new DataBufferByte(data, data.length); WritableRaster wr = Raster.createInterleavedRaster(dbb, width, height, width * 4, 4, bandoffsets, null); int[] bitfield = {8, 8, 8, 8}; ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); ColorModel cm = new ComponentColorModel(cs, bitfield, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); return new BufferedImage(cm, wr, false, null); }
java
public static BufferedImage ByteBufferImage( byte[] data, int width, int height ) { int[] bandoffsets = {0, 1, 2, 3}; DataBufferByte dbb = new DataBufferByte(data, data.length); WritableRaster wr = Raster.createInterleavedRaster(dbb, width, height, width * 4, 4, bandoffsets, null); int[] bitfield = {8, 8, 8, 8}; ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); ColorModel cm = new ComponentColorModel(cs, bitfield, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); return new BufferedImage(cm, wr, false, null); }
[ "public", "static", "BufferedImage", "ByteBufferImage", "(", "byte", "[", "]", "data", ",", "int", "width", ",", "int", "height", ")", "{", "int", "[", "]", "bandoffsets", "=", "{", "0", ",", "1", ",", "2", ",", "3", "}", ";", "DataBufferByte", "dbb"...
create a buffered image from a set of color triplets @param data @param width @param height @return
[ "create", "a", "buffered", "image", "from", "a", "set", "of", "color", "triplets" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/GrassLegacyUtilities.java#L322-L332
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/GrassLegacyUtilities.java
GrassLegacyUtilities.getRectangleAroundPoint
public static Window getRectangleAroundPoint( Window activeRegion, double x, double y ) { double minx = activeRegion.getRectangle().getBounds2D().getMinX(); double ewres = activeRegion.getWEResolution(); double snapx = minx + (Math.round((x - minx) / ewres) * ewres); double miny = activeRegion.getRectangle().getBounds2D().getMinY(); double nsres = activeRegion.getNSResolution(); double snapy = miny + (Math.round((y - miny) / nsres) * nsres); double xmin = 0.0; double xmax = 0.0; double ymin = 0.0; double ymax = 0.0; if (x >= snapx) { xmin = snapx; xmax = xmin + ewres; } else { xmax = snapx; xmin = xmax - ewres; } if (y <= snapy) { ymax = snapy; ymin = ymax - nsres; } else { ymin = snapy; ymax = ymin + nsres; } // why do I have to put ymin, Rectangle requires the upper left // corner?????!!!! Is it a BUG // in the Rectangle2D class? or docu? // Rectangle2D rect = new Rectangle2D.Double(xmin, ymin, ewres, nsres); return new Window(xmin, xmax, ymin, ymax, 1, 1); }
java
public static Window getRectangleAroundPoint( Window activeRegion, double x, double y ) { double minx = activeRegion.getRectangle().getBounds2D().getMinX(); double ewres = activeRegion.getWEResolution(); double snapx = minx + (Math.round((x - minx) / ewres) * ewres); double miny = activeRegion.getRectangle().getBounds2D().getMinY(); double nsres = activeRegion.getNSResolution(); double snapy = miny + (Math.round((y - miny) / nsres) * nsres); double xmin = 0.0; double xmax = 0.0; double ymin = 0.0; double ymax = 0.0; if (x >= snapx) { xmin = snapx; xmax = xmin + ewres; } else { xmax = snapx; xmin = xmax - ewres; } if (y <= snapy) { ymax = snapy; ymin = ymax - nsres; } else { ymin = snapy; ymax = ymin + nsres; } // why do I have to put ymin, Rectangle requires the upper left // corner?????!!!! Is it a BUG // in the Rectangle2D class? or docu? // Rectangle2D rect = new Rectangle2D.Double(xmin, ymin, ewres, nsres); return new Window(xmin, xmax, ymin, ymax, 1, 1); }
[ "public", "static", "Window", "getRectangleAroundPoint", "(", "Window", "activeRegion", ",", "double", "x", ",", "double", "y", ")", "{", "double", "minx", "=", "activeRegion", ".", "getRectangle", "(", ")", ".", "getBounds2D", "(", ")", ".", "getMinX", "(",...
return the rectangle of the cell of the active region, that surrounds the given coordinates @param activeRegion @param x the given easting coordinate @param y given northing coordinate @return the rectangle localizing the cell inside which the x and y stay
[ "return", "the", "rectangle", "of", "the", "cell", "of", "the", "active", "region", "that", "surrounds", "the", "given", "coordinates" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/GrassLegacyUtilities.java#L357-L392
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/GrassLegacyUtilities.java
GrassLegacyUtilities.rasterizePolygonGeometry
public static void rasterizePolygonGeometry( Window active, Geometry polygon, RasterData raster, RasterData rasterToMap, double value, IHMProgressMonitor monitor ) { GeometryFactory gFactory = new GeometryFactory(); int rows = active.getRows(); int cols = active.getCols(); double delta = active.getWEResolution() / 4.0; monitor.beginTask("rasterizing...", rows); //$NON-NLS-1$ for( int i = 0; i < rows; i++ ) { monitor.worked(1); // do scan line to fill the polygon Coordinate west = rowColToCenterCoordinates(active, i, 0); Coordinate east = rowColToCenterCoordinates(active, i, cols - 1); LineString line = gFactory.createLineString(new Coordinate[]{west, east}); if (polygon.intersects(line)) { Geometry internalLines = polygon.intersection(line); Coordinate[] coords = internalLines.getCoordinates(); for( int j = 0; j < coords.length; j = j + 2 ) { Coordinate startC = new Coordinate(coords[j].x + delta, coords[j].y); Coordinate endC = new Coordinate(coords[j + 1].x - delta, coords[j + 1].y); int[] startcol = coordinateToNearestRowCol(active, startC); int[] endcol = coordinateToNearestRowCol(active, endC); if (startcol == null || endcol == null) { // vertex is outside of the region, ignore it continue; } /* * the part in between has to be filled */ for( int k = startcol[1]; k <= endcol[1]; k++ ) { if (rasterToMap != null) { raster.setValueAt(i, k, rasterToMap.getValueAt(i, k)); } else { raster.setValueAt(i, k, value); } } } } } }
java
public static void rasterizePolygonGeometry( Window active, Geometry polygon, RasterData raster, RasterData rasterToMap, double value, IHMProgressMonitor monitor ) { GeometryFactory gFactory = new GeometryFactory(); int rows = active.getRows(); int cols = active.getCols(); double delta = active.getWEResolution() / 4.0; monitor.beginTask("rasterizing...", rows); //$NON-NLS-1$ for( int i = 0; i < rows; i++ ) { monitor.worked(1); // do scan line to fill the polygon Coordinate west = rowColToCenterCoordinates(active, i, 0); Coordinate east = rowColToCenterCoordinates(active, i, cols - 1); LineString line = gFactory.createLineString(new Coordinate[]{west, east}); if (polygon.intersects(line)) { Geometry internalLines = polygon.intersection(line); Coordinate[] coords = internalLines.getCoordinates(); for( int j = 0; j < coords.length; j = j + 2 ) { Coordinate startC = new Coordinate(coords[j].x + delta, coords[j].y); Coordinate endC = new Coordinate(coords[j + 1].x - delta, coords[j + 1].y); int[] startcol = coordinateToNearestRowCol(active, startC); int[] endcol = coordinateToNearestRowCol(active, endC); if (startcol == null || endcol == null) { // vertex is outside of the region, ignore it continue; } /* * the part in between has to be filled */ for( int k = startcol[1]; k <= endcol[1]; k++ ) { if (rasterToMap != null) { raster.setValueAt(i, k, rasterToMap.getValueAt(i, k)); } else { raster.setValueAt(i, k, value); } } } } } }
[ "public", "static", "void", "rasterizePolygonGeometry", "(", "Window", "active", ",", "Geometry", "polygon", ",", "RasterData", "raster", ",", "RasterData", "rasterToMap", ",", "double", "value", ",", "IHMProgressMonitor", "monitor", ")", "{", "GeometryFactory", "gF...
Fill polygon areas mapping on a raster @param active the active region @param polygon the jts polygon geometry @param raster the empty raster data to be filled @param rasterToMap the map from which the values to fill raster are taken (if null, the value parameter is used) @param value the value to set if a second map is not given @param monitor
[ "Fill", "polygon", "areas", "mapping", "on", "a", "raster" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/GrassLegacyUtilities.java#L577-L618
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/GrassLegacyUtilities.java
GrassLegacyUtilities.removeGrassRasterMap
public static boolean removeGrassRasterMap( String mapsetPath, String mapName ) throws IOException { // list of files to remove String mappaths[] = filesOfRasterMap(mapsetPath, mapName); // first delete the list above, which are just files for( int j = 0; j < mappaths.length; j++ ) { File filetoremove = new File(mappaths[j]); if (filetoremove.exists()) { if (!FileUtilities.deleteFileOrDir(filetoremove)) { return false; } } } return true; }
java
public static boolean removeGrassRasterMap( String mapsetPath, String mapName ) throws IOException { // list of files to remove String mappaths[] = filesOfRasterMap(mapsetPath, mapName); // first delete the list above, which are just files for( int j = 0; j < mappaths.length; j++ ) { File filetoremove = new File(mappaths[j]); if (filetoremove.exists()) { if (!FileUtilities.deleteFileOrDir(filetoremove)) { return false; } } } return true; }
[ "public", "static", "boolean", "removeGrassRasterMap", "(", "String", "mapsetPath", ",", "String", "mapName", ")", "throws", "IOException", "{", "// list of files to remove", "String", "mappaths", "[", "]", "=", "filesOfRasterMap", "(", "mapsetPath", ",", "mapName", ...
Given the mapsetpath and the mapname, the map is removed with all its accessor files @param mapsetPath @param mapName @throws IOException
[ "Given", "the", "mapsetpath", "and", "the", "mapname", "the", "map", "is", "removed", "with", "all", "its", "accessor", "files" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/GrassLegacyUtilities.java#L658-L673
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/GrassLegacyUtilities.java
GrassLegacyUtilities.rowColToNodeboundCoordinates
public static double[] rowColToNodeboundCoordinates( Window active, int row, int col ) { double anorth = active.getNorth(); double awest = active.getWest(); double nsres = active.getNSResolution(); double ewres = active.getWEResolution(); double[] nsew = new double[4]; nsew[0] = anorth - row * nsres; nsew[1] = anorth - row * nsres - nsres; nsew[2] = awest + col * ewres + ewres; nsew[3] = awest + col * ewres; return nsew; }
java
public static double[] rowColToNodeboundCoordinates( Window active, int row, int col ) { double anorth = active.getNorth(); double awest = active.getWest(); double nsres = active.getNSResolution(); double ewres = active.getWEResolution(); double[] nsew = new double[4]; nsew[0] = anorth - row * nsres; nsew[1] = anorth - row * nsres - nsres; nsew[2] = awest + col * ewres + ewres; nsew[3] = awest + col * ewres; return nsew; }
[ "public", "static", "double", "[", "]", "rowColToNodeboundCoordinates", "(", "Window", "active", ",", "int", "row", ",", "int", "col", ")", "{", "double", "anorth", "=", "active", ".", "getNorth", "(", ")", ";", "double", "awest", "=", "active", ".", "ge...
Transforms row and column index of the active region into an array of the coordinates of the edgaes, i.e. n, s, e, w @param active - the active region (can be null) @param row - row number of the point to transform @param col - column number of the point to transform @return the array of north, south, east, west
[ "Transforms", "row", "and", "column", "index", "of", "the", "active", "region", "into", "an", "array", "of", "the", "coordinates", "of", "the", "edgaes", "i", ".", "e", ".", "n", "s", "e", "w" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/GrassLegacyUtilities.java#L713-L727
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/utils/AcadExtrusionCalculator.java
AcadExtrusionCalculator.CalculateAcadExtrusion
public static double[] CalculateAcadExtrusion(double[] coord_in, double[] xtru) { double[] coord_out; double dxt0 = 0D, dyt0 = 0D, dzt0 = 0D; double dvx1, dvx2, dvx3; double dvy1, dvy2, dvy3; double dmod, dxt, dyt, dzt; double aux = 1D/64D; double aux1 = Math.abs(xtru[0]); double aux2 = Math.abs(xtru[1]); dxt0 = coord_in[0]; dyt0 = coord_in[1]; dzt0 = coord_in[2]; double xtruX, xtruY, xtruZ; xtruX = xtru[0]; xtruY = xtru[1]; xtruZ = xtru[2]; if ((aux1 < aux) && (aux2 < aux)) { dmod = Math.sqrt(xtruZ*xtruZ + xtruX*xtruX); dvx1 = xtruZ / dmod; dvx2 = 0; dvx3 = -xtruX / dmod; } else { dmod = Math.sqrt(xtruY*xtruY + xtruX*xtruX); dvx1 = -xtruY / dmod; dvx2 = xtruX / dmod; dvx3 = 0; } dvy1 = xtruY*dvx3 - xtruZ*dvx2; dvy2 = xtruZ*dvx1 - xtruX*dvx3; dvy3 = xtruX*dvx2 - xtruY*dvx1; dmod = Math.sqrt(dvy1*dvy1 + dvy2*dvy2 + dvy3*dvy3); dvy1 = dvy1 / dmod; dvy2 = dvy2 / dmod; dvy3 = dvy3 / dmod; dxt = dvx1*dxt0 + dvy1*dyt0 + xtruX*dzt0; dyt = dvx2*dxt0 + dvy2*dyt0 + xtruY*dzt0; dzt = dvx3*dxt0 + dvy3*dyt0 + xtruZ*dzt0; coord_out = new double[]{dxt, dyt, dzt}; dxt0 = 0; dyt0 = 0; dzt0 = 0; return coord_out; }
java
public static double[] CalculateAcadExtrusion(double[] coord_in, double[] xtru) { double[] coord_out; double dxt0 = 0D, dyt0 = 0D, dzt0 = 0D; double dvx1, dvx2, dvx3; double dvy1, dvy2, dvy3; double dmod, dxt, dyt, dzt; double aux = 1D/64D; double aux1 = Math.abs(xtru[0]); double aux2 = Math.abs(xtru[1]); dxt0 = coord_in[0]; dyt0 = coord_in[1]; dzt0 = coord_in[2]; double xtruX, xtruY, xtruZ; xtruX = xtru[0]; xtruY = xtru[1]; xtruZ = xtru[2]; if ((aux1 < aux) && (aux2 < aux)) { dmod = Math.sqrt(xtruZ*xtruZ + xtruX*xtruX); dvx1 = xtruZ / dmod; dvx2 = 0; dvx3 = -xtruX / dmod; } else { dmod = Math.sqrt(xtruY*xtruY + xtruX*xtruX); dvx1 = -xtruY / dmod; dvx2 = xtruX / dmod; dvx3 = 0; } dvy1 = xtruY*dvx3 - xtruZ*dvx2; dvy2 = xtruZ*dvx1 - xtruX*dvx3; dvy3 = xtruX*dvx2 - xtruY*dvx1; dmod = Math.sqrt(dvy1*dvy1 + dvy2*dvy2 + dvy3*dvy3); dvy1 = dvy1 / dmod; dvy2 = dvy2 / dmod; dvy3 = dvy3 / dmod; dxt = dvx1*dxt0 + dvy1*dyt0 + xtruX*dzt0; dyt = dvx2*dxt0 + dvy2*dyt0 + xtruY*dzt0; dzt = dvx3*dxt0 + dvy3*dyt0 + xtruZ*dzt0; coord_out = new double[]{dxt, dyt, dzt}; dxt0 = 0; dyt0 = 0; dzt0 = 0; return coord_out; }
[ "public", "static", "double", "[", "]", "CalculateAcadExtrusion", "(", "double", "[", "]", "coord_in", ",", "double", "[", "]", "xtru", ")", "{", "double", "[", "]", "coord_out", ";", "double", "dxt0", "=", "0D", ",", "dyt0", "=", "0D", ",", "dzt0", ...
Method that allows to apply the extrusion transformation of Autocad @param coord_in Array of doubles that represents the input coordinates @param xtru array of doubles that contanins the extrusion parameters @return double[] Is the result of the application of the extrusion transformation to the input point
[ "Method", "that", "allows", "to", "apply", "the", "extrusion", "transformation", "of", "Autocad" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/utils/AcadExtrusionCalculator.java#L40-L94
train
TheHortonMachine/hortonmachine
dbs/src/main/java/org/hortonmachine/dbs/spatialite/hm/SpatialiteDb.java
SpatialiteDb.deleteGeoTable
public void deleteGeoTable( String tableName ) throws Exception { String sql = "SELECT DropGeoTable('" + tableName + "');"; try (IHMStatement stmt = mConn.createStatement()) { stmt.execute(sql); } }
java
public void deleteGeoTable( String tableName ) throws Exception { String sql = "SELECT DropGeoTable('" + tableName + "');"; try (IHMStatement stmt = mConn.createStatement()) { stmt.execute(sql); } }
[ "public", "void", "deleteGeoTable", "(", "String", "tableName", ")", "throws", "Exception", "{", "String", "sql", "=", "\"SELECT DropGeoTable('\"", "+", "tableName", "+", "\"');\"", ";", "try", "(", "IHMStatement", "stmt", "=", "mConn", ".", "createStatement", "...
Delete a geo-table with all attached indexes and stuff. @param tableName @throws Exception
[ "Delete", "a", "geo", "-", "table", "with", "all", "attached", "indexes", "and", "stuff", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/dbs/spatialite/hm/SpatialiteDb.java#L294-L300
train
TheHortonMachine/hortonmachine
dbs/src/main/java/org/hortonmachine/dbs/spatialite/hm/SpatialiteDb.java
SpatialiteDb.runRawSqlToCsv
public void runRawSqlToCsv( String sql, File csvFile, boolean doHeader, String separator ) throws Exception { try (BufferedWriter bw = new BufferedWriter(new FileWriter(csvFile))) { SpatialiteWKBReader wkbReader = new SpatialiteWKBReader(); try (IHMStatement stmt = mConn.createStatement(); IHMResultSet rs = stmt.executeQuery(sql)) { IHMResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); int geometryIndex = -1; for( int i = 1; i <= columnCount; i++ ) { if (i > 1) { bw.write(separator); } String columnTypeName = rsmd.getColumnTypeName(i); String columnName = rsmd.getColumnName(i); bw.write(columnName); if (ESpatialiteGeometryType.isGeometryName(columnTypeName)) { geometryIndex = i; } } bw.write("\n"); while( rs.next() ) { for( int j = 1; j <= columnCount; j++ ) { if (j > 1) { bw.write(separator); } byte[] geomBytes = null; if (j == geometryIndex) { geomBytes = rs.getBytes(j); } if (geomBytes != null) { try { Geometry geometry = wkbReader.read(geomBytes); bw.write(geometry.toText()); } catch (Exception e) { // write it as it comes Object object = rs.getObject(j); if (object instanceof Clob) { object = rs.getString(j); } if (object != null) { bw.write(object.toString()); } else { bw.write(""); } } } else { Object object = rs.getObject(j); if (object instanceof Clob) { object = rs.getString(j); } if (object != null) { bw.write(object.toString()); } else { bw.write(""); } } } bw.write("\n"); } } } }
java
public void runRawSqlToCsv( String sql, File csvFile, boolean doHeader, String separator ) throws Exception { try (BufferedWriter bw = new BufferedWriter(new FileWriter(csvFile))) { SpatialiteWKBReader wkbReader = new SpatialiteWKBReader(); try (IHMStatement stmt = mConn.createStatement(); IHMResultSet rs = stmt.executeQuery(sql)) { IHMResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); int geometryIndex = -1; for( int i = 1; i <= columnCount; i++ ) { if (i > 1) { bw.write(separator); } String columnTypeName = rsmd.getColumnTypeName(i); String columnName = rsmd.getColumnName(i); bw.write(columnName); if (ESpatialiteGeometryType.isGeometryName(columnTypeName)) { geometryIndex = i; } } bw.write("\n"); while( rs.next() ) { for( int j = 1; j <= columnCount; j++ ) { if (j > 1) { bw.write(separator); } byte[] geomBytes = null; if (j == geometryIndex) { geomBytes = rs.getBytes(j); } if (geomBytes != null) { try { Geometry geometry = wkbReader.read(geomBytes); bw.write(geometry.toText()); } catch (Exception e) { // write it as it comes Object object = rs.getObject(j); if (object instanceof Clob) { object = rs.getString(j); } if (object != null) { bw.write(object.toString()); } else { bw.write(""); } } } else { Object object = rs.getObject(j); if (object instanceof Clob) { object = rs.getString(j); } if (object != null) { bw.write(object.toString()); } else { bw.write(""); } } } bw.write("\n"); } } } }
[ "public", "void", "runRawSqlToCsv", "(", "String", "sql", ",", "File", "csvFile", ",", "boolean", "doHeader", ",", "String", "separator", ")", "throws", "Exception", "{", "try", "(", "BufferedWriter", "bw", "=", "new", "BufferedWriter", "(", "new", "FileWriter...
Execute a query from raw sql and put the result in a csv file. @param sql the sql to run. @param csvFile the output file. @param doHeader if <code>true</code>, the header is written. @param separator the separator (if null, ";" is used). @throws Exception
[ "Execute", "a", "query", "from", "raw", "sql", "and", "put", "the", "result", "in", "a", "csv", "file", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/dbs/spatialite/hm/SpatialiteDb.java#L372-L432
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java
DwgFile.read
public void read() throws IOException { System.out.println("DwgFile.read() executed ..."); setDwgVersion(); if (dwgVersion.equals("R13")) { dwgReader = new DwgFileV14Reader(); dwgReader.read(this); } else if (dwgVersion.equals("R14")) { dwgReader = new DwgFileV14Reader(); dwgReader.read(this); } else if (dwgVersion.equals("R15")) { dwgReader = new DwgFileV15Reader(); dwgReader.read(this); } else if (dwgVersion.equals("Unknown")) { throw new IOException("DWG version of the file is not supported."); } }
java
public void read() throws IOException { System.out.println("DwgFile.read() executed ..."); setDwgVersion(); if (dwgVersion.equals("R13")) { dwgReader = new DwgFileV14Reader(); dwgReader.read(this); } else if (dwgVersion.equals("R14")) { dwgReader = new DwgFileV14Reader(); dwgReader.read(this); } else if (dwgVersion.equals("R15")) { dwgReader = new DwgFileV15Reader(); dwgReader.read(this); } else if (dwgVersion.equals("Unknown")) { throw new IOException("DWG version of the file is not supported."); } }
[ "public", "void", "read", "(", ")", "throws", "IOException", "{", "System", ".", "out", ".", "println", "(", "\"DwgFile.read() executed ...\"", ")", ";", "setDwgVersion", "(", ")", ";", "if", "(", "dwgVersion", ".", "equals", "(", "\"R13\"", ")", ")", "{",...
Reads a DWG file and put its objects in the dwgObjects Vector This method is version independent @throws IOException If the file location is wrong
[ "Reads", "a", "DWG", "file", "and", "put", "its", "objects", "in", "the", "dwgObjects", "Vector", "This", "method", "is", "version", "independent" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java#L99-L114
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java
DwgFile.calculateCadModelDwgPolylines
public void calculateCadModelDwgPolylines() { for( int i = 0; i < dwgObjects.size(); i++ ) { DwgObject pol = (DwgObject) dwgObjects.get(i); if (pol instanceof DwgPolyline2D) { int flags = ((DwgPolyline2D) pol).getFlags(); int firstHandle = ((DwgPolyline2D) pol).getFirstVertexHandle(); int lastHandle = ((DwgPolyline2D) pol).getLastVertexHandle(); Vector pts = new Vector(); Vector bulges = new Vector(); double[] pt = new double[3]; for( int j = 0; j < dwgObjects.size(); j++ ) { DwgObject firstVertex = (DwgObject) dwgObjects.get(j); if (firstVertex instanceof DwgVertex2D) { int vertexHandle = firstVertex.getHandle(); if (vertexHandle == firstHandle) { int k = 0; while( true ) { DwgObject vertex = (DwgObject) dwgObjects.get(j + k); int vHandle = vertex.getHandle(); if (vertex instanceof DwgVertex2D) { pt = ((DwgVertex2D) vertex).getPoint(); pts.add(new Point2D.Double(pt[0], pt[1])); double bulge = ((DwgVertex2D) vertex).getBulge(); bulges.add(new Double(bulge)); k++; if (vHandle == lastHandle && vertex instanceof DwgVertex2D) { break; } } else if (vertex instanceof DwgSeqend) { break; } } } } } if (pts.size() > 0) { /*Point2D[] newPts = new Point2D[pts.size()]; if ((flags & 0x1)==0x1) { newPts = new Point2D[pts.size()+1]; for (int j=0;j<pts.size();j++) { newPts[j] = (Point2D)pts.get(j); } newPts[pts.size()] = (Point2D)pts.get(0); bulges.add(new Double(0)); } else { for (int j=0;j<pts.size();j++) { newPts[j] = (Point2D)pts.get(j); } }*/ double[] bs = new double[bulges.size()]; for( int j = 0; j < bulges.size(); j++ ) { bs[j] = ((Double) bulges.get(j)).doubleValue(); } ((DwgPolyline2D) pol).setBulges(bs); // Point2D[] points = GisModelCurveCalculator.calculateGisModelBulge(newPts, // bs); Point2D[] points = new Point2D[pts.size()]; for( int j = 0; j < pts.size(); j++ ) { points[j] = (Point2D) pts.get(j); } ((DwgPolyline2D) pol).setPts(points); } else { // System.out.println("Encontrada polil�nea sin puntos ..."); // TODO: No se debe mandar nunca una polil�nea sin puntos, si esto // ocurre es porque existe un error que hay que corregir ... } } else if (pol instanceof DwgPolyline3D) { } else if (pol instanceof DwgLwPolyline && ((DwgLwPolyline) pol).getVertices() != null) { } } }
java
public void calculateCadModelDwgPolylines() { for( int i = 0; i < dwgObjects.size(); i++ ) { DwgObject pol = (DwgObject) dwgObjects.get(i); if (pol instanceof DwgPolyline2D) { int flags = ((DwgPolyline2D) pol).getFlags(); int firstHandle = ((DwgPolyline2D) pol).getFirstVertexHandle(); int lastHandle = ((DwgPolyline2D) pol).getLastVertexHandle(); Vector pts = new Vector(); Vector bulges = new Vector(); double[] pt = new double[3]; for( int j = 0; j < dwgObjects.size(); j++ ) { DwgObject firstVertex = (DwgObject) dwgObjects.get(j); if (firstVertex instanceof DwgVertex2D) { int vertexHandle = firstVertex.getHandle(); if (vertexHandle == firstHandle) { int k = 0; while( true ) { DwgObject vertex = (DwgObject) dwgObjects.get(j + k); int vHandle = vertex.getHandle(); if (vertex instanceof DwgVertex2D) { pt = ((DwgVertex2D) vertex).getPoint(); pts.add(new Point2D.Double(pt[0], pt[1])); double bulge = ((DwgVertex2D) vertex).getBulge(); bulges.add(new Double(bulge)); k++; if (vHandle == lastHandle && vertex instanceof DwgVertex2D) { break; } } else if (vertex instanceof DwgSeqend) { break; } } } } } if (pts.size() > 0) { /*Point2D[] newPts = new Point2D[pts.size()]; if ((flags & 0x1)==0x1) { newPts = new Point2D[pts.size()+1]; for (int j=0;j<pts.size();j++) { newPts[j] = (Point2D)pts.get(j); } newPts[pts.size()] = (Point2D)pts.get(0); bulges.add(new Double(0)); } else { for (int j=0;j<pts.size();j++) { newPts[j] = (Point2D)pts.get(j); } }*/ double[] bs = new double[bulges.size()]; for( int j = 0; j < bulges.size(); j++ ) { bs[j] = ((Double) bulges.get(j)).doubleValue(); } ((DwgPolyline2D) pol).setBulges(bs); // Point2D[] points = GisModelCurveCalculator.calculateGisModelBulge(newPts, // bs); Point2D[] points = new Point2D[pts.size()]; for( int j = 0; j < pts.size(); j++ ) { points[j] = (Point2D) pts.get(j); } ((DwgPolyline2D) pol).setPts(points); } else { // System.out.println("Encontrada polil�nea sin puntos ..."); // TODO: No se debe mandar nunca una polil�nea sin puntos, si esto // ocurre es porque existe un error que hay que corregir ... } } else if (pol instanceof DwgPolyline3D) { } else if (pol instanceof DwgLwPolyline && ((DwgLwPolyline) pol).getVertices() != null) { } } }
[ "public", "void", "calculateCadModelDwgPolylines", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dwgObjects", ".", "size", "(", ")", ";", "i", "++", ")", "{", "DwgObject", "pol", "=", "(", "DwgObject", ")", "dwgObjects", ".", "get"...
Configure the geometry of the polylines in a DWG file from the vertex list in this DWG file. This geometry is given by an array of Points Besides, manage closed polylines and polylines with bulges in a GIS Data model. It means that the arcs of the polylines will be done through a curvature parameter called bulge associated with the points of the polyline.
[ "Configure", "the", "geometry", "of", "the", "polylines", "in", "a", "DWG", "file", "from", "the", "vertex", "list", "in", "this", "DWG", "file", ".", "This", "geometry", "is", "given", "by", "an", "array", "of", "Points", "Besides", "manage", "closed", ...
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java#L434-L504
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java
DwgFile.blockManagement
public void blockManagement() { Vector dwgObjectsWithoutBlocks = new Vector(); boolean addingToBlock = false; for( int i = 0; i < dwgObjects.size(); i++ ) { try { DwgObject entity = (DwgObject) dwgObjects.get(i); if (entity instanceof DwgArc && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgEllipse && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgCircle && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgPolyline2D && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgPolyline3D && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgLwPolyline && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgSolid && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgLine && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgPoint && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgMText && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgText && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgAttrib && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgAttdef && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgBlock) { addingToBlock = true; } else if (entity instanceof DwgEndblk) { addingToBlock = false; } else if (entity instanceof DwgBlockHeader) { addingToBlock = true; } else if (entity instanceof DwgInsert && !addingToBlock) { /* double[] p = ((DwgInsert) entity).getInsertionPoint(); Point2D point = new Point2D.Double(p[0], p[1]); double[] scale = ((DwgInsert) entity).getScale(); double rot = ((DwgInsert) entity).getRotation(); int blockHandle = ((DwgInsert) entity).getBlockHeaderHandle(); manageInsert(point, scale, rot, blockHandle, i, dwgObjectsWithoutBlocks);*/ } else { // System.out.println("Detectado dwgObject pendiente de implementar"); } } catch (StackOverflowError e) { e.printStackTrace(); System.out.println("Overflowerror at object: " + i); } } dwgObjects = dwgObjectsWithoutBlocks; }
java
public void blockManagement() { Vector dwgObjectsWithoutBlocks = new Vector(); boolean addingToBlock = false; for( int i = 0; i < dwgObjects.size(); i++ ) { try { DwgObject entity = (DwgObject) dwgObjects.get(i); if (entity instanceof DwgArc && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgEllipse && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgCircle && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgPolyline2D && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgPolyline3D && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgLwPolyline && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgSolid && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgLine && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgPoint && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgMText && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgText && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgAttrib && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgAttdef && !addingToBlock) { dwgObjectsWithoutBlocks.add(entity); } else if (entity instanceof DwgBlock) { addingToBlock = true; } else if (entity instanceof DwgEndblk) { addingToBlock = false; } else if (entity instanceof DwgBlockHeader) { addingToBlock = true; } else if (entity instanceof DwgInsert && !addingToBlock) { /* double[] p = ((DwgInsert) entity).getInsertionPoint(); Point2D point = new Point2D.Double(p[0], p[1]); double[] scale = ((DwgInsert) entity).getScale(); double rot = ((DwgInsert) entity).getRotation(); int blockHandle = ((DwgInsert) entity).getBlockHeaderHandle(); manageInsert(point, scale, rot, blockHandle, i, dwgObjectsWithoutBlocks);*/ } else { // System.out.println("Detectado dwgObject pendiente de implementar"); } } catch (StackOverflowError e) { e.printStackTrace(); System.out.println("Overflowerror at object: " + i); } } dwgObjects = dwgObjectsWithoutBlocks; }
[ "public", "void", "blockManagement", "(", ")", "{", "Vector", "dwgObjectsWithoutBlocks", "=", "new", "Vector", "(", ")", ";", "boolean", "addingToBlock", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dwgObjects", ".", "size", "(", ...
Modify the geometry of the objects contained in the blocks of a DWG file and add these objects to the DWG object list.
[ "Modify", "the", "geometry", "of", "the", "objects", "contained", "in", "the", "blocks", "of", "a", "DWG", "file", "and", "add", "these", "objects", "to", "the", "DWG", "object", "list", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java#L510-L565
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java
DwgFile.initializeLayerTable
public void initializeLayerTable() { layerTable = new Vector(); layerNames = new Vector(); for( int i = 0; i < dwgObjects.size(); i++ ) { DwgObject obj = (DwgObject) dwgObjects.get(i); if (obj instanceof DwgLayer) { Vector layerTableRecord = new Vector(); layerTableRecord.add(new Integer(obj.getHandle())); layerTableRecord.add(((DwgLayer) obj).getName()); layerTableRecord.add(new Integer(((DwgLayer) obj).getColor())); layerTable.add(layerTableRecord); layerNames.add(((DwgLayer) obj).getName()); } } System.out.println(""); }
java
public void initializeLayerTable() { layerTable = new Vector(); layerNames = new Vector(); for( int i = 0; i < dwgObjects.size(); i++ ) { DwgObject obj = (DwgObject) dwgObjects.get(i); if (obj instanceof DwgLayer) { Vector layerTableRecord = new Vector(); layerTableRecord.add(new Integer(obj.getHandle())); layerTableRecord.add(((DwgLayer) obj).getName()); layerTableRecord.add(new Integer(((DwgLayer) obj).getColor())); layerTable.add(layerTableRecord); layerNames.add(((DwgLayer) obj).getName()); } } System.out.println(""); }
[ "public", "void", "initializeLayerTable", "(", ")", "{", "layerTable", "=", "new", "Vector", "(", ")", ";", "layerNames", "=", "new", "Vector", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dwgObjects", ".", "size", "(", ")", ";"...
Initialize a new Vector that contains the DWG file layers. Each layer have three parameters. These parameters are handle, name and color
[ "Initialize", "a", "new", "Vector", "that", "contains", "the", "DWG", "file", "layers", ".", "Each", "layer", "have", "three", "parameters", ".", "These", "parameters", "are", "handle", "name", "and", "color" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java#L928-L943
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java
DwgFile.getColorByLayer
public int getColorByLayer( DwgObject entity ) { int colorByLayer = 0; int layer = entity.getLayerHandle(); for( int j = 0; j < layerTable.size(); j++ ) { Vector layerTableRecord = (Vector) layerTable.get(j); int lHandle = ((Integer) layerTableRecord.get(0)).intValue(); if (lHandle == layer) { colorByLayer = ((Integer) layerTableRecord.get(2)).intValue(); } } return colorByLayer; }
java
public int getColorByLayer( DwgObject entity ) { int colorByLayer = 0; int layer = entity.getLayerHandle(); for( int j = 0; j < layerTable.size(); j++ ) { Vector layerTableRecord = (Vector) layerTable.get(j); int lHandle = ((Integer) layerTableRecord.get(0)).intValue(); if (lHandle == layer) { colorByLayer = ((Integer) layerTableRecord.get(2)).intValue(); } } return colorByLayer; }
[ "public", "int", "getColorByLayer", "(", "DwgObject", "entity", ")", "{", "int", "colorByLayer", "=", "0", ";", "int", "layer", "=", "entity", ".", "getLayerHandle", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "layerTable", ".", "...
Returns the color of the layer of a DWG object @param entity DWG object which we want to know its layer color @return int Layer color of the DWG object in the Autocad color code
[ "Returns", "the", "color", "of", "the", "layer", "of", "a", "DWG", "object" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java#L978-L989
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java
DwgFile.addDwgSectionOffset
public void addDwgSectionOffset( String key, int seek, int size ) { DwgSectionOffset dso = new DwgSectionOffset(key, seek, size); dwgSectionOffsets.add(dso); }
java
public void addDwgSectionOffset( String key, int seek, int size ) { DwgSectionOffset dso = new DwgSectionOffset(key, seek, size); dwgSectionOffsets.add(dso); }
[ "public", "void", "addDwgSectionOffset", "(", "String", "key", ",", "int", "seek", ",", "int", "size", ")", "{", "DwgSectionOffset", "dso", "=", "new", "DwgSectionOffset", "(", "key", ",", "seek", ",", "size", ")", ";", "dwgSectionOffsets", ".", "add", "("...
Add a DWG section offset to the dwgSectionOffsets vector @param key Define the DWG section @param seek Offset of the section @param size Size of the section
[ "Add", "a", "DWG", "section", "offset", "to", "the", "dwgSectionOffsets", "vector" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java#L1122-L1125
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java
DwgFile.getDwgSectionOffset
public int getDwgSectionOffset( String key ) { int offset = 0; for( int i = 0; i < dwgSectionOffsets.size(); i++ ) { DwgSectionOffset dso = (DwgSectionOffset) dwgSectionOffsets.get(i); String ikey = dso.getKey(); if (key.equals(ikey)) { offset = dso.getSeek(); break; } } return offset; }
java
public int getDwgSectionOffset( String key ) { int offset = 0; for( int i = 0; i < dwgSectionOffsets.size(); i++ ) { DwgSectionOffset dso = (DwgSectionOffset) dwgSectionOffsets.get(i); String ikey = dso.getKey(); if (key.equals(ikey)) { offset = dso.getSeek(); break; } } return offset; }
[ "public", "int", "getDwgSectionOffset", "(", "String", "key", ")", "{", "int", "offset", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dwgSectionOffsets", ".", "size", "(", ")", ";", "i", "++", ")", "{", "DwgSectionOffset", "dso", ...
Returns the offset of DWG section given by its key @param key Define the DWG section @return int Offset of the section in the DWG file
[ "Returns", "the", "offset", "of", "DWG", "section", "given", "by", "its", "key" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java#L1133-L1144
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java
DwgFile.addDwgObjectOffset
public void addDwgObjectOffset( int handle, int offset ) { DwgObjectOffset doo = new DwgObjectOffset(handle, offset); dwgObjectOffsets.add(doo); }
java
public void addDwgObjectOffset( int handle, int offset ) { DwgObjectOffset doo = new DwgObjectOffset(handle, offset); dwgObjectOffsets.add(doo); }
[ "public", "void", "addDwgObjectOffset", "(", "int", "handle", ",", "int", "offset", ")", "{", "DwgObjectOffset", "doo", "=", "new", "DwgObjectOffset", "(", "handle", ",", "offset", ")", ";", "dwgObjectOffsets", ".", "add", "(", "doo", ")", ";", "}" ]
Add a DWG object offset to the dwgObjectOffsets vector @param handle Object handle @param offset Offset of the object data in the DWG file
[ "Add", "a", "DWG", "object", "offset", "to", "the", "dwgObjectOffsets", "vector" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/DwgFile.java#L1152-L1155
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java
EnaValidator.initValidator
protected void initValidator() throws SQLException, IOException { EmblEntryValidationPlanProperty emblEntryValidationPlanProperty = new EmblEntryValidationPlanProperty(); emblEntryValidationPlanProperty.validationScope.set(ValidationScope.getScope(fileType)); emblEntryValidationPlanProperty.isDevMode.set(testMode); emblEntryValidationPlanProperty.isFixMode.set(fixMode || fixDiagnoseMode); emblEntryValidationPlanProperty.minGapLength.set(min_gap_length); emblEntryValidationPlanProperty.isRemote.set(remote); emblEntryValidationPlanProperty.fileType.set(fileType); emblEntryValidationPlanProperty.enproConnection.set(con); emblValidator = new EmblEntryValidationPlan(emblEntryValidationPlanProperty); emblValidator.addMessageBundle(ValidationMessageManager.STANDARD_VALIDATION_BUNDLE); emblValidator.addMessageBundle(ValidationMessageManager.STANDARD_FIXER_BUNDLE); gff3Validator = new GFF3ValidationPlan(emblEntryValidationPlanProperty); gff3Validator.addMessageBundle(ValidationMessageManager.GFF3_VALIDATION_BUNDLE); gaValidator = new GenomeAssemblyValidationPlan(emblEntryValidationPlanProperty); gaValidator.addMessageBundle(ValidationMessageManager.GENOMEASSEMBLY_VALIDATION_BUNDLE); gaValidator.addMessageBundle(ValidationMessageManager.GENOMEASSEMBLY_FIXER_BUNDLE); initWriters(); }
java
protected void initValidator() throws SQLException, IOException { EmblEntryValidationPlanProperty emblEntryValidationPlanProperty = new EmblEntryValidationPlanProperty(); emblEntryValidationPlanProperty.validationScope.set(ValidationScope.getScope(fileType)); emblEntryValidationPlanProperty.isDevMode.set(testMode); emblEntryValidationPlanProperty.isFixMode.set(fixMode || fixDiagnoseMode); emblEntryValidationPlanProperty.minGapLength.set(min_gap_length); emblEntryValidationPlanProperty.isRemote.set(remote); emblEntryValidationPlanProperty.fileType.set(fileType); emblEntryValidationPlanProperty.enproConnection.set(con); emblValidator = new EmblEntryValidationPlan(emblEntryValidationPlanProperty); emblValidator.addMessageBundle(ValidationMessageManager.STANDARD_VALIDATION_BUNDLE); emblValidator.addMessageBundle(ValidationMessageManager.STANDARD_FIXER_BUNDLE); gff3Validator = new GFF3ValidationPlan(emblEntryValidationPlanProperty); gff3Validator.addMessageBundle(ValidationMessageManager.GFF3_VALIDATION_BUNDLE); gaValidator = new GenomeAssemblyValidationPlan(emblEntryValidationPlanProperty); gaValidator.addMessageBundle(ValidationMessageManager.GENOMEASSEMBLY_VALIDATION_BUNDLE); gaValidator.addMessageBundle(ValidationMessageManager.GENOMEASSEMBLY_FIXER_BUNDLE); initWriters(); }
[ "protected", "void", "initValidator", "(", ")", "throws", "SQLException", ",", "IOException", "{", "EmblEntryValidationPlanProperty", "emblEntryValidationPlanProperty", "=", "new", "EmblEntryValidationPlanProperty", "(", ")", ";", "emblEntryValidationPlanProperty", ".", "vali...
Inits the validator. @throws SQLException @throws IOException Signals that an I/O exception has occurred.
[ "Inits", "the", "validator", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java#L191-L212
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java
EnaValidator.initWriters
protected void initWriters() throws IOException { String summarywriter = prefix == null ? "VAL_SUMMARY.txt" : prefix + "_" + "VAL_SUMMARY.txt"; String infowriter = prefix == null ? "VAL_INFO.txt" : prefix + "_" + "VAL_INFO.txt"; String errorwriter = prefix == null ? "VAL_ERROR.txt" : prefix + "_" + "VAL_ERROR.txt"; String reportswriter = prefix == null ? "VAL_REPORTS.txt" : prefix + "_" + "VAL_REPORTS.txt"; String fixwriter = prefix == null ? "VAL_FIXES.txt" : prefix + "_" + "VAL_FIXES.txt"; summaryWriter = new PrintWriter(summarywriter,"UTF-8"); infoWriter = new PrintWriter(infowriter,"UTF-8"); errorWriter = new PrintWriter(errorwriter,"UTF-8"); reportWriter = new PrintWriter(reportswriter,"UTF-8"); fixWriter = new PrintWriter(fixwriter,"UTF-8"); }
java
protected void initWriters() throws IOException { String summarywriter = prefix == null ? "VAL_SUMMARY.txt" : prefix + "_" + "VAL_SUMMARY.txt"; String infowriter = prefix == null ? "VAL_INFO.txt" : prefix + "_" + "VAL_INFO.txt"; String errorwriter = prefix == null ? "VAL_ERROR.txt" : prefix + "_" + "VAL_ERROR.txt"; String reportswriter = prefix == null ? "VAL_REPORTS.txt" : prefix + "_" + "VAL_REPORTS.txt"; String fixwriter = prefix == null ? "VAL_FIXES.txt" : prefix + "_" + "VAL_FIXES.txt"; summaryWriter = new PrintWriter(summarywriter,"UTF-8"); infoWriter = new PrintWriter(infowriter,"UTF-8"); errorWriter = new PrintWriter(errorwriter,"UTF-8"); reportWriter = new PrintWriter(reportswriter,"UTF-8"); fixWriter = new PrintWriter(fixwriter,"UTF-8"); }
[ "protected", "void", "initWriters", "(", ")", "throws", "IOException", "{", "String", "summarywriter", "=", "prefix", "==", "null", "?", "\"VAL_SUMMARY.txt\"", ":", "prefix", "+", "\"_\"", "+", "\"VAL_SUMMARY.txt\"", ";", "String", "infowriter", "=", "prefix", "...
separate method to instantiate so unit tests can call this @throws IOException
[ "separate", "method", "to", "instantiate", "so", "unit", "tests", "can", "call", "this" ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java#L472-L484
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java
EnaValidator.validateFile
private List<ValidationPlanResult> validateFile(File file, Writer writer) throws IOException { List<ValidationPlanResult> messages = new ArrayList<ValidationPlanResult>(); ArrayList<Object> entryList = new ArrayList<Object>(); BufferedReader fileReader = null; try { fileReader= new BufferedReader(new FileReader(file)); prepareReader( fileReader,file.getName()); List<ValidationPlanResult> results = validateEntriesInReader(writer,file,entryList); ValidationPlanResult entrySetResult = validateEntry(entryList); if (file != null) { entrySetResult.setTargetOrigin(file.getName()); } for (ValidationPlanResult planResult : results) { messages.add(planResult); } if (!entrySetResult.isValid()) { writeResultsToFile(entrySetResult); messages.add(entrySetResult); } } catch (Exception e) { e.printStackTrace(); } finally{ if(fileReader!=null) fileReader.close(); } return messages; }
java
private List<ValidationPlanResult> validateFile(File file, Writer writer) throws IOException { List<ValidationPlanResult> messages = new ArrayList<ValidationPlanResult>(); ArrayList<Object> entryList = new ArrayList<Object>(); BufferedReader fileReader = null; try { fileReader= new BufferedReader(new FileReader(file)); prepareReader( fileReader,file.getName()); List<ValidationPlanResult> results = validateEntriesInReader(writer,file,entryList); ValidationPlanResult entrySetResult = validateEntry(entryList); if (file != null) { entrySetResult.setTargetOrigin(file.getName()); } for (ValidationPlanResult planResult : results) { messages.add(planResult); } if (!entrySetResult.isValid()) { writeResultsToFile(entrySetResult); messages.add(entrySetResult); } } catch (Exception e) { e.printStackTrace(); } finally{ if(fileReader!=null) fileReader.close(); } return messages; }
[ "private", "List", "<", "ValidationPlanResult", ">", "validateFile", "(", "File", "file", ",", "Writer", "writer", ")", "throws", "IOException", "{", "List", "<", "ValidationPlanResult", ">", "messages", "=", "new", "ArrayList", "<", "ValidationPlanResult", ">", ...
Validate file. @param file the file @param writer the writer @return the list of ValidationPlanResult @throws IOException @throws ValidationEngineException
[ "Validate", "file", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java#L497-L535
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java
EnaValidator.prepareReader
private void prepareReader(BufferedReader fileReader, String fileId) { switch (fileType) { case EMBL: EmblEntryReader emblReader = new EmblEntryReader( fileReader, EmblEntryReader.Format.EMBL_FORMAT,fileId); emblReader.setCheckBlockCounts(lineCount); reader = emblReader; break; case GENBANK: reader = new GenbankEntryReader(fileReader,fileId); break; case GFF3: reader = new GFF3FlatFileEntryReader(fileReader); break; case FASTA: reader = new FastaFileReader(new FastaLineReader(fileReader)); break; case AGP: reader= new AGPFileReader(new AGPLineReader(fileReader)); break; default: System.exit(0); break; } }
java
private void prepareReader(BufferedReader fileReader, String fileId) { switch (fileType) { case EMBL: EmblEntryReader emblReader = new EmblEntryReader( fileReader, EmblEntryReader.Format.EMBL_FORMAT,fileId); emblReader.setCheckBlockCounts(lineCount); reader = emblReader; break; case GENBANK: reader = new GenbankEntryReader(fileReader,fileId); break; case GFF3: reader = new GFF3FlatFileEntryReader(fileReader); break; case FASTA: reader = new FastaFileReader(new FastaLineReader(fileReader)); break; case AGP: reader= new AGPFileReader(new AGPLineReader(fileReader)); break; default: System.exit(0); break; } }
[ "private", "void", "prepareReader", "(", "BufferedReader", "fileReader", ",", "String", "fileId", ")", "{", "switch", "(", "fileType", ")", "{", "case", "EMBL", ":", "EmblEntryReader", "emblReader", "=", "new", "EmblEntryReader", "(", "fileReader", ",", "EmblEnt...
Prepare reader. @param fileReader the file reader @param fileId the file name
[ "Prepare", "reader", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java#L545-L571
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java
EnaValidator.writeResultsToFile
private void writeResultsToFile(ValidationPlanResult planResult) throws IOException { /** * first set any report messages (probably exceptional that the * translation report needs to get set outside the embl-api-core package * due to the need for embl-ff writers **/ for (ValidationResult result : planResult.getResults()) { if (result instanceof ExtendedResult) { ExtendedResult extendedResult = (ExtendedResult) result; if (extendedResult.getExtension() instanceof CdsFeatureTranslationCheck.TranslationReportInfo) { FlatFileValidations.setCDSTranslationReport((ExtendedResult<CdsFeatureTranslationCheck.TranslationReportInfo>) extendedResult); } } } // then look at writing the files for (ValidationResult result : planResult.getResults()) { result.writeMessages(errorWriter,Severity.ERROR,planResult.getTargetOrigin()); result.writeMessages(infoWriter,Severity.INFO,planResult.getTargetOrigin()); result.writeMessages(infoWriter,Severity.WARNING,planResult.getTargetOrigin()); result.writeMessages(fixWriter,Severity.FIX,planResult.getTargetOrigin()); errorWriter.flush(); infoWriter.flush(); fixWriter.flush(); } for (ValidationResult result : planResult.getResults()) { if (result.isHasReportMessage()) { result.setWriteReportMessage(true);// turn report writing on for // this writer result.writeMessages(reportWriter); } } }
java
private void writeResultsToFile(ValidationPlanResult planResult) throws IOException { /** * first set any report messages (probably exceptional that the * translation report needs to get set outside the embl-api-core package * due to the need for embl-ff writers **/ for (ValidationResult result : planResult.getResults()) { if (result instanceof ExtendedResult) { ExtendedResult extendedResult = (ExtendedResult) result; if (extendedResult.getExtension() instanceof CdsFeatureTranslationCheck.TranslationReportInfo) { FlatFileValidations.setCDSTranslationReport((ExtendedResult<CdsFeatureTranslationCheck.TranslationReportInfo>) extendedResult); } } } // then look at writing the files for (ValidationResult result : planResult.getResults()) { result.writeMessages(errorWriter,Severity.ERROR,planResult.getTargetOrigin()); result.writeMessages(infoWriter,Severity.INFO,planResult.getTargetOrigin()); result.writeMessages(infoWriter,Severity.WARNING,planResult.getTargetOrigin()); result.writeMessages(fixWriter,Severity.FIX,planResult.getTargetOrigin()); errorWriter.flush(); infoWriter.flush(); fixWriter.flush(); } for (ValidationResult result : planResult.getResults()) { if (result.isHasReportMessage()) { result.setWriteReportMessage(true);// turn report writing on for // this writer result.writeMessages(reportWriter); } } }
[ "private", "void", "writeResultsToFile", "(", "ValidationPlanResult", "planResult", ")", "throws", "IOException", "{", "/**\n\t\t * first set any report messages (probably exceptional that the\n\t\t * translation report needs to get set outside the embl-api-core package\n\t\t * due to the need f...
Write results to file. @param planResult the plan result @throws IOException Signals that an I/O exception has occurred.
[ "Write", "results", "to", "file", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java#L913-L955
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java
EnaValidator.getNextEntryFromReader
protected Object getNextEntryFromReader(Writer writer) { try { parseError = false; ValidationResult parseResult = reader.read(); if (parseResult.getMessages("FT.10").size() >= 1 && (fixMode || fixDiagnoseMode)) { parseResult.removeMessage("FT.10"); // writer fixes automatically if quotes are not given for qualifier value in fix/fix_diagnose mode. } if (parseResult.count() != 0) { parseResults.add(parseResult); writer.write("\n"); for (ValidationMessage<Origin> validationMessage : parseResult.getMessages()) { validationMessage.writeMessage(writer); } parseError = true; } if (!reader.isEntry()) { return null; } } catch (IOException e) { e.printStackTrace(); } return reader.getEntry(); }
java
protected Object getNextEntryFromReader(Writer writer) { try { parseError = false; ValidationResult parseResult = reader.read(); if (parseResult.getMessages("FT.10").size() >= 1 && (fixMode || fixDiagnoseMode)) { parseResult.removeMessage("FT.10"); // writer fixes automatically if quotes are not given for qualifier value in fix/fix_diagnose mode. } if (parseResult.count() != 0) { parseResults.add(parseResult); writer.write("\n"); for (ValidationMessage<Origin> validationMessage : parseResult.getMessages()) { validationMessage.writeMessage(writer); } parseError = true; } if (!reader.isEntry()) { return null; } } catch (IOException e) { e.printStackTrace(); } return reader.getEntry(); }
[ "protected", "Object", "getNextEntryFromReader", "(", "Writer", "writer", ")", "{", "try", "{", "parseError", "=", "false", ";", "ValidationResult", "parseResult", "=", "reader", ".", "read", "(", ")", ";", "if", "(", "parseResult", ".", "getMessages", "(", ...
Gets the next entry from reader. @param writer the writer @return the next entry from reader
[ "Gets", "the", "next", "entry", "from", "reader", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/EnaValidator.java#L1013-L1046
train
TheHortonMachine/hortonmachine
hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/OmsTrentoP.java
OmsTrentoP.setNetworkPipes
private void setNetworkPipes( boolean isAreaNotAllDry ) throws Exception { int length = inPipes.size(); networkPipes = new Pipe[length]; SimpleFeatureIterator stationsIter = inPipes.features(); boolean existOut = false; int tmpOutIndex = 0; try { int t = 0; while( stationsIter.hasNext() ) { SimpleFeature feature = stationsIter.next(); try { /* * extract the value of the ID which is the position (minus * 1) in the array. */ Number field = ((Number) feature.getAttribute(TrentoPFeatureType.ID_STR)); if (field == null) { pm.errorMessage(msg.message("trentoP.error.number") + TrentoPFeatureType.ID_STR); throw new IllegalArgumentException(msg.message("trentoP.error.number") + TrentoPFeatureType.ID_STR); } if (field.equals(pOutPipe)) { tmpOutIndex = t; existOut = true; } networkPipes[t] = new Pipe(feature, pMode, isAreaNotAllDry, pm); t++; } catch (NullPointerException e) { pm.errorMessage(msg.message("trentop.illegalNet")); throw new IllegalArgumentException(msg.message("trentop.illegalNet")); } } } finally { stationsIter.close(); } if (!existOut) { } // set the id where drain of the outlet. networkPipes[tmpOutIndex].setIdPipeWhereDrain(0); networkPipes[tmpOutIndex].setIndexPipeWhereDrain(-1); // start to construct the net. int numberOfPoint = networkPipes[tmpOutIndex].point.length - 1; findIdThatDrainsIntoIndex(tmpOutIndex, networkPipes[tmpOutIndex].point[0]); findIdThatDrainsIntoIndex(tmpOutIndex, networkPipes[tmpOutIndex].point[numberOfPoint]); List<Integer> missingId = new ArrayList<Integer>(); for( Pipe pipe : networkPipes ) { if (pipe.getIdPipeWhereDrain() == null && pipe.getId() != pOutPipe) { missingId.add(pipe.getId()); } } if (missingId.size() > 0) { String errorMsg = "One of the following pipes doesn't have a connected pipe towards the outlet: " + Arrays.toString(missingId.toArray(new Integer[0])); pm.errorMessage(msg.message(errorMsg)); throw new IllegalArgumentException(errorMsg); } verifyNet(networkPipes, pm); }
java
private void setNetworkPipes( boolean isAreaNotAllDry ) throws Exception { int length = inPipes.size(); networkPipes = new Pipe[length]; SimpleFeatureIterator stationsIter = inPipes.features(); boolean existOut = false; int tmpOutIndex = 0; try { int t = 0; while( stationsIter.hasNext() ) { SimpleFeature feature = stationsIter.next(); try { /* * extract the value of the ID which is the position (minus * 1) in the array. */ Number field = ((Number) feature.getAttribute(TrentoPFeatureType.ID_STR)); if (field == null) { pm.errorMessage(msg.message("trentoP.error.number") + TrentoPFeatureType.ID_STR); throw new IllegalArgumentException(msg.message("trentoP.error.number") + TrentoPFeatureType.ID_STR); } if (field.equals(pOutPipe)) { tmpOutIndex = t; existOut = true; } networkPipes[t] = new Pipe(feature, pMode, isAreaNotAllDry, pm); t++; } catch (NullPointerException e) { pm.errorMessage(msg.message("trentop.illegalNet")); throw new IllegalArgumentException(msg.message("trentop.illegalNet")); } } } finally { stationsIter.close(); } if (!existOut) { } // set the id where drain of the outlet. networkPipes[tmpOutIndex].setIdPipeWhereDrain(0); networkPipes[tmpOutIndex].setIndexPipeWhereDrain(-1); // start to construct the net. int numberOfPoint = networkPipes[tmpOutIndex].point.length - 1; findIdThatDrainsIntoIndex(tmpOutIndex, networkPipes[tmpOutIndex].point[0]); findIdThatDrainsIntoIndex(tmpOutIndex, networkPipes[tmpOutIndex].point[numberOfPoint]); List<Integer> missingId = new ArrayList<Integer>(); for( Pipe pipe : networkPipes ) { if (pipe.getIdPipeWhereDrain() == null && pipe.getId() != pOutPipe) { missingId.add(pipe.getId()); } } if (missingId.size() > 0) { String errorMsg = "One of the following pipes doesn't have a connected pipe towards the outlet: " + Arrays.toString(missingId.toArray(new Integer[0])); pm.errorMessage(msg.message(errorMsg)); throw new IllegalArgumentException(errorMsg); } verifyNet(networkPipes, pm); }
[ "private", "void", "setNetworkPipes", "(", "boolean", "isAreaNotAllDry", ")", "throws", "Exception", "{", "int", "length", "=", "inPipes", ".", "size", "(", ")", ";", "networkPipes", "=", "new", "Pipe", "[", "length", "]", ";", "SimpleFeatureIterator", "statio...
Initializating the array. <p> The array is the net. If there is a FeatureCollection extract values from it. The Array is order following the ID. </p> oss: if the FeatureCillection is null a IllegalArgumentException is throw in {@link OmsTrentoP#verifyParameter()}. @param isAreaNotAllDry it is true if there is only a percentage of the input area dry. @throws IllegalArgumentException if the FeatureCollection hasn't the correct parameters.
[ "Initializating", "the", "array", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/OmsTrentoP.java#L693-L759
train
TheHortonMachine/hortonmachine
hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/OmsTrentoP.java
OmsTrentoP.verifyNet
public void verifyNet( Pipe[] networkPipes, IHMProgressMonitor pm ) { /* * serve per verificare che ci sia almeno un'uscita. True= esiste * un'uscita */ boolean isOut = false; if (networkPipes != null) { /* VERIFICA DATI GEOMETRICI DELLA RETE */ // Per ogni stato int length = networkPipes.length; int kj; for( int i = 0; i < length; i++ ) { // verifica che la rete abbia almeno un-uscita. if (networkPipes[i].getIdPipeWhereDrain() == 0) { isOut = true; } /* * Controlla che non ci siano errori nei dati geometrici della * rete, numero ID pipe in cui drena i >del numero consentito * (la numerazione va da 1 a length */ if (networkPipes[i].getIndexPipeWhereDrain() > length) { pm.errorMessage(msg.message("trentoP.error.pipe")); throw new IllegalArgumentException(msg.message("trentoP.error.pipe")); } /* * Da quanto si puo leggere nel file di input fossolo.geo in * Fluide Turtle, ogni stato o sottobacino e contraddistinto da * un numero crescente che va da 1 a n=numero di stati; n e * anche pari a data->nrh. Inoltre si apprende che la prima * colonna della matrice in fossolo.geo riporta l'elenco degli * stati, mentre la seconda colonna ci dice dove ciascun stato * va a drenare.(NON E AMMESSO CHE LO STESSO STATO DRENI SU PIU * DI UNO!!) Questa if serve per verificare che non siano * presenti condotte non dichiarate, ovvero piu realisticamente * che non ci sia un'errore di numerazione o battitura. In altri * termini lo stato analizzato non puo drenare in uno stato al * di fuori di quelli esplicitamente dichiarati o dell'uscita, * contradistinta con ID 0 */ kj = i; /* * Terra conto degli stati attraversati dall'acqua che inizia a * scorrere a partire dallo stato analizzato */ int count = 0; /* * Seguo il percorso dell'acqua a partire dallo stato corrente */ while( networkPipes[kj].getIdPipeWhereDrain() != 0 ) { kj = networkPipes[kj].getIndexPipeWhereDrain(); /* * L'acqua non puo finire in uno stato che con sia tra * quelli esplicitamente definiti, in altre parole il * percorso dell'acqua non puo essere al di fuori * dell'inseme dei dercorsi possibili */ if (kj > length) { pm.errorMessage(msg.message("trentoP.error.drainPipe") + kj); throw new IllegalArgumentException(msg.message("trentoP.error.drainPipe") + kj); } count++; if (count > length) { pm.errorMessage(msg.message("trentoP.error.pipe")); throw new IllegalArgumentException(msg.message("trentoP.error.pipe")); } /* * La variabile count mi consente di uscire dal ciclo while, * nel caso non ci fosse [kj][2]=0, ossia un'uscita. Infatti * partendo da uno stato qualsiasi il numero degli stati * attraversati prima di raggiungere l'uscita non puo essere * superiore al numero degli stati effettivamente presenti. * Quando questo accade vuol dire che l'acqua e in un loop * chiuso */ } } /* * Non si e trovato neanche un uscita, quindi Trento_p da errore di * esecuzione, perchè almeno una colonna deve essere l'uscita */ if (isOut == false) { pm.errorMessage(msg.message("trentoP.error.noout")); throw new IllegalArgumentException(msg.message("trentoP.error.noout")); } } else { throw new IllegalArgumentException(msg.message("trentoP.error.incorrectmatrix")); } }
java
public void verifyNet( Pipe[] networkPipes, IHMProgressMonitor pm ) { /* * serve per verificare che ci sia almeno un'uscita. True= esiste * un'uscita */ boolean isOut = false; if (networkPipes != null) { /* VERIFICA DATI GEOMETRICI DELLA RETE */ // Per ogni stato int length = networkPipes.length; int kj; for( int i = 0; i < length; i++ ) { // verifica che la rete abbia almeno un-uscita. if (networkPipes[i].getIdPipeWhereDrain() == 0) { isOut = true; } /* * Controlla che non ci siano errori nei dati geometrici della * rete, numero ID pipe in cui drena i >del numero consentito * (la numerazione va da 1 a length */ if (networkPipes[i].getIndexPipeWhereDrain() > length) { pm.errorMessage(msg.message("trentoP.error.pipe")); throw new IllegalArgumentException(msg.message("trentoP.error.pipe")); } /* * Da quanto si puo leggere nel file di input fossolo.geo in * Fluide Turtle, ogni stato o sottobacino e contraddistinto da * un numero crescente che va da 1 a n=numero di stati; n e * anche pari a data->nrh. Inoltre si apprende che la prima * colonna della matrice in fossolo.geo riporta l'elenco degli * stati, mentre la seconda colonna ci dice dove ciascun stato * va a drenare.(NON E AMMESSO CHE LO STESSO STATO DRENI SU PIU * DI UNO!!) Questa if serve per verificare che non siano * presenti condotte non dichiarate, ovvero piu realisticamente * che non ci sia un'errore di numerazione o battitura. In altri * termini lo stato analizzato non puo drenare in uno stato al * di fuori di quelli esplicitamente dichiarati o dell'uscita, * contradistinta con ID 0 */ kj = i; /* * Terra conto degli stati attraversati dall'acqua che inizia a * scorrere a partire dallo stato analizzato */ int count = 0; /* * Seguo il percorso dell'acqua a partire dallo stato corrente */ while( networkPipes[kj].getIdPipeWhereDrain() != 0 ) { kj = networkPipes[kj].getIndexPipeWhereDrain(); /* * L'acqua non puo finire in uno stato che con sia tra * quelli esplicitamente definiti, in altre parole il * percorso dell'acqua non puo essere al di fuori * dell'inseme dei dercorsi possibili */ if (kj > length) { pm.errorMessage(msg.message("trentoP.error.drainPipe") + kj); throw new IllegalArgumentException(msg.message("trentoP.error.drainPipe") + kj); } count++; if (count > length) { pm.errorMessage(msg.message("trentoP.error.pipe")); throw new IllegalArgumentException(msg.message("trentoP.error.pipe")); } /* * La variabile count mi consente di uscire dal ciclo while, * nel caso non ci fosse [kj][2]=0, ossia un'uscita. Infatti * partendo da uno stato qualsiasi il numero degli stati * attraversati prima di raggiungere l'uscita non puo essere * superiore al numero degli stati effettivamente presenti. * Quando questo accade vuol dire che l'acqua e in un loop * chiuso */ } } /* * Non si e trovato neanche un uscita, quindi Trento_p da errore di * esecuzione, perchè almeno una colonna deve essere l'uscita */ if (isOut == false) { pm.errorMessage(msg.message("trentoP.error.noout")); throw new IllegalArgumentException(msg.message("trentoP.error.noout")); } } else { throw new IllegalArgumentException(msg.message("trentoP.error.incorrectmatrix")); } }
[ "public", "void", "verifyNet", "(", "Pipe", "[", "]", "networkPipes", ",", "IHMProgressMonitor", "pm", ")", "{", "/*\n * serve per verificare che ci sia almeno un'uscita. True= esiste\n * un'uscita\n */", "boolean", "isOut", "=", "false", ";", "if", "(...
Verify if the network is consistent. <p> <ol> <li>Verify that the <i>ID</i> of a pipe is a value less than the number of pipe. <li>Verify that the pipe where, the current pipe drain, have an <i>ID</i> less than the number of pipes. <li>Verify that there is an <b>outlet<b> in the net. </ol> </p> @param networkPipes the array which rappresent the net. @param pm the progerss monitor. @throws IllegalArgumentException if the net is unconsistent.
[ "Verify", "if", "the", "network", "is", "consistent", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/OmsTrentoP.java#L825-L922
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java
LineReader.joinLine
public boolean joinLine() { if (!isCurrentLine()) { return false; } if (!isNextLine()) { return false; } if (!isNextTag()) { return true; // no next tag -> continue block } if (!isCurrentTag()) { return false; // no current tag -> new block } // compare current and next tag return getCurrentTag().equals(getNextTag()); }
java
public boolean joinLine() { if (!isCurrentLine()) { return false; } if (!isNextLine()) { return false; } if (!isNextTag()) { return true; // no next tag -> continue block } if (!isCurrentTag()) { return false; // no current tag -> new block } // compare current and next tag return getCurrentTag().equals(getNextTag()); }
[ "public", "boolean", "joinLine", "(", ")", "{", "if", "(", "!", "isCurrentLine", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isNextLine", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isNextTag", "(", ")"...
Returns true if the next and current lines can be joined together either because they have the same tag or because the next line does not have a tag.
[ "Returns", "true", "if", "the", "next", "and", "current", "lines", "can", "be", "joined", "together", "either", "because", "they", "have", "the", "same", "tag", "or", "because", "the", "next", "line", "does", "not", "have", "a", "tag", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java#L197-L212
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java
LineReader.getCurrentLine
public String getCurrentLine() { if (!isCurrentLine()) { return null; } if (isTag(currentLine)) return FlatFileUtils.trimRight(currentLine, getTagWidth(currentLine)); else return currentLine.trim(); }
java
public String getCurrentLine() { if (!isCurrentLine()) { return null; } if (isTag(currentLine)) return FlatFileUtils.trimRight(currentLine, getTagWidth(currentLine)); else return currentLine.trim(); }
[ "public", "String", "getCurrentLine", "(", ")", "{", "if", "(", "!", "isCurrentLine", "(", ")", ")", "{", "return", "null", ";", "}", "if", "(", "isTag", "(", "currentLine", ")", ")", "return", "FlatFileUtils", ".", "trimRight", "(", "currentLine", ",", ...
Return current line without tag.
[ "Return", "current", "line", "without", "tag", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java#L217-L226
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java
LineReader.getNextLine
public String getNextLine() { if (!isNextLine()) { return null; } if (isTag(nextLine)) return FlatFileUtils.trimRight(nextLine, getTagWidth(nextLine)); else return nextLine.trim(); }
java
public String getNextLine() { if (!isNextLine()) { return null; } if (isTag(nextLine)) return FlatFileUtils.trimRight(nextLine, getTagWidth(nextLine)); else return nextLine.trim(); }
[ "public", "String", "getNextLine", "(", ")", "{", "if", "(", "!", "isNextLine", "(", ")", ")", "{", "return", "null", ";", "}", "if", "(", "isTag", "(", "nextLine", ")", ")", "return", "FlatFileUtils", ".", "trimRight", "(", "nextLine", ",", "getTagWid...
Return next line without tag.
[ "Return", "next", "line", "without", "tag", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java#L231-L240
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java
LineReader.getCurrentMaskedLine
public String getCurrentMaskedLine() { if (!isCurrentLine()) { return null; } StringBuilder str = new StringBuilder(); int tagWidth = getTagWidth(currentLine); for (int i = 0; i < tagWidth; ++i) { str.append(" "); } if (currentLine.length() > tagWidth) { str.append(currentLine.substring(tagWidth)); } return str.toString(); }
java
public String getCurrentMaskedLine() { if (!isCurrentLine()) { return null; } StringBuilder str = new StringBuilder(); int tagWidth = getTagWidth(currentLine); for (int i = 0; i < tagWidth; ++i) { str.append(" "); } if (currentLine.length() > tagWidth) { str.append(currentLine.substring(tagWidth)); } return str.toString(); }
[ "public", "String", "getCurrentMaskedLine", "(", ")", "{", "if", "(", "!", "isCurrentLine", "(", ")", ")", "{", "return", "null", ";", "}", "StringBuilder", "str", "=", "new", "StringBuilder", "(", ")", ";", "int", "tagWidth", "=", "getTagWidth", "(", "c...
Return current line with tag masked with whitespace.
[ "Return", "current", "line", "with", "tag", "masked", "with", "whitespace", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java#L245-L258
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java
LineReader.getNextMaskedLine
public String getNextMaskedLine() { if (!isNextLine()) { return null; } StringBuilder str = new StringBuilder(); int tagWidth = getTagWidth(nextLine); for (int i = 0; i < tagWidth; ++i) { str.append(" "); } if (nextLine.length() > tagWidth) { str.append(nextLine.substring(tagWidth)); } return str.toString(); }
java
public String getNextMaskedLine() { if (!isNextLine()) { return null; } StringBuilder str = new StringBuilder(); int tagWidth = getTagWidth(nextLine); for (int i = 0; i < tagWidth; ++i) { str.append(" "); } if (nextLine.length() > tagWidth) { str.append(nextLine.substring(tagWidth)); } return str.toString(); }
[ "public", "String", "getNextMaskedLine", "(", ")", "{", "if", "(", "!", "isNextLine", "(", ")", ")", "{", "return", "null", ";", "}", "StringBuilder", "str", "=", "new", "StringBuilder", "(", ")", ";", "int", "tagWidth", "=", "getTagWidth", "(", "nextLin...
Return next line with tag masked with whitespace.
[ "Return", "next", "line", "with", "tag", "masked", "with", "whitespace", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java#L263-L276
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java
LineReader.getCurrentShrinkedLine
public String getCurrentShrinkedLine() { if (!isCurrentLine()) { return null; } String string = FlatFileUtils.trim(currentLine, getTagWidth(currentLine)); if (string.equals("")) { return null; } return FlatFileUtils.shrink(string); }
java
public String getCurrentShrinkedLine() { if (!isCurrentLine()) { return null; } String string = FlatFileUtils.trim(currentLine, getTagWidth(currentLine)); if (string.equals("")) { return null; } return FlatFileUtils.shrink(string); }
[ "public", "String", "getCurrentShrinkedLine", "(", ")", "{", "if", "(", "!", "isCurrentLine", "(", ")", ")", "{", "return", "null", ";", "}", "String", "string", "=", "FlatFileUtils", ".", "trim", "(", "currentLine", ",", "getTagWidth", "(", "currentLine", ...
Shrink and return the current line without tag.
[ "Shrink", "and", "return", "the", "current", "line", "without", "tag", "." ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/flatfile/reader/LineReader.java#L291-L301
train
TheHortonMachine/hortonmachine
gui/src/main/java/org/hortonmachine/gui/utils/monitor/HMProgressMonitorDialog.java
HMProgressMonitorDialog.propertyChange
public void propertyChange( PropertyChangeEvent evt ) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressMonitor.setProgress(progress); // String message = String.format("Completed %d%%.\n", progress); // progressMonitor.setNote(message); if (progressMonitor.isCanceled() || task.isDone()) { if (progressMonitor.isCanceled()) { task.cancel(true); } } } if ("progressText" == evt.getPropertyName()) { String progressText = (String) evt.getNewValue(); progressMonitor.setNote(progressText); if (progressMonitor.isCanceled() || task.isDone()) { if (progressMonitor.isCanceled()) { task.cancel(true); } } } }
java
public void propertyChange( PropertyChangeEvent evt ) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressMonitor.setProgress(progress); // String message = String.format("Completed %d%%.\n", progress); // progressMonitor.setNote(message); if (progressMonitor.isCanceled() || task.isDone()) { if (progressMonitor.isCanceled()) { task.cancel(true); } } } if ("progressText" == evt.getPropertyName()) { String progressText = (String) evt.getNewValue(); progressMonitor.setNote(progressText); if (progressMonitor.isCanceled() || task.isDone()) { if (progressMonitor.isCanceled()) { task.cancel(true); } } } }
[ "public", "void", "propertyChange", "(", "PropertyChangeEvent", "evt", ")", "{", "if", "(", "\"progress\"", "==", "evt", ".", "getPropertyName", "(", ")", ")", "{", "int", "progress", "=", "(", "Integer", ")", "evt", ".", "getNewValue", "(", ")", ";", "p...
Invoked when task's progress property changes.
[ "Invoked", "when", "task", "s", "progress", "property", "changes", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gui/src/main/java/org/hortonmachine/gui/utils/monitor/HMProgressMonitorDialog.java#L125-L147
train
TheHortonMachine/hortonmachine
modules/src/main/java/org/hortonmachine/modules/Raster.java
Raster.positionAt
public double[] positionAt( int col, int row ) { if (isInRaster(col, row)) { GridGeometry2D gridGeometry = getGridGeometry(); Coordinate coordinate = CoverageUtilities.coordinateFromColRow(col, row, gridGeometry); return new double[]{coordinate.x, coordinate.y}; } return null; }
java
public double[] positionAt( int col, int row ) { if (isInRaster(col, row)) { GridGeometry2D gridGeometry = getGridGeometry(); Coordinate coordinate = CoverageUtilities.coordinateFromColRow(col, row, gridGeometry); return new double[]{coordinate.x, coordinate.y}; } return null; }
[ "public", "double", "[", "]", "positionAt", "(", "int", "col", ",", "int", "row", ")", "{", "if", "(", "isInRaster", "(", "col", ",", "row", ")", ")", "{", "GridGeometry2D", "gridGeometry", "=", "getGridGeometry", "(", ")", ";", "Coordinate", "coordinate...
Get world position from col, row. @param col @param row @return the [x, y] position or <code>null</code> if outside the bounds.
[ "Get", "world", "position", "from", "col", "row", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/modules/src/main/java/org/hortonmachine/modules/Raster.java#L250-L257
train
TheHortonMachine/hortonmachine
modules/src/main/java/org/hortonmachine/modules/Raster.java
Raster.gridAt
public int[] gridAt( double x, double y ) { if (isInRaster(x, y)) { GridGeometry2D gridGeometry = getGridGeometry(); int[] colRowFromCoordinate = CoverageUtilities.colRowFromCoordinate(new Coordinate(x, y), gridGeometry, null); return colRowFromCoordinate; } return null; }
java
public int[] gridAt( double x, double y ) { if (isInRaster(x, y)) { GridGeometry2D gridGeometry = getGridGeometry(); int[] colRowFromCoordinate = CoverageUtilities.colRowFromCoordinate(new Coordinate(x, y), gridGeometry, null); return colRowFromCoordinate; } return null; }
[ "public", "int", "[", "]", "gridAt", "(", "double", "x", ",", "double", "y", ")", "{", "if", "(", "isInRaster", "(", "x", ",", "y", ")", ")", "{", "GridGeometry2D", "gridGeometry", "=", "getGridGeometry", "(", ")", ";", "int", "[", "]", "colRowFromCo...
Get grid col and row from a world coordinate. @param x @param y @return the [col, row] or <code>null</code> if the position is outside the bounds.
[ "Get", "grid", "col", "and", "row", "from", "a", "world", "coordinate", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/modules/src/main/java/org/hortonmachine/modules/Raster.java#L266-L273
train
TheHortonMachine/hortonmachine
modules/src/main/java/org/hortonmachine/modules/Raster.java
Raster.setValueAt
public void setValueAt( int col, int row, double value ) { if (makeNew) { if (isInRaster(col, row)) { ((WritableRandomIter) iter).setSample(col, row, 0, value); } else { throw new RuntimeException("Setting value outside of raster."); } } else { throw new RuntimeException("Writing not allowed."); } }
java
public void setValueAt( int col, int row, double value ) { if (makeNew) { if (isInRaster(col, row)) { ((WritableRandomIter) iter).setSample(col, row, 0, value); } else { throw new RuntimeException("Setting value outside of raster."); } } else { throw new RuntimeException("Writing not allowed."); } }
[ "public", "void", "setValueAt", "(", "int", "col", ",", "int", "row", ",", "double", "value", ")", "{", "if", "(", "makeNew", ")", "{", "if", "(", "isInRaster", "(", "col", ",", "row", ")", ")", "{", "(", "(", "WritableRandomIter", ")", "iter", ")"...
Sets a raster value if the raster is writable. @param col @param row @param value
[ "Sets", "a", "raster", "value", "if", "the", "raster", "is", "writable", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/modules/src/main/java/org/hortonmachine/modules/Raster.java#L282-L292
train
TheHortonMachine/hortonmachine
modules/src/main/java/org/hortonmachine/modules/Raster.java
Raster.surrounding
public double[] surrounding( int col, int row ) { GridNode node = new GridNode(iter, cols, rows, xRes, yRes, col, row); List<GridNode> surroundingNodes = node.getSurroundingNodes(); double[] surr = new double[8]; for( int i = 0; i < surroundingNodes.size(); i++ ) { GridNode gridNode = surroundingNodes.get(i); if (gridNode != null) { surr[i] = gridNode.elevation; } else { surr[i] = HMConstants.doubleNovalue; } } return surr; }
java
public double[] surrounding( int col, int row ) { GridNode node = new GridNode(iter, cols, rows, xRes, yRes, col, row); List<GridNode> surroundingNodes = node.getSurroundingNodes(); double[] surr = new double[8]; for( int i = 0; i < surroundingNodes.size(); i++ ) { GridNode gridNode = surroundingNodes.get(i); if (gridNode != null) { surr[i] = gridNode.elevation; } else { surr[i] = HMConstants.doubleNovalue; } } return surr; }
[ "public", "double", "[", "]", "surrounding", "(", "int", "col", ",", "int", "row", ")", "{", "GridNode", "node", "=", "new", "GridNode", "(", "iter", ",", "cols", ",", "rows", ",", "xRes", ",", "yRes", ",", "col", ",", "row", ")", ";", "List", "<...
Get the values of the surrounding cells. <b>The order of the values is [E, EN, N, NW, W, WS, S, SE].</b> @param col the col of the center cell. @param row the row of the center cell. @return the array of cell values around them as [E, EN, N, NW, W, WS, S, SE].
[ "Get", "the", "values", "of", "the", "surrounding", "cells", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/modules/src/main/java/org/hortonmachine/modules/Raster.java#L303-L316
train
TheHortonMachine/hortonmachine
modules/src/main/java/org/hortonmachine/modules/Raster.java
Raster.write
public void write( String path ) throws Exception { if (makeNew) { RasterWriter.writeRaster(path, buildRaster()); } else { throw new RuntimeException("Only new rasters can be dumped."); } }
java
public void write( String path ) throws Exception { if (makeNew) { RasterWriter.writeRaster(path, buildRaster()); } else { throw new RuntimeException("Only new rasters can be dumped."); } }
[ "public", "void", "write", "(", "String", "path", ")", "throws", "Exception", "{", "if", "(", "makeNew", ")", "{", "RasterWriter", ".", "writeRaster", "(", "path", ",", "buildRaster", "(", ")", ")", ";", "}", "else", "{", "throw", "new", "RuntimeExceptio...
Write the raster to file. @param path th epath to write to. @throws Exception
[ "Write", "the", "raster", "to", "file", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/modules/src/main/java/org/hortonmachine/modules/Raster.java#L359-L365
train
TheHortonMachine/hortonmachine
modules/src/main/java/org/hortonmachine/modules/Raster.java
Raster.read
public static Raster read( String path ) throws Exception { GridCoverage2D coverage2d = RasterReader.readRaster(path); Raster raster = new Raster(coverage2d); return raster; }
java
public static Raster read( String path ) throws Exception { GridCoverage2D coverage2d = RasterReader.readRaster(path); Raster raster = new Raster(coverage2d); return raster; }
[ "public", "static", "Raster", "read", "(", "String", "path", ")", "throws", "Exception", "{", "GridCoverage2D", "coverage2d", "=", "RasterReader", ".", "readRaster", "(", "path", ")", ";", "Raster", "raster", "=", "new", "Raster", "(", "coverage2d", ")", ";"...
Read a raster from file. @param path the path to the raster to read. @return the read raster in readonly mode. @throws Exception
[ "Read", "a", "raster", "from", "file", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/modules/src/main/java/org/hortonmachine/modules/Raster.java#L374-L378
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/template/TemplateLoader.java
TemplateLoader.checkDuplicateTokens
private void checkDuplicateTokens(MutableTemplateInfo templateInfo) throws TemplateException { List<String> allTokenNames = new ArrayList<String>(); for (TemplateTokenInfo tokenInfo : templateInfo.tokenInfos) { if (allTokenNames.contains(tokenInfo.getName())) { throw new TemplateException("Token name '" + tokenInfo.getName() + "' duplicated in template '" + templateInfo.name + "'."); } else { allTokenNames.add(tokenInfo.getName()); } } }
java
private void checkDuplicateTokens(MutableTemplateInfo templateInfo) throws TemplateException { List<String> allTokenNames = new ArrayList<String>(); for (TemplateTokenInfo tokenInfo : templateInfo.tokenInfos) { if (allTokenNames.contains(tokenInfo.getName())) { throw new TemplateException("Token name '" + tokenInfo.getName() + "' duplicated in template '" + templateInfo.name + "'."); } else { allTokenNames.add(tokenInfo.getName()); } } }
[ "private", "void", "checkDuplicateTokens", "(", "MutableTemplateInfo", "templateInfo", ")", "throws", "TemplateException", "{", "List", "<", "String", ">", "allTokenNames", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "TemplateTokenInfo"...
throws error if a token name appears twice - will bail as soon as one duplicate is hit @param templateInfo @throws TemplateException
[ "throws", "error", "if", "a", "token", "name", "appears", "twice", "-", "will", "bail", "as", "soon", "as", "one", "duplicate", "is", "hit" ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/template/TemplateLoader.java#L235-L246
train
enasequence/sequencetools
src/main/java/uk/ac/ebi/embl/template/TemplateLoader.java
TemplateLoader.processGroups
private void processGroups(MutableTemplateInfo template) throws TemplateException { List<TemplateTokenGroupInfo> groupInfos = template.groupInfo; List<String> allGroupTokens = new ArrayList<String>(); for (TemplateTokenGroupInfo groupInfo : groupInfos) { for (String newToken : groupInfo.getContainsString()) { if (allGroupTokens.contains(newToken)) { throw new TemplateException("Token " + newToken + " in template group : '" + groupInfo.getName() + "' already exists in another group"); } else { allGroupTokens.add(newToken); } } } List<String> containsList = new ArrayList<String>(); for (TemplateTokenInfo tokenInfo : template.tokenInfos) { if (!allGroupTokens.contains(tokenInfo.getName())) {//if its not already in another group, add containsList.add(tokenInfo.getName()); } } if (containsList.size() != 0) { TemplateTokenGroupInfo allOthersGroup = new TemplateTokenGroupInfo(null, containsList, "", true); //this will have a group order of '0' by default and will appear at the top when sorted template.groupInfo.add(allOthersGroup); } for (TemplateTokenGroupInfo groupInfo : template.groupInfo) { groupInfo.setParentGroups(template.tokenInfos); } }
java
private void processGroups(MutableTemplateInfo template) throws TemplateException { List<TemplateTokenGroupInfo> groupInfos = template.groupInfo; List<String> allGroupTokens = new ArrayList<String>(); for (TemplateTokenGroupInfo groupInfo : groupInfos) { for (String newToken : groupInfo.getContainsString()) { if (allGroupTokens.contains(newToken)) { throw new TemplateException("Token " + newToken + " in template group : '" + groupInfo.getName() + "' already exists in another group"); } else { allGroupTokens.add(newToken); } } } List<String> containsList = new ArrayList<String>(); for (TemplateTokenInfo tokenInfo : template.tokenInfos) { if (!allGroupTokens.contains(tokenInfo.getName())) {//if its not already in another group, add containsList.add(tokenInfo.getName()); } } if (containsList.size() != 0) { TemplateTokenGroupInfo allOthersGroup = new TemplateTokenGroupInfo(null, containsList, "", true); //this will have a group order of '0' by default and will appear at the top when sorted template.groupInfo.add(allOthersGroup); } for (TemplateTokenGroupInfo groupInfo : template.groupInfo) { groupInfo.setParentGroups(template.tokenInfos); } }
[ "private", "void", "processGroups", "(", "MutableTemplateInfo", "template", ")", "throws", "TemplateException", "{", "List", "<", "TemplateTokenGroupInfo", ">", "groupInfos", "=", "template", ".", "groupInfo", ";", "List", "<", "String", ">", "allGroupTokens", "=", ...
creates a group containing all tokens not contained in any other sections - an "all others" group @param template -
[ "creates", "a", "group", "containing", "all", "tokens", "not", "contained", "in", "any", "other", "sections", "-", "an", "all", "others", "group" ]
4127f5e1a17540239f5810136153fbd6737fa262
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/template/TemplateLoader.java#L253-L284
train
TheHortonMachine/hortonmachine
gears/src/main/java/oms3/io/CharBuffer.java
CharBuffer.shrink
public void shrink() { if (c.length == length) { return; } char[] newc = new char[length]; System.arraycopy(c, 0, newc, 0, length); c = newc; }
java
public void shrink() { if (c.length == length) { return; } char[] newc = new char[length]; System.arraycopy(c, 0, newc, 0, length); c = newc; }
[ "public", "void", "shrink", "(", ")", "{", "if", "(", "c", ".", "length", "==", "length", ")", "{", "return", ";", "}", "char", "[", "]", "newc", "=", "new", "char", "[", "length", "]", ";", "System", ".", "arraycopy", "(", "c", ",", "0", ",", ...
Shrinks the capacity of the buffer to the current length if necessary. This method involves copying the data once!
[ "Shrinks", "the", "capacity", "of", "the", "buffer", "to", "the", "current", "length", "if", "necessary", ".", "This", "method", "involves", "copying", "the", "data", "once!" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/io/CharBuffer.java#L153-L160
train
TheHortonMachine/hortonmachine
gears/src/main/java/oms3/io/CharBuffer.java
CharBuffer.toStringBuffer
public StringBuffer toStringBuffer() { StringBuffer sb = new StringBuffer(length); sb.append(c, 0, length); return sb; }
java
public StringBuffer toStringBuffer() { StringBuffer sb = new StringBuffer(length); sb.append(c, 0, length); return sb; }
[ "public", "StringBuffer", "toStringBuffer", "(", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", "length", ")", ";", "sb", ".", "append", "(", "c", ",", "0", ",", "length", ")", ";", "return", "sb", ";", "}" ]
Converts the contents of the buffer into a StringBuffer. This method involves copying the new data once! @return
[ "Converts", "the", "contents", "of", "the", "buffer", "into", "a", "StringBuffer", ".", "This", "method", "involves", "copying", "the", "new", "data", "once!" ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/io/CharBuffer.java#L200-L204
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java
CoverageUtilities.createSubCoverageFromTemplate
public static GridCoverage2D createSubCoverageFromTemplate( GridCoverage2D template, Envelope2D subregion, Double value, WritableRaster[] writableRasterHolder ) { RegionMap regionMap = getRegionParamsFromGridCoverage(template); double xRes = regionMap.getXres(); double yRes = regionMap.getYres(); double west = subregion.getMinX(); double south = subregion.getMinY(); double east = subregion.getMaxX(); double north = subregion.getMaxY(); int cols = (int) ((east - west) / xRes); int rows = (int) ((north - south) / yRes); ComponentSampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_DOUBLE, cols, rows, 1, cols, new int[]{0}); WritableRaster writableRaster = RasterFactory.createWritableRaster(sampleModel, null); if (value != null) { // autobox only once double v = value; for( int y = 0; y < rows; y++ ) { for( int x = 0; x < cols; x++ ) { writableRaster.setSample(x, y, 0, v); } } } if (writableRasterHolder != null) writableRasterHolder[0] = writableRaster; Envelope2D writeEnvelope = new Envelope2D(template.getCoordinateReferenceSystem(), west, south, east - west, north - south); GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null); GridCoverage2D coverage2D = factory.create("newraster", writableRaster, writeEnvelope); return coverage2D; }
java
public static GridCoverage2D createSubCoverageFromTemplate( GridCoverage2D template, Envelope2D subregion, Double value, WritableRaster[] writableRasterHolder ) { RegionMap regionMap = getRegionParamsFromGridCoverage(template); double xRes = regionMap.getXres(); double yRes = regionMap.getYres(); double west = subregion.getMinX(); double south = subregion.getMinY(); double east = subregion.getMaxX(); double north = subregion.getMaxY(); int cols = (int) ((east - west) / xRes); int rows = (int) ((north - south) / yRes); ComponentSampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_DOUBLE, cols, rows, 1, cols, new int[]{0}); WritableRaster writableRaster = RasterFactory.createWritableRaster(sampleModel, null); if (value != null) { // autobox only once double v = value; for( int y = 0; y < rows; y++ ) { for( int x = 0; x < cols; x++ ) { writableRaster.setSample(x, y, 0, v); } } } if (writableRasterHolder != null) writableRasterHolder[0] = writableRaster; Envelope2D writeEnvelope = new Envelope2D(template.getCoordinateReferenceSystem(), west, south, east - west, north - south); GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null); GridCoverage2D coverage2D = factory.create("newraster", writableRaster, writeEnvelope); return coverage2D; }
[ "public", "static", "GridCoverage2D", "createSubCoverageFromTemplate", "(", "GridCoverage2D", "template", ",", "Envelope2D", "subregion", ",", "Double", "value", ",", "WritableRaster", "[", "]", "writableRasterHolder", ")", "{", "RegionMap", "regionMap", "=", "getRegion...
Create a subcoverage given a template coverage and an envelope. @param template the template coverage used for the resolution. @param subregion the envelope to extract to the new coverage. This should be snapped on the resolution of the coverage, in order to avoid shifts. @param value the value to set the new raster to, if not <code>null</code>. @param writableRasterHolder an array of length 1 to place the writable raster in, that was can be used to populate the coverage. If <code>null</code>, it is ignored. @return the new coverage.
[ "Create", "a", "subcoverage", "given", "a", "template", "coverage", "and", "an", "envelope", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L344-L376
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java
CoverageUtilities.getRegionColsRows
public static int[] getRegionColsRows( GridCoverage2D gridCoverage ) { GridGeometry2D gridGeometry = gridCoverage.getGridGeometry(); GridEnvelope2D gridRange = gridGeometry.getGridRange2D(); int height = gridRange.height; int width = gridRange.width; int[] params = new int[]{width, height}; return params; }
java
public static int[] getRegionColsRows( GridCoverage2D gridCoverage ) { GridGeometry2D gridGeometry = gridCoverage.getGridGeometry(); GridEnvelope2D gridRange = gridGeometry.getGridRange2D(); int height = gridRange.height; int width = gridRange.width; int[] params = new int[]{width, height}; return params; }
[ "public", "static", "int", "[", "]", "getRegionColsRows", "(", "GridCoverage2D", "gridCoverage", ")", "{", "GridGeometry2D", "gridGeometry", "=", "gridCoverage", ".", "getGridGeometry", "(", ")", ";", "GridEnvelope2D", "gridRange", "=", "gridGeometry", ".", "getGrid...
Get the array of rows and cols. @param gridCoverage the coverage. @return the array as [cols, rows]
[ "Get", "the", "array", "of", "rows", "and", "cols", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L485-L492
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java
CoverageUtilities.getLoopColsRowsForSubregion
public static int[] getLoopColsRowsForSubregion( GridCoverage2D gridCoverage, Envelope2D subregion ) throws Exception { GridGeometry2D gridGeometry = gridCoverage.getGridGeometry(); GridEnvelope2D subRegionGrid = gridGeometry.worldToGrid(subregion); int minCol = subRegionGrid.x; int maxCol = subRegionGrid.x + subRegionGrid.width; int minRow = subRegionGrid.y; int maxRow = subRegionGrid.y + subRegionGrid.height; return new int[]{minCol, maxCol, minRow, maxRow}; }
java
public static int[] getLoopColsRowsForSubregion( GridCoverage2D gridCoverage, Envelope2D subregion ) throws Exception { GridGeometry2D gridGeometry = gridCoverage.getGridGeometry(); GridEnvelope2D subRegionGrid = gridGeometry.worldToGrid(subregion); int minCol = subRegionGrid.x; int maxCol = subRegionGrid.x + subRegionGrid.width; int minRow = subRegionGrid.y; int maxRow = subRegionGrid.y + subRegionGrid.height; return new int[]{minCol, maxCol, minRow, maxRow}; }
[ "public", "static", "int", "[", "]", "getLoopColsRowsForSubregion", "(", "GridCoverage2D", "gridCoverage", ",", "Envelope2D", "subregion", ")", "throws", "Exception", "{", "GridGeometry2D", "gridGeometry", "=", "gridCoverage", ".", "getGridGeometry", "(", ")", ";", ...
Get the cols and rows ranges to use to loop the original gridcoverage. @param gridCoverage the coverage. @param subregion the sub region of the coverage to get the cols and rows to loop on. @return the array of looping values in the form [minCol, maxCol, minRow, maxRow]. @throws Exception
[ "Get", "the", "cols", "and", "rows", "ranges", "to", "use", "to", "loop", "the", "original", "gridcoverage", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L519-L527
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java
CoverageUtilities.renderedImage2IntegerArray
public static int[] renderedImage2IntegerArray( RenderedImage renderedImage, double multiply ) { int width = renderedImage.getWidth(); int height = renderedImage.getHeight(); int[] values = new int[width * height]; RandomIter imageIter = RandomIterFactory.create(renderedImage, null); int index = 0;; for( int x = 0; x < width; x++ ) { for( int y = 0; y < height; y++ ) { double sample = imageIter.getSampleDouble(x, y, 0); sample = sample * multiply; values[index++] = (int) sample; } } imageIter.done(); return values; }
java
public static int[] renderedImage2IntegerArray( RenderedImage renderedImage, double multiply ) { int width = renderedImage.getWidth(); int height = renderedImage.getHeight(); int[] values = new int[width * height]; RandomIter imageIter = RandomIterFactory.create(renderedImage, null); int index = 0;; for( int x = 0; x < width; x++ ) { for( int y = 0; y < height; y++ ) { double sample = imageIter.getSampleDouble(x, y, 0); sample = sample * multiply; values[index++] = (int) sample; } } imageIter.done(); return values; }
[ "public", "static", "int", "[", "]", "renderedImage2IntegerArray", "(", "RenderedImage", "renderedImage", ",", "double", "multiply", ")", "{", "int", "width", "=", "renderedImage", ".", "getWidth", "(", ")", ";", "int", "height", "=", "renderedImage", ".", "ge...
Transform a double values rendered image in its integer array representation by scaling the values. @param renderedImage the rendered image to transform. @param multiply value by which to multiply the values before casting to integer. @return the array holding the data.
[ "Transform", "a", "double", "values", "rendered", "image", "in", "its", "integer", "array", "representation", "by", "scaling", "the", "values", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L1050-L1066
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java
CoverageUtilities.renderedImage2ByteArray
public static byte[] renderedImage2ByteArray( RenderedImage renderedImage, boolean doRowsThenCols ) { int width = renderedImage.getWidth(); int height = renderedImage.getHeight(); byte[] values = new byte[width * height]; RandomIter imageIter = RandomIterFactory.create(renderedImage, null); int index = 0; if (doRowsThenCols) { for( int y = 0; y < height; y++ ) { for( int x = 0; x < width; x++ ) { double sample = imageIter.getSampleDouble(x, y, 0); values[index++] = (byte) sample; } } } else { for( int x = 0; x < width; x++ ) { for( int y = 0; y < height; y++ ) { double sample = imageIter.getSampleDouble(x, y, 0); values[index++] = (byte) sample; } } } imageIter.done(); return values; }
java
public static byte[] renderedImage2ByteArray( RenderedImage renderedImage, boolean doRowsThenCols ) { int width = renderedImage.getWidth(); int height = renderedImage.getHeight(); byte[] values = new byte[width * height]; RandomIter imageIter = RandomIterFactory.create(renderedImage, null); int index = 0; if (doRowsThenCols) { for( int y = 0; y < height; y++ ) { for( int x = 0; x < width; x++ ) { double sample = imageIter.getSampleDouble(x, y, 0); values[index++] = (byte) sample; } } } else { for( int x = 0; x < width; x++ ) { for( int y = 0; y < height; y++ ) { double sample = imageIter.getSampleDouble(x, y, 0); values[index++] = (byte) sample; } } } imageIter.done(); return values; }
[ "public", "static", "byte", "[", "]", "renderedImage2ByteArray", "(", "RenderedImage", "renderedImage", ",", "boolean", "doRowsThenCols", ")", "{", "int", "width", "=", "renderedImage", ".", "getWidth", "(", ")", ";", "int", "height", "=", "renderedImage", ".", ...
Transform a double values rendered image in its byte array. <p>No check is done if the double value fits in a byte.</p> @param renderedImage the rendered image to transform. @param doRowsThenCols if <code>true</code>, rows are processed in the outer loop. @return the array holding the data.
[ "Transform", "a", "double", "values", "rendered", "image", "in", "its", "byte", "array", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L1077-L1101
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java
CoverageUtilities.setNovalueBorder
public static void setNovalueBorder( WritableRaster raster ) { int width = raster.getWidth(); int height = raster.getHeight(); for( int c = 0; c < width; c++ ) { raster.setSample(c, 0, 0, doubleNovalue); raster.setSample(c, height - 1, 0, doubleNovalue); } for( int r = 0; r < height; r++ ) { raster.setSample(0, r, 0, doubleNovalue); raster.setSample(width - 1, r, 0, doubleNovalue); } }
java
public static void setNovalueBorder( WritableRaster raster ) { int width = raster.getWidth(); int height = raster.getHeight(); for( int c = 0; c < width; c++ ) { raster.setSample(c, 0, 0, doubleNovalue); raster.setSample(c, height - 1, 0, doubleNovalue); } for( int r = 0; r < height; r++ ) { raster.setSample(0, r, 0, doubleNovalue); raster.setSample(width - 1, r, 0, doubleNovalue); } }
[ "public", "static", "void", "setNovalueBorder", "(", "WritableRaster", "raster", ")", "{", "int", "width", "=", "raster", ".", "getWidth", "(", ")", ";", "int", "height", "=", "raster", ".", "getHeight", "(", ")", ";", "for", "(", "int", "c", "=", "0",...
Creates a border of novalues. @param raster the raster to process.
[ "Creates", "a", "border", "of", "novalues", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L1149-L1161
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java
CoverageUtilities.replaceNovalue
public static WritableRaster replaceNovalue( RenderedImage renderedImage, double newValue ) { WritableRaster tmpWR = (WritableRaster) renderedImage.getData(); RandomIter pitTmpIterator = RandomIterFactory.create(renderedImage, null); int height = renderedImage.getHeight(); int width = renderedImage.getWidth(); for( int y = 0; y < height; y++ ) { for( int x = 0; x < width; x++ ) { if (isNovalue(pitTmpIterator.getSampleDouble(x, y, 0))) { tmpWR.setSample(x, y, 0, newValue); } } } pitTmpIterator.done(); return tmpWR; }
java
public static WritableRaster replaceNovalue( RenderedImage renderedImage, double newValue ) { WritableRaster tmpWR = (WritableRaster) renderedImage.getData(); RandomIter pitTmpIterator = RandomIterFactory.create(renderedImage, null); int height = renderedImage.getHeight(); int width = renderedImage.getWidth(); for( int y = 0; y < height; y++ ) { for( int x = 0; x < width; x++ ) { if (isNovalue(pitTmpIterator.getSampleDouble(x, y, 0))) { tmpWR.setSample(x, y, 0, newValue); } } } pitTmpIterator.done(); return tmpWR; }
[ "public", "static", "WritableRaster", "replaceNovalue", "(", "RenderedImage", "renderedImage", ",", "double", "newValue", ")", "{", "WritableRaster", "tmpWR", "=", "(", "WritableRaster", ")", "renderedImage", ".", "getData", "(", ")", ";", "RandomIter", "pitTmpItera...
Replace the current internal novalue with a given value. @param renderedImage a {@link RenderedImage}. @param newValue the value to put in instead of the novalue. @return the rendered image with the substituted novalue.
[ "Replace", "the", "current", "internal", "novalue", "with", "a", "given", "value", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L1256-L1271
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java
CoverageUtilities.prepareROI
public static ROI prepareROI( Geometry roi, AffineTransform mt2d ) throws Exception { // transform the geometry to raster space so that we can use it as a ROI source Geometry rasterSpaceGeometry = JTS.transform(roi, new AffineTransform2D(mt2d.createInverse())); // simplify the geometry so that it's as precise as the coverage, excess coordinates // just make it slower to determine the point in polygon relationship Geometry simplifiedGeometry = DouglasPeuckerSimplifier.simplify(rasterSpaceGeometry, 1); // build a shape using a fast point in polygon wrapper return new ROIShape(new FastLiteShape(simplifiedGeometry)); }
java
public static ROI prepareROI( Geometry roi, AffineTransform mt2d ) throws Exception { // transform the geometry to raster space so that we can use it as a ROI source Geometry rasterSpaceGeometry = JTS.transform(roi, new AffineTransform2D(mt2d.createInverse())); // simplify the geometry so that it's as precise as the coverage, excess coordinates // just make it slower to determine the point in polygon relationship Geometry simplifiedGeometry = DouglasPeuckerSimplifier.simplify(rasterSpaceGeometry, 1); // build a shape using a fast point in polygon wrapper return new ROIShape(new FastLiteShape(simplifiedGeometry)); }
[ "public", "static", "ROI", "prepareROI", "(", "Geometry", "roi", ",", "AffineTransform", "mt2d", ")", "throws", "Exception", "{", "// transform the geometry to raster space so that we can use it as a ROI source", "Geometry", "rasterSpaceGeometry", "=", "JTS", ".", "transform"...
Utility method for transforming a geometry ROI into the raster space, using the provided affine transformation. @param roi a {@link Geometry} in model space. @param mt2d an {@link AffineTransform} that maps from raster to model space. This is already referred to the pixel corner. @return a {@link ROI} suitable for using with JAI. @throws ProcessException in case there are problems with ivnerting the provided {@link AffineTransform}. Very unlikely to happen.
[ "Utility", "method", "for", "transforming", "a", "geometry", "ROI", "into", "the", "raster", "space", "using", "the", "provided", "affine", "transformation", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L1281-L1291
train
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java
CoverageUtilities.isGrass
public static boolean isGrass( String path ) { File file = new File(path); File cellFolderFile = file.getParentFile(); File mapsetFile = cellFolderFile.getParentFile(); File windFile = new File(mapsetFile, "WIND"); return cellFolderFile.getName().toLowerCase().equals("cell") && windFile.exists(); }
java
public static boolean isGrass( String path ) { File file = new File(path); File cellFolderFile = file.getParentFile(); File mapsetFile = cellFolderFile.getParentFile(); File windFile = new File(mapsetFile, "WIND"); return cellFolderFile.getName().toLowerCase().equals("cell") && windFile.exists(); }
[ "public", "static", "boolean", "isGrass", "(", "String", "path", ")", "{", "File", "file", "=", "new", "File", "(", "path", ")", ";", "File", "cellFolderFile", "=", "file", ".", "getParentFile", "(", ")", ";", "File", "mapsetFile", "=", "cellFolderFile", ...
Checks if the given path is a GRASS raster file. <p>Note that there is no check on the existence of the file. @param path the path to check. @return true if the file is a grass raster.
[ "Checks", "if", "the", "given", "path", "is", "a", "GRASS", "raster", "file", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L1301-L1307
train