我怎样才能让我的线排成一行,移动小于 1px?
How can I make my lines line up, move less then 1px?
在子报表中我有一条线,但我无法将其与周围的元素完美对齐,即使每次只移动 1 px。它似乎总是有 1/2 个像素的偏差。
是否可以将其移动小于 1 px?
你不能
当我试图让像素完美的线条对齐时,我也觉得这很烦人,即使我明白原因,lineWidth/2 = int (px))。我的解决方法是不使用线条,而是在文本框上使用边框。
显示问题和解决方案的示例,2 条连接线(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>
输出
在子报表中我有一条线,但我无法将其与周围的元素完美对齐,即使每次只移动 1 px。它似乎总是有 1/2 个像素的偏差。
是否可以将其移动小于 1 px?
你不能
当我试图让像素完美的线条对齐时,我也觉得这很烦人,即使我明白原因,lineWidth/2 = int (px))。我的解决方法是不使用线条,而是在文本框上使用边框。
显示问题和解决方案的示例,2 条连接线(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>
输出