Java Graphics2D Path2D Simplify or call from separate class - java
I'm wondering if I can clean up my code somehow using a list or call it from another class because I have a lot of exact Path2D coordinates just cluttering my paintComponent.
public void paintComponent(Graphics g)
{ Graphics2D g2=(Graphics2D)g;
super.paintComponent(g2);
//Background
Rectangle background = new Rectangle(0,0,getWidth(),getHeight());
Color skyBlue = new Color(135,206,235);
g2.setColor(skyBlue);
g2.fill (background);
Path2D bunny = new Path2D.Float();
bunny.moveTo(486.63,530.25);
bunny.lineTo(483.13,532.25);
bunny.lineTo(483.13,532.25);
bunny.lineTo(483.13,532.25);
bunny.lineTo(477.38,534.38);
bunny.lineTo(477.38,534.38);
bunny.lineTo(477.38,534.38);
bunny.lineTo(469.88,535.50);
bunny.lineTo(469.88,535.50);
bunny.lineTo(469.88,535.50);
bunny.lineTo(453.50,536.38);
bunny.lineTo(453.50,536.38);
bunny.lineTo(453.50,536.38);
bunny.lineTo(437.63,537.75);
bunny.lineTo(437.63,537.75);
bunny.lineTo(437.63,537.75);
bunny.lineTo(418.75,539.25);
bunny.lineTo(418.75,539.25);
bunny.lineTo(418.75,539.25);
bunny.lineTo(405.00,539.88);
bunny.lineTo(405.00,539.88);
bunny.lineTo(405.00,539.88);
bunny.lineTo(392.25,539.63);
bunny.lineTo(392.25,539.63);
bunny.lineTo(392.25,539.63);
bunny.lineTo(385.50,539.13);
bunny.lineTo(385.50,539.13);
bunny.lineTo(385.50,539.13);
bunny.lineTo(381.00,538.63);
bunny.lineTo(381.00,538.63);
bunny.lineTo(381.00,538.63);
bunny.lineTo(375.50,537.88);
bunny.lineTo(375.50,537.88);
bunny.lineTo(375.50,537.88);
bunny.lineTo(370.13,537.75);
bunny.lineTo(370.13,537.75);
bunny.lineTo(370.13,537.75);
bunny.lineTo(364.88,537.13);
bunny.lineTo(364.88,537.13);
bunny.lineTo(364.88,537.13);
bunny.lineTo(357.75,536.63);
bunny.lineTo(357.75,536.63);
bunny.lineTo(357.75,536.63);
bunny.lineTo(353.50,536.25);
bunny.lineTo(353.50,536.25);
bunny.lineTo(353.50,536.25);
bunny.lineTo(347.88,535.75);
bunny.lineTo(347.88,535.75);
bunny.lineTo(347.88,535.75);
bunny.lineTo(341.75,535.38);
bunny.lineTo(341.75,535.38);
bunny.lineTo(341.75,535.38);
bunny.lineTo(336.25,534.38);
bunny.lineTo(336.25,534.38);
bunny.lineTo(336.25,534.38);
bunny.lineTo(328.25,532.88);
bunny.lineTo(328.25,532.88);
bunny.lineTo(328.25,532.88);
bunny.lineTo(323.00,530.63);
bunny.lineTo(323.00,530.63);
bunny.lineTo(323.00,530.63);
bunny.lineTo(318.50,528.13);
bunny.lineTo(318.50,528.13);
bunny.lineTo(318.50,528.13);
bunny.lineTo(313.50,524.63);
bunny.lineTo(313.50,524.63);
bunny.lineTo(313.50,524.63);
bunny.lineTo(311.63,521.25);
bunny.lineTo(311.63,521.25);
bunny.lineTo(311.63,521.25);
bunny.lineTo(310.38,516.25);
bunny.lineTo(310.38,516.25);
bunny.lineTo(310.38,516.25);
bunny.lineTo(309.88,513.00);
bunny.lineTo(309.88,513.00);
bunny.lineTo(309.88,513.00);
bunny.lineTo(311.13,508.38);
bunny.lineTo(311.13,508.38);
bunny.lineTo(311.13,508.38);
bunny.lineTo(312.25,505.38);
bunny.lineTo(312.25,505.38);
bunny.lineTo(312.25,505.38);
bunny.lineTo(313.00,502.63);
bunny.lineTo(313.00,502.63);
bunny.lineTo(313.00,502.63);
bunny.lineTo(314.75,500.00);
bunny.lineTo(314.75,500.00);
bunny.lineTo(314.75,500.00);
bunny.lineTo(316.38,497.63);
bunny.lineTo(316.38,497.63);
bunny.lineTo(316.38,497.63);
bunny.lineTo(316.25,494.00);
bunny.lineTo(316.25,494.00);
bunny.lineTo(316.25,494.00);
bunny.lineTo(314.88,491.00);
bunny.lineTo(314.88,491.00);
bunny.lineTo(314.88,491.00);
bunny.lineTo(312.88,486.38);
bunny.lineTo(312.88,486.38);
bunny.lineTo(312.88,486.38);
bunny.lineTo(310.13,480.00);
bunny.lineTo(310.13,480.00);
bunny.lineTo(310.13,480.00);
bunny.lineTo(308.50,474.75);
bunny.lineTo(308.50,474.75);
bunny.lineTo(308.50,474.75);
bunny.lineTo(306.63,468.75);
bunny.lineTo(306.63,468.75);
bunny.lineTo(306.63,468.75);
bunny.lineTo(305.25,462.75);
bunny.lineTo(305.25,462.75);
bunny.lineTo(305.25,462.75);
bunny.lineTo(304.88,456.63);
bunny.lineTo(304.88,456.63);
bunny.lineTo(304.88,456.63);
bunny.lineTo(304.88,449.88);
bunny.lineTo(304.88,449.88);
bunny.lineTo(304.88,449.88);
bunny.lineTo(305.00,446.38);
bunny.lineTo(305.00,446.38);
bunny.lineTo(305.00,446.38);
bunny.lineTo(305.88,442.75);
bunny.lineTo(305.88,442.75);
bunny.lineTo(305.88,442.75);
bunny.lineTo(307.63,437.88);
bunny.lineTo(307.63,437.88);
bunny.lineTo(307.63,437.88);
bunny.lineTo(309.25,434.50);
bunny.lineTo(309.25,434.50);
bunny.lineTo(309.25,434.50);
bunny.lineTo(310.50,432.25);
bunny.lineTo(310.50,432.25);
bunny.lineTo(310.50,432.25);
bunny.lineTo(311.63,430.25);
bunny.lineTo(311.63,430.25);
bunny.lineTo(311.63,430.25);
bunny.lineTo(312.50,427.25);
bunny.lineTo(312.50,427.25);
bunny.lineTo(312.50,427.25);
bunny.lineTo(312.63,424.00);
bunny.lineTo(312.63,424.00);
bunny.lineTo(312.63,424.00);
bunny.lineTo(311.75,421.25);
bunny.lineTo(311.75,421.25);
bunny.lineTo(311.75,421.25);
bunny.lineTo(309.38,417.88);
bunny.lineTo(309.38,417.88);
bunny.lineTo(309.38,417.88);
bunny.lineTo(307.00,415.00);
bunny.lineTo(307.00,415.00);
bunny.lineTo(307.00,415.00);
bunny.lineTo(304.50,412.25);
bunny.lineTo(304.50,412.25);
bunny.lineTo(304.50,412.25);
bunny.lineTo(302.63,409.38);
bunny.lineTo(302.63,409.38);
bunny.lineTo(302.63,409.38);
bunny.lineTo(300.13,406.63);
bunny.lineTo(300.13,406.63);
bunny.lineTo(300.13,406.63);
bunny.lineTo(298.00,402.88);
bunny.lineTo(298.00,402.88);
bunny.lineTo(298.00,402.88);
bunny.lineTo(296.63,400.50);
bunny.lineTo(296.63,400.50);
bunny.lineTo(296.63,400.50);
bunny.lineTo(295.38,397.88);
bunny.lineTo(295.38,397.88);
bunny.lineTo(295.38,397.88);
bunny.lineTo(294.50,395.63);
bunny.lineTo(294.50,395.63);
bunny.lineTo(294.50,395.63);
bunny.lineTo(294.13,392.88);
bunny.lineTo(294.13,392.88);
bunny.lineTo(294.13,392.88);
bunny.lineTo(293.13,389.88);
bunny.lineTo(293.13,389.88);
bunny.lineTo(293.13,389.88);
bunny.lineTo(292.38,385.75);
bunny.lineTo(292.38,385.75);
bunny.lineTo(292.38,385.75);
bunny.lineTo(291.75,381.13);
bunny.lineTo(291.75,381.13);
bunny.lineTo(291.75,381.13);
bunny.lineTo(290.88,371.75);
bunny.lineTo(290.88,371.75);
bunny.lineTo(290.88,371.75);
bunny.lineTo(291.13,366.88);
bunny.lineTo(291.13,366.88);
bunny.lineTo(291.13,366.88);
bunny.lineTo(293.25,362.50);
bunny.lineTo(293.25,362.50);
bunny.lineTo(293.25,362.50);
bunny.lineTo(295.38,358.88);
bunny.lineTo(295.38,358.88);
bunny.lineTo(295.38,358.88);
bunny.lineTo(296.75,356.38);
bunny.lineTo(296.75,356.38);
bunny.lineTo(296.75,356.38);
bunny.lineTo(300.00,350.00);
bunny.lineTo(300.00,350.00);
bunny.lineTo(300.00,350.00);
bunny.lineTo(305.63,342.75);
bunny.lineTo(305.63,342.75);
bunny.lineTo(305.63,342.75);
bunny.lineTo(309.88,337.00);
bunny.lineTo(309.88,337.00);
bunny.lineTo(309.88,337.00);
bunny.lineTo(313.50,333.13);
bunny.lineTo(313.50,333.13);
bunny.lineTo(313.50,333.13);
bunny.lineTo(319.25,327.63);
bunny.lineTo(319.25,327.63);
bunny.lineTo(319.25,327.63);
bunny.lineTo(323.38,324.00);
bunny.lineTo(323.38,324.00);
bunny.lineTo(323.38,324.00);
bunny.lineTo(328.38,321.25);
bunny.lineTo(328.38,321.25);
bunny.lineTo(328.38,321.25);
bunny.lineTo(333.75,318.88);
bunny.lineTo(333.75,318.88);
bunny.lineTo(333.75,318.88);
bunny.lineTo(338.50,316.38);
bunny.lineTo(338.50,316.38);
bunny.lineTo(338.50,316.38);
bunny.lineTo(341.63,315.50);
bunny.lineTo(341.63,315.50);
bunny.lineTo(341.63,315.50);
bunny.lineTo(348.50,313.25);
bunny.lineTo(348.50,313.25);
bunny.lineTo(348.50,313.25);
bunny.lineTo(355.25,312.00);
bunny.lineTo(355.25,312.00);
bunny.lineTo(355.25,312.00);
bunny.lineTo(361.00,310.88);
bunny.lineTo(361.00,310.88);
bunny.lineTo(361.00,310.88);
bunny.lineTo(364.50,309.75);
bunny.lineTo(364.50,309.75);
bunny.lineTo(364.50,309.75);
bunny.lineTo(367.75,307.50);
bunny.lineTo(367.75,307.50);
bunny.lineTo(367.75,307.50);
bunny.lineTo(373.25,302.50);
bunny.lineTo(373.25,302.50);
bunny.lineTo(373.25,302.50);
bunny.lineTo(379.13,296.13);
bunny.lineTo(379.13,296.13);
bunny.lineTo(379.13,296.13);
bunny.lineTo(384.25,290.13);
bunny.lineTo(384.25,290.13);
bunny.lineTo(384.25,290.13);
bunny.lineTo(389.25,283.88);
bunny.lineTo(389.25,283.88);
bunny.lineTo(389.25,283.88);
bunny.lineTo(393.25,279.50);
bunny.lineTo(393.25,279.50);
bunny.lineTo(393.25,279.50);
bunny.lineTo(396.63,275.50);
bunny.lineTo(396.63,275.50);
bunny.lineTo(396.63,275.50);
bunny.lineTo(400.50,271.38);
bunny.lineTo(400.50,271.38);
bunny.lineTo(400.50,271.38);
bunny.lineTo(406.25,266.75);
bunny.lineTo(406.25,266.75);
bunny.lineTo(406.25,266.75);
bunny.lineTo(411.50,262.13);
bunny.lineTo(411.50,262.13);
bunny.lineTo(411.50,262.13);
bunny.lineTo(414.88,259.75);
bunny.lineTo(414.88,259.75);
bunny.lineTo(414.88,259.75);
bunny.lineTo(420.25,256.63);
bunny.lineTo(420.25,256.63);
bunny.lineTo(420.25,256.63);
bunny.lineTo(424.63,253.88);
bunny.lineTo(424.63,253.88);
bunny.lineTo(424.63,253.88);
bunny.lineTo(427.50,252.88);
bunny.lineTo(427.50,252.88);
bunny.lineTo(427.50,252.88);
bunny.lineTo(431.13,251.50);
bunny.lineTo(431.13,251.50);
bunny.lineTo(431.13,251.50);
bunny.lineTo(434.25,251.13);
bunny.lineTo(434.25,251.13);
bunny.lineTo(434.25,251.13);
bunny.lineTo(437.63,251.00);
bunny.lineTo(437.63,251.00);
bunny.lineTo(437.63,251.00);
bunny.lineTo(442.50,252.25);
bunny.lineTo(442.50,252.25);
bunny.lineTo(442.50,252.25);
bunny.lineTo(445.50,253.75);
bunny.lineTo(445.50,253.75);
bunny.lineTo(445.50,253.75);
bunny.lineTo(447.88,255.25);
bunny.lineTo(447.88,255.25);
bunny.lineTo(447.88,255.25);
bunny.lineTo(450.50,258.25);
bunny.lineTo(450.50,258.25);
bunny.lineTo(450.50,258.25);
bunny.lineTo(451.88,260.75);
bunny.lineTo(451.88,260.75);
bunny.lineTo(451.88,260.75);
bunny.lineTo(453.38,264.13);
bunny.lineTo(453.38,264.13);
bunny.lineTo(453.38,264.13);
bunny.lineTo(454.25,266.88);
bunny.lineTo(454.25,266.88);
bunny.lineTo(454.25,266.88);
bunny.lineTo(455.50,271.13);
bunny.lineTo(455.50,271.13);
bunny.lineTo(455.50,271.13);
bunny.lineTo(455.63,274.75);
bunny.lineTo(455.63,274.75);
bunny.lineTo(455.63,274.75);
bunny.lineTo(456.75,276.50);
bunny.lineTo(456.75,276.50);
bunny.lineTo(456.75,276.50);
bunny.lineTo(458.63,278.00);
bunny.lineTo(458.63,278.00);
bunny.lineTo(458.63,278.00);
bunny.lineTo(460.00,278.88);
bunny.lineTo(460.00,278.88);
bunny.lineTo(460.00,278.88);
bunny.lineTo(461.00,280.75);
bunny.lineTo(461.00,280.75);
bunny.lineTo(461.00,280.75);
bunny.lineTo(462.75,281.00);
bunny.lineTo(462.75,281.00);
bunny.lineTo(462.75,281.00);
bunny.lineTo(464.88,281.88);
bunny.lineTo(464.88,281.88);
bunny.lineTo(464.88,281.88);
bunny.lineTo(467.38,283.00);
bunny.lineTo(467.38,283.00);
bunny.lineTo(467.38,283.00);
bunny.lineTo(470.13,284.50);
bunny.lineTo(470.13,284.50);
bunny.lineTo(470.13,284.50);
bunny.lineTo(472.00,286.13);
bunny.lineTo(472.00,286.13);
bunny.lineTo(473.63,287.50);
bunny.lineTo(477.13,290.13);
bunny.lineTo(477.13,290.13);
bunny.lineTo(477.13,290.13);
bunny.lineTo(479.50,292.25);
bunny.lineTo(479.50,292.25);
bunny.lineTo(479.50,292.25);
bunny.lineTo(481.50,295.00);
bunny.lineTo(481.50,295.00);
bunny.lineTo(481.50,295.00);
bunny.lineTo(483.38,299.13);
bunny.lineTo(483.38,299.13);
bunny.lineTo(483.38,299.13);
bunny.lineTo(483.38,303.63);
bunny.lineTo(483.38,303.63);
bunny.lineTo(483.38,303.63);
bunny.lineTo(482.63,308.00);
bunny.lineTo(482.63,308.00);
bunny.lineTo(482.63,308.00);
bunny.lineTo(480.75,311.75);
bunny.lineTo(480.75,311.75);
bunny.lineTo(480.75,311.75);
bunny.lineTo(469.25,325.00);
bunny.lineTo(469.25,325.00);
bunny.lineTo(469.25,325.00);
bunny.lineTo(464.00,330.63);
bunny.lineTo(464.00,330.63);
bunny.lineTo(464.00,330.63);
bunny.lineTo(458.50,337.13);
bunny.lineTo(458.50,337.13);
bunny.lineTo(458.50,337.13);
bunny.lineTo(451.75,345.13);
bunny.lineTo(451.75,345.13);
bunny.lineTo(451.75,345.13);
bunny.lineTo(448.38,349.63);
bunny.lineTo(448.38,349.63);
bunny.lineTo(448.38,349.63);
bunny.lineTo(446.00,353.13);
bunny.lineTo(446.00,353.13);
bunny.lineTo(446.00,353.13);
bunny.lineTo(443.38,357.75);
bunny.lineTo(443.38,357.75);
bunny.lineTo(443.38,357.75);
bunny.lineTo(442.13,361.13);
bunny.lineTo(442.13,361.13);
bunny.lineTo(442.13,361.13);
bunny.lineTo(441.88,367.38);
bunny.lineTo(441.88,367.38);
bunny.lineTo(441.88,367.38);
bunny.lineTo(441.75,371.75);
bunny.lineTo(441.75,371.75);
bunny.lineTo(441.75,371.75);
bunny.lineTo(442.13,375.63);
bunny.lineTo(442.13,375.63);
bunny.lineTo(442.13,375.63);
bunny.lineTo(443.00,381.88);
bunny.lineTo(443.00,381.88);
bunny.lineTo(443.00,381.88);
bunny.lineTo(444.38,385.75);
bunny.lineTo(444.38,385.75);
bunny.lineTo(444.38,385.75);
bunny.lineTo(446.50,390.75);
bunny.lineTo(446.50,390.75);
bunny.lineTo(446.50,390.75);
bunny.lineTo(450.00,396.38);
bunny.lineTo(450.00,396.38);
bunny.lineTo(450.00,396.38);
bunny.lineTo(452.88,399.50);
bunny.lineTo(452.88,399.50);
bunny.lineTo(452.88,399.50);
bunny.lineTo(457.25,404.25);
bunny.lineTo(457.25,404.25);
bunny.lineTo(457.25,404.25);
bunny.lineTo(462.38,409.50);
bunny.lineTo(462.38,409.50);
bunny.lineTo(462.38,409.50);
bunny.lineTo(467.25,414.50);
bunny.lineTo(467.25,414.50);
bunny.lineTo(467.25,414.50);
bunny.lineTo(471.25,418.63);
bunny.lineTo(471.25,418.63);
bunny.lineTo(471.25,418.63);
bunny.lineTo(473.25,421.38);
bunny.lineTo(473.25,421.38);
bunny.lineTo(473.25,421.38);
bunny.lineTo(476.63,426.13);
bunny.lineTo(476.63,426.13);
bunny.lineTo(476.63,426.13);
bunny.lineTo(480.75,431.13);
bunny.lineTo(480.75,431.13);
bunny.lineTo(480.75,431.13);
bunny.lineTo(483.50,435.13);
bunny.lineTo(483.50,435.13);
bunny.lineTo(483.50,435.13);
bunny.lineTo(485.25,439.63);
bunny.lineTo(485.25,439.63);
bunny.lineTo(485.25,439.63);
bunny.lineTo(487.50,444.75);
bunny.lineTo(487.50,444.75);
bunny.lineTo(487.50,444.75);
bunny.lineTo(489.13,448.88);
bunny.lineTo(489.13,448.88);
bunny.lineTo(489.13,448.88);
bunny.lineTo(489.75,453.88);
bunny.lineTo(489.75,453.88);
bunny.lineTo(489.75,453.88);
bunny.lineTo(490.63,459.38);
bunny.lineTo(490.63,459.38);
bunny.lineTo(490.63,459.38);
bunny.lineTo(492.38,466.25);
bunny.lineTo(492.38,466.25);
bunny.lineTo(492.38,466.25);
bunny.lineTo(493.38,472.88);
bunny.lineTo(493.38,472.88);
bunny.lineTo(493.38,472.88);
bunny.lineTo(493.88,477.13);
bunny.lineTo(493.88,477.13);
bunny.lineTo(493.88,477.13);
bunny.lineTo(494.38,480.63);
bunny.lineTo(494.38,480.63);
bunny.lineTo(494.38,480.63);
bunny.lineTo(495.50,483.38);
bunny.lineTo(495.50,483.38);
bunny.lineTo(495.50,483.38);
bunny.lineTo(498.00,485.25);
bunny.lineTo(498.00,485.25);
bunny.lineTo(498.00,485.25);
bunny.lineTo(499.50,488.00);
bunny.lineTo(499.50,488.00);
bunny.lineTo(499.50,488.00);
bunny.lineTo(500.63,491.50);
bunny.lineTo(500.63,491.50);
bunny.lineTo(500.63,491.50);
bunny.lineTo(501.25,497.13);
bunny.lineTo(501.25,497.13);
bunny.lineTo(501.25,497.13);
bunny.lineTo(500.13,501.13);
bunny.lineTo(500.13,501.13);
bunny.lineTo(500.13,501.13);
bunny.lineTo(499.13,505.63);
bunny.lineTo(499.13,505.63);
bunny.lineTo(499.13,505.63);
bunny.lineTo(497.88,507.88);
bunny.lineTo(497.88,507.88);
bunny.lineTo(497.88,507.88);
bunny.lineTo(495.88,512.25);
bunny.lineTo(495.88,512.25);
bunny.lineTo(495.88,512.25);
bunny.lineTo(494.38,516.25);
bunny.lineTo(494.38,516.25);
bunny.lineTo(494.38,516.25);
bunny.lineTo(493.25,518.63);
bunny.lineTo(493.25,518.63);
bunny.lineTo(493.25,518.63);
bunny.lineTo(491.88,521.88);
bunny.lineTo(491.88,521.88);
bunny.lineTo(491.88,521.88);
bunny.lineTo(489.38,524.00);
bunny.lineTo(489.38,524.00);
bunny.lineTo(489.38,524.00);
bunny.lineTo(489.13,526.63);
bunny.lineTo(489.13,526.63);
bunny.lineTo(489.13,526.63);
bunny.lineTo(488.13,528.75);
bunny.lineTo(488.13,528.75);
bunny.closePath();
g2.draw(bunny);
Color gold = new Color(255,215,0);
g2.setColor(gold);
g2.fill(bunny);
Path2D chocoears = new Path2D.Float();
chocoears.moveTo(473.63, 287.50);
chocoears.lineTo(473.63,287.50);
chocoears.lineTo(477.13,290.13);
chocoears.lineTo(477.13,290.13);
chocoears.lineTo(477.13,290.13);
chocoears.lineTo(479.50,292.25);
chocoears.lineTo(479.50,292.25);
chocoears.lineTo(479.50,292.25);
chocoears.lineTo(481.50,295.00);
chocoears.lineTo(481.50,295.00);
chocoears.lineTo(481.50,295.00);
chocoears.lineTo(483.38,299.13);
chocoears.lineTo(483.38,299.13);
chocoears.lineTo(483.38,299.13);
chocoears.lineTo(483.38,303.63);
chocoears.lineTo(483.38,303.63);
chocoears.lineTo(483.38,303.63);
chocoears.lineTo(482.63,308.00);
chocoears.lineTo(482.63,308.00);
chocoears.lineTo(482.63,308.00);
chocoears.lineTo(480.75,311.75);
chocoears.lineTo(480.75,311.75);
chocoears.lineTo(480.75,311.75);
chocoears.lineTo(469.25,325.00);
chocoears.lineTo(469.25,325.00);
chocoears.lineTo(469.25,325.00);
chocoears.lineTo(464.00,330.63);
chocoears.lineTo(464.00,330.63);
chocoears.lineTo(464.00,330.63);
chocoears.lineTo(458.50,337.13);
chocoears.lineTo(458.50,337.13);
chocoears.lineTo(458.50,337.13);
chocoears.lineTo(451.75,345.13);
chocoears.lineTo(451.75,345.13);
chocoears.lineTo(451.75,345.13);
chocoears.lineTo(442.33,351.00);
chocoears.lineTo(442.33,351.00);
chocoears.lineTo(442.33,351.00);
chocoears.lineTo(435.33,351.00);
chocoears.lineTo(435.33,351.00);
chocoears.lineTo(435.33,351.00);
chocoears.lineTo(432.00,349.00);
chocoears.lineTo(432.00,349.00);
chocoears.lineTo(432.00,349.00);
chocoears.lineTo(427.00,348.67);
chocoears.lineTo(427.00,348.67);
chocoears.lineTo(427.00,348.67);
chocoears.lineTo(420.00,342.67);
chocoears.lineTo(420.00,342.67);
chocoears.lineTo(420.00,342.67);
chocoears.lineTo(415.33,339.33);
chocoears.lineTo(415.33,339.33);
chocoears.lineTo(415.33,339.33);
chocoears.lineTo(412.00,341.00);
chocoears.lineTo(412.00,341.00);
chocoears.lineTo(412.00,341.00);
chocoears.lineTo(408.33,337.00);
chocoears.lineTo(408.33,337.00);
chocoears.lineTo(408.33,337.00);
chocoears.lineTo(407.33,333.33);
chocoears.lineTo(407.33,333.33);
chocoears.lineTo(407.33,333.33);
chocoears.lineTo(403.67,329.67);
chocoears.lineTo(403.67,329.67);
chocoears.lineTo(403.67,329.67);
chocoears.lineTo(399.00,331.67);
chocoears.lineTo(399.00,331.67);
chocoears.lineTo(399.00,331.67);
chocoears.lineTo(396.33,329.33);
chocoears.lineTo(396.33,329.33);
chocoears.lineTo(396.33,329.33);
chocoears.lineTo(394.33,326.67);
chocoears.lineTo(394.33,326.67);
chocoears.lineTo(394.33,326.67);
chocoears.lineTo(386.67,326.33);
chocoears.lineTo(386.67,326.33);
chocoears.lineTo(386.67,326.33);
chocoears.lineTo(382.33,320.67);
chocoears.lineTo(382.33,320.67);
chocoears.lineTo(382.33,320.67);
chocoears.lineTo(378.00,322.00);
chocoears.lineTo(378.00,322.00);
chocoears.lineTo(378.00,322.00);
chocoears.lineTo(372.00,320.00);
chocoears.lineTo(372.00,320.00);
chocoears.lineTo(372.00,320.00);
chocoears.lineTo(373.33,318.00);
chocoears.lineTo(373.33,318.00);
chocoears.lineTo(373.33,318.00);
chocoears.lineTo(371.33,315.67);
chocoears.lineTo(371.33,315.67);
chocoears.lineTo(371.33,315.67);
chocoears.lineTo(365.33,316.00);
chocoears.lineTo(365.33,316.00);
chocoears.lineTo(365.33,316.00);
chocoears.lineTo(355.25,312.00);
chocoears.lineTo(355.25,312.00);
chocoears.lineTo(355.25,312.00);
chocoears.lineTo(361.00,310.88);
chocoears.lineTo(361.00,310.88);
chocoears.lineTo(361.00,310.88);
chocoears.lineTo(364.50,309.75);
chocoears.lineTo(364.50,309.75);
chocoears.lineTo(364.50,309.75);
chocoears.lineTo(367.75,307.50);
chocoears.lineTo(367.75,307.50);
chocoears.lineTo(367.75,307.50);
chocoears.lineTo(373.25,302.50);
chocoears.lineTo(373.25,302.50);
chocoears.lineTo(373.25,302.50);
chocoears.lineTo(379.13,296.13);
chocoears.lineTo(379.13,296.13);
chocoears.lineTo(379.13,296.13);
chocoears.lineTo(384.25,290.13);
chocoears.lineTo(384.25,290.13);
chocoears.lineTo(384.25,290.13);
chocoears.lineTo(389.25,283.88);
chocoears.lineTo(389.25,283.88);
chocoears.lineTo(389.25,283.88);
chocoears.lineTo(393.25,279.50);
chocoears.lineTo(393.25,279.50);
chocoears.lineTo(393.25,279.50);
chocoears.lineTo(396.63,275.50);
chocoears.lineTo(396.63,275.50);
chocoears.lineTo(396.63,275.50);
chocoears.lineTo(400.50,271.38);
chocoears.lineTo(400.50,271.38);
chocoears.lineTo(400.50,271.38);
chocoears.lineTo(406.25,266.75);
chocoears.lineTo(406.25,266.75);
chocoears.lineTo(406.25,266.75);
chocoears.lineTo(411.50,262.13);
chocoears.lineTo(411.50,262.13);
chocoears.lineTo(411.50,262.13);
chocoears.lineTo(414.88,259.75);
chocoears.lineTo(414.88,259.75);
chocoears.lineTo(414.88,259.75);
chocoears.lineTo(420.25,256.63);
chocoears.lineTo(420.25,256.63);
chocoears.lineTo(420.25,256.63);
chocoears.lineTo(424.63,253.88);
chocoears.lineTo(424.63,253.88);
chocoears.lineTo(424.63,253.88);
chocoears.lineTo(427.50,252.88);
chocoears.lineTo(427.50,252.88);
chocoears.lineTo(427.50,252.88);
chocoears.lineTo(431.13,251.50);
chocoears.lineTo(431.13,251.50);
chocoears.lineTo(431.13,251.50);
chocoears.lineTo(434.25,251.13);
chocoears.lineTo(434.25,251.13);
chocoears.lineTo(434.25,251.13);
chocoears.lineTo(437.63,251.00);
chocoears.lineTo(437.63,251.00);
chocoears.lineTo(437.63,251.00);
chocoears.lineTo(442.50,252.25);
chocoears.lineTo(442.50,252.25);
chocoears.lineTo(442.50,252.25);
chocoears.lineTo(445.50,253.75);
chocoears.lineTo(445.50,253.75);
chocoears.lineTo(445.50,253.75);
chocoears.lineTo(447.88,255.25);
chocoears.lineTo(447.88,255.25);
chocoears.lineTo(447.88,255.25);
chocoears.lineTo(450.50,258.25);
chocoears.lineTo(450.50,258.25);
chocoears.lineTo(450.50,258.25);
chocoears.lineTo(451.88,260.75);
chocoears.lineTo(451.88,260.75);
chocoears.lineTo(451.88,260.75);
chocoears.lineTo(453.38,264.13);
chocoears.lineTo(453.38,264.13);
chocoears.lineTo(453.38,264.13);
chocoears.lineTo(454.25,266.88);
chocoears.lineTo(454.25,266.88);
chocoears.lineTo(454.25,266.88);
chocoears.lineTo(455.50,271.13);
chocoears.lineTo(455.50,271.13);
chocoears.lineTo(455.50,271.13);
chocoears.lineTo(455.63,274.75);
chocoears.lineTo(455.63,274.75);
chocoears.lineTo(455.63,274.75);
chocoears.lineTo(456.75,276.50);
chocoears.lineTo(456.75,276.50);
chocoears.lineTo(456.75,276.50);
chocoears.lineTo(458.63,278.00);
chocoears.lineTo(458.63,278.00);
chocoears.lineTo(458.63,278.00);
chocoears.lineTo(460.00,278.88);
chocoears.lineTo(460.00,278.88);
chocoears.lineTo(460.00,278.88);
chocoears.lineTo(461.00,280.75);
chocoears.lineTo(461.00,280.75);
chocoears.lineTo(461.00,280.75);
chocoears.lineTo(462.75,281.00);
chocoears.lineTo(462.75,281.00);
chocoears.lineTo(462.75,281.00);
chocoears.lineTo(464.88,281.88);
chocoears.lineTo(464.88,281.88);
chocoears.lineTo(464.88,281.88);
chocoears.lineTo(467.38,283.00);
chocoears.lineTo(467.38,283.00);
chocoears.lineTo(467.38,283.00);
chocoears.lineTo(470.13,284.50);
chocoears.lineTo(470.13,284.50);
chocoears.lineTo(470.13,284.50);
chocoears.lineTo(472.00,286.13);
chocoears.lineTo(472.00,286.13);
chocoears.closePath();
g2.draw(chocoears);
Color milkChocolate = new Color(111,68,51);
g2.setColor(milkChocolate);
g2.fill(chocoears);
//Grass
Rectangle grass = new Rectangle(0,525,getWidth(),100);
Color lawnGreen = new Color(124,252,0);
g2.setColor(lawnGreen);
g2.fill(grass);
List<Arc2D> blades = new ArrayList<Arc2D>();
for (int x = 0; x < getWidth(); x += 10) {
blades.add(new Arc2D.Double(x, 500, 10, 35, 105, 180, Arc2D.OPEN));
blades.add(new Arc2D.Double(x - 5, 510, 10, 35, 105, 180, Arc2D.OPEN));
blades.add(new Arc2D.Double(x, 520, 10, 35, 105, 180, Arc2D.OPEN));
}
Color yellowGreen = new Color(107, 142, 35);
g2.setColor(yellowGreen);
for (Shape blade : blades) {
g2.draw(blade);
}
Ellipse2D.Double circle = new Ellipse2D.Double(60,100,25,25);
g2.setColor(Color.RED);
g2.fill(circle);
Rectangle box = new Rectangle(150,100,20,80);
g2.setColor(Color.YELLOW);
g2.fill(box);
}
}
Whatever you do I would
create the Path2D objects outside of the paintComponent() method.
add each Path2D object to an ArrayList
in the paintComponent() method you can iterate through the ArrayList to paint each Path2D
Or another approach is to just have a method that:
creates each Path2D object when the class is created
then you paint the Path2D object to a BufferedImage
now that you have a BufferedImage you can create an ImageIcon and Just use a JLabel in you app and you don't need the custom panel.
Heres 2 options I would consider for cleaning up the pathing.
Use SVG, one library I know is Batik found at: http://xmlgraphics.apache.org/batik/
Once I did a project where the paths I needed would be created in photoshop then exported to Illustrator. The file format was each action was line delineated, each line was space delineated and consisted of a set of points with the last entry the command name. Here was a sample input.
10 10 m
15 15 l
10 10 12 12 v
As you can see you just read the file, create your path and do an if test for the last letter on the line and use the appropriate command with for the points. Of course you can make up your own format or procedures but it sure was nice using photoshop for me :)
Related
Adding a timer between animations in Java
Hi guys so I got this issue of adding a timer between the animations, the issue with my code is that the last animation must wait a sufficient time, in order to let the previous animations to end, the code is if (array1[0]>array1[1]) { AnimationClass a = new AnimationClass(); a.jButtonYUp(110, 30, 100,1, jButton6); a.jButtonXLeft(250, 50, 100, 1, jButton6); a.jButtonXRight(50, 250, 100, 1, jButton5); // I need the timer here about 2 seconds a.jButtonYDown(30, 110, 100, 1, jButton2); } So I would greatly appreciate if somebody could direct me to the question if its already there or answer this for me BTW that AnimationClass is a library developed by a you-tuber and I am currently following his tutorials
if (array1[0]>array1[1]) { AnimationClass a = new AnimationClass(); a.jButtonYUp(110, 30, 100,1, jButton6); a.jButtonXLeft(250, 50, 100, 1, jButton6); a.jButtonXRight(50, 250, 100, 1, jButton5); Timer timer1 = new Timer(); MyTimerTask timer1_task = new MyTimerTask(); timer1.schedule (timer1_task, 2000, 0); } class MyTimerTask extends TimerTask { public void run() { a.jButtonYDown(30, 110, 100, 1, jButton2); } }
Apache POI XSLFAutoShape - Shape OffSet property
I am drawing a pptx from scratch using ApachePOI-XSLF (ooxml implementation) and I am struggling to find good documentation and good examples. Also the library isn't easy to follow and not straight forward. I would like to know how do I set the offset of two shapes of XSFLAutoShape connected by XSLFConnectorShape. This is my code right now: XMLSlideShow pptx = new XMLSlideShow(); XSLFSlide slide = pptx.createSlide(); XSLFAutoShape rectangle = slide.createAutoShape(); rectangle.setShapeType(ShapeType.RECT); rectangle.setAnchor(new Rectangle2D.Double(100, 100, 100, 50)); rectangle.setLineColor(Color.blue); rectangle.setFillColor(Color.lightGray); XSLFAutoShape miniCircle = slide.createAutoShape(); miniCircle.setShapeType(ShapeType.ELLIPSE); miniCircle.setAnchor(new Rectangle2D.Double(rectangle.getAnchor().getMaxX() + 200, rectangle.getAnchor().getCenterY()+50, 1, 1)); miniCircle.setLineColor(Color.yellow); miniCircle.setFillColor(Color.yellow); connect(slide, rectangle, miniCircle); XSLFAutoShape anotherRectangle = slide.createAutoShape(); anotherRectangle.setShapeType(ShapeType.RECT); anotherRectangle.setAnchor(new Rectangle2D.Double(miniCircle.getAnchor().getMaxX() + 200, 100, 100, 50)); anotherRectangle.setLineColor(Color.blue); anotherRectangle.setFillColor(Color.lightGray); connect(slide, miniCircle, anotherRectangle); and the connect method: public static void connect(XSLFSlide slide, XSLFAutoShape start, XSLFAutoShape end){ XSLFConnectorShape connector = slide.createConnector(); connector.setAnchor(new Rectangle2D.Double(start.getAnchor().getX() + 100, start.getAnchor().getCenterY(), 100, 1)); CTConnector ctConnector = (CTConnector)connector.getXmlObject(); ctConnector.getSpPr().getPrstGeom().setPrst(STShapeType.STRAIGHT_CONNECTOR_1); CTNonVisualConnectorProperties cx = ctConnector.getNvCxnSpPr().getCNvCxnSpPr(); // connection start CTConnection stCxn = cx.addNewStCxn(); stCxn.setId(start.getShapeId()); // side of the rectangle to attach the connector: left=1, bottom=2,right=3, top=4 stCxn.setIdx(3); CTConnection endCxn = cx.addNewEndCxn(); endCxn.setId(end.getShapeId()); // side of the rectangle to attach the connector: left=1, bottom=2,right=3, top=4 endCxn.setIdx(3); } The output of is: This is the output But I want this: This is what I want p.s. I edit the post because someone thumbs down the post without a reason. I added more info but still complicated because the library is complicated :-/. would mind help and thumbs up again ? If you cannot help at least do not destroy my reputation. I am serious developer. Tkx.
Slick2d drawstring draws a box, no text
I've seen references to this error before but no solution. Where I am drawing the text, there is only a solid box of the specified color being drawn. The code is like this: TrueTypeFont font; Font awtFont = new Font("Arial Unicode MS", Font.BOLD, 12); //name, style (PLAIN, BOLD, or ITALIC), size font = new TrueTypeFont(awtFont, true); //base Font, anti-aliasing true/false while (!Display.isCloseRequested() ) { render(); font.drawString(10, 10, "ABC123", Color.black); //x, y, string to draw, color
//ENABLE THESE: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //RENDER LIKE THIS: glPushMatrix(); bodyPosition = body.getPosition().mul(30); glTranslatef(Position.x, Position.y, 0); GL11.glDisable(GL11.GL_TEXTURE_2D); glPopMatrix();
how to import a mat value in openCV
I exported many CalcHist mat-values into a file and build an average of the values. Now I want to import it back into my Java Programm (static in the Code or import as file, it doesn't matter) to compare the calculated average hist with a hist of an given Image. The problem is that I don't know how to import the values into a Mat variable. Example hist-values: [680.365; 898.065; 583.155; 971.535; 454.825; 202.34; 213.26; 316.98; 449.765; 9902.57; 357078.595; 1292.21; 521.705; 157.985; 109.985; 137.685; 301.395; 127.58; 0; 0; 0; 0; 0; 0] If I implement it as a static value with MatOfDouble (I don't have an idea to do it in another way) like this: MatOfDouble averageHist= new MatOfDouble(680.365, 898.065, 583.155, 971.535, 454.825, 202.34, 213.26, 316.98, 449.765, 9902.57, 357078.595, 1292.21, 521.705, 157.985, 109.985, 137.685, 301.395, 127.58, 0, 0, 0, 0, 0, 0); I can use the variable for a compareHist like this: double res= Imgproc.compareHist(baseHist, averageHist, Imgproc.CV_COMP_CORREL); and compile it, but at runtime it will throw a exception. the programm works, if I only use Mat values that I directly get from calchists like the variable baseHist, but for averageHist I want to put it static in the Code or read it from a file. I tried to cast the MatOfDouble into a normal Mat like this: Mat averSunnyHistCast = new Mat(); averSunnyHistCast = (Mat) averageHist; but it doesn't help. this is the error: CvException [org.opencv.core.CvException: cv::Exception: C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\imgproc\src\histogram.cpp:2281: error: (-215) H1.type() == H2.type() && H1.depth() == CV_32F in function cv::compareHist thanks for your help!
This post helped: OpenCV How to initialize Mat with 2D array in JAVA I wrote my values static in an array, after that I added each value into the Mat variable with the put method. double[] dblArr = {650, 1230, 257, 66, 38, 19, 20, 33, 75, 15617, 350640, 2737, 1251, 547, 325, 328, 417, 150, 0, 0, 0, 0, 0, 0, 0}; Mat averageHist = new Mat(25, 1, CvType.CV_32F); for (int i=0; i<25; i++){ averSunny200.put(i, 0, dblArr[i]); }
LineBreakMeasurer produces result differ from MS Word / LibreOffice
In a swing application, I need to foresee text wrapping of a string like when putting it in a word processor program such as MS Word or LibreOffice. Providing the same width of the displayable area, the same font (face and size) and the same string as following: displayable area width: 179mm (in a .doc file, setup an A4 portrait page - width = 210mm, margin left = 20mm, right = 11mm; the paragraph is formatted with zero margins) Font Times New Roman, size 14 Test string: Tadf fdas fdas daebjnbvx dasf opqwe dsa: dfa fdsa ewqnbcmv caqw vstrt vsip d asfd eacc And the result: On both MS Word and LibreOffice, that test string is displayed on single line, no text wrapping occurs. My bellow program report a text wrapping occurs, 2 lines Line 1: Tadf fdas fdas daebjnbvx dasf opqwe dsa: dfa fdsa ewqnbcmv caqw vstrt vsip d asfd Line 2: eacc Is it possible to achieve the same text wrapping effect like MS Word in swing? What could be wrong in the code? Bellow the my program public static List<String> wrapText(String text, float maxWidth, Graphics2D g, Font displayFont) { // Normalize the graphics context so that 1 point is exactly // 1/72 inch and thus fonts will display at the correct sizes: GraphicsConfiguration gc = g.getDeviceConfiguration(); g.transform(gc.getNormalizingTransform()); AttributedCharacterIterator paragraph = new AttributedString(text).getIterator(); Font backupFont = g.getFont(); g.setFont(displayFont); LineBreakMeasurer lineMeasurer = new LineBreakMeasurer( paragraph, BreakIterator.getWordInstance(), g.getFontRenderContext()); // Set position to the index of the first character in the paragraph. lineMeasurer.setPosition(paragraph.getBeginIndex()); List<String> lines = new ArrayList<String>(); int beginIndex = 0; // Get lines until the entire paragraph has been displayed. while (lineMeasurer.getPosition() < paragraph.getEndIndex()) { lineMeasurer.nextLayout(maxWidth); lines.add(text.substring(beginIndex, lineMeasurer.getPosition())); beginIndex = lineMeasurer.getPosition(); } g.setFont(backupFont); return lines; } public static void main(String[] args) throws Exception { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextPane txtp = new JTextPane(); frame.add(txtp); frame.setSize(200,200); frame.setVisible(true); Font displayFont = new Font("Times New Roman", Font.PLAIN, 14); float textWith = (179 * 0.0393701f) // from Millimeter to Inch * 72f; // From Inch to Pixel (User space) List<String> lines = wrapText( "Tadf fdas fdas daebjnbvx dasf opqwe dsa: dfa fdsa ewqnbcmv caqw vstrt vsip d asfd eacc", textWith, (Graphics2D) txtp.getGraphics(), displayFont); for (int i = 0; i < lines.size(); i++) { System.out.print("Line " + (i + 1) + ": "); System.out.println(lines.get(i)); } frame.dispose(); }
+1 for the question From my experience with text editors it's not possible to achieve exactly the same measuring. You can try to play with DPI there is default DPI=72 and 96 on windows. Also you can try to play with all the rendering hints of the Graphics - text antialiasing etc.