首页 \ 问答 \ 使用Reactor选择匹配键的事件(Select events matching a key using Reactor)

使用Reactor选择匹配键的事件(Select events matching a key using Reactor)

使用reactor( https://github.com/reactor/reactor )我通知了几个事件

 commandReactor.notify("CREATE_CUSTOMER", Event.wrap(customer));
 commandReactor.notify("CREATE_ORDER", Event.wrap(order));

我如何实现一个选择器,选择以“CREATE”开头的所有事件? 就像是

@Selector(value = "CREATE*", reactor = "@commandReactor")

提前致谢。


Using reactor(https://github.com/reactor/reactor) i notify a few events like

 commandReactor.notify("CREATE_CUSTOMER", Event.wrap(customer));
 commandReactor.notify("CREATE_ORDER", Event.wrap(order));

How do i implement a selector which selects all events starting with "CREATE"? Something like

@Selector(value = "CREATE*", reactor = "@commandReactor")

Thanks in advance.


原文:https://stackoverflow.com/questions/19790051
更新时间:2023-07-14 12:07

最满意答案

使用Hesse Normal Form可以计算从点到线的垂直距离。 因此,当距离小于一个阈值时,它们足够接近。

这样的代码叫做distanceFromLine (),内置了Java

   Line2D line = new Line2D.Double(x0, y0, x1, y1);

    double distance = line.ptLineDist(px, py);

    if (Math.abs(distance) < threshold) {
              // is Near line
    }

Using the Hesse Normal Form you can calculate the perpendicular distance from a point to a line. So when the distance is smaller than a treshhold, they are sufficiently near.

Such code is called distanceFromLine() Java has that built in

   Line2D line = new Line2D.Double(x0, y0, x1, y1);

    double distance = line.ptLineDist(px, py);

    if (Math.abs(distance) < threshold) {
              // is Near line
    }

相关问答

更多
  • Dijkstra的算法将为您提供从给定节点到连接图中所有其他节点的最短路径。 获得平均值的一种方法是迭代遍历图的每个节点,运行Dijkstra算法以获得从该节点到其他每个节点的最短距离,并获取从该节点开始的路径的平均值。 在迭代时累积“从当前节点开始的路径的平均值”。 完成迭代后除以节点数。 这是一种蛮力方法,并且会计算每个距离两次,但它应该给出正确的平均值。 Dijkstra's algorithm will give you the shortest path from a given node to ...
  • 您想在创建第一个loglog图之后调用hold on 。 此外,您只需要在第一个图上使用loglog来创建对数轴。 之后你可以调用普通plot ,它将使用对数轴。 x = linspace(0, 100); loglog(x, x, '.', 'LineWidth', 2); hold on plot(x, x.^2, '.r', 'LineWidth',2); You want to call hold on after creating your first loglog plot. Also, ...
  • 使用Hesse Normal Form可以计算从点到线的垂直距离。 因此,当距离小于一个阈值时,它们足够接近。 这样的代码叫做distanceFromLine (),内置了Java Line2D line = new Line2D.Double(x0, y0, x1, y1); double distance = line.ptLineDist(px, py); if (Math.abs(distance) < threshold) { // is Ne ...
  • 将点捕捉到线的技术术语是将点投射到线(段) 剩下的唯一问题是:点数应该投射到线还是线段? (线段仅在两点之间,线具有无限长度并且经过两个点) 下面的代码解决了两个问题:为了允许将点投射到点A-> B之外的线的部分,代码会更简单,但这也在下面的链接中介绍。 请参阅http://forums.codeguru.com/showthread.php?194400-Distance-between-point-and-line-segment 投影点在变量(xx,yy)中:( xx,yy)是最靠近(cx,cy)的l ...
  • import numpy as np def line_tuple(filename,cols=(0,1)): return np.loadtxt(filename,usecols=cols,unpack=True) #parse each line from the datafile into a tuple of the form (xvals,yvals) #store that tuple in a list. data = [line_tuple(fname) for fname in ...
  • JFreeChart绝对是一个不错的选择。 您可能会发现以下资源对了解如何开始有用。 甘特图http://sanjaal.com/java/?p=343 3D类别条形图http://sanjaal.com/java/?p=321 3D饼图http://sanjaal.com/java/?p=318 浏览API文档。 你一定会觉得它值得使用。 JFreeChart is definitely a good one. You might find the following resources useful o ...
  • 您的阵列的数字范围是多少? 我假设你想缩小它以适应你的100长线? 这只是正数吗? 在这种情况下,这样的事情应该有效 //Find the max value for scaling purposes double max = Double.MIN_VALUE; double min = Double.MAX_VALUE for(double i : array){ if(i > max) max = i; if(i < min) min = i; } for(double i : ar ...
  • 好的,我有一个答案。 人们可以像这样实现它。 import random def combine(wt1, wt2): return random.random() < .1, (wt1+wt2)//2 class Linetree(): def __init__(self, wts): self.nodes = [] for i, wt in enumerate(wts): self.nodes.append([[i+1, wt] ...
  • 是的,你可以使用GROUP BY和聚合来做这种事情。 有关此概述,请参阅规范中的聚合 。 如果你想获得每个节点的喜欢,你可以这样做: PREFIX : SELECT ?node (COUNT(*) AS ?likes) WHERE { ?s :likes ?node } GROUP BY ?node 在这里,我们按?node分组并执行COUNT(*) ,它只计算组中解决方案的数量。 这为我们提供了单个查询中每个不同?node值的喜欢数量。 如果我们想 ...
  • 移动平均线在给定窗口上完成。 因此,您需要将该窗口传递给您的平均方法(并使用它)。 所以简而言之,你没有包含所有数据,你“忘记”了那个过去那个窗口的所有数据。 所以它是windowLength信号中最后一个数据的平均值。 简单移动平均值(SMA)是前n个数据的未加权平均值。 来自https://en.wikipedia.org/wiki/Moving_average public static double movingaverage(int windowLength) { double sum = ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)