我有一些自定义组件与overriden paintComponent(Graphics g)方法.在一些组件中drawString(),Graphics g使用来自对象的方法.我想为这种绘制的字符串定义自定义字体.
我有*.ttf文件与真正的字体定义.我有一个带有样式类的css文件,定义如下字体:
.rosTexLogoTitle {
-fx-font: bold 20pt 'Tahoma Bold';
-fx-text-fill: #246db6;
-fx-font-weight: heavybold;
-fx-padding: 0 10 0 0
Run Code Online (Sandbox Code Playgroud)
我想在我的java类中定义css的所有属性,或者有一种方法可以直接从css文件中使用样式(不是必需的).
我试图用带有Map参数的构造函数创建字体:
public Font(Map<? extends Attribute, ?> attributes) {
}
Run Code Online (Sandbox Code Playgroud)
但我没有成功.我可以创建自定义字体Font.createFont(style, path)然后可以派生它来设置大小.颜色可以设置Graphics.setColor().但我不能设置'Tahoma Bold'.
我有这样的application.xml.
Run Code Online (Sandbox Code Playgroud)<module> <web> <web-uri>services-inboxService.war</web-uri> <context-root>/services/inboxService</context-root> </web> </module>
我想将不同的上下文根映射到一个web-uri.但是存在约束,每个模块应该只包含一个Web部分和每个Web - 只有一个上下文根部分.有没有办法除了复制这个命名方式不同的war文件?
看看这段代码:
IDfSessionManager manager = DfcSessionManager.getSessionManager();
try {
IDfSession session = manager.getSession(DfsUtils.getCurrentRepository());
...
return somewhat; //May be without return statement
} finally {
if (session != null) {
manager.release(session);
}
}
Run Code Online (Sandbox Code Playgroud)
这种结构重复多次并围绕不同的代码。这可以是带有或不带有 return 语句的方法。我想为这个 try-finally 块制作一些可重用的东西。
我想出了这样的认识。
public abstract class ISafeExecute<T> {
private IDfSession session = null;
protected abstract T execute() throws DfException;
public T executeSafely() throws Exception {
IDfSessionManager manager = DfcSessionManager.getSessionManager();
try {
session = manager.getSession(DfsUtils.getCurrentRepository());
return execute();
} finally {
if (session != null) {
manager.release(session);
}
} …Run Code Online (Sandbox Code Playgroud)