我必须使用Java通过热敏打印机打印收据.我做了一切.我的程序从数据库中获取数据,并使用特殊字符,制表符和\n转换为一个字符串.然后将字符串传递给另一个将其转换为图形的方法.
问题是当我点击打印按钮时,会出现白纸.我注意到我的String的前4-5个字符被打印在纸张末端右角的纸币的最后一行.我的打印机是Epson TM - T81.
public void printThisBill()
{
DefaultTableModel mod = (DefaultTableModel) jTable1.getModel();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
DateFormat timeFormat = new SimpleDateFormat("HH:mm");
//get current date time with Date()
Date date = new Date();
Date time = new Date();
String Date = dateFormat.format(date);
String Time = timeFormat.format(time);
String Header =
" ****Super Market**** \n"
+ "Date: "+Date+" Time: "+Time+"\n"
+ "---------------------------------\n"
+ "Name Qty Rate Amt\n"
+ "---------------------------------\n";
String amt =
"\n \n \nTotal Amount = "+ amt() +"\n" …
Run Code Online (Sandbox Code Playgroud) 我已经编写了一个简单的Fibonacci函数作为C++中的练习(使用Visual Studio)来测试Tail Recursion并查看它是如何工作的.
这是代码:
int fib_tail(int n, int res, int next) {
if (n == 0) {
return res;
}
return fib_tail(n - 1, next, res + next);
}
int main()
{
fib_tail(10,0,1); //Tail Recursion works
}
Run Code Online (Sandbox Code Playgroud)
当我使用Release模式编译时,尽管有一个调用,我仍然使用JMP指令看到了优化的程序集.所以我的结论是:尾递归有效.见下图:
我想通过增加Fibonacci函数中的输入变量n来进行一些性能测试.然后我选择将函数中使用的变量类型从int更改为unsigned long long.然后我通过了一个很大的数字:10e + 08
这是现在的新功能:
typedef unsigned long long ULONG64;
ULONG64 fib_tail(ULONG64 n, ULONG64 res, ULONG64 next) {
if (n == 0) {
return res;
}
return fib_tail(n - 1, next, res + next);
}
int main()
{
fib_tail(10e+9,0,1); …
Run Code Online (Sandbox Code Playgroud) 我有一个接口模式,如下所示(C#.NET4)
interface A
{
}
interface B
{
List<A> a;
}
interface C
{
List<B> b;
}
Run Code Online (Sandbox Code Playgroud)
我以这种方式实现它:
public interface A
{
}
public interface B<T> where T : A
{
List<T> a { get; set; }
}
public interface C<T> where T : B
{
List<T> b { get; set; } // << ERROR: Using the generic type 'B<T>' requires 1 type arguments
}
Run Code Online (Sandbox Code Playgroud)
我不知道如何避免错误使用泛型类型'B'需要1个类型的参数
如果不存在,我尝试向注册表添加密钥.虽然我调试一切都很好.代码应该工作.但我在注册表编辑器中找不到密钥.你有什么主意吗?
public void ConfigureWindowsRegistry()
{
var reg = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Office\\Outlook\\FormRegions\\tesssst", true);
if (reg == null)
{
reg = Registry.LocalMachine.CreateSubKey("Software\\Microsoft\\Office\\Outlook\\FormRegions\\tesssst");
}
if (reg.GetValue("someKey") == null)
{
reg.SetValue("someKey", "someValue");
}
}
Run Code Online (Sandbox Code Playgroud) const有问题.说我有:
class A{
friend std::ostream& operator<<(std::ostream& os,const A& myObj);
private:
std::map<int,int> someMap;
int someInteger;
};
std::ostream& operator<<(std::ostream& os,const A& myObj){
os<<myObj.someInteger<<std::endl;
os<<myObj.someMap[0]<<std::endl;
}
Run Code Online (Sandbox Code Playgroud)
由于与地图的const冲突,这种代码在编译时会产生错误(如果我注释打印地图值的行一切都很好),如果我摆脱了函数原型中的'const',一切都很好.我真的没有看到问题在哪里..
有什么帮助吗?
我可以通过在关键帧之间插值来使用assimp加载皮肤模型的动画.现在,我一直试图从用户定义的转换矩阵中定向或定位骨骼,而不是仅仅从动画文件中加载骨骼.比如,将手臂旋转一定角度,其中角度将由用户指定.我将模型加载到它的绑定姿势中:
void recursion(aiNode* gNode)
{
std::string gNodeName(gNode->mName.data);
if(boneMapping.find(gNodeName) != boneMapping.end())
{
//if node corresponds to a bone,
Matrix4f boneMatrix = IdentityMatrix;
aiNode* tempNode = gNode;
//find combined transform of a bone
while(tempNode != NULL)
{
Matrix4f NodeMatrix(tempNode->mTransformation);
boneMatrix = NodeMatrix * boneMatrix;
tempNode = tempNode->mParent;
}
pBoneData[boneId].FinalTransform = GlobalInverseTransform * boneMatrix * pBoneData[boneId].OffsetMatrix;
}
for(int i = 0; i < gNode->mNumChildren; i++)
{ //repeat this process for child nodes
recursion(gNode->mChildren[i]);
}
}
Run Code Online (Sandbox Code Playgroud)
为了使用变换矩阵定向模型的一个网格,我尝试搜索与网格的父骨相对应的骨骼名称,然后用所需的矩阵替换它的节点矩阵.然而,这根本不起作用,因为它在不同的网格处使骨骼变形.
右边的模型是T姿势,我打算通过将颈部的骨头旋转45度角来修改它,但它保持不变,腿部变形,如左侧模型所示.因此,任何现有文章或答案的链接都可能非常有用.
根据ISO标准,A4为210x297 mm,或约595.2756x841.8898点.有没有理由在iTextSharp中,点值是四舍五入的,即.595x842,即使它们是花车?
背景:从 Monobehaviour 继承的类无法序列化。
前提:一种保存 MonoBehaviour 脚本的数据(变量/字段及其值)的方法,以便可以将其序列化,并再次反序列化并使用此数据“填充”相应的 MonoBehaviour 脚本的变量/字段值。
到目前为止尝试过:
List<FieldInfo>
并用 MB 的字段填充它...有效 30%;
FieldInfos
添加但类型错误,并且我觉得这不会那么难,但我的反思技能和相关技能是有限的,但鉴于保存/加载是一个相当常见的功能,我希望有人做到了,或者有人可以为我指明正确的方向。