In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how Java draws graphics in PPT. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Microsoft PowerPoint can support the insertion of various types of graphics in slides and can set graphic fill, line color, graphic size, location, and so on. The following will demonstrate the method of drawing graphics in PPT through Java programming.
Tool: Free Spire.Presentation for Java
Jar file import method 1: download through the official website.
Step1: create a new Directory directory in the program and name it lib; and copy the Spire.Presentation.jar in the control package (available in the lib file under the unzipped control package) directly under that directory.
Step2: select the copied Spire.Presentation.jar file, right-click, and select "Add as library". Complete the reference.
Jar file import method 2: install through Maven warehouse.
Java code example (for reference)
Import com.spire.presentation.*; import com.spire.presentation.drawing.*; import javax.imageio.ImageIO; import java.awt.*; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.File; public class CreateShapes_PPT {public static void main (String [] args) throws Exception {/ / create PowerPoint document Presentation presentation = new Presentation () / / add a triangle and set the monochrome fill IAutoShape shape = presentation.getSlides (). Get (0). GetShapes (). AppendShape (ShapeType.TRIANGLE, new Rectangle2D.Double (115,130,100,100); shape.getFill (). SetFillType (FillFormatType.SOLID); shape.getFill (). GetSolidColor (). SetColor (Color.orange); shape.getShapeStyle (). GetLineColor (). SetColor (Color.white) / / add an ellipse and set the picture to be filled with shape = presentation.getSlides (). Get (0). GetShapes (). AppendShape (ShapeType.ELLIPSE, new Rectangle2D.Double (290,130,150,100); shape.getFill (). SetFillType (FillFormatType.PICTURE); shape.getFill (). GetPictureFill (). SetFillType (PictureFillType.STRETCH); BufferedImage image = ImageIO.read (new File ("logo.png")) Shape.getFill (). GetPictureFill (). GetPicture (). SetEmbedImage (presentation.getImages (). Append (image)); shape.getShapeStyle (). GetLineColor (). SetColor (Color.white); / / add a heart and set the hatch shape = presentation.getSlides (). Get (0). GetShapes (). AppendShape (ShapeType.HEART, new Rectangle2D.Double (515,130,130,100); shape.getFill (). SetFillType (FillFormatType.PATTERN) Shape.getFill (). GetPattern (). SetPatternType (PatternFillType.LARGE_GRID); shape.getShapeStyle (). GetLineColor (). SetColor (Color.white); / / add a pentagram and set a gradient fill shape = presentation.getSlides (). Get (0). GetShapes (). AppendShape (ShapeType.FIVE_POINTED_STAR, new Rectangle2D.Double (115,300,115,115); shape.getFill (). SetFillType (FillFormatType.GRADIENT) Shape.getFill (). GetGradient (). GetGradientStops (). Append (0, KnownColors.RED); shape.getFill (). GetGradient (). GetGradientStops (). Append (1, KnownColors.LIGHT_SALMON); shape.getShapeStyle (). GetLineColor (). SetColor (Color.white); / / add a rectangle and set the gradient fill shape = presentation.getSlides (). Get (0). GetShapes (). AppendShape (ShapeType.HEXAGON, new Rectangle2D.Double (290,300,140125)) Shape.getFill (). SetFillType (FillFormatType.GRADIENT); shape.getFill (). GetGradient (). GetGradientStops (). Append (0, KnownColors.LIGHT_PINK); shape.getFill (). GetGradient (). GetGradientStops (). Append (1, KnownColors.LIGHT_SKY_BLUE); shape.getShapeStyle (). GetLineColor (). SetColor (Color.white) Add an upward arrow and set the gradient fill shape = presentation.getSlides (). Get (0). GetShapes (). AppendShape (ShapeType.DOUBLE_WAVE, new Rectangle2D.Double (515,300,130,100); shape.getFill (). SetFillType (FillFormatType.GRADIENT); shape.getFill (). GetGradient (). GetGradientStops (). Append (1f, KnownColors.OLIVE); shape.getFill (). GetGradient (). GetGradientStops (). Append (0, KnownColors.POWDER_BLUE) Shape.getShapeStyle (). GetLineColor (). SetColor (Color.white); / / Save the document presentation.saveToFile ("AddShapes.pptx", FileFormat.PPTX_2010);}} Thank you for reading! This is the end of this article on "how to draw graphics in Java in PPT". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.