def getXY(image): image.setC(2) pp = ProfilePlot(image).getPlot() pw = PlotWindow(image, pp) x, y = pw.getXValues(), pw.getYValues() # convert to java double for use in CurveFitter() class xd = [Double(i) for i in x] yd = [Double(i) for i in y] return xd, yd
def test_nonzero(self): i, pi, j, pj, d, pd = self.get_values() self.assertEqual(bool(i), bool(pi)) self.assertEqual(bool(j), bool(pj)) self.assertEqual(bool(d), bool(pd)) self.assertFalse(bool(Integer(0))) self.assertFalse(bool(Long(0))) self.assertFalse(bool(Double(0.0))) self.assertTrue(bool(Integer(1))) self.assertTrue(bool(Long(1))) self.assertTrue(bool(Double(1.0)))
def test_compare(self): pfive = 5 jfive = Integer(5) ptwosix = 2.6 jtwosix = Double(2.6) # Need to check with same values on opposite sides of the operator due # to Python's richcompare behavior. # check the trues first self.assertTrue(pfive > jtwosix) self.assertTrue(jtwosix < pfive) self.assertTrue(ptwosix < jfive) self.assertTrue(jfive > ptwosix) self.assertTrue(ptwosix == jtwosix) self.assertTrue(jtwosix == ptwosix) self.assertTrue(pfive == jfive) self.assertTrue(jfive == pfive) # check the falses next self.assertFalse(pfive < jtwosix) self.assertFalse(jtwosix > pfive) self.assertFalse(ptwosix > jfive) self.assertFalse(jfive < ptwosix) self.assertFalse(pfive != jfive) self.assertFalse(jfive != pfive) self.assertFalse(ptwosix != jtwosix) self.assertFalse(jtwosix != ptwosix)
def addMapBackground(self, mapName, color=None, lineWidth=None, linePattern=None, xOffset=None, yOffset=None, labelAttribute=None, fontOffset=None): from com.raytheon.uf.viz.core.maps import MapManager rsc = MapManager.getInstance( self.getDescriptor()).loadMapByBundleName(mapName).getResource() if color is not None: rsc.getCapability(ColorableCapability).setColor( RGBColors.getRGBColor(color)) if lineWidth is not None: rsc.getCapability(OutlineCapability).setOutlineWidth(lineWidth) if linePattern is not None: rsc.getCapability(OutlineCapability).setLineStyle(linePattern) if xOffset is not None: rsc.getCapability(LabelableCapability).setxOffset(xOffset) if yOffset is not None: rsc.getCapability(LabelableCapability).setyOffset(yOffset) rsc.getCapability(LabelableCapability).setLabelField(labelAttribute) if fontOffset is not None: mag = Double(1.26**fontOffset) rsc.getCapability(MagnificationCapability).setMagnification(mag)
def getGlobals(mod): mp = HashMap() for attrName in mod.__dict__: if not attrName.startswith('__'): attr = mod.__getattribute__(attrName) t = type(attr) if t is not list: if t is str: mp.put(attrName, attr) elif t is int: mp.put(attrName, Integer(attr)) elif t is float: mp.put(attrName, Double(attr)) elif t is bool: mp.put(attrName, Boolean(attr)) else: arr = None if len(attr) > 0: t = type(attr[0]) if t is int: arr = __fillArray(attr, Integer) elif t is float: arr = __fillArray(attr, Double) elif t is str: arr = __fillArray(attr, String) mp.put(attrName, arr) return mp
def get_values(self): i = Integer(-5) pi = i.intValue() j = Long(5001) pj = j.longValue() d = Double(10.001) pd = d.doubleValue() return i, pi, j, pj, d, pd
def __init__(self): head = 'Byte,Double,Float,Integer,Long,Short'.split(',') self.data = [[ Byte(Byte.MIN_VALUE), Double(Double.MIN_VALUE), Float(Float.MIN_VALUE), Integer(Integer.MIN_VALUE), Long(Long.MIN_VALUE), Short(Short.MIN_VALUE) ], [ Byte(Byte.MAX_VALUE), Double(Double.MAX_VALUE), Float(Float.MAX_VALUE), Integer(Integer.MAX_VALUE), Long(Long.MAX_VALUE), Short(Short.MAX_VALUE) ]] DefaultTableModel.__init__(self, self.data, head)
def _makeInstance(self, i, instances=None): inst = Instance(len(i)) if instances is not None: inst.setDataset(instances) for (attName, value) in i.iteritems(): if attName in self.numericAttributes: value = Double(value) else: value = String(value) attr = self.attName2Obj[attName] #print self.attName2Domain #print "attName, value", attName, value inst.setValue(attr, value) return inst
def __init__(self, data, headings): info = [] df = DateFormat.getDateInstance(DateFormat.SHORT) for tf, date, size, f, d in data: info.append([ Boolean(tf == '1'), df.parse(date), Integer(size.strip().replace(',', '')), Float(f), Double(d) ]) DefaultTableModel.__init__(self, info, headings)
def upload_rt_as_omero_table(rt, ctx, target_id, target_type, roivec=[]): "Convert results into an OMERO table" roivec_cols = ['ROI-id', 'Shape-id', 'Z', 'C', 'T'] length = len(roivec_cols) no_of_columns = rt.getLastColumn() + length no_of_rows = rt.size() data = [[Double(0) for x in range(no_of_rows)] for y in range(no_of_columns)] columns = [TableDataColumn] * no_of_columns for c in range(0, no_of_columns): if c < length: colname = roivec_cols[c] rows = [Double(i[c]) for i in roivec] columns[c] = TableDataColumn(colname, c, Double) else: colname = rt.getColumnHeading(c - length) rows = rt.getColumnAsDoubles(c - length) columns[c] = TableDataColumn(colname, c, Double) if rows is None: continue for r in range(0, len(rows)): data[c][r] = rows[r] table_data = TableData(columns, data) browse = gateway.getFacility(BrowseFacility) # use the appropriate target DataObject and attach the MapAnnotationData object to it if target_type == "Project": target_obj = ProjectData(ProjectI(target_id, False)) elif target_type == "Dataset": target_obj = DatasetData(DatasetI(target_id, False)) elif target_type == "Image": target_obj = browse.getImage(ctx, long(target_id)) table_facility = gateway.getFacility(TablesFacility) table_facility.addTable(ctx, target_obj, "Table_from_Fiji", table_data)
def map_to_vertx(value): """Converts a Jython type to a Vert.x type.""" if value is None: return value if isinstance(value, (list, tuple)): return org.vertx.java.core.json.JsonArray(map_seq_to_java(value)) elif isinstance(value, dict): return org.vertx.java.core.json.JsonObject(map_dict_to_java(value)) elif isinstance(value, Buffer): return value._to_java_buffer() elif isinstance(value, long): return Long(value) elif isinstance(value, float): return Double(value) elif isinstance(value, int): return Integer(value) return map_to_java(value)
def getJavaValue(self, value, type): try: if type == AppilogTypes.LONG_DEF: return Long(value) if type == AppilogTypes.INTEGER_DEF: return Integer(value) if type == AppilogTypes.FLOAT_DEF: return Float(value) if type == AppilogTypes.DOUBLE_DEF: return Double(value) if type == AppilogTypes.BOOLEAN_DEF: return Boolean(value) return value except JavaException, ex: msg = ex.getMessage() info = logger.prepareJavaStackTrace() logger.debug(info) raise CiImportException, self.makeConversionMessage( 'Error while converting to type %s ' % type, msg)
import sys if sys.platform.startswith('java'): from java.lang import String, Integer, Long, Float, Short, Double varz = { 'java_string_int': String('1'), 'java_string_float': String('1.1'), 'java_string_hex': String('F00'), 'java_string_embedded_base': String('0xf00'), 'java_string_invalid': String('foobar'), 'java_integer': Integer(1), 'java_long': Long(1), 'java_short': Short(1), 'java_float': Float(1.1), 'java_double': Double(1.1) } else: varz = {} class MyObject: def __init__(self, value): self.value = value def __int__(self): return 42 / self.value def __str__(self): return 'MyObject'
['foo', 'subfoo', 'subfoo2', 'n']): d[_v] = _id from java.lang import Long, Integer, Short, Character, Byte, Boolean, Double, Float, String from java.math import BigInteger values = [ 0, 0L, 0.0, 'c', "string", (), o, c, foo, subfoo, subfoo2, n, Object, Class, Foo, SubFoo, C, SubFoo2, N, Integer, Long(0), Integer(0), Short(0), Character('c'), Byte(0), Boolean(0), Double(0), Float(0), String("js"), BigInteger("0") ] def pp(v): inst = d.get(v, None) if inst is not None: return inst if hasattr(v, '__name__'): return v.__name__ if isinstance(v, (String, Number, Character, Boolean)): n = v.__class__.__name__ return "%s[%s]" % (n[n.rfind('.') + 1:], v)
def createNativeConstellationClass(classloader=None): """ A Constellation class implemented natively in java using the ASM library. """ cw = ClassWriter(0) cw.visit(52, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, "my/ConstellationFast", None, "java/lang/Object", None) fv = cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, "angle", "D", None, None) fv.visitEnd() fv = cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, "len1", "D", None, None) fv.visitEnd() fv = cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, "len2", "D", None, None) fv.visitEnd() fv = cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, "position", "Lmpicbg/models/Point;", None, None) fv.visitEnd() fv = cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, "len_ratio", "D", None, None) fv.visitEnd() mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "(DDD[D)V", None, None) mv.visitCode() mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V") mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitVarInsn(Opcodes.DLOAD, 1) mv.visitFieldInsn(Opcodes.PUTFIELD, "my/ConstellationFast", "angle", "D") mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitVarInsn(Opcodes.DLOAD, 3) mv.visitFieldInsn(Opcodes.PUTFIELD, "my/ConstellationFast", "len1", "D") mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitVarInsn(Opcodes.DLOAD, 5) mv.visitFieldInsn(Opcodes.PUTFIELD, "my/ConstellationFast", "len2", "D") mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitVarInsn(Opcodes.DLOAD, 3) mv.visitVarInsn(Opcodes.DLOAD, 3) mv.visitVarInsn(Opcodes.DLOAD, 5) mv.visitInsn(Opcodes.DADD) mv.visitInsn(Opcodes.DDIV) mv.visitFieldInsn(Opcodes.PUTFIELD, "my/ConstellationFast", "len_ratio", "D") mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitTypeInsn(Opcodes.NEW, "mpicbg/models/Point") mv.visitInsn(Opcodes.DUP) mv.visitVarInsn(Opcodes.ALOAD, 7) mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "mpicbg/models/Point", "<init>", "([D)V") mv.visitFieldInsn(Opcodes.PUTFIELD, "my/ConstellationFast", "position", "Lmpicbg/models/Point;") mv.visitInsn(Opcodes.RETURN) mv.visitMaxs(7, 8) mv.visitEnd() mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, "matches", "(Lmy/ConstellationFast;DD)Z", None, None) mv.visitCode() mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "angle", "D") mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "angle", "D") mv.visitInsn(Opcodes.DSUB) mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "abs", "(D)D") mv.visitVarInsn(Opcodes.DLOAD, 2) mv.visitInsn(Opcodes.DCMPG) l0 = Label() mv.visitJumpInsn(Opcodes.IFGE, l0) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "len1", "D") mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "len1", "D") mv.visitInsn(Opcodes.DSUB) mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "abs", "(D)D") mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "len2", "D") mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "len2", "D") mv.visitInsn(Opcodes.DSUB) mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "abs", "(D)D") mv.visitInsn(Opcodes.DADD) mv.visitVarInsn(Opcodes.DLOAD, 4) mv.visitInsn(Opcodes.DCMPG) mv.visitJumpInsn(Opcodes.IFGE, l0) mv.visitInsn(Opcodes.ICONST_1) l1 = Label() mv.visitJumpInsn(Opcodes.GOTO, l1) mv.visitLabel(l0) mv.visitFrame(Opcodes.F_SAME, 0, None, 0, None) mv.visitInsn(Opcodes.ICONST_0) mv.visitLabel(l1) mv.visitFrame(Opcodes.F_SAME1, 0, None, 1, [Opcodes.INTEGER]) mv.visitInsn(Opcodes.IRETURN) mv.visitMaxs(6, 6) mv.visitEnd() mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, "matchesScaleInvariant", "(Lmy/ConstellationFast;DD)Z", None, None) mv.visitCode() mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "angle", "D") mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "angle", "D") mv.visitInsn(Opcodes.DSUB) mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "abs", "(D)D") mv.visitVarInsn(Opcodes.DLOAD, 2) mv.visitInsn(Opcodes.DCMPG) l0 = Label() mv.visitJumpInsn(Opcodes.IFGE, l0) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "len_ratio", "D") mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "len_ratio", "D") mv.visitInsn(Opcodes.DSUB) mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "abs", "(D)D") mv.visitVarInsn(Opcodes.DLOAD, 4) mv.visitInsn(Opcodes.DCMPG) mv.visitJumpInsn(Opcodes.IFGE, l0) mv.visitInsn(Opcodes.ICONST_1) l1 = Label() mv.visitJumpInsn(Opcodes.GOTO, l1) mv.visitLabel(l0) mv.visitFrame(Opcodes.F_SAME, 0, None, 0, None) mv.visitInsn(Opcodes.ICONST_0) mv.visitLabel(l1) mv.visitFrame(Opcodes.F_SAME1, 0, None, 1, [Opcodes.INTEGER]) mv.visitInsn(Opcodes.IRETURN) mv.visitMaxs(4, 6) mv.visitEnd() mv = cw.visitMethod(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, "computeAngle", "(DDDDDDDD)D", None, None) mv.visitCode() mv.visitVarInsn(Opcodes.DLOAD, 6) mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "sqrt", "(D)D") mv.visitVarInsn(Opcodes.DSTORE, 16) mv.visitVarInsn(Opcodes.DLOAD, 14) mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "sqrt", "(D)D") mv.visitVarInsn(Opcodes.DSTORE, 18) mv.visitVarInsn(Opcodes.DLOAD, 0) mv.visitVarInsn(Opcodes.DLOAD, 8) mv.visitInsn(Opcodes.DMUL) mv.visitVarInsn(Opcodes.DLOAD, 2) mv.visitVarInsn(Opcodes.DLOAD, 10) mv.visitInsn(Opcodes.DMUL) mv.visitInsn(Opcodes.DADD) mv.visitVarInsn(Opcodes.DLOAD, 4) mv.visitVarInsn(Opcodes.DLOAD, 12) mv.visitInsn(Opcodes.DMUL) mv.visitInsn(Opcodes.DADD) mv.visitVarInsn(Opcodes.DSTORE, 20) mv.visitVarInsn(Opcodes.DLOAD, 20) mv.visitVarInsn(Opcodes.DLOAD, 16) mv.visitVarInsn(Opcodes.DLOAD, 18) mv.visitInsn(Opcodes.DMUL) mv.visitInsn(Opcodes.DDIV) mv.visitVarInsn(Opcodes.DSTORE, 22) mv.visitVarInsn(Opcodes.DLOAD, 22) mv.visitInsn(Opcodes.DCONST_1) mv.visitInsn(Opcodes.DCMPL) l0 = Label() mv.visitJumpInsn(Opcodes.IFLE, l0) mv.visitInsn(Opcodes.DCONST_1) l1 = Label() mv.visitJumpInsn(Opcodes.GOTO, l1) mv.visitLabel(l0) mv.visitFrame(Opcodes.F_FULL, 12, [Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE], 0, []) mv.visitVarInsn(Opcodes.DLOAD, 22) mv.visitLdcInsn(Double("-1.0")) mv.visitInsn(Opcodes.DCMPG) l2 = Label() mv.visitJumpInsn(Opcodes.IFGE, l2) mv.visitLdcInsn(Double("-1.0")) mv.visitJumpInsn(Opcodes.GOTO, l1) mv.visitLabel(l2) mv.visitFrame(Opcodes.F_SAME, 0, None, 0, None) mv.visitVarInsn(Opcodes.DLOAD, 22) mv.visitLabel(l1) mv.visitFrame(Opcodes.F_SAME1, 0, None, 1, [Opcodes.DOUBLE]) mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "acos", "(D)D") mv.visitInsn(Opcodes.DRETURN) mv.visitMaxs(6, 24) mv.visitEnd() mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, "fromSearch", "(Lnet/imglib2/RealLocalizable;Lnet/imglib2/RealLocalizable;DLnet/imglib2/RealLocalizable;D)Lmy/ConstellationFast;", None, None) mv.visitCode() mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitInsn(Opcodes.ICONST_0) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "net/imglib2/RealLocalizable", "getFloatPosition", "(I)F") mv.visitInsn(Opcodes.F2D) mv.visitVarInsn(Opcodes.DSTORE, 7) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitInsn(Opcodes.ICONST_1) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "net/imglib2/RealLocalizable", "getFloatPosition", "(I)F") mv.visitInsn(Opcodes.F2D) mv.visitVarInsn(Opcodes.DSTORE, 9) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitInsn(Opcodes.ICONST_2) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "net/imglib2/RealLocalizable", "getFloatPosition", "(I)F") mv.visitInsn(Opcodes.F2D) mv.visitVarInsn(Opcodes.DSTORE, 11) mv.visitTypeInsn(Opcodes.NEW, "my/ConstellationFast") mv.visitInsn(Opcodes.DUP) mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitInsn(Opcodes.ICONST_0) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "net/imglib2/RealLocalizable", "getFloatPosition", "(I)F") mv.visitInsn(Opcodes.F2D) mv.visitVarInsn(Opcodes.DLOAD, 7) mv.visitInsn(Opcodes.DSUB) mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitInsn(Opcodes.ICONST_1) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "net/imglib2/RealLocalizable", "getFloatPosition", "(I)F") mv.visitInsn(Opcodes.F2D) mv.visitVarInsn(Opcodes.DLOAD, 9) mv.visitInsn(Opcodes.DSUB) mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitInsn(Opcodes.ICONST_2) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "net/imglib2/RealLocalizable", "getFloatPosition", "(I)F") mv.visitInsn(Opcodes.F2D) mv.visitVarInsn(Opcodes.DLOAD, 11) mv.visitInsn(Opcodes.DSUB) mv.visitVarInsn(Opcodes.DLOAD, 2) mv.visitVarInsn(Opcodes.ALOAD, 4) mv.visitInsn(Opcodes.ICONST_0) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "net/imglib2/RealLocalizable", "getFloatPosition", "(I)F") mv.visitInsn(Opcodes.F2D) mv.visitVarInsn(Opcodes.DLOAD, 7) mv.visitInsn(Opcodes.DSUB) mv.visitVarInsn(Opcodes.ALOAD, 4) mv.visitInsn(Opcodes.ICONST_1) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "net/imglib2/RealLocalizable", "getFloatPosition", "(I)F") mv.visitInsn(Opcodes.F2D) mv.visitVarInsn(Opcodes.DLOAD, 9) mv.visitInsn(Opcodes.DSUB) mv.visitVarInsn(Opcodes.ALOAD, 4) mv.visitInsn(Opcodes.ICONST_2) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "net/imglib2/RealLocalizable", "getFloatPosition", "(I)F") mv.visitInsn(Opcodes.F2D) mv.visitVarInsn(Opcodes.DLOAD, 11) mv.visitInsn(Opcodes.DSUB) mv.visitVarInsn(Opcodes.DLOAD, 5) mv.visitMethodInsn(Opcodes.INVOKESTATIC, "my/ConstellationFast", "computeAngle", "(DDDDDDDD)D") mv.visitVarInsn(Opcodes.DLOAD, 2) mv.visitVarInsn(Opcodes.DLOAD, 5) mv.visitInsn(Opcodes.ICONST_3) mv.visitIntInsn(Opcodes.NEWARRAY, Opcodes.T_DOUBLE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_0) mv.visitVarInsn(Opcodes.DLOAD, 7) mv.visitInsn(Opcodes.DASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_1) mv.visitVarInsn(Opcodes.DLOAD, 9) mv.visitInsn(Opcodes.DASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_2) mv.visitVarInsn(Opcodes.DLOAD, 11) mv.visitInsn(Opcodes.DASTORE) mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "my/ConstellationFast", "<init>", "(DDD[D)V") mv.visitInsn(Opcodes.ARETURN) mv.visitMaxs(18, 13) mv.visitEnd() mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, "fromRow", "(Ljava/util/List;)Lmy/ConstellationFast;", "(Ljava/util/List<Ljava/lang/Double;>;)Lmy/ConstellationFast;", None) mv.visitCode() mv.visitTypeInsn(Opcodes.NEW, "my/ConstellationFast") mv.visitInsn(Opcodes.DUP) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitInsn(Opcodes.ICONST_0) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;") mv.visitTypeInsn(Opcodes.CHECKCAST, "java/lang/Double") mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D") mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitInsn(Opcodes.ICONST_1) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;") mv.visitTypeInsn(Opcodes.CHECKCAST, "java/lang/Double") mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D") mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitInsn(Opcodes.ICONST_2) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;") mv.visitTypeInsn(Opcodes.CHECKCAST, "java/lang/Double") mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D") mv.visitInsn(Opcodes.ICONST_3) mv.visitIntInsn(Opcodes.NEWARRAY, Opcodes.T_DOUBLE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_0) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitInsn(Opcodes.ICONST_3) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;") mv.visitTypeInsn(Opcodes.CHECKCAST, "java/lang/Double") mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D") mv.visitInsn(Opcodes.DASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_1) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitInsn(Opcodes.ICONST_4) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;") mv.visitTypeInsn(Opcodes.CHECKCAST, "java/lang/Double") mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D") mv.visitInsn(Opcodes.DASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_2) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitInsn(Opcodes.ICONST_5) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;") mv.visitTypeInsn(Opcodes.CHECKCAST, "java/lang/Double") mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D") mv.visitInsn(Opcodes.DASTORE) mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "my/ConstellationFast", "<init>", "(DDD[D)V") mv.visitInsn(Opcodes.ARETURN) mv.visitMaxs(13, 1) mv.visitEnd() mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, "asRow", "()[D", None, None) mv.visitCode() mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "position", "Lmpicbg/models/Point;") mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "mpicbg/models/Point", "getW", "()[D") mv.visitVarInsn(Opcodes.ASTORE, 1) mv.visitIntInsn(Opcodes.BIPUSH, 6) mv.visitIntInsn(Opcodes.NEWARRAY, Opcodes.T_DOUBLE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_0) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "angle", "D") mv.visitInsn(Opcodes.DASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_1) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "len1", "D") mv.visitInsn(Opcodes.DASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_2) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "len2", "D") mv.visitInsn(Opcodes.DASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_3) mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitInsn(Opcodes.ICONST_0) mv.visitInsn(Opcodes.DALOAD) mv.visitInsn(Opcodes.DASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_4) mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitInsn(Opcodes.ICONST_1) mv.visitInsn(Opcodes.DALOAD) mv.visitInsn(Opcodes.DASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_5) mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitInsn(Opcodes.ICONST_2) mv.visitInsn(Opcodes.DALOAD) mv.visitInsn(Opcodes.DASTORE) mv.visitInsn(Opcodes.ARETURN) mv.visitMaxs(5, 2) mv.visitEnd() mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, "csvHeader", "()[Ljava/lang/String;", None, None) mv.visitCode() mv.visitIntInsn(Opcodes.BIPUSH, 6) mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/String") mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_0) mv.visitLdcInsn("angle") mv.visitInsn(Opcodes.AASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_1) mv.visitLdcInsn("len1") mv.visitInsn(Opcodes.AASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_2) mv.visitLdcInsn("len2") mv.visitInsn(Opcodes.AASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_3) mv.visitLdcInsn("x") mv.visitInsn(Opcodes.AASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_4) mv.visitLdcInsn("y") mv.visitInsn(Opcodes.AASTORE) mv.visitInsn(Opcodes.DUP) mv.visitInsn(Opcodes.ICONST_5) mv.visitLdcInsn("z") mv.visitInsn(Opcodes.AASTORE) mv.visitInsn(Opcodes.ARETURN) mv.visitMaxs(4, 0) mv.visitEnd() mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, "extractFeatures", "(Ljava/util/List;Lnet/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree;DDD)Ljava/util/List;", "(Ljava/util/List<Lnet/imglib2/RealLocalizable;>;Lnet/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree<Lnet/imglib2/RealLocalizable;>;DDD)Ljava/util/List<Lmy/ConstellationFast;>;", None) mv.visitCode() mv.visitTypeInsn(Opcodes.NEW, "java/util/ArrayList") mv.visitInsn(Opcodes.DUP) mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/ArrayList", "<init>", "()V") mv.visitVarInsn(Opcodes.ASTORE, 8) mv.visitVarInsn(Opcodes.ALOAD, 0) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "iterator", "()Ljava/util/Iterator;") mv.visitVarInsn(Opcodes.ASTORE, 9) l0 = Label() mv.visitLabel(l0) mv.visitFrame(Opcodes.F_APPEND,2, ["java/util/List", "java/util/Iterator"], 0, None) mv.visitVarInsn(Opcodes.ALOAD, 9) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z") l1 = Label() mv.visitJumpInsn(Opcodes.IFEQ, l1) mv.visitVarInsn(Opcodes.ALOAD, 9) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;") mv.visitTypeInsn(Opcodes.CHECKCAST, "net/imglib2/RealLocalizable") mv.visitVarInsn(Opcodes.ASTORE, 10) mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitVarInsn(Opcodes.ALOAD, 10) mv.visitVarInsn(Opcodes.DLOAD, 2) mv.visitInsn(Opcodes.ICONST_1) mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree", "search", "(Lnet/imglib2/RealLocalizable;DZ)V") mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree", "numNeighbors", "()I") mv.visitVarInsn(Opcodes.ISTORE, 11) mv.visitVarInsn(Opcodes.ILOAD, 11) mv.visitInsn(Opcodes.ICONST_2) l2 = Label() mv.visitJumpInsn(Opcodes.IF_ICMPLE, l2) mv.visitInsn(Opcodes.ICONST_0) mv.visitVarInsn(Opcodes.ISTORE, 12) mv.visitVarInsn(Opcodes.ILOAD, 11) mv.visitInsn(Opcodes.ICONST_2) mv.visitInsn(Opcodes.ISUB) mv.visitVarInsn(Opcodes.ISTORE, 13) mv.visitVarInsn(Opcodes.ILOAD, 11) mv.visitInsn(Opcodes.ICONST_1) mv.visitInsn(Opcodes.ISUB) mv.visitVarInsn(Opcodes.ISTORE, 14) l3 = Label() mv.visitLabel(l3) mv.visitFrame(Opcodes.F_FULL, 12, ["java/util/List", "net/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree", Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, "java/util/List", "java/util/Iterator", "net/imglib2/RealLocalizable", Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.INTEGER], 0, []) mv.visitVarInsn(Opcodes.ILOAD, 13) mv.visitJumpInsn(Opcodes.IFLE, l2) mv.visitVarInsn(Opcodes.DLOAD, 6) mv.visitVarInsn(Opcodes.ILOAD, 12) mv.visitInsn(Opcodes.I2D) mv.visitInsn(Opcodes.DCMPL) l4 = Label() mv.visitJumpInsn(Opcodes.IFNE, l4) mv.visitJumpInsn(Opcodes.GOTO, l2) mv.visitLabel(l4) mv.visitFrame(Opcodes.F_SAME, 0, None, 0, None) mv.visitVarInsn(Opcodes.ALOAD, 10) mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitVarInsn(Opcodes.ILOAD, 13) mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree", "getPosition", "(I)Lnet/imglib2/RealLocalizable;") mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitVarInsn(Opcodes.ILOAD, 13) mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree", "getSquareDistance", "(I)D") mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitVarInsn(Opcodes.ILOAD, 14) mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree", "getPosition", "(I)Lnet/imglib2/RealLocalizable;") mv.visitVarInsn(Opcodes.ALOAD, 1) mv.visitVarInsn(Opcodes.ILOAD, 14) mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree", "getSquareDistance", "(I)D") mv.visitMethodInsn(Opcodes.INVOKESTATIC, "my/ConstellationFast", "fromSearch", "(Lnet/imglib2/RealLocalizable;Lnet/imglib2/RealLocalizable;DLnet/imglib2/RealLocalizable;D)Lmy/ConstellationFast;") mv.visitVarInsn(Opcodes.ASTORE, 15) mv.visitVarInsn(Opcodes.ALOAD, 15) mv.visitFieldInsn(Opcodes.GETFIELD, "my/ConstellationFast", "angle", "D") mv.visitVarInsn(Opcodes.DLOAD, 4) mv.visitInsn(Opcodes.DCMPL) l5 = Label() mv.visitJumpInsn(Opcodes.IFLT, l5) mv.visitIincInsn(12, 1) mv.visitVarInsn(Opcodes.ALOAD, 8) mv.visitVarInsn(Opcodes.ALOAD, 15) mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z") mv.visitInsn(Opcodes.POP) mv.visitLabel(l5) mv.visitFrame(Opcodes.F_SAME, 0, None, 0, None) mv.visitIincInsn(13, -1) mv.visitIincInsn(14, -1) mv.visitJumpInsn(Opcodes.GOTO, l3) mv.visitLabel(l2) mv.visitFrame(Opcodes.F_FULL, 7, ["java/util/List", "net/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree", Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, "java/util/List", "java/util/Iterator"], 0, []) mv.visitJumpInsn(Opcodes.GOTO, l0) mv.visitLabel(l1) mv.visitFrame(Opcodes.F_CHOP,1, None, 0, None) mv.visitVarInsn(Opcodes.ALOAD, 8) mv.visitInsn(Opcodes.ARETURN) mv.visitMaxs(7, 16) mv.visitEnd() cw.visitEnd() if not classloader: classloader = CustomClassLoader() return classloader.defineClass("my/ConstellationFast", cw.toByteArray())