@Override public List<Object> apply(Object o) { if (o instanceof Drawing) { Object o2 = ((Drawing)o).getAnchorOrInline().get(0); if (o2 instanceof Anchor) { extent = ((Anchor)o2).getExtent(); return null; } if (o2 instanceof Inline) { extent = ((Inline)o2).getExtent(); return null; } } return null; }
/** * Create an instance of {@link Drawing } * */ public Drawing createDrawing() { return new Drawing(); }
/** * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. * * @param parent * The parent object in the object tree. * @param unmarshaller * The unmarshaller that generated the instance. */ public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { setParent(parent); }
org.docx4j.wml.Drawing drawing = factory.createDrawing(); run.getContent().add(drawing); drawing.getAnchorOrInline().add(inline);
/** * Create an instance of {@link Drawing } * */ public Drawing createDrawing() { return new Drawing(); }
/** * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. * * @param parent * The parent object in the object tree. * @param unmarshaller * The unmarshaller that generated the instance. */ public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { setParent(parent); }
drawing.getAnchorOrInline().add(inline);
org.docx4j.wml.Drawing drawing = docx.getFactory().createDrawing(); run.getContent().add(drawing); drawing.getAnchorOrInline().add(inline); return run; } catch (Exception e) {
Drawing instance=new Drawing(); frame.add(instance); frame.addKeyListener(instance);
@Override public List<Object> apply(Object o) { if (o instanceof Drawing) { Object o2 = ((Drawing)o).getAnchorOrInline().get(0); if (o2 instanceof Anchor) { extent = ((Anchor)o2).getExtent(); return null; } if (o2 instanceof Inline) { extent = ((Inline)o2).getExtent(); return null; } } return null; }
public class Game extends JFrame implements ActionListener { Drawing object = new Drawing(); Timer t = new Timer(1, this); int score; ArrayList<Enemy> bombs = new ArrayList<Enemy>(); public Game() { t.start(); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(700, 600); add(object); add(new JLabel("Hello")); validate(); createBombs(); setVisible(true); } }
/** * We create an object factory and use it to create a paragraph and a run. * Then we add the run to the paragraph. Next we create a drawing and * add it to the run. Finally we add the inline object to the drawing and * return the paragraph. * * @param inline The inline object containing the image. * @return the paragraph containing the image */ private static P addInlineImageToParagraph(Inline inline) { // Now add the in-line image to a paragraph org.docx4j.wml.ObjectFactory factory = new org.docx4j.wml.ObjectFactory(); P paragraph = factory.createP(); R run = factory.createR(); paragraph.getContent().add(run); Drawing drawing = factory.createDrawing(); run.getContent().add(drawing); drawing.getAnchorOrInline().add(inline); return paragraph; }
public static Drawing deepClone(Drawing drawing) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(drawing.shapes); //Serializes the drawing.shapes ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); return new Drawing((LinkedList<Shape>)ois.readObject()); //Deserializing and reading } catch (IOException e) { return null; } catch (ClassNotFoundException e) { return null; } }
public static R createRunWithImage(WordprocessingMLPackage wordMLPackage, byte[] bytes, String filenameHint, String altText, Integer maxWidth) throws Exception { BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes); // creating random ids assuming they are unique // id must not be too large, otherwise Word cannot open the document int id1 = random.nextInt(100000); int id2 = random.nextInt(100000); if (filenameHint == null) { filenameHint = "dummyFileName"; } if (altText == null) { altText = "dummyAltText"; } Inline inline; if (maxWidth == null) { inline = imagePart.createImageInline(filenameHint, altText, id1, id2, false); } else { inline = imagePart.createImageInline(filenameHint, altText, id1, id2, false, maxWidth); } // Now add the inline in w:p/w:r/w:drawing org.docx4j.wml.ObjectFactory factory = new org.docx4j.wml.ObjectFactory(); org.docx4j.wml.R run = factory.createR(); org.docx4j.wml.Drawing drawing = factory.createDrawing(); run.getContent().add(drawing); drawing.getAnchorOrInline().add(inline); return run; }
public static void createGUI(){ JFrame frame = new JFrame("My Frame"); JComponent component = new Drawing(); component.setOpaque(true); frame.add(component); frame.setSize(600,400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
Drawing drawing = factory.createDrawing(); run.getRunContent().add(drawing); drawing.getAnchorOrInline().add(inline);
import javax.swing.JFrame; import javax.swing.JPanel; @SuppressWarnings("serial") public class Main extends JPanel{ public static void main(String[] args) { JFrame jf = new JFrame("Matrix raining code - by Ran Galili"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setSize(700,700); jf.setResizable(false); jf.add(new Drawing()); jf.setVisible(true); } }
Drawing drawing = factory.createDrawing(); run.getContent().add(drawing); drawing.getAnchorOrInline().add(inline); return paragraph;