首页 \ 问答 \ swt中的文字轮廓(Text outline in swt)

swt中的文字轮廓(Text outline in swt)

我试图找出如何使用swt图形显示文本轮廓。 更确切地说,我需要编写以下列方式显示文本的代码: http//java.sun.com/developer/onlineTraining/Media/2DText/Art/StarryShape.gif

我找到了以下代码,我想将它从awt转换为swt。

FontRenderContext frc = g2.getFontRenderContext(); 
Font f = new Font("Times",Font.BOLD,w/10);
String s = new String("The Starry Night");
TextLayout tl = new TextLayout(s, f, frc);
float sw = (float) tl.getBounds().getWidth();
AffineTransform transform = new AffineTransform();
transform.setToTranslation(w/2-sw/2, h/4);
Shape shape = tl.getOutline(transform);
Rectangle r = shape.getBounds();
g2.setColor(Color.blue);
g2.draw(shape);

(来自java.sun.com/developer/onlineTraining/Media/2DText/style.html的代码)

但我无法弄清楚如何在swt中获取TextLayout的大纲。 有可能吗?


I am trying to find out how to show text outline by using of swt graphics. More precisely I need to write code which shows text in following way: http://java.sun.com/developer/onlineTraining/Media/2DText/Art/StarryShape.gif

I found following code and I'd like to translate it from awt to swt.

FontRenderContext frc = g2.getFontRenderContext(); 
Font f = new Font("Times",Font.BOLD,w/10);
String s = new String("The Starry Night");
TextLayout tl = new TextLayout(s, f, frc);
float sw = (float) tl.getBounds().getWidth();
AffineTransform transform = new AffineTransform();
transform.setToTranslation(w/2-sw/2, h/4);
Shape shape = tl.getOutline(transform);
Rectangle r = shape.getBounds();
g2.setColor(Color.blue);
g2.draw(shape);

(code from java.sun.com/developer/onlineTraining/Media/2DText/style.html )

But I can't figure out how to get Outline of the TextLayout in swt. Is there such possibility?


原文:https://stackoverflow.com/questions/4538796
更新时间:2022-09-06 14:09

最满意答案

我们倾向于使每个组件成为一个解决方案,包含一个或多个项目(或子组件)和一个测试项目。 测试项目包含所有单元测试。

然后,我们根据模块和组件将解决方案安排到树中,例如:

//depot/MyProject/ASubSystem/AComponentOfTheSubSystem/ASubComponentWithAVSSolution

该解决方案将包含几个Visual Studio项目:

//depot/MyProject/ASubSystem/AComponentOfTheSubSystem/ASubComponentWithAVSSolution/Something
//depot/MyProject/ASubSystem/AComponentOfTheSubSystem/ASubComponentWithAVSSolution/SomethingElse
//depot/MyProject/ASubSystem/AComponentOfTheSubSystem/ASubComponentWithAVSSolution/TestTheSolution

树的深度可能更多,或更少,具体取决于组件/子组件的数量。 我们还倾向于在子系统和子组件级别上具有一般可重用的东西的“通用”解决方案。

然后,我们有一个子系统级解决方案,将所有内容联系在一起以构建子系统。

我们不使用或导出到“include”目录。 我们让Visual Studio在我们的沙箱中构建和链接。 我们有一个单独的“发布”沙箱,以确保我们不会意外链接错误的库。


We tend to make each component a solution, containing one or more projects (or sub-components) and a test project. The test project contains all of the unit tests.

We then arrange the solutions into a tree based on modules and components, for example:

//depot/MyProject/ASubSystem/AComponentOfTheSubSystem/ASubComponentWithAVSSolution

The solution will then contain several Visual Studio projects:

//depot/MyProject/ASubSystem/AComponentOfTheSubSystem/ASubComponentWithAVSSolution/Something
//depot/MyProject/ASubSystem/AComponentOfTheSubSystem/ASubComponentWithAVSSolution/SomethingElse
//depot/MyProject/ASubSystem/AComponentOfTheSubSystem/ASubComponentWithAVSSolution/TestTheSolution

There might be more depth to the tree, or less, depending on the number of components/sub-components there are. We also tend to have a "General" solution at the sub system and sub component level with general re-useable stuff.

We then have a sub system-level solution which ties everything together to build the sub system.

We do not use or export to an "include" directory. We let Visual Studio build and link within our sandboxes. We have a separate "Release" sandbox to ensure we don't accidentally link the wrong library.

相关问答

更多
  • 当你说“不能再运行它”时会发生什么? sln文件不兼容; 每个VS版本都需要不同的sln文件 csproj 大多是兼容的,尽管你可能会看到“版本4不被识别,使用3.5而不是”警告或两个,通常是罚款 只要您不使用dynamic或其他新语言功能,cs就是兼容的 在大多数情况下,您只需为VS2010提供一个单独的sln即可脱身。 因此,只需将其重命名为“Whatever_2010.sln”,从源代码库中取回旧的“Whatever.sln”,并将其重命名为“Whatever_2008.sln”。 When you ...
  • 一些想法尝试... 正如@David Paxson在评论中所说的,在一些语言(例如C#,VB)中,所有项目似乎都是“内置的”,但编译器会跳过那些不需要更快建立的项目,甚至尽管它们仍然在输出中列出。 所以它可能只是重建所有东西。 此外,使用C#,Visual Studio有时会连续多次运行项目,有时候它会决定没有明显的原因需要“重建”项目,但这通常只需要几秒钟,除非您有数百个项目。 重新启动Visual Studio(甚至完全重启PC)。 做一个“重建所有”的整个解决方案,以清除任何旧的缓存信息,并确保所有的 ...
  • 假设您有可用的那些库的预编译版本(即.lib文件,以及带有该接口的一堆.h文件)。 进入Project Properties,从左侧的树中选择Linker \ General。 在“其他库目录”中,添加路径到这些.lib文件所在的位置。然后转到Linker \ Input,并列出“附加依赖项”中的所有.lib文件。 这应该照顾链接。 对于头文件,您需要转到C / C ++ \ General,并将他们所在的目录添加到“Additional Include Directories”中。 那你就像往常一样#in ...
  • 这两个问题都与toolversion =“4.0”问题有关。 我的解决方案中集成了很多项目,因此我在解决方案目录中搜索了“toolsversion =”。 事实证明我的一些.csproj项目文件确实设置为4.0。 一旦所有项目都设置为3.5,安全选项卡就会返回,编译时我没有收到任何更多错误。 Both of these problems were related to the toolsversion="4.0" issue. I have a lot of projects integrated into ...
  • 我们倾向于使每个组件成为一个解决方案,包含一个或多个项目(或子组件)和一个测试项目。 测试项目包含所有单元测试。 然后,我们根据模块和组件将解决方案安排到树中,例如: //depot/MyProject/ASubSystem/AComponentOfTheSubSystem/ASubComponentWithAVSSolution 该解决方案将包含几个Visual Studio项目: //depot/MyProject/ASubSystem/AComponentOfTheSubSystem/ASubCom ...
  • 如果您使用TortoiseSVN,则可以在预构建事件中使用subwcrev.exe将当前修订号写入源文件。 因此,请检查文件version.template.hpp并添加类似的内容 const string version = "13.12.0.$WCREV$"; 添加项目预构建事件 subwcrev.exe "$(SolutionDir)." "$(ProjectDir)version.template.hpp" "$(ProjectDir)version.hpp" 并 ...
  • 首先,你需要有一个视频卡,并检查它是否与OpenGL一起工作,并且驱动程序被更新。 我在这个链接中使用了测试来检查它。 检查Visual Studio 2008的安装是否正确以及您的计算机中是否创建了以下路径也很重要: C:\ Program Files \ Microsoft SDKs \ Windows \ v6.0A 现在我们可以按照安装步骤进行: 1.-从https://www.opengl.org/resources/libraries/glut/glut_downloads.php 下载GLUT ...
  • 我不应该想为什么不 - 只要你保持通常的CRT内存边界(即如果你在库函数中分配内存,总是从库中释放它 - 通过调用lib中的函数来执行释放)。 这种方法适用于使用各种编译器编译的dll,静态链接的库也应该没问题。 I shouldn't think why not - as long as you keep the usual CRT memory boundaries (ie if you allocate memory inside a library function, always free it ...
  • 您要做的是将C#项目添加到现有解决方案中 。 在解决方案资源管理器中,右键单击解决方案并选择“添加”>“现有项目”。 选择C#项目。 现在,您的解决方案中将有两个项目(一个C#和一个C ++)。 构建解决方案时,都会构建两个项目。 更改的文件是* .sln。 What you want to do is to add the C# project to an existing solution. In solution explorer, right-click on the solution and ch ...
  • 是的:您在创建新项目时已经看到的是$ VsInstallDir)/ vcprojects。 要自己创建一个,你基本上创建一个.vsz和a.vsdir文件,在其中描述你的项目模板,你自己的向导的一堆脚本/ html文件,以及模板文件本身(.vcproj,附加内容等) 。 这不是一件容易的事,但一旦完成就有可能并且非常方便。 关于MSDN的完整解释,这里要详细说明。 项目项目/类别向导也是如此,它们都可以自定义。 yes it is: the ones you see already when creating ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。