code
stringlengths
73
34.1k
label
stringclasses
1 value
public void goTo( Sector sector, boolean animate ) { View view = getWwd().getView(); view.stopAnimations(); view.stopMovement(); if (sector == null) { return; } // Create a bounding box for the specified sector in order to estimate // its size in model...
java
public void setFlatGlobe( boolean doMercator ) { EarthFlat globe = new EarthFlat(); globe.setElevationModel(new ZeroElevationModel()); wwd.getModel().setGlobe(globe); wwd.getView().stopMovement(); GeographicProjection projection; if (doMercator) { projection =...
java
public void setSphereGlobe() { Earth globe = new Earth(); wwd.getModel().setGlobe(globe); wwd.getView().stopMovement(); wwd.redraw(); }
java
public void setFlatSphereGlobe() { Earth globe = new Earth(); globe.setElevationModel(new ZeroElevationModel()); wwd.getModel().setGlobe(globe); wwd.getView().stopMovement(); wwd.redraw(); }
java
public List<Message> getFilteredList( EMessageType messageType, Long fromTsMillis, Long toTsMillis, long limit ) throws Exception { String tableName = TABLE_MESSAGES; String sql = "select " + getQueryFieldsString() + " from " + tableName; List<String> wheresList = new ArrayList<>();...
java
@Override public boolean accept(File file) { String name = file.getName(); if (FilenameUtils.wildcardMatch(name, wildcards, caseSensitivity)) { return true; } return false; }
java
public SimpleFeature convertDwgAttribute( String typeName, String layerName, DwgAttrib attribute, int id ) { Point2D pto = attribute.getInsertionPoint(); Coordinate coord = new Coordinate(pto.getX(), pto.getY(), attribute.getElevation()); String textString = attribute.getText(); ...
java
public SimpleFeature convertDwgPolyline2D( String typeName, String layerName, DwgPolyline2D polyline2d, int id ) { Point2D[] ptos = polyline2d.getPts(); CoordinateList coordList = new CoordinateList(); if (ptos != null) { for( int j = 0; j < ptos.length; j++ ) { ...
java
public SimpleFeature convertDwgPoint( String typeName, String layerName, DwgPoint point, int id ) { double[] p = point.getPoint(); Point2D pto = new Point2D.Double(p[0], p[1]); CoordinateList coordList = new CoordinateList(); Coordinate coord = new Coordinate(pto.getX(), pto.getY(), 0.0...
java
public SimpleFeature convertDwgLine( String typeName, String layerName, DwgLine line, int id ) { double[] p1 = line.getP1(); double[] p2 = line.getP2(); Point2D[] ptos = new Point2D[]{new Point2D.Double(p1[0], p1[1]), new Point2D.Double(p2[0], p2[1])}; CoordinateList coor...
java
public SimpleFeature convertDwgCircle( String typeName, String layerName, DwgCircle circle, int id ) { double[] center = circle.getCenter(); double radius = circle.getRadius(); Point2D[] ptos = GisModelCurveCalculator.calculateGisModelCircle(new Point2D.Double( center...
java
public SimpleFeature convertDwgSolid( String typeName, String layerName, DwgSolid solid, int id ) { double[] p1 = solid.getCorner1(); double[] p2 = solid.getCorner2(); double[] p3 = solid.getCorner3(); double[] p4 = solid.getCorner4(); Point2D[] ptos = new Point2D[]{new Point2D.D...
java
public SimpleFeature convertDwgArc( String typeName, String layerName, DwgArc arc, int id ) { double[] c = arc.getCenter(); Point2D center = new Point2D.Double(c[0], c[1]); double radius = (arc).getRadius(); double initAngle = Math.toDegrees((arc).getInitAngle()); double endAngle...
java
public static double norm_vec(double x, double y, double z) { return Math.sqrt(x * x + y * y + z * z); }
java
public static double lag1(double[] vals) { double mean = mean(vals); int size = vals.length; double r1; double q = 0; double v = (vals[0] - mean) * (vals[0] - mean); for (int i = 1; i < size; i++) { double delta0 = (vals[i - 1] - mean); double delt...
java
public static double round(double val, int places) { long factor = (long) Math.pow(10, places); // Shift the decimal the correct number of places // to the right. val = val * factor; // Round to the nearest integer. long tmp = Math.round(val); // Shift the deci...
java
public static double random(double min, double max) { assert max > min; return min + Math.random() * (max - min); }
java
private boolean checkStructure() { File ds; ds = new File(mapsetPath + File.separator + GrassLegacyConstans.CATS + File.separator); if (!ds.exists()) if (!ds.mkdir()) return false; ds = new File(mapsetPath + File.separator + GrassLegacyConstans.CELL + File.se...
java
private boolean createEmptyHeader( String filePath, int rows ) { try { RandomAccessFile theCreatedFile = new RandomAccessFile(filePath, "rw"); rowaddresses = new long[rows + 1]; // the size of a long theCreatedFile.write(4); // write the addresses of...
java
private void createCellhd( int chproj, int chzone, double chn, double chs, double che, double chw, int chcols, int chrows, double chnsres, double chewres, int chformat, int chcompressed ) throws Exception { StringBuffer data = new StringBuffer(512); data.append("proj: " + chproj + "\n").ap...
java
public boolean compressAndWriteObj( RandomAccessFile theCreatedFile, RandomAccessFile theCreatedNullFile, Object dataObject ) throws RasterWritingFailureException { if (dataObject instanceof double[][]) { compressAndWrite(theCreatedFile, theCreatedNullFile, (double[][]) dataObject); ...
java
public String getStyle(StyleType type, Color color, String colorName, String layerName) { throw new UnsupportedOperationException(); }
java
protected Reader toReader(Object input) throws IOException { if (input instanceof Reader) { return (Reader) input; } if (input instanceof InputStream) { return new InputStreamReader((InputStream) input); } if (input instanceof String) { retur...
java
public static boolean supportsNative() { if (!testedLibLoading) { LiblasJNALibrary wrapper = LiblasWrapper.getWrapper(); if (wrapper != null) { isNativeLibAvailable = true; } testedLibLoading = true; } return isNativeLibAvailable; ...
java
public static ALasReader getReader( File lasFile, CoordinateReferenceSystem crs ) throws Exception { if (supportsNative()) { return new LiblasReader(lasFile, crs); } else { return new LasReaderBuffered(lasFile, crs); } }
java
public static ALasWriter getWriter( File lasFile, CoordinateReferenceSystem crs ) throws Exception { if (supportsNative()) { return new LiblasWriter(lasFile, crs); } else { return new LasWriterBuffered(lasFile, crs); } }
java
public void setRoot( DbLevel v ) { DbLevel oldRoot = v; root = v; fireTreeStructureChanged(oldRoot); }
java
public void onError( Exception e ) { e.printStackTrace(); String localizedMessage = e.getLocalizedMessage(); if (localizedMessage == null) { localizedMessage = e.getMessage(); } if (localizedMessage == null || localizedMessage.trim().length() == 0) { local...
java
public static boolean tcaMax( FlowNode flowNode, RandomIter tcaIter, RandomIter hacklengthIter, double maxTca, double maxDistance ) { List<FlowNode> enteringNodes = flowNode.getEnteringNodes(); for( Node node : enteringNodes ) { double tca = node.getValueFromMap(tcaIter); ...
java
public static boolean isCircularBoundary( CompoundLocation<Location> location, long sequenceLength) { if (location.getLocations().size() == 1) { return false;// cant be if there is only 1 location element } boolean lastLocation = false; List<Location> locationList = location.getLocations(); for (int i ...
java
public static boolean deleteDeletedValueQualifiers(Feature feature, ArrayList<Qualifier> deleteQualifierList) { boolean deleted = false; for (Qualifier qual : deleteQualifierList) { feature.removeQualifier(qual); deleted = true; } return deleted; }
java
public static boolean deleteDuplicatedQualfiier(Feature feature, String qualifierName) { ArrayList<Qualifier> qualifiers = (ArrayList<Qualifier>) feature.getQualifiers(qualifierName); Set<String> qualifierValueSet = new HashSet<String>(); for (Qualifier qual : qualifiers) { if (qual.getValue() != null) ...
java
public ImageIcon getImage( String key ) { ImageIcon image = imageMap.get(key); if (image == null) { image = createImage(key); imageMap.put(key, image); } return image; }
java
public static Style getStyleFromFile( File file ) { Style style = null; try { String name = file.getName(); if (!name.endsWith("sld")) { String nameWithoutExtention = FileUtilities.getNameWithoutExtention(file); File sldFile = new File(file.getPare...
java
private static void genericizeftStyles( List<FeatureTypeStyle> ftStyles ) { for( FeatureTypeStyle featureTypeStyle : ftStyles ) { featureTypeStyle.featureTypeNames().clear(); featureTypeStyle.featureTypeNames().add(new NameImpl(GENERIC_FEATURE_TYPENAME)); } }
java
public static Color colorWithoutAlpha( Color color ) { return new Color(color.getRed(), color.getGreen(), color.getBlue()); }
java
public static Color colorWithAlpha( Color color, int alpha ) { return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha); }
java
public Map<String, TemplateTokenInfo> getTokensAsMap() { HashMap<String, TemplateTokenInfo> tokens = new HashMap<String, TemplateTokenInfo>(); for (TemplateTokenInfo tokenInfo : tokenInfos) tokens.put(tokenInfo.getName(), tokenInfo); return Collections.unmodifiableMap(tokens); }
java
public <T> T getTile4TileCoordinate( final int tx, final int ty, int zoom, Class<T> adaptee ) throws IOException { //System.out.println("https://tile.openstreetmap.org/" + zoom + "/" + tx + "/" + ty + ".png"); Tile tile = new Tile(tx, ty, (byte) zoom, tileSize); RendererJob mapGeneratorJob = ne...
java
public void ENopen( String input, String report, String outputBin ) throws EpanetException { int errcode = epanet.ENopen(input, report, outputBin); checkError(errcode); }
java
public void ENsaveinpfile( String fileName ) throws EpanetException { int err = epanet.ENsaveinpfile(fileName); checkError(err); }
java
public void ENsavehydfile( String filePath ) throws EpanetException { int err = epanet.ENsavehydfile(filePath); checkError(err); }
java
public int ENgetcount( Components countcode ) throws EpanetException { int[] count = new int[1]; int error = epanet.ENgetcount(countcode.getCode(), count); checkError(error); return count[0]; }
java
public float ENgetoption( OptionParameterCodes optionCode ) throws EpanetException { float[] optionValue = new float[1]; int error = epanet.ENgetoption(optionCode.getCode(), optionValue); checkError(error); return optionValue[0]; }
java
public long ENgettimeparam( TimeParameterCodes timeParameterCode ) throws EpanetException { long[] timeValue = new long[1]; int error = epanet.ENgettimeparam(timeParameterCode.getCode(), timeValue); checkError(error); return timeValue[0]; }
java
public int ENgetpatternindex( String id ) throws EpanetException { int[] index = new int[1]; int error = epanet.ENgetpatternindex(id, index); checkError(error); return index[0]; }
java
public float ENgetpatternvalue( int index, int period ) throws EpanetException { float[] value = new float[1]; int errcode = epanet.ENgetpatternvalue(index, period, value); checkError(errcode); return value[0]; }
java
public int ENgetnodeindex( String id ) throws EpanetException { int[] index = new int[1]; int error = epanet.ENgetnodeindex(id, index); checkError(error); return index[0]; }
java
public NodeTypes ENgetnodetype( int index ) throws EpanetException { int[] typecode = new int[1]; int error = epanet.ENgetnodetype(index, typecode); checkError(error); NodeTypes type = NodeTypes.forCode(typecode[0]); return type; }
java
public int ENgetlinkindex( String id ) throws EpanetException { int[] index = new int[1]; int error = epanet.ENgetlinkindex(id, index); checkError(error); return index[0]; }
java
public String ENgetlinkid( int index ) throws EpanetException { ByteBuffer bb = ByteBuffer.allocate(64); int errcode = epanet.ENgetlinkid(index, bb); checkError(errcode); String label; label = byteBuffer2String(bb); return label; }
java
public LinkTypes ENgetlinktype( int index ) throws EpanetException { int[] typecode = new int[1]; int error = epanet.ENgetlinktype(index, typecode); checkError(error); LinkTypes type = LinkTypes.forCode(typecode[0]); return type; }
java
public int[] ENgetlinknodes( int index ) throws EpanetException { int[] from = new int[1]; int[] to = new int[1]; int error = epanet.ENgetlinknodes(index, from, to); checkError(error); return new int[]{from[0], to[0]}; }
java
public float[] ENgetlinkvalue( int index, LinkParameters param ) throws EpanetException { float[] value = new float[2]; int errcode = epanet.ENgetlinkvalue(index, param.getCode(), value); checkError(errcode); return value; }
java
public int ENgetversion() throws EpanetException { int[] version = new int[0]; int errcode = epanet.ENgetversion(version); checkError(errcode); return version[0]; }
java
public void ENsetnodevalue( int index, NodeParameters nodeParameter, float value ) throws EpanetException { int errcode = epanet.ENsetnodevalue(index, nodeParameter.getCode(), value); checkError(errcode); }
java
public void ENsetlinkvalue( int index, LinkParameters linkParameter, float value ) throws EpanetException { int errcode = epanet.ENsetnodevalue(index, linkParameter.getCode(), value); checkError(errcode); }
java
public void ENaddpattern( String id ) throws EpanetException { int errcode = epanet.ENaddpattern(id); checkError(errcode); }
java
public void ENsettimeparam( TimeParameterCodes code, Long timevalue ) throws EpanetException { int errcode = epanet.ENsettimeparam(code.getCode(), timevalue); checkError(errcode); }
java
public void ENsetoption( OptionParameterCodes optionCode, float value ) throws EpanetException { int errcode = epanet.ENsetoption(optionCode.getCode(), value); checkError(errcode); }
java
public static ValidationException error(String messageKey, Object... params) { return new ValidationException( ValidationMessage.error(messageKey, params)); }
java
public static ValidationException warning(String messageKey, Object... params) { return new ValidationException( ValidationMessage.warning(messageKey, params)); }
java
public static ValidationException info(String messageKey, Object... params) { return new ValidationException( ValidationMessage.info(messageKey, params)); }
java
protected void writeFeatureLocation(Writer writer) throws IOException { new FeatureLocationWriter(entry, feature, wrapType, featureHeader, qualifierHeader).write(writer); }
java
public void beginElement(String elementName) throws IOException { addElementName(elementName); indent(); writer.write("<"); writer.write(elementName); }
java
public void openElement(String elementName) throws IOException { assert(elementNames.size() > 0); assert(elementNames.get(elementNames.size() - 1).equals(elementName)); writer.write(">"); if(indent || noTextElement) { writer.write("\n"); } }
java
@Override public void setData(FieldContent data) { // allow setting in field once only. // cannot have multiple sources for one @In ! if (this.data != null) { throw new ComponentException("Attempt to set @In field twice: " + comp + "." + field.getName()); } this.d...
java
double qobs(int dummy, double[] xt) { int x = (int) (xt[0]); double p = Math.random(); double[] distr = accumP[x]; int i, left = 0, right = distr.length - 1; // Find and return least i s.t. p <= distr[i] while (left <= right) { // Here distr[left-1] <= p <= di...
java
public static byte[] hexToBytes( String hex ) { int byteLen = hex.length() / 2; byte[] bytes = new byte[byteLen]; for( int i = 0; i < hex.length() / 2; i++ ) { int i2 = 2 * i; if (i2 + 1 > hex.length()) throw new IllegalArgumentException("Hex string has o...
java
private Geometry setSRID( Geometry g, int SRID ) { if (SRID != 0) g.setSRID(SRID); return g; }
java
private void readCoordinate() throws IOException { for( int i = 0; i < inputDimension; i++ ) { if (i <= 1) { ordValues[i] = precisionModel.makePrecise(dis.readDouble()); } else { ordValues[i] = dis.readDouble(); } } }
java
public static void connectElements( List<IHillSlope> elements ) { Collections.sort(elements, elements.get(0)); for( int i = 0; i < elements.size(); i++ ) { IHillSlope elem = elements.get(i); for( int j = i + 1; j < elements.size(); j++ ) { IHillSlope tmp = elemen...
java
public static final String bytesToHex(byte[] bs, int off, int length) { StringBuffer sb = new StringBuffer(length * 2); bytesToHexAppend(bs, off, length, sb); return sb.toString(); }
java
public Vector getPoints(double inc) { Vector arc = new Vector(); double angulo; int iempieza = (int) empieza + 1; int iacaba = (int) acaba; if (empieza <= acaba) { addNode(arc, empieza); for (angulo = iempieza; angulo <= iacaba; angulo += inc) { addNode(arc, angulo); } addNode(arc, acaba); }...
java
public Vector getCentralPoint() { Vector arc = new Vector(); if (empieza <= acaba) { addNode(arc, (empieza+acaba)/2.0); } else { addNode(arc, empieza); double alfa = 360-empieza; double beta = acaba; double an = alfa + beta; double mid = an/2.0; if (mid<=alfa) { addNode(arc, empieza+mid);...
java
public static List<FileStoreDataSet> getDataSets(File cacheRoot) { if (cacheRoot == null) { String message = Logging.getMessage("nullValue.FileStorePathIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } Arra...
java
protected static File[] listDirs(File parent) { return parent.listFiles(new FileFilter() { public boolean accept(File file) { return file.isDirectory(); } }); }
java
protected static boolean isNumeric(String s) { for (char c : s.toCharArray()) { if (!Character.isDigit(c)) return false; } return true; }
java
public static void createModulesOverview() { Map<String, List<ClassField>> hmModules = HortonMachine.getInstance().moduleName2Fields; Map<String, List<ClassField>> jggModules = JGrassGears.getInstance().moduleName2Fields; Map<String, Class< ? >> hmModulesClasses = HortonMachine.getInstance().mo...
java
public static Server startTcpServerMode( String port, boolean doSSL, String tcpPassword, boolean ifExists, String baseDir ) throws SQLException { List<String> params = new ArrayList<>(); params.add("-tcpAllowOthers"); params.add("-tcpPort"); if (port == null) { po...
java
public static Server startWebServerMode( String port, boolean doSSL, boolean ifExists, String baseDir ) throws SQLException { List<String> params = new ArrayList<>(); params.add("-webAllowOthers"); if (port != null) { params.add("-webPort"); params.add(port); } ...
java
public static String createTableFromShp( ASpatialDb db, File shapeFile, String newTableName, boolean avoidSpatialIndex ) throws Exception { FileDataStore store = FileDataStoreFinder.getDataStore(shapeFile); SimpleFeatureSource featureSource = store.getFeatureSource(); SimpleFeatureTy...
java
public static boolean importShapefile( ASpatialDb db, File shapeFile, String tableName, int limit, IHMProgressMonitor pm ) throws Exception { FileDataStore store = FileDataStoreFinder.getDataStore(shapeFile); SimpleFeatureSource featureSource = store.getFeatureSource(); SimpleFeature...
java
private void writeExif() throws IOException { IIOMetadata metadata = jpegReader.getImageMetadata(0); // names says which exif tree to get - 0 for jpeg 1 for the default String[] names = metadata.getMetadataFormatNames(); IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(names...
java
private ArrayList<IIOMetadata> readExif( IIOMetadataNode app1EXIFNode ) { // Set up input skipping EXIF ID 6-byte sequence. byte[] app1Params = (byte[]) app1EXIFNode.getUserObject(); MemoryCacheImageInputStream app1EXIFInput = new MemoryCacheImageInputStream(new ByteArrayInputStream(app1Params,...
java
private IIOMetadataNode createNewExifNode( IIOMetadata tiffMetadata, IIOMetadata thumbMeta, BufferedImage thumbnail ) { IIOMetadataNode app1Node = null; ImageWriter tiffWriter = null; try { Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("tiff"); whil...
java
private long[][] getLatitude( String lat ) { float secs = Float.parseFloat("0" + lat.substring(4)) * 60.f; long nom = (long) (secs * 1000); long[][] latl = new long[][]{{Long.parseLong(lat.substring(0, 2)), 1}, {Long.parseLong(lat.substring(2, 4)), 1}, {nom, 1000}}; re...
java
private long[][] getLongitude( String longi ) { float secs = Float.parseFloat("0" + longi.substring(5)) * 60.f; long nom = (long) (secs * 1000); long[][] longl = new long[][]{{Long.parseLong(longi.substring(0, 3)), 1}, {Long.parseLong(longi.substring(3, 5)), 1}, {nom, 1000}}; ...
java
private long[][] getTime( String time ) { long[][] timel = new long[][]{{Long.parseLong(time.substring(0, 2)), 1}, {Long.parseLong(time.substring(2, 4)), 1}, {Long.parseLong(time.substring(4)), 1}}; return timel; }
java
private String[] getDate( String date ) { String dateStr = "20" + date.substring(4) + ":" + date.substring(2, 4) + ":" + date.substring(0, 2); String[] dateArray = new String[11]; for( int i = 0; i < dateStr.length(); i++ ) dateArray[i] = dateStr.substring(i, i + 1); dateA...
java
void clear() { count = 0; m0 = 0.0; clusters.space.setToOrigin(m1); clusters.space.setToOrigin(m2); var = 0.0; key = null; }
java
void set(final double m, final Object pt) { if (m == 0.0) { if (count != 0) { clusters.space.setToOrigin(m1); clusters.space.setToOrigin(m2); } } else { clusters.space.setToScaled(m1, m, pt); clusters.space.setToScaledSqr(m2, m, pt); } count = 1; m0 = m; var = 0.0; }
java
void add(final double m, final Object pt) { if (count == 0) { set(m, pt); } else { count += 1; if (m != 0.0) { m0 += m; clusters.space.addScaled(m1, m, pt); clusters.space.addScaledSqr(m2, m, pt); update(); } } }
java
void set(GvmCluster<S,K> cluster) { if (cluster == this) throw new IllegalArgumentException("cannot set cluster to itself"); m0 = cluster.m0; clusters.space.setTo(m1, cluster.m1); clusters.space.setTo(m2, cluster.m2); var = cluster.var; }
java
void add(GvmCluster<S,K> cluster) { if (cluster == this) throw new IllegalArgumentException(); if (cluster.count == 0) return; //nothing to do if (count == 0) { set(cluster); } else { count += cluster.count; //TODO accelerate add m0 += cluster.m0; clusters.space.add(m1, cluster.m1); ...
java
public static synchronized String char2DOS437( StringBuffer stringbuffer, int i, char c ) { if (unicode2DOS437 == null) { unicode2DOS437 = new char[0x10000]; for( int j = 0; j < 256; j++ ) { char c1; if ((c1 = unicode[2][j]) != '\uFFFF') ...
java
public static void callAnnotated(Object o, Class<? extends Annotation> ann, boolean lazy) { try { getMethodOfInterest(o, ann).invoke(o); } catch (IllegalAccessException ex) { throw new RuntimeException(ex); } catch (InvocationTargetException ex) { throw new Ru...
java
public static Class infoClass(Class cmp) { Class info = null; try { info = Class.forName(cmp.getName() + "CompInfo"); } catch (ClassNotFoundException E) { // there is no info class, info = cmp; } return info; }
java
public static boolean adjustOutputPath(File outputDir, Object comp, Logger log) { boolean adjusted = false; ComponentAccess cp = new ComponentAccess(comp); for (Access in : cp.inputs()) { String fieldName = in.getField().getName(); Class fieldType = in.getField().getType(...
java
public static Properties createDefault(Object comp) { Properties p = new Properties(); ComponentAccess ca = new ComponentAccess(comp); // over all input slots. for (Access in : ca.inputs()) { try { String name = in.getField().getName(); Object ...
java