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
最满意答案
我们倾向于使每个组件成为一个解决方案,包含一个或多个项目(或子组件)和一个测试项目。 测试项目包含所有单元测试。
然后,我们根据模块和组件将解决方案安排到树中,例如:
//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 ...
-
使用Visual Studio 2008和SVN在C ++中进行自动转换(Autoversioning in C++ with Visual Studio 2008 and SVN)[2021-12-29]
如果您使用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 ...
-
如何创建Visual Studio 2008 C ++项目模板?(How to create a Visual Studio 2008 C++ project template?)[2022-08-19]
是的:您在创建新项目时已经看到的是$ VsInstallDir)/ vcprojects。 要自己创建一个,你基本上创建一个.vsz和a.vsdir文件,在其中描述你的项目模板,你自己的向导的一堆脚本/ html文件,以及模板文件本身(.vcproj,附加内容等) 。 这不是一件容易的事,但一旦完成就有可能并且非常方便。 关于MSDN的完整解释,这里要详细说明。 项目项目/类别向导也是如此,它们都可以自定义。 yes it is: the ones you see already when creating ...