我如何使线条对齐,移动少于1px?

问题描述 投票:1回答:1

在子报表中,我有一行,我无法将其与周围的元素完美对齐,即使每次仅移动1 px。它似乎总是会偏离1/2像素。

是否可以将其移动到小于1像素?

jasper-reports
1个回答
0
投票

您不能

即使我理解原因,当我试图使像素完美的线条对齐时,我也会发现这很烦人,lineWidth / 2 = int(px))。我的解决方法是not使用线条,但在文本框中使用边框。

显示问题和解决方案的示例,两条连接的线(lineWidth = 2px与带有边框的文本框)

jrxml

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Lines" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3f1fba4c-298d-4b77-bf79-04798f7724f3">
    <queryString>
        <![CDATA[]]>
    </queryString>
    <title>
        <band height="50" splitType="Stretch">
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <line>
                <reportElement x="0" y="0" width="50" height="1" uuid="1b773b6e-63d4-4003-b145-edbff21586cf">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <graphicElement>
                    <pen lineWidth="2.0" lineColor="#FF0400"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="0" y="0" width="1" height="50" uuid="675afe9c-5fee-4cb8-9747-9ca3524e1a4d">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <graphicElement>
                    <pen lineWidth="2.0" lineColor="#FF0400"/>
                </graphicElement>
            </line>
            <staticText>
                <reportElement x="100" y="0" width="50" height="50" uuid="7c52df48-a692-47fa-a3bf-fca0130785fa">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="2.0" lineColor="#FF0400"/>
                    <leftPen lineWidth="2.0" lineColor="#FF0400"/>
                </box>
                <text><![CDATA[]]></text>
            </staticText>
        </band>
    </title>
</jasperReport>

输出

output

© www.soinside.com 2019 - 2024. All rights reserved.