用java写了一个处理数据的程序,处理完的数据需要绘制成坐标图,然后将图插入word中,然后再将word文档转化为pdf。
现在问题是,绘制出来的图在pdf中斜线会变成断断续续的。
绘图代码如下
public void paintImage()
    {
BufferedImage image = new BufferedImage(500, 150,BufferedImage.TYPE_INT_RGB);
Graphics2D g=null;
if(image!=null)
   {
              g=image.createGraphics();
            }  
image = g.getDeviceConfiguration().createCompatibleImage(500, 150, Transparency.TRANSLUCENT);
g.dispose();
g = image.createGraphics();
g.setColor(Color.black);
  Line2D.Double xZuoBiao=new Line2D.Double(30,120,490,120);
  Line2D.Double yZuoBiao=new Line2D.Double(30,120,30,30);
  Line2D.Double x1P=new Line2D.Double(105,120,105,117);
  Line2D.Double x2P=new Line2D.Double(180,120,180,117);
  Line2D.Double x3P=new Line2D.Double(255,120,255,117);
  Line2D.Double x4P=new Line2D.Double(330,120,330,117);
  Line2D.Double x5P=new Line2D.Double(405,120,405,117);
  Line2D.Double x6P=new Line2D.Double(480,120,480,117);
  Line2D.Double y1P=new Line2D.Double(30,105,34,105);
  Line2D.Double y2P=new Line2D.Double(30,90,34,90);
  Line2D.Double y3P=new Line2D.Double(30,75,34,75);
  Line2D.Double y4P=new Line2D.Double(30,60,34,60);
  Line2D.Double y5P=new Line2D.Double(30,45,34,45);
  Line2D.Double y6P=new Line2D.Double(30,30,34,30);
  int dx=(int)(Math.round(forceNum[0]/10)*10);
  int dy=10;
   
  Point2D.Double p1=new Point2D.Double(forceNum[0]*75/dx+30,120-getAverNumAtPosition(0)*15/dy);
  Point2D.Double p2=new Point2D.Double(forceNum[1]*75/dx+30,120-getAverNumAtPosition(1)*15/dy);
  Point2D.Double p3=new Point2D.Double(forceNum[2]*75/dx+30,120-getAverNumAtPosition(2)*15/dy);
  Point2D.Double p4=new Point2D.Double(forceNum[3]*75/dx+30,120-getAverNumAtPosition(3)*15/dy);
  Point2D.Double p5=new Point2D.Double(forceNum[4]*75/dx+30,120-getAverNumAtPosition(4)*15/dy);
  Line2D.Double line1=new Line2D.Double(p1,p2);
  Line2D.Double line2=new Line2D.Double(p2,p3);
  Line2D.Double line3=new Line2D.Double(p3,p4);
  Line2D.Double line4=new Line2D.Double(p4,p5);
  Rectangle2D.Double rect1=new Rectangle2D.Double(2,2,496,146);
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON
); 
  g.setStroke(new BasicStroke(1.0f,BasicStroke.CAP_ROUND,BasicStroke.JOIN_MITER,10.0f));
  g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.75f));
  g.draw(rect1);
  g.draw(xZuoBiao);
  g.draw(yZuoBiao);
  g.draw(x1P);
  g.draw(x2P);
  g.draw(x3P);
  g.draw(x4P);
  g.draw(x5P);
  g.draw(x6P);
  g.draw(y1P);
  g.draw(y2P);
  g.draw(y3P);
  g.draw(y4P);
  g.draw(y5P);
  g.draw(y6P);
  
  g.draw(line1);
  g.draw(line2);
  g.draw(line3);
  g.draw(line4);
  g.drawString("0",30,140);
  g.drawString(""+dx,100,140);
  g.drawString(""+2*dx,175,140);
  g.drawString(""+3*dx,250,140);
  g.drawString(""+4*dx,325,140);
  g.drawString(""+5*dx,400,140);
  g.drawString(""+6*dx,475,170);
  g.drawString("0",10,120);
  g.drawString(""+dy,10,105);
  g.drawString(""+2*dy,10,90);
  g.drawString(""+3*dy,10,75);
  g.drawString(""+4*dy,10,60);
  g.drawString(""+5*dy,10,45);
  g.drawString(""+6*dy,10,30);
  g.drawString("kN",220,145);
  g.drawString("MPa",1,20);
  g.setColor(Color.blue);
   Ellipse2D.Double p1p=new Ellipse2D.Double(p1.x-2.2,p1.y-2.2,4.4,4.4);
   Ellipse2D.Double p2p=new Ellipse2D.Double(p2.x-2.2,p2.y-2.2,4.4,4.4);
   Ellipse2D.Double p3p=new Ellipse2D.Double(p3.x-2.2,p3.y-2.2,4.4,4.4);
   Ellipse2D.Double p4p=new Ellipse2D.Double(p4.x-2.2,p4.y-2.2,4.4,4.4);
   Ellipse2D.Double p5p=new Ellipse2D.Double(p5.x-2.2,p5.y-2.2,4.4,4.4);
   g.fill(p1p);
   g.fill(p2p);
   g.fill(p3p);
   g.fill(p4p);
   g.fill(p5p);
   g.dispose();
try{
   ImageIO.write(image, "png", new File(SoftPath.getSrcPath()+"\\modelFile\\datatable\\temp.png"));}
    catch(Exception e){}
 } 各位高手看看是什么原因。