我希望能够在单击该框架的某个JPanels中的按钮后设置JFrame的contentpane.
我的架构由一个控制器组成,该控制器创建JFrame和其中的第一个JPanel.在第一个JPanel中,我正在调用一个方法:setcontentpane(JPanel jpanel)在控制器上.但是,它不是加载传递的JPanel,而是删除所有面板(参见下面的代码)
第一个JPanel里面的ActionListener:
public void actionPerformed(ActionEvent arg0) {
controller.setpanel(new CustomPanel(string1, string2));
}
Run Code Online (Sandbox Code Playgroud)
控制器:
JFrame frame;
public void setpanel(JPanel panel)
{
frame.getContentPane().removeAll();
frame.getContentPane().add(panel);
frame.repaint();
}
public Controller(JFrame frame)
{
this.frame=frame;
}
Run Code Online (Sandbox Code Playgroud)
谁能告诉我我做错了什么?谢谢 :)
有没有办法在没有编写文字SQL的情况下在Alembic中创建一个带有postgresql排除约束的表?
例如,考虑一下这个表:
CREATE TABLE reservation (
during tsrange,
EXCLUDE USING gist (during WITH &&)
);
Run Code Online (Sandbox Code Playgroud)
排除约束似乎不属于alembic中可用的约束类型.
正如SQLAlchemy支持的那样 ExcludeConstraints
from sqlalchemy.dialects.postgresql import ExcludeConstraint, TSRANGE
class RoomBooking(Base):
__tablename__ = 'room_booking'
room = Column(Integer(), primary_key=True)
during = Column(TSRANGE())
__table_args__ = (
ExcludeConstraint(('room', '='), ('during', '&&')),
)
Run Code Online (Sandbox Code Playgroud)
但是alembic似乎没有认出它们,我想知道是否还有其他方法可以在我的架构修订历史中反映这种排除约束.
我xtsExtra用来绘制两个xts对象.
考虑以下对plot.xts的调用:
plot.xts(merge(a,b),screens=c(1,2))
Run Code Online (Sandbox Code Playgroud)
用于在两个单独的面板中绘制xts对象a和b.
如何控制y轴的间距?具体来说,我遇到了y轴标签过于靠近甚至重叠的问题.
理想情况下,我想指定在两个y轴标签之间保持的最小填充.任何帮助表示赞赏!
编辑:一个可重复的例子:
#install if needed
#install.packages("xtsExtra", repos="http://R-Forge.R-project.org")
library(xtsExtra)
ab=structure(c(-1, 0.579760106421202, -0.693649703427259, 0.0960078627769613,
0.829770469089809, -0.804276208608663, 0.72574639798749, 0.977165659135716,
-0.880178529686181, -0.662078620277974, -1, 2.35268982675599,
-0.673979231663719, 0.0673890875594205, 1.46584597734824, 0.38403707067242,
-1.53638088345349, 0.868743976582955, -1.8394614923913, 0.246736581314485
), .Dim = c(10L, 2L), .Dimnames = list(NULL, c("a", "b")), index = structure(c(1354683600,
1354770000, 1354856400, 1354942800, 1355029200, 1355115600, 1355202000,
1355288400, 1355374800, 1355461200), tzone = "", tclass = "Date"), class = c("xts",
"zoo"), .indexCLASS = "Date", .indexTZ = "", tclass = "Date", tzone = "")
plot.xts(ab,screens=c(1,2)) …Run Code Online (Sandbox Code Playgroud) 计算 (nxm) xts 对象的回报的最直接方法是什么?
当我将一个 (nxm) xts 对象mxts输入到quantmod函数中时dailyReturn,返回值是一个 (nx 1) 向量,表示第一列的返回值。我正在寻找的是一种生成 (nxm) xts 对象的方法,该对象包含mxts.
我尝试使用一些应用功能,例如
lapply(mxts,dailyReturn)
Run Code Online (Sandbox Code Playgroud)
但是返回总是有错误的类型并且丢失了它们的标签(dailyReturn将colnames向量的值更改为“daily.returns”)。
有没有一种简单的、非 hacky 的方法来实现这一目标?我可能对这个问题使用了错误的函数吗?
SQLAlchemy的支持Postgres的范围的类型,如所描述的在这里。它使用postgresql+psycopg2方言进行 Postgres 通信。这些测试用例给出了 SQLALchemy 中范围类型的使用示例。
如何过滤或排序 SQLAlchemy 中此类范围字段的一个组件(较低或较高)?
使用第一个链接中的示例
from psycopg2.extras import DateTimeRange
from sqlalchemy.dialects.postgresql import TSRANGE
class RoomBooking(Base):
__tablename__ = 'room_booking'
room = Column(Integer(), primary_key=True)
during = Column(TSRANGE())
booking = RoomBooking(
room=101,
during=DateTimeRange(datetime(2013, 3, 23), None)
)
Run Code Online (Sandbox Code Playgroud)
例如,我想过滤在给定日期时间开始的期间的预订,或者在日期时间开始之前对预订进行排序。
因此,我希望大致生成此 SQL:
SELECT room, during
FROM room_booking
WHERE lower(during) = foo
ORDER BY upper(during)
Run Code Online (Sandbox Code Playgroud)
我试过像这样的结构
RoomBooking.query.filter(RoomBooking.during.lower == foo).order_by(RoomBooking.during.upper)
Run Code Online (Sandbox Code Playgroud)
但要认识到这可能不起作用,因为 lower 是 python 对象上的一个属性,与基础表列无关。
一个可能的解决方案可能是找到一种使用upper()/lower()SQLAlchemy 范围函数的方法。
postgresql ×2
r ×2
sqlalchemy ×2
xts ×2
alembic ×1
java ×1
psycopg2 ×1
python ×1
quantmod ×1
swing ×1